Permalink
Browse files

Basic fix for #1671

  • Loading branch information...
ralsina committed May 1, 2015
1 parent a35ebf1 commit 2d3a5aa043142a4a20a9ee215acf5c627f9a7988
Showing with 20 additions and 3 deletions.
  1. +1 −0 CHANGES.txt
  2. +7 −0 docs/manual.txt
  3. +1 −0 nikola/plugins/compile/rest/post_list.py
  4. +11 −3 nikola/plugins/task/posts.py
View
@@ -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;
View
@@ -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``::
@@ -180,6 +180,7 @@ def run(self):
if not posts:
return []
+ self.state.document.settings.record_dependencies.add("####MAGIC####TIMELINE")
template_data = {
'lang': lang,
@@ -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):
@@ -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.