-
Notifications
You must be signed in to change notification settings - Fork 460
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
[WIP] Basic support for itunes rss tags #2674
Conversation
nikola/utils.py
Outdated
@@ -1272,13 +1286,66 @@ def publish_extensions(self, handler): | |||
}) | |||
handler.endElement("atom:link") | |||
|
|||
if self.itunes_author: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could duplicate less code, eg. with getattr
or some iTunes data dictionary.
Looks good (apart from a lot of duplicated code). Please update CHANGES.txt, AUTHORS.txt, and the manual. |
nikola/utils.py
Outdated
self.itunes_categories = itunes_categories | ||
self.itunes_explicit = itunes_explicit | ||
|
||
return rss.RSS2.__init__(self, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don’t use return
here, instead call rss.RSS2.__init__
at the start of this function. (old-style class in Python 2, so super()
does not work(
First, thank you for reviewing this pull request! I returned As for the duplicated code: can you provide a pointer to somewhere else in the codebase that does something similar better? (It'd just be nice to have an example of what idiom is considered most normal in this codebase.) I'm also not happy with my handling of the |
itunes = {'itunes:subtitle': 'foo'}
# in publish_extensions
for name in ['itunes:author', 'itunes:subtitle', 'itunes:summary', 'itunes:duration']:
if name in itunes:
handler.startElement(name, {})
handler.characters(itunes[name])
handler.endElement(name)
# special handling for image and explicit stays
|
@@ -1649,7 +1649,7 @@ def apply_shortcodes(self, data, filename=None, lang=None, with_dependencies=Fal | |||
|
|||
def generic_rss_renderer(self, lang, title, link, description, timeline, output_path, | |||
rss_teasers, rss_plain, feed_length=10, feed_url=None, | |||
enclosure=_enclosure, rss_links_append_query=None): | |||
enclosure=_enclosure, rss_links_append_query=None, itunes=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Souldn't the default value for itunes
be False
and not None
? After all, it is only used like a boolean.
It is my habit to use `None` for a default value so that the underlying
code can distinguish between "unspecified" and "explicitly false."
But f that's counter to expectation here, I'm fine to change it.
…On Sun, Feb 19, 2017, 9:44 AM Felix Fontein ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In nikola/nikola.py
<#2674 (comment)>:
> @@ -1649,7 +1649,7 @@ def apply_shortcodes(self, data, filename=None, lang=None, with_dependencies=Fal
def generic_rss_renderer(self, lang, title, link, description, timeline, output_path,
rss_teasers, rss_plain, feed_length=10, feed_url=None,
- enclosure=_enclosure, rss_links_append_query=None):
+ enclosure=_enclosure, rss_links_append_query=None, itunes=None):
Souldn't the default value for itunes be False and not None? After all,
it is only used like a boolean.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2674 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAVYVrrbUgbW6yKbDMlA6LI62SOsncVvks5reHFjgaJpZM4MFans>
.
|
|
I see now that I've added explicit references to my "postcast" plugin in this Nikola core PR; so I'm going to have to factor that out. Comments welcome on the other bits, though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, apart from minor style glitches.
nikola/nikola.py
Outdated
or post.author(lang)) | ||
args['itunes_summary'] = post.meta[lang].get('itunes_summary') or data | ||
if 'itunes_image' in post.meta[lang]: | ||
args['itunes_image'] = self.url_replacer(post.permalink(), post.meta[lang]['itunes_image'], lang, 'absolute') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just keep in mind that the permalink won’t affect parsing of itunes_image
paths, hey should be relative to site root (in your posts).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That hasn't been my experience. With this code, the image is located relative to the post's location, and then an absolute url to that location is generated.
edit: it appears to work exactly like a standard image directive.
nikola/nikola.py
Outdated
for tag in ('subtitle', 'duration', 'explicit'): | ||
key = 'itunes_{}'.format(tag) | ||
args[key] = post.meta[lang].get(key) | ||
args['itunes_author'] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write that on one line, will look better and fix a style checker complaint.
nikola/utils.py
Outdated
# It's an old style class | ||
rss.RSS2.__init__(self, **kwargs) | ||
|
||
def _itunes_attributes (self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the space before (self)
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops. That's a minor stylistic affectation I use in my own code, but don't intend to inflict on anyone. Just a habit. :)
|
||
class ExtendedItem(rss.RSSItem): | ||
"""Extended RSS item.""" | ||
|
||
def __init__(self, **kw): | ||
def __init__(self, itunes_author=None, itunes_subtitle=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use the kw
dict as well for your itunes attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't that kind of reading-into-kwargs defeat static code analysis? If you don't declare what arguments you take in your function definition, you're unnecessarily hiding information.
At least, that's been my take on it in the past.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep it this way if it was started this way — perhaps there’s a reason for using kw
there?
I'm actually going a different way on this; leave this open for now, but I'd prefer to merge #2686 rather than this, and do my iTunes-specific stuff in my plugin rather than pollute core. |
Since now #2686 is merged, can we close this @anderbubble? |
@felixfontein for sure. Thanks. |
I'm working on enhancing Nikola to support publishing a podcast RSS feed. Most of this work is going into a "postcast" plugin I'm working on, and will submit or publish eventually; but some of what I'm trying to do requires support in Nikola itself.
This PR aims to support iTunes-specific tags in RSS feeds.
Other related PRs I'm working on:
I'd also be interested in direction for where and how to publish a plugin, when that's ready.
todo