Skip to content

[WIP] diazo as post processor #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@
#
# # Deploy Preview context: All Deploy Previews
# # will inherit these settings.
# [context.deploy-preview.environment]
# ACCESS_TOKEN = "not so secret"
[context.deploy-preview.environment]
# ACCESS_TOKEN = "not so secret"
NIKOLA_DEBUG = "1"
NIKOLA_SHOW_TRACEBACKS = "1"
#
# # Branch Deploy context: All deploys that are not in
# # an active Deploy Preview will inherit these settings.
Expand Down
28 changes: 25 additions & 3 deletions site/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,12 +743,34 @@
# Many filters are shipped with Nikola. A list is available in the manual:
# <https://getnikola.com/handbook.html#post-processing-filters>
#
# from nikola import filters
# FILTERS = {

#from nikola import filters
#def diazoit(infile):
# return filters.runinplace(r'diazorun -o %2 -r ../rules.xml %1', infile)

from lxml import etree
from diazo.compiler import compile_theme

absolute_prefix = "/static"

rules = "themes/rules.xml"
theme = "themes/theme.html"

compiled_theme = compile_theme(rules, theme, absolute_prefix=absolute_prefix)
transform = etree.XSLT(compiled_theme)

def diazoit(infile):
content = etree.parse(infile)
transformed = transform(content)
return etree.tostring(transformed)

FILTERS = {
".html": "diazoit",

# ".html": [filters.typogrify],
# ".js": [filters.closure_compiler],
# ".jpg": ["jpegoptim --strip-all -m75 -v %s"],
# }
}

# Executable for the "yui_compressor" filter (defaults to 'yui-compressor').
# YUI_COMPRESSOR_EXECUTABLE = 'yui-compressor'
Expand Down
1 change: 1 addition & 0 deletions site/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ruamel.yaml
webassets
nikola
diazo
10 changes: 10 additions & 0 deletions site/themes/rules.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<rules
xmlns="http://namespaces.plone.org/diazo"
xmlns:css="http://namespaces.plone.org/diazo/css"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<theme href="theme.html" />
<!-- do nothing -->
<replace theme="/html" content="/html" />

</rules>
6 changes: 6 additions & 0 deletions site/themes/theme.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<html>
<body>
test
</body>

</html>