diff --git a/.gitignore b/.gitignore index 4b07dbf..0b693b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ output/ __pycache__/ *.py[cod] -*$py.class \ No newline at end of file +*$py.class +web/micron/ +sticker/ \ No newline at end of file diff --git a/web/nfc-theme/templates/article.mu b/web/nfc-theme/templates/article.mu new file mode 100644 index 0000000..c2d40b1 --- /dev/null +++ b/web/nfc-theme/templates/article.mu @@ -0,0 +1,5 @@ +{% extends "base.mu" %} +{% block content %} +- +{{ article.content }} +{% endblock %} diff --git a/web/nfc-theme/templates/base.mu b/web/nfc-theme/templates/base.mu new file mode 100644 index 0000000..e7bb2e3 --- /dev/null +++ b/web/nfc-theme/templates/base.mu @@ -0,0 +1,10 @@ +>{% block title %}{{ SITENAME }}{% endblock title %} + +{% block content %} +{% endblock %} + +{% if DESCRIPTION %} +- +{{ DESCRIPTION }} +- +{% endif %} diff --git a/web/pelicanconf.py b/web/pelicanconf.py index b82e6a0..a273790 100644 --- a/web/pelicanconf.py +++ b/web/pelicanconf.py @@ -43,6 +43,8 @@ AUTHOR_SAVE_AS = '' AUTHORS_SAVE_AS = '' TAGS_SAVE_AS = '' +MICRON_PATH = 'micron' + PATH = 'content' ARTICLE_PATHS = ['tags',] PAGE_PATHS = ['pages',] @@ -57,4 +59,4 @@ CATEGORY_SAVE_AS = 'projects/{slug}/index.html' DELETE_OUTPUT_DIRECTORY = True -PLUGINS = ['geohash', 'geodata'] \ No newline at end of file +PLUGINS = ['geohash', 'geodata', 'micron'] \ No newline at end of file diff --git a/web/plugins/micron/__init__.py b/web/plugins/micron/__init__.py new file mode 100644 index 0000000..5e48b24 --- /dev/null +++ b/web/plugins/micron/__init__.py @@ -0,0 +1 @@ +from .micron import * \ No newline at end of file diff --git a/web/plugins/micron/micron.py b/web/plugins/micron/micron.py new file mode 100644 index 0000000..9a978d7 --- /dev/null +++ b/web/plugins/micron/micron.py @@ -0,0 +1,25 @@ +from pelican import signals, generators +from itertools import chain +from jinja2 import Environment, FileSystemLoader +import os +from pprint import pprint + +def generate_micron(generator): + template_path = os.path.join(generator.settings.get('THEME'), 'templates') + out_path = generator.settings.get('MICRON_PATH', 'micron/') + environment = Environment(loader=FileSystemLoader(template_path)) + if not os.path.exists(out_path): + os.mkdir(out_path) + for obj in generator.articles: + filename = obj.slug + ".mu" + template = environment.get_template( obj.template + '.mu') + context = dict() + context.update({ 'article' : obj }) + context.update(obj.settings) + content = template.render(context) + output_micron = os.path.join(out_path, filename) + with open(output_micron, 'w') as mf: + mf.write(content) + +def register(): + signals.article_generator_finalized.connect(generate_micron) \ No newline at end of file