From ac23ef384af98c22e20d1bb0b3cff760b03bdd0a Mon Sep 17 00:00:00 2001 From: Joseph Nix Date: Mon, 23 Apr 2018 12:10:46 -0500 Subject: [PATCH] [pluginlist-update] Adding project data plugin and using it to retrieve info about plugins. --- content/plugins/disqus-comments/contents.lr | 5 ---- content/plugins/flask/contents.lr | 3 +++ content/plugins/jinja-content/contents.lr | 4 --- content/plugins/lektor-htmlmin/contents.lr | 3 +++ content/plugins/lektor-i18n/contents.lr | 3 +++ .../plugins/lektor-jinja-content/contents.lr | 3 +++ content/plugins/lektor-make/contents.lr | 3 +++ .../plugins/lektor-npm-support/contents.lr | 3 +++ .../lektor-webpack-support/contents.lr | 5 ++++ .../plugins/markdown-admonition/contents.lr | 7 ----- .../plugins/markdown-highlighter/contents.lr | 7 ----- content/plugins/webpack-support/contents.lr | 7 ----- models/plugin.ini | 9 ++----- packages/project-data/.gitignore | 5 ++++ packages/project-data/lektor_project_data.py | 27 +++++++++++++++++++ packages/project-data/setup.py | 18 +++++++++++++ templates/macros/plugins.html | 15 ++++++----- templates/plugin.html | 9 ++++--- 18 files changed, 90 insertions(+), 46 deletions(-) delete mode 100644 content/plugins/disqus-comments/contents.lr create mode 100644 content/plugins/flask/contents.lr delete mode 100644 content/plugins/jinja-content/contents.lr create mode 100644 content/plugins/lektor-htmlmin/contents.lr create mode 100644 content/plugins/lektor-i18n/contents.lr create mode 100644 content/plugins/lektor-jinja-content/contents.lr create mode 100644 content/plugins/lektor-make/contents.lr create mode 100644 content/plugins/lektor-npm-support/contents.lr create mode 100644 content/plugins/lektor-webpack-support/contents.lr delete mode 100644 content/plugins/markdown-admonition/contents.lr delete mode 100644 content/plugins/markdown-highlighter/contents.lr delete mode 100644 content/plugins/webpack-support/contents.lr create mode 100644 packages/project-data/.gitignore create mode 100644 packages/project-data/lektor_project_data.py create mode 100644 packages/project-data/setup.py diff --git a/content/plugins/disqus-comments/contents.lr b/content/plugins/disqus-comments/contents.lr deleted file mode 100644 index 09391027..00000000 --- a/content/plugins/disqus-comments/contents.lr +++ /dev/null @@ -1,5 +0,0 @@ -title: Disqus Comments ---- -official: yes ---- -categories: templates diff --git a/content/plugins/flask/contents.lr b/content/plugins/flask/contents.lr new file mode 100644 index 00000000..dca335c4 --- /dev/null +++ b/content/plugins/flask/contents.lr @@ -0,0 +1,3 @@ +name: flask +--- +categories: content diff --git a/content/plugins/jinja-content/contents.lr b/content/plugins/jinja-content/contents.lr deleted file mode 100644 index 06c3b6a3..00000000 --- a/content/plugins/jinja-content/contents.lr +++ /dev/null @@ -1,4 +0,0 @@ -title: Jinja Content ---- -categories: content ---- diff --git a/content/plugins/lektor-htmlmin/contents.lr b/content/plugins/lektor-htmlmin/contents.lr new file mode 100644 index 00000000..5f180048 --- /dev/null +++ b/content/plugins/lektor-htmlmin/contents.lr @@ -0,0 +1,3 @@ +name: lektor-htmlmin +--- +categories: build diff --git a/content/plugins/lektor-i18n/contents.lr b/content/plugins/lektor-i18n/contents.lr new file mode 100644 index 00000000..c28f59a9 --- /dev/null +++ b/content/plugins/lektor-i18n/contents.lr @@ -0,0 +1,3 @@ +name: lektor-i18n +--- +categories: build diff --git a/content/plugins/lektor-jinja-content/contents.lr b/content/plugins/lektor-jinja-content/contents.lr new file mode 100644 index 00000000..a36115fe --- /dev/null +++ b/content/plugins/lektor-jinja-content/contents.lr @@ -0,0 +1,3 @@ +name: lektor-jinja-content +--- +categories: content diff --git a/content/plugins/lektor-make/contents.lr b/content/plugins/lektor-make/contents.lr new file mode 100644 index 00000000..93d65c7f --- /dev/null +++ b/content/plugins/lektor-make/contents.lr @@ -0,0 +1,3 @@ +name: lektor-make +--- +categories: build diff --git a/content/plugins/lektor-npm-support/contents.lr b/content/plugins/lektor-npm-support/contents.lr new file mode 100644 index 00000000..0a955e79 --- /dev/null +++ b/content/plugins/lektor-npm-support/contents.lr @@ -0,0 +1,3 @@ +name: lektor-npm-support +--- +categories: build diff --git a/content/plugins/lektor-webpack-support/contents.lr b/content/plugins/lektor-webpack-support/contents.lr new file mode 100644 index 00000000..9c2359bf --- /dev/null +++ b/content/plugins/lektor-webpack-support/contents.lr @@ -0,0 +1,5 @@ +name: lektor-webpack-support +--- +categories: build +--- +official: yes diff --git a/content/plugins/markdown-admonition/contents.lr b/content/plugins/markdown-admonition/contents.lr deleted file mode 100644 index 16570399..00000000 --- a/content/plugins/markdown-admonition/contents.lr +++ /dev/null @@ -1,7 +0,0 @@ -title: Markdown Admonition ---- -categories: content ---- -link: https://pypi.org/project/lektor-markdown-admonition/ ---- -official: yes diff --git a/content/plugins/markdown-highlighter/contents.lr b/content/plugins/markdown-highlighter/contents.lr deleted file mode 100644 index f9c3815e..00000000 --- a/content/plugins/markdown-highlighter/contents.lr +++ /dev/null @@ -1,7 +0,0 @@ -title: Markdown Highlighter ---- -categories: content ---- -link: https://pypi.org/project/lektor-markdown-highlighter/ ---- -official: yes diff --git a/content/plugins/webpack-support/contents.lr b/content/plugins/webpack-support/contents.lr deleted file mode 100644 index a28afc66..00000000 --- a/content/plugins/webpack-support/contents.lr +++ /dev/null @@ -1,7 +0,0 @@ -title: Webpack Support ---- -categories: build ---- -link: https://pypi.org/project/lektor-webpack-support/ ---- -official: yes diff --git a/models/plugin.ini b/models/plugin.ini index 581b3cb1..e04cac11 100644 --- a/models/plugin.ini +++ b/models/plugin.ini @@ -1,13 +1,12 @@ [model] name = Plugin -inherit = page label = {{ this.title }} [children] enabled = no -[fields.title] -label = Title +[fields.name] +label = Plugin Name (as it appears when you install it) type = string size = large @@ -17,10 +16,6 @@ type = boolean checkbox_label = If true, then the plugin will be marked as official. default = false -[fields.link] -label = PyPI Link. We use this to scrape information about your project and display it on this site. -type = url - [fields.categories] label = Categories type = select diff --git a/packages/project-data/.gitignore b/packages/project-data/.gitignore new file mode 100644 index 00000000..463960b8 --- /dev/null +++ b/packages/project-data/.gitignore @@ -0,0 +1,5 @@ +dist +build +*.pyc +*.pyo +*.egg-info diff --git a/packages/project-data/lektor_project_data.py b/packages/project-data/lektor_project_data.py new file mode 100644 index 00000000..0847ae4c --- /dev/null +++ b/packages/project-data/lektor_project_data.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from qypi.api import QyPI + +from lektor.pluginsystem import Plugin + +class ProjectDataPlugin(Plugin): + name = 'Project Data' + description = u'Retrieve project information from PyPI.' + + data = {} + + def package_data(self, name, entry_point=None): + if not entry_point: + entry_point = 'https://pypi.org/pypi' + + q = QyPI(entry_point) + pkg = q.get_package(name) + self.data.update(pkg['info']) + + def project_data(self, name): + self.package_data(name) + # self.github_data + # self.bitbucket_data + return self.data + + def on_setup_env(self, **extra): + self.env.jinja_env.globals['project_data'] = self.project_data diff --git a/packages/project-data/setup.py b/packages/project-data/setup.py new file mode 100644 index 00000000..58cd2edf --- /dev/null +++ b/packages/project-data/setup.py @@ -0,0 +1,18 @@ +from setuptools import setup + +setup( + name='lektor-project-data', + version='0.1', + author='Joseph Nix', + author_email='nixjdm@terminallabs.com', + license='MIT', + py_modules=['lektor_project_data'], + install_requires=[ + 'qypi==0.4.1', + ], + entry_points={ + 'lektor.plugins': [ + 'project-data = lektor_project_data:ProjectDataPlugin', + ] + } +) diff --git a/templates/macros/plugins.html b/templates/macros/plugins.html index 75fe4430..bc3d02d1 100644 --- a/templates/macros/plugins.html +++ b/templates/macros/plugins.html @@ -8,19 +8,22 @@ {% endmacro %} {% macro render_plugin_list(plugins, active=none) %} - {% endmacro %} diff --git a/templates/plugin.html b/templates/plugin.html index d9ce7e22..67808659 100644 --- a/templates/plugin.html +++ b/templates/plugin.html @@ -2,7 +2,10 @@ {% from 'macros/blocksupport.html' import render_full_width_blocks %} {% block title %}{{ this.title }}{% endblock %} {% block outerbody %} -

{{ this.title }}

1111 - {{ this.summary }}2222 - {{ this.repo }}333 +

{{ this.name }}

+ {% set pd = project_data(this.name) %} + {{ pd }} +
+ {{ pd.description }} + {% endblock %}