Jdlrobson has uploaded a new change for review. https://gerrit.wikimedia.org/r/277358
Change subject: POC: Special Mobile Cite page and PHPUnit tests ...................................................................... POC: Special Mobile Cite page and PHPUnit tests The current implementation of lazy loaded references cannot be tested until the Special MobileCite page exists. This adds some scaffolding which we can iterate on later. Change-Id: If0e9c0850aec7136cc75dcc8f3b67831a2fa164d --- M MobileFrontend.alias.php M extension.json M includes/MobileFormatter.php A includes/specials/SpecialMobileCite.php M tests/phpunit/MobileFormatterTest.php 5 files changed, 65 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/58/277358/1 diff --git a/MobileFrontend.alias.php b/MobileFrontend.alias.php index c72c7aa..7071d26 100644 --- a/MobileFrontend.alias.php +++ b/MobileFrontend.alias.php @@ -12,6 +12,7 @@ /** English (English) */ $specialPageAliases['en'] = array( 'History' => array( 'History' ), + 'MobileCite' => array( 'MobileCite' ), 'MobileOptions' => array( 'MobileOptions' ), 'Uploads' => array( 'Uploads' ), 'MobileDiff' => array( 'MobileDiff' ), diff --git a/extension.json b/extension.json index 7fa686d..1d94e85 100644 --- a/extension.json +++ b/extension.json @@ -40,6 +40,7 @@ }, "SpecialPages": { "History": "SpecialMobileHistory", + "MobileCite": "SpecialMobileCite", "MobileDiff": "SpecialMobileDiff", "MobileEditor": "SpecialMobileEditor", "MobileOptions": "SpecialMobileOptions", @@ -93,6 +94,7 @@ "SpecialMobileContributions": "includes/specials/SpecialMobileContributions.php", "SpecialNearby": "includes/specials/SpecialNearby.php", "SpecialMobileLanguages": "includes/specials/SpecialMobileLanguages.php", + "SpecialMobileCite": "includes/specials/SpecialMobileCite.php", "SpecialMobilePreferences": "includes/specials/SpecialMobilePreferences.php", "MobileSpecialPage": "includes/specials/MobileSpecialPage.php", "MobileSpecialPageFeed": "includes/specials/MobileSpecialPageFeed.php", diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php index d6579de..2a28056 100644 --- a/includes/MobileFormatter.php +++ b/includes/MobileFormatter.php @@ -176,7 +176,7 @@ $citePath = "$listId/" . $this->title->getPrefixedText(); // FIXME: Currently a broken link see https://phabricator.wikimedia.org/T125897 $placeholder->setAttribute( 'href', - SpecialPage::getTitleFor( 'Cite', $citePath )->getLocalUrl() ); + SpecialPage::getTitleFor( 'MobileCite', $citePath )->getLocalUrl() ); $parent->replaceChild( $placeholder, $list ); $listId -= 1; } diff --git a/includes/specials/SpecialMobileCite.php b/includes/specials/SpecialMobileCite.php new file mode 100644 index 0000000..08f6756 --- /dev/null +++ b/includes/specials/SpecialMobileCite.php @@ -0,0 +1,41 @@ +<?php +/** + * SpecialMobileCite.php + */ + +/** + * Provides a list of citiations available for a page + */ +class SpecialMobileCite extends MobileSpecialPage { + /** + * Construct function + */ + public function __construct() { + parent::__construct( 'MobileCite' ); + } + + /** + * Render the page with a list of languages the page is available in + * @param string $pagename The name of the page + */ + public function executeWhenAvailable( $param ) { + if ( $param ) { + $args = explode( '/', $param ); + if ( sizeof( $args ) > 1 ) { + $id = $args[0]; + $title = implode( array_slice ( $args, 1 ) ); + $pageTitle = 'References for ' . $title; + $html = 'Under construction'; + $html = MobileUI::contentElement( $html ); + $out = $this->getOutput(); + $out->setPageTitle( $pageTitle ); + $out->addHTML( $html ); + return; + } + } + + // errors suck + wfHttpError( 404, 'Page not provided', + 'Need to know which title to look up references for' ); + } +} diff --git a/tests/phpunit/MobileFormatterTest.php b/tests/phpunit/MobileFormatterTest.php index 4d823cf..f25145d 100644 --- a/tests/phpunit/MobileFormatterTest.php +++ b/tests/phpunit/MobileFormatterTest.php @@ -49,6 +49,15 @@ . Html::element( 'span', array( 'class' => MobileUI::iconClass( 'spinner', 'element', 'loading spinner' ) ) ) . '</span>'; $noscript = '<noscript><img alt="foo" src="foo.jpg" width="100" height="100"></noscript>'; + $reftext = '<p>They saved the world with one single unit test<sup><a href="cite-note-1">[1]</a></sup></p>'; + $refhtml = '<ol class="references"><li>link 1</li><li>link 2</li></ol>'; + $refplaceholder = Html::element( 'a', + array( + 'class' => 'mf-lazy-references-placeholder', + 'href' => SpecialPage::getTitleFor( 'MobileCite', '0/Mobile' )->getLocalUrl(), + ), + wfMessage( 'mobile-frontend-references-list' ) + ); return array( // # Lazy loading images @@ -79,6 +88,17 @@ false, false, true, ), + // # Lazy loading references + array( + $reftext + . '<h2>references</h2>' . $refhtml, + '<div class="mf-section-0">' . $reftext . '</div>' + . '<h2>references</h2>' + . '<div class="mf-section-1">' . $refplaceholder . '</div>', + $enableSections, + false, true, false + ), + // # Removal of images array( '<img src="/foo/bar.jpg" alt="Blah"/>', -- To view, visit https://gerrit.wikimedia.org/r/277358 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If0e9c0850aec7136cc75dcc8f3b67831a2fa164d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Jdlrobson <jrob...@wikimedia.org> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits