Permalink
Browse files

updated to work with blogofile 0.8.1

  • Loading branch information...
1 parent a04bc6a commit 543223439fa48a3b91aeea77f1e59a611a067597 @arturoc arturoc committed Mar 3, 2013
Showing with 21 additions and 640 deletions.
  1. +4 −2 _config.py
  2. +0 −43 _controllers/blog/__init__.py
  3. +0 −38 _controllers/blog/archives.py
  4. +0 −82 _controllers/blog/categories.py
  5. +0 −55 _controllers/blog/chronological.py
  6. +0 −16 _controllers/blog/feed.py
  7. +0 −38 _controllers/blog/permapage.py
  8. +0 −342 _controllers/blog/post.py
  9. +1 −1 _controllers/community.py
  10. +3 −3 _controllers/documentation.py
  11. +10 −5 _controllers/tutorials.py
  12. 0 _filters/{asciidoc_template.py → asciidoc_template/__init__.py}
  13. 0 _filters/{ → asciidoc_template}/asciidoc
  14. 0 _filters/{ → asciidoc_template}/asciidoc.conf
  15. +2 −1 _filters/{ → asciidoc_template}/asciidocapi.py
  16. BIN _filters/{ → asciidoc_template}/asciidocc
  17. 0 _filters/{ → asciidoc_template}/docbook45.conf
  18. 0 _filters/{ → asciidoc_template}/escape.py
  19. 0 _filters/{ → asciidoc_template}/help.conf
  20. 0 _filters/{ → asciidoc_template}/html4.conf
  21. 0 _filters/{ → asciidoc_template}/lang-de.conf
  22. 0 _filters/{ → asciidoc_template}/lang-en.conf
  23. 0 _filters/{ → asciidoc_template}/lang-es.conf
  24. 0 _filters/{ → asciidoc_template}/lang-fr.conf
  25. 0 _filters/{ → asciidoc_template}/lang-hu.conf
  26. 0 _filters/{ → asciidoc_template}/lang-it.conf
  27. 0 _filters/{ → asciidoc_template}/lang-pt-BR.conf
  28. 0 _filters/{ → asciidoc_template}/lang-ru.conf
  29. 0 _filters/{ → asciidoc_template}/lang-uk.conf
  30. 0 _filters/{ → asciidoc_template}/latex.conf
  31. 0 _filters/{ → asciidoc_template}/testasciidoc.conf
  32. 0 _filters/{ → asciidoc_template}/text.conf
  33. 0 _filters/{ → asciidoc_template}/wordpress.conf
  34. 0 _filters/{ → asciidoc_template}/xhtml11-quirks.conf
  35. 0 _filters/{ → asciidoc_template}/xhtml11.conf
  36. +1 −14 readme.md
View
@@ -14,6 +14,8 @@
# Basic Settings
# (almost all sites will want to configure these settings)
######################################################################
+import inspect, os
+sys.path.append( os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))) ) # script directory
from _version import currentVersion
## site_url -- Your site's full URL
@@ -29,15 +31,15 @@
## blog_enabled -- Should the blog be enabled?
# (You don't _have_ to use blogofile to build blogs)
-blog.enabled = True
+blog.enabled = False
## blog_path -- Blog path.
# This is the path of the blog relative to the site_url.
# If your site_url is "http://www.yoursite.com/~ryan"
# and you set blog_path to "/blog" your full blog URL would be
# "http://www.yoursite.com/~ryan/blog"
# Leave blank "" to set to the root of site_url
-blog.path = "/blog"
+#blog.path = "/blog"
## blog_name -- Your Blog's name.
# This is used repeatedly in default blog templates
@@ -1,43 +0,0 @@
-import logging
-
-from blogofile.cache import bf
-
-import archives
-import categories
-import chronological
-import feed
-import permapage
-import post
-
-config = {
- "name": "Blog",
- "description": "Creates a Blog",
- "priority": 90.0,
-
- #Posts
- "post.date_format": "%Y/%m/%d %H:%M:%S"
- }
-
-def run():
- blog = bf.config.controllers.blog
-
- #Parse the posts
- blog.posts = post.parse_posts("_posts")
- blog.dir = bf.util.path_join(bf.writer.output_dir, blog.path)
-
- # Find all the categories and archives before we write any pages
- blog.archived_posts = {} ## "/archive/Year/Month" -> [post, post, ... ]
- blog.archive_links = [] ## [("/archive/2009/12", name, num_in_archive1), ...] (sorted in reverse by date)
- blog.categorized_posts = {} ## "Category Name" -> [post, post, ... ]
- blog.all_categories = [] ## [("Category 1",num_in_category_1), ...] (sorted alphabetically)
- archives.sort_into_archives()
- categories.sort_into_categories()
-
- blog.logger = logging.getLogger(config['name'])
-
- permapage.run()
- chronological.run()
- archives.run()
- categories.run()
- feed.run()
-
@@ -1,38 +0,0 @@
-################################################################################
-## Archives controller
-##
-## Writes out yearly, monthly, and daily archives.
-## Each archive is navigable to the next and previous archive
-## in which posts were made.
-################################################################################
-
-import operator
-
-from blogofile.cache import bf
-import chronological
-
-blog = bf.config.controllers.blog
-
-
-def run():
- write_monthly_archives()
-
-
-def sort_into_archives():
- #This is run in 0.initial.py
- for post in blog.posts:
- link = post.date.strftime("archive/%Y/%m")
- try:
- blog.archived_posts[link].append(post)
- except KeyError:
- blog.archived_posts[link] = [post]
- for archive, posts in sorted(
- blog.archived_posts.items(), key=operator.itemgetter(0), reverse=True):
- name = posts[0].date.strftime("%B %Y")
- blog.archive_links.append((archive, name, len(posts)))
-
-
-def write_monthly_archives():
- for link, posts in blog.archived_posts.items():
- name = posts[0].date.strftime("%B %Y")
- chronological.write_blog_chron(posts, root=link)
@@ -1,82 +0,0 @@
-import os
-import shutil
-import operator
-import feed
-from blogofile.cache import bf
-
-blog = bf.config.controllers.blog
-
-
-def run():
- write_categories()
-
-
-def sort_into_categories():
- categories = set()
- for post in blog.posts:
- categories.update(post.categories)
- for category in categories:
- category_posts = [post for post in blog.posts
- if category in post.categories]
- blog.categorized_posts[category] = category_posts
- for category, posts in sorted(
- blog.categorized_posts.items(), key=operator.itemgetter(0)):
- blog.all_categories.append((category, len(posts)))
-
-
-def write_categories():
- """Write all the blog posts in categories"""
- root = bf.util.path_join(blog.path, blog.category_dir)
- #Find all the categories:
- categories = set()
- for post in blog.posts:
- categories.update(post.categories)
- for category, category_posts in blog.categorized_posts.items():
- #Write category RSS feed
- rss_path = bf.util.fs_site_path_helper(
- blog.path, blog.category_dir,
- category.url_name, "feed")
- feed.write_feed(category_posts,rss_path, "rss.mako")
- atom_path = bf.util.fs_site_path_helper(
- blog.path, blog.category_dir,
- category.url_name, "feed", "atom")
- feed.write_feed(category_posts, atom_path, "atom.mako")
- page_num = 1
- while True:
- path = bf.util.path_join(root, category.url_name,
- str(page_num), "index.html")
- page_posts = category_posts[:blog.posts_per_page]
- category_posts = category_posts[blog.posts_per_page:]
- #Forward and back links
- if page_num > 1:
- prev_link = bf.util.site_path_helper(
- blog.path, blog.category_dir, category.url_name,
- str(page_num - 1))
- else:
- prev_link = None
- if len(category_posts) > 0:
- next_link = bf.util.site_path_helper(
- blog.path, blog.category_dir, category.url_name,
- str(page_num + 1))
- else:
- next_link = None
-
- env = {
- "category": category,
- "posts": page_posts,
- "prev_link": prev_link,
- "next_link": next_link
- }
- bf.writer.materialize_template("chronological.mako", path, env)
-
- #Copy category/1 to category/index.html
- if page_num == 1:
- shutil.copyfile(
- bf.util.path_join(bf.writer.output_dir, path),
- bf.util.path_join(
- bf.writer.output_dir, root, category.url_name,
- "index.html"))
- #Prepare next iteration
- page_num += 1
- if len(category_posts) == 0:
- break
@@ -1,55 +0,0 @@
-# Write all the blog posts in reverse chronological order
-import os
-from blogofile.cache import bf
-
-blog = bf.config.controllers.blog
-
-
-def run():
- write_blog_chron(posts=blog.posts, root=blog.pagination_dir.lstrip("/"))
- write_blog_first_page()
-
-
-def write_blog_chron(posts, root):
- page_num = 1
- post_num = 0
- html = []
- while len(posts) > post_num:
- #Write the pages, num_per_page posts per page:
- page_posts = posts[post_num:post_num + blog.posts_per_page]
- post_num += blog.posts_per_page
- if page_num > 1:
- prev_link = "../" + str(page_num - 1)
- else:
- prev_link = None
- if len(posts) > post_num:
- next_link = "../" + str(page_num + 1)
- else:
- next_link = None
- page_dir = bf.util.path_join(blog.path, root, str(page_num))
- fn = bf.util.path_join(page_dir, "index.html")
- env = {
- "posts": page_posts,
- "next_link": next_link,
- "prev_link": prev_link
- }
- bf.writer.materialize_template("chronological.mako", fn, env)
- page_num += 1
-
-
-def write_blog_first_page():
- if not blog.custom_index:
- page_posts = blog.posts[:blog.posts_per_page]
- path = bf.util.path_join(blog.path, "index.html")
- blog.logger.info(u"Writing blog index page: " + path)
- if len(blog.posts) > blog.posts_per_page:
- next_link = bf.util.site_path_helper(
- blog.path, blog.pagination_dir+"/2")
- else:
- next_link = None
- env = {
- "posts": page_posts,
- "next_link": next_link,
- "prev_link": None
- }
- bf.writer.materialize_template("chronological.mako", path, env)
View
@@ -1,16 +0,0 @@
-from blogofile.cache import bf
-
-blog = bf.config.controllers.blog
-
-
-def run():
- write_feed(blog.posts, bf.util.path_join(blog.path, "feed"), "rss.mako")
- write_feed(blog.posts, bf.util.path_join(blog.path, "feed", "atom"),
- "atom.mako")
-
-def write_feed(posts, root, template):
- root = root.lstrip("/")
- path = bf.util.path_join(root, "index.xml")
- blog.logger.info("Writing RSS/Atom feed: " + path)
- env = {"posts": posts, "root": root}
- bf.writer.materialize_template(template, path, env)
@@ -1,38 +0,0 @@
-import urlparse
-from blogofile.cache import bf
-import re
-
-blog = bf.config.controllers.blog
-
-
-def run():
- write_permapages()
-
-
-def write_permapages():
- "Write blog posts to their permalink locations"
- site_re = re.compile(bf.config.site.url, re.IGNORECASE)
- num_posts = len(blog.posts)
-
- for i, post in enumerate(blog.posts):
- if post.permalink:
- path = site_re.sub("", post.permalink)
- blog.logger.info(u"Writing permapage for post: {0}".format(path))
- else:
- #Permalinks MUST be specified. No permalink, no page.
- blog.logger.info(u"Post has no permalink: {0}".format(post.title))
- continue
-
- env = {
- "post": post,
- "posts": blog.posts
- }
-
- #Find the next and previous posts chronologically
- if i < num_posts - 1:
- env['prev_post'] = blog.posts[i + 1]
- if i > 0:
- env['next_post'] = blog.posts[i - 1]
-
- bf.writer.materialize_template(
- "permapage.mako", bf.util.path_join(path, "index.html"), env)
Oops, something went wrong.

0 comments on commit 5432234

Please sign in to comment.