[mathjax] Add addon config
authorHypolite Petovan <mrpetovan@gmail.com>
Thu, 28 Jun 2018 03:17:57 +0000 (23:17 -0400)
committerHypolite Petovan <mrpetovan@gmail.com>
Tue, 10 Jul 2018 12:39:48 +0000 (08:39 -0400)
- Update mentions of .htconfig.php

mathjax/README.md
mathjax/config/mathjax.ini.php [new file with mode: 0644]
mathjax/mathjax.php

index 9647a98..7108639 100644 (file)
@@ -13,21 +13,23 @@ This addon for friendica includes the [MathJax][1] CDN to enable rendering of
 
 Configuration
 -------------
-All you need to do is provide friendica with the base URL of MathJax. This can
+All you need to do is provide Friendica with the base URL of MathJax. This can
 be either the URL of the CDN of MathJax or your own installation.
 
 In case you want to use the CDN you can try the following URL as a quick start
 
        http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML
 
-In case you don't want or can use the admin panel of firneidca you can activate
-the addon by adding _mathjax_ to the 
+In case you don't want or can use the admin panel of Friendica you can activate
+the addon by adding _mathjax_ to the
 
-       $a->config['system']['addon']
+       [system]
+       addon = ...,mathjax
 
-list in your .htconfig.php file and then providing the base URL after that
+list in your config/local.ini.php file and then providing the base URL after that
 
-        $a->config['mathjax']['baseurl'] = 'the URL to your MathJax installation';
+       [mathjax]
+       baseurl = [the URL to your MathJax installation];
 
 Usage
 =====
diff --git a/mathjax/config/mathjax.ini.php b/mathjax/config/mathjax.ini.php
new file mode 100644 (file)
index 0000000..d89ea69
--- /dev/null
@@ -0,0 +1,12 @@
+<?php return <<<INI
+
+; Warning: Don't change this file! It only holds the default config values for this addon.
+; Instead overwrite these config values in config/local.ini.php in your Friendica directory
+
+[mathjax]
+; baseurl (String)
+; The URL to your MathJax installation
+baseurl =
+
+INI;
+//Keep this line
\ No newline at end of file
index 91a6a06..c85068e 100644 (file)
@@ -13,6 +13,7 @@ use Friendica\Core\L10n;
 use Friendica\Core\PConfig;
 
 function mathjax_install() {
+       Addon::registerHook('load_config', 'addon/mathjax/mathjax.php', 'mathjax_load_config');
     Addon::registerHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header');
     Addon::registerHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings');
     Addon::registerHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post');
@@ -21,12 +22,18 @@ function mathjax_install() {
 }
 
 function mathjax_uninstall() {
+       Addon::unregisterHook('load_config', 'addon/mathjax/mathjax.php', 'mathjax_load_config');
     Addon::unregisterHook('page_header', 'addon/mathjax/mathjax.php', 'mathjax_page_header');
     Addon::unregisterHook('addon_settings', 'addon/mathjax/mathjax.php', 'mathjax_settings');
     Addon::unregisterHook('addon_settings_post', 'addon/mathjax/mathjax.php', 'mathjax_settings_post');
     Addon::unregisterHook('template_vars', 'addon/mathjax/mathjax.php', 'mathjax_template_vars');
 }
 
+function mathjax_load_config(\Friendica\App $a)
+{
+       $a->loadConfigFile(__DIR__. '/config/mathjax.ini.php');
+}
+
 function mathjax_template_vars($a, &$arr)
 {
     if (!array_key_exists('addon_hooks',$arr['vars']))