From 4f411104f3fbd88446eccb3cde19726a9435491b Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 23 Apr 2020 14:56:46 +0530 Subject: [PATCH] fix(frappe-nginx): Generate Standard Style CSS use nunjucks to render jinja2 template generate default theme --- build/frappe-nginx/Dockerfile | 12 +++++++++++- build/frappe-nginx/generate_standard_style_css.js | 14 ++++++++++++++ build/frappe-nginx/v12.Dockerfile | 12 +++++++++++- 3 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 build/frappe-nginx/generate_standard_style_css.js diff --git a/build/frappe-nginx/Dockerfile b/build/frappe-nginx/Dockerfile index 6fa6441a..a4684140 100644 --- a/build/frappe-nginx/Dockerfile +++ b/build/frappe-nginx/Dockerfile @@ -6,13 +6,23 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN install_packages git -RUN mkdir -p apps sites/assets \ +RUN mkdir -p apps sites/assets/css \ && cd apps \ && git clone --depth 1 https://github.com/frappe/frappe +COPY build/frappe-nginx/generate_standard_style_css.js \ + /home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js + RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ + && yarn add nunjucks -D \ + && node generate_standard_style_css.js \ + frappe/website/doctype/website_theme/website_theme_template.scss > \ + /home/frappe/standard_templates_string \ + && node generate_bootstrap_theme.js \ + /home/frappe/frappe-bench/sites/assets/css/standard_style.css \ + "$(cat /home/frappe/standard_templates_string)" \ && rm -fr node_modules \ && yarn install --production=true \ && node --version \ diff --git a/build/frappe-nginx/generate_standard_style_css.js b/build/frappe-nginx/generate_standard_style_css.js new file mode 100644 index 00000000..275ab47d --- /dev/null +++ b/build/frappe-nginx/generate_standard_style_css.js @@ -0,0 +1,14 @@ +const nunjucks = require("nunjucks"); + +const templatePath = process.argv[2]; +const pathArray = templatePath.split("/"); +const templateFile = pathArray.pop(); +const templateDir = pathArray.join("/"); + +nunjucks.configure(templateDir); +const rendered = nunjucks.render(templateFile, { + button_rounded_corners: true, + font_properties: "300,600", +}); + +console.log(rendered.replace(/\n/gm, "\\n")); diff --git a/build/frappe-nginx/v12.Dockerfile b/build/frappe-nginx/v12.Dockerfile index c1860a2a..f9839d66 100644 --- a/build/frappe-nginx/v12.Dockerfile +++ b/build/frappe-nginx/v12.Dockerfile @@ -6,13 +6,23 @@ RUN mkdir -p /home/frappe/frappe-bench/sites \ RUN install_packages git -RUN mkdir -p apps sites/assets \ +RUN mkdir -p apps sites/assets/css \ && cd apps \ && git clone --depth 1 https://github.com/frappe/frappe --branch version-12 +COPY build/frappe-nginx/generate_standard_style_css.js \ + /home/frappe/frappe-bench/apps/frappe/generate_standard_style_css.js + RUN cd /home/frappe/frappe-bench/apps/frappe \ && yarn \ && yarn run production \ + && yarn add nunjucks -D \ + && node generate_standard_style_css.js \ + frappe/website/doctype/website_theme/website_theme_template.scss > \ + /home/frappe/standard_templates_string \ + && node generate_bootstrap_theme.js \ + /home/frappe/frappe-bench/sites/assets/css/standard_style.css \ + "$(cat /home/frappe/standard_templates_string)" \ && rm -fr node_modules \ && yarn install --production=true \ && node --version \