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] Change draft, private and mathjax to own metadata (#2761) #3066
Conversation
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 think we should at least deprecate the tags feature and convince users to convert their input files, and definitely don’t mention the old tags as much in the docs.
nikola/conf.py.in
Outdated
|
||
# If set to True, the tags 'draft', 'mathjax' and 'private' have special | ||
# meaning. If set to False, these tags are handled like regular tags. | ||
# USE_TAG_METADATA = 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.
I wouldn’t mind deprecating the tags in v8, conf.py-defaulting this to False
, and providing a plugin that can upgrade posts from the old format to the new.
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'll give the plugin a shot tomorrow.
if status == 'trash': | ||
LOGGER.warn('Trashed post "{0}" will not be imported.'.format(title)) | ||
return False | ||
elif status == 'private': | ||
tags.append('private') | ||
if self.site.config['USE_TAG_METADATA']: |
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 bother.
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.
Gone.
nikola/post.py
Outdated
self._tags[lang].remove('private') | ||
status = self.meta[lang].get('status') | ||
if status: | ||
if status == 'published': |
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.
rewrite this, make it shorter (three lines above, one line in each if block)
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 rewrote this, but not completely: I don't want to update post_status
in case status
has an invalid value. (Of course, we could turn this into an error. But it might screw up existing blogs which for whatever reason used status
metadata already...)
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 would be me and the projectpages
plugin (I guess I’ll make it devstatus
from now on.)
nikola/post.py
Outdated
@@ -312,14 +343,28 @@ def _has_pretty_url(self, lang): | |||
|
|||
@property | |||
def is_mathjax(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.
This could be renamed to has_math
for consistency and neatness.
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 keep a is_mathjax
dummy which logs that an update needs to be done to the theme, and returns the new has_math
value? Otherwise, we might break some custom themes.
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.
This is v8, feel free to break themes. (They should switch to math_helper.tmpl
anyways.)
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.
Done.
I've now taken a look at your |
… new sites with the new system.
f06db0b
to
61ebd06
Compare
Re upgrader plugin: this should be doable, as metadata extractors can also write to files. If posts don’t know what extractor data comes from, that could be changed — or we could just let users modify their post themselves. |
Bonus feature request: support |
I've added |
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
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.
LGTM (with very minor fixes I applied)
nikola/post.py
Outdated
show_warning = True | ||
if show_warning: | ||
LOGGER.warn('It is suggested that you convert special tags to metadata and set ' + | ||
'USE_TAG_METADATA to False. You can use the XXX command plugin for ' + |
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 that sentence about this plugin for the time being so we can merge this more quickly.
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.
Bonus code style hint: you do not need +
to join two strings literals separated by whitespace.
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.
Fixed.
CHANGES.txt
Outdated
@@ -20,8 +20,8 @@ Features | |||
-------- | |||
|
|||
* Tags ``draft``, ``private`` and ``mathjax`` are no longer treated | |||
special if ``USE_TAG_METADATA`` is set to ``True`` (default for |
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.
Good catch! Thanks :)
nikola/post.py
Outdated
@@ -359,13 +359,13 @@ def has_math(self): | |||
return True | |||
lang = nikola.utils.LocaleBorg().current_lang | |||
if self.is_translation_available(lang): | |||
if self.meta[lang].get('has_math') in ('true', 'True', 'yes'): | |||
if self.meta[lang].get('has_math') in ('true', 'True', 'yes', '1', 1, 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.
Good idea!
Ok. I guess we can merge this for now; I'll open a new PR for the plugin then. |
Thanks for getting this done! |
Thanks for reviewing and merging! |
Fixes #2761.
First try. Hacked together on a train ride. More will follow during the next days :)