diff --git a/docs/changelog.rst b/docs/changelog.rst index 54b0d871..976eecc8 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,7 +4,8 @@ Release history Next release ============ -- Nothing yet +* Added the `:modified:` metadata field to complement `:date:`. + Used to specify the last date and time an article was updated independently from the date and time it was published. 3.3.0 (2013-09-24) ================== diff --git a/docs/getting_started.rst b/docs/getting_started.rst index 201b9ad4..4860576c 100644 --- a/docs/getting_started.rst +++ b/docs/getting_started.rst @@ -301,6 +301,7 @@ this metadata in text files via the following syntax (give your file the ############## :date: 2010-10-03 10:20 + :modified: 2010-10-04 18:40 :tags: thats, awesome :category: yeah :slug: my-super-post @@ -320,6 +321,7 @@ pattern:: Title: My super title Date: 2010-12-03 10:20 + Modified: 2010-12-05 19:30 Category: Python Tags: pelican, publishing Slug: my-super-post @@ -341,6 +343,7 @@ interprets the HTML in a very straightforward manner, reading metadata from My super title + @@ -367,6 +370,10 @@ the W3C's `suggested subset ISO 8601`__. __ `W3C ISO 8601`_ +``modified`` should be last time you updated the article, and defaults to ``date`` if not specified. +Besides you can show ``modified`` in the templates, feed entries in feed readers will be updated automatically +when you set ``modified`` to the current date after you modified your article. + If you do not explicitly specify summary metadata for a given post, the ``SUMMARY_MAX_LENGTH`` setting can be used to specify how many words from the beginning of an article are used as the summary. diff --git a/pelican/contents.py b/pelican/contents.py index 059c54a7..96794026 100644 --- a/pelican/contents.py +++ b/pelican/contents.py @@ -113,6 +113,10 @@ class Content(object): if hasattr(self, 'date'): self.locale_date = strftime(self.date, self.date_format) + if not hasattr(self, 'modified'): + self.modified = self.date + if hasattr(self, 'modified'): + self.locale_modified = strftime(self.modified, self.date_format) # manage status if not hasattr(self, 'status'): diff --git a/pelican/readers.py b/pelican/readers.py index 6c279abc..c286e801 100644 --- a/pelican/readers.py +++ b/pelican/readers.py @@ -42,6 +42,7 @@ from pelican.utils import get_date, pelican_open METADATA_PROCESSORS = { 'tags': lambda x, y: [Tag(tag, y) for tag in x.split(',')], 'date': lambda x, y: get_date(x), + 'modified': lambda x, y: get_date(x), 'status': lambda x, y: x.strip(), 'category': Category, 'author': Author, @@ -521,6 +522,7 @@ def default_metadata(settings=None, process=None): metadata['category'] = value if 'DEFAULT_DATE' in settings and settings['DEFAULT_DATE'] != 'fs': metadata['date'] = datetime.datetime(*settings['DEFAULT_DATE']) + metadata['modified'] = metadata['date'] return metadata @@ -530,6 +532,7 @@ def path_metadata(full_path, source_path, settings=None): if settings.get('DEFAULT_DATE', None) == 'fs': metadata['date'] = datetime.datetime.fromtimestamp( os.stat(full_path).st_ctime) + metadata['modified'] = metadata['date'] metadata.update(settings.get('EXTRA_PATH_METADATA', {}).get( source_path, {})) return metadata diff --git a/pelican/tests/content/article_with_markdown_and_footnote.md b/pelican/tests/content/article_with_markdown_and_footnote.md index dc257d62..332ccea6 100644 --- a/pelican/tests/content/article_with_markdown_and_footnote.md +++ b/pelican/tests/content/article_with_markdown_and_footnote.md @@ -1,8 +1,9 @@ Title: Article with markdown containing footnotes Date: 2012-10-31 +Modified: 2012-11-01 Summary: Summary with **inline** markup *should* be supported. This is some content[^1] with some footnotes[^footnote] [^1]: Numbered footnote -[^footnote]: Named footnote \ No newline at end of file +[^footnote]: Named footnote diff --git a/pelican/tests/content/article_with_markdown_and_nonascii_summary.md b/pelican/tests/content/article_with_markdown_and_nonascii_summary.md index e26cc009..d76ed4a1 100644 --- a/pelican/tests/content/article_with_markdown_and_nonascii_summary.md +++ b/pelican/tests/content/article_with_markdown_and_nonascii_summary.md @@ -1,6 +1,7 @@ Title: マックOS X 10.8でパイソンとVirtualenvをインストールと設定 Slug: python-virtualenv-on-mac-osx-mountain-lion-10.8 Date: 2012-12-20 +Modified: 2012-12-22 Tags: パイソン, マック Category: 指導書 Summary: パイソンとVirtualenvをまっくでインストールする方法について明確に説明します。 diff --git a/pelican/tests/content/article_with_md_extension.md b/pelican/tests/content/article_with_md_extension.md index 1f111796..89b6980c 100644 --- a/pelican/tests/content/article_with_md_extension.md +++ b/pelican/tests/content/article_with_md_extension.md @@ -2,6 +2,7 @@ Title: Test md File Category: test Tags: foo, bar, foobar Date: 2010-12-02 10:14 +Modified: 2010-12-02 10:20 Summary: I have a lot to test Test Markdown File Header diff --git a/pelican/tests/content/article_with_metadata.rst b/pelican/tests/content/article_with_metadata.rst index d4bac1c0..c5768cfb 100644 --- a/pelican/tests/content/article_with_metadata.rst +++ b/pelican/tests/content/article_with_metadata.rst @@ -4,6 +4,7 @@ This is a super article ! :tags: foo, bar, foobar :date: 2010-12-02 10:14 +:modified: 2010-12-02 10:20 :category: yeah :author: Alexis Métaireau :summary: diff --git a/pelican/tests/output/basic/a-markdown-powered-article.html b/pelican/tests/output/basic/a-markdown-powered-article.html index 6bc29eba..40c96766 100644 --- a/pelican/tests/output/basic/a-markdown-powered-article.html +++ b/pelican/tests/output/basic/a-markdown-powered-article.html @@ -35,7 +35,7 @@