jenkins-bot has submitted this change and it was merged.
Change subject: Beta: Override Special:Contributions and Special:RecentChanges
with mobile equivalents
......................................................................
Beta: Override Special:Contributions and Special:RecentChanges with mobile
equivalents
Obviously more work is needed on both of these views before pushing to
stable but at least they render much more nicely in the mobile skin.
Change-Id: Ia00fc297e9687ad8c08c17ad1a0f4df1832f1125
---
M MobileFrontend.i18n.php
M MobileFrontend.php
M includes/MobileFrontend.hooks.php
M includes/specials/MobileSpecialPageFeed.php
A includes/specials/SpecialMobileContributions.php
M includes/specials/SpecialMobileHistory.php
6 files changed, 115 insertions(+), 21 deletions(-)
Approvals:
Jdlrobson: Looks good to me, approved
jenkins-bot: Verified
diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index d1839fe..7cc8e26 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -82,6 +82,7 @@
'mobile-frontend-login' => 'Sign in',
'mobile-frontend-history' => 'View edit history of this page.',
'mobile-frontend-history-no-results' => 'No history matches the filter
provided.',
+ 'mobile-frontend-contribution-summary' => 'All edits made by
{{GENDER:$1|[[Special:UserProfile/$1|$1]]}}',
'mobile-frontend-history-summary' => 'Page history for [[:$1]]',
'mobile-frontend-last-modified-date' => 'Last modified on $1, at $2',
'mobile-frontend-last-modified-seconds' => 'Last modified
{{PLURAL:$1|$1 second|$1 seconds}} ago',
@@ -503,6 +504,10 @@
If not the Main Page, the following message is used:
* {{msg-mw|Mobile-frontend-last-modified-date}}',
'mobile-frontend-history-no-results' => 'Error shown when there are no
history entires for a given/invalid filter.',
+ 'mobile-frontend-contribution-summary' => 'Summary text that appears
at the top of the Special:Contributions page for a given username.
+
+Parameters:
+* $1 - username',
'mobile-frontend-history-summary' => 'Summary text that appears at the
top of the mobile history page for a given page.
Parameters:
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 36e0142..0a30e09 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -70,6 +70,7 @@
'SpecialMobileOptions' => 'specials/SpecialMobileOptions',
'SpecialMobileMenu' => 'specials/SpecialMobileMenu',
'SpecialMobileWatchlist' => 'specials/SpecialMobileWatchlist',
+ 'SpecialMobileContributions' => 'specials/SpecialMobileContributions',
'SpecialNearby' => 'specials/SpecialNearby',
'SpecialMobileNotifications' => 'specials/SpecialMobileNotifications',
'MobileSpecialPage' => 'specials/MobileSpecialPage',
diff --git a/includes/MobileFrontend.hooks.php
b/includes/MobileFrontend.hooks.php
index 156fd63..ec8579b 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -283,6 +283,18 @@
if ( $ctx->shouldDisplayMobileView() ) {
// Replace the standard watchlist view with our custom
one
$list['Watchlist'] = 'SpecialMobileWatchlist';
+ if ( $ctx->isBetaGroupMember() ) {
+ /* In mobile the History page with no
parameters provides history of all pages across the project.
+ * This is essentially Special:RecentChanges
(without the bells and whistles) so redirect people there.
+ */
+ $list['RecentChanges'] = 'SpecialMobileHistory';
+ /* Special:MobileContributions redefines
Special:History in such a way that for Special:Contributions/Foo,
+ * Foo is a username (in Special:History/Foo,
Foo is a page name)
+ * Redirect people here as this is essential
Special:Contributions without the bells and whistles.
+ */
+ $list['Contributions'] =
'SpecialMobileContributions';
+ }
+
// FIXME: Make uploads work on desktop
$list['Uploads'] = 'SpecialUploads';
$list['Userlogin'] = 'SpecialMobileUserlogin';
diff --git a/includes/specials/MobileSpecialPageFeed.php
b/includes/specials/MobileSpecialPageFeed.php
index e5ecdbc..b654720 100644
--- a/includes/specials/MobileSpecialPageFeed.php
+++ b/includes/specials/MobileSpecialPageFeed.php
@@ -38,9 +38,11 @@
*
* @return String: HTML code
*/
- protected function renderFeedItemHtml( $ts, $diffLink ='', $username =
'', $comment = '', $title = false ) {
+ protected function renderFeedItemHtml( $ts, $diffLink ='', $username =
'', $comment = '',
+ $title = false, $isAnon = false ) {
+
$out = $this->getOutput();
- if ( $username === '' ) {
+ if ( $isAnon ) {
$username = $this->msg(
'mobile-frontend-changeslist-ip' )->plain();
$usernameClass = 'mw-mf-user mw-mf-anon';
} else {
@@ -54,8 +56,10 @@
$html .= Html::openElement( 'div', array( 'class' =>
'title' ) );
}
if ( $title ) {
- $html .= Html::element( 'h2', array(),
$title->getPrefixedText() ) .
- Html::element( 'div', array( 'class' =>
$usernameClass ), $username );
+ $html .= Html::element( 'h2', array(),
$title->getPrefixedText() );
+ if ( $username ) {
+ $html .= Html::element( 'div', array( 'class'
=> $usernameClass ), $username );
+ }
} else {
$html .= Html::openElement( 'h2' ) .
Html::element( 'span', array( 'class' =>
$usernameClass ), $username ) .
diff --git a/includes/specials/SpecialMobileContributions.php
b/includes/specials/SpecialMobileContributions.php
new file mode 100644
index 0000000..87edee6
--- /dev/null
+++ b/includes/specials/SpecialMobileContributions.php
@@ -0,0 +1,40 @@
+<?php
+// FIXME: On Special:Contributions add ability to filter a la desktop
+class SpecialMobileContributions extends SpecialMobileHistory {
+ // Note we do not redirect to Special:History/$par to allow the
parameter to be used for usernames
+ protected $specialPageName = 'Contributions';
+ /** @var User */
+ protected $user;
+
+ public function executeWhenAvailable( $par = '' ) {
+ wfProfileIn( __METHOD__ );
+ $out = $this->getOutput();
+ if ( $par ) {
+ // enter article history view
+ $this->user = User::newFromName( $par );
+ $this->renderHeaderBar( $this->msg(
'mobile-frontend-contribution-summary',
+ $this->user->getName() ), true );
+ }
+ $res = $this->doQuery();
+ $this->showHistory( $res );
+ wfProfileOut( __METHOD__ );
+ }
+
+ protected function getQueryConditions() {
+ if ( $this->user ) {
+ $conds = array(
+ 'rev_user' => $this->user->getID(),
+ );
+ } else {
+ $conds = array();
+ }
+ return $conds;
+ }
+
+ protected function renderFeedItemHtml( $ts, $diffLink ='', $username =
'', $comment = '', $title = false, $isAnon=false ) {
+ // Stop username from being rendered
+ $username = False;
+ parent::renderFeedItemHtml( $ts, $diffLink, $username,
$comment, $title );
+ }
+
+}
diff --git a/includes/specials/SpecialMobileHistory.php
b/includes/specials/SpecialMobileHistory.php
index ffcac70..dd1110c 100644
--- a/includes/specials/SpecialMobileHistory.php
+++ b/includes/specials/SpecialMobileHistory.php
@@ -6,11 +6,47 @@
/** @var String|null timestamp to offset results from */
protected $offset;
+ /** @var String name of the special page */
+ protected $specialPageName = 'History';
+
/** @var Title|null if no title passed */
protected $title;
public function __construct() {
- parent::__construct( 'History' );
+ parent::__construct( $this->specialPageName );
+ }
+
+ /**
+ * Returns a list of query conditions that should be run against the
revision table
+ *
+ * @return Array: List of conditions
+ */
+ protected function getQueryConditions() {
+ $conds = array();
+ if ( $this->title ) {
+ $conds[ 'rev_page' ] = $this->title->getArticleID();
+ } else if ( $this->offset ) {
+ $conds[] = 'rev_timestamp <= ' .
$dbr->addQuotes( $this->offset );
+ }
+ return $conds;
+ }
+
+ /**
+ * Adds HTML to render a header at the top of the feed
+ * @param {Message} msg: A message to print in the header bar
+ * @param {boolean} parse: Whether to parse the message or to escape it
(defaults to escape)
+ *
+ * @return Array: List of conditions
+ */
+ protected function renderHeaderBar( $msg, $parse=false ) {
+ $msg = $parse ? $msg->parse() : $msg->escaped();
+ $this->getOutput()->addHtml(
+ Html::openElement( 'div', array( 'class' =>
'page-header-bar' ) ) .
+ Html::openElement( 'div' ) .
+ $msg .
+ Html::closeElement( 'div' ) .
+ Html::closeElement( 'div' )
+ );
}
public function executeWhenAvailable( $par = '' ) {
@@ -22,13 +58,9 @@
if ( $par ) {
// enter article history view
$this->title = Title::newFromText( $par );
- $out->addHtml(
- Html::openElement( 'div', array( 'class' =>
'page-header-bar' ) ) .
- Html::openElement( 'div' ) .
- $this->msg( 'mobile-frontend-history-summary',
$this->title->getPrefixedText() )->parse() .
- Html::closeElement( 'div' ) .
- Html::closeElement( 'div' )
- );
+ if ( $this->title && $this->title->exists() ) {
+ $this->renderHeaderBar( $this->msg(
'mobile-frontend-history-summary', $this->title->getText() ), true );
+ }
}
$res = $this->doQuery();
$this->showHistory( $res );
@@ -40,13 +72,7 @@
wfProfileIn( __METHOD__ );
$table = 'revision';
$dbr = wfGetDB( DB_SLAVE, $table );
- $conds = array();
- if ( $this->offset ) {
- $conds[] = 'rev_timestamp <= ' . $dbr->addQuotes(
$this->offset );
- }
- if ( $this->title ) {
- $conds['rev_page'] = $this->title->getArticleID();
- }
+ $conds = $this->getQueryConditions();
$options = array(
'ORDER BY' => 'rev_timestamp DESC',
'USE INDEX' => 'page_timestamp',
@@ -73,7 +99,13 @@
wfProfileIn( __METHOD__ );
$user = $this->getUser();
$userId = $rev->getUser( Revision::FOR_THIS_USER, $user );
- $username = $userId === 0 ? '' : $rev->getUserText(
Revision::FOR_THIS_USER, $user );
+ if ( $userId === 0 ) {
+ $username = '';
+ $isAnon = true;
+ } else {
+ $username = $rev->getUserText( Revision::FOR_THIS_USER,
$user );
+ $isAnon = false;
+ }
// FIXME: Style differently user comment when this is the case
if ( $rev->userCan( Revision::DELETED_COMMENT, $user ) ) {
@@ -105,7 +137,7 @@
} else {
$title = $rev->getTitle();
}
- $this->renderFeedItemHtml( $ts, $diffLink, $username, $comment,
$title );
+ $this->renderFeedItemHtml( $ts, $diffLink, $username, $comment,
$title, $isAnon );
wfProfileOut( __METHOD__ );
}
--
To view, visit https://gerrit.wikimedia.org/r/94620
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia00fc297e9687ad8c08c17ad1a0f4df1832f1125
Gerrit-PatchSet: 10
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[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