MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/180349
Change subject: Flag to disable main page transformations
......................................................................
Flag to disable main page transformations
Change-Id: Ie3b1b5f1e2c563756c128c84e76d44fd528c06c4
---
M MobileFrontend.php
M includes/MobileFormatter.php
M includes/api/ApiMobileView.php
M includes/api/ApiParseExtender.php
4 files changed, 14 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/49/180349/1
diff --git a/MobileFrontend.php b/MobileFrontend.php
index 4f8debf..cc96685 100644
--- a/MobileFrontend.php
+++ b/MobileFrontend.php
@@ -589,3 +589,9 @@
* wgMFDescription variable
*/
$wgMFUseWikibaseDescription = false;
+
+/**
+ * If set to true, main page HTML will receive special massaging that removes
everything
+ * but a few select pieces.
+ */
+$wgMFSpecialCaseMainPage = true;
diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php
index 36d56c4..6aa9c89 100644
--- a/includes/MobileFormatter.php
+++ b/includes/MobileFormatter.php
@@ -65,10 +65,11 @@
* @return MobileFormatter
*/
public static function newFromContext( $context, $html ) {
+ global $wgMFSpecialCaseMainPage;
wfProfileIn( __METHOD__ );
$title = $context->getTitle();
- $isMainPage = $title->isMainPage();
+ $isMainPage = $title->isMainPage() && $wgMFSpecialCaseMainPage;
$isFilePage = $title->inNamespace( NS_FILE );
$isSpecialPage = $title->isSpecialPage();
diff --git a/includes/api/ApiMobileView.php b/includes/api/ApiMobileView.php
index 6868f3f..fd5201c 100644
--- a/includes/api/ApiMobileView.php
+++ b/includes/api/ApiMobileView.php
@@ -422,7 +422,8 @@
* @return array
*/
private function getData( Title $title, $noImages ) {
- global $wgMemc, $wgUseTidy, $wgMFTidyMobileViewSections,
$wgMFMinCachedPageSize;
+ global $wgMemc, $wgUseTidy, $wgMFTidyMobileViewSections,
$wgMFMinCachedPageSize,
+ $wgMFSpecialCaseMainPage;
wfProfileIn( __METHOD__ );
$wp = $this->makeWikiPage( $title );
@@ -486,7 +487,7 @@
$mf = new MobileFormatter( MobileFormatter::wrapHTML(
$html ), $title );
$mf->setRemoveMedia( $noImages );
$mf->filterContent();
- $mf->setIsMainPage( $this->mainPage );
+ $mf->setIsMainPage( $this->mainPage &&
$wgMFSpecialCaseMainPage );
$html = $mf->getText();
}
wfProfileOut( __METHOD__ . '-MobileFormatter' );
diff --git a/includes/api/ApiParseExtender.php
b/includes/api/ApiParseExtender.php
index 425783c..dd3ee2f 100644
--- a/includes/api/ApiParseExtender.php
+++ b/includes/api/ApiParseExtender.php
@@ -62,6 +62,8 @@
* @return bool
*/
public static function onAPIAfterExecute( ApiBase &$module ) {
+ global $wgMFSpecialCaseMainPage;
+
if ( $module->getModuleName() == 'parse' ) {
wfProfileIn( __METHOD__ );
$data = $module->getResultData();
@@ -75,7 +77,7 @@
$html = MobileFormatter::wrapHTML(
$data['parse']['text']['*'] );
$mf = new MobileFormatter( $html, $title );
$mf->setRemoveMedia( $params['noimages'] );
- $mf->setIsMainPage( $params['mainpage'] );
+ $mf->setIsMainPage( $params['mainpage'] &&
$wgMFSpecialCaseMainPage );
$mf->enableExpandableSections(
!$params['mainpage'] );
// HACK: need a nice way to request a TOC- and
edit link-free HTML in the first place
$mf->remove( array( '.toc', 'mw-editsection' )
);
--
To view, visit https://gerrit.wikimedia.org/r/180349
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie3b1b5f1e2c563756c128c84e76d44fd528c06c4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits