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
Add ATOM_PATH setting #3015
Add ATOM_PATH setting #3015
Conversation
I started working on this feature. Currently i struggle to test it. Maybe Pythons “Development Mode” can help. |
Now i have a shell with the dependencies installed and nikola installed with Nix is a great help as it has this integrated: https://nixos.org/nixpkgs/manual/#development-mode Just put
This works at least on Linux, on macOS is a dependency missing i think. Would you like a PR for that? Now i'm able to build my website, no change in atom path as expected. |
Now it works! Please review. This feature changes the default behavior of the atom link generation. Should that be documented clearer? |
Looks good, except: in case ATOM_PATH
was not set by the user, but INDEX_PATH
was set, the Atom for the main index is suddenly put somewhere else with this change.
Because of that, I would initialize ATOM_PATH
with the value of INDEX_PATH
in case that was set by the user (somewhere in nikola.py
), and adjust the documentation accordingly. Otherwise, we would be breaking backwards compatibility.
nikola/plugins/task/indexes.py
Outdated
@@ -92,7 +92,8 @@ def get_path(self, classification, lang, dest_type='page'): | |||
"""Return a path for the given classification.""" | |||
if dest_type == 'rss': | |||
return [self.site.config['RSS_PATH'](lang)], True |
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.
Please change the True
to 'auto'
(I apparently forgot to change this a long time ago).
nikola/plugins/task/indexes.py
Outdated
@@ -92,7 +92,8 @@ def get_path(self, classification, lang, dest_type='page'): | |||
"""Return a path for the given classification.""" | |||
if dest_type == 'rss': | |||
return [self.site.config['RSS_PATH'](lang)], True | |||
# 'page' (index) or 'feed' (Atom) | |||
if dest_type == 'feed': | |||
return [self.site.config['ATOM_PATH'](lang)], True |
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.
Please also change the True
to "auto"
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.
Is 'auto'
ok or exactly "auto"
? I think it makes no difference and is better in this case.
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.
Ah sorry, I wanted to write 'auto'
here as well :)
Apropos, I'm ususally testing with |
@felixfontein Nix does that, this way pip installs every dependency that is not installed by Nix into /tmp/.... This way you get a temporary development environment without messing up your python install. When i set
the links in the
Now the RSS and Atom link are similar, but have strange file names. Still breaking backwards compatibility. With this setting
the links are
I can set this for Atom and leave RSS as is, then it's backwards compatible. But we should change this in 8.0 to have consistent links among RSS and Atom by default. I can't set it like this in
NameError: name 'INDEX_PATH' is not defined I have to sleep now. Day is dawning already. |
f1a967b
to
dc46106
Compare
As you noticed in #3016, Atom feeds work differently to RSS. We generate them with the same data as
This feature will be v8-only. To do this properly, you’d do it after config is loaded from config['ATOM_PATH'] = config['ATOM_PATH'] if config['ATOM_PATH'] else config['INDEX_PATH']
# ninja edit:
config['ATOM_PATH'] = config['ATOM_PATH'] or config['INDEX_PATH']
I don’t think we need that. The more typical route (virtualenv + |
@Kwpolska What is the reason for that? It seems not to be useful to subscribe to the With your suggested change, i get That can be achived with this lines added in nikola.py at line 616:
Resulting in I suggest to have the same behavior with RSS and Atom path, at least in 8 since it breaks backwards compatibility. |
That’s the way this feature was written. I suppose the use-case was to have pagination between atom feeds. But perhaps we could clean it up and drop that? My code snippet was just an untested example. That said, if you’re letting people customize the path, you should also ask for the file extension (some people might want |
If there is no good reason for this behavior, sure. That's a topic for the other issue.
My first idea was to have What default behavior do you want for this feature?
|
I vote for option 1. |
Thanks. I changed it accordingly. I noticed that when i set |
Are you sure it’s broken? It’s percent-encoding, and looks like UTF-8, so it will work in most sane environments. (Will work on modern Linux. May crash on macOS and Windows if web server is not careful enough.) |
It works, but look strange. So, no problem. |
I've tried running your branch with one of my blogs, and I got:
I didn't set After replacing |
... Why can't |
@tritium21 you’re missing context. |
@Kwpolska if you're building URLs (not for paths for files on disk, which i assumed the context was), then, yes, the os.path alias is not what to use. import posixpath directly (yes, it is always available, even on windows) |
Looks like I was able to do that myself. |
It now works with my blogs (using the default @davidak: does the current version also works with your blog? |
Another thing to look at: 987f186 |
@felixfontein i have also tested it with my blog and default URLs as expected:
And also with
and no change with
with
with
with
That was my initial requirement for this feature, great. |
#3043 was just merged. |
LGTM, except for the fact that ALL_PAGE_DEPS
(brand new, needs merge/rebase from master) should now be used instead of GLOBAL_CONTEXT
.
@@ -225,6 +225,10 @@ | |||
# output / TRANSLATION[lang] / RSS_PATH / rss.xml | |||
# RSS_PATH = "" | |||
|
|||
# Final location for the blog main Atom feed is: | |||
# output / TRANSLATION[lang] / ATOM_PATH / index.atom | |||
# ATOM_PATH = "" |
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.
(FYI, this file does not need to be updated.)
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.
Should we leave this change anyway?
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.
Whatever.
@@ -95,7 +95,8 @@ def get_path(self, classification, lang, dest_type='page'): | |||
self.site.config['RSS_PATH'](lang), | |||
self.site.config['RSS_FILENAME_BASE'](lang) | |||
], 'auto' | |||
# 'page' (index) or 'feed' (Atom) | |||
if dest_type == 'feed': | |||
return [self.site.config['ATOM_PATH'](lang)], 'always' |
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.
@felixfontein: why is page number support not implemented for feeds?
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.
Well, that would be a simple change. But:
- nobody asked for it so far (I think);
- there's still the big open question why the many .atom feed files are needed after all (multiple atom feed files generated #3016).
I'd like to see an answer to #3016 first.
Thanks for contributing, @davidak! |
Pull Request Checklist
Description
Add ATOM_PATH setting, similar to RSS_PATH.
Reference #2971