Robert Vogel has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344894 )

Change subject: Initial
......................................................................

Initial

Change-Id: I9b10e32bea691625034d23f9e14aea26f2d08434
---
A .gitignore
A composer.json
A extension.json
A i18n/de.json
A i18n/en.json
A i18n/qqq.json
A resources/ext.blueSpice.signHere.js
A resources/ext.blueSpice.signHere.less
A src/Hook/ParserFirstCallInit.php
A src/Tag/SignHere.php
10 files changed, 251 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceSignHere 
refs/changes/94/344894/1

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d37d322
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+node_modules/
+vendor
+composer.lock
\ No newline at end of file
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..9e0d332
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,16 @@
+{
+  "autoload" : {
+    "psr-4": {
+      "BS\\SignHere\\Tests\\" : "tests/phpunit",
+      "BS\\SignHere\\" : "src"
+    }
+  },
+  "require-dev": {
+    "jakub-onderka/php-parallel-lint": "0.9.2"
+  },
+  "scripts": {
+    "test": [
+      "parallel-lint . --exclude vendor"
+    ]
+  }
+}
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..a343d78
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,38 @@
+{
+       "name": "BlueSpiceSignHere",
+       "version": "2.27",
+       "license-name": "GPL-2.0+",
+       "author": [
+               "[http://www.hallowelt.com Hallo Welt! GmbH]"
+       ],
+       "url": "http://bluespice.com";,
+       "descriptionmsg": "bs-signhere-desc",
+       "type": "bluespice",
+       "MessagesDirs": {
+               "BlueSpiceSignHere": [ "i18n" ]
+       },
+       "Hooks": {
+               "ParserFirstCallInit": 
"BS\\SignHere\\Hook\\ParserFirstCallInit::handle"
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "resources",
+               "remoteExtPath": "BlueSpiceSignHere/resources"
+       },
+       "ResourceModules": {
+               "ext.blueSpice.signHere": {
+                       "scripts": [
+                               "ext.blueSpice.signHere.js"
+                       ],
+                       "messages" :[
+                               "bs-signhere-edit-summary"
+                       ]
+               },
+               "ext.blueSpice.signHere.styles": {
+                       "styles": [
+                               "ext.blueSpice.signHere.less"
+                       ]
+               }
+       },
+       "load_composer_autoloader": true,
+       "manifest_version": 1
+}
\ No newline at end of file
diff --git a/i18n/de.json b/i18n/de.json
new file mode 100644
index 0000000..58b7f64
--- /dev/null
+++ b/i18n/de.json
@@ -0,0 +1,11 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Robert Vogel <[email protected]>"
+               ]
+       },
+       "bs-signhere-desc": "Stellt ein Tag bereit um schnell eine Signatur auf 
einer Seite einzufügen",
+       "bs-signhere-signatures": "Unterschriften",
+       "bs-signhere-edit-summary": "Unterschrift hinzugefügt",
+       "bs-signhere-tooltip": "Hier klicken um oberhalb der Linie eine 
Unterschrift einzufügen"
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..f760890
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,11 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Robert Vogel <[email protected]>"
+               ]
+       },
+       "bs-signhere-desc": "Provides a tag to quickly add a signature to a 
page",
+       "bs-signhere-signatures": "Signatures",
+       "bs-signhere-edit-summary": "Added signature",
+       "bs-signhere-tooltip": "Click here to add your signature above the line"
+}
diff --git a/i18n/qqq.json b/i18n/qqq.json
new file mode 100644
index 0000000..c47dc85
--- /dev/null
+++ b/i18n/qqq.json
@@ -0,0 +1,11 @@
+{
+       "@metadata": {
+               "authors": [
+                       "Robert Vogel <[email protected]>"
+               ]
+       },
+       "bs-signhere-desc": 
"{{desc|name=BlueSpiceSignHere|url=https://www.mediawiki.org/wiki/Extension:BlueSpiceSignHere}}";,
+       "bs-signhere-signatures": "Label of the button that shows up on the 
wikipage",
+       "bs-signhere-edit-summary": "Text that is being stored together with 
the edit made by this extension",
+       "bs-signhere-tooltip": "Tool tip text for the button provided by the 
extension"
+}
diff --git a/resources/ext.blueSpice.signHere.js 
b/resources/ext.blueSpice.signHere.js
new file mode 100644
index 0000000..ebce038
--- /dev/null
+++ b/resources/ext.blueSpice.signHere.js
@@ -0,0 +1,44 @@
+(function( mw, $, d, undefined ){
+
+       function _sign( pageId, targetCount ) {
+               var count = -1;
+               var api = new mw.Api();
+               api.get({
+                       'action': 'query',
+                       'pageids': pageId,
+                       'prop': 'revisions',
+                       'rvprop': 'content',
+                       'indexpageids' : ''
+               })
+               .done(function( resp, jqXHR ){
+                       var pageId = resp.query.pageids[0];
+                       var content = 
resp.query.pages[pageId].revisions[0]['*'];
+                       var newContent = content.replace( /<(bs:)?signhere/g, 
function( fullMatch, group, pos, fullString ) {
+                               count++;
+
+                               if( targetCount !== count ) {
+                                       return fullMatch;
+                               }
+
+                               return "--~~~~\n\n" +  fullMatch;
+                       });
+
+                       var editPageAPI = new mw.Api();
+                       editPageAPI.postWithToken( 'edit', {
+                               'action': 'edit',
+                               'pageid': pageId,
+                               'text': newContent,
+                               'summary': mw.message( 
'bs-signhere-edit-summary' ).plain()
+                       })
+                       .done(function( resp, jqXHR ){
+                               window.location.reload();
+                       });
+               });
+       }
+
+       $(d).on( 'click', '.bs-signhere',  function() {
+               $(this).find( '.bs-signhere-icon' ).addClass( 
'bs-signhere-spin' );
+               _sign( mw.config.get( 'wgArticleId' ), $(this).data( 
'bs-counter' ) );
+       } );
+
+})( mediaWiki, jQuery, document );
\ No newline at end of file
diff --git a/resources/ext.blueSpice.signHere.less 
b/resources/ext.blueSpice.signHere.less
new file mode 100644
index 0000000..43bc4ff
--- /dev/null
+++ b/resources/ext.blueSpice.signHere.less
@@ -0,0 +1,61 @@
+.bs-signhere {
+       border-top: 1px dashed #555;
+       padding: 0.1em;
+       margin: 0.5em 0;
+       font-size: 80%;
+       text-align: center;
+       font-style: oblique;
+       cursor: pointer;
+       &:hover {
+               color: @bs-color-secondary;
+               border-color: @bs-color-secondary;
+       }
+}
+
+.bs-signhere-icon {
+       display: inline-block;
+       margin-right: 0.1em;
+
+       &:before {
+               font-family: 'icomoon';
+               content: '\e907';
+               font-size: 120%;
+               font-style: normal;
+       }
+}
+
+@-moz-keyframes bs-signhere-spin-anim {
+       from { -moz-transform: rotate( 0deg ); }
+       to { -moz-transform: rotate( 360deg ); }
+}
+
+@-webkit-keyframes bs-signhere-spin-anim {
+       from { -webkit-transform: rotate( 0deg ); }
+       to { -webkit-transform: rotate( 360deg ); }
+}
+
+@-moz-keyframes bs-signhere-spin-anim {
+       from { -moz-transform: rotate( 0deg ); }
+       to { -moz-transform: rotate( 360deg ); }
+}
+
+@-o-keyframes bs-signhere-spin-anim {
+       from { -o-transform: rotate( 0deg ); }
+       to { -o-transform: rotate( 360deg ); }
+}
+
+@keyframes bs-signhere-spin-anim {
+       from { transform: rotate( 0deg ); }
+       to { transform: rotate( 360deg ); }
+}
+
+.bs-signhere-spin {
+       -webkit-animation: bs-signhere-spin-anim 2s infinite linear;
+       -moz-animation: bs-signhere-spin-anim 2s infinite linear;
+       -o-animation: bs-signhere-spin-anim 2s infinite linear;
+       animation: bs-signhere-spin-anim 2s infinite linear;
+       &:before {
+               font-family: 'fontawesome';
+               content: '\f1ce';
+       }
+}
\ No newline at end of file
diff --git a/src/Hook/ParserFirstCallInit.php b/src/Hook/ParserFirstCallInit.php
new file mode 100644
index 0000000..677e4d4
--- /dev/null
+++ b/src/Hook/ParserFirstCallInit.php
@@ -0,0 +1,18 @@
+<?php
+
+namespace BS\SignHere\Hook;
+
+class ParserFirstCallInit {
+
+       /**
+        *
+        * @param \Parser $parser
+        * @return boolean
+        */
+       public static function handle( &$parser ) {
+               $signHereTag = new \BS\SignHere\Tag\SignHere();
+               $parser->setHook( 'signhere', [ $signHereTag, 'render' ] );
+               $parser->setHook( 'bs:signhere', [ $signHereTag, 'render' ] );
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/src/Tag/SignHere.php b/src/Tag/SignHere.php
new file mode 100644
index 0000000..2e0ce9b
--- /dev/null
+++ b/src/Tag/SignHere.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace BS\SignHere\Tag;
+
+class SignHere {
+       protected static $counter = 0;
+
+       /**
+        *
+        * @param string $input
+        * @param array $args
+        * @param \Parser $parser
+        * @param \PPFrame $frame
+        * @return string
+        */
+       public function render( $input, $args, $parser, $frame ) {
+               $parser->getOutput()->addModuleStyles( 
'ext.blueSpice.signHere.styles' );
+               $parser->getOutput()->addModules( 'ext.blueSpice.signHere' );
+
+               $html = \Html::rawElement(
+                       'div',
+                       [
+                               'class' => 'bs-signhere',
+                               'title' => wfMessage( 'bs-signhere-tooltip' 
)->plain(),
+                               'data-bs-counter' => self::$counter++
+                       ],
+                       \Html::element(
+                               'i',
+                               [
+                                       'class' => 'bs-signhere-icon'
+                               ]
+                       ) . wfMessage( 'bs-signhere-signatures' )->escaped()
+               );
+
+               return $html;
+       }
+}
+

-- 
To view, visit https://gerrit.wikimedia.org/r/344894
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9b10e32bea691625034d23f9e14aea26f2d08434
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceSignHere
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to