From b233b1fe72b706279d9c7cebc49b78357c3cad4c Mon Sep 17 00:00:00 2001 From: David Stone Date: Tue, 22 Sep 2015 09:27:15 -0600 Subject: [PATCH 1/4] Remove font tags from some namespaces on save #243 --- lib/plugins/codecleanup/README | 27 ++++++++++++++ lib/plugins/codecleanup/action.php | 49 +++++++++++++++++++++++++ lib/plugins/codecleanup/plugin.info.txt | 7 ++++ 3 files changed, 83 insertions(+) create mode 100644 lib/plugins/codecleanup/README create mode 100644 lib/plugins/codecleanup/action.php create mode 100644 lib/plugins/codecleanup/plugin.info.txt diff --git a/lib/plugins/codecleanup/README b/lib/plugins/codecleanup/README new file mode 100644 index 000000000..fbdc05291 --- /dev/null +++ b/lib/plugins/codecleanup/README @@ -0,0 +1,27 @@ +gitcommit Plugin for DokuWiki + +Adds and commits the file just changed + +All documentation for this plugin can be found at +http://www.distantshores.org + +If you install this plugin manually, make sure it is installed in +lib/plugins/gitcommit/ - if the folder is called different it +will not work! + +Please refer to http://www.dokuwiki.org/plugins for additional info +on how to install plugins in DokuWiki. + +---- +Copyright (C) Dave Pearce + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; version 2 of the License + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +See the COPYING file in your DokuWiki folder for details diff --git a/lib/plugins/codecleanup/action.php b/lib/plugins/codecleanup/action.php new file mode 100644 index 000000000..b11857e87 --- /dev/null +++ b/lib/plugins/codecleanup/action.php @@ -0,0 +1,49 @@ + + */ + +/** + * Class action_plugin_changes + */ +class action_plugin_codecleanup extends DokuWiki_Action_Plugin { + + /** + * Registers a callback function for a given event + * + * @param Doku_Event_Handler $controller DokuWiki's event controller object + * @return void + */ + public function register(Doku_Event_Handler $controller) { + + $controller->register_hook('IO_WIKIPAGE_WRITE', 'BEFORE', $this, 'cleanupCode'); + } + + /** + * [Custom event handler which performs action] + * + * @param Doku_Event $event event object by reference + * @param mixed $param [the parameters passed as fifth argument to register_hook() when this + * handler was registered] + * @return void + */ + public function cleanupCode(Doku_Event &$event, $param) { + + if($this->startsWith($event->data[1],'en:bible:notes') || + $this->startsWith($event->data[1],'en:obe') || + $this->startsWith($event->data[1],'playground')) { + + $event->data[0][1] = preg_replace('/<\/?font[^>]*>/', '', $event->data[0][1]); + } + + } + + private function startsWith($haystack, $needle) { + return (substr($haystack, 0, strlen($needle)) === $needle); + } + + +} diff --git a/lib/plugins/codecleanup/plugin.info.txt b/lib/plugins/codecleanup/plugin.info.txt new file mode 100644 index 000000000..1acc42541 --- /dev/null +++ b/lib/plugins/codecleanup/plugin.info.txt @@ -0,0 +1,7 @@ +base codecleanup +author David Stone +email david@nnucomputerwhiz.com +date 2015-09-21 +name Code Cleanup Plugin +desc Remove font tags and other junk that can occur on copy and paste +url http://www.distantshores.org From 579bb271f1c3909c6e01d1ce9b7b67b3607167e3 Mon Sep 17 00:00:00 2001 From: David Stone Date: Tue, 22 Sep 2015 09:48:49 -0600 Subject: [PATCH 2/4] cleanup code --- lib/plugins/codecleanup/README | 23 +++-------------------- lib/plugins/codecleanup/action.php | 8 +++++++- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/lib/plugins/codecleanup/README b/lib/plugins/codecleanup/README index fbdc05291..8be6aee1c 100644 --- a/lib/plugins/codecleanup/README +++ b/lib/plugins/codecleanup/README @@ -1,27 +1,10 @@ -gitcommit Plugin for DokuWiki +code cleanup Plugin for DokuWiki -Adds and commits the file just changed - -All documentation for this plugin can be found at -http://www.distantshores.org +Removes font tags from pages that shouldn't use them If you install this plugin manually, make sure it is installed in -lib/plugins/gitcommit/ - if the folder is called different it +lib/plugins/codecleanup/ - if the folder is called different it will not work! Please refer to http://www.dokuwiki.org/plugins for additional info on how to install plugins in DokuWiki. - ----- -Copyright (C) Dave Pearce - -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; version 2 of the License - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -See the COPYING file in your DokuWiki folder for details diff --git a/lib/plugins/codecleanup/action.php b/lib/plugins/codecleanup/action.php index b11857e87..07735b843 100644 --- a/lib/plugins/codecleanup/action.php +++ b/lib/plugins/codecleanup/action.php @@ -7,7 +7,7 @@ */ /** - * Class action_plugin_changes + * Class action_plugin_codecleanup */ class action_plugin_codecleanup extends DokuWiki_Action_Plugin { @@ -41,6 +41,12 @@ public function cleanupCode(Doku_Event &$event, $param) { } + /** + * + * @param string $haystack + * @param string $needle + * @return string + */ private function startsWith($haystack, $needle) { return (substr($haystack, 0, strlen($needle)) === $needle); } From 4b587743ffb43fc1983cc57c366bbf0626f3f68a Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 23 Sep 2015 10:59:55 -0600 Subject: [PATCH 3/4] Use new tag plugin fork to allow searching multiple namespaces https://github.com/unfoldingWord-dev/Door43/issues/63 --- .gitmodules | 2 +- lib/plugins/tag | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 0a49731d0..16f729e08 100644 --- a/.gitmodules +++ b/.gitmodules @@ -90,7 +90,7 @@ url = https://github.com/splitbrain/dokuwiki-plugin-swiftmail [submodule "lib/plugins/tag"] path = lib/plugins/tag - url = https://github.com/dokufreaks/plugin-tag + url = https://github.com/superdav42/plugin-tag [submodule "lib/plugins/captcha"] path = lib/plugins/captcha url = https://github.com/splitbrain/dokuwiki-plugin-captcha diff --git a/lib/plugins/tag b/lib/plugins/tag index d57417446..9f440dc27 160000 --- a/lib/plugins/tag +++ b/lib/plugins/tag @@ -1 +1 @@ -Subproject commit d574174463fd3ed89718ac117333e9587e770cfa +Subproject commit 9f440dc273cada4a1285d1dee4db87055fb77ca0 From b6ea1ec582f300ddd9cc24b6ab8a3b9a3e6c325c Mon Sep 17 00:00:00 2001 From: David Stone Date: Wed, 23 Sep 2015 11:10:27 -0600 Subject: [PATCH 4/4] remove font tags everywhere --- lib/plugins/codecleanup/action.php | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/lib/plugins/codecleanup/action.php b/lib/plugins/codecleanup/action.php index 07735b843..d6afcb9d1 100644 --- a/lib/plugins/codecleanup/action.php +++ b/lib/plugins/codecleanup/action.php @@ -32,13 +32,8 @@ public function register(Doku_Event_Handler $controller) { */ public function cleanupCode(Doku_Event &$event, $param) { - if($this->startsWith($event->data[1],'en:bible:notes') || - $this->startsWith($event->data[1],'en:obe') || - $this->startsWith($event->data[1],'playground')) { - - $event->data[0][1] = preg_replace('/<\/?font[^>]*>/', '', $event->data[0][1]); - } - + $event->data[0][1] = preg_replace('/<\/?font[^>]*>/', '', $event->data[0][1]); + } /**