Jack Phoenix has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312269

Change subject: Version 1.2.2: JSON setup file + i18n files
......................................................................

Version 1.2.2: JSON setup file + i18n files

* PHP setup file and i18n file are no more
* Moved API help strings into the i18n file
* Fixed some documentation typos and tweaked doc format

Bug: T146238
Change-Id: I10cedd3710a7d9440613b0e810a7bcfc0dab031c
---
M Snippet.api.php
M Snippet.body.php
D Snippet.i18n.php
D Snippet.php
A extension.json
A i18n/de.json
A i18n/en.json
7 files changed, 57 insertions(+), 62 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Snippet 
refs/changes/69/312269/1

diff --git a/Snippet.api.php b/Snippet.api.php
index 208da71..fda9904 100644
--- a/Snippet.api.php
+++ b/Snippet.api.php
@@ -3,12 +3,11 @@
 class SnippetAPI extends ApiBase {
 
        public function execute() {
-               $set = $this->getMain()->getVal('set');
+               $set = $this->getMain()->getVal( 'set' );
 
                $title = Snippet::getTitle( $set );
 
                if ( $title ) {
-
                        $page = new WikiPage( $title );
                        $content = $page->getContent()->getNativeData();
 
@@ -25,28 +24,18 @@
                return true;
        }
 
-       public function getDescription() {
-               return 'An API action returning a snippet of a page from a 
search.';
-       }
-
        public function getAllowedParams() {
                return array(
-                               'set' => array (
-                                               ApiBase::PARAM_TYPE => 'string',
-                                               ApiBase::PARAM_REQUIRED => true
-                               ),
+                       'set' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
                );
        }
 
-       public function getParamDescription() {
+       public function getExamplesMessages() {
                return array(
-                               'set' => 'The set to search for',
-               );
-       }
-
-       public function getExamples() {
-               return array(
-                               
'api.php?action=snippet&set=7965-1:%20Millennium%20Falcon' => 'Get the 
description for 7965-1: Millennium Falcon'
+                       
'api.php?action=snippet&set=7965-1:%20Millennium%20Falcon' => 
'apihelp-snippet-example-1'
                );
        }
 }
\ No newline at end of file
diff --git a/Snippet.body.php b/Snippet.body.php
index 209bc07..da837d5 100644
--- a/Snippet.body.php
+++ b/Snippet.body.php
@@ -8,8 +8,8 @@
        /**
         * Parse wikitext into raw paragraph
         *
-        * @param String $text: text to proccess
-        * @return String: processed text
+        * @param string $text Text to process
+        * @return string Processed text
         */
        static function parseText( $text ) {
                global $wgSnippetMaxLength;
@@ -17,15 +17,15 @@
                $parts = explode( '==', $text );
                $text = $parts[0]; // remove anything after the first heading
 
-               $text = preg_replace( "/'''/", "", $text ); // remove bold
-               $text = preg_replace( "/''/", "", $text ); // remove italics
+               $text = preg_replace( "/'''/", '', $text ); // remove bold
+               $text = preg_replace( "/''/", '', $text ); // remove italics
 
                $text = preg_replace( '/\[\[([^|]+?)\]\]/', '$1', $text ); // 
remove non-piped links
                $text = preg_replace( '/\[\[[^|\n]+?\|([^|\n]+?)\]\]/', '$1', 
$text ); // remove piped links
 
                $text = preg_replace( '/<ref[^>]*>.+?<\/ref>/', '', $text ); // 
remove <ref> tags
 
-               $text = preg_replace( '/<.+?>/', '', $text ); // remove html 
elements
+               $text = preg_replace( '/<.+?>/', '', $text ); // remove HTML 
elements
 
                $text = preg_replace( '/{{[^{]+?}}/', '', $text ); // remove 
3rd layer templates
                $text = preg_replace( '/{{[^{]+?}}/', '', $text ); // remove 
2nd layer templates
@@ -45,11 +45,10 @@
        /**
         * Get the title object for the given search data, or false if none 
found
         *
-        * @param String $search: article to search for
-        * @return Title|boolean: title if found OR false if none found
+        * @param String $search Article to search for
+        * @return Title|bool Title if found OR false if none found
         */
        static function getTitle( $search ) {
-
                $engine = SearchEngine::create();
                $engine->setLimitOffset( 1, 0 );
                $results = $engine->searchTitle( $search );
diff --git a/Snippet.i18n.php b/Snippet.i18n.php
deleted file mode 100644
index eef90e5..0000000
--- a/Snippet.i18n.php
+++ /dev/null
@@ -1,17 +0,0 @@
-<?php
-
-$messages = array();
-
-/** English (English)
- * @author UltrasonicNXT
- */
-$messages['en'] = array(
-        'snippet-desc' => 'An API extension returning a snippet of a page from 
a search'
-);
-
-/** German (Deutsch)
- * @author ToaMeiko
- */
-$messages['de'] = array(
-        'snippet-desc' => 'Eine API-Erweiterung Rückkehr einen Ausschnitt 
einer Seite aus einem Such'
-);
diff --git a/Snippet.php b/Snippet.php
deleted file mode 100644
index 4dea3ec..0000000
--- a/Snippet.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-$wgExtensionCredits['api'][] = array(
-       'path' => __FILE__,
-       'name' => 'Snippet',
-       'descriptionmsg' => 'snippet-desc',
-       'version' => '1.2.1',
-       'author' => 'UltrasonicNXT/Adam Carter',
-       'url' => '//github.com/Brickimedia/Snippet',
-);
-
-$wgAutoloadClasses['SnippetAPI'] = __DIR__ . '/Snippet.api.php';
-$wgAutoloadClasses['Snippet'] = __DIR__ . '/Snippet.body.php';
-
-$wgAPIModules['snippet'] = 'SnippetAPI';
-
-$wgExtensionMessagesFiles['Snippet'] = __DIR__ . '/Snippet.i18n.php';
-
-$wgSnippetMaxLength = 600;
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..d7a00c9
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,24 @@
+{
+       "name": "Snippet",
+       "version": "1.2.2",
+       "author": "UltrasonicNXT/Adam Carter",
+       "url": "https://www.mediawiki.org/wiki/Extension:Snippet";,
+       "descriptionmsg": "snippet-desc",
+       "type": "api",
+       "APIModules": {
+               "snippet": "SnippetAPI"
+       },
+       "MessagesDirs": {
+               "Snippet": [
+                       "i18n"
+               ]
+       },
+       "AutoloadClasses": {
+               "SnippetAPI": "Snippet.api.php",
+               "Snippet": "Snippet.body.php"
+       },
+       "config": {
+               "SnippetMaxLength": 600
+       },
+       "manifest_version": 1
+}
diff --git a/i18n/de.json b/i18n/de.json
new file mode 100644
index 0000000..58b0c6d
--- /dev/null
+++ b/i18n/de.json
@@ -0,0 +1,8 @@
+{
+       "@metadata": {
+               "authors": [
+                       "ToaMeiko"
+               ]
+       },
+       "snippet-desc": "Eine API-Erweiterung Rückkehr einen Ausschnitt einer 
Seite aus einem Such"
+}
diff --git a/i18n/en.json b/i18n/en.json
new file mode 100644
index 0000000..49307d0
--- /dev/null
+++ b/i18n/en.json
@@ -0,0 +1,11 @@
+{
+       "@metadata": {
+               "authors": [
+                       "UltrasonicNXT"
+               ]
+       },
+       "apihelp-snippet-description": "An API action returning a snippet of a 
page from a search.",
+       "apihelp-snippet-param-set": "The set to search for",
+       "apihelp-snippet-example-1": "Get the description for 7965-1: 
Millennium Falcon",
+       "snippet-desc": "An API extension returning a snippet of a page from a 
search"
+}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I10cedd3710a7d9440613b0e810a7bcfc0dab031c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Snippet
Gerrit-Branch: master
Gerrit-Owner: Jack Phoenix <j...@countervandalism.net>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to