Commits

Christian Jann committed 35bd910

Added author_url, .. author_url::

# Specify a URL that should rank high on Google for the author name
# e.g. your website or your Google+ profile
author_url = 'http://your-name.com';

Comments (0)

Files changed (8)

tinkerer/__templates/conf.py

 # Change this to your name
 author = 'Winston Smith'
 
+# Specify a URL that should rank high on Google for the author name
+# e.g. your website or your Google+ profile
+#author_url = 'http://your-name.com'
+
 # Change this to your copyright string
 copyright = '1984, ' + author         
 

tinkerer/__templates/post.rst

 {{ content }}
 
 .. author:: {{ author }}
+.. author_url:: {{ author_url }}
 .. categories:: {{ categories }}
 .. tags:: {{ tags }}
 .. comments::
             { "title"     : title,
               "content"   : "",
               "author"    : "default",
+              "author_url": "default",
               "categories": "none",
               "tags"      : "none"})
 

tinkerer/ext/author.py

 
         return []
 
+class AuthorUrlDirective(Directive):
+    '''
+    Author URL directive. The directive is not rendered, just stored in the
+    metadata and passed to the templating engine.
+    '''
+    required_arguments = 0
+    optional_arguments = 100
+    has_content = False
 
+    def run(self):
+        '''
+        Called when parsing the document.
+        '''
+        env = self.state.document.settings.env
+
+        # store author in metadata
+        author_url = " ".join(self.arguments)
+        if author_url == "default":
+            author_url = env.config.author_url
+        env.blog_metadata[env.docname].author_url = author_url
+
+        return []
     app.add_config_value("tagline", "My blog", True)
     app.add_config_value("description", "My blog", True)
     app.add_config_value("author", "Winston Smith", True)
+    app.add_config_value("author_url", None, True)
     app.add_config_value("rss_service", None, True)
     app.add_config_value("website", "http://127.0.0.1/blog/html/", True)
     app.add_config_value("posts_per_page", 10, True)
     
     # new directives
     app.add_directive("author", author.AuthorDirective)
+    app.add_directive("author_url", author.AuthorUrlDirective)
     app.add_directive("comments", metadata.CommentsDirective)
     app.add_directive("tags", 
             filing.create_filing_directive("tags"))

tinkerer/ext/metadata.py

         self.formatted_date_short = None
         self.body = None
         self.author = None
+        self.author_url = None
         self.filing = { "tags": [], "categories": [] }
         self.comments, self.comment_count = False, False
         self.num = Metadata.num
 
 
 
-    def write(self, content="", author="default", 
+    def write(self, content="", author="default", author_url="default",
             categories="none", tags="none"):
         '''
         Writes the post template with given arguments.
                { "title"     : self.title,
                  "content"   : content,
                  "author"    : author,
+                 "author_url": author_url,
                  "categories": categories,
                  "tags"      : tags})
 

tinkerer/themes/boilerplate/layout.html

 {%- endmacro -%}
 
 {#- Author -#}
-{%- macro author(author_name) -%}
+{%- macro author(author_name, author_url) -%}
     {%- if author_name -%}
         <div class="author">
+            {%- if author_url -%}
+            <span>{{ text_posted_by }} <a href="{{ author_url }}">{{ author_name }}</a></span>
+            {%- else -%}
             <span>{{ text_posted_by }} {{ author_name }}</span>
+            {%- endif -%}
         </div>
     {%- endif -%}
 {%- endmacro -%}
 {#- Post metadata -#}
 {%- macro post_meta(metadata, comment_count_code=None) -%}
     <div class="postmeta">
-        {{ author(metadata.author) }}
+        {{ author(metadata.author, metadata.author_url) }}
         {{ category_list(metadata.filing["categories"]) }}
         {{ tag_list(metadata.filing["tags"]) }}
         {{ comment_count(comment_count_code) }}