Skip to content
Permalink
Browse files

Moved activate_compiler_extensions() from Nikola to PageCompiler as g…

…et_compiler_extensions().
  • Loading branch information
felixfontein committed Jul 5, 2015
1 parent 2b19136 commit d98d60efb87aac904fc45ea6ab928fae505b1c7c
@@ -837,14 +837,6 @@ def _activate_plugins_of_category(self, category):
plugins.append(plugin_info)
return plugins

def activate_compiler_extensions(self, compiler_name):
"""Activate all the compiler extension plugins for a given compiler and return them."""
plugins = []
for plugin_info in self.compiler_extensions:
if plugin_info.plugin_object.compiler_name == compiler_name:
plugins.append(plugin_info)
return plugins

def _get_themes(self):
if self._THEMES is None:
try:
@@ -283,6 +283,15 @@ def split_metadata(self, data):
# ['metadata', '\n\n', 'post content']
return split_result[0], split_result[-1]

def get_compiler_extensions(self):
"""Activate all the compiler extension plugins for a given compiler and return them."""
plugins = []
for plugin_info in self.site.compiler_extensions:
if plugin_info.plugin_object.compiler_name == self.name:
plugins.append(plugin_info)
return plugins



class CompilerExtension(BasePlugin):

@@ -53,14 +53,14 @@ class CompileMarkdown(PageCompiler):
site = None

def set_site(self, site):
super(CompileMarkdown, self).set_site(site)
self.config_dependencies = []
for plugin_info in site.activate_compiler_extensions('markdown'):
for plugin_info in self.get_compiler_extensions():
self.config_dependencies.append(plugin_info.name)
self.extensions.append(plugin_info.plugin_object)
plugin_info.plugin_object.short_help = plugin_info.description

self.config_dependencies.append(str(sorted(site.config.get("MARKDOWN_EXTENSIONS"))))
return super(CompileMarkdown, self).set_site(site)

def compile_html(self, source, dest, is_two_file=True):
if markdown is None:
@@ -127,17 +127,16 @@ def create_post(self, path, **kw):
fd.write(content)

def set_site(self, site):
super(CompileRest, self).set_site(site)
self.config_dependencies = []
for plugin_info in site.activate_compiler_extensions('rest'):
for plugin_info in self.get_compiler_extensions():
self.config_dependencies.append(plugin_info.name)
plugin_info.plugin_object.short_help = plugin_info.description

self.logger = get_logger('compile_rest', site.loghandlers)
if not site.debug:
self.logger.level = 4

return super(CompileRest, self).set_site(site)


def get_observer(settings):
"""Return an observer for the docutils Reporter."""
@@ -214,6 +214,7 @@ def __init__(self):
"TaskMultiplier": TaskMultiplier,
"CompilerExtension": CompilerExtension
})
self.compiler_extensions = []
self.loghandlers = [nikola.utils.STDERR_HANDLER]
self.plugin_manager.setPluginInfoExtension('plugin')
if sys.version_info[0] == 3:
@@ -237,8 +238,5 @@ def __init__(self):
self.template_system = self
self.name = 'mako'

def activate_compiler_extensions(self, compiler_name):
return []

def render_template(self, name, _, context):
return('<img src="IMG.jpg">')

0 comments on commit d98d60e

Please sign in to comment.
You can’t perform that action at this time.