Skip to content
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

Attempting to fix #2496. #2695

Merged
merged 12 commits into from Apr 2, 2017
Merged

Attempting to fix #2496. #2695

merged 12 commits into from Apr 2, 2017

Conversation

felixfontein
Copy link
Contributor

fixes #2496. closes #2498 (superseeded by this).

@felixfontein
Copy link
Contributor Author

The last commit should fix the texts, but also induces a potentially backwards compatibility breaking change in case a post scanner plugin needs the final site._GLOBAL_CONTEXT in its set_site.

The only way to avoid this is probably to get rid of the bad compilers optimization completely. This would also make all the new code superfluous and simplify logic a lot.

@felixfontein
Copy link
Contributor Author

@ralsina: any thoughts and comments?

@Kwpolska
Copy link
Member

@felixfontein I might not have enough time for a review until the weekend.


def supported_extensions(self):
"""Return a list of supported file extensions, or None if such a list isn't known beforehand."""
return list(set([os.path.splitext(x[0])[1] for x in self.site.config['post_pages']]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be made simpler. Since we dropped 2.6 support, you can use set comprehensions ({i for i in x}). And even if we didn’t, using a generator expression inside set(i for i in x) would look better.

        return list({os.path.splitext(x[0])[1] for x in self.site.config['post_pages']})

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

nikola/nikola.py Outdated
@@ -1729,7 +1759,7 @@ def generic_rss_feed(self, lang, title, link, description, timeline,
post.date.astimezone(dateutil.tz.tzutc())),
'categories': post._tags.get(lang, []),
'creator': post.author(lang),
'guid': post.guid(lang),
'guid': post.permalink(lang, absolute=True),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this intentional or are those just some leftovers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are definitely leftovers!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like that was the only one which got in. I've removed it by now.

@felixfontein
Copy link
Contributor Author

@Kwpolska: take your time! A couple of days more don't really matter ;)

nikola/nikola.py Outdated
self.disabled_compiler_extensions = defaultdict(list)
self.bad_compilers = set([])
for k, v in compilers.items():
# self.config['COMPILERS'][k] = sorted(list(v))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requires a comment to explain (and shouldn’t have commented-out code)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a leftover from the original code. I've removed it and simplified the thing.

utils.LOGGER.debug('Not loading compiler extension {}', p[-1].name)
if to_add:
self.plugin_manager._candidates = self._filter_duplicate_plugins(to_add)
self.plugin_manager.loadPlugins()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are plugins loaded through here activated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Until that point, only plugins of type PostScanner have been activated, and all others not. Since we only added plugins of type PageCompiler or compiler extensions (plugins having compiler set) no plugin should be forgotten.

(Except if a post scanner plugin has compiler set in its .plugin file. I assumed such plugins don't exist.)

nikola/nikola.py Outdated
compilers[compiler].add(candidate)

# Avoid redundant compilers
# Remove compilers that match nothing in POSTS/PAGES
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could use an explanation of how we gather the compilers, and perhaps a better name than bad_compilers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed bad_compilers, since the same information is already contained in disabled_compilers and nothing in core or plugins was using it.

Is the explanation in 53e5f6e good enough, or do you want something more detailed?

@Kwpolska
Copy link
Member

Kwpolska commented Apr 2, 2017

LGTM. How much testing have you done? Have you tested it with some other PostScanner plugin?

@felixfontein
Copy link
Contributor Author

I've tested it with my pages and blogs; they all use the hierarchical pages post scanner plugin (https://plugins.getnikola.com/v7/hierarchical_pages/), and one of them another post scanner plugin I'm currently working on. So far it seems to work fine.

@felixfontein
Copy link
Contributor Author

(I'm using a slightly adjusted version of the hierarchical pages plugin which defines supported_extensions; and used the other plugin first without and later with such a function as well. So it looks like it works both for non-updated as well as updated plugins.)

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
@Kwpolska
Copy link
Member

Kwpolska commented Apr 2, 2017

It works fine in both cases (tested with the plugins site). Merging.

@Kwpolska Kwpolska merged commit 4fb64ab into master Apr 2, 2017
@Kwpolska Kwpolska deleted the fix-2496-second-try branch April 2, 2017 17:51
felixfontein added a commit to getnikola/plugins that referenced this pull request Apr 2, 2017
felixfontein added a commit to getnikola/plugins that referenced this pull request Apr 2, 2017
@felixfontein
Copy link
Contributor Author

Thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PostScanner plugins have problems due to compilers being disabled if not used by default post scanning plugin
2 participants