Skip to content

Commit

Permalink
Show version on /-/plugins page, closes #248
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed May 4, 2018
1 parent d4da4c9 commit ca29071
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -1434,6 +1434,7 @@ def app(self):
'name': p['name'],
'static': p['static_path'] is not None,
'templates': p['templates_path'] is not None,
'version': p.get('version'),
} for p in get_plugins(pm)]),
'/-/plugins<as_json:(\.json)?$>'
)
Expand Down
9 changes: 7 additions & 2 deletions datasette/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ def module_from_path(path, name):

def get_plugins(pm):
plugins = []
plugin_to_distinfo = dict(pm.list_plugin_distinfo())
for plugin in pm.get_plugins():
static_path = None
templates_path = None
Expand All @@ -699,9 +700,13 @@ def get_plugins(pm):
except (KeyError, ImportError):
# Caused by --plugins_dir= plugins - KeyError/ImportError thrown in Py3.5
pass
plugins.append({
plugin_info = {
'name': plugin.__name__,
'static_path': static_path,
'templates_path': templates_path,
})
}
distinfo = plugin_to_distinfo.get(plugin)
if distinfo:
plugin_info['version'] = distinfo.version
plugins.append(plugin_info)
return plugins
3 changes: 2 additions & 1 deletion tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,8 @@ def test_plugins_json(app_client):
assert {
'name': 'my_plugin.py',
'static': False,
'templates': False
'templates': False,
'version': None,
} in response.json


Expand Down

0 comments on commit ca29071

Please sign in to comment.