From fef917e492551a65d2ace2497c31d60693f68b44 Mon Sep 17 00:00:00 2001 From: Christopher Pickering Date: Wed, 23 Nov 2022 11:11:53 +0100 Subject: [PATCH] docs(demo): fixed unicode issue, added readme and misc updates --- docs/.eleventy.js | 10 ++ docs/readme.md | 17 ++ docs/src/_data/i18n/index.js | 15 +- docs/src/_includes/demo.njk | 154 ++++++++++++++++++ docs/src/_includes/foot.njk | 5 +- docs/src/demo.njk | 125 +------------- docs/src/fr/demo.njk | 4 + docs/src/ru/demo.njk | 4 + .../static/font/fontawesome/stylesheet.scss | 1 + docs/src/static/js/worker.js | 2 +- 10 files changed, 209 insertions(+), 128 deletions(-) create mode 100644 docs/readme.md create mode 100644 docs/src/_includes/demo.njk create mode 100644 docs/src/fr/demo.njk create mode 100644 docs/src/ru/demo.njk diff --git a/docs/.eleventy.js b/docs/.eleventy.js index ace5474..b4b4c35 100644 --- a/docs/.eleventy.js +++ b/docs/.eleventy.js @@ -224,6 +224,15 @@ module.exports = function (eleventyConfig) { } }); + eleventyConfig.addFilter('year', (value) => { + try { + const options = { year: 'numeric' }; + return value.toLocaleDateString('en-us', options); + } catch (e) { + return value; + } + }); + eleventyConfig.addFilter('algExcerpt', (text) => { return text .replace(/.*?<\/code>/gs, '') @@ -266,6 +275,7 @@ module.exports = function (eleventyConfig) { 'download', 'code-commit', 'spinner', + 'circle-question', ], }, '_site/static/font/fontawesome/webfonts', diff --git a/docs/readme.md b/docs/readme.md new file mode 100644 index 0000000..b03d7f8 --- /dev/null +++ b/docs/readme.md @@ -0,0 +1,17 @@ +# djLint Docs + +Docs are made with [11ty](https://www.11ty.dev). + +## Running the docs website locally + +1. change into the docs dir. `cd docs` +2. install node deps. `npm install` +3. turn on the website. `npm start` + +## How the demo works + +The demo is running python as a webworker in web assembly from [pyodide](https://pyodide.org/en/stable/index.html). + +When the page is access a webworker starts, downloads python, installs djLint and deps (notice the wheels in `/src/static/py` that are updated when a new release is created.). + +Once the worker responds "ready" the web UI is shown. diff --git a/docs/src/_data/i18n/index.js b/docs/src/_data/i18n/index.js index 107c6b4..facc060 100644 --- a/docs/src/_data/i18n/index.js +++ b/docs/src/_data/i18n/index.js @@ -137,7 +137,18 @@ module.exports = { }, try_online: { 'en-US': '🤩 Try Online', - ru: '🤩 Essayez', - fr: '🤩 Попробуйте онлайн', + fr: '🤩 Essayez Ici', + ru: '🤩 Попробуйте онлайн', + }, + demo_description: { + 'en-US': 'Online HTML Template formatter using djLint!', + ru: 'Онлайн форматировщик HTML-шаблонов с использованием djLint', + fr: 'Formateur de modèles HTML en ligne utilisant djLint !', + }, + footer_credits: { + 'en-US': + 'djLint was originally created for use in the Atlas projects by the Riverside Healthcare Analytics team.', + fr: 'djLint a été créé à l\'origine pour être utilisé dans les projets Atlas par l\'équipe Riverside Healthcare Analytics.', + ru: 'Изначально djLint был создан для использования в проектах Atlas командой Riverside Healthcare Analytics.', }, }; diff --git a/docs/src/_includes/demo.njk b/docs/src/_includes/demo.njk new file mode 100644 index 0000000..d62a97e --- /dev/null +++ b/docs/src/_includes/demo.njk @@ -0,0 +1,154 @@ +--- +layout: layout.njk +date: Last Modified +description: Online HTML Template formatter. Reformat your HTML templates online with djLint. +keywords: online template formatter, djLint, HTML, templates, formatter, linter, rules, online html template formatter +--- + + + + +
+
+

{{ "demo_description" | i18n | safe }}

+
+ + + + + Loading djLint .. + +
+ +
+ +{% rollup "src/static/js/editor.js" | url %} diff --git a/docs/src/_includes/foot.njk b/docs/src/_includes/foot.njk index 765613f..4600900 100644 --- a/docs/src/_includes/foot.njk +++ b/docs/src/_includes/foot.njk @@ -12,7 +12,10 @@
+

+ {{ "footer_credits" | i18n | safe }}

diff --git a/docs/src/demo.njk b/docs/src/demo.njk index d7409ad..8edb099 100644 --- a/docs/src/demo.njk +++ b/docs/src/demo.njk @@ -1,127 +1,4 @@ --- -layout: layout.njk +layout: demo.njk date: Last Modified -description: Online HTML Template formatter. Reformat your HTML templates online with djLint. -keywords: online template formatter, djLint, HTML, templates, formatter, linter, rules, online html template formatter --- - - - -
-
-

Online HTML Template formatter using djLint!

-
- - - - - Loading djLint .. - -
- -
-
-{% rollup "src/static/js/editor.js" | url %} diff --git a/docs/src/fr/demo.njk b/docs/src/fr/demo.njk new file mode 100644 index 0000000..8edb099 --- /dev/null +++ b/docs/src/fr/demo.njk @@ -0,0 +1,4 @@ +--- +layout: demo.njk +date: Last Modified +--- diff --git a/docs/src/ru/demo.njk b/docs/src/ru/demo.njk new file mode 100644 index 0000000..8edb099 --- /dev/null +++ b/docs/src/ru/demo.njk @@ -0,0 +1,4 @@ +--- +layout: demo.njk +date: Last Modified +--- diff --git a/docs/src/static/font/fontawesome/stylesheet.scss b/docs/src/static/font/fontawesome/stylesheet.scss index 03ea82c..03ef573 100644 --- a/docs/src/static/font/fontawesome/stylesheet.scss +++ b/docs/src/static/font/fontawesome/stylesheet.scss @@ -68,6 +68,7 @@ $icons: ( globe: $fa-var-globe, code-commit: $fa-var-code-commit, spinner: $fa-var-spinner, + circle-question: $fa-var-circle-question, ); @each $key, $value in $icons { diff --git a/docs/src/static/js/worker.js b/docs/src/static/js/worker.js index 364db6d..b039d1d 100644 --- a/docs/src/static/js/worker.js +++ b/docs/src/static/js/worker.js @@ -117,7 +117,7 @@ self.onmessage = async (event) => { await pyodide.runPythonAsync(` temp_file = tempfile.NamedTemporaryFile(delete=False) -temp_file.write(b"""${html}""") +temp_file.write(str.encode("""${html}""")) temp_file.seek(0) config = Config( temp_file.name${indent}${profile}${preserveLeadingSpace}${preserveBlankSpace}${formatJs}${formatCss}