From 0d9ba16fc368d519c2e3a91c8f7024a0840b6e2e Mon Sep 17 00:00:00 2001 From: TBK Date: Tue, 21 Mar 2017 00:50:32 +0100 Subject: [PATCH] MathJax support (#147) * MathJax support - Adds support for MathJax. - Mermaid and MathJax can be enabled/disabled via Settings. - Bit of code styling for the layout.hbs files. - Added link to footer. - Updated darkly theme navbar. * Fixed indentation Tabs to spaces. --- README.md | 3 +- public/themes/darkly/views/layouts/layout.hbs | 252 +++++++------- .../themes/twitter/views/layouts/layout.hbs | 172 +++++----- routes/config.js | 6 +- views/layouts/layout.hbs | 322 +++++++++--------- views/settings.hbs | 65 ++-- 6 files changed, 437 insertions(+), 383 deletions(-) diff --git a/README.md b/README.md index 464dfe93..0a4e183b 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,8 @@ Most of the configuration can be done on the `/settings` page but there are some |`show_kb_meta`|Whether to show article meta data including published date, last updated date, author etc| |`suggest_allowed`|If enabled non authenticated users can submit article suggestions for approval| |`show_author_email`|Controls whether the authors email address is displayed in the meta. Requires "Show article meta data" to be true.| -|`enable_mermaid_charts`|Whether to allow Mermaid charts within articles| +|`mermaid`|Whether to allow Mermaid charts within articles| +|`mathjax`|Whether to allow MathJax inputs within articles| |`app_context`|Allows for the website to be run from a non root path. Eg: http://127.0.0.1:4444/openkb/| |`links_blank_page`|Controls whether links within articles open a new page (tab)| |`add_header_anchors`|Whether to add HTML anchors to all heading tags for linking within articles or direct linking from other articles| diff --git a/public/themes/darkly/views/layouts/layout.hbs b/public/themes/darkly/views/layouts/layout.hbs index 3ef5b0b8..67cdfffb 100644 --- a/public/themes/darkly/views/layouts/layout.hbs +++ b/public/themes/darkly/views/layouts/layout.hbs @@ -1,130 +1,140 @@ - - - {{#if result.kb_seo_title}} - {{result.kb_seo_title}} - - {{else}} - {{#if result.kb_title}} + + + {{#if result.kb_seo_title}} + {{result.kb_seo_title}} + + {{else}} + {{#if result.kb_title}} {{result.kb_title}} - {{else}} + {{else}} {{title}} - {{/if}} - {{/if}} - - - - {{#if result.kb_seo_description}} - - - {{else}} - {{#if result.kb_body}} + {{/if}} + {{/if}} + + + + {{#if result.kb_seo_description}} + + + {{else}} + {{#if result.kb_body}} - {{else}} - - - {{/if}} - {{/if}} - {{#if result.kb_keywords}} - - {{else}} - - {{/if}} - - - - - - - - - - - - - - - {{#ifCond user_page '===' true}} - {{#if config.settings.google_analytics}} + {{else}} + + + {{/if}} + {{/if}} + {{#if result.kb_keywords}} + + {{else}} + + {{/if}} + + + + + + + + + + + {{#ifCond config.settings.mermaid '===' true}} + + {{/ifCond}} + {{#ifCond config.settings.mathjax '===' true}} + + + {{/ifCond}} + + + + + {{#ifCond user_page '===' true}} + {{#if config.settings.google_analytics}} {{{config.settings.google_analytics}}} - {{/if}} - {{/ifCond}} - - - - -
- {{{body}}} -
- - - - -
- {{#if show_footer}} - - {{/if}} - + {{/if}} + {{/ifCond}} + + + + +
+ {{{body}}} +
+ + + + +
+ {{#if show_footer}} + + {{/if}} + diff --git a/public/themes/twitter/views/layouts/layout.hbs b/public/themes/twitter/views/layouts/layout.hbs index 506910de..817d7ea1 100644 --- a/public/themes/twitter/views/layouts/layout.hbs +++ b/public/themes/twitter/views/layouts/layout.hbs @@ -1,94 +1,102 @@ - - - {{#if result.kb_seo_title}} - {{result.kb_seo_title}} - - {{else}} - {{#if result.kb_title}} + + + {{#if result.kb_seo_title}} + {{result.kb_seo_title}} + + {{else}} + {{#if result.kb_title}} {{result.kb_title}} - {{else}} + {{else}} {{title}} - {{/if}} - {{/if}} - - - - {{#if result.kb_seo_description}} - - - {{else}} - {{#if result.kb_body}} + {{/if}} + {{/if}} + + + + {{#if result.kb_seo_description}} + + + {{else}} + {{#if result.kb_body}} - {{else}} + {{else}} {{#ifCond homepage '===' true}} - - + + {{else}} - - + + {{/ifCond}} - {{/if}} - {{/if}} - {{#if result.kb_keywords}} - - {{else}} - - {{/if}} - - - - - - - - - - - - - - - - - - - - - - - - - {{#ifCond config.settings.typeahead_search '===' true}} - - {{/ifCond}} - - - {{#ifCond user_page '===' true}} - {{#if config.settings.google_analytics}} + {{/if}} + {{/if}} + {{#if result.kb_keywords}} + + {{else}} + + {{/if}} + + + + + + + + + + + + + + + + + {{#ifCond config.settings.mermaid '===' true}} + + {{/ifCond}} + {{#ifCond config.settings.mathjax '===' true}} + + + {{/ifCond}} + + + + + + + + {{#ifCond config.settings.typeahead_search '===' true}} + + {{/ifCond}} + + + {{#ifCond user_page '===' true}} + {{#if config.settings.google_analytics}} {{{config.settings.google_analytics}}} - {{/if}} - {{/ifCond}} - - - -
- {{{body}}} -
- - - - -
- {{#if show_footer}} - - {{/if}} - + {{/if}} + {{/ifCond}} + + + +
+ {{{body}}} +
+ + + + +
+ {{#if show_footer}} + + {{/if}} + diff --git a/routes/config.js b/routes/config.js index f872e570..4569246f 100644 --- a/routes/config.js +++ b/routes/config.js @@ -18,7 +18,9 @@ "show_kb_meta": true, "suggest_allowed": true, "show_author_email": true, - "enable_mermaid_charts": false, + "mermaid": false, + "mathjax": false, + "mathjax_input_mode": "TeX-MML-AM_CHTML", "app_context": "", "links_blank_page": true, "database": { @@ -39,4 +41,4 @@ "api_allowed": false, "locale": "en" } -} \ No newline at end of file +} diff --git a/views/layouts/layout.hbs b/views/layouts/layout.hbs index a500ec7d..072b3f9b 100644 --- a/views/layouts/layout.hbs +++ b/views/layouts/layout.hbs @@ -1,170 +1,176 @@ - - - {{#if result.kb_seo_title}} - {{result.kb_seo_title}} - - {{else}} - {{#if result.kb_title}} + + + {{#if result.kb_seo_title}} + {{result.kb_seo_title}} + + {{else}} + {{#if result.kb_title}} {{result.kb_title}} - {{else}} + {{else}} {{title}} - {{/if}} - {{/if}} - - - - {{#if result.kb_seo_description}} - - - {{else}} - {{#if result.kb_body}} + {{/if}} + {{/if}} + + + + {{#if result.kb_seo_description}} + + + {{else}} + {{#if result.kb_body}} - {{else}} + {{else}} {{#ifCond homepage '===' true}} - - + + {{else}} - - + + {{/ifCond}} - {{/if}} - {{/if}} - {{#if result.kb_keywords}} - - {{else}} - - {{/if}} - - - - - - - - - - - - - - - - - - {{#ifCond title '===' 'Settings'}} - - {{/ifCond}} - - {{#ifCond config.settings.enable_mermaid_charts '===' true}} - - {{/ifCond}} - - - - - - - - - - {{#ifCond config.settings.typeahead_search '===' true}} - - {{/ifCond}} - - - {{#ifCond user_page '===' true}} - {{#if config.settings.google_analytics}} + {{/if}} + {{/if}} + {{#if result.kb_keywords}} + + {{else}} + + {{/if}} + + + + + + + + + + + + + + + + + + {{#ifCond title '===' 'Settings'}} + + {{/ifCond}} + + {{#ifCond config.settings.mermaid '===' true}} + + {{/ifCond}} + {{#ifCond config.settings.mathjax '===' true}} + + + {{/ifCond}} + + + + + + + + + + {{#ifCond config.settings.typeahead_search '===' true}} + + {{/ifCond}} + + + {{#ifCond user_page '===' true}} + {{#if config.settings.google_analytics}} {{{config.settings.google_analytics}}} - {{/if}} - {{/ifCond}} - - - - -
- {{{body}}} -
- - - - -
- {{#if show_footer}} - - {{/if}} - + {{/if}} + {{/ifCond}} + + + + +
+ {{{body}}} +
+ + + + +
+ {{#if show_footer}} + + {{/if}} + diff --git a/views/settings.hbs b/views/settings.hbs index e38b940a..f4d8d121 100644 --- a/views/settings.hbs +++ b/views/settings.hbs @@ -1,10 +1,10 @@
-
-
- +
+
+
-
+
+ + + +

+ {{__ "Whether to enable "}} mermaid. +

+
+
+ + +

+ {{__ "Whether to enable "}} MathJax. +

+
+
+ + +

+ {{__ "Configure the mode MathJax operates in - "}} Configure MathJax. +

+
@@ -253,16 +280,16 @@ {{__ "Shows the view count next to the results on the homepage and search"}}.

-
- - -

- {{__ "Updates the view count also when users are logged in"}}. -

-
+
+ + +

+ {{__ "Updates the view count also when users are logged in"}}. +

+