MaxSem has uploaded a new change for review.

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


Change subject: Allow customizing post_zip destination
......................................................................

Allow customizing post_zip destination

Looks clumsy though, please let me know if you don't like it

Change-Id: I4b9da674f9fe4de555627d0379fa4ba4a984d2b8
---
M Collection.body.php
M Collection.php
M RenderingAPI.php
3 files changed, 17 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Collection 
refs/changes/47/106847/1

diff --git a/Collection.body.php b/Collection.body.php
index cfea398..714160a 100644
--- a/Collection.body.php
+++ b/Collection.body.php
@@ -1187,7 +1187,12 @@
                }
 
                $api = CollectionRenderingAPI::instance();
-               $result = $api->postZip( $collection, 
$this->mPODPartners[$partner]['posturl'] );
+               $partnerData = $this->mPODPartners[$partner];
+               $url = false;
+               if ( isset( $partnerData['rendererurl'] ) ) {
+                       $url = $partnerData['rendererurl'];
+               }
+               $result = $api->postZip( $collection, $partnerData['posturl'], 
$url );
                if ( !$this->handleResult( $result ) ) {
                        return;
                }
diff --git a/Collection.php b/Collection.php
index 1089d9f..db6e355 100644
--- a/Collection.php
+++ b/Collection.php
@@ -133,6 +133,7 @@
                'url' => 'http://pediapress.com/',
                'posturl' => 'http://pediapress.com/api/collections/',
                'infopagetitle' => 'coll-order_info_article',
+               'rendererurl' => 'http://tools.pediapress.com/mw-serve/',
        ),
 );
 # 
==============================================================================
diff --git a/RenderingAPI.php b/RenderingAPI.php
index 01f6da7..d4aa227 100644
--- a/RenderingAPI.php
+++ b/RenderingAPI.php
@@ -29,9 +29,11 @@
         *
         * @param string $command
         * @param array $params
+        * @param string|bool $url
+        *
         * @return CollectionAPIResult
         */
-       protected abstract function makeRequest( $command, array $params );
+       protected abstract function makeRequest( $command, array $params, $url 
= false );
 
        /**
         * Requests a collection to be rendered
@@ -74,11 +76,12 @@
         * e.g. for printing
         *
         * @param $collection
-        * @param $url
+        * @param $postUrl
+        * @param string|bool $url
         *
         * @return CollectionAPIResult
         */
-       public function postZip( $collection, $url ) {
+       public function postZip( $collection, $postUrl, $url = false ) {
                global $wgScriptPath, $wgScriptExtension;
 
                return $this->makeRequest( 'zip_post',
@@ -86,7 +89,7 @@
                                'metabook' => $this->buildJSONCollection( 
$collection ),
                                'base_url' => wfExpandUrl( $wgScriptPath, 
PROTO_CURRENT ),
                                'script_extension' => $wgScriptExtension,
-                               'pod_api_url' => $url,
+                               'pod_api_url' => $postUrl,
                        )
                );
        }
@@ -203,12 +206,12 @@
  * API for PediaPress' mw-serve
  */
 class MWServeRenderingAPI extends CollectionRenderingAPI {
-       protected function makeRequest( $command, array $params ) {
+       protected function makeRequest( $command, array $params, $url = false ) 
{
                global $wgCollectionMWServeURL, 
$wgCollectionMWServeCredentials, $wgCollectionFormatToServeURL;
 
                wfProfileIn( __METHOD__ . "-$command" );
-               $serveURL = $wgCollectionMWServeURL;
-               if ( $this->writer ) {
+               $serveURL = $url ? $url : $wgCollectionMWServeURL;
+               if ( $this->writer && !$url ) {
                        if ( isset( $wgCollectionFormatToServeURL[ 
$this->writer ] ) ) {
                                $serveURL = $wgCollectionFormatToServeURL[ 
$this->writer ];
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b9da674f9fe4de555627d0379fa4ba4a984d2b8
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Collection
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>

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

Reply via email to