Commits

dan mackinlay committed b91c8a3 Merge

merge upstream

Comments (0)

Files changed (10)

 
 syntax: regexp
 ^content/
-^_ext/sphinxcontrib/
 ^_cache/
 ===========
   
   * Google reader blogroll
+  * check simulation in mobile devices
   * have nice scripts to crunch photos and diagrams down to web size
   * `look pretty <http://www.smashingmagazine.com/2009/03/18/10-principles-for-readable-web-typography/>`_
-
-    * inc. better formatting for
-      
-      * index lists - too much inernal spacing and not enough external
-      * body text (too big compared to titles)
-      * headings (should not get smaller than body text)
-      * TODO items
-      * nested lists (Too close to item above)
-      * block quotes (not gratuitously pullquotey enough)
-      * view .OBJ 3d files in situ -
-        https://github.com/mrdoob/three.js/blob/master/utils/exporters/convert_obj_threejs_slim.py
-        or http://code.google.com/p/jsc3d/
+  
+    * view .OBJ 3d files in situ via `three.js <https://github.com/mrdoob/three.js/blob/master/utils/exporters/convert_obj_threejs_slim.py>`__ or `jcs3d <http://code.google.com/p/jsc3d/>`__
     
     * friendly homepage setup a la `Proven Corporation <http://www.proven-corporation.com/2008/03/27/sphinx-templates/>`_
     * publish the custom algo theme to other sphinx users.
       * this is easy in template overrides but could be made configurable, and
         use the FB `Javascript SDK
         <http://developers.facebook.com/docs/reference/javascript/>`_
+        
     * amazon affiliate link stuff to pay my book bills.
     * `asynchronous <http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html>`_ analytics tracker
   

_ext/applyxrefs.py

 testing = False
 
 DONT_TOUCH = (
-        './index.txt',
+            './index.txt',
+            './index.rst',
         )
 
 def target_name(fn):

_ext/literals_to_xrefs.py

-"""
-Runs through a reST file looking for old-style literals, and helps replace them
-with new-style references.
-"""
-
-import re
-import sys
-import shelve
-
-refre = re.compile(r'``([^`\s]+?)``')
-
-ROLES = (
-    'attr',
-    'class',
-    "djadmin",
-    'data',
-    'exc',
-    'file',
-    'func',
-    'lookup',
-    'meth',
-    'mod' ,
-    "djadminopt",
-    "ref",
-    "setting",
-    "term",
-    "tfilter",
-    "ttag",
-    
-    # special
-    "skip"
-)
-
-ALWAYS_SKIP = [
-    "NULL",
-    "True",
-    "False",
-]
-
-def fixliterals(fname):
-    data = open(fname).read()
-    
-    last = 0
-    new = []
-    storage = shelve.open("/tmp/literals_to_xref.shelve")
-    lastvalues = storage.get("lastvalues", {})
-    
-    for m in refre.finditer(data):
-        
-        new.append(data[last:m.start()])
-        last = m.end()
-        
-        line_start = data.rfind("\n", 0, m.start())
-        line_end = data.find("\n", m.end())
-        prev_start = data.rfind("\n", 0, line_start)
-        next_end = data.find("\n", line_end + 1)
-        
-        # Skip always-skip stuff
-        if m.group(1) in ALWAYS_SKIP:
-            new.append(m.group(0))
-            continue
-            
-        # skip when the next line is a title
-        next_line = data[m.end():next_end].strip()
-        if next_line[0] in "!-/:-@[-`{-~" and all(c == next_line[0] for c in next_line):
-            new.append(m.group(0))
-            continue
-        
-        sys.stdout.write("\n"+"-"*80+"\n")
-        sys.stdout.write(data[prev_start+1:m.start()])
-        sys.stdout.write(colorize(m.group(0), fg="red"))
-        sys.stdout.write(data[m.end():next_end])
-        sys.stdout.write("\n\n")
-        
-        replace_type = None
-        while replace_type is None:
-            replace_type = raw_input(
-                colorize("Replace role: ", fg="yellow")
-            ).strip().lower()
-            if replace_type and replace_type not in ROLES:
-                replace_type = None
-        
-        if replace_type == "":
-            new.append(m.group(0))
-            continue
-            
-        if replace_type == "skip":
-            new.append(m.group(0))
-            ALWAYS_SKIP.append(m.group(1))
-            continue
-        
-        default = lastvalues.get(m.group(1), m.group(1))
-        if default.endswith("()") and replace_type in ("class", "func", "meth"):
-            default = default[:-2]        
-        replace_value = raw_input(
-            colorize("Text <target> [", fg="yellow") + default + colorize("]: ", fg="yellow")
-        ).strip()
-        if not replace_value: 
-            replace_value = default
-        new.append(":%s:`%s`" % (replace_type, replace_value))
-        lastvalues[m.group(1)] = replace_value
-    
-    new.append(data[last:])
-    open(fname, "w").write("".join(new))
-    
-    storage["lastvalues"] = lastvalues
-    storage.close()
-    
-#
-# The following is taken from django.utils.termcolors and is copied here to
-# avoid the dependancy.
-#
-
-
-def colorize(text='', opts=(), **kwargs):
-    """
-    Returns your text, enclosed in ANSI graphics codes.
-
-    Depends on the keyword arguments 'fg' and 'bg', and the contents of
-    the opts tuple/list.
-
-    Returns the RESET code if no parameters are given.
-
-    Valid colors:
-        'black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'
-
-    Valid options:
-        'bold'
-        'underscore'
-        'blink'
-        'reverse'
-        'conceal'
-        'noreset' - string will not be auto-terminated with the RESET code
-
-    Examples:
-        colorize('hello', fg='red', bg='blue', opts=('blink',))
-        colorize()
-        colorize('goodbye', opts=('underscore',))
-        print colorize('first line', fg='red', opts=('noreset',))
-        print 'this should be red too'
-        print colorize('and so should this')
-        print 'this should not be red'
-    """
-    color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white')
-    foreground = dict([(color_names[x], '3%s' % x) for x in range(8)])
-    background = dict([(color_names[x], '4%s' % x) for x in range(8)])
-
-    RESET = '0'
-    opt_dict = {'bold': '1', 'underscore': '4', 'blink': '5', 'reverse': '7', 'conceal': '8'}
-
-    text = str(text)
-    code_list = []
-    if text == '' and len(opts) == 1 and opts[0] == 'reset':
-        return '\x1b[%sm' % RESET
-    for k, v in kwargs.iteritems():
-        if k == 'fg':
-            code_list.append(foreground[v])
-        elif k == 'bg':
-            code_list.append(background[v])
-    for o in opts:
-        if o in opt_dict:
-            code_list.append(opt_dict[o])
-    if 'noreset' not in opts:
-        text = text + '\x1b[%sm' % RESET
-    return ('\x1b[%sm' % ';'.join(code_list)) + text
-
-if __name__ == '__main__':
-    try:
-        fixliterals(sys.argv[1])
-    except (KeyboardInterrupt, SystemExit):
-        print

_templates/layout.html

 
 {%- block content %}
   {{ super() }}
-  <iframe src="http://www.facebook.com/plugins/like.php?href&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;font&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>
-{%- endblock %}
-
-
-{# empty crap out #}
-{% block tables %}{% endblock %}
-
-{# {% set script_files = script_files + [pathto("_static/myscript.js", 1)] %} #}
-
-{% block document %}
-  {{ super() }}
+  <!-- Google plus pt 2 BEGIN -->
+  <div class="socialbutton"><g:plusone></g:plusone></div>
+  <!-- Google plus pt 2 END -->
+  <br/>
+  <!-- Facebook Like BEGIN -->
+  <div class="socialbutton"><iframe src="http://www.facebook.com/plugins/like.php?app_id=103860279662004&amp;send=false&amp;layout=button_count&amp;width=80&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:80px; height:21px;" allowTransparency="true"></iframe></div>
+  <!-- Facebook Like END -->
   {% block comments %}
-  <!-- google analytics BEGIN -->
-  <script type="text/javascript">
-    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
-    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
-   </script>
-  <script type="text/javascript">
-    try {
-       var pageTracker = _gat._getTracker("{{ google_analytics_key }}");
-       pageTracker._trackPageview();
-     } catch(err) {}
-  </script>
-  <!-- google analytics END -->
-  <!-- AddThis Button BEGIN -->
-  <a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;pub={{ addthis_key }}">
-    <img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/>
-  </a>
-  <script type="text/javascript">
-     var addthis_config = {
-        data_ga_tracker: pageTracker
-     };
-  </script>
-  <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pub={{ addthis_key }}"></script>
-  <!-- AddThis Button END -->
   <!-- Disqus pt 2 BEGIN -->
-  <div id="disqus_wrapper">
+  <div id="disqus_wrapper" class="aligner">
     <div id="disqus_thread"></div>
     <script type="text/javascript" src="http://disqus.com/forums/{{ disqus_forum_name }}/embed.js"></script>
     <noscript><a href="http://disqus.com/forums/{{ disqus_forum_name }}/?url=ref">View the discussion thread.</a></noscript>
   </div>
   <!-- Disqus pt 2 END -->
   {% endblock %}
-{% endblock %}
+  
+{%- endblock %}
+
+
+{# empty crap out #}
+{% block tables %}{% endblock %}
+
+{# {% set script_files = script_files + [pathto("_static/myscript.js", 1)] %} #}
 
 {% block footer %}
   {{ super() }}
   //]]>
   </script>
   <!-- Disqus pt 1 END -->
+  <!-- Google plus pt 1 BEGIN -->
+  <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
+  <!-- Google plus pt 1 END -->  
+  <!-- google analytics BEGIN -->
+  <script type="text/javascript">
+    var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+    document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+   </script>
+  <script type="text/javascript">
+    try {
+       var pageTracker = _gat._getTracker("{{ google_analytics_key }}");
+       pageTracker._trackPageview();
+     } catch(err) {}
+  </script>
+  <!-- google analytics END -->
 {% endblock %}

_themes/algo/layout.html

 {#     VERSION:    '{{ release }}' #}
 {#   }; #}
 {# </script> #}
-{# <script type="text/javascript" src="{{ pathto('_static/jquery.js', 1) }}"></script> #}
-{# <script type="text/javascript" src="{{ pathto('_static/doctools.js', 1) }}"></script> #}
-{# <link media="(max-device-width: 480px)" href="{{ pathto('_static/mobile.css', 1) }}" type="text/css" rel="stylesheet" /> #}
 <script type="text/javascript" src="{{ pathto('_static/algo.js', 1) }}"></script>
 <link media="(max-width: 480px)" href="{{ pathto('_static/mobile.css', 1) }}" type="text/css" rel="stylesheet" />
 <link rel="alternate" type="application/rss+xml" title="RSS" href="{{ rss_link }}">
       </form>
     </div>
     {%- endblock %}
-    {# {%- block dropdownlocaltoc %} #}
-    {#   {%- if display_toc %} #}
-    {#     <div class="dropdown localtoc"> #}
-    {#       <h3>{{ _('Article Contents') }}</h3> #}
-    {#       {{ toc }} #}
-    {#     </div> #}
-    {#   {%- endif %} #}
-    {# {%- endblock %} #}
     
     {# naked content here. no sense wrapping it, it's already triple wrapped #}
     {%- block body %}
       {{ super() }}
     {%- endblock %}
+    
+    {%- if meta %}
+      {%- if meta.date %}
+        <time>
+          Last changed: {{ meta.date }}
+        </time>
+      {%- endif %}
+    {%- endif %}
+    
+    
   </div>
 {% endblock %}
 

_themes/algo/static/algo.css_t

 */
 body {
   font-family: {{ theme_bodyfont }};
-  font-size: 14px;
   color: black;
   background-color: {{ theme_bgcolor }};
 }
 body h1, body h2, body h3, body h4 {
   font-family: {{ theme_headerfont }};
   font-weight: normal;
+  font-style: {{ theme_headerfontstyle }};
   color: {{ theme_headercolor2 }};
-  margin-bottom: .8em;
+  margin-top: 1.1em;
+  margin-bottom: 0.7em;
+}
+
+.section h2, .section h3, .section h4, .section h5, .section h6 {
+  padding-right: 2em;
+  padding-bottom: 0.3em;
+  padding-left: 1ex;
+  border-bottom: 1px solid {{ theme_headercolor2 }};
+  display: inline;
+}
+
+.content .section h2+*, .content .section h3+*, .content .section h4+*, .content .section h5+*, .content .section h6+* {
+  margin-top: 1.5em;
 }
 
 body h1 {
   color: {{ theme_headercolor1 }};
 }
 
-body h2 {
-  padding-bottom: .5em;
-  border-bottom: 1px solid {{ theme_headercolor2 }};
-}
-
 a.headerlink {
   visibility: hidden;
   color: #dddddd;
 
 div.header div.rel a {
   color: {{ theme_headerlinkcolor }};
-  letter-spacing: .1em;
   text-transform: uppercase;
 }
 
     border: 0;
 }
 
-/*-------------------------body text styles ----------------------------*/
+/*----------------------body + menu text styles -------------------------*/
+
+/* NB - to get just the menu use .toctree-wrapper, since the both end up in
+ .section*/
 
 div.content{
   background-color: white;
   padding-bottom: 20px;
   /*padding-right: 2em;*/
   text-align: left;
+  font-size: 16px;
+}
+div.content em {
+  font-style: italic;
+}
+div.content .section .toctree-wrapper ul {
+    margin-bottom: 0;
 }
 
-div.content .toctree-wrapper ul li {
+div.content .section .toctree-wrapper ul li {
     list-style-type: disc;
     padding-left: 2em;
     text-indent: -2em;
-/*    margin-left: 2em;
-*/}
-
+    margin-top: 0.3ex;
+    margin-bottom: 0.3ex;
+}
 div.content .citation {
   border-left: 1px solid #444;
   font-size: 100%;
     padding-right: 1em;
 }
 
-div.content p {
-  line-height: 1.4em;
-}
-
 div.content ul {
-  margin-left: 1.2em;
+  margin-left: 0.6em;
+  margin-top: 0.3em;
+  margin-bottom: 0.em;
 }
 div.content ul li {
-  list-style-type: square;
   margin-bottom: 0.2em;
 }
 
   margin-bottom: 1em;
 }
 
+/*---------------------- body text styles -------------------------*/
+
+/* I'd really prefer to suppress Sphinx's <em> insertion by stopping it.*/
+div.content a.reference em { font-style: normal; }
+
 div.content .section {
   margin-top: 1.7em;
   margin-bottom: 1.0em;
 }
+
+div.content .section p, div.content .section ul, div.content .section ol {
+  line-height: 1.6em;
+}
+
+/*in-text lists. Not too specific, or the overrides don't work*/
+div.content ul {
+  margin: 0.5em 2em 0.5em 0.5em;
+}
+div.content .section ul ul {
+  margin-top: 0;
+  margin-bottom: 0;
+}
+
+div.content .section li {
+  margin-bottom: 1ex;
+  margin-top: 1ex;
+  margin-left: 1em;
+}
+
+div.content .section ul li {
+  list-style-type: square;
+}
+
+div.content .section ol li {
+  list-style-type: decimal;
+}
+
+div.content .section h1, div.content .section h2, div.content .section h3, div.content .section h4, div.content .section h5, div.content .section h6 {
+  margin-left: -1ex;
+}
+
 div.content .section:first-child {
   margin-top: 0px;
 }
   margin-top: .8em;
   margin-bottom: .8em;
 }
-
-div.content h2 {
-  margin-top: .7em;
+div.content .section p, div.content .section blockquote, div.content .section ul, div.content .section ol {
+  font-size: 16px;
 }
-
-div.content p, div.content blockquote {
-  margin-bottom: .5em;
+div.content p {
+  margin-bottom: 1.5ex;
+  margin-top: 1.5ex;
 }
 
 div.content blockquote {
-  padding-left: 4em;
-  padding-right: 4em;
-  border-left: 1em solid #555;
+  margin-bottom: 0.5ex;
+  margin-top: 0.5ex;
+  padding: 0.7em 1em 0.3em 1.5em;
+  border-left: 1em solid #BBB;
+  border-bottom: 3px solid #BBB;
+  background-color: #DDD;
 }
 
-div.content li.toctree-l1 {
+/*div.content li.toctree-l1 {
   margin-bottom: 1em;
-}
+}*/
 
 div.content .descname {
   font-weight: bold;
   padding-right: 0.5em;
   font-style: normal;
 }
-
-div.content table.footnote {
-  border-top: 1px solid #000;
-  font-size: .83em ;
+div.content .section .footnote td p {
+  max-width: none;
+}
+/* p elements sometimes appear in the footnotes, adn other times not. this is painful for styling */
+div.content table.footnote td, div.content table.footnote td p {
+  font-size: 13px ;
   font-style: italic;
 }
 
   font-size: .83em ; vertical-align: super;
 }
 
-
+div.content time {
+  font-style: italic;
+  text-align: right;
+  display: block;
+  font-size: 80%;
+}
 /* Dropdowns */
 .dropdown .collapsed {
 /*  color: #F00;*/
 
 div.dropdown h3 {
   color: #2e3436;
-  text-transform: uppercase;
+  font-variant: small-caps;
   font-size: 130%;
-  letter-spacing: .1em;
   margin-bottom: 0;
   margin-top: 0.3em;
 }
   border-top: 1px dashed {{ theme_headerlinkcolor }};
   border-bottom: 1px dashed {{ theme_headerlinkcolor }};*/
   font-weight: bold;
-  list-style-type: square
+  list-style-type: none;
+  font-style: italic;
 }
 
 div.dropdown li.current li {
   font-weight: normal;
-  list-style-type: none
+  font-style: italic;
+  list-style-type: none;
 }
 
 div.dropdown li.current li.toctree-l2 a {

_themes/algo/theme.conf

 [theme]
 inherit = basic
 stylesheet = default.css
-pygments_style = tango
+pygments_style = default
 
 [options]
-bodyfont = "Verdana", Arial, sans-serif
-headerfont = "Georgia", "Times New Roman", serif
+bodyfont = Georgia, "Times New Roman", serif
+headerfont = "Hoefler Text", "Palatino Linotype", "Book Antiqua", serif
+headerfontstyle = italic
 pagewidth = 100%
-documentwidth = 40em
+documentwidth = 75ex
 dropdownwidth = 100%
 #bgcolor = #eeeeec
 bgcolor = #ffffff 
-headerbg = url(bgtop.png) top left repeat-x
-footerbg = url(bgfooter.png) top left repeat-x
+headerbg = url(bgtop.jpg) top left repeat-x
+footerbg = none
 #footercolor = #888a85
 footercolor = #111111
 linkcolor = #ce5c00
 
 # General information about the project.
 project = u'Possum Palace'
-copyright = u'2010, Dan MacKinlay except where otherwise specified'
+copyright = u'2011, Dan MacKinlay except where otherwise specified'
 
 publicness = 'public'
 
 #show_authors = False
 
 # The name of the Pygments (syntax highlighting) style to use.
-pygments_style = 'sphinx'
+pygments_style = 'default'
 
 # A list of ignored prefixes for module index sorting.
 #modindex_common_prefix = []
     ),
     sitemap_gen=Bunch(
         # Where is the config file for sitemap_gen.py?
-        config=getattr(conf, 'sitemap_gen_config', 'content/sitemap_gen_config.xml')
+        sitemap_config=getattr(conf, 'sitemap_gen_config', 'content/sitemap_gen_config.xml'),
+        sitemap_output=getattr(conf, 'sitemap_gen_output', 'content/sitemap.xml')        
     ),
 )
 
     author_email="possumpalace@email.possumpalace.org"
 )
 
-def _get_cul(options=None):
-    if options is None: options=globals()['options']
-    from citeulike.citeulike_api import CiteULike
-    
-    outjsonpath = path(options.docroot)/options.bibtex_json_file
-    if os.path.isabs(options.attachment_path):
-        outpdfpath = path(options.attachment_path)
-    else:
-        outpdfpath = path(options.docroot)/options.attachment_path
-
-    cul = CiteULike(username=options.cul_username,
-      password=options.cul_pass,
-      json_cache=outjsonpath,
-      attachment_path=outpdfpath
-    )
-    cul.cache_records()
-    return cul
-    
 @task
 def update_sphinx_contrib():
-    """uses setuptools to install the relevent sphinxcontrib thingy.
+    """uses setuptools to install the relevent sphinxcontrib thingies.
     (You want to be in the right virtualenv before running this.)
     """
-    contrib_ext_name = 'feed'
+    contrib_ext_names = ['feed']
     if options.sphinx_contrib_path.exists() and options.sphinx_contrib_path.isdir() and \
       (options.sphinx_contrib_path/".hg").exists():
         with pushd(options.sphinx_contrib_path) as old_dir:
             sh("""
             hg clone %s %s
             """ % (options.sphinx_contrib_repos_url, options.sphinx_contrib_path.basename()))
-    with pushd(options.sphinx_contrib_path/
-      contrib_ext_name) as old_dir:
-        sh("pip install .")
+    for contrib_ext_name in contrib_ext_names:
+        with pushd(options.sphinx_contrib_path/
+          contrib_ext_name) as old_dir:
+            sh("pip install .")
 
 
 @task
     #http://forum.webfaction.com/viewtopic.php?id=4922
     with pushd(options.htmldir) as old_dir:
         sh('ln -sf feed.rss rss.xml')
-    sh("rsync -avz --delete %s %s@%s:%s/" % (options.htmldir,
+    sh("rsync -avz --delete --exclude=%s %s %s@%s:%s/" % (options.sitemap_output, options.htmldir,
             options.username, options.host, options.hostpath))
     sh("open %s" % options.siteurl)
 
 @task
 @needs(['clean_build', 'html'])
 def rebuild_html():
-    """i do this so often when themeing"""
+    """i do this so often when themeing
+    TODO: work out how to use sphinx's "ignore environment" option, -E
+    """
     pass
 
 @task