jenkins-bot has submitted this change and it was merged.
Change subject: RSSFeeder: Ajax2api
......................................................................
RSSFeeder: Ajax2api
RSSFeeder now uses task api instead of ajax method.
Patch Set 2: Implemented CR by pwirth
Patch Set 3: Implemented CR by Robert Vogel
Change-Id: I097a643dd296a982af5d4e8a48d8fb2eaddd4b5f
---
M RSSFeeder/RSSFeeder.setup.php
M RSSFeeder/i18n/en.json
M RSSFeeder/i18n/qqq.json
A RSSFeeder/includes/api/BSApiTasksRSSFeeder.php
M RSSFeeder/resources/BS.RSSFeeder/RSSPortlet.js
5 files changed, 131 insertions(+), 23 deletions(-)
Approvals:
Robert Vogel: Looks good to me, approved
Raimond Spekking: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/RSSFeeder/RSSFeeder.setup.php b/RSSFeeder/RSSFeeder.setup.php
index f0f4187..8f7306d 100644
--- a/RSSFeeder/RSSFeeder.setup.php
+++ b/RSSFeeder/RSSFeeder.setup.php
@@ -11,10 +11,11 @@
$wgAutoloadClasses['SpecialRSSFeeder'] = __DIR__ .
'/includes/specials/SpecialRSSFeeder.class.php';
$wgAutoloadClasses['RSSCreator'] = __DIR__ . '/includes/RSSCreator.class.php';
$wgAutoloadClasses['RSSItemCreator'] = __DIR__ .
'/includes/RSSCreator.class.php';
+$wgAutoloadClasses['BSApiTasksRSSFeeder'] = __DIR__ .
'/includes/api/BSApiTasksRSSFeeder.php';
$wgSpecialPages['RSSFeeder'] = 'SpecialRSSFeeder';
-$wgAjaxExportList[] = 'RSSFeeder::getRSS';
+$wgAPIModules['bs-rssfeeder-tasks'] = 'BSApiTasksRSSFeeder';
$wgResourceModules['ext.bluespice.rssFeeder'] = array(
'styles' => 'bluespice.rssFeeder.css',
diff --git a/RSSFeeder/i18n/en.json b/RSSFeeder/i18n/en.json
index 29f78e7..81e644e 100644
--- a/RSSFeeder/i18n/en.json
+++ b/RSSFeeder/i18n/en.json
@@ -6,11 +6,13 @@
},
"bs-rssfeeder-desc": "An extension to output valid RSS for every
extension, which has a buildRss-function",
"rssfeeder": "RSS feeder",
+ "apihelp-bs-rssfeeder-tasks-description": "Provides common tasks for
the RSSFeeder",
"bs-rssfeeder-pagetext": "You can subscribe to the following RSS
feeds:",
"bs-rssfeeder-recent-changes": "Recent changes",
"bs-rssfeeder-pages": "Page",
"bs-rssfeeder-submit": "Show",
"bs-rssfeeder-rss": "RSS feed",
"bs-rssfeeder-rss-desc": "Create your own RSS feed",
- "bs-extjs-rssfeeder-rss-title": "RSS URL"
+ "bs-extjs-rssfeeder-rss-title": "RSS URL",
+ "bs-rssfeeder-invalid-url": "Please provide a valid URL."
}
diff --git a/RSSFeeder/i18n/qqq.json b/RSSFeeder/i18n/qqq.json
index cd8a49f..a370e3c 100644
--- a/RSSFeeder/i18n/qqq.json
+++ b/RSSFeeder/i18n/qqq.json
@@ -7,11 +7,13 @@
},
"bs-rssfeeder-desc": "Used in
[{{canonicalurl:Special:WikiAdmin|mode=ExtensionInfo}}
Special:WikiAdmin?mode=ExtensionInfo], description of rss feeder extension",
"rssfeeder": "{{doc-special|RSS feeder}}",
+ "apihelp-bs-rssfeeder-tasks-description": "Describes an API endpoint
that provides common tasks for the RSSFeeder",
"bs-rssfeeder-pagetext": "Headline on special page for RSS feeds
section:",
"bs-rssfeeder-recent-changes": "Headline for recent
changes\n{{Identical|Recent changes}}",
"bs-rssfeeder-pages": "Headline for page\n{{Identical|Page}}",
"bs-rssfeeder-submit": "Button label for show\n{{Identical|Show}}",
"bs-rssfeeder-rss": "Used in [[Special:AdminDashboard]] and
[[Special:UserDashboard]], headline for rss feed portlet.\n{{Identical|RSS
feed}}",
"bs-rssfeeder-rss-desc": "Used in [[Special:AdminDashboard]] and
[[Special:UserDashboard]], description of rss feed portlet",
- "bs-extjs-rssfeeder-rss-title": "Used in [[Special:AdminDashboard]] and
[[Special:UserDashboard]], label for rss URL."
+ "bs-extjs-rssfeeder-rss-title": "Used in [[Special:AdminDashboard]] and
[[Special:UserDashboard]], label for rss URL.",
+ "bs-rssfeeder-invalid-url": "Error message when URL is not provided in
the API"
}
diff --git a/RSSFeeder/includes/api/BSApiTasksRSSFeeder.php
b/RSSFeeder/includes/api/BSApiTasksRSSFeeder.php
new file mode 100644
index 0000000..327c9df
--- /dev/null
+++ b/RSSFeeder/includes/api/BSApiTasksRSSFeeder.php
@@ -0,0 +1,109 @@
+<?php
+/**
+ * Provides the RSSFeeder api for BlueSpice.
+ *
+ * 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; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * This file is part of BlueSpice for MediaWiki
+ * For further information visit http://www.bluespice.com
+ *
+ * @author Markus Glaser <[email protected]>
+ * @package Bluespice_Extensions
+ * @copyright Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
+ * @license http://www.gnu.org/copyleft/gpl.html GNU Public License v2 or
later
+ */
+
+/**
+ * ShoutBox Api class
+ * @package BlueSpice_Extensions
+ */
+class BSApiTasksRSSFeeder extends BSApiTasksBase {
+
+ /**
+ * Methods that can be called by task param
+ * @var array
+ */
+ protected $aTasks = array(
+ 'getRSS'
+ );
+
+ /**
+ * Methods that can be executed even when the wiki is in read-mode, as
+ * they do not alter the state/content of the wiki
+ * @var array
+ */
+ protected $aReadTasks = array(
+ 'getRSS',
+ );
+
+ /**
+ * Returns an array of tasks and their required permissions
+ * array( 'taskname' => array('read', 'edit') )
+ * @return array
+ */
+ protected function getRequiredTaskPermissions() {
+ return array(
+ 'getRSS' => array( 'read' )
+ );
+ }
+
+ /**
+ * Delivers a rendered RSS feed
+ * @param stdClass $oTaskData contains params
+ * @return stdClass Standard task API return
+ */
+ protected function task_getRSS( $oTaskData ) {
+ global $wgParser;
+ $oReturn = $this->makeStandardReturn();
+
+ $iCount = isset( $oTaskData->count )
+ ? (int) $oTaskData->count
+ : 10
+ ;
+ if ( isset( $oTaskData->url ) && filter_var( $oTaskData->url,
FILTER_SANITIZE_URL ) ) {
+ $sUrl = $oTaskData->url;
+ } else {
+ $oReturn->message = wfMessage(
+ 'bs-rssfeeder-invalid-url'
+ )->plain();
+ return $oReturn;
+ }
+
+ $oParserOpts = new ParserOptions;
+ $iCount = intval( $iCount );
+
+ $sTag = '<rss max="' . $iCount . '">' . $sUrl . '</rss>';
+
+ $params = new DerivativeRequest(
+ $this->getRequest(), // Fallback upon $wgRequest if you
can't access context.
+ array(
+ 'action' => 'parse',
+ 'text' => $sTag,
+ 'contentmodel' => 'wikitext'
+ )
+ );
+ $api = new ApiMain( $params );
+ $api->execute();
+ $data = $api->getResult()->getResultData();
+
+ $oReturn->payload['html'] = $data['parse']['text'];
+ $oReturn->success = true;
+ return $oReturn;
+ }
+
+ public function needsToken() {
+ return false;
+ }
+}
\ No newline at end of file
diff --git a/RSSFeeder/resources/BS.RSSFeeder/RSSPortlet.js
b/RSSFeeder/resources/BS.RSSFeeder/RSSPortlet.js
index fc9c643..8858e4f 100644
--- a/RSSFeeder/resources/BS.RSSFeeder/RSSPortlet.js
+++ b/RSSFeeder/resources/BS.RSSFeeder/RSSPortlet.js
@@ -2,7 +2,8 @@
* RSSFeeder extension
*
* @author Stephan Muggli <[email protected]>
- * @version 2.22.0
+ * @author Markus Glaser <[email protected]>
+ * @version 2.27.0
* @package Bluespice_Extensions
* @subpackage RSSFeeder
* @copyright Copyright (C) 2016 Hallo Welt! GmbH, All rights reserved.
@@ -11,32 +12,25 @@
*/
Ext.define( 'BS.RSSFeeder.RSSPortlet', {
- extend: 'BS.portal.HTMLPortlet',
+ extend: 'BS.portal.APIPortlet',
portletConfigClass: 'BS.RSSFeeder.RSSPortletConfig',
+ module: 'rssfeeder',
+ task: 'getRSS',
- constructor: function() {
- this.autoLoadPortlet = false;
- this.callParent(arguments);
- this.cContent.getLoader().load({
- url: bs.util.getAjaxDispatcherUrl( 'RSSFeeder::getRSS',
[ this.portletItemCount, this.rssurl ] )
- });
- },
setPortletConfig: function( cfg ) {
this.rssurl = cfg.rssurl;
this.callParent(arguments);
- this.cContent.getLoader().load({
- url: bs.util.getAjaxDispatcherUrl( 'RSSFeeder::getRSS',
[ this.portletItemCount, cfg.rssurl ] )
- });
},
getPortletConfig: function() {
- //There is no method like Panel::getTitle()!
- return {
- title: this.title,
- height: this.height || 0,
- portletItemCount: this.portletItemCount,
- portletTimeSpan: this.portletTimeSpan,
- collapsed: this.getCollapsed(),
- rssurl: this.rssurl
+ cfg = this.callParent( arguments );
+ cfg.rssurl = this.rssurl;
+ return cfg;
+ },
+ makeData: function() {
+ data = {
+ 'count': this.portletItemCount,
+ 'url':this.rssurl
};
+ return data;
}
} );
\ No newline at end of file
--
To view, visit https://gerrit.wikimedia.org/r/302425
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I097a643dd296a982af5d4e8a48d8fb2eaddd4b5f
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: Mglaser <[email protected]>
Gerrit-Reviewer: Dvogel hallowelt <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Raimond Spekking <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits