micron writer
This commit is contained in:
parent
d37b0a67a4
commit
306423cd99
6 changed files with 47 additions and 2 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,4 +1,6 @@
|
||||||
output/
|
output/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*$py.class
|
*$py.class
|
||||||
|
web/micron/
|
||||||
|
sticker/
|
||||||
5
web/nfc-theme/templates/article.mu
Normal file
5
web/nfc-theme/templates/article.mu
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
{% extends "base.mu" %}
|
||||||
|
{% block content %}
|
||||||
|
-
|
||||||
|
{{ article.content }}
|
||||||
|
{% endblock %}
|
||||||
10
web/nfc-theme/templates/base.mu
Normal file
10
web/nfc-theme/templates/base.mu
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
>{% block title %}{{ SITENAME }}{% endblock title %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% if DESCRIPTION %}
|
||||||
|
-
|
||||||
|
{{ DESCRIPTION }}
|
||||||
|
-
|
||||||
|
{% endif %}
|
||||||
|
|
@ -43,6 +43,8 @@ AUTHOR_SAVE_AS = ''
|
||||||
AUTHORS_SAVE_AS = ''
|
AUTHORS_SAVE_AS = ''
|
||||||
TAGS_SAVE_AS = ''
|
TAGS_SAVE_AS = ''
|
||||||
|
|
||||||
|
MICRON_PATH = 'micron'
|
||||||
|
|
||||||
PATH = 'content'
|
PATH = 'content'
|
||||||
ARTICLE_PATHS = ['tags',]
|
ARTICLE_PATHS = ['tags',]
|
||||||
PAGE_PATHS = ['pages',]
|
PAGE_PATHS = ['pages',]
|
||||||
|
|
@ -57,4 +59,4 @@ CATEGORY_SAVE_AS = 'projects/{slug}/index.html'
|
||||||
|
|
||||||
DELETE_OUTPUT_DIRECTORY = True
|
DELETE_OUTPUT_DIRECTORY = True
|
||||||
|
|
||||||
PLUGINS = ['geohash', 'geodata']
|
PLUGINS = ['geohash', 'geodata', 'micron']
|
||||||
1
web/plugins/micron/__init__.py
Normal file
1
web/plugins/micron/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
from .micron import *
|
||||||
25
web/plugins/micron/micron.py
Normal file
25
web/plugins/micron/micron.py
Normal file
|
|
@ -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)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue