From 5d1a1d3fddc4682ee2da31cdc016a1b13c0384f8 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 22:31:28 +0700 Subject: [PATCH 1/6] try to get diazo as post processor --- rules.xml | 8 ++++++++ site/conf.py | 10 +++++++--- site/requirements.txt | 1 + theme.html | 6 ++++++ 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 rules.xml create mode 100644 theme.html diff --git a/rules.xml b/rules.xml new file mode 100644 index 00000000..13bf9439 --- /dev/null +++ b/rules.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/site/conf.py b/site/conf.py index 7f1d778b..55447a41 100644 --- a/site/conf.py +++ b/site/conf.py @@ -815,12 +815,16 @@ # Many filters are shipped with Nikola. A list is available in the manual: # # -# from nikola import filters -# FILTERS = { +from nikola import filters +def diazoit(infile): + return filters.runinplace(r'diazorun -o %2 -r rules.xml %1', infile) +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' diff --git a/site/requirements.txt b/site/requirements.txt index 82f8a65a..441d4d34 100644 --- a/site/requirements.txt +++ b/site/requirements.txt @@ -1,3 +1,4 @@ PyYAML webassets nikola +diazo diff --git a/theme.html b/theme.html new file mode 100644 index 00000000..669d4089 --- /dev/null +++ b/theme.html @@ -0,0 +1,6 @@ + + +test + + + From ec2af11232395b0167aa5ad54dd3e62a46df5d36 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 22:39:34 +0700 Subject: [PATCH 2/6] switch to ruamel.yaml --- site/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/requirements.txt b/site/requirements.txt index 441d4d34..72f647b9 100644 --- a/site/requirements.txt +++ b/site/requirements.txt @@ -1,4 +1,4 @@ -PyYAML +ruamel.yaml webassets nikola diazo From d5f3555b467e3afb3c06b2a5756d4f4a7c277871 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 22:50:46 +0700 Subject: [PATCH 3/6] path to rules --- site/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site/conf.py b/site/conf.py index 55447a41..056cc570 100644 --- a/site/conf.py +++ b/site/conf.py @@ -817,7 +817,7 @@ # from nikola import filters def diazoit(infile): - return filters.runinplace(r'diazorun -o %2 -r rules.xml %1', infile) + return filters.runinplace(r'diazorun -o %2 -r ../rules.xml %1', infile) FILTERS = { ".html": "diazoit", From 03d201d3f4a2e2cb846bfeeddc60cd73c26c9cd0 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 22:58:43 +0700 Subject: [PATCH 4/6] switch to calling diazo using python --- site/conf.py | 22 ++++++++++++++++++++-- rules.xml => site/themes/rules.xml | 0 theme.html => site/themes/theme.html | 0 3 files changed, 20 insertions(+), 2 deletions(-) rename rules.xml => site/themes/rules.xml (100%) rename theme.html => site/themes/theme.html (100%) diff --git a/site/conf.py b/site/conf.py index 056cc570..1286d70f 100644 --- a/site/conf.py +++ b/site/conf.py @@ -815,9 +815,27 @@ # Many filters are shipped with Nikola. A list is available in the manual: # # -from nikola import 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): - return filters.runinplace(r'diazorun -o %2 -r ../rules.xml %1', infile) + content = etree.parse(infile) + transformed = transform(content) + return etree.tostring(transformed) + FILTERS = { ".html": "diazoit", diff --git a/rules.xml b/site/themes/rules.xml similarity index 100% rename from rules.xml rename to site/themes/rules.xml diff --git a/theme.html b/site/themes/theme.html similarity index 100% rename from theme.html rename to site/themes/theme.html From 393ea90bb4e130db623faf1fc610354f4bf81589 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 23:15:51 +0700 Subject: [PATCH 5/6] try to show debug of build --- netlify.toml | 6 ++++-- site/themes/rules.xml | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/netlify.toml b/netlify.toml index 51bf38b3..b04421a9 100644 --- a/netlify.toml +++ b/netlify.toml @@ -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. diff --git a/site/themes/rules.xml b/site/themes/rules.xml index 13bf9439..743c26e6 100644 --- a/site/themes/rules.xml +++ b/site/themes/rules.xml @@ -4,5 +4,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + + From eb0a48299f1576acf76439fd4b47a83cb7d45e41 Mon Sep 17 00:00:00 2001 From: Dylan Jay Date: Mon, 4 Mar 2019 23:17:20 +0700 Subject: [PATCH 6/6] fix missing quote --- netlify.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netlify.toml b/netlify.toml index b04421a9..04640a73 100644 --- a/netlify.toml +++ b/netlify.toml @@ -22,7 +22,7 @@ [context.deploy-preview.environment] # ACCESS_TOKEN = "not so secret" NIKOLA_DEBUG = "1" - NIKOLA_SHOW_TRACEBACKS = "1' + NIKOLA_SHOW_TRACEBACKS = "1" # # # Branch Deploy context: All deploys that are not in # # an active Deploy Preview will inherit these settings.