Skip to content

Commit

Permalink
Moving default filter registration into Nikola.__init__.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jun 4, 2017
1 parent f54db6c commit 30efe17
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 64 deletions.
3 changes: 1 addition & 2 deletions nikola/filters.py
Expand Up @@ -26,8 +26,7 @@

"""Utility functions to help run filters on files.
All filters defined in this module are registered in the
default_filters plugin.
All filters defined in this module are registered in Nikola.__init__.
"""

from functools import wraps
Expand Down
13 changes: 12 additions & 1 deletion nikola/nikola.py
Expand Up @@ -61,7 +61,7 @@

from .post import Post # NOQA
from .state import Persistor
from . import DEBUG, utils, shortcodes
from . import DEBUG, filters, utils, shortcodes
from .plugin_categories import (
Command,
LateTask,
Expand Down Expand Up @@ -974,6 +974,17 @@ def __init__(self, **config):
# Get search path for themes
self.themes_dirs = ['themes'] + self.config['EXTRA_THEMES_DIRS']

# Register default filters
filter_name_format = 'filters.{0}'
for filter_name, filter_definition in filters.__dict__.items():
# Ignore objects whose name starts with an underscore, or which are not callable
if filter_name.startswith('_'):
continue
if not callable(filter_definition):
continue
# Register all other objects as filters
site.register_filter(filter_name_format.format(filter_name), filter_definition)

self._set_global_context_from_config()
# Read data files only if a site exists (Issue #2708)
if self.configured:
Expand Down
9 changes: 0 additions & 9 deletions nikola/plugins/misc/default_filters.plugin

This file was deleted.

52 changes: 0 additions & 52 deletions nikola/plugins/misc/default_filters.py

This file was deleted.

0 comments on commit 30efe17

Please sign in to comment.