Bladeren bron

Merge remote-tracking branch 'upstream/master'

mikitex70 10 jaren geleden
bovenliggende
commit
f733972105
47 gewijzigde bestanden met toevoegingen van 2231 en 205 verwijderingen
  1. 18 0
      .gitmodules
  2. 121 1
      Readme.rst
  3. 28 0
      asciidoc_reader/README.rst
  4. 1 0
      asciidoc_reader/__init__.py
  5. 64 0
      asciidoc_reader/asciidoc_reader.py
  6. 257 0
      asciidoc_reader/asciidocapi.py
  7. 60 0
      asciidoc_reader/test_asciidoc_reader.py
  8. 12 0
      asciidoc_reader/test_data/article_with_asc_extension.asc
  9. 9 0
      asciidoc_reader/test_data/article_with_asc_options.asc
  10. 1 0
      better_code_samples
  11. 3 0
      collate_content/.gitignore
  12. 661 0
      collate_content/LICENSE
  13. 57 0
      collate_content/README.md
  14. 10 0
      collate_content/__init__.py
  15. 74 0
      collate_content/collate_content.py
  16. 250 0
      collate_content/test_collate_content.py
  17. 0 0
      disqus_static/__init__.py
  18. 1 0
      disqus_static/disqus_static.py
  19. 1 1
      feed_summary/Readme.md
  20. 59 0
      filetime_from_git/README.rst
  21. 1 0
      filetime_from_git/__init__.py
  22. 60 0
      filetime_from_git/filetime_from_git.py
  23. 27 8
      gzip_cache/gzip_cache.py
  24. 21 0
      gzip_cache/test_gzip_cache.py
  25. 6 2
      liquid_tags/video.py
  26. 9 2
      liquid_tags/vimeo.py
  27. 10 2
      liquid_tags/youtube.py
  28. 1 0
      pelican-flickr
  29. 1 0
      pelican-gist
  30. 3 1
      pelican_comment_system/Readme.md
  31. 61 53
      pelican_comment_system/avatars.py
  32. 57 38
      pelican_comment_system/comment.py
  33. 2 2
      pelican_comment_system/doc/feed.md
  34. 1 1
      pelican_comment_system/doc/form.md
  35. 9 9
      pelican_comment_system/doc/installation.md
  36. 111 75
      pelican_comment_system/pelican_comment_system.py
  37. 1 0
      pelicanfly
  38. 1 0
      pin_to_top
  39. 1 1
      post_stats/readability.py
  40. 39 2
      representative_image/Readme.md
  41. 3 0
      representative_image/representative_image.py
  42. 14 0
      representative_image/test_representative_image.py
  43. 24 3
      summary/Readme.rst
  44. 7 4
      thumbnailer/thumbnailer.py
  45. 36 0
      tipue_search/tipue_search.py
  46. 7 0
      touch/README.rst
  47. 31 0
      touch/__init__.py

+ 18 - 0
.gitmodules

@@ -1,3 +1,6 @@
+[submodule "pelican-fontawesome"]
+	path = pelican-fontawesome
+	url = https://github.com/kura/pelican-fontawesome.git
 [submodule "pelican_youtube"]
 	path = pelican_youtube
 	url = https://github.com/kura/pelican_youtube.git
@@ -7,3 +10,18 @@
 [submodule "cjk-auto-spacing"]
 	path = cjk-auto-spacing
 	url = https://github.com/yuex/cjk-auto-spacing.git
+[submodule "pelican-gist"]
+	path = pelican-gist
+	url = https://github.com/streeter/pelican-gist.git
+[submodule "pelicanfly"]
+	path = pelicanfly
+	url = https://github.com/bmcorser/pelicanfly.git
+[submodule "pelican-flickr"]
+	path = pelican-flickr
+	url = https://github.com/La0/pelican-flickr.git
+[submodule "better_code_samples"]
+	path = better_code_samples
+	url = https://github.com/ChrislS/better_code_samples.git
+[submodule "pin_to_top"]
+	path = pin_to_top
+	url = https://github.com/Shaked/pin_to_top.git

+ 121 - 1
Readme.rst

@@ -15,7 +15,7 @@ Easiest way to install and use these plugins is cloning this repo::
 
 and activating the ones you want in your settings file::
 
-    PLUGIN_PATH = 'path/to/pelican-plugins'
+    PLUGIN_PATHS = ['path/to/pelican-plugins']
     PLUGINS = ['assets', 'sitemap', 'gravatar']
 
 ``PLUGIN_PATH`` can be a path relative to your settings file or an absolute path.
@@ -30,6 +30,126 @@ or you can ``import`` the plugin directly and give that::
     import my_plugin
     PLUGINS = [my_plugin, 'assets']
 
+Plugin descriptions
+===================
+
+========================  ===========================================================
+Plugin                    Description
+========================  ===========================================================
+AsciiDoc reader           Use AsciiDoc to write your posts.
+
+Asset management          Use the Webassets module to manage assets such as CSS and JS files.
+                    
+Better code samples       Wraps all `table` blocks with a class attribute `.codehilitetable` in an additional `div` of class `.hilitewrapper`. It thus permits to style codeblocks better, especially to make them scrollable.
+                    
+Better figures/samples    Adds a `style="width: ???px; height: auto;"` attribute to any `<img>` tags in the content
+           
+CJK auto spacing          Inserts spaces between Chinese/Japanese/Korean characters and English words
+                
+Clean summary             Cleans your summary of excess images
+
+Code include              Includes Pygments highlighted code in reStructuredText
+
+Collate content           Makes categories of content available to the template as lists through a `collations` attribute 
+
+Creole reader             Allows you to write your posts using the wikicreole syntax
+
+Custom article URLs       Adds support for defining different default URLs for different categories
+
+Disqus static comments    Adds a disqus_comments property to all articles. Comments are fetched at generation time using disqus API
+
+Extract table of content  Extracts table of contents (ToC) from `article.content`
+
+Feed Summary              Allows article summaries to be used in ATOM and RSS feeds instead of the entire article
+
+Filetime from git         Uses git commit to determine page date
+
+Gallery                   Allows an article to contain an album of pictures
+
+GitHub activity           On the template side, you just have to iterate over the ``github_activity`` variable
+
+Global license            Allows you to define a ``LICENSE`` setting and adds the contents of that license variable to the article's context
+
+Goodreads activity        Lists books from your Goodreads shelves
+
+GooglePlus comments       Adds GooglePlus comments to Pelican
+
+Gravatar                  Assigns the ``author_gravatar`` variable to the Gravatar URL and makes the variable available within the article's context
+
+Gzip cache                Enables certain web servers (e.g., Nginx) to use a static cache of gzip-compressed files to prevent the server from compressing files during an HTTP call
+
+HTML entities             Allows you to enter HTML entities such as &copy;, &lt;, &#149; inline in a RST document
+
+HTML tags for rST         Allows you to use HTML tags from within reST documents
+
+I18N Sub-sites            Extends the translations functionality by creating internationalized sub-sites for the default site
+
+ical                      Looks for and parses an ``.ics`` file if it is defined in a given page's ``calendar`` metadata.
+
+Interlinks                Lets you add frequently used URLs to your markup using short keywords
+
+Liquid-style tags         Allows liquid-style tags to be inserted into markdown within Pelican documents
+
+Multi parts posts         Allows you to write multi-part posts
+
+Neighbor articles         Adds ``next_article`` (newer) and ``prev_article`` (older) variables to the article's context
+
+Optimize images           Applies lossless compression on JPEG and PNG images
+
+PDF generator             Automatically exports RST articles and pages as PDF files
+
+Pelican-flickr            Brings your Flickr photos & sets into your static website
+
+Pelican Gist tag          Easily embed GitHub Gists in your Pelican articles
+
+Pelican comment system    Allows you to add static comments to your articles
+
+Pelican Vimeo             Enables you to embed Vimeo videos in your pages and articles
+
+Pelican YouTube           Enables you to embed YouTube videos in your pages and articles
+
+pelicanfly                Lets you type things like `i ♥ :fa-coffee:` in your Markdown documents and have it come out as little Font Awesome icons in the browser
+
+Pin to top                Pin Pelican's article(s) to top "Sticky article"
+
+PlantUML                  Allows you to define UML diagrams directly into rst documents using the great PlantUML tool
+
+Post statistics           Calculates various statistics about a post and store them in an article.stats dictionary
+
+Random article            Generates a html file which redirect to a random article
+
+Read More link            Inserts an inline "read more" or "continue" link into the last html element of the object summary
+
+Related posts             Adds the ``related_posts`` variable to the article's context
+
+Math Render               Gives pelican the ability to render mathematics
+
+Representative image      Extracts a representative image (i.e, featured image) from the article's summary or content
+
+Share post                Creates share URLs of article
+
+Simple footnotes          Adds footnotes to blog posts
+
+Sitemap                   Generates plain-text or XML sitemaps
+
+Static comments           Allows you to add static comments to an article
+
+Subcategory               Adds support for subcategories
+
+Summary                   Allows easy, variable length summaries directly embedded into the body of your articles
+
+Thumbnailer               Creates thumbnails for all of the images found under a specific directory
+
+Tipue Search              Serializes generated HTML to JSON that can be used by jQuery plugin - Tipue Search
+
+Touch                     Does a touch on your generated files using the date metadata from the content
+
+Twitter Bootstrap         Defines some rst directive that enable a clean usage of the twitter bootstrap CSS and Javascript components
+
+W3C validate              Submits generated HTML content to the W3C Markup Validation Service
+========================  ===========================================================
+
+
 Please refer to the ``Readme`` file in a plugin's folder for detailed information about 
 that plugin.
 

+ 28 - 0
asciidoc_reader/README.rst

@@ -0,0 +1,28 @@
+AsciiDoc Reader
+###############
+
+This plugin allows you to use `AsciiDoc <http://www.methods.co.nz/asciidoc/>`_ 
+to write your posts. File extension should be ``.asc``, ``.adoc``, 
+or ``.asciidoc``.
+
+Dependency
+----------
+
+If you want to use AsciiDoc you need to install it from `source
+<http://www.methods.co.nz/asciidoc/INSTALL.html>`_ or use your operating
+system's package manager.
+
+**Note**: AsciiDoc does not work with Python 3, so you should be using Python 2.
+
+Settings
+--------
+
+========================================  =======================================================
+Setting name (followed by default value)  What does it do?
+========================================  =======================================================
+``ASCIIDOC_OPTIONS = []``                 A list of options to pass to AsciiDoc. See the `manpage
+                                          <http://www.methods.co.nz/asciidoc/manpage.html>`_.
+``ASCIIDOC_BACKEND = 'html5'``            Backend format for output. See the `documentation 
+                                          <http://www.methods.co.nz/asciidoc/userguide.html#X5>`_
+                                          for possible values.
+========================================  =======================================================

+ 1 - 0
asciidoc_reader/__init__.py

@@ -0,0 +1 @@
+from .asciidoc_reader import *

+ 64 - 0
asciidoc_reader/asciidoc_reader.py

@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+"""
+AsciiDoc Reader
+===============
+
+This plugin allows you to use AsciiDoc to write your posts. 
+File extension should be ``.asc``, ``.adoc``, or ``asciidoc``.
+"""
+
+from pelican.readers import BaseReader
+from pelican.utils import pelican_open
+from pelican import signals
+
+try:
+    # asciidocapi won't import on Py3
+    from .asciidocapi import AsciiDocAPI, AsciiDocError
+    # AsciiDocAPI class checks for asciidoc.py
+    AsciiDocAPI()
+except:
+    asciidoc_enabled = False
+else:
+    asciidoc_enabled = True
+
+
+
+class AsciiDocReader(BaseReader):
+    """Reader for AsciiDoc files"""
+
+    enabled = asciidoc_enabled
+    file_extensions = ['asc', 'adoc', 'asciidoc']
+    default_options = ["--no-header-footer", "-a newline=\\n"]
+    default_backend = 'html5'
+
+    def read(self, source_path):
+        """Parse content and metadata of asciidoc files"""
+        from cStringIO import StringIO
+        with pelican_open(source_path) as source:
+            text = StringIO(source)
+        content = StringIO()
+        ad = AsciiDocAPI()
+
+        options = self.settings.get('ASCIIDOC_OPTIONS', [])
+        options = self.default_options + options
+        for o in options:
+            ad.options(*o.split())
+
+        backend = self.settings.get('ASCIIDOC_BACKEND', self.default_backend)
+        ad.execute(text, content, backend=backend)
+        content = content.getvalue()
+
+        metadata = {}
+        for name, value in ad.asciidoc.document.attributes.items():
+            name = name.lower()
+            metadata[name] = self.process_metadata(name, value)
+        if 'doctitle' in metadata:
+            metadata['title'] = metadata['doctitle']
+        return content, metadata
+
+def add_reader(readers):
+    for ext in AsciiDocReader.file_extensions:
+        readers.reader_classes[ext] = AsciiDocReader
+
+def register():
+    signals.readers_init.connect(add_reader)

+ 257 - 0
asciidoc_reader/asciidocapi.py

@@ -0,0 +1,257 @@
+#!/usr/bin/env python
+"""
+asciidocapi - AsciiDoc API wrapper class.
+
+The AsciiDocAPI class provides an API for executing asciidoc. Minimal example
+compiles `mydoc.txt` to `mydoc.html`:
+
+  import asciidocapi
+  asciidoc = asciidocapi.AsciiDocAPI()
+  asciidoc.execute('mydoc.txt')
+
+- Full documentation in asciidocapi.txt.
+- See the doctests below for more examples.
+
+Doctests:
+
+1. Check execution:
+
+   >>> import StringIO
+   >>> infile = StringIO.StringIO('Hello *{author}*')
+   >>> outfile = StringIO.StringIO()
+   >>> asciidoc = AsciiDocAPI()
+   >>> asciidoc.options('--no-header-footer')
+   >>> asciidoc.attributes['author'] = 'Joe Bloggs'
+   >>> asciidoc.execute(infile, outfile, backend='html4')
+   >>> print outfile.getvalue()
+   <p>Hello <strong>Joe Bloggs</strong></p>
+
+   >>> asciidoc.attributes['author'] = 'Bill Smith'
+   >>> infile = StringIO.StringIO('Hello _{author}_')
+   >>> outfile = StringIO.StringIO()
+   >>> asciidoc.execute(infile, outfile, backend='docbook')
+   >>> print outfile.getvalue()
+   <simpara>Hello <emphasis>Bill Smith</emphasis></simpara>
+
+2. Check error handling:
+
+   >>> import StringIO
+   >>> asciidoc = AsciiDocAPI()
+   >>> infile = StringIO.StringIO('---------')
+   >>> outfile = StringIO.StringIO()
+   >>> asciidoc.execute(infile, outfile)
+   Traceback (most recent call last):
+     File "<stdin>", line 1, in <module>
+     File "asciidocapi.py", line 189, in execute
+       raise AsciiDocError(self.messages[-1])
+   AsciiDocError: ERROR: <stdin>: line 1: [blockdef-listing] missing closing delimiter
+
+
+Copyright (C) 2009 Stuart Rackham. Free use of this software is granted
+under the terms of the GNU General Public License (GPL).
+
+"""
+
+import sys,os,re,imp
+
+API_VERSION = '0.1.2'
+MIN_ASCIIDOC_VERSION = '8.4.1'  # Minimum acceptable AsciiDoc version.
+
+
+def find_in_path(fname, path=None):
+    """
+    Find file fname in paths. Return None if not found.
+    """
+    if path is None:
+        path = os.environ.get('PATH', '')
+    for dir in path.split(os.pathsep):
+        fpath = os.path.join(dir, fname)
+        if os.path.isfile(fpath):
+            return fpath
+    else:
+        return None
+
+
+class AsciiDocError(Exception):
+    pass
+
+
+class Options(object):
+    """
+    Stores asciidoc(1) command options.
+    """
+    def __init__(self, values=[]):
+        self.values = values[:]
+    def __call__(self, name, value=None):
+        """Shortcut for append method."""
+        self.append(name, value)
+    def append(self, name, value=None):
+        if type(value) in (int,float):
+            value = str(value)
+        self.values.append((name,value))
+
+
+class Version(object):
+    """
+    Parse and compare AsciiDoc version numbers. Instance attributes:
+
+    string: String version number '<major>.<minor>[.<micro>][suffix]'.
+    major:  Integer major version number.
+    minor:  Integer minor version number.
+    micro:  Integer micro version number.
+    suffix: Suffix (begins with non-numeric character) is ignored when
+            comparing.
+
+    Doctest examples:
+
+    >>> Version('8.2.5') < Version('8.3 beta 1')
+    True
+    >>> Version('8.3.0') == Version('8.3. beta 1')
+    True
+    >>> Version('8.2.0') < Version('8.20')
+    True
+    >>> Version('8.20').major
+    8
+    >>> Version('8.20').minor
+    20
+    >>> Version('8.20').micro
+    0
+    >>> Version('8.20').suffix
+    ''
+    >>> Version('8.20 beta 1').suffix
+    'beta 1'
+
+    """
+    def __init__(self, version):
+        self.string = version
+        reo = re.match(r'^(\d+)\.(\d+)(\.(\d+))?\s*(.*?)\s*$', self.string)
+        if not reo:
+            raise ValueError('invalid version number: %s' % self.string)
+        groups = reo.groups()
+        self.major = int(groups[0])
+        self.minor = int(groups[1])
+        self.micro = int(groups[3] or '0')
+        self.suffix = groups[4] or ''
+    def __cmp__(self, other):
+        result = cmp(self.major, other.major)
+        if result == 0:
+            result = cmp(self.minor, other.minor)
+            if result == 0:
+                result = cmp(self.micro, other.micro)
+        return result
+
+
+class AsciiDocAPI(object):
+    """
+    AsciiDoc API class.
+    """
+    def __init__(self, asciidoc_py=None):
+        """
+        Locate and import asciidoc.py.
+        Initialize instance attributes.
+        """
+        self.options = Options()
+        self.attributes = {}
+        self.messages = []
+        # Search for the asciidoc command file.
+        # Try ASCIIDOC_PY environment variable first.
+        cmd = os.environ.get('ASCIIDOC_PY')
+        if cmd:
+            if not os.path.isfile(cmd):
+                raise AsciiDocError('missing ASCIIDOC_PY file: %s' % cmd)
+        elif asciidoc_py:
+            # Next try path specified by caller.
+            cmd = asciidoc_py
+            if not os.path.isfile(cmd):
+                raise AsciiDocError('missing file: %s' % cmd)
+        else:
+            # Try shell search paths.
+            for fname in ['asciidoc.py','asciidoc.pyc','asciidoc']:
+                cmd = find_in_path(fname)
+                if cmd: break
+            else:
+                # Finally try current working directory.
+                for cmd in ['asciidoc.py','asciidoc.pyc','asciidoc']:
+                    if os.path.isfile(cmd): break
+                else:
+                    raise AsciiDocError('failed to locate asciidoc')
+        self.cmd = os.path.realpath(cmd)
+        self.__import_asciidoc()
+
+    def __import_asciidoc(self, reload=False):
+        '''
+        Import asciidoc module (script or compiled .pyc).
+        See
+        http://groups.google.com/group/asciidoc/browse_frm/thread/66e7b59d12cd2f91
+        for an explanation of why a seemingly straight-forward job turned out
+        quite complicated.
+        '''
+        if os.path.splitext(self.cmd)[1] in ['.py','.pyc']:
+            sys.path.insert(0, os.path.dirname(self.cmd))
+            try:
+                try:
+                    if reload:
+                        import __builtin__  # Because reload() is shadowed.
+                        __builtin__.reload(self.asciidoc)
+                    else:
+                        import asciidoc
+                        self.asciidoc = asciidoc
+                except ImportError:
+                    raise AsciiDocError('failed to import ' + self.cmd)
+            finally:
+                del sys.path[0]
+        else:
+            # The import statement can only handle .py or .pyc files, have to
+            # use imp.load_source() for scripts with other names.
+            try:
+                imp.load_source('asciidoc', self.cmd)
+                import asciidoc
+                self.asciidoc = asciidoc
+            except ImportError:
+                raise AsciiDocError('failed to import ' + self.cmd)
+        if Version(self.asciidoc.VERSION) < Version(MIN_ASCIIDOC_VERSION):
+            raise AsciiDocError(
+                'asciidocapi %s requires asciidoc %s or better'
+                % (API_VERSION, MIN_ASCIIDOC_VERSION))
+
+    def execute(self, infile, outfile=None, backend=None):
+        """
+        Compile infile to outfile using backend format.
+        infile can outfile can be file path strings or file like objects.
+        """
+        self.messages = []
+        opts = Options(self.options.values)
+        if outfile is not None:
+            opts('--out-file', outfile)
+        if backend is not None:
+            opts('--backend', backend)
+        for k,v in self.attributes.items():
+            if v == '' or k[-1] in '!@':
+                s = k
+            elif v is None: # A None value undefines the attribute.
+                s = k + '!'
+            else:
+                s = '%s=%s' % (k,v)
+            opts('--attribute', s)
+        args = [infile]
+        # The AsciiDoc command was designed to process source text then
+        # exit, there are globals and statics in asciidoc.py that have
+        # to be reinitialized before each run -- hence the reload.
+        self.__import_asciidoc(reload=True)
+        try:
+            try:
+                self.asciidoc.execute(self.cmd, opts.values, args)
+            finally:
+                self.messages = self.asciidoc.messages[:]
+        except SystemExit, e:
+            if e.code:
+                raise AsciiDocError(self.messages[-1])
+
+
+if __name__ == "__main__":
+    """
+    Run module doctests.
+    """
+    import doctest
+    options = doctest.NORMALIZE_WHITESPACE + doctest.ELLIPSIS
+    doctest.testmod(optionflags=options)

+ 60 - 0
asciidoc_reader/test_asciidoc_reader.py

@@ -0,0 +1,60 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+import datetime
+import os
+
+from pelican.readers import Readers
+from pelican.tests.support import unittest, get_settings
+
+from .asciidoc_reader import asciidoc_enabled
+
+CUR_DIR = os.path.dirname(__file__)
+CONTENT_PATH = os.path.join(CUR_DIR, 'test_data')
+
+@unittest.skipUnless(asciidoc_enabled, "asciidoc isn't installed")
+class AsciiDocReaderTest(unittest.TestCase):
+    def read_file(self, path, **kwargs):
+        # Isolate from future API changes to readers.read_file
+        r = Readers(settings=get_settings(**kwargs))
+        return r.read_file(base_path=CONTENT_PATH, path=path)
+
+    def test_article_with_asc_extension(self):
+        # Ensure the asc extension is being processed by the correct reader
+        page = self.read_file(
+            path='article_with_asc_extension.asc')
+        expected = ('<div class="sect1">\n'
+                    '<h2 id="_used_for_pelican_test">'
+                    'Used for pelican test</h2>\n'
+                    '<div class="sectionbody">\n'
+                    '<div class="paragraph">'
+                    '<p>The quick brown fox jumped over '
+                    'the lazy dog&#8217;s back.</p>'
+                    '</div>\n</div>\n</div>\n')
+        self.assertEqual(page.content, expected)
+        expected = {
+            'category': 'Blog',
+            'author': 'Author O. Article',
+            'title': 'Test AsciiDoc File Header',
+            'date': datetime.datetime(2011, 9, 15, 9, 5),
+            'tags': ['Linux', 'Python', 'Pelican'],
+        }
+
+        for key, value in expected.items():
+            self.assertEqual(value, page.metadata[key], key)
+
+    def test_article_with_asc_options(self):
+        # test to ensure the ASCIIDOC_OPTIONS is being used
+        page = self.read_file(path='article_with_asc_options.asc',
+            ASCIIDOC_OPTIONS=["-a revision=1.0.42"])
+        expected = ('<div class="sect1">\n'
+                    '<h2 id="_used_for_pelican_test">'
+                    'Used for pelican test</h2>\n'
+                    '<div class="sectionbody">\n'
+                    '<div class="paragraph">'
+                    '<p>version 1.0.42</p></div>\n'
+                    '<div class="paragraph">'
+                    '<p>The quick brown fox jumped over '
+                    'the lazy dog&#8217;s back.</p>'
+                    '</div>\n</div>\n</div>\n')
+        self.assertEqual(page.content, expected)

+ 12 - 0
asciidoc_reader/test_data/article_with_asc_extension.asc

@@ -0,0 +1,12 @@
+Test AsciiDoc File Header
+=========================
+:Author: Author O. Article
+:Email: <author@nowhere.com>
+:Date: 2011-09-15 09:05
+:Category: Blog
+:Tags: Linux, Python, Pelican
+
+Used for pelican test
+---------------------
+
+The quick brown fox jumped over the lazy dog's back.

+ 9 - 0
asciidoc_reader/test_data/article_with_asc_options.asc

@@ -0,0 +1,9 @@
+Test AsciiDoc File Header
+=========================
+
+Used for pelican test
+---------------------
+
+version {revision}
+
+The quick brown fox jumped over the lazy dog's back.

+ 1 - 0
better_code_samples

@@ -0,0 +1 @@
+Subproject commit 91717a204bbd0ae4a1af6fe25ac5dd783fb4a7db

+ 3 - 0
collate_content/.gitignore

@@ -0,0 +1,3 @@
+
+# Python files
+*.pyc

+ 661 - 0
collate_content/LICENSE

@@ -0,0 +1,661 @@
+                    GNU AFFERO GENERAL PUBLIC LICENSE
+                       Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+  A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate.  Many developers of free software are heartened and
+encouraged by the resulting cooperation.  However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+  The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community.  It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server.  Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+  An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals.  This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU Affero General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Remote Network Interaction; Use with the GNU General Public License.
+
+  Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software.  This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time.  Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU Affero General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU Affero General Public License for more details.
+
+    You should have received a copy of the GNU Affero General Public License
+    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source.  For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code.  There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.

+ 57 - 0
collate_content/README.md

@@ -0,0 +1,57 @@
+# Collate Content
+*Author: Edward J. Stronge <ejstronge@gmail.com>*
+
+Makes categories of content available to the template as lists through a
+`collations` attribute. I primarily developed this to make it easier
+to work with `Page` objects that contain category metadata.
+
+## Installation
+
+If you downloaded this module as part of the pelican-plugins repository, 
+add it to your Pelican configuration as follows:
+
+    PLUGIN_PATH = '/path/to/pelican-plugins'
+    PLUGINS = ['pelican_collate_content', ]
+    
+Otherwise, you can import it into Python as a normal module if you place
+this repository in your `$PYTHONPATH`.
+
+## Usage
+
+To display all content in the category `Software Development`, 
+you could use the following block in a template. In the template, the category
+will appear in lowercase with internal whitespace and '-' characters
+converted to underscores:
+
+    ```html
+    <h1>Development blog</h1>
+    <ul> 
+    {% for a in collations.software_development_articles %}
+        <li>a.date - a.title</li> 
+    {% endfor %}
+    </ul>
+    
+    <h1> Open source projects </h1>
+    I'm an active contributor to the following projects:
+    
+    <ul>
+    {% for p in software_development_pages %}
+        <li> p.title - p.summary</li> 
+    {% endfor %}
+    </ul>
+    ```
+
+### Articles or pages with multiple categories
+
+Multiple categories are supported out-of-the box. Categories may not
+contain commas but otherwise work with no problem.
+
+## Settings
+
+To limit which categories and subcategories are collated, set the
+`CATEGORIES_TO_COLLATE` option in your Pelican configuration file.
+
+If this option is present and is a list, only categories present
+in `CATEGORIES_TO_COLLATE` will be collated:
+
+    CATEGORIES_TO_COLLATE = ['category-of-interest', 'another-cool-category']

+ 10 - 0
collate_content/__init__.py

@@ -0,0 +1,10 @@
+"""
+__init__.py
+===========
+
+Edward J. Stronge
+(c) 2014
+
+Imports collate_content to facilitate Pelican's plugin loading process.
+"""
+from .collate_content import *

+ 74 - 0
collate_content/collate_content.py

@@ -0,0 +1,74 @@
+"""
+collate_content.py
+==================
+(c) 2014 - Edward Stronge
+
+Connects to the content generator finalized signal to combine
+articles and pages sharing a category into lists that will be
+available in the template context.
+
+Thanks to #pelican member @kura for suggestions on creating this
+plugin.
+"""
+from collections import defaultdict
+import functools
+import re
+
+from pelican import signals
+
+
+def group_content(generator, content_type):
+    """
+    Assembles articles and pages into lists based on each
+    article or page's content. These lists are available
+    through the global context passed to the template engine.
+
+    When multiple categories are present, splits category names
+    based on commas and trims whitespace surrounding a
+    category's name. Thus, commas may not appear within a category
+    but they can be used to delimit categories and may be surrounded by
+    arbitrary amounts of whitespace.
+
+    For each category, substitutes '_' for all whitespace and '-'
+    characters, then creates a list named `SUBSTITUTED_CATEGORY_NAME`_articles
+    or `SUBSTITUTED_CATEGORY_NAME`_pages for Articles or Pages,
+    respectively.
+
+    Note that the *original* category name must appear in the
+    `CATEGORIES_TO_COLLATE` when using this plugin with category
+    filtering enabled.
+    """
+    category_filter = generator.settings.get('CATEGORIES_TO_COLLATE', None)
+    filtering_active = type(category_filter) in (list, tuple, set)
+
+    collations = generator.context.get('collations', defaultdict(list))
+    for content in generator.context[content_type]:
+        category_list = [c.strip() for c in content.category.name.split(',')]
+        for category in category_list:
+            if filtering_active and category not in category_filter:
+                continue
+            category = substitute_category_name(category)
+            collations['%s_%s' % (category, content_type)].append(content)
+    generator.context['collations'] = collations
+
+
+def substitute_category_name(category_name):
+    """
+    Replaces whitespace and '-' characters in `category_name`
+    to allow category_name to be made into a valid Python
+    identifier.
+
+    Doesn't check all possible ways a string might be invalid;
+    the user of the collate_content module is advised to use
+    categories with Python-friendly names.
+    """
+    return re.sub(r'\s', '_', category_name).replace('-', '_').lower()
+
+ARTICLE_GROUPER = functools.partial(group_content, content_type='articles')
+PAGE_GROUPER = functools.partial(group_content, content_type='pages')
+
+
+def register():
+    """Register the new plugin"""
+    signals.article_generator_finalized.connect(ARTICLE_GROUPER)
+    signals.page_generator_finalized.connect(PAGE_GROUPER)

+ 250 - 0
collate_content/test_collate_content.py

@@ -0,0 +1,250 @@
+"""
+test_collate_content.py
+=======================
+
+(c) 2014 - Edward J. Stronge
+
+Tests for the collate_content module
+"""
+from collections import defaultdict, namedtuple
+import os
+import random
+import tempfile
+import shutil
+import string
+import unittest
+
+from pelican import Pelican
+from pelican import ArticlesGenerator, PagesGenerator
+from pelican.settings import read_settings
+
+import collate_content as cc
+
+TEMP_PAGE_TEMPLATE = """Title: {title}
+Category: {category}
+"""
+
+Content = namedtuple('Content', ['title', 'path', 'category'])
+# Characters likely to appear in blog titles/categories. Could eventually
+# extend support to more characters that can't appear in a Python identifier
+BLOG_CHARACTERS = string.letters + ' -:'
+
+
+def make_content(directory, categories, count=5, categories_per_content=1):
+    """
+    make_content --> {(processed_category, original_category): articles, ...}
+
+    Writes random titles and categories into `count` temporary
+    files in `directory`. If desired, specify `categories_per_content`
+    to assign multiple categories to each written file.
+
+    Returns a dictionary whose keys are in `categories` with values
+    that are (title, path, category) tuples for the generated
+    content files.
+    """
+    new_content = defaultdict(list)
+    for _ in range(count):
+        title = get_random_text_and_whitespace()
+        category_choice = random.sample(categories, categories_per_content)
+        categories_string = ', '.join(category_choice)
+        output = TEMP_PAGE_TEMPLATE.format(
+            title=title, category=categories_string)
+        with tempfile.NamedTemporaryFile(
+                dir=directory, mode='w', suffix='.md', delete=False) as tmp:
+            tmp.write(output)
+            path = os.path.join(directory, tmp.name)
+
+        for each_cat in category_choice:
+            new_content[(cc.substitute_category_name(each_cat), each_cat)]\
+                .append(Content(title, path, categories_string))
+    return new_content
+
+
+def get_random_text_and_whitespace(length=10):
+    """
+    Returns at most `length` randomly-generated letters and/or
+    whitespace. The returned string will not begin or end in whitespace.
+    """
+    return "".join(random.sample(BLOG_CHARACTERS, length)).strip()
+
+
+def modified_pelican_run(self):
+    """Runs the generators and returns the context object
+
+    Modified from the Pelican object's run methods.
+    """
+
+    context = self.settings.copy()
+    context['filenames'] = {}  # share the dict between all the generators
+    context['localsiteurl'] = self.settings['SITEURL']  # share
+    generators = [
+        cls(
+            context=context,
+            settings=self.settings,
+            path=self.path,
+            theme=self.theme,
+            output_path=self.output_path,
+        ) for cls in self.get_generator_classes()
+    ]
+
+    for p in generators:
+        if hasattr(p, 'generate_context'):
+            p.generate_context()
+
+    writer = self.get_writer()
+
+    for p in generators:
+        if hasattr(p, 'generate_output'):
+            p.generate_output(writer)
+
+    next(g for g in generators if isinstance(g, ArticlesGenerator))
+    next(g for g in generators if isinstance(g, PagesGenerator))
+    return context
+
+
+class ContentCollationTester(unittest.TestCase):
+    """Test generation of lists of content based on their Category metadata"""
+
+    def setUp(self, settings_overrides=None, count=5,
+              categories_per_content=1, categories=None):
+        self.temp_input_dir = tempfile.mkdtemp(prefix="cc-input-")
+        page_directory = os.path.join(self.temp_input_dir, 'pages')
+        os.mkdir(page_directory)
+        self.temp_output_dir = tempfile.mkdtemp(prefix="cc-output-")
+
+        if categories is None:
+            categories = [get_random_text_and_whitespace() for _ in range(5)]
+
+        self.articles = make_content(
+            self.temp_input_dir, categories, count=count,
+            categories_per_content=categories_per_content)
+        self.pages = make_content(
+            page_directory, categories, count=count,
+            categories_per_content=categories_per_content)
+        settings = {
+            'PATH': self.temp_input_dir,
+            'PAGE_DIR': 'pages',
+            'OUTPUT_PATH': self.temp_output_dir,
+            'PLUGINS': [cc],
+            'DEFAULT_DATE': (2014, 6, 8),
+            }
+        if settings_overrides is not None:
+            settings.update(settings_overrides)
+        settings = read_settings(override=settings)
+        pelican = Pelican(settings=settings)
+        pelican.modified_run = modified_pelican_run
+        self.collations = pelican.modified_run(pelican)['collations']
+
+    def tearDown(self):
+        shutil.rmtree(self.temp_input_dir)
+        shutil.rmtree(self.temp_output_dir)
+
+
+class TestCollation(ContentCollationTester):
+    """Test generation of lists of content based on their Category metadata"""
+
+    def test_articles_with_one_category(self):
+
+        for substituted_category, original_category in self.articles.keys():
+            collation_key = '%s_articles' % substituted_category
+            self.assertIn(collation_key, self.collations)
+
+            collated_titles = [a.title for a in self.collations[collation_key]]
+
+            for title, _, _ in self.articles[
+                    (substituted_category, original_category)]:
+                self.assertIn(title, collated_titles)
+
+    def test_pages_with_one_category(self):
+
+        for substituted_category, original_category in self.pages.keys():
+            collation_key = '%s_pages' % substituted_category
+            self.assertIn(collation_key, self.collations)
+
+            collated_titles = [a.title for a in self.collations[collation_key]]
+
+            for title, _, _ in self.pages[
+                    (substituted_category, original_category)]:
+                self.assertIn(title, collated_titles)
+
+
+class TestCollationAndMultipleCategories(TestCollation):
+    """
+    Test collate_content with multiple categories specified in each
+    article and each page.
+    """
+    def setUp(self):
+        categories = [get_random_text_and_whitespace() for _ in range(5)]
+
+        ContentCollationTester.setUp(
+            self, categories=categories, categories_per_content=3)
+
+
+class TestFilteredCategories(ContentCollationTester):
+    """
+    Test collate_content with the `CATEGORIES_TO_COLLATE` setting
+    in effect
+    """
+
+    def setUp(self):
+        categories = [get_random_text_and_whitespace() for _ in range(5)]
+        self.retained_categories = categories[:2]
+        override = {'CATEGORIES_TO_COLLATE': self.retained_categories}
+
+        ContentCollationTester.setUp(
+            self, settings_overrides=override, categories=categories)
+
+    def test_articles_with_one_category_after_filtering(self):
+
+        for substituted_category, original_category in self.articles.keys():
+            collation_key = '%s_articles' % substituted_category
+
+            if original_category not in self.retained_categories:
+                self.assertNotIn(collation_key, self.collations)
+                continue
+
+            self.assertIn(collation_key, self.collations)
+
+            collated_titles = [a.title for a in self.collations[collation_key]]
+
+            for title, _, _ in self.articles[
+                    (substituted_category, original_category)]:
+                self.assertIn(title, collated_titles)
+
+    def test_pages_with_one_category_after_filtering(self):
+
+        for substituted_category, original_category in self.pages.keys():
+            collation_key = '%s_pages' % substituted_category
+
+            if original_category not in self.retained_categories:
+                self.assertNotIn(collation_key, self.collations)
+                continue
+
+            self.assertIn(collation_key, self.collations)
+
+            collated_titles = [a.title for a in self.collations[collation_key]]
+
+            for title, _, _ in self.pages[
+                    (substituted_category, original_category)]:
+                self.assertIn(title, collated_titles)
+
+
+class TestFilteredAndMultipleCategories(TestFilteredCategories):
+    """
+    Test collate_content with the `CATEGORIES_TO_COLLATE` setting
+    in effect as well as with multiple categories specified in each
+    article and each page.
+    """
+    def setUp(self):
+        categories = [get_random_text_and_whitespace() for _ in range(5)]
+        self.retained_categories = categories[:2]
+        override = {'CATEGORIES_TO_COLLATE': self.retained_categories}
+
+        ContentCollationTester.setUp(
+            self, settings_overrides=override, categories=categories,
+            categories_per_content=3)
+
+
+if __name__ == '__main__':
+    suite = unittest.TestLoader().loadTestsFromNames(['test_collate_content'])
+    unittest.TextTestRunner(verbosity=1).run(suite)

disqus_static/__init__py → disqus_static/__init__.py


+ 1 - 0
disqus_static/disqus_static.py

@@ -6,6 +6,7 @@ This plugin adds a disqus_comments property to all articles.
 Comments are fetched at generation time using disqus API.
 """
 
+from __future__ import unicode_literals
 from disqusapi import DisqusAPI, Paginator
 from pelican import signals
 

+ 1 - 1
feed_summary/Readme.md

@@ -3,7 +3,7 @@ This plugin allows article summaries to be used in ATOM and RSS feeds instead of
 built-in pelican `Summary:` metadata.
 
 The summary of an article can either be set explicitly with the `Summary:` metadata attribute as described in the
-[pelican getting started docs](http://docs.getpelican.com/en/latest/getting_started.html#file-metadata),
+[Pelican documentation](http://docs.getpelican.com/) (*Writing content* > *File metadata* section),
 or automatically generated using the number of words specified in the
 [SUMMARY_MAX_LENGTH](http://docs.getpelican.com/en/latest/settings.html) setting.
 

+ 59 - 0
filetime_from_git/README.rst

@@ -0,0 +1,59 @@
+Use git commit to determine page date
+======================================
+
+If the blog content is managed by git repo, this plugin will set articles'
+and pages' ``metadata['date']`` according to git commit. This plugin depends
+on python package ``gitpython``, install::
+
+    pip install gitpython
+
+The determine logic will works so:
+
+* if a file is not tracked by git, or a file is staged but never commited
+    - metadata['date'] = fs time
+    - metadata['updated'] = fs time
+* if a file is tracked, but no changes in stage area or work dir
+    - metadata['date'] = first commit time
+    - metadata['updated'] = last commit time
+* if a file is tracked, and has changes in stage area or work dir
+    - metadata['date'] = first commit time
+    - metadata['updated'] = fs time
+
+When this module is enabled, ``date`` and ``updated`` will be set automatically
+by git status, no need to manually set in article/page's metadata. And
+operations like copy, move will not affect the generated results.
+
+If some article or page doesn't like to use git time, set a ``gittime: off``
+metadata to disable it.
+
+Some notes on git
+~~~~~~~~~~~~~~~~~~
+
+* How to check if a file is managed?
+
+.. code-block:: sh
+
+   git ls-files $file --error-unmatch
+
+* How to check if a file has changes?
+
+.. code-block:: sh
+
+   git diff $file            # compare staged area with working directory
+   git diff --cached $file   # compare HEAD with staged area
+   git diff HEAD $file       # compare HEAD with working directory
+
+* How to get commits related to a file?
+
+.. code-block:: sh
+
+   git status $file
+
+with ``gitpython`` package, it's easier to parse commited time:
+
+.. code-block:: python
+
+   repo = Git.repo('/path/to/repo')
+   commits = repo.commits(path='path/to/file')
+   commits[-1].committed_date    # oldest commit time
+   commits[0].committed_date     # latest commit time

+ 1 - 0
filetime_from_git/__init__.py

@@ -0,0 +1 @@
+from .filetime_from_git import *

+ 60 - 0
filetime_from_git/filetime_from_git.py

@@ -0,0 +1,60 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+import os
+from git import Git, Repo, InvalidGitRepositoryError
+from pelican import signals, contents
+from datetime import datetime
+from time import mktime, altzone
+
+try:
+    repo = Repo(os.path.abspath('.'))
+    git = Git(os.path.abspath('.'))
+except InvalidGitRepositoryError as e:
+    repo = None
+
+def filetime_from_git(content):
+    if isinstance(content, contents.Static) or repo is None:
+        return
+    gittime = content.metadata.get('gittime', 'yes').lower()
+    gittime = gittime.replace("false", "no").replace("off", "no")
+    if gittime == "no":
+        return
+    # 1. file is not managed by git
+    #    date: fs time
+    # 2. file is staged, but has no commits
+    #    date: fs time
+    # 3. file is managed, and clean
+    #    date: first commit time, update: last commit time or None
+    # 4. file is managed, but dirty
+    #    date: first commit time, update: fs time
+    path = content.source_path
+    status, stdout, stderr = git.execute(['git', 'ls-files', path, '--error-unmatch'],
+            with_extended_output=True, with_exceptions=False)
+    if status != 0:
+        # file is not managed by git
+        content.date = datetime.fromtimestamp(os.stat(path).st_ctime)
+    else:
+        # file is managed by git
+        commits = repo.commits(path=path)
+        if len(commits) == 0:
+            # never commited, but staged
+            content.date = datetime.fromtimestamp(os.stat(path).st_ctime)
+        else:
+            # has commited
+            content.date = datetime.fromtimestamp(mktime(commits[-1].committed_date) - altzone)
+
+            status, stdout, stderr = git.execute(['git', 'diff', '--quiet', 'HEAD', path],
+                    with_extended_output=True, with_exceptions=False)
+            if status != 0:
+                # file has changed
+                content.updated = datetime.fromtimestamp(os.stat(path).st_ctime)
+            else:
+                # file is not changed
+                if len(commits) > 1:
+                    content.updated = datetime.fromtimestamp(mktime(commits[0].committed_date) - altzone)
+    if not hasattr(content, 'updated'):
+        content.updated = content.date
+
+def register():
+    signals.content_object_init.connect(filetime_from_git)

+ 27 - 8
gzip_cache/gzip_cache.py

@@ -7,9 +7,9 @@ Gzip cache
 A plugin to create .gz cache files for optimization.
 '''
 
-import gzip
 import logging
 import os
+import zlib
 
 from pelican import signals
 
@@ -39,6 +39,18 @@ EXCLUDE_TYPES = [
     '.mp4',
 ]
 
+COMPRESSION_LEVEL = 9 # Best Compression
+
+""" According to zlib manual: 'Add 16 to
+windowBits to write a simple gzip header and trailer around the
+compressed data instead of a zlib wrapper. The gzip header will
+have no file name, no extra data, no comment, no modification
+time (set to zero), no header crc, and the operating system
+will be set to 255 (unknown)'
+"""
+WBITS = zlib.MAX_WBITS | 16
+
+
 def create_gzip_cache(pelican):
     '''Create a gzip cache file for every file that a webserver would
     reasonably want to cache (e.g., text type files).
@@ -51,6 +63,7 @@ def create_gzip_cache(pelican):
                 filepath = os.path.join(dirpath, name)
                 create_gzip_file(filepath)
 
+
 def should_compress(filename):
     '''Check if the filename is a type of file that should be compressed.
 
@@ -62,6 +75,7 @@ def should_compress(filename):
 
     return True
 
+
 def create_gzip_file(filepath):
     '''Create a gzipped file in the same directory with a filepath.gz name.
 
@@ -70,14 +84,19 @@ def create_gzip_file(filepath):
     compressed_path = filepath + '.gz'
 
     with open(filepath, 'rb') as uncompressed:
-        try:
+        gzip_compress_obj = zlib.compressobj(COMPRESSION_LEVEL,
+                                                zlib.DEFLATED, WBITS)
+
+        uncompressed_data = uncompressed.read()
+        gzipped_data = gzip_compress_obj.compress(uncompressed_data)
+        gzipped_data += gzip_compress_obj.flush()
+        with open(compressed_path, 'wb') as compressed:
             logger.debug('Compressing: %s' % filepath)
-            compressed = gzip.open(compressed_path, 'wb')
-            compressed.writelines(uncompressed)
-        except Exception as ex:
-            logger.critical('Gzip compression failed: %s' % ex)
-        finally:
-            compressed.close()
+            try:
+                compressed.write(gzipped_data)
+            except Exception as ex:
+                logger.critical('Gzip compression failed: %s' % ex)
+
 
 def register():
     signals.finalized.connect(create_gzip_cache)

+ 21 - 0
gzip_cache/test_gzip_cache.py

@@ -4,10 +4,12 @@
 import os
 import tempfile
 import unittest
+import time
 
 from contextlib import contextmanager
 from tempfile import mkdtemp
 from shutil import rmtree
+from hashlib import md5
 
 import gzip_cache
 
@@ -52,3 +54,22 @@ class TestGzipCache(unittest.TestCase):
             gzip_cache.create_gzip_file(a_html_filename)
             self.assertTrue(os.path.exists(a_html_filename + '.gz'))
 
+    def test_creates_same_gzip_file(self):
+        # Should create the same gzip file from the same contents.
+
+        # gzip will create a slightly different file because it includes
+        # a timestamp in the compressed file by default. This can cause
+        # problems for some caching strategies.
+        with temporary_folder() as tempdir:
+            _, a_html_filename = tempfile.mkstemp(suffix='.html', dir=tempdir)
+            a_gz_filename = a_html_filename + '.gz'
+            gzip_cache.create_gzip_file(a_html_filename)
+            gzip_hash = get_md5(a_gz_filename)
+            time.sleep(1)
+            gzip_cache.create_gzip_file(a_html_filename)
+            self.assertEqual(gzip_hash, get_md5(a_gz_filename))
+
+
+def get_md5(filepath):
+    with open(filepath, 'rb') as fh:
+        return md5(fh.read()).hexdigest()

+ 6 - 2
liquid_tags/video.py

@@ -49,7 +49,11 @@ def video(preprocessor, tag, markup):
         poster = groups[9]
 
     if any(videos):
-        video_out =  "<video width='{width}' height='{height}' preload='none' controls poster='{poster}'>".format(width=width, height=height, poster=poster)
+        video_out = """
+        <div class="videobox">
+            <video width="{width}" height="{height}" preload="none" controls poster="{poster}">
+        """.format(width=width, height=height, poster=poster).strip()
+
         for vid in videos:
             base, ext = os.path.splitext(vid)
             if ext not in VID_TYPEDICT:
@@ -57,7 +61,7 @@ def video(preprocessor, tag, markup):
                                  "{0}".format(ext))
             video_out += ("<source src='{0}' "
                           "{1}>".format(vid, VID_TYPEDICT[ext]))
-        video_out += "</video>"
+        video_out += "</video></div>"
     else:
         raise ValueError("Error processing input, "
                          "expected syntax: {0}".format(SYNTAX))

+ 9 - 2
liquid_tags/vimeo.py

@@ -24,7 +24,7 @@ from .mdx_liquid_tags import LiquidTags
 
 SYNTAX = "{% vimeo id [width height] %}"
 
-VIMEO = re.compile(r'(\w+)(\s+(\d+)\s(\d+))?')
+VIMEO = re.compile(r'(\S+)(\s+(\d+)\s(\d+))?')
 
 
 @LiquidTags.register('vimeo')
@@ -41,7 +41,14 @@ def vimeo(preprocessor, tag, markup):
         height = groups[3] or height
 
     if vimeo_id:
-        vimeo_out = '<div style="width:{width}px; height:{height}px;"><iframe src="//player.vimeo.com/video/{vimeo_id}?title=0&amp;byline=0&amp;portrait=0" width="{width}" height="{height}" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></div>'.format(width=width, height=height, vimeo_id=vimeo_id)
+        vimeo_out = """
+            <div class="videobox">
+                <iframe src="//player.vimeo.com/video/{vimeo_id}?title=0&amp;byline=0&amp;portrait=0"
+                        width="{width}" height="{height}" frameborder="0"
+                        webkitAllowFullScreen mozallowfullscreen allowFullScreen>
+                </iframe>
+            </div>
+        """.format(width=width, height=height, vimeo_id=vimeo_id).strip()
     else:
         raise ValueError("Error processing input, "
                          "expected syntax: {0}".format(SYNTAX))

+ 10 - 2
liquid_tags/youtube.py

@@ -24,7 +24,7 @@ from .mdx_liquid_tags import LiquidTags
 
 SYNTAX = "{% youtube id [width height] %}"
 
-YOUTUBE = re.compile(r'(\w+)(\s+(\d+)\s(\d+))?')
+YOUTUBE = re.compile(r'([\S]+)(\s+(\d+)\s(\d+))?')
 
 @LiquidTags.register('youtube')
 def youtube(preprocessor, tag, markup):
@@ -40,7 +40,15 @@ def youtube(preprocessor, tag, markup):
         height = groups[3] or height
 
     if youtube_id:
-        youtube_out = "<iframe width='{width}' height='{height}' src='http://www.youtube.com/embed/{youtube_id}' frameborder='0' webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>".format(width=width, height=height, youtube_id=youtube_id)
+        youtube_out = """
+            <div class="videobox">
+                <iframe width="{width}" height="{height}"
+                        src='http://www.youtube.com/v/{youtube_id}'
+                        frameborder='0'
+                        webkitAllowFullScreen mozallowfullscreen allowFullScreen>
+                </iframe>
+            </div>
+        """.format(width=width, height=height, youtube_id=youtube_id).strip()
     else:
         raise ValueError("Error processing input, "
                          "expected syntax: {0}".format(SYNTAX))

+ 1 - 0
pelican-flickr

@@ -0,0 +1 @@
+Subproject commit e1b6dddf2cd12aef4096d2b01e5af6e15d46683a

+ 1 - 0
pelican-gist

@@ -0,0 +1 @@
+Subproject commit 4cce3dad9e7d03511bd04734def69f5fe2958ee5

+ 3 - 1
pelican_comment_system/Readme.md

@@ -1,6 +1,6 @@
 # Pelican comment system
 The pelican comment system allows you to add static comments to your articles.
-The comments are stored in Markdown files. Each comment in it own file.
+The comments are stored in files which can be processed by Pelican (e.g.: Markdown, reStructuredText, ...). Each comment in its own file.
 
 #### Features
  - Static comments for each article
@@ -23,6 +23,8 @@ Bernhard Scheirle  | <http://blog.scheirle.de> | <https://github.com/Scheirle>
  - [Comment Form (aka: never gather Metadata)](doc/form.md)
  
 ## Requirements
+Pelican 3.4 or newer is required.
+
 To create identicons the Python Image Library is needed. Therefore you either need PIL **or** Pillow (recommended).
 
 ##### Install Pillow

+ 61 - 53
pelican_comment_system/avatars.py

@@ -1,6 +1,6 @@
 # -*- coding: utf-8 -*-
 """
-
+Author: Bernhard Scheirle
 """
 
 from __future__ import unicode_literals
@@ -14,11 +14,11 @@ import hashlib
 logger = logging.getLogger(__name__)
 _log = "pelican_comment_system: avatars: "
 try:
-	from . identicon import identicon
-	_identiconImported = True
+    from . identicon import identicon
+    identiconImported = True
 except ImportError as e:
-	logger.warning(_log + "identicon deactivated: " + str(e))
-	_identiconImported = False
+    logger.warning(_log + "identicon deactivated: " + str(e))
+    _identiconImported = False
 
 # Global Variables
 _identicon_save_path = None
@@ -29,66 +29,74 @@ _initialized = False
 _authors = None
 _missingAvatars = []
 
+
 def _ready():
-	if not _initialized:
-		logger.warning(_log + "Module not initialized. use init")
-	if not _identicon_data:
-		logger.debug(_log + "No identicon data set")
-	return _identiconImported and _initialized and _identicon_data
-
-
-def init(pelican_output_path, identicon_output_path, identicon_data, identicon_size, authors):
-	global _identicon_save_path
-	global _identicon_output_path
-	global _identicon_data
-	global _identicon_size
-	global _initialized
-	global _authors
-	_identicon_save_path = os.path.join(pelican_output_path, identicon_output_path)
-	_identicon_output_path = identicon_output_path
-	_identicon_data = identicon_data
-	_identicon_size = identicon_size
-	_authors = authors
-	_initialized = True
+    if not _initialized:
+        logger.warning(_log + "Module not initialized. use init")
+    if not _identicon_data:
+        logger.debug(_log + "No identicon data set")
+    return _identiconImported and _initialized and _identicon_data
+
+
+def init(pelican_output_path, identicon_output_path, identicon_data,
+         identicon_size, authors):
+    global _identicon_save_path
+    global _identicon_output_path
+    global _identicon_data
+    global _identicon_size
+    global _initialized
+    global _authors
+    if _initialized:
+        return
+    _identicon_save_path = os.path.join(pelican_output_path,
+                                        identicon_output_path)
+    _identicon_output_path = identicon_output_path
+    _identicon_data = identicon_data
+    _identicon_size = identicon_size
+    _authors = authors
+    _initialized = True
+
 
 def _createIdenticonOutputFolder():
-	if not _ready():
-		return
+    if not _ready():
+        return
 
-	if not os.path.exists(_identicon_save_path):
-		os.makedirs(_identicon_save_path)
+    if not os.path.exists(_identicon_save_path):
+        os.makedirs(_identicon_save_path)
 
 
 def getAvatarPath(comment_id, metadata):
-	if not _ready():
-		return ''
+    if not _ready():
+        return ''
+
+    md5 = hashlib.md5()
+    author = tuple()
+    for data in _identicon_data:
+        if data in metadata:
+            string = "{}".format(metadata[data])
+            md5.update(string.encode('utf-8'))
+            author += tuple([string])
+        else:
+            logger.warning(_log + data +
+                           " is missing in comment: " + comment_id)
 
-	md5 = hashlib.md5()
-	author = tuple()
-	for data in _identicon_data:
-		if data in metadata:
-			string = str(metadata[data])
-			md5.update(string.encode('utf-8'))
-			author += tuple([string])
-		else:
-			logger.warning(_log + data + " is missing in comment: " + comment_id)
+    if author in _authors:
+        return _authors[author]
 
-	if author in _authors:
-		return _authors[author]
+    global _missingAvatars
 
-	global _missingAvatars
+    code = md5.hexdigest()
 
-	code = md5.hexdigest()
+    if not code in _missingAvatars:
+        _missingAvatars.append(code)
 
-	if not code in _missingAvatars:
-		_missingAvatars.append(code)
+    return os.path.join(_identicon_output_path, '%s.png' % code)
 
-	return os.path.join(_identicon_output_path, '%s.png' % code)
 
 def generateAndSaveMissingAvatars():
-	_createIdenticonOutputFolder()
-	for code in _missingAvatars:
-		avatar_path = '%s.png' % code
-		avatar = identicon.render_identicon(int(code, 16), _identicon_size)
-		avatar_save_path = os.path.join(_identicon_save_path, avatar_path)
-		avatar.save(avatar_save_path, 'PNG')
+    _createIdenticonOutputFolder()
+    for code in _missingAvatars:
+        avatar_path = '%s.png' % code
+        avatar = identicon.render_identicon(int(code, 16), _identicon_size)
+        avatar_save_path = os.path.join(_identicon_save_path, avatar_path)
+        avatar.save(avatar_save_path, 'PNG')

+ 57 - 38
pelican_comment_system/comment.py

@@ -1,45 +1,64 @@
 # -*- coding: utf-8 -*-
 """
-
+Author: Bernhard Scheirle
 """
 from __future__ import unicode_literals
-from pelican import contents
+import os
+
 from pelican.contents import Content
+from pelican.utils import slugify
+
+from . import avatars
+
 
 class Comment(Content):
-	mandatory_properties = ('author', 'date')
-	default_template = 'None'
-
-	def __init__(self, id, avatar, content, metadata, settings, source_path, context):
-		super(Comment,self).__init__( content, metadata, settings, source_path, context )
-		self.id = id
-		self.replies = []
-		self.avatar = avatar
-		self.title = "Posted by:  " + str(metadata['author'])
-
-	def addReply(self, comment):
-		self.replies.append(comment)
-
-	def getReply(self, id):
-		for reply in self.replies:
-			if reply.id == id:
-				return reply
-			else:
-				deepReply = reply.getReply(id)
-				if deepReply != None:
-					return deepReply
-		return None
-
-	def __lt__(self, other):
-		return self.metadata['date'] < other.metadata['date']
-
-	def sortReplies(self):
-		for r in self.replies:
-			r.sortReplies()
-		self.replies = sorted(self.replies)
-
-	def countReplies(self):
-		amount = 0
-		for r in self.replies:
-			amount += r.countReplies()
-		return amount + len(self.replies)
+    mandatory_properties = ('author', 'date')
+    default_template = 'None'
+
+    def __init__(self, content, metadata, settings, source_path, context):
+        # Strip the path off the full filename.
+        name = os.path.split(source_path)[1]
+
+        if not hasattr(self, 'slug'):
+            #compute the slug before initializing the base Content object, so
+            # it doesn't get set there
+            # This is required because we need a slug containing the file
+            # extension.
+            self.slug = slugify(name, settings.get('SLUG_SUBSTITUTIONS', ()))
+
+        super(Comment, self).__init__(content, metadata, settings, source_path,
+                                      context)
+
+        self.replies = []
+
+        # Strip the extension from the filename.
+        name = os.path.splitext(name)[0]
+        self.avatar = avatars.getAvatarPath(name, metadata)
+        self.title = "Posted by:  {}".format(metadata['author'])
+
+    def addReply(self, comment):
+        self.replies.append(comment)
+
+    def getReply(self, slug):
+        for reply in self.replies:
+            if reply.slug == slug:
+                return reply
+            else:
+                deepReply = reply.getReply(slug)
+                if deepReply is not None:
+                    return deepReply
+        return None
+
+    def __lt__(self, other):
+        return self.metadata['date'] < other.metadata['date']
+
+    def sortReplies(self):
+        for r in self.replies:
+            r.sortReplies()
+        self.replies = sorted(self.replies)
+
+    def countReplies(self):
+        amount = 0
+        for r in self.replies:
+            amount += r.countReplies()
+        return amount + len(self.replies)

+ 2 - 2
pelican_comment_system/doc/feed.md

@@ -4,14 +4,14 @@ Be sure that the id of the html tag containing the comment matches `COMMENT_URL`
 
 ##### pelicanconf.py
 ```python
-COMMENT_URL = "#my_own_comment_id_{path}"
+COMMENT_URL = "#my_own_comment_id_{slug}"
 ```
 
 ##### Theme
 ```html
 {% for comment in article.comments recursive %}
 	...
-	<article id="my_own_comment_id_{{comment.id}}">{{ comment.content }}</article>
+	<article id="my_own_comment_id_{{comment.slug}}">{{ comment.content }}</article>
 	...
 {% endfor %}
 ```

+ 1 - 1
pelican_comment_system/doc/form.md

@@ -8,7 +8,7 @@ The resulting email contains a valid markdown block. Now you only have to copy t
 Add this in the "comment for loop" in your article theme, so your visitors can reply to a comment.
 
 ```html
-<button onclick="reply('{{comment.id | urlencode}}');">Reply</button>
+<button onclick="reply('{{comment.slug | urlencode}}');">Reply</button>
 ```
 
 #### Form

+ 9 - 9
pelican_comment_system/doc/installation.md

@@ -1,7 +1,7 @@
 # Installation
 Activate the plugin by adding it to your `pelicanconf.py`
 
-	PLUGIN_PATH = '/path/to/pelican-plugins'
+	PLUGIN_PATH = ['/path/to/pelican-plugins']
 	PLUGINS = ['pelican_comment_system']
 	PELICAN_COMMENT_SYSTEM = True
 
@@ -11,13 +11,13 @@ And modify your `article.html` theme (see below).
 Name                                           | Type      | Default                    | Description
 -----------------------------------------------|-----------|----------------------------|-------
 `PELICAN_COMMENT_SYSTEM`                       | `boolean` | `False`                    | Activates or deactivates the comment system
-`PELICAN_COMMENT_SYSTEM_DIR`                   | `string`  | `comments`                 | Folder where the comments are stored
+`PELICAN_COMMENT_SYSTEM_DIR`                   | `string`  | `comments`                 | Folder where the comments are stored, relative to `PATH`
 `PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH` | `string`  | `images/identicon`         | Relative URL to the output folder where the identicons are stored
 `PELICAN_COMMENT_SYSTEM_IDENTICON_DATA`        | `tuple`   | `()`                       | Contains all Metadata tags, which in combination identifies a comment author (like `('author', 'email')`)
 `PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE`        | `int`     | `72`                       | Width and height of the identicons. Has to be a multiple of 3.
 `PELICAN_COMMENT_SYSTEM_AUTHORS`               | `dict`    | `{}`                       | Comment authors, which should have a specific avatar. More info [here](avatars.md)
 `PELICAN_COMMENT_SYSTEM_FEED`                  | `string`  |`feeds/comment.%s.atom.xml` | Relative URL to output the Atom feed for each article.`%s` gets replaced with the slug of the article. More info [here](http://docs.getpelican.com/en/latest/settings.html#feed-settings)
-`COMMENT_URL`                                  | `string`  | `#comment-{path}`          | `{path}` gets replaced with the id of the comment. More info [here](feed.md)
+`COMMENT_URL`                                  | `string`  | `#comment-{slug}`          | `{slug}` gets replaced with the slug of the comment. More info [here](feed.md)
 
 ## Folder structure
 Every comment file has to be stored in a sub folder of `PELICAN_COMMENT_SYSTEM_DIR`.
@@ -46,7 +46,8 @@ Tag           | Required  | Description
 --------------|-----------|----------------
 `date`        | yes       | Date when the comment was posted
 `author`      | yes       | Name of the comment author
-`replyto`     | no        | Identifier of the parent comment. Identifier = Filename (**with** extension)
+`slug`        | no        | Slug of the comment. If not present it will be computed from the file name (including the extension)
+`replyto`     | no        | Slug of the parent comment
 
 Every other (custom) tag gets parsed as well and will be available through the theme.
 
@@ -55,7 +56,7 @@ Every other (custom) tag gets parsed as well and will be available through the t
 	date: 2014-3-21 15:02
 	author: Author of the comment
 	website: http://authors.website.com
-	replyto: 7
+	replyto: 1md
 	anothermetatag: some random tag
 
 	Content of the comment.
@@ -69,13 +70,12 @@ Variables                | Description
 `article.comments`       | Array containing the top level comments for this article (no replies to comments)
 
 ### Comment object
-The comment object is a [content](https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L34) object, so all common attributes are available (like author, content, date, local_date, metadata, ...).
+The comment object is a [content](https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L34) object, so all common attributes are available (like author, content, date, local_date, slug, metadata, ...).
 
 Additional following attributes are added:
 
 Attribute  | Description
 -----------|--------------------------
-`id`       | Identifier of this comment
 `replies`  | Array containing the top level replies for this comment
 `avatar`   | Path to the avatar or identicon of the comment author
 
@@ -89,8 +89,8 @@ Attribute  | Description
 		{% else %}
 			{% set marginLeft = 50 %}
 		{% endif %}
-			<article id="comment-{{comment.id}}" style="border: 1px solid #DDDDDD; padding: 5px 0px 0px 5px; margin: 0px -1px 5px {{marginLeft}}px;">
-				<a href="{{ SITEURL }}/{{ article.url }}#comment-{{comment.id}}" rel="bookmark" title="Permalink to this comment">Permalink</a>
+			<article id="comment-{{comment.slug}}" style="border: 1px solid #DDDDDD; padding: 5px 0px 0px 5px; margin: 0px -1px 5px {{marginLeft}}px;">
+				<a href="{{ SITEURL }}/{{ article.url }}#comment-{{comment.slug}}" rel="bookmark" title="Permalink to this comment">Permalink</a>
 				<h4>{{ comment.author }}</h4>
 				<p>Posted on <abbr class="published" title="{{ comment.date.isoformat() }}">{{ comment.locale_date }}</abbr></p>
 				{{ comment.metadata['my_custom_metadata'] }}

+ 111 - 75
pelican_comment_system/pelican_comment_system.py

@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
 
 from itertools import chain
 from pelican import signals
-from pelican.readers import MarkdownReader
+from pelican.readers import Readers
 from pelican.writers import Writer
 
 from . comment import Comment
@@ -24,98 +24,134 @@ from . import avatars
 
 
 def pelican_initialized(pelican):
-	from pelican.settings import DEFAULT_CONFIG
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM', False)
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_DIR' 'comments')
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH' 'images/identicon')
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_DATA', ())
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE', 72)
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_AUTHORS', {})
-	DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_FEED', os.path.join('feeds', 'comment.%s.atom.xml'))
-	DEFAULT_CONFIG.setdefault('COMMENT_URL', '#comment-{path}')
-	if pelican:
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM', False)
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_DIR', 'comments')
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH', 'images/identicon')
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_DATA', ())
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE', 72)
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_AUTHORS', {})
-		pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_FEED', os.path.join('feeds', 'comment.%s.atom.xml'))
-		pelican.settings.setdefault('COMMENT_URL', '#comment-{path}')
-
+    from pelican.settings import DEFAULT_CONFIG
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM', False)
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_DIR', 'comments')
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH' 'images/identicon')
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_DATA', ())
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE', 72)
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_AUTHORS', {})
+    DEFAULT_CONFIG.setdefault('PELICAN_COMMENT_SYSTEM_FEED', os.path.join('feeds', 'comment.%s.atom.xml'))
+    DEFAULT_CONFIG.setdefault('COMMENT_URL', '#comment-{slug}')
+    DEFAULT_CONFIG['PAGE_EXCLUDES'].append(DEFAULT_CONFIG['PELICAN_COMMENT_SYSTEM_DIR'])
+    DEFAULT_CONFIG['ARTICLE_EXCLUDES'].append(DEFAULT_CONFIG['PELICAN_COMMENT_SYSTEM_DIR'])
+    if pelican:
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM', False)
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_DIR', 'comments')
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH', 'images/identicon')
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_DATA', ())
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE', 72)
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_AUTHORS', {})
+        pelican.settings.setdefault('PELICAN_COMMENT_SYSTEM_FEED', os.path.join('feeds', 'comment.%s.atom.xml'))
+        pelican.settings.setdefault('COMMENT_URL', '#comment-{slug}')
+
+        pelican.settings['PAGE_EXCLUDES'].append(pelican.settings['PELICAN_COMMENT_SYSTEM_DIR'])
+        pelican.settings['ARTICLE_EXCLUDES'].append(pelican.settings['PELICAN_COMMENT_SYSTEM_DIR'])
 
 def initialize(article_generator):
-	avatars.init(
-		article_generator.settings['OUTPUT_PATH'],
-		article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH'],
-		article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_DATA'],
-		article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE']/3,
-		article_generator.settings['PELICAN_COMMENT_SYSTEM_AUTHORS'],
-		)
+    avatars.init(
+        article_generator.settings['OUTPUT_PATH'],
+        article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_OUTPUT_PATH'],
+        article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_DATA'],
+        article_generator.settings['PELICAN_COMMENT_SYSTEM_IDENTICON_SIZE']/3,
+        article_generator.settings['PELICAN_COMMENT_SYSTEM_AUTHORS'],
+        )
+
+
+def warn_on_slug_collision(items):
+    slugs = {}
+    for comment in items:
+        if not comment.slug in slugs:
+            slugs[comment.slug] = [comment]
+        else:
+            slugs[comment.slug].append(comment)
+
+    for slug, itemList in slugs.items():
+        len_ = len(itemList)
+        if len_ > 1:
+            logger.warning('There are %s comments with the same slug: %s' %
+                           (len_, slug))
+            for x in itemList:
+                logger.warning('    %s' % x.source_path)
+
+
+def write_feed(gen, items, context, slug):
+    if gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] is None:
+        return
+
+    path = gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] % slug
+
+    writer = Writer(gen.output_path, settings=gen.settings)
+    writer.write_feed(items, context, path)
+
 
 def add_static_comments(gen, content):
-	if gen.settings['PELICAN_COMMENT_SYSTEM'] != True:
-		return
+    if gen.settings['PELICAN_COMMENT_SYSTEM'] is not True:
+        return
 
-	content.comments_count = 0
-	content.comments = []
+    content.comments_count = 0
+    content.comments = []
 
-	#Modify the local context, so we get proper values for the feed
-	context = copy.copy(gen.context)
-	context['SITEURL'] += "/" + content.url
-	context['SITENAME'] = "Comments for: " + content.title
-	context['SITESUBTITLE'] = ""
-	path = gen.settings['PELICAN_COMMENT_SYSTEM_FEED'] % content.slug
-	writer = Writer(gen.output_path, settings=gen.settings)
+    #Modify the local context, so we get proper values for the feed
+    context = copy.copy(gen.context)
+    context['SITEURL'] += "/" + content.url
+    context['SITENAME'] += " - Comments: " + content.title
+    context['SITESUBTITLE'] = ""
 
-	folder = os.path.join(gen.settings['PELICAN_COMMENT_SYSTEM_DIR'], content.slug)
+    folder = os.path.join(
+        gen.settings['PATH'],
+        gen.settings['PELICAN_COMMENT_SYSTEM_DIR'],
+        content.slug
+    )
 
-	if not os.path.isdir(folder):
-		logger.debug("No comments found for: " + content.slug)
-		writer.write_feed( [], context, path)
-		return
+    if not os.path.isdir(folder):
+        logger.debug("No comments found for: " + content.slug)
+        write_feed(gen, [], context, content.slug)
+        return
 
-	reader = MarkdownReader(gen.settings)
-	comments = []
-	replies = []
+    reader = Readers(gen.settings)
+    comments = []
+    replies = []
 
-	for file in os.listdir(folder):
-		name, extension = os.path.splitext(file)
-		if extension[1:].lower() in reader.file_extensions:
-			com_content, meta = reader.read(os.path.join(folder, file))
-			
-			avatar_path = avatars.getAvatarPath(name, meta)
+    for file in os.listdir(folder):
+        name, extension = os.path.splitext(file)
+        if extension[1:].lower() in reader.extensions:
+            com = reader.read_file(
+                base_path=folder, path=file,
+                content_class=Comment, context=context)
 
-			com = Comment(file, avatar_path, com_content, meta, gen.settings, file, context)
+            if hasattr(com, 'replyto'):
+                replies.append(com)
+            else:
+                comments.append(com)
 
-			if 'replyto' in meta:
-				replies.append( com )
-			else:
-				comments.append( com )
+    warn_on_slug_collision(comments + replies)
 
-	writer.write_feed( comments + replies, context, path)
+    write_feed(gen, comments + replies, context, content.slug)
 
-	#TODO: Fix this O(n²) loop
-	for reply in replies:
-		for comment in chain(comments, replies):
-			if comment.id == reply.metadata['replyto']:
-				comment.addReply(reply)
+    #TODO: Fix this O(n²) loop
+    for reply in replies:
+        for comment in chain(comments, replies):
+            if comment.slug == reply.replyto:
+                comment.addReply(reply)
 
-	count = 0
-	for comment in comments:
-		comment.sortReplies()
-		count += comment.countReplies()
+    count = 0
+    for comment in comments:
+        comment.sortReplies()
+        count += comment.countReplies()
 
-	comments = sorted(comments)
+    comments = sorted(comments)
+
+    content.comments_count = len(comments) + count
+    content.comments = comments
 
-	content.comments_count = len(comments) + count
-	content.comments = comments
 
 def writeIdenticonsToDisk(gen, writer):
-	avatars.generateAndSaveMissingAvatars()
+    avatars.generateAndSaveMissingAvatars()
+
 
 def register():
-	signals.initialized.connect(pelican_initialized)
-	signals.article_generator_init.connect(initialize)
-	signals.article_generator_write_article.connect(add_static_comments)
-	signals.article_writer_finalized.connect(writeIdenticonsToDisk)
+    signals.initialized.connect(pelican_initialized)
+    signals.article_generator_init.connect(initialize)
+    signals.article_generator_write_article.connect(add_static_comments)
+    signals.article_writer_finalized.connect(writeIdenticonsToDisk)

+ 1 - 0
pelicanfly

@@ -0,0 +1 @@
+Subproject commit 265865f693092f6409f4e4ef451ff7543fa4e350

+ 1 - 0
pin_to_top

@@ -0,0 +1 @@
+Subproject commit 4c022ecbd958cbf5538e06d5bd233d048902dad4

+ 1 - 1
post_stats/readability.py

@@ -30,7 +30,7 @@ def normalize(text):
 def text_stats(text, wc):
     text = normalize(text)
     stcs = [s.split(" ") for s in text.split(". ")]
-    stcs = filter(lambda s: len(s) >= 2, stcs)
+    stcs = [s for s in stcs if len(s) >= 2]
 
     if wc:
         words = wc

+ 39 - 2
representative_image/Readme.md

@@ -1,8 +1,45 @@
 # Summary
 
-This plugin extracts a representative image (i.e, featured image) from the article's summary or article's content. The image can be access at `article.featured_image`. 
+This plugin extracts a representative image (i.e, featured image) from the article's summary or content if not specifed in the metadata. 
 
-The plugin also remove any images from the summary after extraction to avoid duplication. 
+The plugin also removes any images from the summary after extraction to avoid duplication. 
 
 It allows the flexibility on where and how to display the featured image of an article together with its summary in a template page. For example, the article metadata can be displayed in thumbnail format, in which there is a short summary and an image. The layout of the summary and the image can be varied for aesthetical purpose. It doesn't have to depend on article's content format. 
 
+Installation
+------------
+
+This plugin requires BeautifulSoup. 
+
+	pip install beautifulsoup4
+
+To enable, add the following to your settings.py:
+
+    PLUGIN_PATH = 'path/to/pelican-plugins'
+    PLUGINS = ["representative_image"]
+
+`PLUGIN_PATH` can be a path relative to your settings file or an absolute path.
+
+Usage
+-----
+
+To override the default behaviour of selecting the first image in the article's summary or content, set the image property the article's metadata to the url of the image to display, e.g:
+
+```markdown
+Title: My super title
+Date: 2010-12-03 10:20
+Category: Python
+Tags: pelican, publishing
+Slug: my-super-post
+Author: Alexis Metaireau
+Summary: Short version for index and feeds
+Image: /images/my-super-image.png
+
+Article content...
+```
+
+To include a representative image in a page add the following to the template:
+
+    {% if  article.featured_image %}
+        <img src="{{ article.featured_image }}">
+    {% endif %}

+ 3 - 0
representative_image/representative_image.py

@@ -5,6 +5,9 @@ from bs4 import BeautifulSoup
 def images_extraction(instance):
     representativeImage = None
     if type(instance) == Article:
+        if 'image' in instance.metadata:
+            representativeImage = instance.metadata['image']
+
         # Process Summary:
         # If summary contains images, extract one to be the representativeImage and remove images from summary
         soup = BeautifulSoup(instance.summary, 'html.parser')

+ 14 - 0
representative_image/test_representative_image.py

@@ -9,6 +9,7 @@ TEST_CONTENT = str(generate_lorem_ipsum(n=3, html=True)) + '<img src="' + TEST_C
 TEST_SUMMARY_IMAGE_URL = 'https://testimage.com/summary.jpg'
 TEST_SUMMARY_WITHOUTIMAGE = str(generate_lorem_ipsum(n=1, html=True))
 TEST_SUMMARY_WITHIMAGE = TEST_SUMMARY_WITHOUTIMAGE + '<img src="' + TEST_SUMMARY_IMAGE_URL + '"/>'
+TEST_CUSTOM_IMAGE_URL = 'https://testimage.com/custom.jpg' 
 
 
 from pelican.contents import Article
@@ -43,6 +44,19 @@ class TestRepresentativeImage(unittest.TestCase):
         self.assertEqual(article.featured_image, TEST_SUMMARY_IMAGE_URL)
         self.assertEqual(article.summary, TEST_SUMMARY_WITHOUTIMAGE)
 
+    def test_extract_image_from_summary_with_custom_image(self):
+        args = {
+            'content': TEST_CONTENT,
+            'metadata': {
+                'summary': TEST_SUMMARY_WITHIMAGE,
+                'image': TEST_CUSTOM_IMAGE_URL,
+            },
+        }
+
+        article = Article(**args)
+        self.assertEqual(article.featured_image, TEST_CUSTOM_IMAGE_URL)
+        self.assertEqual(article.summary, TEST_SUMMARY_WITHOUTIMAGE)
+
 if __name__ == '__main__':
     unittest.main()
         

+ 24 - 3
summary/Readme.rst

@@ -1,10 +1,10 @@
 Summary
 -------
 
-This plugin allows easy, variable length summaries directly embedded into the 
+This plugin allows easy, variable length summaries directly embedded into the
 body of your articles. It introduces two new settings: ``SUMMARY_BEGIN_MARKER``
 and ``SUMMARY_END_MARKER``: strings which can be placed directly into an article
-to mark the beginning and end of a summary. When found, the standard 
+to mark the beginning and end of a summary. When found, the standard
 ``SUMMARY_MAX_LENGTH`` setting will be ignored. The markers themselves will also
 be removed from your articles before they are published. The default values
 are ``<!-- PELICAN_BEGIN_SUMMARY -->`` and ``<!-- PELICAN_END_SUMMARY -->``.
@@ -16,7 +16,7 @@ For example::
     Category: yeah
     Slug: my-super-post
     Author: Alexis Metaireau
-    
+
     This is the content of my super blog post.
     <!-- PELICAN_END_SUMMARY -->
     and this content occurs after the summary.
@@ -25,3 +25,24 @@ Here, the summary is taken to be the first line of the post. Because no
 beginning marker was found, it starts at the top of the body. It is possible
 to leave out the end marker instead, in which case the summary will start at the
 beginning marker and continue to the end of the body.
+
+reST example
+~~~~~~~~~~~~
+
+Inserting the markers into a reStructuredText document makes use of the
+comment directive, because raw HTML is automatically escaped. The reST equivalent of the above Markdown example looks like this::
+
+    My super title
+    ##############
+
+    :date: 2010-12-03 10:20
+    :tags: thats, awesome
+    :category: yeah
+    :slug: my-super-post
+    :author: Alexis Metaireau
+
+    This is the content of my super blog post.
+
+    .. PELICAN_END_SUMMARY
+
+    and this content occurs after the summary.

+ 7 - 4
thumbnailer/thumbnailer.py

@@ -106,10 +106,13 @@ class _resizer(object):
         if not path.exists(out_path):
             os.makedirs(out_path)
         if not path.exists(filename):
-            image = Image.open(in_path)
-            thumbnail = self.resize(image)
-            thumbnail.save(filename)
-            logger.info("Generated Thumbnail {0}".format(path.basename(filename)))
+            try:
+                image = Image.open(in_path)
+                thumbnail = self.resize(image)
+                thumbnail.save(filename)
+                logger.info("Generated Thumbnail {0}".format(path.basename(filename)))
+            except IOError:
+                logger.info("Generating Thumbnail for {0} skipped".format(path.basename(filename)))
 
 
 def resize_thumbnails(pelican):

+ 36 - 0
tipue_search/tipue_search.py

@@ -15,6 +15,10 @@ import os.path
 import json
 from bs4 import BeautifulSoup
 from codecs import open
+try:
+    from urlparse import urljoin
+except ImportError:
+    from urllib.parse import urljoin
 
 from pelican import signals
 
@@ -26,8 +30,11 @@ class Tipue_Search_JSON_Generator(object):
         self.output_path = output_path
         self.context = context
         self.siteurl = settings.get('SITEURL')
+        self.tpages = settings.get('TEMPLATE_PAGES')
+        self.output_path = output_path
         self.json_nodes = []
 
+
     def create_json_node(self, page):
 
         if getattr(page, 'status', 'published') != 'published':
@@ -54,6 +61,32 @@ class Tipue_Search_JSON_Generator(object):
 
         self.json_nodes.append(node)
 
+
+    def create_tpage_node(self, srclink):
+
+        srcfile = open(os.path.join(self.output_path, self.tpages[srclink]))
+        soup = BeautifulSoup(srcfile, 'html.parser')
+        page_text = soup.get_text()
+
+        # What happens if there is not a title.
+        if soup.title is not None:
+            page_title = soup.title.string
+        else:
+            page_title = ''
+
+        # Should set default category?
+        page_category = ''
+
+        page_url = urljoin(self.siteurl, self.tpages[srclink])
+
+        node = {'title': page_title,
+                'text': page_text,
+                'tags': page_category,
+                'loc': page_url}
+        
+        self.json_nodes.append(node)
+
+
     def generate_output(self, writer):
         path = os.path.join(self.output_path, 'tipuesearch_content.json')
 
@@ -62,6 +95,9 @@ class Tipue_Search_JSON_Generator(object):
         for article in self.context['articles']:
             pages += article.translations
 
+        for srclink in self.tpages:
+            self.create_tpage_node(srclink)
+
         for page in pages:
             self.create_json_node(page)
         root_node = {'pages': self.json_nodes}

+ 7 - 0
touch/README.rst

@@ -0,0 +1,7 @@
+Touch plugin
+############
+
+A simple plugin doing a touch on your generated files using the date metadata
+from the content.
+
+This helps, into other things, to have the web server gently manage the cache.

+ 31 - 0
touch/__init__.py

@@ -0,0 +1,31 @@
+from pelican import signals
+
+import logging
+import os
+import time
+
+
+logger = logging.getLogger(__name__)
+
+
+def set_file_utime(path, datetime):
+    mtime = time.mktime(datetime.timetuple())
+    logger.info('touching %s', path)
+    os.utime(path, (mtime, mtime))
+
+
+def touch_file(path, context):
+    content = context.get('article', context.get('page'))
+    page = context.get('articles_page')
+    dates = context.get('dates')
+
+    if content and hasattr(content, 'date'):
+        set_file_utime(path, content.date)
+    elif page:
+        set_file_utime(path, max(x.date for x in page.object_list))
+    elif dates:
+        set_file_utime(path, max(x.date for x in dates))
+
+
+def register():
+    signals.content_written.connect(touch_file)