1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-24 05:03:00 +00:00

Fix a bunch of bugs with the new interwiki module

This commit is contained in:
Starbeamrainbowlabs 2019-01-05 21:28:47 +00:00
parent fafd5f6f03
commit 3592a132e9
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
6 changed files with 14 additions and 11 deletions

View file

@ -41,7 +41,7 @@ $guiConfig = <<<'GUICONFIG'
"anonedits": { "type": "checkbox", "description": "Whether users who aren't logged in are allowed to edit your wiki.", "default": false }, "anonedits": { "type": "checkbox", "description": "Whether users who aren't logged in are allowed to edit your wiki.", "default": false },
"maxpagesize": { "type": "number", "description": "The maximum page size in characters.", "default": 135000 }, "maxpagesize": { "type": "number", "description": "The maximum page size in characters.", "default": 135000 },
"parser": { "type": "text", "description": "The parser to use when rendering pages. Defaults to an extended version of parsedown (http://parsedown.org/)", "default": "parsedown" }, "parser": { "type": "text", "description": "The parser to use when rendering pages. Defaults to an extended version of parsedown (http://parsedown.org/)", "default": "parsedown" },
"interwiki_index_location": { "type": "url", "description": "The location to find the interwiki wiki definition file, which contains a list of wikis along with their names, prefixes, and root urls. May be a URL, or simply a file path - as it's passed to file_get_contents(). If left blank, interwiki link parsing is disabled.", "default": null }, "interwiki_index_location": { "type": "text", "description": "The location to find the interwiki wiki definition file, which contains a list of wikis along with their names, prefixes, and root urls. May be a URL, or simply a file path - as it's passed to file_get_contents(). If left blank, interwiki link parsing is disabled.", "default": null },
"clean_raw_html": { "type": "checkbox", "description": "Whether page sources should be cleaned of HTML before rendering. It is STRONGLY recommended that you keep this option turned on.", "default": true}, "clean_raw_html": { "type": "checkbox", "description": "Whether page sources should be cleaned of HTML before rendering. It is STRONGLY recommended that you keep this option turned on.", "default": true},
"enable_math_rendering": { "type": "checkbox", "description": "Whether to enable client side rendering of mathematical expressions with MathJax (https://www.mathjax.org/). Math expressions should be enclosed inside of dollar signs ($). Turn off if you don't use it.", "default": true}, "enable_math_rendering": { "type": "checkbox", "description": "Whether to enable client side rendering of mathematical expressions with MathJax (https://www.mathjax.org/). Math expressions should be enclosed inside of dollar signs ($). Turn off if you don't use it.", "default": true},
"users": { "type": "usertable", "description": "An array of usernames and passwords - passwords should be hashed with password_hash() (the hash action can help here)", "default": { "users": { "type": "usertable", "description": "An array of usernames and passwords - passwords should be hashed with password_hash() (the hash action can help here)", "default": {
@ -407,7 +407,7 @@ if($settings->sessionprefix == "auto")
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
/** The version of Pepperminty Wiki currently running. */ /** The version of Pepperminty Wiki currently running. */
$version = "v0.18-dev"; $version = "v0.18-dev";
$commit = "3cb1f49798633c4fadb7a0564edc7669d454c703"; $commit = "fafd5f6f0341ca9b0d57d0dcee20f9247d339891";
/// Environment /// /// Environment ///
/** Holds information about the current request environment. */ /** Holds information about the current request environment. */
$env = new stdClass(); $env = new stdClass();
@ -3556,7 +3556,7 @@ register_module([
"description" => "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.", "description" => "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.",
"id" => "feature-interwiki-links", "id" => "feature-interwiki-links",
"code" => function() { "code" => function() {
global $settings; global $env, $settings, $paths;
if(!empty($settings->interwiki_index_location)) { if(!empty($settings->interwiki_index_location)) {
// Generate the interwiki index cache file if it doesn't exist already // Generate the interwiki index cache file if it doesn't exist already
// NOTE: If you want to update the cache file, just delete it & it'll get regenerated automagically :-) // NOTE: If you want to update the cache file, just delete it & it'll get regenerated automagically :-)
@ -3577,6 +3577,8 @@ register_module([
* nothing. * nothing.
*/ */
function interwiki_index_update() { function interwiki_index_update() {
global $env, $settings, $paths;
if(empty($settings->interwiki_index_location)) if(empty($settings->interwiki_index_location))
return; return;
@ -3592,7 +3594,7 @@ function interwiki_index_update() {
$interwiki_def->prefix = $interwiki_data[1]; $interwiki_def->prefix = $interwiki_data[1];
$interwiki_def->root_url = $interwiki_data[2]; $interwiki_def->root_url = $interwiki_data[2];
$env->interwiki_index->$prefix = $interwiki_def; $env->interwiki_index->{$interwiki_def->prefix} = $interwiki_def;
} }
file_put_contents($paths->interwiki_index, json_encode($env->interwiki_index, JSON_PRETTY_PRINT)); file_put_contents($paths->interwiki_index, json_encode($env->interwiki_index, JSON_PRETTY_PRINT));

View file

@ -16,7 +16,7 @@ The CSV file format is best explained with an example:
Name,Prefix,Root URL Name,Prefix,Root URL
Another Wiki,another_wiki,https://wiki.example.com/?page=%s Another Wiki,another_wiki,https://wiki.example.com/?page=%s
Tree Field Guide,trees,https://trees.bobsrockets.io/wiki/%s Tree Field Guide,trees,https://trees.bobsrockets.io/wiki/%s
History Wiki,history,https://history.sanssatellites.co.uk/#%s History Wiki,history,https://history.seanssatellites.co.uk/#%s
Wiki Display Name,internal link prefix,url with %s in place of page name Wiki Display Name,internal link prefix,url with %s in place of page name
Apt Link,apt,apt://%s Apt Link,apt,apt://%s
``` ```

View file

@ -86,7 +86,7 @@
"author": "Starbeamrainbowlabs", "author": "Starbeamrainbowlabs",
"description": "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.", "description": "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.",
"id": "feature-interwiki-links", "id": "feature-interwiki-links",
"lastupdate": 1546710490, "lastupdate": 1546721931,
"optional": false "optional": false
}, },
{ {
@ -284,7 +284,7 @@
"author": "Emanuil Rusev & Starbeamrainbowlabs", "author": "Emanuil Rusev & Starbeamrainbowlabs",
"description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds some weight to your installation, and also *requires* write access to the disk on first load.",
"id": "parser-parsedown", "id": "parser-parsedown",
"lastupdate": 1546710932, "lastupdate": 1546710994,
"optional": false "optional": false
} }
] ]

View file

@ -6,7 +6,7 @@ register_module([
"description" => "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.", "description" => "Adds interwiki link support. Set the interwiki_index_location setting at an index file to activate support.",
"id" => "feature-interwiki-links", "id" => "feature-interwiki-links",
"code" => function() { "code" => function() {
global $settings; global $env, $settings, $paths;
if(!empty($settings->interwiki_index_location)) { if(!empty($settings->interwiki_index_location)) {
// Generate the interwiki index cache file if it doesn't exist already // Generate the interwiki index cache file if it doesn't exist already
// NOTE: If you want to update the cache file, just delete it & it'll get regenerated automagically :-) // NOTE: If you want to update the cache file, just delete it & it'll get regenerated automagically :-)
@ -27,6 +27,8 @@ register_module([
* nothing. * nothing.
*/ */
function interwiki_index_update() { function interwiki_index_update() {
global $env, $settings, $paths;
if(empty($settings->interwiki_index_location)) if(empty($settings->interwiki_index_location))
return; return;
@ -42,7 +44,7 @@ function interwiki_index_update() {
$interwiki_def->prefix = $interwiki_data[1]; $interwiki_def->prefix = $interwiki_data[1];
$interwiki_def->root_url = $interwiki_data[2]; $interwiki_def->root_url = $interwiki_data[2];
$env->interwiki_index->$prefix = $interwiki_def; $env->interwiki_index->{$interwiki_def->prefix} = $interwiki_def;
} }
file_put_contents($paths->interwiki_index, json_encode($env->interwiki_index, JSON_PRETTY_PRINT)); file_put_contents($paths->interwiki_index, json_encode($env->interwiki_index, JSON_PRETTY_PRINT));

View file

@ -477,7 +477,6 @@ class PeppermintParsedown extends ParsedownExtra
} }
// 3: Page name auto-correction // 3: Page name auto-correction
// ------------------------------- // -------------------------------
$is_interwiki_link = module_exists("feature-interwiki-links") && is_interwiki_link($link_page); $is_interwiki_link = module_exists("feature-interwiki-links") && is_interwiki_link($link_page);

View file

@ -18,7 +18,7 @@
"anonedits": { "type": "checkbox", "description": "Whether users who aren't logged in are allowed to edit your wiki.", "default": false }, "anonedits": { "type": "checkbox", "description": "Whether users who aren't logged in are allowed to edit your wiki.", "default": false },
"maxpagesize": { "type": "number", "description": "The maximum page size in characters.", "default": 135000 }, "maxpagesize": { "type": "number", "description": "The maximum page size in characters.", "default": 135000 },
"parser": { "type": "text", "description": "The parser to use when rendering pages. Defaults to an extended version of parsedown (http://parsedown.org/)", "default": "parsedown" }, "parser": { "type": "text", "description": "The parser to use when rendering pages. Defaults to an extended version of parsedown (http://parsedown.org/)", "default": "parsedown" },
"interwiki_index_location": { "type": "url", "description": "The location to find the interwiki wiki definition file, which contains a list of wikis along with their names, prefixes, and root urls. May be a URL, or simply a file path - as it's passed to file_get_contents(). If left blank, interwiki link parsing is disabled.", "default": null }, "interwiki_index_location": { "type": "text", "description": "The location to find the interwiki wiki definition file, which contains a list of wikis along with their names, prefixes, and root urls. May be a URL, or simply a file path - as it's passed to file_get_contents(). If left blank, interwiki link parsing is disabled.", "default": null },
"clean_raw_html": { "type": "checkbox", "description": "Whether page sources should be cleaned of HTML before rendering. It is STRONGLY recommended that you keep this option turned on.", "default": true}, "clean_raw_html": { "type": "checkbox", "description": "Whether page sources should be cleaned of HTML before rendering. It is STRONGLY recommended that you keep this option turned on.", "default": true},
"enable_math_rendering": { "type": "checkbox", "description": "Whether to enable client side rendering of mathematical expressions with MathJax (https://www.mathjax.org/). Math expressions should be enclosed inside of dollar signs ($). Turn off if you don't use it.", "default": true}, "enable_math_rendering": { "type": "checkbox", "description": "Whether to enable client side rendering of mathematical expressions with MathJax (https://www.mathjax.org/). Math expressions should be enclosed inside of dollar signs ($). Turn off if you don't use it.", "default": true},
"users": { "type": "usertable", "description": "An array of usernames and passwords - passwords should be hashed with password_hash() (the hash action can help here)", "default": { "users": { "type": "usertable", "description": "An array of usernames and passwords - passwords should be hashed with password_hash() (the hash action can help here)", "default": {