本文整理汇总了Python中nikola.utils.apply_filters函数的典型用法代码示例。如果您正苦于以下问题:Python apply_filters函数的具体用法?Python apply_filters怎么用?Python apply_filters使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了apply_filters函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: remove_excluded_image
def remove_excluded_image(self, img, input_folder):
# Remove excluded images
# img is something like input_folder/demo/tesla2_lg.jpg so it's the *source* path
# and we should remove both the large and thumbnail *destination* paths
output_folder = os.path.dirname(
os.path.join(self.kw["output_folder"], self.site.path("gallery", os.path.dirname(img)))
)
img = os.path.relpath(img, input_folder)
img_path = os.path.join(output_folder, os.path.basename(img))
fname, ext = os.path.splitext(img_path)
thumb_path = fname + ".thumbnail" + ext
yield utils.apply_filters(
{
"basename": "_render_galleries_clean",
"name": thumb_path,
"actions": [(utils.remove_file, (thumb_path,))],
"clean": True,
"uptodate": [utils.config_changed(self.kw, "nikola.plugins.task.galleries:clean_thumb")],
},
self.kw["filters"],
)
yield utils.apply_filters(
{
"basename": "_render_galleries_clean",
"name": img_path,
"actions": [(utils.remove_file, (img_path,))],
"clean": True,
"uptodate": [utils.config_changed(self.kw, "nikola.plugins.task.galleries:clean_file")],
},
self.kw["filters"],
)
开发者ID:mgaitan,项目名称:nikola,代码行数:34,代码来源:galleries.py
示例2: remove_excluded_image
def remove_excluded_image(self, img):
# Remove excluded images
# img is something like galleries/demo/tesla2_lg.jpg so it's the *source* path
# and we should remove both the large and thumbnail *destination* paths
img = os.path.relpath(img, self.kw['gallery_path'])
output_folder = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery", os.path.dirname(img))))
img_path = os.path.join(output_folder, os.path.basename(img))
fname, ext = os.path.splitext(img_path)
thumb_path = fname + '.thumbnail' + ext
yield utils.apply_filters({
'basename': '_render_galleries_clean',
'name': thumb_path,
'actions': [
(utils.remove_file, (thumb_path,))
],
'clean': True,
'uptodate': [utils.config_changed(self.kw)],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': '_render_galleries_clean',
'name': img_path,
'actions': [
(utils.remove_file, (img_path,))
],
'clean': True,
'uptodate': [utils.config_changed(self.kw)],
}, self.kw['filters'])
开发者ID:Liessae,项目名称:nikola,代码行数:33,代码来源:galleries.py
示例3: gen_tasks
def gen_tasks(self):
"""Create tasks to copy the assets of the whole theme chain.
If a file is present on two themes, use the version
from the "youngest" theme.
"""
kw = {
"themes": self.site.THEMES,
"output_folder": self.site.config['OUTPUT_FOLDER'],
"filters": self.site.config['FILTERS'],
"code_color_scheme": self.site.config['CODE_COLOR_SCHEME'],
}
flag = True
has_code_css = False
tasks = {}
code_css_path = os.path.join(kw['output_folder'], 'assets', 'css', 'code.css')
for theme_name in kw['themes']:
src = os.path.join(utils.get_theme_path(theme_name), 'assets')
dst = os.path.join(kw['output_folder'], 'assets')
for task in utils.copy_tree(src, dst):
if task['name'] in tasks:
continue
if task['targets'][0] == code_css_path:
has_code_css = True
tasks[task['name']] = task
task['uptodate'] = [utils.config_changed(kw)]
task['basename'] = self.name
flag = False
yield utils.apply_filters(task, kw['filters'])
if flag:
yield {
'basename': self.name,
'name': 'None',
'uptodate': [True],
'actions': [],
}
if not has_code_css: # Generate it
def create_code_css():
from pygments.formatters import get_formatter_by_name
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;}")
task = {
'basename': self.name,
'name': code_css_path,
'targets': [code_css_path],
'uptodate': [utils.config_changed(kw)],
'actions': [(create_code_css, [])],
'clean': True,
}
yield utils.apply_filters(task, kw['filters'])
开发者ID:emilopez,项目名称:nikola,代码行数:58,代码来源:copy_assets.py
示例4: gen_tasks
def gen_tasks(self):
"""Create tasks to copy the assets of the whole theme chain.
If a file is present on two themes, use the version
from the "youngest" theme.
"""
kw = {
"themes": self.site.THEMES,
"output_folder": self.site.config["OUTPUT_FOLDER"],
"filters": self.site.config["FILTERS"],
"code_color_scheme": self.site.config["CODE_COLOR_SCHEME"],
}
has_code_css = False
tasks = {}
code_css_path = os.path.join(kw["output_folder"], "assets", "css", "code.css")
yield self.group_task()
for theme_name in kw["themes"]:
src = os.path.join(utils.get_theme_path(theme_name), "assets")
dst = os.path.join(kw["output_folder"], "assets")
for task in utils.copy_tree(src, dst):
if task["name"] in tasks:
continue
if task["targets"][0] == code_css_path:
has_code_css = True
tasks[task["name"]] = task
task["uptodate"] = [utils.config_changed(kw)]
task["basename"] = self.name
yield utils.apply_filters(task, kw["filters"])
if not has_code_css: # Generate it
def create_code_css():
from pygments.formatters import get_formatter_by_name
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(["pre.code", "div.code pre"]))
outf.write("\ntable.codetable { width: 100%;} td.linenos {text-align: right; width: 4em;}\n")
task = {
"basename": self.name,
"name": code_css_path,
"targets": [code_css_path],
"uptodate": [utils.config_changed(kw)],
"actions": [(create_code_css, [])],
"clean": True,
}
yield utils.apply_filters(task, kw["filters"])
开发者ID:jonhedson,项目名称:nikola,代码行数:52,代码来源:copy_assets.py
示例5: create_target_images
def create_target_images(self, img, input_path):
"""Copy images to output."""
gallery_name = os.path.dirname(img)
output_gallery = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery_global", gallery_name)))
# Do thumbnails and copy originals
# img is "galleries/name/image_name.jpg"
# img_name is "image_name.jpg"
# fname, ext are "image_name", ".jpg"
# thumb_path is
# "output/GALLERY_PATH/name/image_name.thumbnail.jpg"
img_name = os.path.basename(img)
fname, ext = os.path.splitext(img_name)
thumb_path = os.path.join(
output_gallery,
".thumbnail".join([fname, ext]))
# thumb_path is "output/GALLERY_PATH/name/image_name.jpg"
orig_dest_path = os.path.join(output_gallery, img_name)
yield utils.apply_filters({
'basename': self.name,
'name': thumb_path,
'file_dep': [img],
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size'], True, self.kw['preserve_exif_data'],
self.kw['exif_whitelist'], self.kw['preserve_icc_profiles']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['thumbnail_size']
}, 'nikola.plugins.task.galleries:resize_thumb')],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': self.name,
'name': orig_dest_path,
'file_dep': [img],
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size'], True, self.kw['preserve_exif_data'],
self.kw['exif_whitelist'], self.kw['preserve_icc_profiles']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['max_image_size']
}, 'nikola.plugins.task.galleries:resize_max')],
}, self.kw['filters'])
开发者ID:scp93ch,项目名称:nikola,代码行数:51,代码来源:galleries.py
示例6: gen_tasks
def gen_tasks(self):
self.site.scan_posts()
kw = {
"translations": self.site.config['TRANSLATIONS'],
"output_folder": self.site.config['OUTPUT_FOLDER'],
"filters": self.site.config['FILTERS'],
"timeline": self.site.timeline,
}
posts = self.site.timeline[:]
dst_path = os.path.join(kw["output_folder"], "assets", "js",
"tipuesearch_content.json")
def save_data():
pages = []
for lang in kw["translations"]:
for post in posts:
# Don't index drafts (Issue #387)
if post.is_draft or post.is_private or post.publish_later:
continue
text = post.text(lang, strip_html=True)
text = text.replace('^', '')
data = {}
data["title"] = post.title(lang)
data["text"] = text
data["tags"] = ",".join(post.tags)
data["url"] = post.permalink(lang, absolute=True)
pages.append(data)
output = json.dumps({"pages": pages}, indent=2)
makedirs(os.path.dirname(dst_path))
with codecs.open(dst_path, "wb+", "utf8") as fd:
fd.write(output)
task = {
"basename": str(self.name),
"name": dst_path,
"targets": [dst_path],
"actions": [(save_data, [])],
'uptodate': [config_changed(kw)],
'calc_dep': ['_scan_locs:sitemap']
}
yield apply_filters(task, kw['filters'])
# Copy all the assets to the right places
asset_folder = os.path.join(os.path.dirname(__file__), "files")
for task in copy_tree(asset_folder, kw["output_folder"]):
task["basename"] = str(self.name)
yield apply_filters(task, kw['filters'])
开发者ID:ChillarAnand,项目名称:plugins,代码行数:50,代码来源:__init__.py
示例7: create_target_images
def create_target_images(self, img):
gallery_name = os.path.relpath(os.path.dirname(img), self.kw['gallery_path'])
output_gallery = os.path.dirname(
os.path.join(
self.kw["output_folder"],
self.site.path("gallery", gallery_name)))
# Do thumbnails and copy originals
# img is "galleries/name/image_name.jpg"
# img_name is "image_name.jpg"
# fname, ext are "image_name", ".jpg"
# thumb_path is
# "output/GALLERY_PATH/name/image_name.thumbnail.jpg"
img_name = os.path.basename(img)
fname, ext = os.path.splitext(img_name)
thumb_path = os.path.join(
output_gallery,
".thumbnail".join([fname, ext]))
# thumb_path is "output/GALLERY_PATH/name/image_name.jpg"
orig_dest_path = os.path.join(output_gallery, img_name)
yield utils.apply_filters({
'basename': self.name,
'name': thumb_path,
'file_dep': [img],
'targets': [thumb_path],
'actions': [
(self.resize_image,
(img, thumb_path, self.kw['thumbnail_size']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['thumbnail_size']
})],
}, self.kw['filters'])
yield utils.apply_filters({
'basename': self.name,
'name': orig_dest_path,
'file_dep': [img],
'targets': [orig_dest_path],
'actions': [
(self.resize_image,
(img, orig_dest_path, self.kw['max_image_size']))
],
'clean': True,
'uptodate': [utils.config_changed({
1: self.kw['max_image_size']
})],
}, self.kw['filters'])
开发者ID:Liessae,项目名称:nikola,代码行数:48,代码来源:galleries.py
示例8: gen_tasks
def gen_tasks(self):
"""Create tasks to copy the assets of the whole theme chain.
If a file is present on two themes, use the version
from the "youngest" theme.
"""
kw = {
"themes": self.site.THEMES,
"output_folder": self.site.config['OUTPUT_FOLDER'],
"filters": self.site.config['FILTERS'],
}
flag = True
tasks = {}
for theme_name in kw['themes']:
src = os.path.join(utils.get_theme_path(theme_name), 'assets')
dst = os.path.join(kw['output_folder'], 'assets')
for task in utils.copy_tree(src, dst):
if task['name'] in tasks:
continue
tasks[task['name']] = task
task['uptodate'] = [utils.config_changed(kw)]
task['basename'] = self.name
flag = False
yield utils.apply_filters(task, kw['filters'])
if flag:
yield {
'basename': self.name,
'name': 'None',
'uptodate': [True],
'actions': [],
}
开发者ID:snaewe,项目名称:nikola,代码行数:33,代码来源:task_copy_assets.py
示例9: author_rss
def author_rss(self, author, lang, posts, kw):
"""Create a RSS feed for a single author in a given language."""
kind = "author"
# Render RSS
output_name = os.path.normpath(
os.path.join(kw['output_folder'],
self.site.path(kind + "_rss", author, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(kind + "_rss", author, lang).lstrip('/'))
deps = []
deps_uptodate = []
post_list = sorted(posts, key=lambda a: a.date)
post_list.reverse()
for post in post_list:
deps += post.deps(lang)
deps_uptodate += post.deps_uptodate(lang)
task = {
'basename': str(self.name),
'name': output_name,
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, "{0} ({1})".format(kw["blog_title"](lang), self._get_title(author)),
kw["site_url"], None, post_list,
output_name, kw["feed_teasers"], kw["feed_plain"], kw['feed_length'],
feed_url, None, kw["feed_link_append_query"]))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.authors:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
}
return utils.apply_filters(task, kw['filters'])
开发者ID:habi,项目名称:nikola,代码行数:30,代码来源:authors.py
示例10: _generate_classification_page_as_rss
def _generate_classification_page_as_rss(self, taxonomy, classification, filtered_posts, title, description, kw, lang):
"""Create a RSS feed for a single classification in a given language."""
kind = taxonomy.classification_name
# Render RSS
output_name = os.path.normpath(os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path(kind + "_rss", classification, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(kind + "_rss", classification, lang).lstrip('/'))
deps = []
deps_uptodate = []
for post in filtered_posts:
deps += post.deps(lang)
deps_uptodate += post.deps_uptodate(lang)
blog_title = kw["blog_title"](lang)
task = {
'basename': str(self.name),
'name': output_name,
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, "{0} ({1})".format(blog_title, title) if blog_title != title else blog_title,
kw["site_url"], description, filtered_posts,
output_name, kw["feed_teasers"], kw["feed_plain"], kw['feed_length'],
feed_url, _enclosure, kw["feed_links_append_query"]))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.taxonomies:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
}
return utils.apply_filters(task, kw['filters'])
开发者ID:scp93ch,项目名称:nikola,代码行数:27,代码来源:taxonomies.py
示例11: gen_tasks
def gen_tasks(self):
"""Copy static files into the output folder."""
self.kw = {
'image_thumbnail_size': self.site.config['IMAGE_THUMBNAIL_SIZE'],
'image_thumbnail_format': self.site.config['IMAGE_THUMBNAIL_FORMAT'],
'max_image_size': self.site.config['MAX_IMAGE_SIZE'],
'image_folders': self.site.config['IMAGE_FOLDERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],
'preserve_exif_data': self.site.config['PRESERVE_EXIF_DATA'],
'exif_whitelist': self.site.config['EXIF_WHITELIST'],
'preserve_icc_profiles': self.site.config['PRESERVE_ICC_PROFILES'],
}
self.image_ext_list = self.image_ext_list_builtin
self.image_ext_list.extend(self.site.config.get('EXTRA_IMAGE_EXTENSIONS', []))
yield self.group_task()
for src in self.kw['image_folders']:
dst = self.kw['output_folder']
filters = self.kw['filters']
real_dst = os.path.join(dst, self.kw['image_folders'][src])
for task in self.process_tree(src, real_dst):
task['basename'] = self.name
task['uptodate'] = [utils.config_changed(self.kw)]
yield utils.apply_filters(task, filters)
开发者ID:FelixSchwarz,项目名称:nikola,代码行数:26,代码来源:scale_images.py
示例12: gen_tasks
def gen_tasks(self):
"""Copy static files into the output folder."""
kw = {
'files_folders': self.site.config['FILES_FOLDERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'filters': self.site.config['FILTERS'],
}
flag = False
for src in kw['files_folders']:
dst = kw['output_folder']
filters = kw['filters']
real_dst = os.path.join(dst, kw['files_folders'][src])
for task in utils.copy_tree(src, real_dst, link_cutoff=dst):
flag = True
task['basename'] = self.name
task['uptodate'] = task.get('uptodate', []) +\
[utils.config_changed(kw)]
yield utils.apply_filters(task, filters)
if not flag:
yield {
'basename': self.name,
'actions': (),
}
开发者ID:Bluerise,项目名称:nikola,代码行数:25,代码来源:task_copy_files.py
示例13: tag_rss
def tag_rss(self, tag, lang, posts, kw, is_category):
"""RSS for a single tag / language"""
kind = "category" if is_category else "tag"
# Render RSS
output_name = os.path.normpath(
os.path.join(kw['output_folder'],
self.site.path(kind + "_rss", tag, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(kind + "_rss", tag, lang).lstrip('/'))
deps = []
post_list = sorted(posts, key=lambda a: a.date)
post_list.reverse()
for post in post_list:
deps += post.deps(lang)
task = {
'basename': str(self.name),
'name': output_name,
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, "{0} ({1})".format(kw["blog_title"](lang), tag),
kw["site_url"], None, post_list,
output_name, kw["rss_teasers"], kw["rss_plain"], kw['feed_length'],
feed_url))],
'clean': True,
'uptodate': [utils.config_changed(kw)],
'task_dep': ['render_posts'],
}
return utils.apply_filters(task, kw['filters'])
开发者ID:AN6U5,项目名称:nikola,代码行数:28,代码来源:tags.py
示例14: gen_tasks
def gen_tasks(self):
"""Bundle assets using WebAssets."""
kw = {
'filters': self.site.config['FILTERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'cache_folder': self.site.config['CACHE_FOLDER'],
'theme_bundles': get_theme_bundles(self.site.THEMES),
'themes': self.site.THEMES,
'files_folders': self.site.config['FILES_FOLDERS'],
'code_color_scheme': self.site.config['CODE_COLOR_SCHEME'],
}
def build_bundle(output, inputs):
out_dir = os.path.join(kw['output_folder'],
os.path.dirname(output))
inputs = [i for i in inputs if os.path.isfile(
os.path.join(out_dir, i))]
cache_dir = os.path.join(kw['cache_folder'], 'webassets')
utils.makedirs(cache_dir)
env = webassets.Environment(out_dir, os.path.dirname(output),
cache=cache_dir)
if inputs:
bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
env.register(output, bundle)
# This generates the file
env[output].urls()
else:
with open(os.path.join(out_dir, os.path.basename(output)), 'wb+'):
pass # Create empty file
yield self.group_task()
if (webassets is not None and self.site.config['USE_BUNDLES'] is not
False):
for name, _files in kw['theme_bundles'].items():
output_path = os.path.join(kw['output_folder'], name)
dname = os.path.dirname(name)
files = []
for fname in _files:
# paths are relative to dirname
files.append(os.path.join(dname, fname))
file_dep = [os.path.join(kw['output_folder'], fname)
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'],
'basename': str(self.name),
'name': str(output_path),
'actions': [(build_bundle, (name, files))],
'targets': [output_path],
'uptodate': [
utils.config_changed({
1: kw,
2: file_dep
})],
'clean': True,
}
yield utils.apply_filters(task, kw['filters'])
开发者ID:rhewett,项目名称:nikola,代码行数:59,代码来源:bundles.py
示例15: _prepare_tag_cloud
def _prepare_tag_cloud(self, lang, config):
"""Create tag cloud task."""
# Collect information
fn = os.path.join(self.site.config['OUTPUT_FOLDER'], config['filename'])
css_fn = os.path.join(self.site.config['OUTPUT_FOLDER'], config['style_filename'])
taxonomy_type = config['taxonomy_type']
posts_per_tag = self.site.posts_per_classification[taxonomy_type][lang]
taxonomy = self.site.taxonomy_plugins[taxonomy_type]
# Compose list of tags, their post count and links
tag_count_url_list = []
for tag in natsort.humansorted(list(posts_per_tag.keys())):
tag_count_url_list.append((
taxonomy.get_classification_friendly_name(tag, lang),
len([post for post in posts_per_tag[tag] if self.site.config['SHOW_UNTRANSLATED_POSTS'] or post.is_translation_available(lang)]),
self.site.link(taxonomy_type, tag, lang)
))
# Get tag cloud data
tags, level_weights = engine.create_tag_cloud_data(tag_count_url_list, max_number_of_levels=config['max_number_of_levels'], max_tags=config['max_tags'], minimal_number_of_appearances=config['minimal_number_of_appearances'])
# Determine url type for rewriting. Must not be relative.
url_type = self.site.config['URL_TYPE']
if url_type == 'rel_path':
url_type = 'full_path'
# Create task for HTML fragment
task = {
'basename': self.name,
'name': fn,
'targets': [fn],
'actions': [(self._render_tag_cloud_html, [fn, tags, level_weights, config, lang, url_type])],
'clean': True,
'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tag_cloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tag_cloud:config')]
}
yield utils.apply_filters(task, self.site.config["FILTERS"])
# Create task for CSS
task = {
'basename': self.name,
'name': css_fn,
'targets': [css_fn],
'actions': [(self._render_tag_cloud_css, [css_fn, tags, level_weights, config])],
'clean': True,
'uptodate': [utils.config_changed({1: tags, 2: level_weights}, 'nikola.plugins.render_tag_cloud:tags'), utils.config_changed(config, 'nikola.plugins.render_tag_cloud:config')]
}
yield utils.apply_filters(task, self.site.config["FILTERS"])
开发者ID:getnikola,项目名称:plugins,代码行数:46,代码来源:__init__.py
示例16: gen_tasks
def gen_tasks(self):
"""Bundle assets using WebAssets."""
kw = {
'filters': self.site.config['FILTERS'],
'output_folder': self.site.config['OUTPUT_FOLDER'],
'cache_folder': self.site.config['CACHE_FOLDER'],
'theme_bundles': get_theme_bundles(self.site.THEMES),
'themes': self.site.THEMES,
'files_folders': self.site.config['FILES_FOLDERS'],
'code_color_scheme': self.site.config['CODE_COLOR_SCHEME'],
}
def build_bundle(output, inputs):
out_dir = os.path.join(kw['output_folder'],
os.path.dirname(output))
inputs = [i for i in inputs if os.path.isfile(
os.path.join(out_dir, i))]
cache_dir = os.path.join(kw['cache_folder'], 'webassets')
if not os.path.isdir(cache_dir):
os.makedirs(cache_dir)
env = webassets.Environment(out_dir, os.path.dirname(output),
cache=cache_dir)
bundle = webassets.Bundle(*inputs, output=os.path.basename(output))
env.register(output, bundle)
# This generates the file
env[output].urls()
flag = False
if (webassets is not None and self.site.config['USE_BUNDLES'] is not
False):
for name, files in kw['theme_bundles'].items():
output_path = os.path.join(kw['output_folder'], name)
dname = os.path.dirname(name)
file_dep = [utils.get_asset_path(
os.path.join(dname, fname), kw['themes'],
kw['files_folders'])
for fname in files
]
file_dep = filter(None, file_dep) # removes missing files
task = {
'file_dep': file_dep,
'basename': str(self.name),
'name': str(output_path),
'actions': [(build_bundle, (name, files))],
'targets': [output_path],
'uptodate': [utils.config_changed(kw)],
'clean': True,
}
flag = True
yield utils.apply_filters(task, kw['filters'])
if flag is False: # No page rendered, yield a dummy task
yield {
'basename': self.name,
'uptodate': [True],
'name': 'None',
'actions': [],
}
开发者ID:ariel17,项目名称:nikola,代码行数:58,代码来源:task_create_bundles.py
示例17: create_target_images
def create_target_images(self, img, input_path):
gallery_name = os.path.dirname(img)
output_gallery = os.path.dirname(
os.path.join(self.kw["output_folder"], self.site.path("gallery", gallery_name))
)
# Do thumbnails and copy originals
# img is "galleries/name/image_name.jpg"
# img_name is "image_name.jpg"
# fname, ext are "image_name", ".jpg"
# thumb_path is
# "output/GALLERY_PATH/name/image_name.thumbnail.jpg"
img_name = os.path.basename(img)
fname, ext = os.path.splitext(img_name)
thumb_path = os.path.join(output_gallery, ".thumbnail".join([fname, ext]))
# thumb_path is "output/GALLERY_PATH/name/image_name.jpg"
orig_dest_path = os.path.join(output_gallery, img_name)
yield utils.apply_filters(
{
"basename": self.name,
"name": thumb_path,
"file_dep": [img],
"targets": [thumb_path],
"actions": [(self.resize_image, (img, thumb_path, self.kw["thumbnail_size"]))],
"clean": True,
"uptodate": [
utils.config_changed({1: self.kw["thumbnail_size"]}, "nikola.plugins.task.galleries:resize_thumb")
],
},
self.kw["filters"],
)
yield utils.apply_filters(
{
"basename": self.name,
"name": orig_dest_path,
"file_dep": [img],
"targets": [orig_dest_path],
"actions": [(self.resize_image, (img, orig_dest_path, self.kw["max_image_size"]))],
"clean": True,
"uptodate": [
utils.config_changed({1: self.kw["max_image_size"]}, "nikola.plugins.task.galleries:resize_max")
],
},
self.kw["filters"],
)
开发者ID:mgaitan,项目名称:nikola,代码行数:45,代码来源:galleries.py
示例18: gen_tasks
def gen_tasks(self):
"""Generate (ogg) RSS feeds."""
kw = {
"translations": self.site.config["TRANSLATIONS"],
"filters": self.site.config["FILTERS"],
"blog_title": self.site.config["BLOG_TITLE"],
"site_url": self.site.config["SITE_URL"],
"base_url": self.site.config["BASE_URL"],
"blog_description": self.site.config["BLOG_DESCRIPTION"],
"output_folder": self.site.config["OUTPUT_FOLDER"],
"feed_teasers": self.site.config["FEED_TEASERS"],
"feed_plain": self.site.config["FEED_PLAIN"],
"show_untranslated_posts": self.site.config['SHOW_UNTRANSLATED_POSTS'],
"feed_length": self.site.config['FEED_LENGTH'],
"feed_previewimage": self.site.config["FEED_PREVIEWIMAGE"],
"tzinfo": self.site.tzinfo,
"feed_read_more_link": self.site.config["FEED_READ_MORE_LINK"],
"feed_links_append_query": self.site.config["FEED_LINKS_APPEND_QUERY"],
}
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'],
self.site.path("rss_ogg", None, lang))
deps = []
deps_uptodate = []
if kw["show_untranslated_posts"]:
posts = self.site.posts[:kw['feed_length']]
else:
posts = [x for x in self.site.posts if x.is_translation_available(lang)][:kw['feed_length']]
for post in posts:
deps += post.deps(lang)
deps_uptodate += post.deps_uptodate(lang)
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link("rss", None, lang).lstrip('/'))
task = {
'basename': 'generate_rss_ogg',
'name': os.path.normpath(output_name),
'file_dep': deps,
'targets': [output_name],
'actions': [(utils.generic_rss_renderer,
(lang, kw["blog_title"](lang), kw["site_url"],
kw["blog_description"](lang), posts, output_name,
kw["feed_teasers"], kw["feed_plain"], kw['feed_length'], feed_url,
self._enclosure, kw["feed_links_append_query"]))],
'task_dep': ['render_posts'],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.rss')] + deps_uptodate,
}
yield utils.apply_filters(task, kw['filters'])
开发者ID:x1101,项目名称:nikola,代码行数:57,代码来源:rss_ogg.py
示例19: gen_tasks
def gen_tasks(self):
self.kw = {
"strip_indexes": self.site.config["STRIP_INDEXES"],
"output_folder": self.site.config["OUTPUT_FOLDER"],
"cache_folder": self.site.config["CACHE_FOLDER"],
"default_lang": self.site.config["DEFAULT_LANG"],
"filters": self.site.config["FILTERS"],
"translations": self.site.config["TRANSLATIONS"],
"global_context": self.site.GLOBAL_CONTEXT,
"tzinfo": self.site.tzinfo,
}
# print(dir(self.site.compilers["markdown"].compile_html))
# yield self.group_task()
template_name = "documentation.mako"
template_dep = self.site.template_system.template_deps(template_name)
# template_dep += [template_name]
class_template_name = "documentation_class.mako"
class_template_dep = self.site.template_system.template_deps(class_template_name)
index_block_template_name = "documentation_index_block.mako"
index_block_template_dep = self.site.template_system.template_deps(index_block_template_name)
module_intro_template_name = "documentation_module_intro.mako"
module_intro_template_dep = self.site.template_system.template_deps(module_intro_template_name)
# class_template_dep += [class_template_name]
tdst = []
for lang in self.kw["translations"]:
short_tdst = os.path.join(self.kw["translations"][lang], "documentation", "index.html")
tdst.append(os.path.normpath(os.path.join(self.kw["output_folder"], short_tdst)))
docs_md = []
directory = os.path.join(self.site.original_cwd, "documentation")
for root, subFolders, files in os.walk(directory):
for file in files:
f = os.path.join(root, file)
docs_md.append(f)
yield utils.apply_filters(
{
"basename": self.name,
"name": "documentation",
"file_dep": template_dep
+ docs_md
+ class_template_dep
+ index_block_template_dep
+ module
|
请发表评论