From 108894f196d1737222edd38488de23be44363b2c Mon Sep 17 00:00:00 2001 From: Tobias Diekershoff Date: Tue, 10 Apr 2018 19:22:32 +0200 Subject: [PATCH] fixing mathjax addon --- mathjax/mathjax.php | 24 +++++++++++++----------- mathjax/templates/admin.tpl | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php index d51857f3f..7d1a81340 100644 --- a/mathjax/mathjax.php +++ b/mathjax/mathjax.php @@ -2,10 +2,11 @@ /** * Name: MathJax * Description: Addon for Friendika to include MathJax (LaTeX math syntax) - * Version: 1.0 - * Author: Tobias Diekershoff + * Version: 1.1 + * Author: Tobias Diekershoff * License: 3-clause BSD license */ +use Friendica\App; use Friendica\Core\Addon; use Friendica\Core\Config; use Friendica\Core\L10n; @@ -25,7 +26,6 @@ function mathjax_uninstall() { function mathjax_settings_post ($a, $post) { if (! local_user()) return; - // don't check statusnet settings if statusnet submit button is not clicked if (!x($_POST,'mathjax-submit')) return; PConfig::set(local_user(),'mathjax','use',intval($_POST['mathjax_use'])); @@ -57,30 +57,32 @@ function mathjax_page_header($a, &$b) { // if the visitor of the page is not a local_user, use MathJax // otherwise check the users settings. $url = Config::get ('mathjax','baseurl'); - if(! $url) - $url = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'; + if(! $url) { + $url = 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'; + } if (! local_user()) { - $b .= ''; + $b .= ''; } else { $use = PConfig::get(local_user(),'mathjax','use'); if ($use) { - $b .= ''; + $b .= ''; } } } function mathjax_addon_admin_post (&$a) { - $baseurl = ((x($_POST, 'baseurl')) ? trim($_POST['baseurl']) : 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'); + $baseurl = ((x($_POST, 'mjbaseurl')) ? trim($_POST['mjbaseurl']) : 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'); Config::set('mathjax','baseurl',$baseurl); info(L10n::t('Settings updated.'). EOL); } -function mathjax_addon_admin (&$a, &$o) { +function mathjax_addon_admin (App $a, &$o) { $t = get_markup_template( "admin.tpl", "addon/mathjax/" ); + if (Config::get('mathjax','baseurl','') == '') { - Config::set('mathjax','baseurl','http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'); + Config::set('mathjax','baseurl','https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML'); } $o = replace_macros( $t, [ '$submit' => L10n::t('Save Settings'), - '$baseurl' => ['baseurl', L10n::t('MathJax Base URL'), Config::get('mathjax','baseurl' ), L10n::t('The URL for the javascript file that should be included to use MathJax. Can be either the MathJax CDN or another installation of MathJax.')], + '$mjbaseurl' => ['mjbaseurl', L10n::t('MathJax Base URL'), Config::get('mathjax','baseurl' ), L10n::t('The URL for the javascript file that should be included to use MathJax. Can be either the MathJax CDN or another installation of MathJax.'), 'required'] ]); } diff --git a/mathjax/templates/admin.tpl b/mathjax/templates/admin.tpl index f6ec03e0d..e4b893806 100644 --- a/mathjax/templates/admin.tpl +++ b/mathjax/templates/admin.tpl @@ -1,2 +1,2 @@ -{{include file="field_input.tpl" field=$baseurl}} +{{include file="field_input.tpl" field=$mjbaseurl}}