Florianschmidtwelzow has uploaded a new change for review.
https://gerrit.wikimedia.org/r/190728
Change subject: Add a "Discussion" button to the page in stable mode, too
......................................................................
Add a "Discussion" button to the page in stable mode, too
* Link to the wikitext talk page instead of using the talk Overlay feature
* Partially promote mobile.talk to stable:
** Loaded only in beta on all pages
** Loaded on all talk pages (stable/beta/alpha) to add the "Add discussion"
button
to easily add a discussion to the talk page
In stable, the user is linked to the wikitext talk page and can add a
discussion with the
Add discussion button and edit discussions like any other article with the edit
pencils.
Bug: T54165
Change-Id: I1c938f79a164c30f33258dc729e83bb17eaaee6c
---
M includes/Resources.php
M includes/skins/SkinMinerva.php
M includes/skins/SkinMinervaBeta.php
M javascripts/modules/talk/TalkOverlay.js
M javascripts/modules/talk/TalkSectionAddOverlay.js
M javascripts/modules/talk/talk.js
6 files changed, 68 insertions(+), 55 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/28/190728/1
diff --git a/includes/Resources.php b/includes/Resources.php
index 9ca059b..c72f703 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -581,7 +581,7 @@
'mobile.talk' => $wgMFResourceFileModuleBoilerplate + array(
'dependencies' => array(
- 'mobile.beta',
+ 'mobile.stable',
),
'styles' => array(
'less/modules/talk.less',
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 7080a4c..fc3f5fa 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -744,11 +744,45 @@
}
/**
+ * Returns an array with details for a talk button.
+ * @param Title $talkTitle Title object of the talk page
+ * @param array $talkButton Array with data of desktop talk button
+ * @return array
+ */
+ protected function getTalkButton( $talkTitle, $talkButton ) {
+ return array(
+ 'attributes' => array(
+ 'href' => $talkTitle->getLinkURL(),
+ 'data-title' => $talkTitle->getFullText(),
+ ),
+ 'label' => $talkButton['text'],
+ );
+ }
+
+ /**
* Returns an array of links for page secondary actions
* @param BaseTemplate $tpl
*/
protected function getSecondaryActions( BaseTemplate $tpl ) {
- return array();
+ $buttons = array();
+
+ // always add a button to link to the talk page
+ // in beta it will be the entry point for the talk overlay
feature,
+ // in stable it will link to the wikitext talk page
+ $title = $this->getTitle();
+ $namespaces = $tpl->data['content_navigation']['namespaces'];
+ if ( $this->isTalkAllowed() ) {
+ // FIXME [core]: This seems unnecessary..
+ $subjectId = $title->getNamespaceKey( '' );
+ $talkId = $subjectId === 'main' ? 'talk' :
"{$subjectId}_talk";
+ if ( isset( $namespaces[$talkId] ) &&
!$title->isTalkPage() ) {
+ $talkButton = $namespaces[$talkId];
+ }
+
+ $talkTitle = $title->getTalkPage();
+ $buttons['talk'] = $this->getTalkButton( $talkTitle,
$talkButton );
+ }
+ return $buttons;
}
/**
@@ -864,6 +898,17 @@
}
/**
+ * Returns true, if the page can have a talk page.
+ * @return boolean
+ */
+ protected function isTalkAllowed() {
+ $title = $this->getTitle();
+ return $this->isAllowedPageAction( 'talk' ) &&
+ !$title->isTalkPage() &&
+ $title->canTalk();
+ }
+
+ /**
* Returns an array of modules related to the current context of the
page.
* @return array
*/
@@ -901,6 +946,12 @@
if ( $this->mobileContext->userCanUpload() ) {
$modules[] = 'mobile.upload.ui';
}
+
+ // talk pages should have an easy way to add discussions.
mobile.talk adds an "Add discussion"
+ // button to talk pages, but is only loaded in beta actually,
load it on talk pages, too
+ if ( $title->isTalkPage() ) {
+ $modules[] = 'mobile.talk';
+ }
return $modules;
}
diff --git a/includes/skins/SkinMinervaBeta.php
b/includes/skins/SkinMinervaBeta.php
index 8d3b484..5e05fb5 100644
--- a/includes/skins/SkinMinervaBeta.php
+++ b/includes/skins/SkinMinervaBeta.php
@@ -48,28 +48,29 @@
}
/**
- * Returns true, if the page can have a talk page.
- * @return boolean
- */
- protected function isTalkAllowed() {
- $title = $this->getTitle();
- return $this->isAllowedPageAction( 'talk' ) &&
- !$title->isTalkPage() &&
- $title->canTalk();
- }
-
- /**
* Returns an array of modules related to the current context of the
page.
* @return array
*/
public function getContextSpecificModules() {
$modules = parent::getContextSpecificModules();
- $title = $this->getTitle();
- if ( $this->isTalkAllowed() || $title->isTalkPage() ) {
+ if ( $this->isTalkAllowed() ) {
$modules[] = 'mobile.talk';
}
return $modules;
+ }
+
+ /**
+ * Returns an array with details for a talk button.
+ * @param Title $talkTitle Title object of the talk page
+ * @param array $talkButton Array with data of desktop talk button
+ * @return array
+ */
+ protected function getTalkButton( $talkTitle, $talkButton ) {
+ $button = parent::getTalkButton( $talkTitle, $talkButton );
+ $button['attributes']['class'] = MobileUI::iconClass( 'talk',
'before', 'talk icon-32px' );
+
+ return $button;
}
/**
@@ -87,38 +88,6 @@
}
return $modules;
- }
-
- /**
- * Returns an array of links for page secondary actions
- * @param BaseTemplate $tpl
- * @return Array
- */
- protected function getSecondaryActions( BaseTemplate $tpl ) {
- $buttons = parent::getSecondaryActions( $tpl );
-
- $title = $this->getTitle();
- $namespaces = $tpl->data['content_navigation']['namespaces'];
- if ( $this->isTalkAllowed() ) {
- // FIXME [core]: This seems unnecessary..
- $subjectId = $title->getNamespaceKey( '' );
- $talkId = $subjectId === 'main' ? 'talk' :
"{$subjectId}_talk";
- if ( isset( $namespaces[$talkId] ) &&
!$title->isTalkPage() ) {
- $talkButton = $namespaces[$talkId];
- }
-
- $talkTitle = $title->getTalkPage();
- $buttons['talk'] = array(
- 'attributes' => array(
- 'href' => $talkTitle->getLinkURL(),
- 'class' => MobileUI::iconClass(
'talk', 'before', 'talk icon-32px' ),
- 'data-title' =>
$talkTitle->getFullText(),
- ),
- 'label' => $talkButton['text'],
- );
- }
-
- return $buttons;
}
/**
diff --git a/javascripts/modules/talk/TalkOverlay.js
b/javascripts/modules/talk/TalkOverlay.js
index 340a803..9b40f7d 100644
--- a/javascripts/modules/talk/TalkOverlay.js
+++ b/javascripts/modules/talk/TalkOverlay.js
@@ -1,6 +1,4 @@
( function ( M, $ ) {
- M.require( 'context' ).assertMode( [ 'beta', 'alpha' ] );
-
var
Overlay = M.require( 'Overlay' ),
Page = M.require( 'Page' ),
diff --git a/javascripts/modules/talk/TalkSectionAddOverlay.js
b/javascripts/modules/talk/TalkSectionAddOverlay.js
index 455ffcb..0185585 100644
--- a/javascripts/modules/talk/TalkSectionAddOverlay.js
+++ b/javascripts/modules/talk/TalkSectionAddOverlay.js
@@ -1,5 +1,4 @@
( function ( M, $ ) {
- M.require( 'context' ).assertMode( [ 'beta', 'alpha' ] );
var
Overlay = M.require( 'Overlay' ),
api = M.require( 'api' ),
diff --git a/javascripts/modules/talk/talk.js b/javascripts/modules/talk/talk.js
index 458051a..680c52e 100644
--- a/javascripts/modules/talk/talk.js
+++ b/javascripts/modules/talk/talk.js
@@ -5,10 +5,7 @@
licenseLink = mw.config.get( 'wgMFLicenseLink' ),
$talk = $( '.talk' ),
page = M.getCurrentPage(),
- overlayManager = M.require( 'overlayManager' ),
- context = M.require( 'context' );
-
- context.assertMode( [ 'beta', 'alpha', 'app' ] );
+ overlayManager = M.require( 'overlayManager' );
overlayManager.add( /^\/talk\/?(.*)$/, function ( id ) {
var result = $.Deferred(),
@@ -51,7 +48,6 @@
// add an "add discussion" button to talk pages (only for beta and
logged in users)
if (
- context.isBetaGroupMember() &&
!user.isAnon() &&
( page.inNamespace( 'talk' ) || page.inNamespace( 'user_talk' )
)
) {
--
To view, visit https://gerrit.wikimedia.org/r/190728
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1c938f79a164c30f33258dc729e83bb17eaaee6c
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits