diff --git a/mathjax/README b/mathjax/README new file mode 100644 index 00000000..023e1c89 --- /dev/null +++ b/mathjax/README @@ -0,0 +1,31 @@ +Addon for Friendika to include MathJax (LaTeX math syntax) + +This addon lets your users use LaTeX to type mathematical formulas +within their posts. MathJax takes care about the best method for the +browser to display the formula and provides compatibility to 99% +of the modern browsers. + +You can either use the MathJax CDN online, thus loading the required javascript +libraries from the MathJax cloud, or use a local installation of MathJax. +Please see the plugin settings in the admin panel for configuration possibles. +If you don't set up a local MathJax instance, leave the configuration untouched +it will fall back to the MathJax cloud as default value. + +If you don't use the admin panel add mathjax to the list of active addons + +$a->config['system']['addon'] = [..., mathjax, ...] + +To select the source of the included javascript libraries add a line + +$a->config['mathjax']['baseurl'] = 'the URL to your MathJax installation'; + +to your .htconfig.php file. If this line is not there, the addon assumes that +you want to use the MathJax cloud (CDN). + +Please note that your usage of the CDN is governed by the "MathJax CDN Terms of +Service" see http://www.mathjax.org/download/mathjax-cdn-terms-of-service/ + +Author: Tobias Diekershoff + http://diekershoff.homeunix.net/friendika/profile/tobias + email: tobias.diekershoff@gmx.net + diff --git a/mathjax/admin.tpl b/mathjax/admin.tpl new file mode 100644 index 00000000..1c723cdd --- /dev/null +++ b/mathjax/admin.tpl @@ -0,0 +1,2 @@ +{{ inc field_input.tpl with $field=$baseurl }}{{endinc }} +
diff --git a/mathjax/mathjax.php b/mathjax/mathjax.php new file mode 100644 index 00000000..69df4225 --- /dev/null +++ b/mathjax/mathjax.php @@ -0,0 +1,74 @@ + + * License: 3-clause BSD license + */ + +function mathjax_install() { + register_hook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); + register_hook('plugin_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings'); + register_hook('plugin_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); + logger('installed js_math plugin'); +} +function mathjax_uninstall() { + unregister_hook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header'); + unregister_hook('plugin_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings'); + unregister_hook('plugin_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post'); +} +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; + set_pconfig(local_user(),'mathjax','use',intval($_POST['mathjax_use'])); +} +function mathjax_settings (&$a, &$s) { + if (! local_user()) + return; + $use = get_pconfig(local_user(),'mathjax','use'); + $usetext = (($use) ? ' checked="checked" ' : ''); + $s .= ''.t('The MathJax addon renders mathematical formulae written using the LaTeX syntax surrounded by the usual $$ or an eqnarray block in the postings of your wall,network tab and private mail.').'
'; + $s .= ''; + $s .= ''; + $s .= ''; + + $s .= ''; + $s .= '