Skip to content

Commit

Permalink
Basic fix for #1671
Browse files Browse the repository at this point in the history
  • Loading branch information
ralsina committed May 1, 2015
1 parent a35ebf1 commit 2d3a5aa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -18,6 +18,7 @@ Features
Bugfixes
--------

* Posts/Pages that use post-list will never be up to date (Issue #1671)
* Support using post.text() in post_list_directive.tmpl (Issue #1671)
* Avoid recursive dep when using post-list in a post (Issue #1671)
* Encode IDNs to Punycode in ``nikola init`` and in links;
Expand Down
7 changes: 7 additions & 0 deletions docs/manual.txt
Expand Up @@ -1635,6 +1635,13 @@ and it will produce:
Post List
~~~~~~~~~

.. WARNING::

Any post or page that uses this directive will **never** be considered up-to-date,
meaning that every time you build the site, that post/page and everything that
depends on it (tag pages, RSS feeds, sitemap, etc.) will be rebuilt.


This directive can be used to generate a list of posts. You could use it, for
example, to make a list of the latest 5 blog posts, or a list of all blog posts
with the tag ``nikola``::
Expand Down
1 change: 1 addition & 0 deletions nikola/plugins/compile/rest/post_list.py
Expand Up @@ -180,6 +180,7 @@ def run(self):

if not posts:
return []
self.state.document.settings.record_dependencies.add("####MAGIC####TIMELINE")

template_data = {
'lang': lang,
Expand Down
14 changes: 11 additions & 3 deletions nikola/plugins/task/posts.py
Expand Up @@ -37,7 +37,11 @@ def update_deps(post, lang, task):
dependencies into a .dep file. This file is read and incorporated when calling
post.fragment_deps(), and only available /after/ compiling the fragment.
"""
task.file_dep.update(post.fragment_deps(lang))
task.file_dep.update([p for p in post.fragment_deps(lang) if not p.startswith("####MAGIC####")])


def dependence_on_timeline(post, lang):
return "####MAGIC####TIMELINE" not in post.fragment_deps(lang)


class RenderPosts(Task):
Expand All @@ -63,15 +67,19 @@ def gen_tasks(self):
deps_dict.pop('timeline')
for post in kw['timeline']:
dest = post.translated_base_path(lang)
file_dep = [p for p in post.fragment_deps(lang) if not p.startswith("####MAGIC####")]
task = {
'basename': self.name,
'name': dest,
'file_dep': post.fragment_deps(lang),
'file_dep': file_dep,
'targets': [dest],
'actions': [(post.compile, (lang, )),
(update_deps, (post, lang, )),
],
'clean': True,
'uptodate': [utils.config_changed(deps_dict, 'nikola.plugins.task.posts')] + post.fragment_deps_uptodate(lang),
'uptodate': [
utils.config_changed(deps_dict, 'nikola.plugins.task.posts'),
lambda p=post, l=lang: dependence_on_timeline(p, l)
] + post.fragment_deps_uptodate(lang),
}
yield task

0 comments on commit 2d3a5aa

Please sign in to comment.