Skip to content

Commit

Permalink
Add EXTRA_PLUGINS_DIR config variable
Browse files Browse the repository at this point in the history
This can be used to point to any directory containing Nikola plugins.
This is more convenient than installing plugins in the site, for each
Nikola site that I maintain/use.
  • Loading branch information
punchagan committed Dec 8, 2013
1 parent b09b04e commit 08de678
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docs/manual.txt
Expand Up @@ -1559,6 +1559,10 @@ Similarly to themes, there is a nice, built-in command to install them —
You can also share plugins you created with the community! Visit the
`GitHub repository <https://github.com/getnikola/plugins>`__ to find out more.

You can use the plugins in this repository without installing them into your
site, by cloning the repository and setting the EXTRA_PLUGINS_DIR in your
configuration to point to this directory.

License
-------

Expand Down
4 changes: 4 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -611,6 +611,10 @@ CONTENT_FOOTER = CONTENT_FOOTER.format(email=BLOG_EMAIL,
# Plugins you don't want to use. Be careful :-)
# DISABLED_PLUGINS = ["render_galleries"]

# Add the absolute path to a directory containing plugins, to use those plugins
# For example, a clone of the nikola plugins repository
# EXTRA_PLUGINS_DIR = ''

# Experimental plugins - use at your own risk.
# They probably need some manual adjustments - please see their respective
# readme.
Expand Down
7 changes: 7 additions & 0 deletions nikola/nikola.py
Expand Up @@ -143,6 +143,7 @@ def __init__(self, **config):
'DEFAULT_LANG': "en",
'DEPLOY_COMMANDS': [],
'DISABLED_PLUGINS': (),
'EXTRA_PLUGINS_DIR': '',
'COMMENT_SYSTEM_ID': 'nikolademo',
'ENABLED_EXTRAS': (),
'EXTRA_HEAD_DATA': '',
Expand Down Expand Up @@ -341,16 +342,22 @@ def __init__(self, **config):
"SignalHandler": SignalHandler,
})
self.plugin_manager.setPluginInfoExtension('plugin')
extra_plugin_dir = self.config['EXTRA_PLUGINS_DIR']
if sys.version_info[0] == 3:
places = [
os.path.join(os.path.dirname(__file__), 'plugins'),
os.path.join(os.getcwd(), 'plugins'),
]
if extra_plugin_dir:
places.append(os.path.join(extra_plugin_dir, 'plugins'))
else:
places = [
os.path.join(os.path.dirname(__file__), utils.sys_encode('plugins')),
os.path.join(os.getcwd(), utils.sys_encode('plugins')),
]
if extra_plugin_dir:
places.append(os.path.join(extra_plugin_dir, utils.sys_encode('plugins')))

self.plugin_manager.setPluginPlaces(places)
self.plugin_manager.collectPlugins()

Expand Down

0 comments on commit 08de678

Please sign in to comment.