From 6c9d158609f10963e83c9bc18e355f9ce2673869 Mon Sep 17 00:00:00 2001 From: Dominique Plante Date: Sat, 18 May 2013 06:33:49 -0700 Subject: [PATCH 01/45] makes Pelican-quickstart debuggable in PyCharm --- pelican/tools/pelican_quickstart.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py index a6045256..8d697fa3 100755 --- a/pelican/tools/pelican_quickstart.py +++ b/pelican/tools/pelican_quickstart.py @@ -283,3 +283,6 @@ needed by Pelican. print('Error: {0}'.format(e)) print('Done. Your new project is available at %s' % CONF['basedir']) + +if __name__ == "__main__": + main() \ No newline at end of file From 39dd4a025581cfa3b4d6256a3b8f327b26372e1d Mon Sep 17 00:00:00 2001 From: Kyle Machulis Date: Fri, 14 Jun 2013 12:12:19 -0700 Subject: [PATCH 02/45] Changed meta tag "contents" attribute to "content", to conform to HTML spec. Fixes #918 --- docs/getting_started.rst | 10 +++++----- pelican/readers.py | 15 ++++++++++++--- pelican/tests/content/article_with_keywords.html | 2 +- pelican/tests/content/article_with_metadata.html | 12 ++++++------ .../article_with_metadata_and_contents.html | 15 +++++++++++++++ .../content/article_with_uppercase_metadata.html | 2 +- pelican/tests/test_readers.py | 15 +++++++++++++++ 7 files changed, 55 insertions(+), 16 deletions(-) create mode 100644 pelican/tests/content/article_with_metadata_and_contents.html diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 383acdc4..1e31f26d 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -265,11 +265,11 @@ interprets the HTML in a very straightforward manner, reading metadata from My super title - - - - - + + + + + This is the content of my super blog post. diff --git a/pelican/readers.py b/pelican/readers.py index bd9f5914..fb2ccfc4 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -5,6 +5,7 @@ import datetime import logging import os import re +import logging try: import docutils import docutils.core @@ -47,6 +48,8 @@ METADATA_PROCESSORS = { 'author': Author, } +logger = logging.getLogger(__name__) + class Reader(object): enabled = True @@ -199,7 +202,7 @@ class HTMLReader(Reader): enabled = True class _HTMLParser(HTMLParser): - def __init__(self, settings): + def __init__(self, settings, filename): HTMLParser.__init__(self) self.body = '' self.metadata = {} @@ -207,6 +210,8 @@ class HTMLReader(Reader): self._data_buffer = '' + self._filename = filename + self._in_top_level = True self._in_head = False self._in_title = False @@ -275,7 +280,11 @@ class HTMLReader(Reader): def _handle_meta_tag(self, attrs): name = self._attr_value(attrs, 'name').lower() - contents = self._attr_value(attrs, 'contents', '') + contents = self._attr_value(attrs, 'content', '') + if not contents: + contents = self._attr_value(attrs, 'contents', '') + if contents: + logger.warning("Meta tag attribute 'contents' used in file %s, should be changed to 'content'", self._filename) if name == 'keywords': name = 'tags' @@ -288,7 +297,7 @@ class HTMLReader(Reader): def read(self, filename): """Parse content and metadata of HTML files""" with pelican_open(filename) as content: - parser = self._HTMLParser(self.settings) + parser = self._HTMLParser(self.settings, filename) parser.feed(content) parser.close() diff --git a/pelican/tests/content/article_with_keywords.html b/pelican/tests/content/article_with_keywords.html index c869f514..0744c754 100644 --- a/pelican/tests/content/article_with_keywords.html +++ b/pelican/tests/content/article_with_keywords.html @@ -1,6 +1,6 @@ This is a super article ! - + diff --git a/pelican/tests/content/article_with_metadata.html b/pelican/tests/content/article_with_metadata.html index b108ac8a..b501ea29 100644 --- a/pelican/tests/content/article_with_metadata.html +++ b/pelican/tests/content/article_with_metadata.html @@ -1,12 +1,12 @@ This is a super article ! - - - - - - + + + + + + Multi-line metadata should be supported diff --git a/pelican/tests/content/article_with_metadata_and_contents.html b/pelican/tests/content/article_with_metadata_and_contents.html new file mode 100644 index 00000000..b108ac8a --- /dev/null +++ b/pelican/tests/content/article_with_metadata_and_contents.html @@ -0,0 +1,15 @@ + + + This is a super article ! + + + + + + + + + Multi-line metadata should be supported + as well as inline markup. + + diff --git a/pelican/tests/content/article_with_uppercase_metadata.html b/pelican/tests/content/article_with_uppercase_metadata.html index 4fe5a9ee..b4cedf39 100644 --- a/pelican/tests/content/article_with_uppercase_metadata.html +++ b/pelican/tests/content/article_with_uppercase_metadata.html @@ -1,6 +1,6 @@ This is a super article ! - + diff --git a/pelican/tests/test_readers.py b/pelican/tests/test_readers.py index 14d42325..c67b8a1f 100644 --- a/pelican/tests/test_readers.py +++ b/pelican/tests/test_readers.py @@ -350,6 +350,21 @@ class HTMLReaderTest(ReaderTest): for key, value in expected.items(): self.assertEqual(value, page.metadata[key], key) + def test_article_with_metadata_and_contents_attrib(self): + page = self.read_file(path='article_with_metadata_and_contents.html') + expected = { + 'category': 'yeah', + 'author': 'Alexis Métaireau', + 'title': 'This is a super article !', + 'summary': 'Summary and stuff', + 'date': datetime.datetime(2010, 12, 2, 10, 14), + 'tags': ['foo', 'bar', 'foobar'], + 'custom_field': 'http://notmyidea.org', + } + for key, value in expected.items(): + self.assertEqual(value, page.metadata[key], key) + + def test_article_with_null_attributes(self): page = self.read_file(path='article_with_null_attributes.html') From 12fd53c27e133ed4e79c2f5a85ea8fb038c23b12 Mon Sep 17 00:00:00 2001 From: bas smit Date: Wed, 26 Jun 2013 13:25:20 +0200 Subject: [PATCH 03/45] Add debug target to the template makefile If the DEBUG variable is set (e.g. DEBUG=1 make target) debugging will be enabled by using pelicans -D flag. --- pelican/tools/templates/Makefile.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pelican/tools/templates/Makefile.in b/pelican/tools/templates/Makefile.in index 221568aa..fd553550 100644 --- a/pelican/tools/templates/Makefile.in +++ b/pelican/tools/templates/Makefile.in @@ -20,6 +20,11 @@ S3_BUCKET=$s3_bucket DROPBOX_DIR=$dropbox_dir +DEBUG ?= 0 +ifeq ($(DEBUG), 1) + PELICANOPTS += -D +endif + help: @echo 'Makefile for a pelican Web site ' @echo ' ' From 0d63b4520a302d5fb8e249c1d98c0043c566315b Mon Sep 17 00:00:00 2001 From: bas smit Date: Wed, 26 Jun 2013 13:58:35 +0200 Subject: [PATCH 04/45] Add info about debugging to the help output of the makefile --- pelican/tools/templates/Makefile.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pelican/tools/templates/Makefile.in b/pelican/tools/templates/Makefile.in index fd553550..80cf4737 100644 --- a/pelican/tools/templates/Makefile.in +++ b/pelican/tools/templates/Makefile.in @@ -43,7 +43,8 @@ help: @echo ' s3_upload upload the web site via S3 ' @echo ' github upload the web site via gh-pages ' @echo ' ' - + @echo 'Set the DEBUG variable to 1 to enable debugging, e.g. make DEBUG=1 html' + @echo ' ' html: clean $$(OUTPUTDIR)/index.html From 6c5444eb6833cda2ea9129321c3a4ba43505b772 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Sun, 14 Jul 2013 23:01:16 +1000 Subject: [PATCH 05/45] do slug_substitutions on category and author ... --- pelican/contents.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/pelican/contents.py b/pelican/contents.py index d56335dd..ed213c31 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -141,14 +141,21 @@ class Content(object): """Returns the URL, formatted with the proper values""" metadata = copy.copy(self.metadata) path = self.metadata.get('path', self.get_relative_source_path()) + default_category = self.settings['DEFAULT_CATEGORY'] + slug_substitutions = self.settings.get('SLUG_SUBSTITUTIONS', ()) metadata.update({ 'path': path_to_url(path), 'slug': getattr(self, 'slug', ''), 'lang': getattr(self, 'lang', 'en'), 'date': getattr(self, 'date', datetime.now()), - 'author': getattr(self, 'author', ''), - 'category': getattr(self, 'category', - self.settings['DEFAULT_CATEGORY']), + 'author': slugify( + getattr(self, 'author', ''), + slug_substitutions + ), + 'category': slugify( + getattr(self, 'category', default_category), + slug_substitutions + ) }) return metadata From 9b7ae20aa9182e7d3c10bea111716bb4e12edbd8 Mon Sep 17 00:00:00 2001 From: Nick Moore Date: Mon, 15 Jul 2013 00:22:05 +1000 Subject: [PATCH 06/45] test for author & category slugification --- pelican/tests/test_contents.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py index c081639d..af97db3f 100644 --- a/pelican/tests/test_contents.py +++ b/pelican/tests/test_contents.py @@ -191,6 +191,20 @@ class TestArticle(TestPage): custom_article = Article(**article_kwargs) self.assertEqual('custom', custom_article.template) + def test_slugify_category_author(self): + settings = get_settings() + settings['SLUG_SUBSTITUTIONS'] = [ ('C#', 'csharp') ] + settings['ARTICLE_URL'] = '{author}/{category}/{slug}/' + settings['ARTICLE_SAVE_AS'] = '{author}/{category}/{slug}/index.html' + article_kwargs = self._copy_page_kwargs() + article_kwargs['metadata']['author'] = "O'Brien" + article_kwargs['metadata']['category'] = 'C# & stuff' + article_kwargs['metadata']['title'] = 'fnord' + article_kwargs['settings'] = settings + article = Article(**article_kwargs) + self.assertEqual(article.url, 'obrien/csharp-stuff/fnord/') + self.assertEqual(article.save_as, 'obrien/csharp-stuff/fnord/index.html') + class TestURLWrapper(unittest.TestCase): def test_comparisons(self): From c5008f61e0a480afb954a5258748eec576ee9a72 Mon Sep 17 00:00:00 2001 From: Jude N Date: Tue, 16 Jul 2013 23:44:53 -0400 Subject: [PATCH 07/45] Adding a FEED_ALL_ATOM check in the "social" div. The head section has a tests for FEED_ALL_ATOM when building the atom link. This diff add a similar test in the "social" div. --- pelican/themes/notmyidea/templates/base.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pelican/themes/notmyidea/templates/base.html b/pelican/themes/notmyidea/templates/base.html index 9bf4b12b..e44e20fd 100644 --- a/pelican/themes/notmyidea/templates/base.html +++ b/pelican/themes/notmyidea/templates/base.html @@ -53,7 +53,9 @@ - - -
-
+
+ -
+