예제 #1
0
파일: posts.py 프로젝트: shalicke/nikola
    def gen_tasks(self):
        """Build HTML fragments from metadata and text."""
        self.site.scan_posts()
        kw = {
            "translations": self.site.config["TRANSLATIONS"],
            "timeline": self.site.timeline,
            "default_lang": self.site.config["DEFAULT_LANG"],
            "hide_untranslated_posts":
            self.site.config['HIDE_UNTRANSLATED_POSTS'],
        }

        nikola.post.READ_MORE_LINK = self.site.config['READ_MORE_LINK']
        yield self.group_task()

        for lang in kw["translations"]:
            deps_dict = copy(kw)
            deps_dict.pop('timeline')
            for post in kw['timeline']:
                dest = post.translated_base_path(lang)
                task = {
                    'basename': self.name,
                    'name': dest,
                    'file_dep': post.fragment_deps(lang),
                    'targets': [dest],
                    'actions': [(post.compile, (lang, ))],
                    'clean': True,
                    'uptodate': [utils.config_changed(deps_dict)],
                }
                yield task
예제 #2
0
    def gen_tasks(self):
        """Build HTML fragments from metadata and text."""
        self.site.scan_posts()
        kw = {
            "translations": self.site.config["TRANSLATIONS"],
            "timeline": self.site.timeline,
            "default_lang": self.site.config["DEFAULT_LANG"],
            "hide_untranslated_posts": self.site.config['HIDE_UNTRANSLATED_POSTS'],
        }

        nikola.post.READ_MORE_LINK = self.site.config['READ_MORE_LINK']
        yield self.group_task()

        for lang in kw["translations"]:
            deps_dict = copy(kw)
            deps_dict.pop('timeline')
            for post in kw['timeline']:
                dest = post.translated_base_path(lang)
                task = {
                    'basename': self.name,
                    'name': dest,
                    'file_dep': post.fragment_deps(lang),
                    'targets': [dest],
                    'actions': [(post.compile, (lang, ))],
                    'clean': True,
                    'uptodate': [utils.config_changed(deps_dict)],
                }
                yield task
예제 #3
0
    def gen_tasks(self):
        """Build HTML fragments from metadata and text."""
        self.site.scan_posts()
        kw = {
            "translations": self.site.config["TRANSLATIONS"],
            "timeline": self.site.timeline,
            "default_lang": self.site.config["DEFAULT_LANG"],
            "hide_untranslated_posts":
            self.site.config['HIDE_UNTRANSLATED_POSTS'],
        }

        nikola.post.READ_MORE_LINK = self.site.config['READ_MORE_LINK']

        flag = False
        for lang in kw["translations"]:
            deps_dict = copy(kw)
            deps_dict.pop('timeline')
            for post in kw['timeline']:
                source = post.source_path
                dest = post.base_path
                if not post.is_translation_available(
                        lang) and kw["hide_untranslated_posts"]:
                    continue
                else:
                    source = post.translated_source_path(lang)
                    if lang != post.default_lang:
                        dest = dest + '.' + lang
                flag = True
                task = {
                    'basename':
                    self.name,
                    'name':
                    dest,
                    'file_dep':
                    post.fragment_deps(lang),
                    'targets': [dest],
                    'actions':
                    [(self.site.get_compiler(post.source_path).compile_html,
                      [source, dest, post.is_two_file])],
                    'clean':
                    True,
                    'uptodate': [utils.config_changed(deps_dict)],
                }
                if post.publish_later:
                    print(
                        '%s is scheduled to be published in the future (%s)' %
                        (post.source_path, post.date))
                if post.meta('password'):
                    task['actions'].append(
                        (wrap_encrypt, (dest, post.meta('password'))))
                yield task
        if flag is False:  # Return a dummy task
            yield {
                'basename': self.name,
                'name': 'None',
                'uptodate': [True],
                'actions': [],
            }
예제 #4
0
    def gen_tasks(self):
        """Build HTML fragments from metadata and text."""
        self.site.scan_posts()
        kw = {
            "translations": self.site.config["TRANSLATIONS"],
            "timeline": self.site.timeline,
            "default_lang": self.site.config["DEFAULT_LANG"],
            "hide_untranslated_posts": self.site.config['HIDE_UNTRANSLATED_POSTS'],
        }

        nikola.post.READ_MORE_LINK = self.site.config['READ_MORE_LINK']

        flag = False
        for lang in kw["translations"]:
            deps_dict = copy(kw)
            deps_dict.pop('timeline')
            for post in kw['timeline']:
                source = post.source_path
                dest = post.base_path
                if not post.is_translation_available(lang) and kw["hide_untranslated_posts"]:
                    continue
                else:
                    source = post.translated_source_path(lang)
                    if lang != post.default_lang:
                        dest = dest + '.' + lang
                flag = True
                task = {
                    'basename': self.name,
                    'name': dest,
                    'file_dep': post.fragment_deps(lang),
                    'targets': [dest],
                    'actions': [(self.site.get_compiler(post.source_path).compile_html,
                                [source, dest, post.is_two_file])],
                    'clean': True,
                    'uptodate': [utils.config_changed(deps_dict)],
                }
                if post.publish_later:
                    print('%s is scheduled to be published in the future (%s)'
                          % (post.source_path, post.date))
                if post.meta('password'):
                    task['actions'].append((wrap_encrypt, (dest, post.meta('password'))))
                yield task
        if flag is False:  # Return a dummy task
            yield {
                'basename': self.name,
                'name': 'None',
                'uptodate': [True],
                'actions': [],
            }