Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting custom GUID in feeds (fixes #2378) #2687

Merged
merged 1 commit into from
Mar 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Features
``OPTIPNG_EXECUTABLE``, ``JPEGOPTIM_EXECUTABLE`` and
``HTML_TIDY_EXECUTABLE`` to configure executables for built-in filters.
(Issue #2615)
* Allow setting custom GUID in feeds (Issue #2378)

Bugfixes
--------
Expand Down
4 changes: 4 additions & 0 deletions docs/manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ category
Like tags, except each post can have only one, and they usually have
more descriptive names.

guid
String used as GUID in RSS feeds and as ID in Atom feeds instead of the
permalink.

link
Link to original source for content. May be displayed by some themes.

Expand Down
4 changes: 2 additions & 2 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,7 @@ def generic_rss_renderer(self, lang, title, link, description, timeline, output_
post.date.astimezone(dateutil.tz.tzutc())),
'categories': post._tags.get(lang, []),
'creator': post.author(lang),
'guid': post.permalink(lang, absolute=True),
'guid': post.guid(lang),
}

if post.author(lang):
Expand Down Expand Up @@ -2397,7 +2397,7 @@ def atom_post_text(post, text):
entry_title = lxml.etree.SubElement(entry_root, "title")
entry_title.text = post.title(lang)
entry_id = lxml.etree.SubElement(entry_root, "id")
entry_id.text = post.permalink(lang, absolute=True)
entry_id.text = post.guid(lang)
entry_updated = lxml.etree.SubElement(entry_root, "updated")
entry_updated.text = post.formatted_updated('webiso')
entry_published = lxml.etree.SubElement(entry_root, "published")
Expand Down
11 changes: 11 additions & 0 deletions nikola/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ def description(self, lang=None):
lang = nikola.utils.LocaleBorg().current_lang
return self.meta[lang]['description']

def guid(self, lang=None):
"""Return localized GUID."""
if lang is None:
lang = nikola.utils.LocaleBorg().current_lang
if self.meta[lang]['guid']:
guid = self.meta[lang]['guid']
else:
guid = self.permalink(lang, absolute=True)

return guid

def add_dependency(self, dependency, add='both', lang=None):
"""Add a file dependency for tasks using that post.

Expand Down