1. Grahack
  2. poole

Commits

Oben Sonne  committed ba6b24d

Move recipes from README into wiki

This keeps the README compact and makes it easier for others to
contribute more recipes for how to get things done with Poole.

  • Participants
  • Parent commits e529749
  • Branches default

Comments (0)

Files changed (1)

File README.md

View file
 [clevercss]: http://sandbox.pocoo.org/clevercss/
 [less]: http://lesscss.org/
 
-### Howtos
+### Recipes
 
-#### Navigation menu
+You can do some pretty fancy and useful things with inlined Python code and
+the macros module, for instance generate a list of blog posts or create an RSS
+file -- check out the [example recipes][recipes].
 
-Have a look into the `page.html` file in a freshly initialized Poole project.
-
-#### List of blog posts
-
-If you want to write some blog posts, you probably would like to have a page
-listing all or the latest blog posts. This is easy if you set certain page
-attributes in every blog post page:
-
-`input/brain-on-mongs.md`:
-
-    title: blog
-    post: This is your brain on mongs
-    date: 2010-03-01
-    ---
-
-    # {{ page.post }}
-
-    Posted on {{ page.date }}
-
-    My hero is full of keyboards. Get nonsense at <http://automeme.net/>
-
-`input/blog.md`:
-
-    This is my blog.
-
-    # My posts
-
-    {%
-    from datetime import datetime
-    posts = [p for p in pages if "post" in p] # get all blog post pages
-    posts.sort(key=lambda p: p.get("date"), reverse=True) # sort post pages by date
-    for p in posts:
-        date = datetime.strptime(p["date"], "%Y-%m-%d").strftime("%B %d, %Y")
-        print "  * **[%s](%s)** - %s" % (p.post, p.url, date) # markdown list item
-    %}
-
-Feel free to adjust this to your needs.
-
-**TIP:** Instead of setting the post title and date as page attributes, you can
-encode them in the page's file name using a structure like
-`page-title.YYYY-MM-DD.post-title.md`. For instance for the file name
-`blog.2010-03-01.This_is_your_brain_on_mongs.md` Poole would automatically set
-the page attributes which has been set manually in the example above.
-
-To see this example in action, have a look into the example pages in a freshly
-initialized Poole project.
-
-#### Google sitemap file
-
-To generate a Google sitemap.xml file, put this into the project's `macros.py`
-file:
-
-    # -----------------------------------------------------------------------------
-    # generate sitemap.xml
-    # -----------------------------------------------------------------------------
-
-    from datetime import datetime
-    import os.path
-
-    _SITEMAP = """<?xml version="1.0" encoding="UTF-8"?>
-    <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
-    %s
-    </urlset>
-    """
-
-    _SITEMAP_URL = """
-    <url>
-        <loc>%s/%s</loc>
-        <lastmod>%s</lastmod>
-        <changefreq>%s</changefreq>
-        <priority>%s</priority>
-    </url>
-    """
-
-    def hook_preconvert_sitemap():
-        """Generate Google sitemap.xml file."""
-        date = datetime.strftime(datetime.now(), "%Y-%m-%d")
-        urls = []
-        for p in pages:
-            urls.append(_SITEMAP_URL % (options.base_url.rstrip('/'), p.url, date,
-                        p.get("changefreq", "monthly"), p.get("priority", "0.8")))
-        fname = os.path.join(options.project, "output", "sitemap.xml")
-        fp = open(fname, 'w')
-        fp.write(_SITEMAP % "".join(urls))
-        fp.close()
-
-You probably want to adjust the default values for *changefreq* and *priority*.
-
-**Info:** Every function in `macros.py` whose name starts with
-`hook_preconvert_` or `hook_postconvert_` is executed exactly once per project
-build -- either before or after converting pages from markdown to HTML. In
-post-convert hooks the HTML content of a page (yet without header and footer)
-can be accessed with `page.html`. This is useful to generate full-content RSS
-feeds.
-
-#### RSS feed for blog posts
-
-To generate an RSS feed for blog posts put this into the project's `macros.py`
-file and adjust for your site:
-
-    # -----------------------------------------------------------------------------
-    # generate rss feed
-    # -----------------------------------------------------------------------------
-
-    import email.utils
-    import os.path
-    import time
-
-    _RSS = """<?xml version="1.0"?>
-    <rss version="2.0">
-    <channel>
-    <title>%s</title>
-    <link>%s</link>
-    <description>%s</description>
-    <language>en-us</language>
-    <pubDate>%s</pubDate>
-    <lastBuildDate>%s</lastBuildDate>
-    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
-    <generator>Poole</generator>
-    %s
-    </channel>
-    </rss>
-    """
-
-    _RSS_ITEM = """
-    <item>
-        <title>%s</title>
-        <link>%s</link>
-        <description>%s</description>
-        <pubDate>%s</pubDate>
-        <guid>%s</guid>
-    </item>
-    """
-
-    def hook_postconvert_rss():
-        items = []
-        posts = [p for p in pages if "post" in p] # get all blog post pages
-        posts.sort(key=lambda p: p.date, reverse=True)
-        for p in posts:
-            title = p.post
-            link = "%s/%s" % (options.base_url.rstrip("/"), p.url)
-            desc = p.get("description", "")
-            date = time.mktime(time.strptime("%s 12" % p.date, "%Y-%m-%d %H"))
-            date = email.utils.formatdate(date)
-            items.append(_RSS_ITEM % (title, link, desc, date, link))
-
-        items = "".join(items)
-
-        # --- CHANGE THIS --- #
-        title = "Maximum volume yields maximum moustaches"
-        link = "%s/blog.html" % options.base_url.rstrip("/")
-        desc = "My name is dragonforce. You killed my dragons. Prepare to scream."
-        date = email.utils.formatdate()
-
-        rss = _RSS % (title, link, desc, date, date, items)
-
-        fp = open(os.path.join(output, "rss.xml"), 'w')
-        fp.write(rss)
-        fp.close()
+[recipes]: https://bitbucket.org/obensonne/poole/wiki/Recipes
 
 ## Feedback