diff options
author | wushin <pasekei@gmail.com> | 2016-03-15 12:35:44 -0500 |
---|---|---|
committer | wushin <pasekei@gmail.com> | 2016-03-15 12:35:44 -0500 |
commit | 3e30b9f0f5d6cd4f587d186aa9ea6308bcfdd3cf (patch) | |
tree | 7e0304fbed4599f462513f2165a02feef692ada7 | |
parent | 3463a5c81917784c922a08f94adeef28cfdcbc5a (diff) | |
download | website-3e30b9f0f5d6cd4f587d186aa9ea6308bcfdd3cf.tar.gz website-3e30b9f0f5d6cd4f587d186aa9ea6308bcfdd3cf.tar.bz2 website-3e30b9f0f5d6cd4f587d186aa9ea6308bcfdd3cf.tar.xz website-3e30b9f0f5d6cd4f587d186aa9ea6308bcfdd3cf.zip |
Fix Spoilers Extension
-rw-r--r-- | extensions/Spoilers/.gitignore | 4 | ||||
-rw-r--r-- | extensions/Spoilers/README.md | 9 | ||||
l--------- | extensions/Spoilers/Spoilers | 1 | ||||
-rw-r--r-- | extensions/Spoilers/Spoilers.hooks.php | 18 | ||||
-rw-r--r-- | extensions/Spoilers/Spoilers.i18n.php | 1 | ||||
-rw-r--r-- | extensions/Spoilers/Spoilers.php | 41 | ||||
-rw-r--r-- | extensions/Spoilers/css/spoilers.css | 36 | ||||
-rw-r--r-- | extensions/Spoilers/extension.json | 43 | ||||
-rw-r--r-- | extensions/Spoilers/i18n/en.json | 2 | ||||
-rw-r--r-- | extensions/Spoilers/i18n/qqq.json | 8 | ||||
-rw-r--r-- | extensions/Spoilers/i18n/ru.json | 9 | ||||
-rw-r--r-- | extensions/Spoilers/js/spoilers.js | 25 |
12 files changed, 138 insertions, 59 deletions
diff --git a/extensions/Spoilers/.gitignore b/extensions/Spoilers/.gitignore new file mode 100644 index 0000000..506ca61 --- /dev/null +++ b/extensions/Spoilers/.gitignore @@ -0,0 +1,4 @@ +.DS_Store +.idea +*.sublime-project +*.sublime-workspace
\ No newline at end of file diff --git a/extensions/Spoilers/README.md b/extensions/Spoilers/README.md index f4b7826..4a29920 100644 --- a/extensions/Spoilers/README.md +++ b/extensions/Spoilers/README.md @@ -5,12 +5,19 @@ Mediawiki extension that allows for spoiler tags that will hide a block of text. Installation ------------ -To install this extension, add the follwoing lines to the end of the LocalSettings.php file: +To install this extension, add the following lines to the end of the LocalSettings.php file: ``` //Spoilers require("$IP/extensions/Spoilers/Spoilers.php"); ``` +Or, if you are using MediaWiki 1.25+ + +``` +//Spoilers +wfLoadExtension('Spoilers'); +``` + Usage Example --------------------- ``` diff --git a/extensions/Spoilers/Spoilers b/extensions/Spoilers/Spoilers deleted file mode 120000 index ab8bd0c..0000000 --- a/extensions/Spoilers/Spoilers +++ /dev/null @@ -1 +0,0 @@ -/usr/share/mediawiki-extensions/Spoilers
\ No newline at end of file diff --git a/extensions/Spoilers/Spoilers.hooks.php b/extensions/Spoilers/Spoilers.hooks.php index a2a596a..6558232 100644 --- a/extensions/Spoilers/Spoilers.hooks.php +++ b/extensions/Spoilers/Spoilers.hooks.php @@ -33,19 +33,19 @@ class Spoilers { * @return string HTML */ static public function parseSpoilerTag( $input, array $args, Parser $parser, PPFrame $frame ) { - $out = $parser->getOutput(); - $out->addModules( 'ext.spoilers' ); - $renderedInput = $parser->recursiveTagParse( $input ); - $output = "<div class='spoilers'> + $parser->getOutput()->addModules('ext.spoilers'); + $renderedInput = $parser->recursiveTagParse( $input, $frame ); + $showText = isset($args['show']) ? htmlentities( $args['show'], ENT_QUOTES) : wfMessage('spoilers_show_default' )->text(); + $hideText = isset($args['hide']) ? htmlentities( $args['hide'], ENT_QUOTES ) : wfMessage('spoilers_hide_default')->text(); + $output = "<p class='spoilers'> <div class='spoilers-button-container'> <span class='spoilers-button'> - <span class='spoilers-show'>" . ( $args['show'] ? htmlentities( $args['show'], ENT_QUOTES) : wfMessage('spoilers_show_default' )->text() ) . "</span> - <span class='spoilers-hide' style='display:none;'>" . ( $args['hide'] ? htmlentities( $args['hide'], ENT_QUOTES ) : wfMessage('spoilers_hide_default')->text() ) . "</span> + <span class='spoilers-show'>{$showText}</span> + <span class='spoilers-hide'>{$hideText}</span> </span> </div> - <div class='spoilers-body' style='display:none;'>{$renderedInput}</div> - </div>"; + <ul class='spoilers-body'>{$renderedInput}</ul> + </p>"; return $output; } } -?> diff --git a/extensions/Spoilers/Spoilers.i18n.php b/extensions/Spoilers/Spoilers.i18n.php index a5e1460..ceb6cc1 100644 --- a/extensions/Spoilers/Spoilers.i18n.php +++ b/extensions/Spoilers/Spoilers.i18n.php @@ -33,4 +33,3 @@ if ( !function_exists( 'wfJsonI18nShimefa4e861731a8843' ) ) { $GLOBALS['wgHooks']['LocalisationCacheRecache'][] = 'wfJsonI18nShimefa4e861731a8843'; } -?> diff --git a/extensions/Spoilers/Spoilers.php b/extensions/Spoilers/Spoilers.php index 247cfe4..1c8222b 100644 --- a/extensions/Spoilers/Spoilers.php +++ b/extensions/Spoilers/Spoilers.php @@ -8,36 +8,39 @@ * @package: Spoilers * @link: http://www.mediawiki.org/wiki/Extension:Spoilers */ - + +# Only run if included by MediaWiki +if ( !defined( 'MEDIAWIKI' ) ) die( 'Invalid entry point.' ); + /******************************************/ /* Credits */ /******************************************/ $wgExtensionCredits['specialpage'][] = array ( - 'path' => __FILE__, - 'name' => 'Spoilers', - 'author' => 'Tim Aldridge', - 'descriptionmsg' => 'spoilers_description', - 'version' => '1.1', - 'license-name' => 'LGPLv3' - ); + 'path' => __FILE__, + 'name' => 'Spoilers', + 'author' => 'Tim "Telshin" Aldridge', + 'descriptionmsg' => 'spoilers_description', + 'version' => '1.4', + 'license-name' => 'LGPLv3' +); /******************************************/ /* Language Strings, Page Aliases, Hooks */ /******************************************/ -$extDir = dirname( __FILE__ ); - $wgMessagesDirs['Spoilers'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['Spoilers'] = $extDir . "/Spoilers.i18n.php"; +$wgExtensionMessagesFiles['Spoilers'] = __DIR__ . "/Spoilers.i18n.php"; -$wgAutoloadClasses['Spoilers'] = $extDir . "/Spoilers.hooks.php"; +// Classes +$wgAutoloadClasses['Spoilers'] = __DIR__ . "/Spoilers.hooks.php"; +// Resources Modules $wgResourceModules['ext.spoilers'] = array ( - 'styles' => array( 'css/spoilers.css' ), - 'scripts' => array( 'js/spoilers.js' ), - 'localBasePath' => __DIR__, - 'remoteExtPath' => 'Spoilers', - 'dependencies' => array() - ); + 'styles' => array( 'css/spoilers.css' ), + 'scripts' => array( 'js/spoilers.js' ), + 'localBasePath' => __DIR__, + 'remoteExtPath' => 'Spoilers', + 'dependencies' => array() +); +// Hooks $wgHooks['ParserFirstCallInit'][] = "Spoilers::onParserFirstCallInit"; -?> diff --git a/extensions/Spoilers/css/spoilers.css b/extensions/Spoilers/css/spoilers.css index 10da4b1..1709ee0 100644 --- a/extensions/Spoilers/css/spoilers.css +++ b/extensions/Spoilers/css/spoilers.css @@ -1,25 +1,31 @@ -div.spoilers-body { - border: 1px dashed #000; - background-color: #EEE; - padding: 3px; +.spoilers-body { + display: none; } .spoilers-button-container { - padding: 1px 0; + padding: 1px 0; } .spoilers-button { - background-color: #AAA; - background-repeat: no-repeat; - background-image: -webkit-linear-gradient(top, #EEE, #AAA); - background-image: -moz-linear-gradient(top, #EEE, #AAA); - background-image: linear-gradient(to bottom, #EEE, #AAA); - border: 1px solid #999; - border-radius: 5px; - padding: 3px 10px; - transition: 0.1s background-position linear; + background: #AAA; + background: -moz-linear-gradient(top, #EEE, #AAA); + background: -webkit-gradient(left top, left bottom, color-stop(0%, #EEE), color-stop(100%, #AAA)); + background: -webkit-linear-gradient(top, #EEE, #AAA); + background: -o-linear-gradient(top, #EEE, #AAA); + background: -ms-liner-gradient(top, #EEE, #AAA); + background: linear-gradient(to bottom, #EEE, #AAA); + filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#EEE', endColorstr='#AAA',GradientType=0 ); + border: 1px solid #999; + border-radius: 5px; + padding: 3px 10px; + transition: 0.1s background-position linear; } .spoilers-button:hover { - background-position: 0 -6px; + background-position: 0 -6px; + cursor: pointer; +} + +.spoilers-hide { + display: none; } diff --git a/extensions/Spoilers/extension.json b/extensions/Spoilers/extension.json new file mode 100644 index 0000000..d005a7d --- /dev/null +++ b/extensions/Spoilers/extension.json @@ -0,0 +1,43 @@ +{ + "name": "Spoilers", + "version": "1.4", + "author": [ + "Tim \"Telshin\" Aldridge", + "Kris (cblair91)" + ], + "descriptionmsg": "spoilers_description", + "license-name": "LGPLv3", + "type": "specialpage", + "MessagesDirs": { + "Spoilers": [ + "i18n" + ] + }, + "ExtensionMessagesFiles": { + "Spoilers": "Spoilers.i18n.php" + }, + "AutoloadClasses": { + "Spoilers": "Spoilers.hooks.php" + }, + "ResourceModules": { + "ext.spoilers": { + "styles": [ + "css/spoilers.css" + ], + "scripts": [ + "js/spoilers.js" + ], + "dependencies": [] + } + }, + "ResourceFileModulePaths": { + "localBasePath": "/", + "remoteExtPath": "Spoilers" + }, + "Hooks": { + "ParserFirstCallInit": [ + "Spoilers::onParserFirstCallInit" + ] + }, + "manifest_version": 1 +} diff --git a/extensions/Spoilers/i18n/en.json b/extensions/Spoilers/i18n/en.json index 4d5c782..7811e68 100644 --- a/extensions/Spoilers/i18n/en.json +++ b/extensions/Spoilers/i18n/en.json @@ -6,4 +6,4 @@ "spoilers_description": "Spoiler Tag - <spoiler show=\"showMessage\" hide=\"hideMessage\">Spoiler Text</spoiler>", "spoilers_show_default": "Show Spoiler", "spoilers_hide_default": "Hide Spoiler" -} +}
\ No newline at end of file diff --git a/extensions/Spoilers/i18n/qqq.json b/extensions/Spoilers/i18n/qqq.json new file mode 100644 index 0000000..961c2a4 --- /dev/null +++ b/extensions/Spoilers/i18n/qqq.json @@ -0,0 +1,8 @@ +{ + "@metadata": { + "authors": ["Tim Aldridge"] + }, + "spoilers_description": "{{desc|what=extension|name=Spoilers|url=https://www.mediawiki.org/wiki/Extension:Spoilers}}", + "spoilers_show_default": "{{Identical|Show button default text}}", + "spoilers_hide_default": "{{Identical|Hide button default text}}" +} diff --git a/extensions/Spoilers/i18n/ru.json b/extensions/Spoilers/i18n/ru.json new file mode 100644 index 0000000..3ef21d4 --- /dev/null +++ b/extensions/Spoilers/i18n/ru.json @@ -0,0 +1,9 @@ +{ + "@metadata": { + "authors": ["Tim Aldridge"] + }, + "spoilers": "Spoilers", + "spoilers_description": "Тег спойлера - <spoiler show=\"showMessage\" hide=\"hideMessage\">Скрытый текст</spoiler>", + "spoilers_show_default": "Показать спойлер", + "spoilers_hide_default": "Скрыть спойлер" +} diff --git a/extensions/Spoilers/js/spoilers.js b/extensions/Spoilers/js/spoilers.js index b05bf86..fbe8cb8 100644 --- a/extensions/Spoilers/js/spoilers.js +++ b/extensions/Spoilers/js/spoilers.js @@ -1,12 +1,13 @@ -/** - * Created by Telshin on 10/22/13. - */ -$( '.spoilers-button' ).toggle( function() { - $( this ).parents( '.spoilers' ).find( '.spoilers-body' ).show(); - $( this ).children( '.spoilers-show' ).hide(); - $( this ).children( '.spoilers-hide' ).show(); -}, function() { - $( this ).parents( '.spoilers' ).find( '.spoilers-body' ).hide(); - $( this ).children( '.spoilers-show' ).show(); - $( this ).children( '.spoilers-hide' ).hide(); -}); +(function($) { + 'use strict'; + + function init() { + $('.spoilers-button').show(); + $('.spoilers-button').click(function() { + $(this).parents('.spoilers').children('.spoilers-body').toggle(); + $(this).children().toggle(); + }); + } + + $(init); +}(this.jQuery)); |