Skip to content
Permalink
Browse files

Merge pull request #2512 from getnikola/list-installed-themes

Fix #2504 -- add nikola theme --list-installed
  • Loading branch information
Kwpolska committed Sep 25, 2016
2 parents 9018c37 + b6d5e40 commit 7b71cedcb4b70f058fb7657c5495789be3d18715
Showing with 29 additions and 4 deletions.
  1. +1 −0 CHANGES.txt
  2. +3 −3 nikola/plugins/command/plugin.py
  3. +25 −1 nikola/plugins/command/theme.py
@@ -14,6 +14,7 @@ Bugfixes
Features
--------

* Add ``nikola theme --list-installed`` (Issue #2504)
* Add Chinese (Traditional) ``zh_TW`` locale by Po-Wen Chi
* Add ``KATEX_AUTO_RENDER`` setting to configure math delimiters
* Update KaTeX version to 0.6.0: support aligned math display
@@ -50,7 +50,7 @@ class CommandPlugin(Command):

json = None
name = "plugin"
doc_usage = "[[-u][--user] --install name] | [[-u] [-l |--upgrade|--list-installed] | [--uninstall name]]"
doc_usage = "[-u url] [--user] [-i name] [-r name] [--upgrade] [-l] [--list-installed]"
doc_purpose = "manage plugins"
output_dir = None
needs_config = False
@@ -177,8 +177,8 @@ def list_installed(self):
plugins.append([plugin.name, p])

plugins.sort()
print('Installed Plugins')
print('-----------------')
print('Installed Plugins:')
print('------------------')
for name, path in plugins:
print('{0} at {1}'.format(name, path))
print('\n\nAlso, you have disabled these plugins: {}'.format(self.site.config['DISABLED_PLUGINS']))
@@ -36,6 +36,7 @@
import pygments
from pygments.lexers import PythonLexer
from pygments.formatters import TerminalFormatter
from pkg_resources import resource_filename

from nikola.plugin_categories import Command
from nikola import utils
@@ -48,7 +49,7 @@ class CommandTheme(Command):

json = None
name = "theme"
doc_usage = "[-i theme_name] [-r theme_name] [-l] [-u url] [-g] [-n theme_name] [-c template_name]"
doc_usage = "[-u url] [-i theme_name] [-r theme_name] [-l] [--list-installed] [-g] [-n theme_name] [-c template_name]"
doc_purpose = "manage themes"
output_dir = 'themes'
cmd_options = [
@@ -76,6 +77,13 @@ class CommandTheme(Command):
'default': False,
'help': 'Show list of available themes.'
},
{
'name': 'list_installed',
'long': 'list-installed',
'type': bool,
'help': "List the installed themes with their location.",
'default': False
},
{
'name': 'url',
'short': 'u',
@@ -133,6 +141,7 @@ def _execute(self, options, args):
install = options.get('install')
uninstall = options.get('uninstall')
list_available = options.get('list')
list_installed = options.get('list_installed')
get_path = options.get('getpath')
copy_template = options.get('copy-template')
new = options.get('new')
@@ -142,6 +151,7 @@ def _execute(self, options, args):
install,
uninstall,
list_available,
list_installed,
get_path,
copy_template,
new)].count(True)
@@ -151,6 +161,8 @@ def _execute(self, options, args):

if list_available:
return self.list_available(url)
elif list_installed:
return self.list_installed()
elif install:
return self.do_install_deps(url, install)
elif uninstall:
@@ -263,6 +275,18 @@ def list_available(self, url):
print(theme)
return 0

def list_installed(self):
"""List all installed themes."""
print("Installed Themes:")
print("-----------------")
themes = []
themes_dirs = self.site.themes_dirs + [resource_filename('nikola', os.path.join('data', 'themes'))]
for tdir in themes_dirs:
themes += [(i, os.path.join(tdir, i)) for i in os.listdir(tdir)]
for tname, tpath in sorted(set(themes)):
if os.path.isdir(tpath):
print("{0} at {1}".format(tname, tpath))

def copy_template(self, template):
"""Copy the named template file from the parent to a local theme or to templates/."""
# Find template

0 comments on commit 7b71ced

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