Feed enumeration, alt support#16
Open
eigengrau wants to merge 4 commits into
Open
Conversation
goanpeca
reviewed
Jul 16, 2018
| return feeds | ||
|
|
||
| def atom_feeds(self, for_page=None): | ||
| if not for_page: |
Member
There was a problem hiding this comment.
Better to be explicit and use if page is None ?
43b4920 to
6c3241d
Compare
Contributor
Author
|
For a project I needed “real” support for feed alternatives, so I came up with 6c3241d. This replaces field names by template expressions, so that we can localize things we otherwise can’t. For convenience, we also support alt-specific config values, so there’s no need to copy-paste feed settings. |
cfe1101 to
c40f134
Compare
This adds support for a Jinja function/filter, “atom_feeds”, which can be used to enumerate all feeds defined in the project (“atom_feeds()”), or those relevant to the page being generated (“atom_feeds(for_page=this)”). This is convenient, e.g., to define a generic site header which automatically displays a “subscribe” link on those pages which generate feeds.
While lektor-atom currently supports creating feed variants by relying on specially-crafted item query expressions, this is only useful for item model fields that contain natural language strings. When creating feeds based on structured data, this is not helpful, since field values are identical across two alts. E.g., when we would like to publish a feed based on PDF attachments that have a `volume_number` set, we are currently unable to have the English feed display item titles as »Volume 1« in the English feed resp. »Ausgabe 1« in the German alternative. This commit adds support for such use-cases by adding two new mechanisms: 1. Instead of supplying field names to map records to Atom entries, the user supplies a Jinja template. These expressions are evaluated with `this` bound to the blog resp. the item record. 2. For a feed named `feed`, configuration values are first looked-up in the config file section `[feed.ALT]`, where `ALT` is the alternative currently being generated. This allows settings defaults in `[feed]`, and overriding only those settings that are locale-specific by adding them to `[feed.ALT]`. As a side-effect, this also benefits users that don’t use alternatives, since it enables them to compose item titles, bodies, etc. using multiple fields at the same time. Fixes lektor#3, lektor#13.
Lektor sometimes yields invalid URLs for attachment records that have ‘alt’ set. We work around this by forcing the primary alt when linking to attachments.
c40f134 to
663fa0f
Compare
Member
|
:-p @nixjdm ? |
|
I've rebased and submitted a PR to the author of this feature. If you're still interested in merging this and would like a new PR with the rebased code, let me know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds support for a Jinja function/filter, “atom_feeds”, which can be used
to enumerate all feeds defined in the project (“atom_feeds()”), or those
relevant to the page being generated (“atom_feeds(for_page=this)”).
This is convenient, e.g., to define a generic site header which automatically
displays a “subscribe” link on those pages which generate feeds.