[pluginlist-update] Adding project data plugin and using it to retrieve info about plugins.

This commit is contained in:
Joseph Nix 2018-04-23 12:10:46 -05:00
parent efafc6e60f
commit ac23ef384a
18 changed files with 90 additions and 46 deletions

View File

@ -1,5 +0,0 @@
title: Disqus Comments
---
official: yes
---
categories: templates

View File

@ -0,0 +1,3 @@
name: flask
---
categories: content

View File

@ -1,4 +0,0 @@
title: Jinja Content
---
categories: content
---

View File

@ -0,0 +1,3 @@
name: lektor-htmlmin
---
categories: build

View File

@ -0,0 +1,3 @@
name: lektor-i18n
---
categories: build

View File

@ -0,0 +1,3 @@
name: lektor-jinja-content
---
categories: content

View File

@ -0,0 +1,3 @@
name: lektor-make
---
categories: build

View File

@ -0,0 +1,3 @@
name: lektor-npm-support
---
categories: build

View File

@ -0,0 +1,5 @@
name: lektor-webpack-support
---
categories: build
---
official: yes

View File

@ -1,7 +0,0 @@
title: Markdown Admonition
---
categories: content
---
link: https://pypi.org/project/lektor-markdown-admonition/
---
official: yes

View File

@ -1,7 +0,0 @@
title: Markdown Highlighter
---
categories: content
---
link: https://pypi.org/project/lektor-markdown-highlighter/
---
official: yes

View File

@ -1,7 +0,0 @@
title: Webpack Support
---
categories: build
---
link: https://pypi.org/project/lektor-webpack-support/
---
official: yes

View File

@ -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

5
packages/project-data/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
dist
build
*.pyc
*.pyo
*.egg-info

View File

@ -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

View File

@ -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',
]
}
)

View File

@ -8,19 +8,22 @@
{% endmacro %}
{% macro render_plugin_list(plugins, active=none) %}
<ul>
{% for category in site.query('/plugin-categories') %}
<li{% if category._id == active %} class="active"{% endif
%}><a href="{{ category|url }}">{{ category.name }}</a></li>
<h2><a href="{{ category|url }}">{{ category.name }}</a></h2>
<ul>
{% for plugin in category.children.order_by('-official', 'title') %}
{% if plugin.official %}
<li><a href="{{ plugin|url }}">* {{ plugin.title }}</a></li>
<li><a href="{{ plugin|url }}">* {{ plugin.name }}</a></li>
{% if loop.nextitem %}
{% if not loop.nextitem.official %}
---
{% endif %}
{% endif %}
{% else %}
<li><a href="{{ plugin|url }}">{{ plugin.title }}</a></li>
<li><a href="{{ plugin|url }}">{{ plugin.name }}</a></li>
{% endif %}
{% endfor %}
</ul>
{% endfor %}
</ul>
{% endmacro %}

View File

@ -2,7 +2,10 @@
{% from 'macros/blocksupport.html' import render_full_width_blocks %}
{% block title %}{{ this.title }}{% endblock %}
{% block outerbody %}
<h1>{{ this.title }}</h1>1111
{{ this.summary }}2222
{{ this.repo }}333
<h1>{{ this.name }}</h1>
{% set pd = project_data(this.name) %}
{{ pd }}
<br>
{{ pd.description }}
{% endblock %}