Commit 121be484 authored by Louis's avatar Louis
Browse files

New column types: html, empty, link

parent 961efea1
Pipeline #6963 failed with stage
......@@ -5,6 +5,11 @@
* Name changed from "pypistats" to "pypimonitor".
* Use chartsjs.org to draw line charts (was morrisjs before).
* Package names are now case insensitive.
* New column/badge types:
* empty: empty column;
* link: hyperlin;
* html: raw html code;
* and more…
-- Louis Paternault <spalax@gresille.org>
......
......@@ -32,5 +32,5 @@
- [ ] Add a favicon
- [ ] Each plugin can access global and common options in global configuration
- [ ] Add copyright information
- [ ] Create plugins `empty`, `link`, `html`
- [x] Create plugins `empty`, `link`, `html`
- [ ] Remove obsolete templates
......@@ -19,3 +19,37 @@ class Column:
def render(self, context, package, options):
raise NotImplementedError()
class Empty(Column):
keyword = "empty"
def render(self, context, package, options):
return ""
class Html(Column):
keyword = 'html'
default = {'html': ''}
def render(self, context, package, options):
return options['html']
class Jinja2(Column):
def render(self, context, package, options):
TODO("""Make available:
- package: the package name (as the key of the yaml dict)
- pypi: the package information (as get from pypi)
- column: the column options
- config: the whole yaml file
""")
return context.environment.get_template(os.path.join("columns", self.keyword)).render(context)
class Link(Jinja2):
keyword = 'link'
def render(self, context, package, options):
if 'href' not in options:
raise MissingArgument(self.keyword, 'href')
if 'content' not in options:
options['content'] = options['href']
super().render(context, package, options)
from pypimonitor.column import Column
class Jinja2(Column):
def render(self, context, package, options):
TODO("""Make available:
- package: the package name (as the key of the yaml dict)
- pypi: the package information (as get from pypi)
- column: the column options
- config: the whole yaml file
""")
return context.environment.get_template(os.path.join("columns", self.keyword)).render(context)
<a href="{{ href }}">
{{ content }}
</a>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment