From 055eee6650c62015cfd24cfd297e010ffdcccf5c Mon Sep 17 00:00:00 2001 From: zyachel Date: Sun, 27 Nov 2022 22:47:33 +0530 Subject: [PATCH] fix(mathjax): fix mathjax script route also change the location of mathjax resources. and clean up docs --- README.md | 8 ------ app.js | 3 +-- public/js/index.js | 5 ++++ .../fonts/woff-v2/MathJax_AMS-Regular.woff | Bin .../woff-v2/MathJax_Calligraphic-Bold.woff | Bin .../woff-v2/MathJax_Calligraphic-Regular.woff | Bin .../fonts/woff-v2/MathJax_Fraktur-Bold.woff | Bin .../woff-v2/MathJax_Fraktur-Regular.woff | Bin .../fonts/woff-v2/MathJax_Main-Bold.woff | Bin .../fonts/woff-v2/MathJax_Main-Italic.woff | Bin .../fonts/woff-v2/MathJax_Main-Regular.woff | Bin .../woff-v2/MathJax_Math-BoldItalic.woff | Bin .../fonts/woff-v2/MathJax_Math-Italic.woff | Bin .../fonts/woff-v2/MathJax_Math-Regular.woff | Bin .../fonts/woff-v2/MathJax_SansSerif-Bold.woff | Bin .../woff-v2/MathJax_SansSerif-Italic.woff | Bin .../woff-v2/MathJax_SansSerif-Regular.woff | Bin .../fonts/woff-v2/MathJax_Script-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size1-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size2-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size3-Regular.woff | Bin .../fonts/woff-v2/MathJax_Size4-Regular.woff | Bin .../woff-v2/MathJax_Typewriter-Regular.woff | Bin .../fonts/woff-v2/MathJax_Vector-Bold.woff | Bin .../fonts/woff-v2/MathJax_Vector-Regular.woff | Bin .../chtml/fonts/woff-v2/MathJax_Zero.woff | Bin public/{js => }/mathjax/tex-chtml.js | 0 views/pug/base.pug | 2 +- views/pug/pages/privacy.pug | 4 --- views/sass/_base.scss | 23 ------------------ 30 files changed, 7 insertions(+), 38 deletions(-) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff (100%) rename public/{js => }/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff (100%) rename public/{js => }/mathjax/tex-chtml.js (100%) diff --git a/README.md b/README.md index 4ae8cc0..f69cc83 100644 --- a/README.md +++ b/README.md @@ -136,10 +136,6 @@ From [their privacy policy](https://www.quora.com/about/privacy) A key called 'theme' is stored in local storage provided by your browser to store your theme preference should you override the default theme. To prevent this behaviour, either disable JavaScript or local storage for Quetre. -- Data collected by other services - - As Quetre connects to 'cdn.jsdelivr.net' for MathJax library, jsdelivr might log some data. So, follow due precaution. Using a VPN might be a good idea. Or even better, consider hosting your own instance. - --- ## FAQs @@ -156,10 +152,6 @@ From [their privacy policy](https://www.quora.com/about/privacy) I'm working to implement them soon. Keep an eye on [To-Do list](#to-do). -- Why is the website connecting to 'cdn.jsdelivr.net'? - - It is for an open source library – [Mathjax](https://www.mathjax.org/) – which is used to display math eqations nicely. If I get enough time, I'll include it locally. - - Why are some math equations showing up weirdly? If you're browsing with JavaScript disabled, then the Mathjax library isn't able to load and format tex equations. I'd recommend to enable JavaScript for it since there's no other way to show them in the browser. Even Quora uses Mathjax. diff --git a/app.js b/app.js index 323c951..aac5d98 100644 --- a/app.js +++ b/app.js @@ -20,10 +20,9 @@ const app = express(); // 1. IMPORTANT MIDDLWARES app.use(compression()); // compressing responses app.use( - helmet({ + helmet({ contentSecurityPolicy: { directives: { - 'script-src': ["'self'"], 'block-all-mixed-content': null, // deprecated. 'upgrade-insecure-requests': process.env.NO_UPGRADE ? null : [], }, diff --git a/public/js/index.js b/public/js/index.js index c77c348..bac2e6e 100644 --- a/public/js/index.js +++ b/public/js/index.js @@ -48,3 +48,8 @@ btnTheme.addEventListener('click', () => { if (userPrefersTheme) setTheme(userPrefersTheme); else if (browserPrefersDarkTheme) setTheme('dark'); })(); + +//////////////////////////////////////////////////////// +// MATHJAX CONFIG +//////////////////////////////////////////////////////// +window.MathJax = { options: { enableMenu: false } }; diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_AMS-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Bold.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Calligraphic-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Bold.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Fraktur-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Bold.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Italic.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Main-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-BoldItalic.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Italic.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Math-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Bold.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Italic.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_SansSerif-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Script-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size1-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size2-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size3-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Size4-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Typewriter-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Bold.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Vector-Regular.woff diff --git a/public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff b/public/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff similarity index 100% rename from public/js/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff rename to public/mathjax/output/chtml/fonts/woff-v2/MathJax_Zero.woff diff --git a/public/js/mathjax/tex-chtml.js b/public/mathjax/tex-chtml.js similarity index 100% rename from public/js/mathjax/tex-chtml.js rename to public/mathjax/tex-chtml.js diff --git a/views/pug/base.pug b/views/pug/base.pug index e3c2f0b..cff006c 100644 --- a/views/pug/base.pug +++ b/views/pug/base.pug @@ -50,6 +50,6 @@ html(lang='en') if someAnswerContainsMath script#MathJax-script( type='text/javascript', - src='/public/js/mathjax/tex-chtml.js', + src='/mathjax/tex-chtml.js', async ) diff --git a/views/pug/pages/privacy.pug b/views/pug/pages/privacy.pug index 23f2b8b..781d683 100644 --- a/views/pug/pages/privacy.pug +++ b/views/pug/pages/privacy.pug @@ -31,7 +31,3 @@ block content summary.faqs__question Data stored locally in your browser svg.faqs__icon: use(href='/misc/sprite.svg#icon-open') p.faqs__answer A key called 'theme' is stored in local storage provided by your browser to store your theme preference should you override the default theme. To prevent this behaviour, either disable JavaScript or local storage for Quetre. - details.faqs__faq - summary.faqs__question Data collected by other services - svg.faqs__icon: use(href='/misc/sprite.svg#icon-open') - p.faqs__answer As Quetre connects to 'cdn.jsdelivr.net' for MathJax library, jsdelivr might log some data. So, follow due precaution. Using a VPN might be a good idea. Or even better, consider hosting your own instance. diff --git a/views/sass/_base.scss b/views/sass/_base.scss index ab82736..9fa94cd 100644 --- a/views/sass/_base.scss +++ b/views/sass/_base.scss @@ -141,26 +141,3 @@ body { @include focus-rules; } } - -//////////////////////////////////////////////////////// -// FOR MATHJAX -//////////////////////////////////////////////////////// -mjx-container.MathJax { - pointer-events: none; -} -/* -.CtxtMenu_ContextMenu, -.CtxtMenu_Info { - background-color: var(--clr-base-bg) !important; - font-family: inherit !important; - color: inherit !important; -} -.CtxtMenu_InfoTitle, -.CtxtMenu_InfoSignature, -.CtxtMenu_MenuClose .CtxtMenu_InfoClose, -.CtxtMenu_InfoContent { - font-family: inherit !important; - background: inherit !important; - color: inherit !important; -} -*/