diff options
| author | 2014-03-09 03:14:40 +0100 | |
|---|---|---|
| committer | 2014-03-09 03:14:40 +0100 | |
| commit | fa50632a9d87c3989566fed3e49c160a132e0d14 (patch) | |
| tree | 81f58cc0dcfbb34710856b59c034bc47c53d91dc /nikola/plugins/task | |
| parent | 2828399ba5cbb14502b023d4de1ba02f13dd5055 (diff) | |
Imported Upstream version 6.4.0upstream/6.4.0
Diffstat (limited to 'nikola/plugins/task')
| -rw-r--r-- | nikola/plugins/task/build_less.py | 16 | ||||
| -rw-r--r-- | nikola/plugins/task/build_sass.py | 19 | ||||
| -rw-r--r-- | nikola/plugins/task/bundles.py | 4 | ||||
| -rw-r--r-- | nikola/plugins/task/copy_assets.py | 4 | ||||
| -rw-r--r-- | nikola/plugins/task/galleries.py | 6 | ||||
| -rw-r--r-- | nikola/plugins/task/listings.py | 2 | ||||
| -rw-r--r--[-rwxr-xr-x] | nikola/plugins/task/localsearch/files/assets/css/img/search.png | bin | 315 -> 315 bytes | |||
| -rw-r--r--[-rwxr-xr-x] | nikola/plugins/task/localsearch/files/assets/css/tipuesearch.css | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | nikola/plugins/task/localsearch/files/tipue_search.html | 0 | ||||
| -rw-r--r-- | nikola/plugins/task/rss.py | 5 | ||||
| -rw-r--r-- | nikola/plugins/task/sitemap/__init__.py | 19 | ||||
| -rw-r--r-- | nikola/plugins/task/tags.py | 14 |
12 files changed, 70 insertions, 19 deletions
diff --git a/nikola/plugins/task/build_less.py b/nikola/plugins/task/build_less.py index 14a53f9..a672282 100644 --- a/nikola/plugins/task/build_less.py +++ b/nikola/plugins/task/build_less.py @@ -46,22 +46,34 @@ class BuildLess(Task): def gen_tasks(self): """Generate CSS out of LESS sources.""" self.compiler_name = self.site.config['LESS_COMPILER'] + self.compiler_options = self.site.config['LESS_OPTIONS'] kw = { 'cache_folder': self.site.config['CACHE_FOLDER'], 'themes': self.site.THEMES, } + tasks = {} # Find where in the theme chain we define the LESS targets # There can be many *.less in the folder, but we only will build # the ones listed in less/targets - targets_path = utils.get_asset_path(os.path.join(self.sources_folder, "targets"), self.site.THEMES) + if os.path.isfile(os.path.join(self.sources_folder, "targets")): + targets_path = os.path.join(self.sources_folder, "targets") + else: + targets_path = utils.get_asset_path(os.path.join(self.sources_folder, "targets"), self.site.THEMES) try: with codecs.open(targets_path, "rb", "utf-8") as inf: targets = [x.strip() for x in inf.readlines()] except Exception: targets = [] + for task in utils.copy_tree(self.sources_folder, os.path.join(kw['cache_folder'], self.sources_folder)): + if task['name'] in tasks: + continue + task['basename'] = 'prepare_less_sources' + tasks[task['name']] = task + yield task + for theme_name in kw['themes']: src = os.path.join(utils.get_theme_path(theme_name), self.sources_folder) for task in utils.copy_tree(src, os.path.join(kw['cache_folder'], self.sources_folder)): @@ -82,7 +94,7 @@ class BuildLess(Task): src = os.path.join(kw['cache_folder'], self.sources_folder, target) run_in_shell = sys.platform == 'win32' try: - compiled = subprocess.check_output([self.compiler_name, src], shell=run_in_shell) + compiled = subprocess.check_output([self.compiler_name] + self.compiler_options + [src], shell=run_in_shell) except OSError: utils.req_missing([self.compiler_name], 'build LESS files (and use this theme)', diff --git a/nikola/plugins/task/build_sass.py b/nikola/plugins/task/build_sass.py index 7575505..becc843 100644 --- a/nikola/plugins/task/build_sass.py +++ b/nikola/plugins/task/build_sass.py @@ -47,26 +47,41 @@ class BuildSass(Task): """Generate CSS out of Sass sources.""" self.logger = utils.get_logger('build_sass', self.site.loghandlers) self.compiler_name = self.site.config['SASS_COMPILER'] + self.compiler_options = self.site.config['SASS_OPTIONS'] kw = { 'cache_folder': self.site.config['CACHE_FOLDER'], 'themes': self.site.THEMES, } + tasks = {} # Find where in the theme chain we define the Sass targets # There can be many *.sass/*.scss in the folder, but we only # will build the ones listed in sass/targets - targets_path = utils.get_asset_path(os.path.join(self.sources_folder, "targets"), self.site.THEMES) + if os.path.isfile(os.path.join(self.sources_folder, "targets")): + targets_path = os.path.join(self.sources_folder, "targets") + else: + targets_path = utils.get_asset_path(os.path.join(self.sources_folder, "targets"), self.site.THEMES) try: with codecs.open(targets_path, "rb", "utf-8") as inf: targets = [x.strip() for x in inf.readlines()] except Exception: targets = [] + for task in utils.copy_tree(self.sources_folder, os.path.join(kw['cache_folder'], self.sources_folder)): + if task['name'] in tasks: + continue + task['basename'] = 'prepare_sass_sources' + tasks[task['name']] = task + yield task + for theme_name in kw['themes']: src = os.path.join(utils.get_theme_path(theme_name), self.sources_folder) for task in utils.copy_tree(src, os.path.join(kw['cache_folder'], self.sources_folder)): + if task['name'] in tasks: + continue task['basename'] = 'prepare_sass_sources' + tasks[task['name']] = task yield task # Build targets and write CSS files @@ -83,7 +98,7 @@ class BuildSass(Task): run_in_shell = sys.platform == 'win32' src = os.path.join(kw['cache_folder'], self.sources_folder, target) try: - compiled = subprocess.check_output([self.compiler_name, src], shell=run_in_shell) + compiled = subprocess.check_output([self.compiler_name] + self.compiler_options + [src], shell=run_in_shell) except OSError: utils.req_missing([self.compiler_name], 'build Sass files (and use this theme)', diff --git a/nikola/plugins/task/bundles.py b/nikola/plugins/task/bundles.py index b035b97..fcfaf42 100644 --- a/nikola/plugins/task/bundles.py +++ b/nikola/plugins/task/bundles.py @@ -87,8 +87,8 @@ class BuildBundles(LateTask): output_path = os.path.join(kw['output_folder'], name) dname = os.path.dirname(name) file_dep = [os.path.join(kw['output_folder'], dname, fname) - for fname in files] - file_dep = filter(os.path.isfile, file_dep) # removes missing files + for fname in files if + utils.get_asset_path(fname, self.site.THEMES, self.site.config['FILES_FOLDERS'])] task = { 'file_dep': list(file_dep), 'task_dep': ['copy_assets'], diff --git a/nikola/plugins/task/copy_assets.py b/nikola/plugins/task/copy_assets.py index 21f1f85..93b7fb3 100644 --- a/nikola/plugins/task/copy_assets.py +++ b/nikola/plugins/task/copy_assets.py @@ -75,8 +75,8 @@ class CopyAssets(Task): formatter = get_formatter_by_name('html', style=kw["code_color_scheme"]) utils.makedirs(os.path.dirname(code_css_path)) with codecs.open(code_css_path, 'wb+', 'utf8') as outf: - outf.write(formatter.get_style_defs('.code')) - outf.write("table.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}") + outf.write(formatter.get_style_defs(['pre.code', 'div.code pre'])) + outf.write("\ntable.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}\n") task = { 'basename': self.name, diff --git a/nikola/plugins/task/galleries.py b/nikola/plugins/task/galleries.py index 6977eab..880d47c 100644 --- a/nikola/plugins/task/galleries.py +++ b/nikola/plugins/task/galleries.py @@ -176,6 +176,7 @@ class Galleries(Task): thumbs = ['.thumbnail'.join(os.path.splitext(p)) for p in image_list] thumbs = [os.path.join(self.kw['output_folder'], t) for t in thumbs] + dest_img_list = [os.path.join(self.kw['output_folder'], t) for t in image_list] folders = [] @@ -193,7 +194,8 @@ class Galleries(Task): context["folders"] = folders context["crumbs"] = crumbs context["permalink"] = self.site.link( - "gallery", os.path.basename(gallery), lang) + "gallery", os.path.basename( + os.path.relpath(gallery, self.kw['gallery_path'])), lang) # FIXME: use kw context["enable_comments"] = ( self.site.config["COMMENTS_IN_GALLERIES"]) @@ -219,7 +221,7 @@ class Galleries(Task): template_name, dst, context, - image_list, + dest_img_list, thumbs, file_dep))], 'clean': True, diff --git a/nikola/plugins/task/listings.py b/nikola/plugins/task/listings.py index d8ed43b..86be6c4 100644 --- a/nikola/plugins/task/listings.py +++ b/nikola/plugins/task/listings.py @@ -55,7 +55,7 @@ class Listings(Task): } # Things to ignore in listings - ignored_extensions = (".pyc",) + ignored_extensions = (".pyc", ".pyo") def render_listing(in_name, out_name, folders=[], files=[]): if in_name: diff --git a/nikola/plugins/task/localsearch/files/assets/css/img/search.png b/nikola/plugins/task/localsearch/files/assets/css/img/search.png Binary files differindex 9ab0f2c..9ab0f2c 100755..100644 --- a/nikola/plugins/task/localsearch/files/assets/css/img/search.png +++ b/nikola/plugins/task/localsearch/files/assets/css/img/search.png diff --git a/nikola/plugins/task/localsearch/files/assets/css/tipuesearch.css b/nikola/plugins/task/localsearch/files/assets/css/tipuesearch.css index 2230193..2230193 100755..100644 --- a/nikola/plugins/task/localsearch/files/assets/css/tipuesearch.css +++ b/nikola/plugins/task/localsearch/files/assets/css/tipuesearch.css diff --git a/nikola/plugins/task/localsearch/files/tipue_search.html b/nikola/plugins/task/localsearch/files/tipue_search.html index 789fbe5..789fbe5 100755..100644 --- a/nikola/plugins/task/localsearch/files/tipue_search.html +++ b/nikola/plugins/task/localsearch/files/tipue_search.html diff --git a/nikola/plugins/task/rss.py b/nikola/plugins/task/rss.py index e5f7548..9e4204c 100644 --- a/nikola/plugins/task/rss.py +++ b/nikola/plugins/task/rss.py @@ -58,6 +58,11 @@ class GenerateRSS(Task): "feed_length": self.site.config['FEED_LENGTH'], } self.site.scan_posts() + # Check for any changes in the state of use_in_feeds for any post. + # Issue #934 + kw['use_in_feeds_status'] = ''.join( + ['T' if x.use_in_feeds else 'F' for x in self.site.timeline] + ) yield self.group_task() for lang in kw["translations"]: output_name = os.path.join(kw['output_folder'], diff --git a/nikola/plugins/task/sitemap/__init__.py b/nikola/plugins/task/sitemap/__init__.py index 0164000..147bd50 100644 --- a/nikola/plugins/task/sitemap/__init__.py +++ b/nikola/plugins/task/sitemap/__init__.py @@ -144,26 +144,35 @@ class Sitemap(LateTask): def write_sitemap(): # Have to rescan, because files may have been added between # task dep scanning and task execution - scan_locs() with codecs.open(sitemap_path, 'wb+', 'utf8') as outf: outf.write(header) for k in sorted(locs.keys()): outf.write(locs[k]) outf.write("</urlset>") - # Other tasks can depend on this output, instead of having - # to scan locations. + + # Yield a task to calculate the dependencies of the sitemap + # Other tasks can depend on this output, instead of having + # to scan locations. + def scan_locs_task(): + scan_locs() return {'locations': list(locs.keys())} - scan_locs() + yield { + "basename": "_scan_locs", + "name": "sitemap", + "actions": [(scan_locs_task)] + } + yield self.group_task() task = { "basename": "sitemap", "name": sitemap_path, "targets": [sitemap_path], "actions": [(write_sitemap,)], - "uptodate": [config_changed({1: kw, 2: locs})], + "uptodate": [config_changed(kw)], "clean": True, "task_dep": ["render_site"], + "calc_dep": ["_scan_locs:sitemap"], } yield task diff --git a/nikola/plugins/task/tags.py b/nikola/plugins/task/tags.py index a2444ec..f6b8234 100644 --- a/nikola/plugins/task/tags.py +++ b/nikola/plugins/task/tags.py @@ -311,9 +311,17 @@ class RenderTags(Task): self.site.config['INDEX_FILE']] if _f] def tag_path(self, name, lang): - return [_f for _f in [self.site.config['TRANSLATIONS'][lang], - self.site.config['TAG_PATH'], self.slugify_name(name) + ".html"] if - _f] + if self.site.config['PRETTY_URLS']: + return [_f for _f in [ + self.site.config['TRANSLATIONS'][lang], + self.site.config['TAG_PATH'], + self.slugify_name(name), + self.site.config['INDEX_FILE']] if _f] + else: + return [_f for _f in [ + self.site.config['TRANSLATIONS'][lang], + self.site.config['TAG_PATH'], + self.slugify_name(name) + ".html"] if _f] def tag_rss_path(self, name, lang): return [_f for _f in [self.site.config['TRANSLATIONS'][lang], |
