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

Initial JSON Feed implementation #229

Merged
merged 11 commits into from May 22, 2017

Conversation

Projects
None yet
2 participants
@Kwpolska
Member

Kwpolska commented May 21, 2017

Fixes getnikola/nikola#2779.

An experimental implementation of the JSON Feed specification (version 1).

Currently only supports main blog RSS (/feed.json). Other items are not supported, but are planned for the future.

  • tags → missing for untranslated tags
  • categories
  • sections
  • galleries (painful without changes in Core?)
  • archives (WIP; getnikola/nikola#2783)
  • authors
  • add links (JSONFEED_APPEND_LINKS)

Comments, ideas, insights welcome. (I had to make some uglier architectural decisions, including duplicating code, because this is not in Core.)

Kwpolska added some commits May 21, 2017

jsonfeed: Generate absolute previewimage URLs
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
jsonfeed: Add post dependencies correctly
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@felixfontein

This comment has been minimized.

Contributor

felixfontein commented May 21, 2017

BTW, how about a bit of infrastructure in Nikola core which allows to add new feed types (or remove existing ones by disabling corresponding plugins)? Currently, RSS and Atom are kind of hard-coded and it is hard to change their behavior.

Also, Atom and RSS behave very differently: Atom is like another representation of the accompanying HTML page, while RSS is what I traditionally knew as a feed. I guess the infrastructure would have to support both modes. Or are there even more modes than these two to consider?

jsonfeed: support for author, category, section_index, tag
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska

This comment has been minimized.

Member

Kwpolska commented May 21, 2017

How many feed types are there, really? I don’t think we need to bother. This plugin works pretty well without any core changes, the only things I can’t handle very nicely from here would be galleries (but it’s doable with some copy-paste, I’ll see if it’s doable later).

@felixfontein There is an issue with tags: site.posts_per_classification does not have untranslated tags. Those tags do get RSS feeds and indexes, should I use something else?

@felixfontein

This comment has been minimized.

Contributor

felixfontein commented May 21, 2017

This also happens for categories, and it is some kind of left-over from the past / something for compatibility to the old version.

There's some extra code in taxonomies.py which collects tag and category names from all languages when also_create_classifications_from_other_languages is True, which happens precisely for the tag and category taxonomies. I guess you have to copy that behavior.

(I'd personally would be happy if we'd remove this behavior from the taxonomies at some point in the future. I don't see any reason why these should be generated in the first place.)

@felixfontein

This comment has been minimized.

Contributor

felixfontein commented May 21, 2017

About feed types: no idea. I'm happy with RSS and Atom (though I still don't know what Atom is for anyway). It would just also clean up the RSS and Atom code a bit, currently explicit RSS and Atom handling is all over the place.

jsonfeed: support untranslated tags/categories
(Adds support for also_create_classifications_from_other_languages)
h/t @felixfontein

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@felixfontein

This comment has been minimized.

Contributor

felixfontein commented on v7/jsonfeed/jsonfeed.py in 315c886 May 21, 2017

You could ask the taxonomy object to create context and use the title from there. Then it would be the same title as used for the HTML pages or other feeds.

@felixfontein

This comment has been minimized.

Contributor

felixfontein commented on v7/jsonfeed/jsonfeed.py in 315c886 May 21, 2017

Sections can have them, for example. If you call Taxonomy.provide_context_and_uptodate you can extract title and description from there, and fallback to the defaults you used in case they don't provide them.

This comment has been minimized.

Member

Kwpolska replied May 21, 2017

Yeah, I realized that a while ago. Those were kind of placeholders.

Kwpolska added some commits May 21, 2017

jsonfeed: Archive support; titles and descriptions
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
jsonfeed: update docs
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
jsonfeed: add links to feeds
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska

This comment has been minimized.

Member

Kwpolska commented May 21, 2017

This is pretty done now, there seem to be some dependency problems (probably caused by template_handlers). I’ll look at it tomorrow.

@felixfontein make an issue in the main repo for also_create… and other things in Taxonomies that should be deprecated/changed in v8.

Kwpolska added some commits May 22, 2017

jsonfeed: depend on taxonomies and make dirs
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Fix typo in README.md
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
jsonfeed: Minor style fixes
Signed-off-by: Chris Warrick <kwpolska@gmail.com>

@Kwpolska Kwpolska merged commit 953e196 into master May 22, 2017

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@Kwpolska Kwpolska deleted the jsonfeed branch May 22, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment