diff options
| author | Bobby <[email protected]> | 2023-03-10 00:00:50 -0500 |
|---|---|---|
| committer | Bobby <[email protected]> | 2023-03-10 00:00:50 -0500 |
| commit | 8e5000e31396debf13da969012d1c47886c37524 (patch) | |
| tree | e9a6264ba05d129ab86263ee29e1ef0a61a278ed | |
| parent | 21e597c2829cc0f188c2ed1e5d46ceb68608c4b0 (diff) | |
| download | thatcomputerscientist-8e5000e31396debf13da969012d1c47886c37524.tar.xz thatcomputerscientist-8e5000e31396debf13da969012d1c47886c37524.zip | |
DRY improvements
| -rw-r--r-- | templates/blog/activity.html | 34 | ||||
| -rw-r--r-- | templates/blog/home.html | 36 | ||||
| -rw-r--r-- | templates/blog/partials/mathjax.html | 39 | ||||
| -rw-r--r-- | templates/blog/post.html | 40 |
4 files changed, 47 insertions, 102 deletions
diff --git a/templates/blog/activity.html b/templates/blog/activity.html index dce9256f..6c3d99f2 100644 --- a/templates/blog/activity.html +++ b/templates/blog/activity.html @@ -52,38 +52,6 @@ {% endif %} </div> -<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> -</script> -<script type="text/x-mathjax-config"> - MathJax.Hub.Register.StartupHook("End Jax",function () { - var BROWSER = MathJax.Hub.Browser; - - var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || - (BROWSER.isMSIE && BROWSER.hasMathPlayer) || - (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || - (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && - !BROWSER.versionAtLeast("14.0")); - - var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ - prefer: { - MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", - other:"HTML" - } - }); - - var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; - if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; - if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; - return MathJax.Hub.setRenderer(jax); - }); - MathJax.Hub.Config({ - "tex2jax": { - "inlineMath": [['$','$'], ['\\(','\\)']], - }, - "fast-preview": { - disabled: true - } - }); -</script> +{% include 'blog/partials/mathjax.html' %} {% endblock %} diff --git a/templates/blog/home.html b/templates/blog/home.html index e07440a4..eba8c4f9 100644 --- a/templates/blog/home.html +++ b/templates/blog/home.html @@ -15,8 +15,6 @@ <img src="{% static 'images/gifs/construction.gif' %}" style="width: 720px;"> </div> - - {% if announcements is not None %} <div id="announcements" class="mtctitem"> <h2><img src = "{% static 'images/gifs/update.gif' %}" style="height: 14px;"></h2> @@ -71,39 +69,7 @@ </div> {% endfor %} </div> -<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> -</script> -<script type="text/x-mathjax-config"> - MathJax.Hub.Register.StartupHook("End Jax",function () { - var BROWSER = MathJax.Hub.Browser; - - var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || - (BROWSER.isMSIE && BROWSER.hasMathPlayer) || - (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || - (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && - !BROWSER.versionAtLeast("14.0")); - - var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ - prefer: { - MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", - other:"HTML" - } - }); - - var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; - if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; - if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; - return MathJax.Hub.setRenderer(jax); - }); - MathJax.Hub.Config({ - "tex2jax": { - "inlineMath": [['$','$'], ['\\(','\\)']], - }, - "fast-preview": { - disabled: true - } - }); -</script> +{% include 'blog/partials/mathjax.html' %} {% endif %} {% endblock %} diff --git a/templates/blog/partials/mathjax.html b/templates/blog/partials/mathjax.html new file mode 100644 index 00000000..f580c4f5 --- /dev/null +++ b/templates/blog/partials/mathjax.html @@ -0,0 +1,39 @@ +{% load static %} +<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> +</script> +<script type="text/x-mathjax-config"> + MathJax.Hub.Register.StartupHook("End Jax",function () { + var BROWSER = MathJax.Hub.Browser; + + var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || + (BROWSER.isMSIE && BROWSER.hasMathPlayer) || + (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || + (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && + !BROWSER.versionAtLeast("14.0")); + + var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ + prefer: { + MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", + other:"HTML" + } + }); + + var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; + if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; + if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; + return MathJax.Hub.setRenderer(jax); + }); + MathJax.Hub.Config({ + "tex2jax": { + "inlineMath": [['$','$'], ['\\(','\\)']], + }, + "fast-preview": { + disabled: true + }, + showMathMenu: false, + showMathMenuMSIE: false, + errorSettings: { + message: ["[Math Processing Error]"] + } + }); +</script>
\ No newline at end of file diff --git a/templates/blog/post.html b/templates/blog/post.html index 80c7d625..2cd87644 100644 --- a/templates/blog/post.html +++ b/templates/blog/post.html @@ -15,7 +15,6 @@ <div id="article-body">{{ post.body | safe }}</div> </div> - <div id="comments" style="clear: both;" class="mtsbitem"> {% if comments %} <h2>Comments</h2> @@ -99,6 +98,11 @@ shortkey: <kbd>Ctrl or Cmd + K</kbd> <br><br> </li> + <li>Wrap text in double dollar sign ($$) to make it a math block and single dollar sign ($) to make it inline math. You can use LaTeX syntax. + <br> + e.g. <code>$$\frac{1}{2}$$</code> or <code>$\frac{1}{2}$</code> + <br><br> + </li> </ul> <p style="margin-top: -7px;">Any links, images or other markup will be kept as plain text. Also, free speech is good and all, but please keep it civil. Sufficient JavaScript support will be required to bind shortkeys. Please type the markup manually if you are on an older browser.</p> </div> @@ -109,39 +113,7 @@ <p><em>You must be logged in to leave a comment.</em></p> </div> {% endif %} -<script type="text/javascript" src="{% static 'js/MathJax/MathJax.js' %}?config=TeX-AMS-MML_HTMLorMML-full"> -</script> -<script type="text/x-mathjax-config"> - MathJax.Hub.Register.StartupHook("End Jax",function () { - var BROWSER = MathJax.Hub.Browser; - - var canUseMML = (BROWSER.isFirefox && BROWSER.versionAtLeast("1.5")) || - (BROWSER.isMSIE && BROWSER.hasMathPlayer) || - (BROWSER.isSafari && BROWSER.versionAtLeast("5.0")) || - (BROWSER.isOpera && BROWSER.versionAtLeast("9.52") && - !BROWSER.versionAtLeast("14.0")); - - var CONFIG = MathJax.Hub.CombineConfig("MMLorHTML",{ - prefer: { - MSIE:"MML", Firefox:"HTML", Opera:"HTML", Chrome:"HTML", Safari:"HTML", - other:"HTML" - } - }); - - var jax = CONFIG.prefer[BROWSER] || CONFIG.prefer.other; - if (jax === "HTML") jax = "HTML-CSS"; else if (jax === "MML") jax = "NativeMML"; - if (jax === "NativeMML" && !canUseMML) jax = CONFIG.prefer.other; - return MathJax.Hub.setRenderer(jax); - }); - MathJax.Hub.Config({ - "tex2jax": { - "inlineMath": [['$','$'], ['\\(','\\)']], - }, - "fast-preview": { - disabled: true - } - }); -</script> +{% include 'blog/partials/mathjax.html' %} <script> function editComment(id) { document.getElementById('comment-body-' + id).style.display = 'none'; |
