Christian Jann avatar Christian Jann committed 8a40121 Draft Merge

Merged with Tinkerer

Comments (0)

Files changed (5)

tinkerer/__templates/conf.py

 # linked directly
 rss_service = None
 
-# generate rss feed for categories?
-rss_for_categories = False
-# list of categories to generate rss feed (otherwise all)
-#rss_categories_to_build = ["my category", "other category"...]
-
-# generate rss feed for tags?
-rss_for_tags = False
-# list of tags to generate rss feed (otherwise all)
-#rss_tags_to_build = ["tag1", "tag2"...]
-
 # Number of blog posts per page
 posts_per_page = 2
 

tinkerer/ext/blog.py

     '''
     Generates additional pages.
     '''
-    for name, context, template in rss.generate_all_feed(app):
-        yield (name, context, template)
-
-    for name, context, template in rss.generate_feed_for_categories(app):
-        yield (name, context, template)
-
-    for name, context, template in rss.generate_feed_for_tags(app):
+    for name, context, template in rss.generate_feed(app):
         yield (name, context, template)
 
     for name, context, template in filing.make_tag_pages(app):
     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)
-    app.add_config_value("rss_for_categories", False, True)
-    app.add_config_value("rss_categories_to_build", None, True)
-    app.add_config_value("rss_for_tags", False, True)
-    app.add_config_value("rss_tags_to_build", None, True)
     
     # new directives
     app.add_directive("author", author.AuthorDirective)

tinkerer/ext/filing.py

 
 
 
-def make_archive_page(env, title, pagename, post_filter=None, context=None):
+def make_archive_page(env, title, pagename, post_filter=None):
     '''
     Generates archive page with given title by applying the given filter to
     all posts and aggregating results by year.
     '''
-    context = context if context is not None else {}
-    context["title"] = title
+    context = { "title": title }
     context["years"] = dict()
 
     for post in filter(post_filter, env.blog_posts):
     '''
     env = app.builder.env
     for tag in env.filing["tags"]:
-        # set rss_feed_link
-        context = None
-        if app.config.rss_for_tags:
-            if not app.config.rss_tags_to_build or \
-                    tag in app.config.rss_tags_to_build:
-                context = {}
-                context["rss_feed_link"] = u"../rss/tags/%s.html" % (
-                    utils.name_from_title(tag),)
         yield make_archive_page(env,
                 UIStr.TAGGED_WITH_FMT % tag,
                 "tags/" + utils.name_from_title(tag),
-                lambda post: post in env.filing["tags"][tag],
-                context)
+                lambda post: post in env.filing["tags"][tag])
 
 
 
     '''
     env = app.builder.env
     for category in env.filing["categories"]:
-        # set rss_feed_link
-        context = None
-        if app.config.rss_for_categories:
-            if not app.config.rss_categories_to_build or \
-                    category in app.config.rss_categories_to_build:
-                context = {}
-                context["rss_feed_link"] = "../rss/categories/%s.html" % (
-                    utils.name_from_title(category),)
         yield make_archive_page(env,
                 UIStr.FILED_UNDER_FMT % category,
                 "categories/" + utils.name_from_title(category),
-                lambda post: post in env.filing["categories"][category],
-                context)
+                lambda post: post in env.filing["categories"][category])
 

tinkerer/ext/rss.py

 import email.utils
 import time
 from tinkerer.ext import patch
-from tinkerer.utils import name_from_title
 
 
 
 
 
 
-def generate_feed(app, name, posts):
+def generate_feed(app):
     '''
     Generates RSS feed.
     '''
     env = app.builder.env
  
     # don't do anything if no posts are available
-    if not posts:
+    if not env.blog_posts:
         return
 
     context = dict()
 
     # feed items
     context["items"] = []
-    for post in posts:
+    for post in env.blog_posts:
         link = "%s%s.html" % (app.config.website, post)
 
         timestamp = email.utils.formatdate(
     # feed pubDate is equal to latest post pubDate
     context["pubDate"] = context["items"][0]["pubDate"]
 
-    return (name, context, "rss.html")
+    yield ("rss", context, "rss.html")
 
-
-
-def generate_all_feed(app):
-    '''
-    Generates all RSS feed.
-    '''
-
-    env = app.builder.env
- 
-    yield generate_feed(app, "rss/all", env.blog_posts)
-
-
-
-def generate_feed_for(app, feed_type="categories"):
-    '''
-    Generates RSS feed for categories or tags.
-    '''
-    env = app.builder.env
- 
-    # only for categories and tags
-    if feed_type not in ("categories", "tags"):
-        return []
-
-    # don't do anything if no posts are available
-    if not env.blog_posts:
-        return []
-
-    # don't do anything if option is not set
-    if (feed_type == "categories" and not app.config.rss_for_categories) or \
-       (feed_type == "tags" and not app.config.rss_for_tags):
-        return []
-
-    context = dict()
-    # posts for categories/tags
-    posts = {}
-
-    # categories or tags to build rss feed
-    list_to_build = app.config.rss_categories_to_build if feed_type == "categories" \
-                    else app.config.rss_tags_to_build
-
-    # get posts by category or tag
-    for post in env.blog_posts:
-        cts = [ct[1] for ct in env.blog_metadata[post].filing[feed_type]]
-        for ct in cts:
-            if not list_to_build or ct in list_to_build:
-                p = posts.setdefault(ct, [])
-                p.append(post)
-
-    return posts
-
-
-
-def generate_feed_for_categories(app):
-    '''
-    Generates RSS feed for categories.
-    '''
-    posts = generate_feed_for(app, "categories") 
-    for ct in posts:
-        name = "rss/%s/%s" % ("categories", name_from_title(ct))
-        yield generate_feed(app, name, posts[ct])
-
-
-
-def generate_feed_for_tags(app):
-    '''
-    Generates RSS feed for tags.
-    '''
-    posts = generate_feed_for(app, "tags") 
-    for ct in posts:
-        name = "rss/%s/%s" % ("tags", name_from_title(ct))
-        yield generate_feed(app, name, posts[ct])

tinkerer/themes/tinkerbase/layout.html

 {%- if rss_service %}
     {%- set rss_feed_link = rss_service %}
 {%- else %}
-    {%- set rss_feed_link = rss_feed_link is defined and rss_feed_link or pathto('rss/all') %}
+    {%- set rss_feed_link = pathto('rss') %}
 {%- endif %}        
 
 {# include RSS feed link in page_nav (default True) #}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.