Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix #1688
  • Loading branch information
ralsina committed May 12, 2015
1 parent fa27ee5 commit ebebae7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -7,6 +7,7 @@ Features
Bugfixes
--------

* Timeline checksum for whole-timeline dependencies (Issue #1688)
* new_post paths are now relative to CWD (Issue #1325)

New in v7.4.1
Expand Down
30 changes: 23 additions & 7 deletions nikola/plugins/task/posts.py
Expand Up @@ -30,7 +30,7 @@
from nikola import utils


def update_deps(post, lang, task):
def update_deps(post, lang, deps_dict, timeline, task):
"""Updates file dependencies as they might have been updated during compilation.
This is done for example by the ReST page compiler, which writes its
Expand All @@ -40,10 +40,6 @@ def update_deps(post, lang, task):
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):
"""Build HTML fragments from metadata and text."""

Expand All @@ -59,13 +55,25 @@ def gen_tasks(self):
"show_untranslated_posts": self.site.config['SHOW_UNTRANSLATED_POSTS'],
"demote_headers": self.site.config['DEMOTE_HEADERS'],
}
self.tl_changed = False

yield self.group_task()

def tl_ch():
self.tl_changed = True

yield {
'basename': self.name,
'name': 'timeline_changes',
'actions': [tl_ch],
'uptodate': [utils.config_changed(str(kw['timeline']))],
}

for lang in kw["translations"]:
deps_dict = copy(kw)
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 = {
Expand All @@ -74,12 +82,20 @@ def gen_tasks(self):
'file_dep': file_dep,
'targets': [dest],
'actions': [(post.compile, (lang, )),
(update_deps, (post, lang, )),
(update_deps, (post, lang, deps_dict, kw['timeline'], )),
],
'clean': True,
'uptodate': [
utils.config_changed(deps_dict, 'nikola.plugins.task.posts'),
lambda p=post, l=lang: dependence_on_timeline(p, l)
lambda p=post, l=lang: self.dependence_on_timeline(p, l)
] + post.fragment_deps_uptodate(lang),
'task_dep': ['render_posts:timeline_changes']
}
yield task

def dependence_on_timeline(self, post, lang):
if "####MAGIC####TIMELINE" not in post.fragment_deps(lang):
return True # No dependency on timeline
elif self.tl_changed:
return False # Timeline changed
return True

0 comments on commit ebebae7

Please sign in to comment.