[MediaWiki-commits] [Gerrit] mediawiki...WikidataPageBanner[master]: WPB enable banners on diff pages
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/321369 Change subject: WPB enable banners on diff pages .. WPB enable banners on diff pages Bug: T147946 Change-Id: I64415799b2403db568a06295d1d79cf8d3d987bd --- M includes/WikidataPageBanner.hooks.php 1 file changed, 2 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/69/321369/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index a87290d..f7d4cf2 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -84,11 +84,10 @@ } $config = WikidataPageBannerFunctions::getWPBConfig(); $title = $out->getTitle(); - $isDiff = $out->getRequest()->getCheck( 'diff' ); $wpbFunctionsClass = self::$wpbFunctionsClass; // if banner-options are set and not a diff page, add banner anyway - if ( $out->getProperty( 'wpb-banner-options' ) !== null && !$isDiff ) { + if ( $out->getProperty( 'wpb-banner-options' ) !== null ) { $params = $out->getProperty( 'wpb-banner-options' ); $bannername = $params['name']; if ( isset( $params['icons'] ) ){ @@ -114,8 +113,7 @@ } elseif ( $title->isKnown() && $out->isArticle() && - $config->get( 'WPBEnableDefaultBanner' ) && - !$isDiff + $config->get( 'WPBEnableDefaultBanner' ) ) { // if the page uses no 'PAGEBANNER' invocation and if article page, insert default banner $ns = $title->getNamespace(); -- To view, visit https://gerrit.wikimedia.org/r/321369 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I64415799b2403db568a06295d1d79cf8d3d987bd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] mediawiki...RelatedArticles[master]: Disable related articles on disambiguation pages
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/306298 Change subject: Disable related articles on disambiguation pages .. Disable related articles on disambiguation pages Uses DisambiguatorHooks to prevent related pages module addition on disambiguation pages. Bug: T127068 Change-Id: I166712d7e5df26ad00c725f3e4fe23ec074b3329 --- M includes/FooterHooks.php 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedArticles refs/changes/98/306298/1 diff --git a/includes/FooterHooks.php b/includes/FooterHooks.php index b3ca93c..dfcc3c4 100644 --- a/includes/FooterHooks.php +++ b/includes/FooterHooks.php @@ -8,6 +8,7 @@ use Skin; use ConfigFactory; use User; +use DisambiguatorHooks; class FooterHooks { @@ -52,6 +53,10 @@ * @return boolean Always true */ public static function onBeforePageDisplay( OutputPage $out, Skin $skin ) { + if( class_exists( 'DisambiguatorHooks' ) && + DisambiguatorHooks::isDisambiguationPage( $out->getTitle() ) ) { + return true; + } $config = ConfigFactory::getDefaultInstance()->makeConfig( 'RelatedArticles' ); $showReadMore = $config->get( 'RelatedArticlesShowInFooter' ); -- To view, visit https://gerrit.wikimedia.org/r/306298 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I166712d7e5df26ad00c725f3e4fe23ec074b3329 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/RelatedArticles Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Allow date ranges in Special:Contributions - change (mediawiki/core)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/281113 Change subject: Allow date ranges in Special:Contributions .. Allow date ranges in Special:Contributions Adds the functionality to set date ranges in Special:Contributions. Does not add a day filter. Bug: T120733 Change-Id: I7021f1f751c5331bcdb17e9cb0df1c1849663274 --- M includes/Xml.php M includes/actions/HistoryAction.php M includes/logging/LogPager.php M includes/pager/ReverseChronologicalPager.php M includes/specials/SpecialContributions.php M includes/specials/pagers/ContribsPager.php M languages/i18n/en.json M languages/i18n/qqq.json 8 files changed, 69 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/13/281113/1 diff --git a/includes/Xml.php b/includes/Xml.php index 43f7217..7366130 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -144,7 +144,7 @@ public static function monthSelector( $selected = '', $allmonths = null, $id = 'month' ) { global $wgLang; $options = []; - $data = new XmlSelect( 'month', $id, $selected ); + $data = new XmlSelect( $id, $id, $selected ); if ( is_null( $selected ) ) { $selected = ''; } @@ -164,7 +164,7 @@ * @param int $month * @return string Formatted HTML */ - public static function dateMenu( $year, $month ) { + public static function dateMenu( $year, $month, $prefix = '' ) { # Offset overrides year/month selection if ( $month && $month !== -1 ) { $encMonth = intval( $month ); @@ -184,11 +184,11 @@ } else { $encYear = ''; } - $inputAttribs = [ 'id' => 'year', 'maxlength' => 4, 'size' => 7 ]; - return self::label( wfMessage( 'year' )->text(), 'year' ) . ' ' . - Html::input( 'year', $encYear, 'number', $inputAttribs ) . ' ' . - self::label( wfMessage( 'month' )->text(), 'month' ) . ' ' . - self::monthSelector( $encMonth, -1 ); + $inputAttribs = [ 'id' => $prefix . 'year', 'maxlength' => 4, 'size' => 7 ]; + return self::label( wfMessage( $prefix . 'year' )->text(), $prefix . 'year' ) . ' ' . + Html::input( $prefix . 'year', $encYear, 'number', $inputAttribs ) . ' ' . + self::label( wfMessage( $prefix . 'month' )->text(), $prefix . 'month' ) . ' ' . + self::monthSelector( $encMonth, -1, $prefix . 'month' ); } /** diff --git a/includes/actions/HistoryAction.php b/includes/actions/HistoryAction.php index 5ec10e6..66b13b3 100644 --- a/includes/actions/HistoryAction.php +++ b/includes/actions/HistoryAction.php @@ -384,7 +384,7 @@ parent::__construct( $historyPage->getContext() ); $this->historyPage = $historyPage; $this->tagFilter = $tagFilter; - $this->getDateCond( $year, $month ); + $this->mOffset = $this->getDateCond( $year, $month ); $this->conds = $conds; $this->showTagEditUI = ChangeTags::showTagEditingUI( $this->getUser() ); } diff --git a/includes/logging/LogPager.php b/includes/logging/LogPager.php index 8518c91..8fb987c 100644 --- a/includes/logging/LogPager.php +++ b/includes/logging/LogPager.php @@ -68,7 +68,7 @@ $this->limitType( $types ); // also excludes hidden types $this->limitPerformer( $performer ); $this->limitTitle( $title, $pattern ); - $this->getDateCond( $year, $month ); + $this->mOffset = $this->getDateCond( $year, $month ); $this->mTagFilter = $tagFilter; $this->mDb = wfGetDB( DB_SLAVE, 'logpager' ); diff --git a/includes/pager/ReverseChronologicalPager.php b/includes/pager/ReverseChronologicalPager.php index 31c9c6d..e862b6d 100644 --- a/includes/pager/ReverseChronologicalPager.php +++ b/includes/pager/ReverseChronologicalPager.php @@ -52,7 +52,6 @@ $firstLastLinks = $this->msg( 'parentheses' )->rawParams( "{$pagingLinks['first']}" . $this->msg( 'pipe-separator' )->escaped() . "{$pagingLinks['last']}" )->escaped(); - $this->mNavigationBar = $firstLastLinks . ' ' . $this->msg( 'viewprevnext' )->rawParams( $pagingLinks['prev'], $pagingLinks['next'], $limits )->escaped(); @@ -60,7 +59,7 @@ return $this->mNavigationBar; } - function getDateCond( $year, $month ) { + function getDateCond( $year, $month, $dir = 1 ) { $year = intval( $year );
[MediaWiki-commits] [Gerrit] Apply filterContentInSection to last section - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/277603 Change subject: Apply filterContentInSection to last section .. Apply filterContentInSection to last section Fixes images in last section not being lazy loaded. Bug: T130025 Change-Id: I324888faacd45dfb05d72772b43a3b626ea80063 --- M includes/MobileFormatter.php 1 file changed, 4 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/03/277603/1 diff --git a/includes/MobileFormatter.php b/includes/MobileFormatter.php index d6579de..389ef03 100644 --- a/includes/MobileFormatter.php +++ b/includes/MobileFormatter.php @@ -404,6 +404,10 @@ $sectionBody->appendChild( $node ); } + if ( $sectionBody->hasChildNodes() ) { + // Apply transformations to the last section body + $this->filterContentInSection( $sectionBody, $doc, $sectionNumber, $transformOptions ); + } // Append the last section body. $body->appendChild( $sectionBody ); } -- To view, visit https://gerrit.wikimedia.org/r/277603 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I324888faacd45dfb05d72772b43a3b626ea80063 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] MobileFrontendSkinHooks fix getLicense() doc - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/272486 Change subject: MobileFrontendSkinHooks fix getLicense() doc .. MobileFrontendSkinHooks fix getLicense() doc Change-Id: I0ea05e1dc4e31dae75fb81974ee697cc7bc9d176 --- M includes/MobileFrontend.skin.hooks.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/86/272486/1 diff --git a/includes/MobileFrontend.skin.hooks.php b/includes/MobileFrontend.skin.hooks.php index 7a8f738..5bfb9c2 100644 --- a/includes/MobileFrontend.skin.hooks.php +++ b/includes/MobileFrontend.skin.hooks.php @@ -55,7 +55,7 @@ * @param string $context The context in which the license link appears, e.g. footer, * editor, talk, or upload. * @param array $attribs An associative array of extra HTML attributes to add to the link -* @return string +* @return array Associative array containing the license text and link */ public static function getLicense( $context, $attribs = array() ) { $config = MobileContext::singleton()->getConfig(); -- To view, visit https://gerrit.wikimedia.org/r/272486 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0ea05e1dc4e31dae75fb81974ee697cc7bc9d176 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Override Copyright warning message for Minerva - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/271594 Change subject: Override Copyright warning message for Minerva .. Override Copyright warning message for Minerva Replace copyright warning message with a shorter version for Mobile Editing when javascript is disabled. Bug: T125174 Change-Id: I9b9bdb59e4bc1f8de0c4e943828bf3053e6c8f0a --- M extension.json M includes/MobileFrontend.hooks.php 2 files changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/94/271594/1 diff --git a/extension.json b/extension.json index d048513..73bfd40 100644 --- a/extension.json +++ b/extension.json @@ -1964,6 +1964,9 @@ ], "RejectParserCacheValue": [ "MobileFrontendHooks::onRejectParserCacheValue" + ], + "EditPageCopyrightWarning": [ + "MobileFrontendHooks::onEditPageCopyrightWarning" ] }, "config": { diff --git a/includes/MobileFrontend.hooks.php b/includes/MobileFrontend.hooks.php index fc43514..3d73937 100644 --- a/includes/MobileFrontend.hooks.php +++ b/includes/MobileFrontend.hooks.php @@ -1343,4 +1343,27 @@ // Set LESS importpath $wgResourceLoaderLESSImportPaths[] = dirname( __DIR__ ) . "/minerva.less/"; } + + /** +* Override copyright message with a shorter one for mobile +* FIXME - Temporary solution, See +* https://phabricator.wikimedia.org/T125174#2035251 +* +* @param $title Title +* @param $msg string +* +* @return bool +*/ + public static function onEditPageCopyrightWarning( $title, &$msg ) { + global $wgRightsText; + if ( $wgRightsText ) { + $msg = [ 'mobile-frontend-copyright', + '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]', + $wgRightsText ]; + } else { + $msg = [ 'mobile-frontend-copyright', + '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text() . ']]' ]; + } + return true; + } } -- To view, visit https://gerrit.wikimedia.org/r/271594 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9b9bdb59e4bc1f8de0c4e943828bf3053e6c8f0a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Hide cancel and pipe seaparator in editor in nojs - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/270348 Change subject: Hide cancel and pipe seaparator in editor in nojs .. Hide cancel and pipe seaparator in editor in nojs Bug: T125174 Change-Id: Ie0403491404fec53790784f04677b508384f989d --- M resources/skins.minerva.fallbackeditor/fallbackeditor.less 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/48/270348/1 diff --git a/resources/skins.minerva.fallbackeditor/fallbackeditor.less b/resources/skins.minerva.fallbackeditor/fallbackeditor.less index a688156..2dbf8ec 100644 --- a/resources/skins.minerva.fallbackeditor/fallbackeditor.less +++ b/resources/skins.minerva.fallbackeditor/fallbackeditor.less @@ -3,7 +3,7 @@ @import "minerva.mixins"; @import "mediawiki.mixins"; -#page-secondary-actions, .editHelp { +#page-secondary-actions, .editHelp, .cancelLink, .mw-editButtons-pipe-separator{ display: none; } -- To view, visit https://gerrit.wikimedia.org/r/270348 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie0403491404fec53790784f04677b508384f989d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] [WIP] Enable no-js editing in mobile - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/267281 Change subject: [WIP] Enable no-js editing in mobile .. [WIP] Enable no-js editing in mobile Bug: T125174 Change-Id: I4b14c390aefd38b63edbc8e4d671da82e39b0fd9 --- M includes/MobileFrontend.hooks.php M includes/Resources.php M includes/skins/SkinMinerva.php M resources/skins.minerva.base.styles/pageactions.less M resources/skins.minerva.base.styles/ui.less M resources/skins.minerva.editor/init.js R resources/skins.minerva.icons.images/edit.svg R resources/skins.minerva.icons.images/editLocked.svg 8 files changed, 62 insertions(+), 42 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/81/267281/1 diff --git a/includes/MobileFrontend.hooks.php b/includes/MobileFrontend.hooks.php index 65c0256..4f24fce 100644 --- a/includes/MobileFrontend.hooks.php +++ b/includes/MobileFrontend.hooks.php @@ -103,16 +103,31 @@ // log whether user is using beta/stable $mobileContext->logMobileMode(); - $skinName = $mobileContext->getMFConfig()->get( 'MFDefaultSkinClass' ); - $betaSkinName = $skinName . 'Beta'; - // Force beta for test mode to sure all modules can run - $name = $context->getTitle()->getDBkey(); - $inTestMode = - $name === SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' )->getDBkey(); - if ( $mobileContext->isBetaGroupMember() && class_exists( $betaSkinName ) ) { - $skinName = $betaSkinName; + // Allow overriding of skin by useskin e.g. useskin=vector=mobile + if ( $context->getRequest()->getVal( 'useskin' ) ) { + $userSkin = $mobileContext->getUser()->getOption( 'mobileskin' ); + $userSkin = $mobileContext->getRequest()->getVal( 'useskin', $userSkin ); + + // Normalize the key in case the user is passing gibberish + // or has old preferences (bug 69566). + $normalized = Skin::normalizeKey( $userSkin ); + + // Skin::normalizeKey will also validate it, so + // this won't throw an exception + $factory = SkinFactory::getDefaultInstance(); + $skin = $factory->makeSkin( $normalized ); + } else { + $skinName = $mobileContext->getMFConfig()->get( 'MFDefaultSkinClass' ); + $betaSkinName = $skinName . 'Beta'; + // Force beta for test mode to sure all modules can run + $name = $context->getTitle()->getDBkey(); + $inTestMode = + $name === SpecialPage::getTitleFor( 'JavaScriptTest', 'qunit' )->getDBkey(); + if ( $mobileContext->isBetaGroupMember() && class_exists( $betaSkinName ) ) { + $skinName = $betaSkinName; + } + $skin = new $skinName( $context ); } - $skin = new $skinName( $context ); return false; } @@ -805,22 +820,6 @@ * @return bool */ public static function onCustomEditor( $article, $user ) { - $context = MobileContext::singleton(); - - // redirect to mobile editor instead of showing desktop editor - if ( $context->shouldDisplayMobileView() && !$context->getRequest()->wasPosted() ) { - $output = $context->getOutput(); - $data = $output->getRequest()->getValues(); - // Unset these to avoid a redirect loop but make sure we pass other - // parameters to edit e.g. undo actions - unset( $data['action'] ); - unset( $data['title'] ); - - $output->redirect( SpecialPage::getTitleFor( 'MobileEditor', $article->getTitle() ) - ->getFullURL( $data ) ); - return false; - } - return true; } diff --git a/includes/Resources.php b/includes/Resources.php index e5619b1..71ed316 100644 --- a/includes/Resources.php +++ b/includes/Resources.php @@ -82,6 +82,8 @@ // T97410 is resolved. 'notifications' => 'resources/skins.minerva.icons.images/bell.svg', 'mainmenu' => 'resources/skins.minerva.icons.images/hamburger.svg', + 'edit' => 'resources/skins.minerva.icons.images/editLocked.svg', + 'edit-enabled' => 'resources/skins.minerva.icons.images/edit.svg' ) ), @@ -1425,8 +1427,6 @@
[MediaWiki-commits] [Gerrit] MobileFrontend Remove deprecated Class.extend - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/265547 Change subject: MobileFrontend Remove deprecated Class.extend .. MobileFrontend Remove deprecated Class.extend Remove all instances of Class.extend and introduces OO.mfExtend for extending modules. Bug: T123077 Change-Id: I641f9f4145b0e96b33beefcef35bc2cfa243696d --- M resources/mobile.abusefilter/AbuseFilterOverlay.js M resources/mobile.abusefilter/AbuseFilterPanel.js M resources/mobile.backtotop/BackToTopOverlay.js M resources/mobile.betaoptin/BetaOptinPanel.js M resources/mobile.categories.overlays/CategoryAddOverlay.js M resources/mobile.categories.overlays/CategoryOverlay.js M resources/mobile.commonsCategory/CommonsCategoryOverlay.js M resources/mobile.contentOverlays/PointerOverlay.js M resources/mobile.drawers/CtaDrawer.js M resources/mobile.drawers/Drawer.js M resources/mobile.editor.common/EditorOverlayBase.js M resources/mobile.editor.overlay.withtoolbar/AddReferenceOverlay.js M resources/mobile.editor.overlay.withtoolbar/EditorOverlayWithToolbar.js M resources/mobile.editor.overlay/EditorOverlay.js M resources/mobile.editor.ve/VisualEditorOverlay.js M resources/mobile.fontchanger/FontChanger.js M resources/mobile.gallery/PhotoItem.js M resources/mobile.gallery/PhotoList.js M resources/mobile.issues/CleanupOverlay.js M resources/mobile.languages/LanguageOverlay.js M resources/mobile.loggingSchemas/SchemaEdit.js M resources/mobile.loggingSchemas/SchemaMobileWebSectionUsage.js M resources/mobile.mainMenu/MainMenu.js M resources/mobile.mediaViewer.beta/ImageOverlayBeta.js M resources/mobile.mediaViewer/ImageOverlay.js M resources/mobile.messageBox/MessageBox.js M resources/mobile.nearby/Nearby.js M resources/mobile.notifications.overlay/NotificationsOverlay.js M resources/mobile.overlays/ContentOverlay.js M resources/mobile.overlays/LoadingOverlay.js M resources/mobile.overlays/Overlay.js M resources/mobile.pagelist.scripts/WatchstarPageList.js M resources/mobile.pagelist/PageList.js M resources/mobile.references/ReferencesDrawer.js M resources/mobile.search/SearchOverlay.js M resources/mobile.special.mobileoptions.scripts/mobileoptions.js M resources/mobile.startup/Anchor.js M resources/mobile.startup/Button.js M resources/mobile.startup/Icon.js M resources/mobile.startup/Page.js M resources/mobile.startup/Panel.js M resources/mobile.startup/Schema.js M resources/mobile.startup/Section.js M resources/mobile.startup/Skin.js M resources/mobile.startup/Thumbnail.js M resources/mobile.talk.overlays/TalkOverlay.js M resources/mobile.talk.overlays/TalkOverlayBase.js M resources/mobile.talk.overlays/TalkSectionAddOverlay.js M resources/mobile.talk.overlays/TalkSectionOverlay.js M resources/mobile.toc/TableOfContents.js M resources/mobile.view/View.js M resources/mobile.watchlist/WatchList.js M resources/mobile.watchstar/Watchstar.js M tests/qunit/mobile.overlays/test_Overlay.js M tests/qunit/mobile.view/test_View.js 55 files changed, 884 insertions(+), 798 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/47/265547/1 diff --git a/resources/mobile.abusefilter/AbuseFilterOverlay.js b/resources/mobile.abusefilter/AbuseFilterOverlay.js index 5bfd2cc..f649dd6 100644 --- a/resources/mobile.abusefilter/AbuseFilterOverlay.js +++ b/resources/mobile.abusefilter/AbuseFilterOverlay.js @@ -1,6 +1,5 @@ ( function ( M, $ ) { - var AbuseFilterOverlay, - Button = M.require( 'mobile.startup/Button' ), + var Button = M.require( 'mobile.startup/Button' ), Overlay = M.require( 'mobile.overlays/Overlay' ); /** @@ -9,7 +8,11 @@ * @class AbuseFilterOverlay * @extends Overlay */ - AbuseFilterOverlay = Overlay.extend( { + function AbuseFilterOverlay() { + Overlay.apply( this, arguments ); + } + + OO.mfExtend( AbuseFilterOverlay, Overlay, { /** * @inheritdoc * @cfg {Object} defaults Default options hash. diff --git a/resources/mobile.abusefilter/AbuseFilterPanel.js b/resources/mobile.abusefilter/AbuseFilterPanel.js index 9fbf3b7..f66f761 100644 --- a/resources/mobile.abusefilter/AbuseFilterPanel.js +++ b/resources/mobile.abusefilter/AbuseFilterPanel.js @@ -2,8 +2,7 @@ var View = M.require( 'mobile.view/View' ), AbuseFilterOverlay = M.require( 'mobile.abusefilter/AbuseFilterOverlay' ), - overlayManager = M.require( 'mobile.startup/overlayManager' ), - AbuseFilterPanel; + overlayManager = M.require( 'mobile.startup/overlayManager' ); /** * Panel that shows an error message related to the abusefilter extension. @@ -12,7 +11,12 @@ * @uses AbuseFilterOverlay * FIXME: should extend Panel not View. Or the name should be changed to
[MediaWiki-commits] [Gerrit] Replace deprecated 'llurl=true' with 'llprop=url' - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/264104 Change subject: Replace deprecated 'llurl=true' with 'llprop=url' .. Replace deprecated 'llurl=true' with 'llprop=url' Bug: T123631 Change-Id: Ib5336f2c65d2329c7e74167be141e521eef0d227 --- M resources/mobile.startup/PageGateway.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/04/264104/1 diff --git a/resources/mobile.startup/PageGateway.js b/resources/mobile.startup/PageGateway.js index d241153..5cfa885 100644 --- a/resources/mobile.startup/PageGateway.js +++ b/resources/mobile.startup/PageGateway.js @@ -274,7 +274,7 @@ meta: 'siteinfo', siprop: 'general|languages', prop: 'langlinks', - llurl: true, + llprop: 'url', lllimit: 'max', titles: title, formatversion: 2 -- To view, visit https://gerrit.wikimedia.org/r/264104 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib5336f2c65d2329c7e74167be141e521eef0d227 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix new collection creation - change (mediawiki...Gather)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/263849 Change subject: Fix new collection creation .. Fix new collection creation Pass mw.Api as a parameter to CollectionEditOverlay constructor during creating a new collection. Bug: T123395 Change-Id: I1aaf2bc85776d8151c53569e665b29846b202268 --- M resources/ext.gather.collections.list/CreateCollectionButton.js 1 file changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather refs/changes/49/263849/1 diff --git a/resources/ext.gather.collections.list/CreateCollectionButton.js b/resources/ext.gather.collections.list/CreateCollectionButton.js index e5f1ccd..e92eaaf 100644 --- a/resources/ext.gather.collections.list/CreateCollectionButton.js +++ b/resources/ext.gather.collections.list/CreateCollectionButton.js @@ -40,7 +40,8 @@ ev.preventDefault(); editOverlay = new CollectionEditOverlay( { skin: this.options.skin, - reloadOnSave: true + reloadOnSave: true, + api: new mw.Api() } ); editOverlay.show(); } -- To view, visit https://gerrit.wikimedia.org/r/263849 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1aaf2bc85776d8151c53569e665b29846b202268 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: dev Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Enable skipped router tests - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/260330 Change subject: Enable skipped router tests .. Enable skipped router tests Refactor Router.js to include a 'testHash' for testing and decouple test_Router.js from window, and instead use this 'testHash'. Bug: T98731 Change-Id: I8c089700b1280b64d180de0f78630654a9dbdccf --- M resources/mobile.startup/Router.js M tests/qunit/mobile.startup/test_Router.js 2 files changed, 58 insertions(+), 42 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/30/260330/1 diff --git a/resources/mobile.startup/Router.js b/resources/mobile.startup/Router.js index 865fda7..5e9d7d8 100644 --- a/resources/mobile.startup/Router.js +++ b/resources/mobile.startup/Router.js @@ -35,12 +35,18 @@ this.routes = {}; this._enabled = true; this._oldHash = this.getPath(); + // custom hash, only use with tests + this.testHash = ''; $( window ).on( 'popstate', function () { self.emit( 'popstate' ); } ); $( window ).on( 'hashchange', function () { + self.emit( 'hashchange' ); + } ); + + this.on( 'hashchange', function(){ // ev.originalEvent.newURL is undefined on Android 2.x var routeEv; @@ -56,7 +62,7 @@ // if route was prevented, ignore the next hash change and revert the // hash to its old value self._enabled = false; - window.location.hash = self._oldHash; + self.navigate( self._oldHash ); } } else { self._enabled = true; @@ -117,6 +123,22 @@ }; /** +* Sets the current hash of the router. +* Note that this method is only for setting hash during tests +* @param {String} hash Current hash in the test +*/ + Router.prototype.setHash = function( hash ) { + this.testHash = hash; + } + + /** +* Triggers back on the window +*/ + Router.prototype.goBack = function() { + window.history.back(); + } + + /** * Navigate to the previous route. This is a wrapper for window.history.back * @method * @return {jQuery.Deferred} @@ -131,7 +153,7 @@ deferredRequest.resolve(); } ); - window.history.back(); + this.goBack(); // If for some reason (old browser, bug in IE/windows 8.1, etc) popstate doesn't fire, // resolve manually. Since we don't know for sure which browsers besides IE10/11 have diff --git a/tests/qunit/mobile.startup/test_Router.js b/tests/qunit/mobile.startup/test_Router.js index 89b06c8..941e959 100644 --- a/tests/qunit/mobile.startup/test_Router.js +++ b/tests/qunit/mobile.startup/test_Router.js @@ -3,54 +3,44 @@ hashQueue = [], interval, router; - // we can't change hash too quickly because hashchange callbacks are async - // (don't fire immediately after the hash is changed) and all the callbacks - // would get the same (latest) hash; see setup and teardown too - function setHash( hash ) { - hashQueue.push( hash ); - } - QUnit.module( 'MobileFrontend Router', { setup: function () { router = new Router(); - interval = setInterval( function () { - var hash = hashQueue.pop(); - if ( hash !== undefined ) { - window.location.hash = hash; - } - }, 10 ); + this.stub( router, 'getPath', function(){ + return router.testHash.slice(1); + } ); + this.stub( router, 'navigate', function( path ){ + router.setHash( path ) + } ); }, teardown: function () { - // hashchange is async, we need to wait - $( window ).one( 'hashchange.test', function () { - $( window ).off( 'hashchange.test' ); - clearInterval( interval ); - QUnit.start(); - } ); - setHash( '' ); - QUnit.stop(); +
[MediaWiki-commits] [Gerrit] MF restrict max width on Special:Contributions - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/259461 Change subject: MF restrict max width on Special:Contributions .. MF restrict max width on Special:Contributions Bug: T121577 Change-Id: I13cd865e2691147ccf3c914b5984088ba0ae9b9b --- M includes/specials/SpecialMobileContributions.php 1 file changed, 2 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/61/259461/1 diff --git a/includes/specials/SpecialMobileContributions.php b/includes/specials/SpecialMobileContributions.php index ea12f67..e7de584 100644 --- a/includes/specials/SpecialMobileContributions.php +++ b/includes/specials/SpecialMobileContributions.php @@ -68,7 +68,9 @@ $this->renderHeaderBar( $this->user->getUserPage() ); } $res = $this->doQuery(); + $out->addHtml( Html::openElement( 'div', array( 'class' => 'content-unstyled' ) ) ); $this->showContributions( $res ); + $out->addHtml( Html::closeElement( 'div' ) ); return; } } -- To view, visit https://gerrit.wikimedia.org/r/259461 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I13cd865e2691147ccf3c914b5984088ba0ae9b9b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] MobileFrontend mw.notification instead of toast - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/258969 Change subject: MobileFrontend mw.notification instead of toast .. MobileFrontend mw.notification instead of toast Makes MobileFrontend use mw.notification for toast notifications. This change includes: * Removing toastDrawer. * Using toast.js as a gateway to access mw.notification. * Change toast.less to override mw.notification.css with same class names, but styles suited for minerva. Bug: T116555 Change-Id: I25669d8a28c8419534bbd3524ba1777e556a74cc --- M includes/Resources.php M resources/mobile.categories.overlays/CategoryAddOverlay.js M resources/mobile.editor.common/EditorOverlayBase.js M resources/mobile.talk.overlays/TalkSectionAddOverlay.js M resources/mobile.talk.overlays/TalkSectionOverlay.js D resources/mobile.toast/ToastDrawer.js M resources/mobile.toast/toast.js M resources/mobile.toast/toast.less M resources/skins.minerva.editor/init.js M resources/skins.minerva.scripts/mobileRedirect.js M tests/qunit/mobile.editor.overlay/test_EditorOverlay.js 11 files changed, 41 insertions(+), 96 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/69/258969/1 diff --git a/includes/Resources.php b/includes/Resources.php index 5bdd878..424348c 100644 --- a/includes/Resources.php +++ b/includes/Resources.php @@ -887,11 +887,7 @@ ), 'mobile.toast' => $wgMFResourceFileModuleBoilerplate + array( - 'dependencies' => array( - 'mobile.drawers', - ), 'scripts' => array( - 'resources/mobile.toast/ToastDrawer.js', 'resources/mobile.toast/toast.js', ), 'skinStyles' => array( diff --git a/resources/mobile.categories.overlays/CategoryAddOverlay.js b/resources/mobile.categories.overlays/CategoryAddOverlay.js index 573aff9..0ec77ae 100644 --- a/resources/mobile.categories.overlays/CategoryAddOverlay.js +++ b/resources/mobile.categories.overlays/CategoryAddOverlay.js @@ -120,7 +120,7 @@ // if there are no categories added, don't do anything (the user shouldn't see the save button) if ( newCategories.length === 0 ) { - toast.show( mw.msg( 'mobile-frontend-categories-nodata' ), 'toast error' ); + toast.show( mw.msg( 'mobile-frontend-categories-nodata' ), 'error' ); } else { // save the new categories this.gateway.save( this.title, newCategories ).done( function () { diff --git a/resources/mobile.editor.common/EditorOverlayBase.js b/resources/mobile.editor.common/EditorOverlayBase.js index a9d22ef..a71f02b 100644 --- a/resources/mobile.editor.common/EditorOverlayBase.js +++ b/resources/mobile.editor.common/EditorOverlayBase.js @@ -214,7 +214,7 @@ * @param {String} text Text of message to display to user */ reportError: function ( text ) { - toast.show( text, 'toast error' ); + toast.show( text, 'error' ); }, /** * Prepares the penultimate screen before saving. diff --git a/resources/mobile.talk.overlays/TalkSectionAddOverlay.js b/resources/mobile.talk.overlays/TalkSectionAddOverlay.js index 6196e02..80a1f4d 100644 --- a/resources/mobile.talk.overlays/TalkSectionAddOverlay.js +++ b/resources/mobile.talk.overlays/TalkSectionAddOverlay.js @@ -3,6 +3,7 @@ toast = M.require( 'mobile.toast/toast' ), Icon = M.require( 'mobile.startup/Icon' ), TalkSectionAddOverlay; + mw.loader.load( 'mediawiki.notification' ); /** * Overlay for adding a talk section @@ -58,6 +59,7 @@ this.$confirm = this.$( 'button.confirm-save' ); this.$subject = this.$( '.summary' ); this.$ta = this.$( '.wikitext-editor' ); + toast.show( mw.msg( 'mobile-frontend-talk-topic-feedback' ) ); }, /** @inheritdoc */ hide: function () { @@ -98,7 +100,7 @@ // Check if the user was previously on the talk overlay if ( self.title !== mw.config.get( 'wgPageName' ) ) { self.pageGateway.invalidatePage( self.title ); - toast.show( mw.msg( 'mobile-frontend-talk-topic-feedback' ), 'toast' ); + toast.show( mw.msg( 'mobile-frontend-talk-topic-feedback' ) ); M.emit( 'talk-discussion-added' );
[MediaWiki-commits] [Gerrit] MobileFrontend fix back on Special:Nearby - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/258476 Change subject: MobileFrontend fix back on Special:Nearby .. MobileFrontend fix back on Special:Nearby Fixes back on browser from an article reached via Special:Nearby/#page/Page_Title Bug: T117412 Change-Id: I1b9574b24d2a12fe942da7ecbe5d7a62b8508bbf --- M resources/mobile.nearby/Nearby.js 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/76/258476/1 diff --git a/resources/mobile.nearby/Nearby.js b/resources/mobile.nearby/Nearby.js index 11f3156..438f605 100644 --- a/resources/mobile.nearby/Nearby.js +++ b/resources/mobile.nearby/Nearby.js @@ -229,7 +229,10 @@ // FIXME: not unique if multiple Nearby objects on same page $( this ).attr( 'id', 'nearby-page-list-item-' + i ); } ).on( 'click', function () { - window.location.hash = $( this ).attr( 'id' ); + // if not on Special:Nearby/#page/page_title, then set hash to clicked element + if ( hash.indexOf( '#' ) === -1 ) { + window.location.hash = hash + '#' + $( this ).attr( 'id' ); + } } ); // Restore the offset -- To view, visit https://gerrit.wikimedia.org/r/258476 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1b9574b24d2a12fe942da7ecbe5d7a62b8508bbf Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB fix inconsistent ImageDisabled test - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/258511 Change subject: WPB fix inconsistent ImageDisabled test .. WPB fix inconsistent ImageDisabled test Use reflection class to set disableImages variable which is used for testimg against images disabled feature. Bug: T121066 Change-Id: Ifb183abf2af2629350e855199509b435686baf58 --- M tests/phpunit/BannerMFTest.php 1 file changed, 38 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/11/258511/1 diff --git a/tests/phpunit/BannerMFTest.php b/tests/phpunit/BannerMFTest.php index 7811a74..6702b99 100644 --- a/tests/phpunit/BannerMFTest.php +++ b/tests/phpunit/BannerMFTest.php @@ -8,16 +8,10 @@ */ class BannerMFTest extends MediaWikiTestCase { /** -* Stores the original value for disableImages cookie +* Stores the original value for MobileContext * @var bool $oldDisableImages; */ - private $oldDisableImages; - - /** -* Stores the original value for forcedMobileView -* @var bool $oldForceMobile; -*/ - private $oldForceMobileView; + private static $oldMobileContext = null; /** * Add test pages to database @@ -35,11 +29,15 @@ protected function setUp() { parent::setUp(); if ( class_exists( 'MobileContext' ) ) { - $mobileContext = MobileContext::singleton(); - $this->oldDisableImages = $mobileContext->imagesDisabled(); - $this->oldForceMobileView = $mobileContext->getForceMobileView(); - $mobileContext->setDisableImagesCookie( true ); + self::$oldMobileContext = MobileContext::singleton(); + $mobileContext = $this->makeContext(); $mobileContext->setForceMobileView( true ); + MobileContext::setInstance( $mobileContext ); + // set protected disableImages property to true, so that we can simulate images disabled + $reflectionClass = new ReflectionClass('MobileContext'); + $reflectionProperty = $reflectionClass->getProperty('disableImages'); + $reflectionProperty->setAccessible( true ); + $reflectionProperty->setValue( $mobileContext, true ); } $this->addDBData(); $this->setMwGlobals( 'wgWPBImage', "DefaultBanner" ); @@ -48,9 +46,8 @@ protected function tearDown() { if ( class_exists( 'MobileContext' ) ) { - $mobileContext = MobileContext::singleton(); - $mobileContext->setDisableImagesCookie( $this->oldDisableImages ); - $mobileContext->setForceMobileView( $this->oldForceMobileView ); + // restore old mobile context class + $mobileContext = MobileContext::setInstance( self::$oldMobileContext ); } parent::tearDown(); } @@ -83,4 +80,30 @@ $out->setArticleFlag( true ); return $out; } + + /** +* @param string $url +* @param array $cookies +* @return MobileContext +*/ + private function makeContext( $url = '/', $cookies = array() ) { + $query = array(); + if ( $url ) { + $params = wfParseUrl( wfExpandUrl( $url ) ); + if ( isset( $params['query'] ) ) { + $query = wfCgiToArray( $params['query'] ); + } + } + + $request = new FauxRequest( array() ); + $request->setRequestURL( $url ); + $request->setCookies( $cookies, '' ); + + $context = new DerivativeContext( RequestContext::getMain() ); + $context->setRequest( $request ); + $context->setOutput( new OutputPage( $context ) ); + $instance = unserialize( 'O:13:"MobileContext":0:{}' ); + $instance->setContext( $context ); + return $instance; + } } -- To view, visit https://gerrit.wikimedia.org/r/258511 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifb183abf2af2629350e855199509b435686baf58 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] BetaFeatures only add whitelisted preferences - change (mediawiki...BetaFeatures)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/258418 Change subject: BetaFeatures only add whitelisted preferences .. BetaFeatures only add whitelisted preferences Check if a preference is whitelisted irrespective of its dependency specifications, before displaying it. Bug: T121182 Change-Id: I7e0ab007933a096ac6bb8eda211622c9b138e217 --- M BetaFeaturesHooks.php 1 file changed, 15 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BetaFeatures refs/changes/18/258418/1 diff --git a/BetaFeaturesHooks.php b/BetaFeaturesHooks.php index 3b3b835..584b8b1 100644 --- a/BetaFeaturesHooks.php +++ b/BetaFeaturesHooks.php @@ -141,12 +141,10 @@ // This complex structure brought to you by Per-Wiki Configuration, // coming soon to a wiki very near you. Hooks::run( 'GetBetaFeatureDependencyHooks', array( &$depHooks ) ); - $saveUser = false; $autoEnrollAll = $user->getOption( 'betafeatures-auto-enroll' ) === HTMLFeatureField::OPTION_ENABLED; $autoEnroll = array(); - foreach ( $betaPrefs as $key => $info ) { if ( isset( $info['auto-enrollment'] ) ) { $autoEnroll[$info['auto-enrollment']] = $key; @@ -154,22 +152,25 @@ } foreach ( $betaPrefs as $key => $info ) { + $success = true; + // check if dependencies are met if ( isset( $info['dependent'] ) && $info['dependent'] === true ) { - $success = true; - - if ( - is_array( $wgBetaFeaturesWhitelist ) && - !in_array( $key, $wgBetaFeaturesWhitelist ) - ) { - $success = false; - } elseif ( isset( $depHooks[$key] ) ) { + if ( isset( $depHooks[$key] ) ) { $success = Hooks::run( $depHooks[$key] ); } + } - if ( $success !== true ) { - // Skip this preference! - continue; - } + // check if feature is whitelisted + if ( + is_array( $wgBetaFeaturesWhitelist ) && + !in_array( $key, $wgBetaFeaturesWhitelist ) + ) { + $success = false; + } + + if ( $success !== true ) { + // Skip this preference! + continue; } $opt = array( -- To view, visit https://gerrit.wikimedia.org/r/258418 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7e0ab007933a096ac6bb8eda211622c9b138e217 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/BetaFeatures Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] MobileFrontend allow anons to see per user uploads - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/257588 Change subject: MobileFrontend allow anons to see per user uploads .. MobileFrontend allow anons to see per user uploads Removes the need to login for anons to see urls of the form Special:Uploads/username, i.e., per user uploads. Bug: T109894 Change-Id: Ie927242f805ba86d53f86a369b2209e12c27c0e1 --- M includes/specials/SpecialUploads.php 1 file changed, 25 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/88/257588/1 diff --git a/includes/specials/SpecialUploads.php b/includes/specials/SpecialUploads.php index 733a455..16dc416 100644 --- a/includes/specials/SpecialUploads.php +++ b/includes/specials/SpecialUploads.php @@ -21,34 +21,36 @@ * @param string|null $par Username to get uploads from */ public function executeWhenAvailable( $par = '' ) { - // Anons don't get to see this page - $this->requireLogin( 'mobile-frontend-donate-image-anon' ); + if ( ( $par === '' || $par === null ) && $this->getUser()->isAnon() ) { + // Anons don't get to see this page + $this->requireLogin( 'mobile-frontend-donate-image-anon' ); + } else { + $this->setHeaders(); + $output = $this->getOutput(); + $output->addJsConfigVars( + 'wgMFPhotoUploadEndpoint', + $this->getMFConfig()->get( 'MFPhotoUploadEndpoint' ) + ); + $output->setPageTitle( $this->msg( 'mobile-frontend-donate-image-title' ) ); - $this->setHeaders(); - $output = $this->getOutput(); - $output->addJsConfigVars( - 'wgMFPhotoUploadEndpoint', - $this->getMFConfig()->get( 'MFPhotoUploadEndpoint' ) - ); - $output->setPageTitle( $this->msg( 'mobile-frontend-donate-image-title' ) ); - - if ( $par !== '' && $par !== null ) { - $user = User::newFromName( $par ); - if ( !$user || $user->isAnon() ) { - $output->setStatusCode( 404 ); - $html = MobileUI::contentElement( - MobileUI::errorBox( - $this->msg( 'mobile-frontend-photo-upload-invalid-user', $par )->parse() ) - ); + if ( $par !== '' && $par !== null ) { + $user = User::newFromName( $par ); + if ( !$user || $user->isAnon() ) { + $output->setStatusCode( 404 ); + $html = MobileUI::contentElement( + MobileUI::errorBox( + $this->msg( 'mobile-frontend-photo-upload-invalid-user', $par )->parse() ) + ); + } else { + $html = $this->getUserUploadsPageHtml( $user ); + } } else { + $user = $this->getUser(); + // TODO: what if the user cannot upload to the destination wiki in $wgMFPhotoUploadEndpoint? $html = $this->getUserUploadsPageHtml( $user ); } - } else { - $user = $this->getUser(); - // TODO: what if the user cannot upload to the destination wiki in $wgMFPhotoUploadEndpoint? - $html = $this->getUserUploadsPageHtml( $user ); + $output->addHTML( $html ); } - $output->addHTML( $html ); } /** * Generates HTML for the uploads page for the passed user. -- To view, visit https://gerrit.wikimedia.org/r/257588 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie927242f805ba86d53f86a369b2209e12c27c0e1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] RelatedArticles load after half window scroll - change (mediawiki...RelatedArticles)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/257069 Change subject: RelatedArticles load after half window scroll .. RelatedArticles load after half window scroll Only triggers RelatedArticles module load and query after user has scrolled through half the document height. Bug: T116838 Change-Id: If290988fb7cc187cad37dd4a8a2c4f38abed9bb9 --- M resources/ext.relatedArticles.readMore.bootstrap/index.js 1 file changed, 18 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedArticles refs/changes/69/257069/1 diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js b/resources/ext.relatedArticles.readMore.bootstrap/index.js index 3cd056e..ff72cd6 100644 --- a/resources/ext.relatedArticles.readMore.bootstrap/index.js +++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js @@ -9,24 +9,31 @@ mw.config.get( 'wgRelatedArticlesOnlyUseCirrusSearch' ) ), LIMIT = 3; - if ( config.wgNamespaceNumber === 0 && !config.wgIsMainPage && // any skin except minerva stable ( config.skin !== 'minerva' || config.wgMFMode === 'beta' ) ) { - $.when( - // Note we load dependencies here rather than ResourceLoader - // to avoid PHP exceptions when Cards not installed - // which should never happen given the if statement. - mw.loader.using( [ 'ext.cards', 'ext.relatedArticles.readMore' ] ), - relatedPages.getForCurrentPage( LIMIT ) - ).done( function ( _, pages ) { - if ( pages.length ) { - mw.track( 'ext.relatedArticles.init', pages ); + config.relatedPagesShown = false; + // load related articles after half article read + $( window ).on( 'scroll', $.debounce( 100, function() { + if ( $( window ).scrollTop() > $( document ).height() / 2 && + config.relatedPagesShown === false ) { + $.when( + // Note we load dependencies here rather than ResourceLoader + // to avoid PHP exceptions when Cards not installed + // which should never happen given the if statement. + mw.loader.using( [ 'ext.cards', 'ext.relatedArticles.readMore' ] ), + relatedPages.getForCurrentPage( LIMIT ) + ).done( function ( _, pages ) { + if ( pages.length ) { + mw.track( 'ext.relatedArticles.init', pages ); + } + } ); + config.relatedPagesShown = true; } - } ); + } ) ); } }( jQuery ) ); -- To view, visit https://gerrit.wikimedia.org/r/257069 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If290988fb7cc187cad37dd4a8a2c4f38abed9bb9 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/RelatedArticles Gerrit-Branch: dev Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Convert title to its language variant - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/256664 Change subject: Convert title to its language variant .. Convert title to its language variant The title rendered on the banner is first converted to its Language variant using LanguageConverter::convertTitle(). Bug: T114734 Change-Id: I77e135386eb863ff594fdc9573ee21859ef5d3d6 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/64/256664/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 572144d..7b5144d 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -242,8 +242,11 @@ self::addBadParserFunctionArgsWarning( $argumentsFromParserFunction, $parser ); // set title and tooltip attribute to default title - $paramsForBannerTemplate['tooltip'] = $title->getText(); - $paramsForBannerTemplate['title'] = $title->getText(); + // convert title to language variant as done in core Parser.php + $paramsForBannerTemplate['tooltip'] = $parser->getConverterLanguage() + ->convertTitle( $title ); + $paramsForBannerTemplate['title'] = $parser->getConverterLanguage() + ->convertTitle( $title ); if ( isset( $argumentsFromParserFunction['pgname'] ) ) { // set tooltip attribute to parameter 'pgname', if set $paramsForBannerTemplate['tooltip'] = $argumentsFromParserFunction['pgname']; -- To view, visit https://gerrit.wikimedia.org/r/256664 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I77e135386eb863ff594fdc9573ee21859ef5d3d6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Save banner properties in page_props for api use - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/256409 Change subject: Save banner properties in page_props for api use .. Save banner properties in page_props for api use Set valid banner 'name' and banner 'focus' from parser hook in page_props table. Store 'wpb-banner-options' array using ParserOutput::setExtensionData() as it is only being used programatically by the extension. Bug: T118937 Change-Id: I14df56e8907d1398e40c552c1eb2b9d8d2120abc --- M includes/WikidataPageBanner.hooks.php M tests/phpunit/BannerOptionsTest.php M tests/phpunit/BannerTest.php 3 files changed, 20 insertions(+), 15 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/09/256409/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 572144d..95df5a6 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -152,8 +152,8 @@ * @param ParserOutput $pOut */ public static function onOutputPageParserOutput( OutputPage $out, ParserOutput $pOut ) { - if ( $pOut->getProperty( 'wpb-banner-options' ) != null ) { - $options = $pOut->getProperty( 'wpb-banner-options' ); + if ( $pOut->getExtensionData( 'wpb-banner-options' ) != null ) { + $options = $pOut->getExtensionData( 'wpb-banner-options' ); // if toc parameter set and toc enabled, remove original classes and add banner class if ( isset( $options['enable-toc'] ) && $pOut->getTOCEnabled() ) { @@ -267,7 +267,7 @@ $argumentsFromParserFunction ); $paramsForBannerTemplate['name'] = $bannername; // Set 'wpb-banner-options' property for generating banner later - $parser->getOutput()->setProperty( 'wpb-banner-options', $paramsForBannerTemplate ); + $parser->getOutput()->setExtensionData( 'wpb-banner-options', $paramsForBannerTemplate ); // add the valid banner to image links // @FIXME:Since bannernames which are to be added are generated here, getBannerHtml can @@ -282,8 +282,13 @@ } elseif ( $wpbFunctionsClass::getImageUrl( $wikidataBanner ) !== null ) { $bannerTitle = Title::makeTitleSafe( NS_FILE, $wikidataBanner ); } + // add custom or wikidata banner properties to page_props table if a valid banner exists + // in, checking for custom banner first, then wikidata banner if ( $bannerTitle !== null ) { $parser->fetchFileAndTitle( $bannerTitle ); + $parser->getOutput()->setProperty( 'wpb_banner', $bannerTitle->getText() ); + $parser->getOutput()->setProperty( 'wpb_banner_focus_x', $paramsForBannerTemplate['data-pos-x'] ); + $parser->getOutput()->setProperty( 'wpb_banner_focus_y', $paramsForBannerTemplate['data-pos-y'] ); } } } diff --git a/tests/phpunit/BannerOptionsTest.php b/tests/phpunit/BannerOptionsTest.php index 6d7cc31..4ccb887 100644 --- a/tests/phpunit/BannerOptionsTest.php +++ b/tests/phpunit/BannerOptionsTest.php @@ -47,7 +47,7 @@ WikidataPageBanner::addCustomBanner( $parser, 'Banner1' ); $pOut = $parser->getOutput(); - $bannerparams = $pOut->getProperty( 'wpb-banner-options' ); + $bannerparams = $pOut->getExtensionData( 'wpb-banner-options' ); $this->assertEquals( $bannerparams['title'], 'BannerWithOptions', 'pgname must be set to title' ); $this->assertEquals( $bannerparams['tooltip'], 'BannerWithOptions', @@ -57,7 +57,7 @@ $pOut->setProperty( 'wpb-banner-options', null ); WikidataPageBanner::addCustomBanner( $parser, 'Banner1', 'pgname=Banner2' ); - $bannerparams = $pOut->getProperty( 'wpb-banner-options' ); + $bannerparams = $pOut->getExtensionData( 'wpb-banner-options' ); $this->assertEquals( $bannerparams['title'], 'Banner2', 'pgname must be set' ); $this->assertEquals( $bannerparams['tooltip'], 'Banner2', @@ -67,7 +67,7 @@ $pOut->setProperty( 'wpb-banner-options', null ); WikidataPageBanner::addCustomBanner( $parser, 'Banner1', 'pgname=Banner2', 'tooltip=hovertext' ); - $bannerparams = $pOut->getProperty( 'wpb-banner-options' ); +
[MediaWiki-commits] [Gerrit] TextExtracts do not crop after initials - change (mediawiki...TextExtracts)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/255959 Change subject: TextExtracts do not crop after initials .. TextExtracts do not crop after initials Disables sentence termination at a full stop preceeded by a capital alphabet which is likely to be an initial. Bug: T115795 Change-Id: Ibf38e87823155c704ffb106642944cbd05e3f632 --- M includes/ExtractFormatter.php M tests/ExtractFormatterTest.php 2 files changed, 2 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts refs/changes/59/255959/1 diff --git a/includes/ExtractFormatter.php b/includes/ExtractFormatter.php index a6581f3..01b16eb 100644 --- a/includes/ExtractFormatter.php +++ b/includes/ExtractFormatter.php @@ -80,7 +80,7 @@ public static function getFirstSentences( $text, $requestedSentenceCount ) { // Based on code from OpenSearchXml by Brion Vibber $endchars = array( - '\.\s', '\!\s', '\?\s', // regular ASCII + '[^A-Z]\.\s', '\!\s', '\?\s', // regular ASCII '。', // full-width ideographic full-stop '.', '!', '?', // double-width roman forms '。', // half-width ideographic full stop diff --git a/tests/ExtractFormatterTest.php b/tests/ExtractFormatterTest.php index 227f95c..eaf85be 100644 --- a/tests/ExtractFormatterTest.php +++ b/tests/ExtractFormatterTest.php @@ -109,12 +109,11 @@ 1, 'Foo was born in 1977.', ), - /* @fixme array( 'P.J. Harvey is a singer. She is awesome!', 1, 'P.J. Harvey is a singer.', - ),*/ + ), ); } -- To view, visit https://gerrit.wikimedia.org/r/255959 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibf38e87823155c704ffb106642944cbd05e3f632 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TextExtracts Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB show no banner when images disabled - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/255940 Change subject: WPB show no banner when images disabled .. WPB show no banner when images disabled Turns off pagebanner when using skin minerva with images disabled. Bug: T107368 Change-Id: If4aa5110ad51258ea4a147e46b531e719fe49363 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 5 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/40/255940/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index f8cbb25..45834d3 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -73,6 +73,11 @@ * @return bool */ public static function addBanner( OutputPage $out, Skin $skin ) { + // if images are disabled on Minerva skin, then do nothing + if ( $skin->getSkinName() === 'minerva' && + (bool)$out->getRequest()->getCookie( 'disableImages' ) === true ) { + return true; + } $config = WikidataPageBannerFunctions::getWPBConfig(); $title = $out->getTitle(); $isDiff = $out->getRequest()->getVal( 'diff' ); -- To view, visit https://gerrit.wikimedia.org/r/255940 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If4aa5110ad51258ea4a147e46b531e719fe49363 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] TextExtracts allow sentence end with numbers - change (mediawiki...TextExtracts)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/253834 Change subject: TextExtracts allow sentence end with numbers .. TextExtracts allow sentence end with numbers Allows sentences to end with numbers before a full stop in query extractsentences. Bug: T115795 Change-Id: I9cbf487601d4165b490696d38d5fcbcf6d8f4637 --- M includes/ExtractFormatter.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TextExtracts refs/changes/34/253834/1 diff --git a/includes/ExtractFormatter.php b/includes/ExtractFormatter.php index 689fd84..a6581f3 100644 --- a/includes/ExtractFormatter.php +++ b/includes/ExtractFormatter.php @@ -80,7 +80,7 @@ public static function getFirstSentences( $text, $requestedSentenceCount ) { // Based on code from OpenSearchXml by Brion Vibber $endchars = array( - '([^\d])\.\s', '\!\s', '\?\s', // regular ASCII + '\.\s', '\!\s', '\?\s', // regular ASCII '。', // full-width ideographic full-stop '.', '!', '?', // double-width roman forms '。', // half-width ideographic full stop -- To view, visit https://gerrit.wikimedia.org/r/253834 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9cbf487601d4165b490696d38d5fcbcf6d8f4637 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TextExtracts Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add a separate flag for toc - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/248277 Change subject: WikidataPageBanner add a separate flag for toc .. WikidataPageBanner add a separate flag for toc This will prevent setting the actual toc with true, which results in rendering of 1 in place of actual toc. Bug: T115719 Change-Id: Iac3f17a0223e3a9d06d5a026ffc20d02eddfef3e --- M includes/WikidataPageBanner.functions.php M includes/WikidataPageBanner.hooks.php 2 files changed, 2 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/77/248277/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index b6cb2f4..8865e59 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -22,7 +22,7 @@ */ public static function addToc( &$paramsForBannerTemplate, $options ) { if ( isset( $options['toc'] ) && $options['toc'] === 'yes' ) { - $paramsForBannerTemplate['toc'] = true; + $paramsForBannerTemplate['enable-toc'] = true; } } diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index bed606a..f8cbb25 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -150,7 +150,7 @@ $options = $pOut->getProperty( 'wpb-banner-options' ); // if toc parameter set and toc enabled, remove original classes and add banner class - if ( isset( $options['toc'] ) && $pOut->getTOCEnabled() ) { + if ( isset( $options['enable-toc'] ) && $pOut->getTOCEnabled() ) { $options['toc'] = $pOut->getTOCHTML(); // replace id and class of toc with blank // FIXME! This code is hacky, until core has better handling of toc contents -- To view, visit https://gerrit.wikimedia.org/r/248277 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iac3f17a0223e3a9d06d5a026ffc20d02eddfef3e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Gather sort single user lists by time - change (mediawiki...Gather)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/240975 Change subject: Gather sort single user lists by time .. Gather sort single user lists by time Sort lists of a single user with last modified list first. Bug: T94762 Change-Id: I8ea4520b5ec46dfa86526f28149ccee4becb80db --- M includes/api/ApiQueryLists.php 1 file changed, 3 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather refs/changes/75/240975/1 diff --git a/includes/api/ApiQueryLists.php b/includes/api/ApiQueryLists.php index e732f44..2b50dac 100644 --- a/includes/api/ApiQueryLists.php +++ b/includes/api/ApiQueryLists.php @@ -122,7 +122,7 @@ } else { $this->addFields( array( 'isWl' => "gl_label=''" ) ); } - $this->addFieldsIf( 'gl_updated', $fld_updated || $mode ); + $this->addFieldsIf( 'gl_updated', $fld_updated || $mode || $fld_owner || $owner ); $this->addFieldsIf( 'gl_perm', $fld_public ); $this->addFieldsIf( 'gl_perm_override', $fld_public ); $this->addFieldsIf( 'gl_flag_count', $fld_public ); @@ -243,9 +243,9 @@ return "{$row->gl_user}|{$row->gl_label}"; }; } else { - $this->addOption( 'ORDER BY', 'gl_label' ); + $this->addOption( 'ORDER BY', 'gl_updated DESC, gl_id DESC' ); $getContinueEnumParameter = function( $row ) { - return $row->gl_label; + return "{$row->gl_updated}|{$row->gl_id}"; }; } -- To view, visit https://gerrit.wikimedia.org/r/240975 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8ea4520b5ec46dfa86526f28149ccee4becb80db Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner set focus after banner load - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/236735 Change subject: WikidataPageBanner set focus after banner load .. WikidataPageBanner set focus after banner load Trigger positionBanner() after banner image has loaded. Also reset margin in positionBanner() before setting new focus values, so that focus is not affected by previously set margins. Bug: T111710 Change-Id: I21fbf96b5c558afd19a2374d7eb942020860fc0a --- M resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js 1 file changed, 7 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/35/236735/1 diff --git a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js index d5b8692..4354935 100644 --- a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js +++ b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js @@ -18,7 +18,9 @@ transform: 'translate(0)', MozTransform: 'translate(0)', WebkitTransform: 'translate(0)', - msTransform: 'translate(0)' + msTransform: 'translate(0)', + 'margin-left': 0, + 'margin-top': 0 } ); // Adjust vertical focus if ( $wpbBannerImage.height() > $container.height() ) { @@ -66,7 +68,10 @@ positionBanner( $wpbBannerImageContainer ); } ) ); - positionBanner( $wpbBannerImageContainer ); + // set focus after image has loaded + $( 'img.wpb-banner-image' ).load( function() { + positionBanner( $wpbBannerImageContainer ); + } ); // Expose interface for testing. mw.wpb = { positionBanner: positionBanner -- To view, visit https://gerrit.wikimedia.org/r/236735 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I21fbf96b5c558afd19a2374d7eb942020860fc0a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB title should use Mediawiki:Pagetitle - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/236250 Change subject: WPB title should use Mediawiki:Pagetitle .. WPB title should use Mediawiki:Pagetitle WikidataPageBanner should use Mediawiki:Pagetitle to set the title page instead of only using $out->getTitle() Bug: T111593 Change-Id: I3c95aa2b8a53e2feecf2351b9bc15e5ed05076a4 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/50/236250/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index ba7d5f2..ea7b4bb 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -44,7 +44,10 @@ $out->prependHtml( $banner ); // hide primary title $out->setPageTitle( '' ); - $out->setHTMLTitle( $out->getTitle() ); + $out->setHTMLTitle( + $out->msg( 'pagetitle' )->rawParams( $out->getTitle() ) + ->inContentLanguage() + ); // set articlebanner property on OutputPage // FIXME: This is currently only needed to support testing $out->setProperty( 'articlebanner', $bannername ); -- To view, visit https://gerrit.wikimedia.org/r/236250 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3c95aa2b8a53e2feecf2351b9bc15e5ed05076a4 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner disable on diff pages - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/235492 Change subject: WikidataPageBanner disable on diff pages .. WikidataPageBanner disable on diff pages Show no banner when viewing a diff of a page. Bug: T110384 Change-Id: I922921142af086402a685078860760351243efcd --- M includes/WikidataPageBanner.hooks.php 1 file changed, 4 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/92/235492/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 4137b0c..ba7d5f2 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -21,8 +21,9 @@ public static function addBanner( OutputPage $out ) { global $wgWPBImage, $wgWPBNamespaces, $wgWPBEnableDefaultBanner; $title = $out->getTitle(); - // if banner-options are set, add banner anyway - if ( $out->getProperty( 'wpb-banner-options' ) !== null ) { + $isDiff = $out->getRequest()->getVal( 'diff' ); + // if banner-options are set and not a diff page, add banner anyway + if ( $out->getProperty( 'wpb-banner-options' ) !== null && !$isDiff ) { $params = $out->getProperty( 'wpb-banner-options' ); $bannername = $params['name']; $out->enableOOUI(); @@ -50,7 +51,7 @@ } } // if the page uses no 'PAGEBANNER' invocation and if article page, insert default banner - elseif ( $title->isKnown() && $out->isArticle() && $wgWPBEnableDefaultBanner ) { + elseif ( $title->isKnown() && $out->isArticle() && $wgWPBEnableDefaultBanner && !$isDiff ) { $ns = $title->getNamespace(); // banner only on specified namespaces, and not Main Page of wiki if ( in_array( $ns, $wgWPBNamespaces ) -- To view, visit https://gerrit.wikimedia.org/r/235492 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I922921142af086402a685078860760351243efcd Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner make links row selectable - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/235041 Change subject: WikidataPageBanner make links row selectable .. WikidataPageBanner make links row selectable Add text decoration on dropdown link on hovering over 'li' row item. Currently text decorates only on hovering over itself. Bug: T110785 Change-Id: I0221fe2861b56d666d74f419aff435eab49dad69 --- M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less 1 file changed, 5 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/41/235041/1 diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less index 062f367..8ffd817 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less @@ -49,10 +49,6 @@ font-weight: bold; } - a:hover { - color: #BDDDFD; - } - // these are actual toc items li { position: relative; @@ -73,6 +69,11 @@ } // make hovered element prominent background: rgba(0, 0, 0, .8) none repeat scroll 0% 0%; + // decorate links on hover over list item + &>a { + color: #BDDDFD; + text-decoration: underline; + } } // Prevent display of subheadings in horizontal ToC -- To view, visit https://gerrit.wikimedia.org/r/235041 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0221fe2861b56d666d74f419aff435eab49dad69 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner restrict heading to one line - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/235059 Change subject: WikidataPageBanner restrict heading to one line .. WikidataPageBanner restrict heading to one line On screen below 768px, restrict heading to one line and hide overflow. Also make the media query targeting 768px more specific. Bug: T110905 Change-Id: I1a0ad8e83f45d98d760877449e615e2d9aedf890 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less 1 file changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/59/235059/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index eab11c5..ff17534 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -64,8 +64,10 @@ } @media screen and ( max-width: 768px ) { - .wpb-topbanner .wpb-name { + .ext-wpb-pagebanner .wpb-topbanner .wpb-name { font-size: 1em; + white-space: nowrap; + overflow: hidden; } } -- To view, visit https://gerrit.wikimedia.org/r/235059 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1a0ad8e83f45d98d760877449e615e2d9aedf890 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner replace div with h1 for heading - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/232934 Change subject: WikidataPageBanner replace div with h1 for heading .. WikidataPageBanner replace div with h1 for heading Bug: T109811 Change-Id: I938214e260659a3d37b79cc8ea215f363af866c6 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less M templates/banner.mustache 2 files changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/34/232934/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index e104bfe..fb0b3d5 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -28,7 +28,9 @@ .wpb-topbanner .wpb-name { position: absolute; z-index: 2; - margin: 0.6em 0 0 0.4em; + // skins's have their own margins on h1 however arbitrary margin on banner h1 could cause a bad + // view, therefore rule made important + margin: 0.6em 0 0 0.4em !important; padding: 8px 7px; font-size: 2.2em; font-weight: bold; diff --git a/templates/banner.mustache b/templates/banner.mustache index 6331f94..875e0cc 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,6 +1,6 @@ div class=ext-wpb-pagebanner noprint div class=wpb-topbanner - div class=wpb-name{{title}}/div + h1 class=wpb-name{{title}}/h1 a class=image title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image {{originx}} data-pos-x={{data-pos-x}} data-pos-y={{data-pos-y}} style=max-width:{{maxWidth}}px/a {{#hasIcons}} div class=wpb-iconbox -- To view, visit https://gerrit.wikimedia.org/r/232934 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I938214e260659a3d37b79cc8ea215f363af866c6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner move toc position - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/232759 Change subject: WikidataPageBanner move toc position .. WikidataPageBanner move toc position https://gerrit.wikimedia.org/r/#/c/228813/ hides the overflow on banner to support cropping. As a side effect it also cropped overflowing TOC. Therefore move the toc out of .wpb-topbanner and keep it within .ext-wpb-pagebanner. Bug: T109628 Change-Id: I58b085496f2e84b8b157c43cad3932eac49a0d49 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less M templates/banner.mustache 2 files changed, 2 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/59/232759/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index fac010a..3e43e1b 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -10,6 +10,7 @@ } .ext-wpb-pagebanner { + position: relative; width:100%; } diff --git a/templates/banner.mustache b/templates/banner.mustache index aca46f3..6331f94 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -9,6 +9,6 @@ {{/icons}} /div {{/hasIcons}} - div class=wpb-topbanner-toc {{#bottomtoc}}wpb-bottomtoc{{/bottomtoc}}div class=wpb-banner-toc{{{toc}}}/div/div /div + div class=wpb-topbanner-toc {{#bottomtoc}}wpb-bottomtoc{{/bottomtoc}}div class=wpb-banner-toc{{{toc}}}/div/div /div -- To view, visit https://gerrit.wikimedia.org/r/232759 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I58b085496f2e84b8b157c43cad3932eac49a0d49 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add .jshintrc - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/232072 Change subject: WikidataPageBanner add .jshintrc .. WikidataPageBanner add .jshintrc Add .jshintrc Edit Gruntfile.js to test resources/ and tests/qunit/ Fix jshint errors. Change-Id: I518cab59234b4f50a34aa58baba6938da020e2c3 --- A .jshintrc M Gruntfile.js M resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js 3 files changed, 24 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/72/232072/1 diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 000..df30cb2 --- /dev/null +++ b/.jshintrc @@ -0,0 +1,21 @@ +{ + globals: { + console: true, + jQuery: true, + JsDiff: true, + Hogan: true, + QUnit: true, + mw: true, + OO: true + }, + + browser: true, + curly: true, + eqeqeq: true, + forin: false, + onevar: true, + trailing: true, + undef : true, + unused: true, + supernew: true +} diff --git a/Gruntfile.js b/Gruntfile.js index 0f6ab82..5cac144 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,7 +10,8 @@ jshintrc: true }, all: [ - '*.js' + 'resources/**/*.js', + 'tests/qunit/**/*.js' ] }, banana: { diff --git a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js index a685f09..d5b8692 100644 --- a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js +++ b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js @@ -63,7 +63,7 @@ $( window ).on( 'resize', $.debounce( 100, function() { - positionBanner( $wpbBannerImageContainer ) + positionBanner( $wpbBannerImageContainer ); } ) ); positionBanner( $wpbBannerImageContainer ); -- To view, visit https://gerrit.wikimedia.org/r/232072 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I518cab59234b4f50a34aa58baba6938da020e2c3 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner improve qunit test - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/232195 Change subject: WikidataPageBanner improve qunit test .. WikidataPageBanner improve qunit test Followup to I856690b82cacd295147f89a1f740ecac56c3176c. Adds more test cases to test_ext.WikidataPageBanner.positionBanner.js. Bug: T109319 Change-Id: I1a7bbb07fcc1ddde77572423885f0245f661c3bc --- M tests/qunit/ext.WikidataPageBanner.positionBanner/test_ext.WikidataPageBanner.positionBanner.js 1 file changed, 46 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/95/232195/1 diff --git a/tests/qunit/ext.WikidataPageBanner.positionBanner/test_ext.WikidataPageBanner.positionBanner.js b/tests/qunit/ext.WikidataPageBanner.positionBanner/test_ext.WikidataPageBanner.positionBanner.js index 1d4be5b..e6463bc 100644 --- a/tests/qunit/ext.WikidataPageBanner.positionBanner/test_ext.WikidataPageBanner.positionBanner.js +++ b/tests/qunit/ext.WikidataPageBanner.positionBanner/test_ext.WikidataPageBanner.positionBanner.js @@ -1,6 +1,6 @@ ( function ( mw, $ ) { QUnit.module( 'ext.WikidataPageBanner.positionBanner', QUnit.newMwEnvironment() ); - QUnit.test( 'testFocus', 6, function( assert ) { + QUnit.test( 'testFocus', 10, function( assert ) { this.$wpbBannerImageContainer = $( 'div/', { width: 600, height: 300 @@ -15,21 +15,60 @@ this.$wpbBannerImage.data( 'pos-x', 0 ); this.$wpbBannerImage.data( 'pos-y', 0 ); mw.wpb.positionBanner( this.$wpbBannerImageContainer ); - assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '-150px' ); - assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '-100px' ); + assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '-150px', + 'Banner left should shift -150px for focus' ); + assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '-100px', + 'Banner top should shift -100px for focus' ); // set test focus points + // this case tests the case where origin is ignored because a positive margin would appear this.$wpbBannerImage.data( 'pos-x', -1 ); this.$wpbBannerImage.data( 'pos-y', -1 ); mw.wpb.positionBanner( this.$wpbBannerImageContainer ); - assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '0px' ); - assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '0px' ); + assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '0px', + 'Banner left should not leave positive margin for focus' ); + assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '0px', + 'Banner top should not leave positive margin for focus' ); // set test focus points this.$wpbBannerImage.data( 'pos-x', 0.5 ); this.$wpbBannerImage.data( 'pos-y', undefined ); mw.wpb.positionBanner( this.$wpbBannerImageContainer ); - assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '-300px' ); - assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '0px' ); + assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '-300px', + 'Banner left should shift -300px for focus' ); + assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '0px', + 'Banner top should not leave positive margin for focus' ); + + this.$wpbBannerImageContainer = $( 'div/', { + width: 1500, + height: 300 + } ); + this.$wpbBannerImage = $( 'img/', { + 'class': 'wpb-banner-image', + width: 1900, + height: 400 + } ); + this.$wpbBannerImageContainer.append( this.$wpbBannerImage ); + // set test focus points + // position in vertical direction is ignored after a limit because of too much negative + // margin + this.$wpbBannerImage.data( 'pos-x', 0 ); + this.$wpbBannerImage.data( 'pos-y', 1 ); + mw.wpb.positionBanner( this.$wpbBannerImageContainer ); + assert.equal( this.$wpbBannerImage.css( 'margin-left' ), '-200px', + 'Banner left should shift -390px for focus' ); + assert.equal( this.$wpbBannerImage.css( 'margin-top' ), '-100px', + 'Banner top should shift -100px only for to not leave too much negative margin' ); + + // set test focus points + // Position in vertical
[MediaWiki-commits] [Gerrit] WikidataPageBanner add max-wdith - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/231886 Change subject: WikidataPageBanner add max-wdith .. WikidataPageBanner add max-wdith Add a parameter max-width to the banner so as to prevent pixelation of the banner. Bug: T108986 Change-Id: I54353ca33a243954392de4467f2f2b23b76601a2 --- M includes/WikidataPageBanner.functions.php M templates/banner.mustache 2 files changed, 3 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/86/231886/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index 374e20c..0c6658d 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -149,6 +149,8 @@ $options['bannerfile'] = $bannerfile-getLocalUrl(); $options['banner'] = $bannerurl; $options['srcset'] = $srcset; + $file = wfFindFile( $bannerfile ); + $options['maxWidth'] = $file-getWidth(); $banner = $templateParser-processTemplate( 'banner', $options diff --git a/templates/banner.mustache b/templates/banner.mustache index 40560be..aca46f3 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,7 +1,7 @@ div class=ext-wpb-pagebanner noprint div class=wpb-topbanner div class=wpb-name{{title}}/div - a class=image title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image {{originx}} data-pos-x={{data-pos-x}} data-pos-y={{data-pos-y}}/a + a class=image title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image {{originx}} data-pos-x={{data-pos-x}} data-pos-y={{data-pos-y}} style=max-width:{{maxWidth}}px/a {{#hasIcons}} div class=wpb-iconbox {{#icons}} -- To view, visit https://gerrit.wikimedia.org/r/231886 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I54353ca33a243954392de4467f2f2b23b76601a2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner switch for default banner - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230978 Change subject: WikidataPageBanner switch for default banner .. WikidataPageBanner switch for default banner Adds a switch to enable default banners on pages.Even if $wgWPBImage is blank, extension will still add a WikidataBanner. This might lead to duplication where a banner has already been added by some other template and is not needed. Bug: T108788 Change-Id: I5acefab6b4826f2069b4538e695533e373928201 --- M extension.json M includes/WikidataPageBanner.hooks.php 2 files changed, 3 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/78/230978/1 diff --git a/extension.json b/extension.json index cb7d6d3..65425cf 100644 --- a/extension.json +++ b/extension.json @@ -69,6 +69,7 @@ ] }, config: { + WPBEnableDefaultBanner: false, WPBImage: , WPBNamespaces: [ 0 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index ca892a4..144db80 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -19,7 +19,7 @@ * @return bool */ public static function addBanner( OutputPage $out ) { - global $wgWPBImage, $wgWPBNamespaces; + global $wgWPBImage, $wgWPBNamespaces, $wgWPBEnableDefaultBanner; $title = $out-getTitle(); // if banner-options are set, add banner anyway if ( $out-getProperty( 'wpb-banner-options' ) !== null ) { @@ -49,7 +49,7 @@ } } // if the page uses no 'PAGEBANNER' invocation and if article page, insert default banner - elseif ( $title-isKnown() $out-isArticle() ) { + elseif ( $title-isKnown() $out-isArticle() $wgWPBEnableDefaultBanner ) { $ns = $title-getNamespace(); // banner only on specified namespaces, and not Main Page of wiki if ( in_array( $ns, $wgWPBNamespaces ) -- To view, visit https://gerrit.wikimedia.org/r/230978 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5acefab6b4826f2069b4538e695533e373928201 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner unquote false in extension.json - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/231057 Change subject: WikidataPageBanner unquote false in extension.json .. WikidataPageBanner unquote false in extension.json Follow-up to I5acefab6b4826f2069b4538e695533e373928201. Unquote false assigned to WPBEnableDefaultBanner. Quoting boolean false in extension.json makes it string. Change-Id: I3dd72d7cb6aca577b0dbb0b28823287f00adbdd1 --- M extension.json 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/57/231057/1 diff --git a/extension.json b/extension.json index 65425cf..76325da 100644 --- a/extension.json +++ b/extension.json @@ -69,7 +69,7 @@ ] }, config: { - WPBEnableDefaultBanner: false, + WPBEnableDefaultBanner: false, WPBImage: , WPBNamespaces: [ 0 -- To view, visit https://gerrit.wikimedia.org/r/231057 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3dd72d7cb6aca577b0dbb0b28823287f00adbdd1 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add class image to a:link - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230975 Change subject: WikidataPageBanner add class image to a:link .. WikidataPageBanner add class image to a:link Since MultimediaViewer operates on links with class image, add the class a tag around banner so that MultimediaViewer recognizes the banner. Bug: T108778 Change-Id: Iaa9fe57fb96104e6ba222d54c2aa08916870d906 --- M templates/banner.mustache 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/75/230975/1 diff --git a/templates/banner.mustache b/templates/banner.mustache index e6e9c62..089cbd4 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,7 +1,7 @@ div class=ext-wpb-pagebanner noprint div class=wpb-topbanner div class=wpb-name{{title}}/div - a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image {{originx}} data-pos-x={{data-pos-x}} data-pos-y={{data-pos-y}}/a + a class=image title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image {{originx}} data-pos-x={{data-pos-x}} data-pos-y={{data-pos-y}}/a {{#hasIcons}} div class=wpb-iconbox {{#icons}} -- To view, visit https://gerrit.wikimedia.org/r/230975 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaa9fe57fb96104e6ba222d54c2aa08916870d906 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add banner to imagelinks - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230643 Change subject: WikidataPageBanner add banner to imagelinks .. WikidataPageBanner add banner to imagelinks Check which banner is valid and eligible to be added and added it to imagelinks in addCustomBanner parser hook. Bug: T108614 Change-Id: I23751b51f7c937e8c368351d1cb071ceae50b7ee --- M includes/WikidataPageBanner.hooks.php 1 file changed, 17 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/43/230643/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 678955f..34bba01 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -108,7 +108,7 @@ * @param string $bannername Name of custom banner */ public static function addCustomBanner( Parser $parser, $bannername ) { - global $wgWPBNamespaces; + global $wgWPBNamespaces, $wgWPBImage; // @var array to hold parameters to be passed to banner template $paramsForBannerTemplate = array(); // skip parser function name and bannername in arguments @@ -146,6 +146,22 @@ $paramsForBannerTemplate['name'] = $bannername; // Set 'wpb-banner-options' property for generating banner later $parser-getOutput()-setProperty( 'wpb-banner-options', $paramsForBannerTemplate ); + + // add the valid banner to image links + // @FIXME:Since bannernames which are to be added are generated here, getBannerHtml can + // be cleaned to only accept a valid title object pointing to a banner file + $bannerName = ''; + $wikidataBanner = static::getWikidataBanner( $title ); + $imageName = Title::newFromText( File: . $paramsForBannerTemplate['name'] ); + if ( $imageName $imageName-exists() ) { + $bannerName = $paramsForBannerTemplate['name']; + } else if ( $imageName = Title::newFromText( File: . $wikidataBanner ) + $imageName-exists() ) { + $bannerName = $wikidataBanner; + } else { + $bannerName = $wgWPBImage; + } + $parser-getOutput()-addImage( $bannerName ); } } -- To view, visit https://gerrit.wikimedia.org/r/230643 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I23751b51f7c937e8c368351d1cb071ceae50b7ee Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB followup - move maxheight - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230226 Change subject: WPB followup - move maxheight .. WPB followup - move maxheight Followup to Ifd696117d4614389685945ad3853a473179c2c03 to move max-height outside media query as a general rule. Bug: T108232 Change-Id: I385b11a55beea1c2a6922d5eb92b2da3268f3844 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less 1 file changed, 4 insertions(+), 5 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/26/230226/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index ed938c9..fac010a 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -18,6 +18,10 @@ max-width: 1800px; height: auto; margin: 1em 0; + overflow: hidden; + // rule for banners whose height may be much due to a different aspect ratio other than + // Wikivoyage banners + max-height: 300px; } .wpb-topbanner .wpb-name { @@ -67,11 +71,6 @@ // banner enlargement and faking banner cropping for small screens @media screen and ( max-width: 400px ) { .wpb-topbanner { - overflow: hidden; - // rule for banners whose height may be much due to a different aspect ratio other than - // Wikivoyage banners - max-height: 300px; - .wpb-banner-image { // this rule overrides the max-width:100% rule for images in Skin Minerva so that banner // can be increased in size for increasing the height accordingly. The overflowing -- To view, visit https://gerrit.wikimedia.org/r/230226 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I385b11a55beea1c2a6922d5eb92b2da3268f3844 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner reduce margin-top for minerva - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230051 Change subject: WikidataPageBanner reduce margin-top for minerva .. WikidataPageBanner reduce margin-top for minerva Reduces margin-top from 3em to 1em for skin Minerva. Bug: T108214 Change-Id: Ia4eddd15cf1e3876e3c236426080b5819f516eb2 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/51/230051/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less index 3f747f1..ff2cd7f 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less @@ -4,7 +4,7 @@ @import mediawiki.mixins; .wpb-topbanner{ // some extra margin to make banner stand out and prevent overlapping elements - margin: 3em 0 1em 0; + margin: 1em 0 1em 0; } .ext-wpb-pagebanner { -- To view, visit https://gerrit.wikimedia.org/r/230051 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia4eddd15cf1e3876e3c236426080b5819f516eb2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB followup - fine tune banner position using js - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/230050 Change subject: WPB followup - fine tune banner position using js .. WPB followup - fine tune banner position using js This is a followup to https://gerrit.wikimedia.org/r/#q,Ifd696117d4614389685945ad3853a473179c2c03,n,z It further refines the position of banner using data-pos coordinates set by parser function when js is enabled. Also moves max-height of banner outside media-query as a general rule. Adds tests for position coordinates. Bug: T108232 Change-Id: I856690b82cacd295147f89a1f740ecac56c3176c --- M extension.json M includes/WikidataPageBanner.hooks.php A resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less M tests/phpunit/BannerOptionsTest.php 5 files changed, 93 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/50/230050/1 diff --git a/extension.json b/extension.json index cb7d6d3..4ded47d 100644 --- a/extension.json +++ b/extension.json @@ -48,6 +48,16 @@ mobile ], position: top + }, + ext.WikidataPageBanner.positionBanner: { + scripts: [ + ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js + ], + targets: [ + desktop, + mobile + ], + position: bottom } }, ResourceFileModulePaths: { diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 4df78c1..146d3e9 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -26,6 +26,7 @@ // only add banner and styling if valid banner generated if ( $banner !== null ) { $out-addModuleStyles( 'ext.WikidataPageBanner' ); + $out-addModules( 'ext.WikidataPageBanner.positionBanner' ); if ( isset( $params['toc'] ) ) { $out-addModuleStyles( 'ext.WikidataPageBanner.toc.styles' ); } @@ -56,6 +57,7 @@ // only add banner and styling if valid banner generated if ( $banner !== null ) { $out-addModuleStyles( 'ext.WikidataPageBanner' ); + $out-addModules( 'ext.WikidataPageBanner.positionBanner' ); $out-prependHtml( $banner ); // hide primary title $out-setPageTitle( '' ); diff --git a/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js new file mode 100644 index 000..cbdace0 --- /dev/null +++ b/resources/ext.WikidataPageBanner.positionBanner/ext.WikidataPageBanner.positionBanner.js @@ -0,0 +1,57 @@ +( function( mw, $ ) { + /** +* Javascript to fine tune position of banner according to position coordinates. +*/ + // extract position parameters + var centrex = $( '.wpb-banner-image' ).data( 'pos-x' ); + var centrey = $( '.wpb-banner-image' ).data( 'pos-y' ); + // reset translations applied by css + $( '.wpb-banner-image' ).css( { + transform: 'translate(0)', + MozTransform: 'translate(0)', + WebkitTransform: 'translate(0)', + msTransform: 'translate(0)' + } ); + if ( $( '.wpb-banner-image' ).height() $( '.wpb-topbanner' ).height() ) { + // first reset margin + $( '.wpb-banner-image' ).css( 'margin-top', 0 ); + // do not shift below to leave blank space + var minOffsetTop = 0; + // this is the max shift up that can be achieved without leaving blank space below + var maxOffsetTop = $( '.wpb-banner-image' ).height() - + $( '.wpb-topbanner' ).height(); + // offset beyond centre 0 + var offsetTop = centrey * $( '.wpb-banner-image' ).height() / 2; + // offset for default centre is maxOffsetTop/2 + // total offset = offset for centre + manual offset + var totalOffset = maxOffsetTop / 2 + offsetTop; + // shift the banner no more than maxOffsets on either side + if (
[MediaWiki-commits] [Gerrit] WikidataPageBanner add link to icons - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/229759 Change subject: WikidataPageBanner add link to icons .. WikidataPageBanner add link to icons Allow editors to define the article an icon refers to by specifying it in an optional [] after icon name. Example icons=star[Star article]. Bug: T108207 Change-Id: Ib4494910f68a1d45e470cd5b463a2ab17d3b72b6 --- M includes/WikidataPageBanner.functions.php M templates/banner.mustache 2 files changed, 22 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/59/229759/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index fd059c2..44aa364 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -30,12 +30,31 @@ if ( empty( $iconname ) ) { continue; } - $iconName = Sanitizer::escapeClass( $iconname ); + $iconData[] = $iconname; + // separate the icon name from link present within [], if such a link given + if ( strpos( $iconname, '[' ) !== false ) { + // store name in first index + $iconData[0] = substr( $iconname, 0, strpos( $iconname, '[' ) ); + // take the link as the substring within [] + $iconData[1] = substr( $iconname, strpos( $iconname, '[' ) + 1, -1 ); + } + + // Generate the icon from the part before [] + $iconName = Sanitizer::escapeClass( $iconData[0] ); $icon = new OOUI\IconWidget( array( 'icon' = $iconName, 'title' = $iconName ) ); - $iconsToAdd[] = array( 'icon' = $icon ); + // set a default iconurl as '#' in case none is provided + $finalIcon = array( 'icon' = $icon, 'iconurl' = '#' ); + if ( count( $iconData ) === 2 ) { + $iconUrl = Title::newFromText( $iconData[1] ); + // reference article for icons provided and is valid, then add its link + if ( $iconUrl-exists() ) { + $finalIcon['iconurl'] = $iconUrl-getLocalUrl(); + } + } + $iconsToAdd[] = $finalIcon; } // only set hasIcons to true if parser function gives some non-empty icon names if ( !empty( $iconsToAdd ) ) { diff --git a/templates/banner.mustache b/templates/banner.mustache index a10996a..663c9e8 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -5,7 +5,7 @@ {{#hasIcons}} div class=wpb-iconbox {{#icons}} - {{{icon}}} + a href={{iconurl}}{{{icon}}}/a {{/icons}} /div {{/hasIcons}} -- To view, visit https://gerrit.wikimedia.org/r/229759 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib4494910f68a1d45e470cd5b463a2ab17d3b72b6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner hygiene - move non-hook methods - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/229389 Change subject: WikidataPageBanner hygiene - move non-hook methods .. WikidataPageBanner hygiene - move non-hook methods Move non-hook functions from WikidataPageBanner.hooks.php to WikidataPageBanner.functions.php. Add a static variable $wpbFunctionsObj which stores the classname of functions class and which is used to call functions of that class. This variable is being added to facilitate injecting a mock classname while performing tests. Modify tests. Bug: T107755 Change-Id: I16ef2db74f34f122f83b3ace86c8b5edd17c3674 --- M includes/WikidataPageBanner.functions.php M includes/WikidataPageBanner.hooks.php M tests/phpunit/BannerOptionsTest.php M tests/phpunit/BannerTest.php 4 files changed, 210 insertions(+), 170 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/89/229389/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index fd059c2..f510189 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -44,4 +44,161 @@ } } } + + /** +* Converts an array of values in form [0] = name=value into a real +* associative array in form [name] = value +* +* @param array string[] $options +* @return array $results +*/ + public static function extractOptions( array $options ) { + $results = array(); + foreach ( $options as $option ) { + $pair = explode( '=', $option, 2 ); + if ( count( $pair ) == 2 ) { + $name = trim( $pair[0] ); + $value = trim( $pair[1] ); + $results[$name] = $value; + } + } + return $results; + } + + /** +* WikidataPageBanner::getBannerHtml +* Returns the html code for the pagebanner +* +* @param string $bannername FileName of banner image +* @param array $options additional parameters passed to template +* @return string|null Html code of the banner or null if invalid bannername +*/ + public static function getBannerHtml( $bannername, $options = array() ) { + global $wgWPBStandardSizes; + $urls = static::getStandardSizeUrls( $bannername ); + $banner = null; + /** @var String srcset attribute for img element of banner image */ + $srcset = array(); + // if a valid bannername given, set banner + if ( !empty( $urls ) ) { + // @var int index variable + $i = 0; + foreach ( $urls as $url ) { + $size = $wgWPBStandardSizes[$i]; + // add url with width and a comma if not adding the last url + if ( $i count( $urls ) ) { + $srcset[] = $url {$size}w; + } + $i++; + } + // create full src set from individual urls, separated by comma + $srcset = implode( ',', $srcset ); + // use largest image url as src attribute + $bannerurl = $urls[count( $urls ) - 1]; + $bannerfile = Title::newFromText( File:$bannername ); + $templateParser = new TemplateParser( __DIR__ . '/../templates' ); + $options['bannerfile'] = $bannerfile-getLocalUrl(); + $options['banner'] = $bannerurl; + $options['srcset'] = $srcset; + $banner = $templateParser-processTemplate( + 'banner', + $options + ); + } + return $banner; + } + + /** +* WikidataPageBanner::getImageUrl +* Return the full url of the banner image, stored on the wiki, given the +* image name. Additionally, if a width parameter is specified, it creates +* and returns url of an image of specified width. +* +* @param string $filename Filename of the banner image +* @return string|null Full url of the banner image on the wiki or null +*/ + public static function getImageUrl( $filename, $imagewidth = null ) { + // make title object from image name + $title = Title::makeTitleSafe( NS_IMAGE, $filename ); + $file = wfFindFile( $title ); +
[MediaWiki-commits] [Gerrit] WikidataPageBanner implement srcset polyfill - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/228785 Change subject: WikidataPageBanner implement srcset polyfill .. WikidataPageBanner implement srcset polyfill Implement a polyfill for srcset attribute which presently has limited support. Set default banner image as an image of size 640px to avoid unnecessary loading of a large image. Change-Id: Ic8f2bbdabe69b9da32acbdf1e13e03c912eae82a --- M extension.json M includes/WikidataPageBanner.hooks.php A resources/ext.WikidataPageBanner.srcsetPolyfill/ext.WikidataPageBanner.srcsetPolyfill.js 3 files changed, 140 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/85/228785/1 diff --git a/extension.json b/extension.json index ab4ff9d..2f6e2c8 100644 --- a/extension.json +++ b/extension.json @@ -48,6 +48,16 @@ mobile ], position: top + }, + ext.WikidataPageBanner.srcsetPolyfill: { + scripts: [ + ext.WikidataPageBanner.srcsetPolyfill/ext.WikidataPageBanner.srcsetPolyfill.js + ], + targets: [ + desktop, + mobile + ], + position: bottom } }, ResourceFileModulePaths: { diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 6465701..0fd5dff 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -26,6 +26,7 @@ // only add banner and styling if valid banner generated if ( $banner !== null ) { $out-addModuleStyles( 'ext.WikidataPageBanner' ); + $out-addModules( 'ext.WikidataPageBanner.srcsetPolyfill' ); if ( isset( $params['toc'] ) ) { $out-addModuleStyles( 'ext.WikidataPageBanner.toc.styles' ); } @@ -211,7 +212,7 @@ // create full src set from individual urls, separated by comma $srcset = implode( ',', $srcset ); // use largest image url as src attribute - $bannerurl = $urls[count( $urls ) - 1]; + $bannerurl = $urls[1]; $bannerfile = Title::newFromText( File:$bannername ); $templateParser = new TemplateParser( __DIR__ . '/../templates' ); $options['bannerfile'] = $bannerfile-getLocalUrl(); diff --git a/resources/ext.WikidataPageBanner.srcsetPolyfill/ext.WikidataPageBanner.srcsetPolyfill.js b/resources/ext.WikidataPageBanner.srcsetPolyfill/ext.WikidataPageBanner.srcsetPolyfill.js new file mode 100644 index 000..b309c6a --- /dev/null +++ b/resources/ext.WikidataPageBanner.srcsetPolyfill/ext.WikidataPageBanner.srcsetPolyfill.js @@ -0,0 +1,128 @@ +( function( mw, $ ) { + /** +* Returns whether or not srcset attribute is supported by this browser +* @return bool true if srcset is supported, otherwise false +*/ + function isSrcsetSupported() { + return 'srcset' in new Image(); + } + + /** +* Parses the srcset= attribute and forms an array of type [{url:,descriptor:}] +* @return {array} Array of objects each of which contains a url of image and its corresponding +* size +*/ + function parseSrcset( srcset ) { + var srcSet = [], + url, + desc, + separator, + position; + // remove any whitespaces from the end + srcset = srcset.trim(); + while ( srcset.indexOf( ',' ) !== -1 ) { + // get index of space which marks end of url part + position = srcset.indexOf( ' ' ); + // url will be the part of string till first whitespace + url = srcset.slice(0, position); + while ( srcset.charAt( position ) === ' ' ) { + position++; + } + desc = ''; + // get position of next COMMA ',' + separator = srcset.indexOf( ',' ); + // get the descriptor which is only 'w' in the extension currently + desc = srcset.slice( position, separator ); + srcset = srcset.slice( separator + 1 ); + srcSet.push( { + url: url, +
[MediaWiki-commits] [Gerrit] WikidataPageBanner option to hide default TOC - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/22 Change subject: WikidataPageBanner option to hide default TOC .. WikidataPageBanner option to hide default TOC WikidataPageBanner extension hides default TOC on all allowed namespace pages. Provide a config option to editors $wgWPBHideDefaultTOC to turn this behaviour off. Change-Id: Idc5dbd056c4dd4e0c451b642087d2ec310e09b79 --- M extension.json M includes/WikidataPageBanner.hooks.php 2 files changed, 7 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/88/22/1 diff --git a/extension.json b/extension.json index ab4ff9d..382e588 100644 --- a/extension.json +++ b/extension.json @@ -79,7 +79,8 @@ 1280, 2560 ], - WPBBannerProperty: + WPBBannerProperty: , + WPBHideDefaultTOC: true }, manifest_version: 1 } diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 6465701..5ace0ef 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -77,6 +77,7 @@ * @param ParserOutput $pOut */ public static function onOutputPageParserOutput( $out, $pOut ) { + global $wgWPBHideDefaultTOC; if ( $pOut-getProperty( 'wpb-banner-options' ) != null ) { $options = $pOut-getProperty( 'wpb-banner-options' ); // if toc parameter set and toc enabled, remove original classes and add banner class @@ -91,8 +92,10 @@ if ( strpos( $options['toc'], 'class=toc' ) !== false ) { $options['toc'] = str_replace( 'class=toc', '', $options['toc'] ); } - // disable default TOC - $out-enableTOC( false ); + // disable default TOC, if HideDefaultTOC set + if ( $wgWPBHideDefaultTOC ) { + $out-enableTOC( false ); + } } // set banner properties as an OutputPage property $out-setProperty( 'wpb-banner-options', $options ); -- To view, visit https://gerrit.wikimedia.org/r/22 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idc5dbd056c4dd4e0c451b642087d2ec310e09b79 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WPB fake banner cropping for small screens - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/228813 Change subject: WPB fake banner cropping for small screens .. WPB fake banner cropping for small screens On screen size below 400px, make the banners exceed 100% width so that a cropping effect can be faked, by hiding overflow on container div and defining focus parameters. Adds a parameter 'hfocus' to {{PAGEBANNER}} which specifies horizontal focus as a multiple of 1/8th width of banner. Allowed values are 0,1,2,3. For example,setting hfocus=2 would shift the banner left by 25% thereby shifting the focus. Bug: T105033 Change-Id: Ifd696117d4614389685945ad3853a473179c2c03 --- M extension.json M includes/WikidataPageBanner.functions.php M includes/WikidataPageBanner.hooks.php M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less M templates/banner.mustache 5 files changed, 62 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/13/228813/1 diff --git a/extension.json b/extension.json index ab4ff9d..cb7d6d3 100644 --- a/extension.json +++ b/extension.json @@ -74,7 +74,6 @@ 0 ], WPBStandardSizes: [ - 320, 640, 1280, 2560 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index fd059c2..72f9060 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -44,4 +44,24 @@ } } } + + /** +* Sets focus parameter on banner templates to shift focus on banner when cropped +* @param array $paramsForBannerTemplate Parameters defined for banner template +* @param array $argumentsFromParserFunction Arguments passed to {{PAGEBANNER}} function +* @return +*/ + public static function addFocus( $paramsForBannerTemplate, $argumentsFromParserFunction ) { + if ( isset( $argumentsFromParserFunction['hfocus'] ) ) { + // only 3 focus values allowed + $options = array( + 'options' = array( 'min_range' = 0, 'max_range' = 3 ) + ); + if ( filter_var( $argumentsFromParserFunction['hfocus'], FILTER_VALIDATE_INT, + $options ) ) { + $paramsForBannerTemplate['hfocus'] = 'wpb-left-' . + $argumentsFromParserFunction['hfocus']; + } + } + } } diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 6465701..4df78c1 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -145,6 +145,8 @@ $argumentsFromParserFunction ); WikidataPageBannerFunctions::addIcons( $paramsForBannerTemplate, $argumentsFromParserFunction ); + WikidataPageBannerFunctions::addFocus( $paramsForBannerTemplate, + $argumentsFromParserFunction ); $paramsForBannerTemplate['name'] = $bannername; // Set 'wpb-banner-options' property for generating banner later $parser-getOutput()-setProperty( 'wpb-banner-options', $paramsForBannerTemplate ); diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less index 3f747f1..8e6d722 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less @@ -10,3 +10,42 @@ .ext-wpb-pagebanner { clear: both; } + +// banner enlargement and faking banner cropping for small screens +@media screen and ( max-width: 400px ) { + .wpb-topbanner { + .wpb-banner-image { + // this rule overrides the max-width:100% rule for images in Skin Minerva so that banner + // can be increased in size for increasing the height accordingly. The overflowing + // banner is cropped by setting overflow hidden on containing element + max-width: 150% !important; + width: 150%; + margin-left: -25%; + } + + /** +* The rules below define custom positioning for banner in case the cropped banner needs to be +* shifted to allow focus to a different area +
[MediaWiki-commits] [Gerrit] WikidataPageBanner check avoid empty icons - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/227415 Change subject: WikidataPageBanner check avoid empty icons .. WikidataPageBanner check avoid empty icons Excess commas may lead to empty icon generation. Check for empty icon name and avoid adding any such icon. Bug: T107133 Change-Id: I63ec901acd049f62f0797a9e57d401232e6dc495 --- M includes/WikidataPageBanner.functions.php 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/15/227415/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index 2fda70e..dff4785 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -26,6 +26,9 @@ if ( isset( $argumentsFromParserFunction['icons'] ) ) { $icons = explode( ',', $argumentsFromParserFunction['icons'] ); foreach ( $icons as $iconname ) { + if ( empty( $iconname ) ) { + continue; + } $iconName = Sanitizer::escapeClass( $iconname ); $icon = new OOUI\IconWidget( array( 'icon' = $iconName, -- To view, visit https://gerrit.wikimedia.org/r/227415 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I63ec901acd049f62f0797a9e57d401232e6dc495 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner improve documentation - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/227254 Change subject: WikidataPageBanner improve documentation .. WikidataPageBanner improve documentation Improve the description of functions in WikidataPageBanner.hooks.php Change-Id: I8257914b86f07d4bb51ffba4d6ede60055aa3f57 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 10 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/54/227254/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index dea3058..e5980ad 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -2,7 +2,8 @@ class WikidataPageBanner { /** * WikidataPageBanner::addBanner Generates banner from given options and adds it and its styles -* to Output Page +* to Output Page. If no options defined through {{PAGEBANNER}}, tries to add a wikidata banner +* or a default one. * * @param $out OutputPage * @param $skin Skin Object @@ -69,6 +70,7 @@ /** * WikidataPageBanner::onOutputPageParserOutput add banner parameters from ParserOutput to * Output page +* * @param OutputPage $out * @param ParserOutput $pOut */ @@ -87,19 +89,22 @@ if ( strpos( $options['toc'], 'class=toc' ) !== false ) { $options['toc'] = str_replace( 'class=toc', '', $options['toc'] ); } + // disable default TOC $out-enableTOC( false ); } + // set banner properties as an OutputPage property $out-setProperty( 'wpb-banner-options', $options ); } } /** * WikidataPageBanner::addCustomBanner -* Parser function hooked to 'PAGEBANNER' magic word, to expand and load banner. +* Parser function hooked to 'PAGEBANNER' magic word, to define a custom banner and options to +* customize banner such as icons,horizontal TOC,etc. * * @param $parser Parser * @param $bannername Name of custom banner -* @return output +* @return array */ public static function addCustomBanner( $parser, $bannername ) { global $wgBannerNamespaces; @@ -129,6 +134,7 @@ if ( isset( $argumentsFromParserFunction['tooltip'] ) ) { $paramsForBannerTemplate['tooltip'] = $argumentsFromParserFunction['tooltip']; } + // set 'bottomtoc' parameter to allow TOC completely below the banner if ( isset( $argumentsFromParserFunction['bottomtoc'] ) $argumentsFromParserFunction['bottomtoc'] === 'yes' ) { $paramsForBannerTemplate['bottomtoc'] = true; @@ -251,7 +257,7 @@ } /** -* Fetches banner from wikidata for the specified page +* WikidataPageBanner::getWikidataBanner Fetches banner from wikidata for the specified page * * @param Title $title Title of the page * @return String|null file name of the banner from wikitata [description] -- To view, visit https://gerrit.wikimedia.org/r/227254 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I8257914b86f07d4bb51ffba4d6ede60055aa3f57 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner set bannername as articlebanner - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/227261 Change subject: WikidataPageBanner set bannername as articlebanner .. WikidataPageBanner set bannername as articlebanner Setting the whole bannerhtml as articlebanner property is not useful, insted set bannername as articlebanner property for reference. Bug: T107065 Change-Id: I05e7704e1e2b67ef85752f45c869cb516a8ceb58 --- M includes/WikidataPageBanner.hooks.php M tests/phpunit/BannerTest.php 2 files changed, 8 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/61/227261/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index dea3058..993ff7a 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -33,7 +33,7 @@ $out-setPageTitle( '' ); $out-setHTMLTitle( $out-getTitle() ); // set articlebanner property on OutputPage - $out-setProperty( 'articlebanner', $banner ); + $out-setProperty( 'articlebanner', $bannername ); } } // if the page uses no 'PAGEBANNER' invocation and if article page, insert default banner @@ -59,7 +59,7 @@ $out-setPageTitle( '' ); $out-setHTMLTitle( $out-getTitle() ); // set articlebanner property on OutputPage - $out-setProperty( 'articlebanner', $banner ); + $out-setProperty( 'articlebanner', $bannername ); } } } diff --git a/tests/phpunit/BannerTest.php b/tests/phpunit/BannerTest.php index 35849be..7d53610 100644 --- a/tests/phpunit/BannerTest.php +++ b/tests/phpunit/BannerTest.php @@ -17,7 +17,7 @@ if ( $title == 'NoWikidataBanner' ) { return null; } - return Banner; + return WikidataBanner; } } @@ -30,11 +30,11 @@ * property */ protected $testPagesForDefaultBanner = array( - array( 'PageWithoutCustomBanner', NS_MAIN, false, Banner ), - array( 'PageWithCustomBanner', NS_MAIN, CustomBanner, Banner ), + array( 'PageWithoutCustomBanner', NS_MAIN, false, WikidataBanner ), + array( 'PageWithCustomBanner', NS_MAIN, CustomBanner, CustomBanner ), array( 'PageInFileNamespace', NS_FILE, false, null ), - array( 'NoWikidataBanner', NS_MAIN, false, Banner ), - array( 'PageWithInvalidCustomBanner', NS_MAIN, NoBanner, Banner ) + array( 'NoWikidataBanner', NS_MAIN, false, DefaultBanner ), + array( 'PageWithInvalidCustomBanner', NS_MAIN, NoBanner, WikidataBanner ) ); /** @@ -56,6 +56,7 @@ } protected function setUp() { parent::setUp(); + $this-setMwGlobals( 'wgPBImage', DefaultBanner ); $this-addDBData(); } -- To view, visit https://gerrit.wikimedia.org/r/227261 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I05e7704e1e2b67ef85752f45c869cb516a8ceb58 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner check for invalid Property name - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/227176 Change subject: WikidataPageBanner check for invalid Property name .. WikidataPageBanner check for invalid Property name Add a try-catch block to getWikidataBanner to catch InvalidArgumentExceptions in case the property name is invalid. Bug: T107001 Change-Id: Iade85972f384c2644a4b27e6bce76079c6a2697d --- M includes/WikidataPageBanner.hooks.php 1 file changed, 29 insertions(+), 23 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/76/227176/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index dea3058..be3b43f 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -260,32 +260,38 @@ public static function getWikidataBanner( $title ) { global $wgBannerProperty; $banner = null; - // Ensure Wikibase client is installed - if ( class_exists( 'Wikibase\Client\WikibaseClient' ) ) { - $entityIdLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() - -getStore() - -getEntityIdLookup(); - $itemId = $entityIdLookup-getEntityIdForTitle( $title ); - // check if this page has an associated item page - $entityLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() - -getStore() - -getEntityLookup(); - /** @var Wikibase\DataModel\Entity\Item $item */ - if ( $itemId != null ) { - $item = $entityLookup-getEntity( $itemId ); - $statements = $item-getStatements()-getByPropertyId( - new Wikibase\DataModel\Entity\PropertyId( - $wgBannerProperty - ) - )-getBestStatements(); - if ( !$statements-isEmpty() ) { - $statements = $statements-toArray(); - $snak = $statements[0]-getMainSnak(); - if ( $snak instanceof Wikibase\DataModel\Snak\PropertyValueSnak ) { - $banner = $snak-getDataValue()-getValue(); + // Invalid Property name will throw an exception therefore use a try-catch block + try { + // Ensure Wikibase client is installed + if ( class_exists( 'Wikibase\Client\WikibaseClient' ) ) { + $entityIdLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() + -getStore() + -getEntityIdLookup(); + $itemId = $entityIdLookup-getEntityIdForTitle( $title ); + // check if this page has an associated item page + $entityLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() + -getStore() + -getEntityLookup(); + /** @var Wikibase\DataModel\Entity\Item $item */ + if ( $itemId != null ) { + $item = $entityLookup-getEntity( $itemId ); + $statements = $item-getStatements()-getWithPropertyId( + new Wikibase\DataModel\Entity\PropertyId( + $wgBannerProperty + ) + )-getBestStatements(); + if ( !$statements-isEmpty() ) { + $statements = $statements-toArray(); + $snak = $statements[0]-getMainSnak(); + if ( $snak instanceof Wikibase\DataModel\Snak\PropertyValueSnak ) { + $banner = $snak-getDataValue()-getValue(); + } } } } + } catch ( InvalidArgumentException $e ) { + // return null to safely avoid adding any Wikidata Banner + return null; } return $banner; } -- To view, visit
[MediaWiki-commits] [Gerrit] WikidataPageBanner prefix wpb in toc minerva style - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226697 Change subject: WikidataPageBanner prefix wpb in toc minerva style .. WikidataPageBanner prefix wpb in toc minerva style Banner class names in WikidataPageBanner have been prefixed with wpb-. Therefore change the style in ext.WikidataPageBanner.toc.less accordingly. Change-Id: I88a75b606bfc97210453c103882fa12128f5bf40 --- M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.minerva.less 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/97/226697/1 diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.minerva.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.minerva.less index 537f082..ba6c3e2 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.minerva.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.minerva.less @@ -2,6 +2,6 @@ * Minerva styles for table of Contents inside banner added by WikidataPageBanner extension */ // Hide banner toc on Skin Minerva -.topbanner-toc { +.wpb-topbanner-toc { display: none; } -- To view, visit https://gerrit.wikimedia.org/r/226697 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I88a75b606bfc97210453c103882fa12128f5bf40 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner prefix all globals with WPB - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226919 Change subject: WikidataPageBanner prefix all globals with WPB .. WikidataPageBanner prefix all globals with WPB Bug: T106586 Change-Id: I0960d0f2ad105528541a7da095c01b149939462d --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 2 files changed, 21 insertions(+), 21 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/19/226919/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index b3566c0..2cdd96c 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -23,16 +23,16 @@ ); /** - * $wgPBImage - default pagebanner image file, use only filename, do not prefix 'File:', - * e.g. $wgPBImage = 'Foo.jpg' + * $wgWPBImage - default pagebanner image file, use only filename, do not prefix 'File:', + * e.g. $wgWPBImage = 'Foo.jpg' */ -$wgPBImage = ; -/** $wgBannerNamespace - Namespaces on which to display banner */ -$wgBannerNamespaces = array( NS_MAIN ); -/** $wgStandardSizes - Array of standard predefined screen widths in increasing order */ -$wgStandardSizes = array( 320, 640, 1280, 2560 ); -/** $wgBannerProperty - Banner property on wikidata which holds commons media file */ -$wgBannerProperty = ; +$wgWPBImage = ; +/** $wgWPBBannerNamespace - Namespaces on which to display banner */ +$wgWPBNamespaces = array( NS_MAIN ); +/** $wgWPBStandardSizes - Array of standard predefined screen widths in increasing order */ +$wgWPBStandardSizes = array( 320, 640, 1280, 2560 ); +/** $wgWPBBannerProperty - Banner property on wikidata which holds commons media file */ +$wgWPBBannerProperty = ; /* Setup */ // autoloader diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 04a80f6..12b9641 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -9,7 +9,7 @@ * @return bool */ public static function addBanner( $out, $skin ) { - global $wgPBImage, $wgBannerNamespaces; + global $wgWPBImage, $wgWPBNamespaces; $title = $out-getTitle(); // if banner-options are set, add banner anyway if ( $out-getProperty( 'wpb-banner-options' ) !== null ) { @@ -40,13 +40,13 @@ elseif ( $title-isKnown() $out-isArticle() ) { $ns = $title-getNamespace(); // banner only on specified namespaces, and not Main Page of wiki - if ( in_array( $ns, $wgBannerNamespaces ) + if ( in_array( $ns, $wgWPBNamespaces ) !$title-isMainPage() ) { // first try to obtain bannername from Wikidata $bannername = static::getWikidataBanner( $title ); if ( $bannername === null ) { // if Wikidata banner not found, set bannername to default banner - $bannername = $wgPBImage; + $bannername = $wgWPBImage; } // add title to template parameters $paramsForBannerTemplate = array( 'title' = $title ); @@ -102,7 +102,7 @@ * @return output */ public static function addCustomBanner( $parser, $bannername ) { - global $wgBannerNamespaces; + global $wgWPBNamespaces; // @var array to get arguments passed to {{PAGEBANNER}} function $argumentsFromParserFunction = array(); // @var array to hold parameters to be passed to banner template @@ -115,7 +115,7 @@ $banner = ''; $title = $parser-getTitle(); $ns = $title-getNamespace(); - if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { + if ( in_array( $ns, $wgWPBNamespaces ) !$title-isMainPage() ) { // set title and tooltip attribute to default title $paramsForBannerTemplate['tooltip'] = $title-getText(); $paramsForBannerTemplate['title'] = $title-getText(); @@ -180,7 +180,7 @@ * @return string|null Html code of the banner or null if invalid bannername */ public static function getBannerHtml( $bannername, $options = array() ) { - global $wgStandardSizes; + global $wgWPBStandardSizes; $urls = static::getStandardSizeUrls( $bannername ); $banner = null; /** @var String srcset attribute for img element of banner image */ @@ -190,7 +190,7 @@ // @var int index variable
[MediaWiki-commits] [Gerrit] WikidataPageBanner add parameter tocbelow - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226762 Change subject: WikidataPageBanner add parameter tocbelow .. WikidataPageBanner add parameter tocbelow Add a parameter 'tocbelow' to {{PAGEBANNER}} which when set to yes would cause the toc to appear below the banner. Bug: T106534 Change-Id: I1ff8770875f889ff3d8b89cf91f338532490bffc --- M includes/WikidataPageBanner.hooks.php M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less M templates/banner.mustache 3 files changed, 9 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/62/226762/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 04a80f6..2782976 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -129,6 +129,10 @@ if ( isset( $argumentsFromParserFunction['tooltip'] ) ) { $paramsForBannerTemplate['tooltip'] = $argumentsFromParserFunction['tooltip']; } + if ( isset( $argumentsFromParserFunction['tocbelow'] ) + $argumentsFromParserFunction['tocbelow'] === 'yes' ) { + $paramsForBannerTemplate['tocbelow'] = true; + } WikidataPageBannerFunctions::addToc( $paramsForBannerTemplate, $argumentsFromParserFunction ); WikidataPageBannerFunctions::addIcons( $paramsForBannerTemplate, diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less index 062f367..2042436 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less @@ -21,6 +21,10 @@ width: 100%; } + .tocbelow { + position: relative; + } + .wpb-banner-toc { display: table; color: white; diff --git a/templates/banner.mustache b/templates/banner.mustache index 165b9a0..e926120 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -10,7 +10,7 @@ {{/icons}} /div {{/hasIcons}} - div class=wpb-topbanner-tocdiv class=wpb-banner-toc{{{toc}}}/div/div + div class=wpb-topbanner-toc {{#tocbelow}}tocbelow{{/tocbelow}}div class=wpb-banner-toc{{{toc}}}/div/div /div /div /div -- To view, visit https://gerrit.wikimedia.org/r/226762 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1ff8770875f889ff3d8b89cf91f338532490bffc Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner prefix all globals with WPB - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226520 Change subject: WikidataPageBanner prefix all globals with WPB .. WikidataPageBanner prefix all globals with WPB Bug: T106586 Change-Id: Id1d03ebc5ce4ae63f70f267cce7368b8c80ad8fa --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 2 files changed, 18 insertions(+), 18 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/20/226520/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index b3566c0..9599f15 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -26,13 +26,13 @@ * $wgPBImage - default pagebanner image file, use only filename, do not prefix 'File:', * e.g. $wgPBImage = 'Foo.jpg' */ -$wgPBImage = ; -/** $wgBannerNamespace - Namespaces on which to display banner */ -$wgBannerNamespaces = array( NS_MAIN ); -/** $wgStandardSizes - Array of standard predefined screen widths in increasing order */ -$wgStandardSizes = array( 320, 640, 1280, 2560 ); +$wgWPBImage = ; +/** $wgPBNamespace - Namespaces on which to display banner */ +$wgWPBNamespaces = array( NS_MAIN ); +/** $wgPBStandardSizes - Array of standard predefined screen widths in increasing order */ +$wgWPBStandardSizes = array( 320, 640, 1280, 2560 ); /** $wgBannerProperty - Banner property on wikidata which holds commons media file */ -$wgBannerProperty = ; +$wgWPBBannerProperty = ; /* Setup */ // autoloader diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3f5886c..3d89309 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -9,7 +9,7 @@ * @return bool */ public static function addBanner( $out, $skin ) { - global $wgPBImage, $wgBannerNamespaces; + global $wgWPBImage, $wgWPBNamespaces; $title = $out-getTitle(); // if banner-options are set, add banner anyway if ( $out-getProperty( 'wpb-banner-options' ) !== null ) { @@ -41,13 +41,13 @@ elseif ( $title-isKnown() $out-isArticle() ) { $ns = $title-getNamespace(); // banner only on specified namespaces, and not Main Page of wiki - if ( in_array( $ns, $wgBannerNamespaces ) + if ( in_array( $ns, $wgWPBNamespaces ) !$title-isMainPage() ) { // first try to obtain bannername from Wikidata $bannername = static::getWikidataBanner( $title ); if ( $bannername === null ) { // if Wikidata banner not found, set bannername to default banner - $bannername = $wgPBImage; + $bannername = $wgWPBImage; } // add title to template parameters $paramsForBannerTemplate = array( 'title' = $title ); @@ -103,7 +103,7 @@ * @return output */ public static function addCustomBanner( $parser, $bannername ) { - global $wgBannerNamespaces; + global $wgWPBNamespaces; // @var array to get arguments passed to {{PAGEBANNER}} function $argumentsFromParserFunction = array(); // @var array to hold parameters to be passed to banner template @@ -116,7 +116,7 @@ $banner = ''; $title = $parser-getTitle(); $ns = $title-getNamespace(); - if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { + if ( in_array( $ns, $wgWPBNamespaces ) !$title-isMainPage() ) { // set title and tooltip attribute to default title $paramsForBannerTemplate['tooltip'] = $title-getText(); $paramsForBannerTemplate['title'] = $title-getText(); @@ -181,7 +181,7 @@ * @return string|null Html code of the banner or null if invalid bannername */ public static function getBannerHtml( $bannername, $options = array() ) { - global $wgStandardSizes, $wgArticlePath; + global $wgWPBStandardSizes, $wgArticlePath; $urls = static::getStandardSizeUrls( $bannername ); $banner = null; /** @var String srcset attribute for img element of banner image */ @@ -191,7 +191,7 @@ // @var int index variable $i = 0; foreach ( $urls as $url ) { - $size = $wgStandardSizes[$i]; + $size =
[MediaWiki-commits] [Gerrit] Load oojs ui styles only for banner icons - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226521 Change subject: Load oojs ui styles only for banner icons .. Load oojs ui styles only for banner icons Replace oojs-ui with oojs-ui-styles as a depedency for ext.WikidataPageBanner module. Bug: T106588 Change-Id: I877a700165fd5241e0235fcf810a2ca03700854a --- M resources/Resources.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/21/226521/1 diff --git a/resources/Resources.php b/resources/Resources.php index 76698c7..2364054 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -35,7 +35,7 @@ 'remoteExtPath' = 'WikidataPageBanner/resources', 'targets' = array( 'desktop', 'mobile' ), 'position' = 'top', - 'dependencies' = 'oojs-ui' + 'dependencies' = 'oojs-ui-styles' ); $wgResourceModules['ext.WikidataPageBanner.toc.styles'] = array( -- To view, visit https://gerrit.wikimedia.org/r/226521 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I877a700165fd5241e0235fcf810a2ca03700854a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner remove outermost div - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226574 Change subject: WikidataPageBanner remove outermost div .. WikidataPageBanner remove outermost div Remove container with class noprint and add that class to inner div. Bug: T106537 Change-Id: I276bc560167d8e286c4ad0f163432021eb40dc60 --- M templates/banner.mustache 1 file changed, 11 insertions(+), 13 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/74/226574/1 diff --git a/templates/banner.mustache b/templates/banner.mustache index 997d11d..f3eb217 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,16 +1,14 @@ -div class=noprint - div class=ext-wpb-pagebanner - div class=wpb-topbanner - div class=wpb-name{{title}}/div - a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a - {{#hasIcons}} - div class=wpb-iconbox - {{#icons}} - {{{icon}}} - {{/icons}} - /div - {{/hasIcons}} - div class=wpb-topbanner-tocdiv class=wpb-banner-toc{{{toc}}}/div/div +div class=ext-wpb-pagebanner noprint + div class=wpb-topbanner + div class=wpb-name{{title}}/div + a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a + {{#hasIcons}} + div class=wpb-iconbox + {{#icons}} + {{{icon}}} + {{/icons}} /div + {{/hasIcons}} + div class=wpb-topbanner-tocdiv class=wpb-banner-toc{{{toc}}}/div/div /div /div -- To view, visit https://gerrit.wikimedia.org/r/226574 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I276bc560167d8e286c4ad0f163432021eb40dc60 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner drop OOUI\Theme::setSingleton - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226558 Change subject: WikidataPageBanner drop OOUI\Theme::setSingleton .. WikidataPageBanner drop OOUI\Theme::setSingleton Remove the call to OOUI\Theme::setSingleton(), as OutputPage::enableOOUI() already does that. Bug: T106706 Change-Id: Ic344f8198fd3553dc417ddf320537362e031217b --- M includes/WikidataPageBanner.hooks.php 1 file changed, 0 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/58/226558/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3f5886c..9fa9767 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -15,7 +15,6 @@ if ( $out-getProperty( 'wpb-banner-options' ) !== null ) { $params = $out-getProperty( 'wpb-banner-options' ); $bannername = $params['name']; - OOUI\Theme::setSingleton( new OOUI\MediaWikiTheme ); $out-enableOOUI(); $banner = static::getBannerHtml( $bannername, $params ); // attempt to get WikidataBanner -- To view, visit https://gerrit.wikimedia.org/r/226558 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic344f8198fd3553dc417ddf320537362e031217b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner toc - make toc less overlapping - change (mediawiki...WikidataPageBanner)
Sumit has submitted this change and it was merged. Change subject: WikidataPageBanner toc - make toc less overlapping .. WikidataPageBanner toc - make toc less overlapping To prevent too much toc overlapping banner on smaller screens, following style changes made: * list items vertical padding removed. * toc container given a vertical padding. * line-height increased to 1.6 * toc made to stick to bottom, by setting bottom as 0. * font-size changed from .85em to .8em on links Bug: T106426 Change-Id: I787636fc1928d7973971b0eaa18c64c00e24e3c0 --- M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less 1 file changed, 5 insertions(+), 5 deletions(-) Approvals: Sumit: Verified; Looks good to me, approved Jdlrobson: Looks good to me, approved jenkins-bot: Checked diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less index 4692e16..d8c90ab 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less @@ -15,7 +15,7 @@ display: block; position: absolute; background: rgba(0, 0, 0, 0.5) none repeat scroll 0% 0%; - bottom: 6px; + bottom: 0; left: 0; z-index: 3; width: 100%; @@ -26,8 +26,8 @@ color: white; background: none; border: medium none; - line-height: 1.1em; - padding: 0 2em 0 2em; + line-height: 1.6em; + padding: .2em 2em; margin: 0; width: auto; @@ -45,7 +45,7 @@ a { color: white; - font-size: 0.85em; + font-size: 0.8em; font-weight: bold; } @@ -56,7 +56,7 @@ // these are actual toc items li { position: relative; - padding: .5em; + padding: 0 .4em; margin: 0; ul { list-style: none; -- To view, visit https://gerrit.wikimedia.org/r/226229 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I787636fc1928d7973971b0eaa18c64c00e24e3c0 Gerrit-PatchSet: 6 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: Jdlrobson jrob...@wikimedia.org Gerrit-Reviewer: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner TOC unstyle visited and hygiene - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226341 Change subject: WikidataPageBanner TOC unstyle visited and hygiene .. WikidataPageBanner TOC unstyle visited and hygiene Disable styling on visited links. Use .x instead of 0.x Bug: T106532 Change-Id: Idc1cf74d94e6838b1b1f7f1085721d84e0d5be44 --- M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less 1 file changed, 6 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/41/226341/1 diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less index d8c90ab..655b9e6 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less @@ -14,7 +14,7 @@ .wpb-topbanner-toc { display: block; position: absolute; - background: rgba(0, 0, 0, 0.5) none repeat scroll 0% 0%; + background: rgba(0, 0, 0, .5) none repeat scroll 0% 0%; bottom: 0; left: 0; z-index: 3; @@ -39,13 +39,13 @@ divul { list-style: none; margin: 0; - background: rgba(0, 0, 0, 0.6) none repeat scroll 0% 0%; + background: rgba(0, 0, 0, .6) none repeat scroll 0% 0%; z-index: 4; } - a { + a, a:visited { color: white; - font-size: 0.8em; + font-size: .8em; font-weight: bold; } @@ -61,7 +61,7 @@ ul { list-style: none; margin: 0; - background: rgba(0, 0, 0, 0.6) none repeat scroll 0% 0%; + background: rgba(0, 0, 0, .6) none repeat scroll 0% 0%; z-index: 4; } } @@ -72,7 +72,7 @@ display: block; } // make hovered element prominent - background: rgba(0, 0, 0, 0.8) none repeat scroll 0% 0%; + background: rgba(0, 0, 0, .8) none repeat scroll 0% 0%; } // Prevent display of subheadings in horizontal ToC -- To view, visit https://gerrit.wikimedia.org/r/226341 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Idc1cf74d94e6838b1b1f7f1085721d84e0d5be44 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner allow space in image src - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226303 Change subject: WikidataPageBanner allow space in image src .. WikidataPageBanner allow space in image src Bug: T106321 Change-Id: If34d8ee2b9b4668e3d968ec02c69482710ee8d9e --- M templates/banner.mustache 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/03/226303/1 diff --git a/templates/banner.mustache b/templates/banner.mustache index 997d11d..165b9a0 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -2,7 +2,7 @@ div class=ext-wpb-pagebanner div class=wpb-topbanner div class=wpb-name{{title}}/div - a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a + a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a {{#hasIcons}} div class=wpb-iconbox {{#icons}} -- To view, visit https://gerrit.wikimedia.org/r/226303 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If34d8ee2b9b4668e3d968ec02c69482710ee8d9e Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner toc - make toc less overlapping - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/226229 Change subject: WikidataPageBanner toc - make toc less overlapping .. WikidataPageBanner toc - make toc less overlapping To prevent too much toc overlapping banner on smaller screens, following style changes made: * list items vertical padding removed. * toc container given a vertical padding. * font-size reduced to 95%. Bug: T106426 Change-Id: I787636fc1928d7973971b0eaa18c64c00e24e3c0 --- M resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less 1 file changed, 5 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/29/226229/1 diff --git a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less index 4692e16..1279e68 100644 --- a/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc.styles/ext.WikidataPageBanner.toc.less @@ -15,7 +15,7 @@ display: block; position: absolute; background: rgba(0, 0, 0, 0.5) none repeat scroll 0% 0%; - bottom: 6px; + bottom: 0; left: 0; z-index: 3; width: 100%; @@ -26,10 +26,11 @@ color: white; background: none; border: medium none; - line-height: 1.1em; - padding: 0 2em 0 2em; + line-height: 1.6em; + padding: 0.2em 2em 0.2em 2em; margin: 0; width: auto; + font-size: 95%; // Suppress numbering of items in TOC .tocnumber { @@ -56,7 +57,7 @@ // these are actual toc items li { position: relative; - padding: .5em; + padding: 0 0.3em; margin: 0; ul { list-style: none; -- To view, visit https://gerrit.wikimedia.org/r/226229 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I787636fc1928d7973971b0eaa18c64c00e24e3c0 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner allow spaces in banner href - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/225855 Change subject: WikidataPageBanner allow spaces in banner href .. WikidataPageBanner allow spaces in banner href Bug: T106321 Change-Id: Iaae97116ed93877ac12eb3935380eedb3a50ae52 --- M templates/banner.mustache 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/55/225855/1 diff --git a/templates/banner.mustache b/templates/banner.mustache index fb37c81..997d11d 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -2,7 +2,7 @@ div class=ext-wpb-pagebanner div class=wpb-topbanner div class=wpb-name{{title}}/div - a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a + a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a {{#hasIcons}} div class=wpb-iconbox {{#icons}} -- To view, visit https://gerrit.wikimedia.org/r/225855 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaae97116ed93877ac12eb3935380eedb3a50ae52 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add custom banner category - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/225904 Change subject: WikidataPageBanner add custom banner category .. WikidataPageBanner add custom banner category Return the value specified in $wgCustomBannerCategory from parser function to add category to pages which have a custom banner. Bug: T101229 Change-Id: I0b62ab6974db542080b59282c483d33d997fb283 --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 2 files changed, 4 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/04/225904/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index b3566c0..dfa45e1 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -33,6 +33,8 @@ $wgStandardSizes = array( 320, 640, 1280, 2560 ); /** $wgBannerProperty - Banner property on wikidata which holds commons media file */ $wgBannerProperty = ; +/** $wgBannerCategory - Category to add to pages with a custom banner */ +$wgCustomBannerCategory = [[Category:Has Custom Banner]]; /* Setup */ // autoloader diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3f5886c..0fa1bbc 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -103,7 +103,7 @@ * @return output */ public static function addCustomBanner( $parser, $bannername ) { - global $wgBannerNamespaces; + global $wgBannerNamespaces, $wgCustomBannerCategory; // @var array to get arguments passed to {{PAGEBANNER}} function $argumentsFromParserFunction = array(); // @var array to hold parameters to be passed to banner template @@ -138,7 +138,7 @@ // Set 'wpb-banner-options' property for generating banner later $parser-getOutput()-setProperty( 'wpb-banner-options', $paramsForBannerTemplate ); } - return array( '', 'noparse' = true, 'isHTML' = true ); + return array( $wgCustomBannerCategory, 'noparse' = false, 'isHTML' = false ); } /** -- To view, visit https://gerrit.wikimedia.org/r/225904 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0b62ab6974db542080b59282c483d33d997fb283 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner prefix class names with wpb- - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/224089 Change subject: WikidataPageBanner prefix class names with wpb- .. WikidataPageBanner prefix class names with wpb- Class names on banner elements have been prefixed with wpb- to avoid clash with other extension's and existing pagebanner template on engligh wikivoyage. Change-Id: I785f6620e6e62f2e2c162a53bea4d11bae40a5d2 --- M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less M resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less M templates/banner.mustache 4 files changed, 12 insertions(+), 12 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/89/224089/1 diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index 4abd59a..c9a9cf6 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -6,14 +6,14 @@ width:100%; } -.topbanner{ +.wpb-topbanner{ position: relative; max-width: 1800px; height: auto; margin: 1em 0; } -.topbanner .name { +.wpb-topbanner .wpb-name { position: absolute; z-index: 2; margin: 0.6em 0 0 0.4em; @@ -31,12 +31,12 @@ display: none; } -.topbanner .wpb-banner-image{ +.wpb-topbanner .wpb-banner-image{ width: 100%; height: auto; } -.iconbox{ +.wpb-iconbox{ top: 0; position: absolute; margin-top: -2px; @@ -52,7 +52,7 @@ } @media screen and ( max-width: 768px ) { - .topbanner .name { + .wpb-topbanner .wpb-name { font-size: 1em; } } diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less index b37fb6e..3f747f1 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.minerva.less @@ -2,7 +2,7 @@ * Style tweaks for page-wide Banner in WikidataPageBanner extension for Skin Minerva. */ @import mediawiki.mixins; -.topbanner{ +.wpb-topbanner{ // some extra margin to make banner stand out and prevent overlapping elements margin: 3em 0 1em 0; } diff --git a/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less index 1924c14..d69759f 100644 --- a/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less @@ -5,13 +5,13 @@ */ @import mediawiki.mixins; // hide topbanner-toc by default -.topbanner-toc { +.wpb-topbanner-toc { display: none; } // style rules to apply only if screen wide enough for a horizontal toc @media screen and ( min-width: 768px ) { - .topbanner-toc { + .wpb-topbanner-toc { display: block; position: absolute; background: rgba(0, 0, 0, 0.5) none repeat scroll 0% 0%; diff --git a/templates/banner.mustache b/templates/banner.mustache index f1cc539..57cee7b 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,16 +1,16 @@ div class=noprint div class=ext-wpb-pagebanner - div class=topbanner - div class=name{{title}}/div + div class=wpb-topbanner + div class=wpb-name{{title}}/div a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a {{#hasIcons}} - div class=iconbox + div class=wpb-iconbox {{#icons}} {{{icon}}} {{/icons}} /div {{/hasIcons}} - div class=topbanner-toc/div + div class=wpb-topbanner-toc/div /div /div /div -- To view, visit https://gerrit.wikimedia.org/r/224089 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I785f6620e6e62f2e2c162a53bea4d11bae40a5d2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Prevent back button hiding on scroll in chrome - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/224194 Change subject: Prevent back button hiding on scroll in chrome .. Prevent back button hiding on scroll in chrome Add overflow: visible to back button to prevent it from hiding in chrome when scrolled. Bug: T98846 Change-Id: Id27c14f07bc870ced9d333458b4a84f35621fc67 --- M resources/mobile.overlays/Overlay.less 1 file changed, 3 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/94/224194/1 diff --git a/resources/mobile.overlays/Overlay.less b/resources/mobile.overlays/Overlay.less index d2c421d..2c44135 100644 --- a/resources/mobile.overlays/Overlay.less +++ b/resources/mobile.overlays/Overlay.less @@ -294,6 +294,9 @@ .overlay-header-container { top: 0; + .back { + overflow: visible; + } } .overlay-footer-container { -- To view, visit https://gerrit.wikimedia.org/r/224194 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id27c14f07bc870ced9d333458b4a84f35621fc67 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Fix blurry banners when no support for srcset - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223746 Change subject: Fix blurry banners when no support for srcset .. Fix blurry banners when no support for srcset Set src attribute of banner image to url of largest in order to load best banner when browser has no support for srcset. Bug: T105203 Change-Id: I0b659b30b89171a91c70b0e243accf7f0046d1b6 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/46/223746/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 29e57c7..9d8a02a 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -195,7 +195,7 @@ } // create full src set from individual urls, separated by comma $srcset = implode( ',', $srcset ); - $bannerurl = $urls[0]; + $bannerurl = $urls[count($urls) - 1]; $bannerfile = str_replace( $1, File:$bannername, $wgArticlePath ); $templateParser = new TemplateParser( __DIR__ . '/../templates' ); $options['bannerfile'] = $bannerfile; -- To view, visit https://gerrit.wikimedia.org/r/223746 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0b659b30b89171a91c70b0e243accf7f0046d1b6 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner hide icon placeholder if empty - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223558 Change subject: WikidataPageBanner hide icon placeholder if empty .. WikidataPageBanner hide icon placeholder if empty Bug: T105163 Change-Id: I1ac2edc605bb262e751bdbebb3d1109f9c30b6ab --- M includes/WikidataPageBanner.functions.php M templates/banner.mustache 2 files changed, 6 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/58/223558/1 diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php index 7a3d83d..503d025 100644 --- a/includes/WikidataPageBanner.functions.php +++ b/includes/WikidataPageBanner.functions.php @@ -33,7 +33,8 @@ ) ); $iconsToAdd[] = array( 'icon' = $icon ); } + $paramsForBannerTemplate['icons'] = true; + $paramsForBannerTemplate['iconSet'] = $iconsToAdd; } - $paramsForBannerTemplate['icons'] = $iconsToAdd; } } diff --git a/templates/banner.mustache b/templates/banner.mustache index a6e6ed7..e2c7564 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -3,11 +3,13 @@ div class=topbanner div class=name{{title}}/div a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a + {{#icons}} div class=iconbox - {{#icons}} + {{#iconSet}} {{{icon}}} - {{/icons}} + {{/iconSet}} /div + {{/icons}} div class=topbanner-toc/div /div /div -- To view, visit https://gerrit.wikimedia.org/r/223558 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1ac2edc605bb262e751bdbebb3d1109f9c30b6ab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] TalkSectionOverlay disallow empty fields - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223657 Change subject: TalkSectionOverlay disallow empty fields .. TalkSectionOverlay disallow empty fields Keep save button disabled on add-talk section overlay until both discussion and subject have atleast one non-whitespace character. Bug: T104837 Change-Id: I804602b61f0c17e6f7ff3ea51960fe9aaa830fff --- M resources/mobile.talk.overlays/TalkSectionAddOverlay.js 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/57/223657/1 diff --git a/resources/mobile.talk.overlays/TalkSectionAddOverlay.js b/resources/mobile.talk.overlays/TalkSectionAddOverlay.js index 8135b0d..6cec9aa 100644 --- a/resources/mobile.talk.overlays/TalkSectionAddOverlay.js +++ b/resources/mobile.talk.overlays/TalkSectionAddOverlay.js @@ -83,7 +83,7 @@ clearTimeout( this.timer ); this.timer = setTimeout( function () { - if ( !self.$ta.val() || !self.$subject.val() ) { + if ( !self.$ta.val().trim() || !self.$subject.val().trim() ) { self.$confirm.prop( 'disabled', true ); } else { self.$confirm.prop( 'disabled', false ); -- To view, visit https://gerrit.wikimedia.org/r/223657 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I804602b61f0c17e6f7ff3ea51960fe9aaa830fff Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] More padding to check icons in collection overlay - change (mediawiki...Gather)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223370 Change subject: More padding to check icons in collection overlay .. More padding to check icons in collection overlay Padding for list in 'add to existing collection' overlay increased from 12px to 16px to avoid clipping of check icon. Bug: T104890 Change-Id: Icf8bfd558473415b8cd521cef4d7a0124a1286b8 --- M resources/ext.gather.collection.contentOverlay/contentOverlay.less 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather refs/changes/70/223370/1 diff --git a/resources/ext.gather.collection.contentOverlay/contentOverlay.less b/resources/ext.gather.collection.contentOverlay/contentOverlay.less index 5e3e51a..956d8c9 100644 --- a/resources/ext.gather.collection.contentOverlay/contentOverlay.less +++ b/resources/ext.gather.collection.contentOverlay/contentOverlay.less @@ -157,7 +157,7 @@ cursor: pointer; border-top: solid 1px @grayLight; font-size: 1.4em; - padding: 12px 50px 0 0; + padding: 16px 50px 0 0; position: relative; overflow: hidden; -- To view, visit https://gerrit.wikimedia.org/r/223370 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Icf8bfd558473415b8cd521cef4d7a0124a1286b8 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Gather Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner allow custom Wikidata Banner - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223065 Change subject: WikidataPageBanner allow custom Wikidata Banner .. WikidataPageBanner allow custom Wikidata Banner If {{PAGEBANNER}} provides an invalid bannername, it should attempt to load a Wikidata Banner there itself. Bug: T104886 Change-Id: Ifa58bbb631d968d61c7bad52d7e327dcec54df2b --- M includes/WikidataPageBanner.hooks.php M tests/phpunit/BannerTest.php 2 files changed, 6 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/65/223065/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 1f32fb9..45380c8 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -121,7 +121,11 @@ $banner = static::getBannerHtml( $bannername, $paramsForBannerTemplate ); // if given banner does not exist, return if ( $banner === null ) { - return array( '', 'noparse' = true, 'isHTML' = true ); + $bannername = static::getWikidataBanner( $title ); + $banner = static::getBannerHtml( $bannername, $paramsForBannerTemplate ); + if ( $banner === null ) { + return array( '', 'noparse' = true, 'isHTML' = true ); + } } // Set 'articlebanner' property for future reference $parser-getOutput()-setProperty( 'articlebanner', $banner ); diff --git a/tests/phpunit/BannerTest.php b/tests/phpunit/BannerTest.php index 2a3832c..53951a9 100644 --- a/tests/phpunit/BannerTest.php +++ b/tests/phpunit/BannerTest.php @@ -43,7 +43,7 @@ protected $testPagesForCustomBanner = array( array( 'PageWithCustomBanner', NS_MAIN, Banner ), array( 'PageInTalkNamespace', NS_TALK, '' ), - array( 'NoBanner', NS_MAIN, '' ) + array( 'NoBanner', NS_MAIN, Banner ) ); /** -- To view, visit https://gerrit.wikimedia.org/r/223065 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifa58bbb631d968d61c7bad52d7e327dcec54df2b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add pageactions check while rendering pre-content - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/223090 Change subject: Add pageactions check while rendering pre-content .. Add pageactions check while rendering pre-content This allows page-actions alone to be rendered in absence of page title. Bug: T104897 Change-Id: I4817459e172780412cff8e06a680b3ff7bb8900d --- M includes/skins/MinervaTemplate.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/90/223090/1 diff --git a/includes/skins/MinervaTemplate.php b/includes/skins/MinervaTemplate.php index 65cb427..e90d70a 100644 --- a/includes/skins/MinervaTemplate.php +++ b/includes/skins/MinervaTemplate.php @@ -279,7 +279,7 @@ $internalBanner = $data[ 'internalBanner' ]; $preBodyText = isset( $data['prebodytext'] ) ? $data['prebodytext'] : ''; - if ( $internalBanner || $preBodyText ) { + if ( $internalBanner || $preBodyText || isset( $data['page_actions'] ) ) { ? div class=pre-content heading-holder ?php -- To view, visit https://gerrit.wikimedia.org/r/223090 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4817459e172780412cff8e06a680b3ff7bb8900d Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner fixes for skin Minerva - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/222693 Change subject: WikidataPageBanner fixes for skin Minerva .. WikidataPageBanner fixes for skin Minerva Introduced the following css changes for skin Minerva: * precontent h1 made to hide * extra margin-top given to topbanner to prevent overlapping with edit buttons. * .banner-image class renamed to .wpb-banner-image class because MobileFrontend's banner module also uses the same class. * Reduce banner name font to 1em when screen below 768px Bug: T98034 Change-Id: Iaab674cc216110fa2b59348e0a3add7e2c001654 --- M resources/Resources.php M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less A resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.mobile.less M resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less M templates/banner.mustache 5 files changed, 29 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/93/222693/1 diff --git a/resources/Resources.php b/resources/Resources.php index 1fecc55..cdf02ef 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -28,6 +28,9 @@ 'styles' = array( 'ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less', ), + 'skinStyles' = array( + 'minerva' = 'ext.WikidataPageBanner.styles/ext.WikidataPageBanner.mobile.less' + ), 'localBasePath' = __DIR__, 'remoteExtPath' = 'WikidataPageBanner/resources', 'targets' = array( 'desktop', 'mobile' ), diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index 3b6fd8e..4abd59a 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -10,6 +10,7 @@ position: relative; max-width: 1800px; height: auto; + margin: 1em 0; } .topbanner .name { @@ -30,7 +31,7 @@ display: none; } -.topbanner .banner-image{ +.topbanner .wpb-banner-image{ width: 100%; height: auto; } @@ -49,3 +50,9 @@ float: left; } } + +@media screen and ( max-width: 768px ) { + .topbanner .name { + font-size: 1em; + } +} diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.mobile.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.mobile.less new file mode 100644 index 000..52673dc --- /dev/null +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.mobile.less @@ -0,0 +1,12 @@ +/** + * Stylesheet for page-wide Banner in WikidataPageBanner extension. + */ +@import mediawiki.mixins; +.topbanner{ + // since h1 is hidden so give extra margin to prevent overlapping with edit buttons + margin: 3em 0 1em 0; +} + +.pre-content h1 { + display: none; +} diff --git a/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less b/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less index 1924c14..59f11bf 100644 --- a/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less +++ b/resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less @@ -105,4 +105,9 @@ #toctitle { display: none; } + + // hide toc if toc module added and screen is large + .toc-mobile, .toc { + display: none; + } } diff --git a/templates/banner.mustache b/templates/banner.mustache index 47e2d32..a6e6ed7 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -2,7 +2,7 @@ div class=ext-wpb-pagebanner div class=topbanner div class=name{{title}}/div - a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=banner-image/a + a title={{tooltip}} href={{bannerfile}}img src={{banner}} srcset={{srcset}} class=wpb-banner-image/a div class=iconbox {{#icons}} {{{icon}}} -- To view, visit https://gerrit.wikimedia.org/r/222693 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaab674cc216110fa2b59348e0a3add7e2c001654 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner remove i18n-alias reference - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/221881 Change subject: WikidataPageBanner remove i18n-alias reference .. WikidataPageBanner remove i18n-alias reference Change-Id: Ie225a87961ac89af537bb1bb0de0f8da7f940d22 --- M WikidataPageBanner.php 1 file changed, 0 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/81/221881/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index bf2617c..958c92b 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -42,8 +42,6 @@ // Register files $wgMessagesDirs['WikidataPageBanner'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['WikidataPageBannerAlias'] = - __DIR__ . '/WikidataPageBanner.i18n.alias.php'; $wgExtensionMessagesFiles['WikidataPageBannerMagic'] = __DIR__ . '/WikidataPageBanner.i18n.magic.php'; -- To view, visit https://gerrit.wikimedia.org/r/221881 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie225a87961ac89af537bb1bb0de0f8da7f940d22 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner remove url for 2x from srcset - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/221898 Change subject: WikidataPageBanner remove url for 2x from srcset .. WikidataPageBanner remove url for 2x from srcset Remove the image-url for 2x from srcset. 'w' takes care of hi-res devices. See http://stackoverflow.com/questions/26928828/html5-srcset-mixing-x-and-w-syntax. Bug: T103994 Change-Id: I46180fbd8eaaf4f3bb7f3c505bcf9902f8d45249 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 2 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/98/221898/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 24f4928..3234c2b 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -187,10 +187,8 @@ } $i++; } - // only use the largest size url as a hi-res banner url, as a mix - // of 'w' and 'x' causes issues in chrome - $url = $urls[$i-1]; - $srcset .= $url 2x; + // remove last comma + $srcset = substr( $srcset, 0, -1 ); $bannerurl = $urls[0]; $bannerfile = str_replace( $1, File:$bannername, $wgArticlePath ); $templateParser = new TemplateParser( __DIR__ . '/../templates' ); -- To view, visit https://gerrit.wikimedia.org/r/221898 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I46180fbd8eaaf4f3bb7f3c505bcf9902f8d45249 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner remove unused files - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/221636 Change subject: WikidataPageBanner remove unused files .. WikidataPageBanner remove unused files Following redundant files leftover from boilerplate extension have been removed: * resources/ext.WikidataPageBanner.js * special/SpecialHelloWorld.php * BoilerPlate.hooks.php Bug: T103710 Change-Id: I1de93f9a097d3864cbff2fd0eb93671159978c6b --- D BoilerPlate.hooks.php D resources/ext.WikidataPageBanner.js D specials/SpecialHelloWorld.php 3 files changed, 0 insertions(+), 64 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/36/221636/1 diff --git a/BoilerPlate.hooks.php b/BoilerPlate.hooks.php deleted file mode 100644 index e96cba0..000 --- a/BoilerPlate.hooks.php +++ /dev/null @@ -1,11 +0,0 @@ -?php -/** - * Hooks for BoilerPlate extension - * - * @file - * @ingroup Extensions - */ - -class BoilerPlateHooks { - -} diff --git a/resources/ext.WikidataPageBanner.js b/resources/ext.WikidataPageBanner.js deleted file mode 100644 index dcbbaee..000 --- a/resources/ext.WikidataPageBanner.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * JavaScript for Foo in BoilerPlate. - */ - -( function ( mw, $ ) { - var foo, x, y; - - function my() { - - } - - foo = { - init: function () { - // .. - }, - doStuff: function () { - // .. - } - }; - - mw.libs.foo = foo; - -}( mediaWiki, jQuery ) ); diff --git a/specials/SpecialHelloWorld.php b/specials/SpecialHelloWorld.php deleted file mode 100644 index aa75f45..000 --- a/specials/SpecialHelloWorld.php +++ /dev/null @@ -1,30 +0,0 @@ -?php -/** - * HelloWorld SpecialPage for BoilerPlate extension - * - * @file - * @ingroup Extensions - */ - -class SpecialHelloWorld extends SpecialPage { - public function __construct() { - parent::__construct( 'HelloWorld' ); - } - - /** -* Shows the page to the user. -* @param string $sub: The subpage string argument (if any). -* [[Special:HelloWorld/subpage]]. -*/ - public function execute( $sub ) { - $out = $this-getOutput(); - - $out-setPageTitle( $this-msg( 'boilerplate-helloworld' ) ); - - $out-addWikiMsg( 'boilerplate-helloworld-intro' ); - } - - protected function getGroupName() { - return 'other'; - } -} -- To view, visit https://gerrit.wikimedia.org/r/221636 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1de93f9a097d3864cbff2fd0eb93671159978c6b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner hook changes - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/221459 Change subject: WikidataPageBanner hook changes .. WikidataPageBanner hook changes Remove addDefaultBanner(ArticleViewHeader hook) and add OutputPageParserOutput hook. The banner is now generated only at the last stage, i.e. in BeforePageDisplay hook. This is being done so that all properties required for banner are available before generating it, such as a TOC. The custom banner is handled by setting banner parameters in the parser function, which are then propagated to addBanner(BeforePageDisplay hook), where banner is generated. The hook checks if banners parameters have been set and generated banner from them, else adds a default banner. Additional advantage of this is that additional properties such as [[Category:foo]] can be passed in parser function as return which will be parsed and added to page as banner property on that page. The only disadvantage of this approach, is that parser function will not determine banner position. Rename 'loadModules' to 'addBanner' and fix its documentation. Phpunit tests modified as per new strucutre. Change-Id: Iff1ac56fdb3f691f0cabe31e4e34aa78e5ac48d8 --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php M tests/phpunit/BannerOptionsTest.php M tests/phpunit/BannerTest.php 4 files changed, 72 insertions(+), 71 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/59/221459/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index bf2617c..613c688 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -49,9 +49,9 @@ // Register hooks // Hook to inject banner code -$wgHooks['ArticleViewHeader'][] = 'WikidataPageBanner::addDefaultBanner'; // Load Banner modules, styles -$wgHooks['BeforePageDisplay'][] = 'WikidataPageBanner::loadModules'; +$wgHooks['BeforePageDisplay'][] = 'WikidataPageBanner::addBanner'; +$wgHooks['OutputPageParserOutput'][] = 'WikidataPageBanner::propagateData'; $wgHooks['ParserFirstCallInit'][] = 'WikidataPageBanner::onParserFirstCallInit'; $wgHooks['UnitTestsList'][] = 'WikidataPageBanner::onUnitTestsList'; diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 24f4928..27a5f70 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -1,24 +1,26 @@ ?php class WikidataPageBanner { - /** -* WikidataPageBanner::addDefaultBanner -* This method is only for rendering a default banner, in case no -* user-defined banner is added using the 'PAGEBANNER' parser function, to -* the article. Otherwise, it only sets the 'articlebanner' property on -* OutputPage if a banner has been added +* WikidataPageBanner::loadModules * -* @param Article $article -* @return bool +* @param $out OutputPage +* @param $skin Skin Object +* @return bool */ - public static function addDefaultBanner( $article ) { + public static function addBanner( $out, $skin ) { global $wgPBImage, $wgBannerNamespaces; - $title = $article-getTitle(); - $out = $article-getContext()-getOutput(); - // if the page does not exist, or can not be viewed, return - if ( !$title-isKnown() ) { - return true; - } elseif ( $article-getParserOutput()-getProperty( 'articlebanner' ) == null ) { + $title = $out-getTitle(); + // if bannerparams are set, add banner anyway + if ( $out-getProperty( 'bannerparams' ) !== null ) { + $params = $out-getProperty( 'bannerparams' ); + $bannername = $params['name']; + $banner = static::getBannerHtml( $bannername, $params ); + $out-prependHtml( $banner ); + $out-setProperty( 'articlebanner', $banner ); + $out-addModuleStyles( 'ext.WikidataPageBanner' ); + } + // if bannerparams are not set, add banner only when page is exists + elseif( $title-isKnown() ) { $ns = $title-getNamespace(); // banner only on specified namespaces, and not Main Page of wiki if ( in_array( $ns, $wgBannerNamespaces ) @@ -37,18 +39,13 @@ if ( $banner !== null ) { // add the banner to output page if a valid one found // only set articlebanner property on OutputPage - $out-addHtml( $banner ); + $out-prependHtml( $banner );
[MediaWiki-commits] [Gerrit] WikidataPageBanner getWPBFunctionsInstace() added - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/221279 Change subject: WikidataPageBanner getWPBFunctionsInstace() added .. WikidataPageBanner getWPBFunctionsInstace() added This adds a static method to get a singleton of WikidataPageBannerFunctions class. This would allow easy mocking of helper functions when static hooks need to be tested. To mock, simply an overriding of the above method to return a mock object with desired characteristics would be needed. This method is required before moving non-hook functions from WikidataPageBanner to WikidataPageBannerFunctions as static methods. Change-Id: Ide40b5dcc4737117d0376df009ebeff191a294f7 --- M includes/WikidataPageBanner.hooks.php 1 file changed, 16 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/79/221279/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 27b3c6c..1275e4a 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -1,5 +1,10 @@ ?php class WikidataPageBanner { + /** +* Singleton instance for helper class functions +* @var WikidataPageBannerFunctions +*/ + static $wpbFunctionsObj; /** * WikidataPageBanner::addDefaultBanner @@ -306,4 +311,15 @@ } return true; } + + /** +* Getter method to obtain an instance of WikidataPageBannerFunctions +* @return object WikidataPageBannerFunctions +*/ + public static function getWPBFunctionsInstance() { + if ( !isset( self::$wpbFunctionsObj ) ) { + self::$wpbFunctionsObj = new WikidataPageBannerFunctions(); + } + return self::$wpbFunctionsObj; + } } -- To view, visit https://gerrit.wikimedia.org/r/221279 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ide40b5dcc4737117d0376df009ebeff191a294f7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner add getBannerUrl test - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/220963 Change subject: WikidataPageBanner add getBannerUrl test .. WikidataPageBanner add getBannerUrl test Adds a test for function getBannerUrl() which fetches image from local or foreign repo. Test uses files from wikimedia commons(foreign). Adjust the max_width in getBannerUrl() to 5000. Bug: T98832 Change-Id: I7bca4c7b14aa480d5d5b069ccf747aa71c1ac071 --- M includes/WikidataPageBanner.hooks.php A tests/phpunit/GetBannerUrlTest.php 2 files changed, 49 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/63/220963/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 27b3c6c..8a5fde2 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -130,7 +130,7 @@ $title = Title::makeTitleSafe( NS_IMAGE, $filename ); $file = wfFindFile( $title ); $options = array( - 'options' = array( 'min_range' = 0, 'max_range' = 3000 ) + 'options' = array( 'min_range' = 0, 'max_range' = 5000 ) ); // if file not found, return null if ( $file == null ) { diff --git a/tests/phpunit/GetBannerUrlTest.php b/tests/phpunit/GetBannerUrlTest.php new file mode 100644 index 000..332346f --- /dev/null +++ b/tests/phpunit/GetBannerUrlTest.php @@ -0,0 +1,48 @@ +?php +/** + * @group WikidataPageBanner + */ +class GetBannerUrlTest extends \MediaWikiTestCase { + protected function setUp() { + parent::setUp(); + $this-setMWGlobals( array( + 'wgUseInstantCommons' = 'true' + ) ); + } + + protected function tearDown() { + parent::tearDown(); + } + + /** +* testGetBannerUrl Tests getBannerUrl by using images from wikimedia commons +* Note: The mentioned images need to be present on commons for tests to succeed, if not, +* they should be replaced +* @covers getBannerUrl(...) +*/ + public function testGetBannerUrl() { + $file = 'Manhattan4_amk.jpg'; + $url = WikidataPageBanner::getBannerUrl( $file ); + $this-assertStringStartsWith( 'http', $url, + 'On providing valid image, its url should be returned' ); + $url = WikidataPageBanner::getBannerUrl( $file, 800, + 'On providing valid image, its url should be returned' ); + $this-assertStringStartsWith( 'http', $url ); + $url = WikidataPageBanner::getBannerUrl( $file, 1600, + 'On providing valid image, its url should be returned' ); + $this-assertStringStartsWith( 'http', $url ); + + $file = 'Sainte-Enimie-Gorges_du_Tarn_France_banner.jpg'; + $url = WikidataPageBanner::getBannerUrl( $file ); + $this-assertStringStartsWith( 'http', $url, + 'On providing valid image, its url should be returned' ); + $url = WikidataPageBanner::getBannerUrl( $file, 4300 ); + $this-assertNull( $url, + 'On providing valid image with width greater than original width, null should be returned' ); + + $file = ''; + $url = WikidataPageBanner::getBannerUrl( $file, 1600 ); + $this-assertNull( $url, 'invalid image should return null' ); + } +} + -- To view, visit https://gerrit.wikimedia.org/r/220963 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7bca4c7b14aa480d5d5b069ccf747aa71c1ac071 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner custom banner on page-preview - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/218691 Change subject: WikidataPageBanner custom banner on page-preview .. WikidataPageBanner custom banner on page-preview Modify loadModules() to add banner style after checking a valid namespace for banner and not check for articlebanner property. This is being done because the extension in any case tries to add a banner on allowed namespaces, and adding a style assuming a banner, allows banners to be seen on page-preview. Remove addition of 'loadImage' module as it no longer exists. Bug: T100983 Change-Id: I3c69250a540d6ce1ad05f9e0bbe00c7db7069b2b --- M includes/WikidataPageBanner.hooks.php 1 file changed, 10 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/91/218691/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index ac1c6bf..6ced653 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -59,10 +59,16 @@ * @return bool */ public static function loadModules( $out, $parserOutput ) { - if ( $out-getProperty( 'articlebanner' ) != null ) { - // if articlebanner property is set, we need to add banner styles - $out-addModuleStyles( 'ext.WikidataPageBanner' ); - $out-addModules( 'ext.WikidataPageBanner.loadImage' ); + global $wgBannerNamespaces; + $pageTitle = $out-getPageTitle(); + $title = Title::newFromText( $pageTitle ); + if ( isset( $title ) ) { + $ns = $title-getNamespace(); + if ( in_array( $ns, $wgBannerNamespaces ) ) { + // add banner style on allowed namespaces, so that banners are visible even on + // preview + $out-addModuleStyles( 'ext.WikidataPageBanner' ); + } } } -- To view, visit https://gerrit.wikimedia.org/r/218691 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I3c69250a540d6ce1ad05f9e0bbe00c7db7069b2b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner toc added - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/218672 Change subject: WikidataPageBanner toc added .. WikidataPageBanner toc added Add option 'toc=yes' to allow passing a parameter to {{PAGEBANNER}} for rendering a horizontal TOC within the banner. The toc is manipulated from client-side using jquery, where it is removed from normal location and inserted into the banner. Bug: T97839 Change-Id: If8249dfb198b37952f5740f348c48b093ffde5c1 --- M WikidataPageBanner.php A includes/WikidataPageBanner.functions.php M includes/WikidataPageBanner.hooks.php M resources/Resources.php M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less A resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.js A resources/ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less M templates/banner.mustache 8 files changed, 133 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/72/218672/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index be3ad4e..f77bc9d 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -37,6 +37,8 @@ /* Setup */ // autoloader $wgAutoloadClasses['WikidataPageBanner'] = __DIR__ . '/includes/WikidataPageBanner.hooks.php'; +$wgAutoloadClasses['WikidataPageBannerFunctions'] = + __DIR__ . '/includes/WikidataPageBanner.functions.php'; // Register files $wgMessagesDirs['WikidataPageBanner'] = __DIR__ . '/i18n'; diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php new file mode 100644 index 000..10f4c9c --- /dev/null +++ b/includes/WikidataPageBanner.functions.php @@ -0,0 +1,13 @@ +?php +class WikidataPageBannerFunctions { + /** +* Set bannertoc variable on parser output object +* @param ParserOutput $parserOutput ParserOutput object +* @param array $options options from parser function +*/ + public static function addToc( $parserOutput, $options ) { + if ( isset( $options['toc'] ) $options['toc'] == 'yes' ) { + $parserOutput-setProperty( 'bannertoc', true ); + } + } +} diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index ac1c6bf..8f8bac5 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -48,6 +48,10 @@ $article-getParserOutput()-getProperty( 'articlebanner' ) ); } + if ( $article-getParserOutput()-getProperty( 'bannertoc' ) $out-isTOCEnabled() ) { + $out-addJsConfigVars( 'bannertoc', true ); + $out-addModules( 'ext.WikidataPageBanner.toc' ); + } return true; } @@ -62,7 +66,6 @@ if ( $out-getProperty( 'articlebanner' ) != null ) { // if articlebanner property is set, we need to add banner styles $out-addModuleStyles( 'ext.WikidataPageBanner' ); - $out-addModules( 'ext.WikidataPageBanner.loadImage' ); } } @@ -93,6 +96,7 @@ $title = $argumentsFromParserFunction['pgname']; } $paramsForBannerTemplate['title'] = $title; + WikidataPageBannerFunctions::addToc( $parser-getOutput(), $argumentsFromParserFunction ); $banner = self::getBannerHtml( $bannername, $paramsForBannerTemplate ); // if given banner does not exist, return if ( $banner === null ) { diff --git a/resources/Resources.php b/resources/Resources.php index 8a1fc14..03105ec 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -33,3 +33,16 @@ 'targets' = array( 'desktop', 'mobile' ), 'position' = 'top' ); + +$wgResourceModules['ext.WikidataPageBanner.toc'] = array( + 'styles' = array( + 'ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.less', + ), + 'scripts' = array( + 'ext.WikidataPageBanner.toc/ext.WikidataPageBanner.toc.js' + ), + 'localBasePath' = __DIR__, + 'remoteExtPath' = 'WikidataPageBanner/resources', + 'targets' = array( 'desktop', 'mobile' ), + 'position' = 'bottom' +); diff --git a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less index 185af6d..9355308 100644 --- a/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less +++ b/resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less @@ -9,7 +9,6 @@ .topbanner{ position: relative; max-width: 1800px; - overflow:
[MediaWiki-commits] [Gerrit] WikidataPageBanner Add unit tests - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/216735 Change subject: WikidataPageBanner Add unit tests .. WikidataPageBanner Add unit tests This patch introduces unit-testing for the following functions: * addDefaultBanner() * addCustomBanner() * getBannerUrl() Additionally, it changes all static calls done using 'self' to use 'static'. This has been done to allow mocking of the class WikidataPageBanner. See http://php.net/manual/en/language.oop5.late-static-bindings.php Bug: T98832 Change-Id: Ia122bdef53f646d3e35733b80c2c6c688c161dbc --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php A tests/phpunit/BannerTest.php A tests/phpunit/GetBannerUrlTest.php 4 files changed, 203 insertions(+), 7 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/35/216735/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index be3ad4e..40984a6 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -51,6 +51,7 @@ // Load Banner modules, styles $wgHooks['BeforePageDisplay'][] = 'WikidataPageBanner::loadModules'; $wgHooks['ParserFirstCallInit'][] = 'WikidataPageBanner::onParserFirstCallInit'; +$wgHooks['UnitTestsList'][] = 'WikidataPageBanner::onUnitTestsList'; // include WikidataPageBanner class file require_once __DIR__ . /includes/WikidataPageBanner.hooks.php; diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index f57344f..4f79504 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -26,13 +26,13 @@ !$title-isMainPage() ) { // if the page uses no 'PAGEBANNER' invocation, insert default banner or // WikidataBanner - // only set articlebanner property on OutputPage - $bannername = self::getWikidataBanner( $title ); + $bannername = static::getWikidataBanner( $title ); if ( $bannername === null ) { $bannername = $wgPBImage; } - $banner = self::getBannerHtml( $title, $bannername ); + $banner = static::getBannerHtml( $title, $bannername ); if ( $banner !== null ) { + // only set articlebanner property on OutputPage $out-addHtml( $banner ); $out-setProperty( 'articlebanner', $banner ); } @@ -76,7 +76,7 @@ $title = $parser-getTitle(); $ns = $title-getNamespace(); if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { - $banner = self::getBannerHtml( $title, $bannername ); + $banner = static::getBannerHtml( $title, $bannername ); // if given banner does not exist, return if ( $banner === null ) { return array( '', 'noparse' = true, 'isHTML' = true ); @@ -101,7 +101,7 @@ $title = Title::makeTitleSafe( NS_IMAGE, $filename ); $file = wfFindFile( $title ); $options = array( - 'options' = array( 'min_range' = 0, 'max_range' = 3000 ) + 'options' = array( 'min_range' = 0, 'max_range' = 5000 ) ); // if file not found, return null if ( $file == null ) { @@ -133,7 +133,7 @@ */ public static function getBannerHtml( $title, $bannername ) { global $wgStandardSizes, $wgArticlePath; - $urls = self::getStandardSizeUrls( $bannername ); + $urls = static::getStandardSizeUrls( $bannername ); $banner = null; /** @var String srcset attribute for img element of banner image */ $srcset = ; @@ -192,7 +192,7 @@ global $wgStandardSizes; $urlSet = array(); foreach ( $wgStandardSizes as $size ) { - $url = self::getBannerUrl( $filename, $size ); + $url = static::getBannerUrl( $filename, $size ); if ( $url != null ) { $urlSet[] = $url; } @@ -240,4 +240,16 @@ } return $banner; } + + /** +* UnitTestsList hook handler +* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList +* +* @param array $files +* @return bool +
[MediaWiki-commits] [Gerrit] Fix phpcs warnings in WikidataPageBanner - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/216108 Change subject: Fix phpcs warnings in WikidataPageBanner .. Fix phpcs warnings in WikidataPageBanner Remove unused $wgScript and $wgStandardSizes from WikidataPageBanner.hooks.php. Fix line 'exceeding 100 characters' on lines 43,44 in WikidataPageBanner.php. Bug: T101293 Change-Id: I6c048dda865acc11d7dc32b1d092e105d1e09ec2 --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 2 files changed, 6 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/08/216108/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index 4a54658..c71b4d9 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -40,8 +40,10 @@ // Register files $wgMessagesDirs['WikidataPageBanner'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['WikidataPageBannerAlias'] = __DIR__ . '/WikidataPageBanner.i18n.alias.php'; -$wgExtensionMessagesFiles['WikidataPageBannerMagic'] = __DIR__ . '/WikidataPageBanner.i18n.magic.php'; +$wgExtensionMessagesFiles['WikidataPageBannerAlias'] = + __DIR__ . '/WikidataPageBanner.i18n.alias.php'; +$wgExtensionMessagesFiles['WikidataPageBannerMagic'] = + __DIR__ . '/WikidataPageBanner.i18n.magic.php'; // Register hooks // Hook to inject banner code diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 770ef8b..0b3b909 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -65,7 +65,7 @@ * @return output */ public static function addCustomBanner( $parser, $bannername ) { - global $wgBannerNamespaces, $wgStandardSizes; + global $wgBannerNamespaces; $banner = ''; $title = $parser-getTitle(); $ns = $title-getNamespace(); @@ -126,7 +126,7 @@ * @return string|null Html code of the banner or null if invalid bannername */ public static function getBannerHtml( $title, $bannername ) { - global $wgStandardSizes, $wgScript, $wgArticlePath; + global $wgStandardSizes, $wgArticlePath; $urls = self::getStandardSizeUrls( $bannername ); $banner = null; /** @var String srcset attribute for img element of banner image */ -- To view, visit https://gerrit.wikimedia.org/r/216108 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I6c048dda865acc11d7dc32b1d092e105d1e09ec2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Add php entry points for WikidataPageBanner - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/215574 Change subject: Add php entry points for WikidataPageBanner .. Add php entry points for WikidataPageBanner As per https://www.mediawiki.org/wiki/Continuous_integration/Entry_points#PHP add composer.json file for mediawiki codesniffer. Bug: T101223 Change-Id: Ic867f1ea75de990c02786ad8116ae1c322025dab --- M .gitignore A composer.json 2 files changed, 19 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/74/215574/1 diff --git a/.gitignore b/.gitignore index 07e6e47..e50cdbd 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,10 @@ /node_modules +/composer.phar +/vendor/ +tmp/ +docs/ +dev-scripts/remotes/ +vendor/ +composer.phar +composer.lock +tests/report diff --git a/composer.json b/composer.json new file mode 100644 index 000..8e7abf6 --- /dev/null +++ b/composer.json @@ -0,0 +1,10 @@ +{ + require-dev: { + mediawiki/mediawiki-codesniffer: 0.2.0 + }, + scripts: { + test: [ + phpcs --standard=vendor/mediawiki/mediawiki-codesniffer/MediaWiki --extensions=php,php5,inc --ignore=vendor -p . + ] + } +} -- To view, visit https://gerrit.wikimedia.org/r/215574 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic867f1ea75de990c02786ad8116ae1c322025dab Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner option to add icons added - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/215029 Change subject: WikidataPageBanner option to add icons added .. WikidataPageBanner option to add icons added The extension now supports defining new icons in its configuration, which can then be activated by parameters to {{PAGEBANNER...}} to render on the banner. The icons are represented as an array of key=value pairs with keys representing parameter names and values representing details about the icon. The getBannerIcons() traverses this array, checks if its set as a parameter to {{PAGEBANNER...}} and returns the icons array to insert into the banner template. The parameter is of the form 'star=yes', to render a star icon. depends on I1e67311e76c66c26bd8b1f2dc22856dffd98c99a Bug: T100486 Change-Id: I36471b826e7cce9405c8d135bb3934bb0214170c --- M WikidataPageBanner.php A includes/WikidataPageBanner.functions.php M includes/WikidataPageBanner.hooks.php M resources/ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less M templates/banner.mustache 5 files changed, 77 insertions(+), 2 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/29/215029/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index c634f5b..0c2a1ff 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -27,10 +27,31 @@ * * $wgPBImage - static pagebanner image url, use only filename, do not prefix 'File:' * $wgBannerNamespace - Namespaces on which to display banner + * $wgBannerIcons - array of icons with keys representing parameter names and + * values representing an array of values as + * (icon-file-name, icon-name, url of page about icon) + * $wgBannerIconSize - Size of each banner icon */ $wgPBImage = ; $wgBannerNamespaces = array( NS_MAIN ); - +$wgBannerIcons = array( + 'star' = array( + 'Cscr-featured.svg', 'Star Article', 'http://localhost:8080/wiki/Main_Page' + ), + 'unesco' = array( + 'WorldHeritageBlanc.svg', 'UNESCO World Heritage Site', 'http://localhost:8080/wiki/Main_Page' + ), + 'otbp' = array( + 'Yes_Check_Circle.svg', 'Previously Off the beaten path', 'http://localhost:8080/wiki/Main_Page' + ), + 'dotm' = array( + 'Yes_Check_Circle.svg', 'Previous_Destinations_of_the_month', 'http://localhost:8080/wiki/Main_Page' + ), + 'ftt' = array( + 'Yes_Check_Circle.svg', 'Previously featured travel topic', 'http://localhost:8080/wiki/Main_Page' + ), + ); +$wgBannerIconSize = 27; /* Setup */ // autoloader $wgAutoloadClasses['WikidataPageBanner'] = __DIR__ . 'includes/WikidataPageBanner.hooks.php'; @@ -49,5 +70,7 @@ // include WikidataPageBanner class file require_once __DIR__ . /includes/WikidataPageBanner.hooks.php; +require_once __DIR__ . /includes/WikidataPageBanner.functions.php; require_once __DIR__ . /resources/Resources.php; + diff --git a/includes/WikidataPageBanner.functions.php b/includes/WikidataPageBanner.functions.php new file mode 100644 index 000..31cdc18 --- /dev/null +++ b/includes/WikidataPageBanner.functions.php @@ -0,0 +1,31 @@ +?php +/** + * getBannerIcons Returns an array of icons with their url, name, and url of + * article they refer to + * @param $options array options passed as arguments to {{PAGEBANNER}} function + * @return array Array of icons with their url, name and and url of + * article they refer to. + */ +public function getBannerIcons( $options ) { + global $wgBannerIconSize, $wgBannerIcons; + $icons = array(); + $i = 0; + foreach ( $wgBannerIcons as $key = $value ) { + if ( isset( $options[$key] ) $options[$key] == 'yes' ) { + $size = $wgBannerIconSize; + $icon = $value; + $iconfilename = $icon[0]; + $iconname = $icon[1]; + $iconurl = $icon[2]; + $url = WikidataPageBanner::getBannerUrl( $iconfilename, $size ); + if ( $url !== null ) { + $icons[$i++] = array( + 'iconfileurl' = $url, + 'iconname' = $iconname, + 'iconurl' = $iconurl + ); + } + } + } + return $icons; +} diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 522cc0e..6829e6c 100644 --- a/includes/WikidataPageBanner.hooks.php +++
[MediaWiki-commits] [Gerrit] WikidataPageBanner add option caption - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/214895 Change subject: WikidataPageBanner add option caption .. WikidataPageBanner add option caption Add parameter 'caption' to {{PAGEBANNER}} function, which will display a caption on the banner image as a tooltip. Depends on I1e67311e76c66c26bd8b1f2dc22856dffd98c99a Bug: T100486 Change-Id: I2acffb73ba6d28fd72fe13cae26384a29b15fbae --- M includes/WikidataPageBanner.hooks.php M templates/banner.mustache 2 files changed, 4 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/95/214895/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 522cc0e..4a02028 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -73,6 +73,9 @@ $title = $parser-getTitle(); $ns = $title-getNamespace(); if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { + if ( isset( $opts['caption'] ) ) { + $params['caption'] = $opts['caption']; + } $banner = self::getBannerHtml( $fileurl, $title ); // Set 'articlebanner' property for future reference $parser-getOutput()-setProperty( 'articlebanner', $banner ); diff --git a/templates/banner.mustache b/templates/banner.mustache index cec3226..8909f1e 100644 --- a/templates/banner.mustache +++ b/templates/banner.mustache @@ -1,5 +1,5 @@ div class=noprint - div class=ext-wpb-pagebanner style=background-image:url({{banner}}) + div title={{caption}} class=ext-wpb-pagebanner style=background-image:url({{banner}}) div class=topbanner div class=name{{title}}/div div class=iconbox/div -- To view, visit https://gerrit.wikimedia.org/r/214895 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2acffb73ba6d28fd72fe13cae26384a29b15fbae Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner allow named parameters - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/214672 Change subject: WikidataPageBanner allow named parameters .. WikidataPageBanner allow named parameters Allow the use of parameters of the form name=value, as arguments to the parser function {{PAGEBANNER}}, for customizing. Required for https://phabricator.wikimedia.org/T100486 Change-Id: I1e67311e76c66c26bd8b1f2dc22856dffd98c99a --- M includes/WikidataPageBanner.hooks.php 1 file changed, 26 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/72/214672/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 522cc0e..3cb656d 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -64,6 +64,12 @@ */ public static function addCustomBanner( $parser, $bannername ) { global $wgBannerNamespaces; + // @var options array + $opts = array(); + for ( $i = 1; $i func_num_args(); $i++ ) { + $opts[] = func_get_arg( $i ); + } + $params = self::extractOptions( $opts ); $fileurl = self::getBannerUrl( $bannername ); // if given banner does not exist, return if ( $fileurl === null ) { @@ -143,4 +149,24 @@ $parser-setFunctionHook( 'PAGEBANNER', 'WikidataPageBanner::addCustomBanner', SFH_NO_HASH ); return true; } + + /** +* Converts an array of values in form [0] = name=value into a real +* associative array in form [name] = value +* +* @param array string $options +* @return array $results +*/ + public static function extractOptions( array $options ) { + $results = array(); + foreach ( $options as $option ) { + $pair = explode( '=', $option, 2 ); + if ( count( $pair ) == 2 ) { + $name = trim( $pair[0] ); + $value = trim( $pair[1] ); + $results[$name] = $value; + } + } + return $results; + } } -- To view, visit https://gerrit.wikimedia.org/r/214672 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1e67311e76c66c26bd8b1f2dc22856dffd98c99a Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner: Add template for banner markup - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/213576 Change subject: WikidataPageBanner: Add template for banner markup .. WikidataPageBanner: Add template for banner markup The pagebanner rendered by echoing raw html, is now rendered using mustache template supported by core. Bug: T98152 Change-Id: Ib6736a75a34c5fc2d5648e3c7d7dd91b95092b90 --- M includes/WikidataPageBanner.hooks.php A templates/banner.mustache 2 files changed, 16 insertions(+), 16 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/76/213576/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3b67b7e..522cc0e 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -121,22 +121,14 @@ * TODO:Move this banner html code to a template. */ public static function getBannerHtml( $bannerurl, $title ) { - $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . - Html::openElement( 'div', array( 'class' = 'ext-wpb-pagebanner', - 'style' = background-image:url($bannerurl); - ) - ) . - Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . - Html::element( 'div', - array( 'class' = 'name' ), - $title - ) . - Html::element( 'div', - array( 'class' = 'iconbox' ) - ) . - Html::closeElement( 'div' ) . - Html::closeElement( 'div' ) . - Html::closeElement( 'div' ); + $templateParser = new TemplateParser( __DIR__ . '/../templates' ); + $banner = $templateParser-processTemplate( + 'banner', + array( + 'banner' = $bannerurl, + 'title' = $title + ) + ); return $banner; } diff --git a/templates/banner.mustache b/templates/banner.mustache new file mode 100644 index 000..cec3226 --- /dev/null +++ b/templates/banner.mustache @@ -0,0 +1,8 @@ +div class=noprint + div class=ext-wpb-pagebanner style=background-image:url({{banner}}) + div class=topbanner + div class=name{{title}}/div + div class=iconbox/div + /div + /div +/div -- To view, visit https://gerrit.wikimedia.org/r/213576 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib6736a75a34c5fc2d5648e3c7d7dd91b95092b90 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] WikidataPageBanner::getWikidataBanner added - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/213478 Change subject: WikidataPageBanner::getWikidataBanner added .. WikidataPageBanner::getWikidataBanner added A function getWikidataBanner() is added, which fetches a banner for an article page if the page has an associated item page and a banner statement in wikidata. The function returns the banner image name on wikimedia commons or 'null' if it fails to achieve the above objective. Bug: T98044 Change-Id: Ic05f6c132e4e5f4d96f0d986d068941eb27480a8 --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 2 files changed, 47 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/78/213478/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index c634f5b..5ffcff3 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -27,9 +27,11 @@ * * $wgPBImage - static pagebanner image url, use only filename, do not prefix 'File:' * $wgBannerNamespace - Namespaces on which to display banner + * $wgBannerProperty - Banner property on wikidata which holds commons media file */ $wgPBImage = ; $wgBannerNamespaces = array( NS_MAIN ); +$wgBannerProperty = P948; /* Setup */ // autoloader diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3b67b7e..bb5bc2b 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -21,7 +21,13 @@ } else if ( $article-getParserOutput()-getProperty( 'articlebanner' ) == null ) { // if the page uses no 'PAGEBANNER' invocation, insert default banner, // only set articlebanner property on OutputPage - $bannerurl = self::getBannerUrl( $wgPBImage ); + $bannername = self::getWikidataBanner( $title ); + $bannerurl = null; + if ( $bannername == null ) { + $bannerurl = self::getBannerUrl( $wgPBImage ); + } else { + $bannerurl = self::getBannerUrl( $bannername ); + } $ns = $title-getNamespace(); // banner only on specified namespaces, and not Main Page of wiki // if no image exists with given bannerurl, no banner will be added @@ -151,4 +157,42 @@ $parser-setFunctionHook( 'PAGEBANNER', 'WikidataPageBanner::addCustomBanner', SFH_NO_HASH ); return true; } + + /** +* Fetches banner from wikidata for the specified page +* +* @param Title $title Title of the page +* @return String|null file name of the banner from wikitata [description] +* or null if none found +*/ + public static function getWikidataBanner( $title ) { + global $wgBannerProperty; + $banner = null; + // Ensure Wikibase client is installed + if ( class_exists( 'Wikibase\Client\WikibaseClient' ) ) { + $entityIdLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() + -getStore() + -getEntityIdLookup(); + $itemId = $entityIdLookup-getEntityIdForTitle( $title ); + // check if this page has an associated item page + $entityLookup = Wikibase\Client\WikibaseClient::getDefaultInstance() + -getStore() + -getEntityLookup(); + /** @var Wikibase\DataModel\Entity\Item $item */ + if ( $itemId != null ) { + $item = $entityLookup-getEntity( $itemId ); + $statements = $item-getStatements()-getWithPropertyId( + new Wikibase\DataModel\Entity\PropertyId( $wgBannerProperty ) + )-getBestStatements(); + if ( !$statements-isEmpty() ) { + $statements = $statements-toArray(); + $snak = $statements[0]-getMainSnak(); + if ( $snak instanceof Wikibase\DataModel\Snak\PropertyValueSnak ) { + $banner = $snak-getDataValue()-getValue(); + } + } + } + } + return $banner; + } } -- To view, visit https://gerrit.wikimedia.org/r/213478 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id:
[MediaWiki-commits] [Gerrit] WikidataPageBanner client-side image loading - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/212512 Change subject: WikidataPageBanner client-side image loading .. WikidataPageBanner client-side image loading In order to load banner image of appropriate browser size, a js module added which reads data-src attribute on .ext-wpb-pagebanner element and retrieves an image of appropriate size via api request. Change-Id: I3b3564d5bf96528108ce7eb0b41937356f766722 --- M includes/WikidataPageBanner.hooks.php M resources/Resources.php A resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js 3 files changed, 37 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/12/212512/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3b67b7e..eb9f3ea 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -27,7 +27,7 @@ // if no image exists with given bannerurl, no banner will be added if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() $bannerurl !== null ) { - $banner = self::getBannerHtml( $bannerurl, $title ); + $banner = self::getBannerHtml( $bannerurl, $title, $wgPBImage ); $out-addHtml( $banner ); $out-setProperty( 'articlebanner', $banner ); } @@ -51,6 +51,7 @@ if ( $out-getProperty( 'articlebanner' ) != null ) { // if articlebanner property is set, we need to add banner styles $out-addModuleStyles( 'ext.WikidataPageBanner' ); + $out-addModuleScripts( 'ext.WikidataPageBanner.loadImage' ); } } @@ -73,7 +74,7 @@ $title = $parser-getTitle(); $ns = $title-getNamespace(); if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { - $banner = self::getBannerHtml( $fileurl, $title ); + $banner = self::getBannerHtml( $fileurl, $title, $bannername ); // Set 'articlebanner' property for future reference $parser-getOutput()-setProperty( 'articlebanner', $banner ); } @@ -120,10 +121,11 @@ * @return string Html code of the banner * TODO:Move this banner html code to a template. */ - public static function getBannerHtml( $bannerurl, $title ) { + public static function getBannerHtml( $bannerurl, $title, $file ) { $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . Html::openElement( 'div', array( 'class' = 'ext-wpb-pagebanner', - 'style' = background-image:url($bannerurl); + 'style' = background-image:url($bannerurl);, + 'data-src' = $file ) ) . Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . diff --git a/resources/Resources.php b/resources/Resources.php index 018323d..94e80fb 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -32,3 +32,14 @@ 'remoteExtPath' = 'WikidataPageBanner/resources', 'targets' = array( 'desktop', 'mobile' ), ); +$wgResourceModules['ext.WikidataPageBanner.loadImage'] = array( + 'scripts' = array( + 'ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js', + ), + 'localBasePath' = __DIR__, + 'remoteExtPath' = 'WikidataPageBanner/resources', + 'dependencies' = array( + 'mediawiki.api' + ), + 'targets' = array( 'desktop', 'mobile' ), +); diff --git a/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js b/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js new file mode 100644 index 000..99f7ded --- /dev/null +++ b/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js @@ -0,0 +1,20 @@ +/* + * Javascript for loading banner dynamically depending upon browser size + */ +( function ( mw, $ ) { + var src = $( '.ext-wpb-pagebanner' ).data( 'src' ); + src = 'File:abcd.jpg'; + //alert( src ); + //console.log(mw.Api); + var api = new mw.Api(); + api.get({ + 'action': 'query', + 'prop': 'imageinfo', +
[MediaWiki-commits] [Gerrit] WikidataPageBanner image loading via api - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/211676 Change subject: WikidataPageBanner image loading via api .. WikidataPageBanner image loading via api Change-Id: Ic5ab6c6851915535b39dce1d0d55c83def71066e --- M includes/WikidataPageBanner.hooks.php M resources/Resources.php A resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js 3 files changed, 37 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/76/211676/1 diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 3b67b7e..eb9f3ea 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -27,7 +27,7 @@ // if no image exists with given bannerurl, no banner will be added if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() $bannerurl !== null ) { - $banner = self::getBannerHtml( $bannerurl, $title ); + $banner = self::getBannerHtml( $bannerurl, $title, $wgPBImage ); $out-addHtml( $banner ); $out-setProperty( 'articlebanner', $banner ); } @@ -51,6 +51,7 @@ if ( $out-getProperty( 'articlebanner' ) != null ) { // if articlebanner property is set, we need to add banner styles $out-addModuleStyles( 'ext.WikidataPageBanner' ); + $out-addModuleScripts( 'ext.WikidataPageBanner.loadImage' ); } } @@ -73,7 +74,7 @@ $title = $parser-getTitle(); $ns = $title-getNamespace(); if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { - $banner = self::getBannerHtml( $fileurl, $title ); + $banner = self::getBannerHtml( $fileurl, $title, $bannername ); // Set 'articlebanner' property for future reference $parser-getOutput()-setProperty( 'articlebanner', $banner ); } @@ -120,10 +121,11 @@ * @return string Html code of the banner * TODO:Move this banner html code to a template. */ - public static function getBannerHtml( $bannerurl, $title ) { + public static function getBannerHtml( $bannerurl, $title, $file ) { $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . Html::openElement( 'div', array( 'class' = 'ext-wpb-pagebanner', - 'style' = background-image:url($bannerurl); + 'style' = background-image:url($bannerurl);, + 'data-src' = $file ) ) . Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . diff --git a/resources/Resources.php b/resources/Resources.php index 018323d..94e80fb 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -32,3 +32,14 @@ 'remoteExtPath' = 'WikidataPageBanner/resources', 'targets' = array( 'desktop', 'mobile' ), ); +$wgResourceModules['ext.WikidataPageBanner.loadImage'] = array( + 'scripts' = array( + 'ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js', + ), + 'localBasePath' = __DIR__, + 'remoteExtPath' = 'WikidataPageBanner/resources', + 'dependencies' = array( + 'mediawiki.api' + ), + 'targets' = array( 'desktop', 'mobile' ), +); diff --git a/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js b/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js new file mode 100644 index 000..99f7ded --- /dev/null +++ b/resources/ext.WikidataPageBanner.loadImage/ext.WikidataPageBanner.loadImage.js @@ -0,0 +1,20 @@ +/* + * Javascript for loading banner dynamically depending upon browser size + */ +( function ( mw, $ ) { + var src = $( '.ext-wpb-pagebanner' ).data( 'src' ); + src = 'File:abcd.jpg'; + //alert( src ); + //console.log(mw.Api); + var api = new mw.Api(); + api.get({ + 'action': 'query', + 'prop': 'imageinfo', + 'format': 'json', + 'iiprop': 'url', + 'iiurlwidth': '200', + 'titles': src + }).done( function( data ){ + console.log( data ); + } ); +}(
[MediaWiki-commits] [Gerrit] WikidataPageBanner: PAGEBANNER magic word added - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/209432 Change subject: WikidataPageBanner: PAGEBANNER magic word added .. WikidataPageBanner: PAGEBANNER magic word added 'PAGEBANNER' magic word added to WikidataPageBanner extension, which accepts an image file url on the wiki and renders an alternative pagebanner with that image as the background. Allows the user to control banner image. Bug: T97455 Change-Id: I37d02267b61fc070b85a9974eefc5cb66b81083e --- M WikidataPageBanner.i18n.alias.php M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php 3 files changed, 88 insertions(+), 24 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/32/209432/1 diff --git a/WikidataPageBanner.i18n.alias.php b/WikidataPageBanner.i18n.alias.php index 4258562..c253604 100644 --- a/WikidataPageBanner.i18n.alias.php +++ b/WikidataPageBanner.i18n.alias.php @@ -7,3 +7,8 @@ */ $specialPageAliases['en'] = array(); +$magicWords = array(); +$magicWords['en'] = array( + 'PAGEBANNER' = array( 0, 'PAGEBANNER' ), +); + diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index 6ecfd0b..ca14bf7 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -44,6 +44,12 @@ $wgHooks['ArticleViewHeader'][] = 'WikidataPageBanner::viewBanner'; // Load Banner modules, styles $wgHooks['BeforePageDisplay'][] = 'WikidataPageBanner::loadModules'; +$wgHooks['ParserFirstCallInit'][] = 'WikidataPageBannerSetupParserFunction'; + +function WikidataPageBannerSetupParserFunction( $parser ) { + $parser-setFunctionHook( 'PAGEBANNER', 'WikidataPageBanner::loadBanner', SFH_NO_HASH ); + return true; +} // include WikidataPageBanner class file require_once __DIR__ . /includes/WikidataPageBanner.hooks.php; diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 0df9704..26bedca 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -1,5 +1,6 @@ ?php class WikidataPageBanner { + /** * WikidataPageBanner::viewBanner * @@ -7,30 +8,19 @@ * @return bool */ public static function viewBanner( $article ) { - global $wgPBImageUrl, $wgBannerNamespaces; - $bannerurl = $wgPBImageUrl; - $title = $article-getTitle(); - $ns = $title-getNamespace(); - // banner only on specified namespaces, and not Main Page of wiki - if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { - $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . - Html::openElement( 'div', array( 'class' = 'ext-wpb-pagebanner', - 'style' = background-image:url($bannerurl); - ) - ) . - Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . - Html::element( 'div', - array( 'class' = 'name' ), - $title - ) . - Html::element( 'div', - array( 'class' = 'iconbox' ) - ) . - Html::closeElement( 'div' ) . - Html::closeElement( 'div' ) . - Html::closeElement( 'div' ) . \n; - $out = $article-getContext()-getOutput(); - $out-addHtml( $banner ); + // if the page uses no #PAGEBANNER invocation, insert default banner + $text = $article-getPage()-getRawText(); + if ( !MagicWord::get( 'PAGEBANNER' )-match( $text ) ) { + global $wgPBImageUrl, $wgBannerNamespaces; + $bannerurl = $wgPBImageUrl; + $title = $article-getTitle(); + $ns = $title-getNamespace(); + // banner only on specified namespaces, and not Main Page of wiki + if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { + $banner = self::createBanner( $bannerurl, $title ); + $out = $article-getContext()-getOutput(); + $out-addHtml( $banner ); + } } return true; } @@ -50,4 +40,67 @@ $out-addModuleStyles( 'ext.WikidataPageBanner' ); } } + + /** +* WikidataPageBanner::loadBanner +* Parser function hooked to 'PAGEBANNER' magic word, to expand and load banner. +
[MediaWiki-commits] [Gerrit] WikidataPageBanner minor issues fixed - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/208961 Change subject: WikidataPageBanner minor issues fixed .. WikidataPageBanner minor issues fixed As a followup on Iba7cea63902e67e195f4c2a3484d85cbcdf203b6, the following issues have been fixed: 1.Version number fixed 2.messages,dependencies removed from style module 3.Functionality to render banner on any namespace added via a config variable Change-Id: I598deccd368dee31361293e77b8ed59c005a65f2 --- M WikidataPageBanner.php M includes/WikidataPageBanner.hooks.php M resources/Resources.php 3 files changed, 8 insertions(+), 10 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/61/208961/1 diff --git a/WikidataPageBanner.php b/WikidataPageBanner.php index 7d655cd..6ecfd0b 100644 --- a/WikidataPageBanner.php +++ b/WikidataPageBanner.php @@ -17,7 +17,7 @@ 'description'= Render banners on wikivoyage, 'descriptionmsg' = 'Display pagewide banners on wikivoyage', 'author' = array( 'Sumit Asthana' ), - 'version'= '0.0.0', + 'version'= '0.0.1', 'url'= 'https://www.mediawiki.org/wiki/Extension:WikidataPageBanner', 'license-name' = 'GPL-2.0+', ); @@ -26,8 +26,10 @@ * Options: * * $wgPBImage - static pagebanner image url + * $wgBannerNamespace - Namespaces on which to display banner */ $wgPBImageUrl = http://upload.wikimedia.org/wikipedia/commons/a/a0/South_America_Wikivoyage_banner.jpg;; +$wgBannerNamespaces = array( NS_MAIN ); /* Setup */ // autoloader diff --git a/includes/WikidataPageBanner.hooks.php b/includes/WikidataPageBanner.hooks.php index 9584fb4..487d93f 100644 --- a/includes/WikidataPageBanner.hooks.php +++ b/includes/WikidataPageBanner.hooks.php @@ -7,15 +7,15 @@ * @return bool */ public static function viewBanner( $article ) { - global $wgPBImageUrl; + global $wgPBImageUrl, $wgBannerNamespaces; $bannerurl = $wgPBImageUrl; $title = $article-getTitle(); $ns = $title-getNamespace(); // banner only on main namespacem, and not Main Page of wiki - if ( $ns == NS_MAIN !$title-isMainPage() ) { + if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . Html::openElement( 'div', array( 'class' = 'ext-wpb-pagebanner', - 'style' = 'background-image:url('.$bannerurl.');' + 'style' = background-image:url($bannerurl); ) ) . Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . @@ -43,8 +43,9 @@ * @return bool */ public static function loadModules( $out, $parserOutput ) { + global $wgBannerNamespaces; $title = $out-getTitle(); - if ( $title-getNamespace() == NS_MAIN !$title-isMainPage() ) { + if ( in_array( $ns, $wgBannerNamespaces ) !$title-isMainPage() ) { // Setup banner styling, only if main namespace, and not Main Page of wiki $out-addModuleStyles( 'ext.WikidataPageBanner' ); } diff --git a/resources/Resources.php b/resources/Resources.php index 44da9f2..018323d 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -28,11 +28,6 @@ 'styles' = array( 'ext.WikidataPageBanner.styles/ext.WikidataPageBanner.less', ), - 'messages' = array( - ), - 'dependencies' = array( - ), - 'localBasePath' = __DIR__, 'remoteExtPath' = 'WikidataPageBanner/resources', 'targets' = array( 'desktop', 'mobile' ), -- To view, visit https://gerrit.wikimedia.org/r/208961 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I598deccd368dee31361293e77b8ed59c005a65f2 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] PageBanner: Static banner placeholder created - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/208096 Change subject: PageBanner: Static banner placeholder created .. PageBanner: Static banner placeholder created A static banner placeholder created on top of each Article page(Pages in the 'Main' namespace). Other pages remain unaffected. To achieve this, the extension hides main h1 heading using custom css, and then adds banner placehold along lines of http://en.wikivoyage.org/wiki/Template:Pagebanner. The custom html code is inserted using 'ArticleViewHeader' hook. Bug: T94772 Change-Id: Iba7cea63902e67e195f4c2a3484d85cbcdf203b6 --- D BoilerPlate.php A WikidataPageBanner.class.php R WikidataPageBanner.i18n.alias.php A WikidataPageBanner.php D modules/ext.BoilerPlate.foo.css A modules/ext.WikidataPageBanner.css R modules/ext.WikidataPageBanner.js 7 files changed, 155 insertions(+), 68 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/96/208096/1 diff --git a/BoilerPlate.php b/BoilerPlate.php deleted file mode 100644 index b8daf3e..000 --- a/BoilerPlate.php +++ /dev/null @@ -1,59 +0,0 @@ -?php -/** - * BoilerPlate extension - the thing that needs you. - * - * For more info see http://mediawiki.org/wiki/Extension:BoilerPlate - * - * @file - * @ingroup Extensions - * @author John Doe, 2014 - * @license GNU General Public Licence 2.0 or later - */ - -$wgExtensionCredits['other'][] = array( - 'path' = __FILE__, - 'name' = 'BoilerPlate', - 'author' = array( - 'John Doe', - ), - 'version' = '0.2.0', - 'url' = 'https://www.mediawiki.org/wiki/Extension:BoilerPlate', - 'descriptionmsg' = 'boilerplate-desc', -); - -/* Setup */ - -// Register files -$wgAutoloadClasses['BoilerPlateHooks'] = __DIR__ . '/BoilerPlate.hooks.php'; -$wgAutoloadClasses['SpecialHelloWorld'] = __DIR__ . '/specials/SpecialHelloWorld.php'; -$wgMessagesDirs['BoilerPlate'] = __DIR__ . '/i18n'; -$wgExtensionMessagesFiles['BoilerPlateAlias'] = __DIR__ . '/BoilerPlate.i18n.alias.php'; - -// Register hooks -#$wgHooks['NameOfHook'][] = 'BoilerPlateHooks::onNameOfHook'; - -// Register special pages -$wgSpecialPages['HelloWorld'] = 'SpecialHelloWorld'; - -// Register modules -$wgResourceModules['ext.BoilerPlate.foo'] = array( - 'scripts' = array( - 'modules/ext.BoilerPlate.foo.js', - ), - 'styles' = array( - 'modules/ext.BoilerPlate.foo.css', - ), - 'messages' = array( - ), - 'dependencies' = array( - ), - - 'localBasePath' = __DIR__, - 'remoteExtPath' = 'examples/BoilerPlate', -); - - -/* Configuration */ - -// Enable Foo -#$wgBoilerPlateEnableFoo = true; diff --git a/WikidataPageBanner.class.php b/WikidataPageBanner.class.php new file mode 100644 index 000..76e8f35 --- /dev/null +++ b/WikidataPageBanner.class.php @@ -0,0 +1,54 @@ +?php +class WikidataPageBanner { + /** +* WikidataPageBanner::viewBanner +* +* @param Article $article +* @return bool +*/ + public static function viewBanner( $article ) { + global $wgOut, $wgPBImage, $wgIsMainPage; + $bannerurl = $wgPBImage; + $title = $article-getTitle(); + $ns = $title-getNamespace(); + // banner only on main namespace + if ( MWNamespace::equals( $ns, 0 ) ) { + $banner = Html::openElement( 'div', array( 'class' = 'noprint' ) ) . + Html::openElement( 'div', array( 'class' = 'mf-pagebanner', + 'style' = 'background-image:url('.$bannerurl.');' + ) + ) . + Html::openElement( 'div', array( 'class' = 'topbanner' ) ) . + Html::element( 'div', + array( 'class' = 'name' ), + $title + ) . + Html::element( 'div', + array( 'class' = 'iconbox' ) + ) . + Html::closeElement( 'div' ) . + Html::closeElement( 'div' ) . + Html::closeElement( 'div' ) . \n; + $wgOut-addHtml( $banner ); + $wgIsMainPage = true; + } else { + $wgIsMainPage = false; + } + return true; + } + + /** +* WikidataPageBanner::loadBanner +* +* @param $out OutputPage +* @param $parserOutput ParserOutput +* @return bool +*/ + public static function loadModules( $out, $parserOutput ) { +
[MediaWiki-commits] [Gerrit] README Changed - change (mediawiki...WikidataPageBanner)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/201270 Change subject: README Changed .. README Changed Bug: T93127 Change-Id: If985231679a47897307ec37019efccc15061db33 --- M README 1 file changed, 3 insertions(+), 6 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikidataPageBanner refs/changes/70/201270/1 diff --git a/README b/README index 2831f44..df5883f 100644 --- a/README +++ b/README @@ -1,8 +1,5 @@ Wikidata PageBanner Extension = -This is an initial repository for developing Wikidata PageBanner Extension as -per the proposal at https://phabricator.wikimedia.org/T93106 -for the tracking bug at https://phabricator.wikimedia.org/T77925 - -After the initial setup of the boilerplate extension, the code will be moved to gerrit for development. -The tracking bug for repository migration to gerrit is at https://phabricator.wikimedia.org/T93127 +This is a repository for Wikidata PageBanner Extension for Wikivoyage as +per the proposal at https://phabricator.wikimedia.org/T93106. +The tracking bug for the extension is at https://phabricator.wikimedia.org/T77925 -- To view, visit https://gerrit.wikimedia.org/r/201270 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If985231679a47897307ec37019efccc15061db33 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/WikidataPageBanner Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] MediaViewer cancel button made to close viewer - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/200201 Change subject: MediaViewer cancel button made to close viewer .. MediaViewer cancel button made to close viewer Cancel button on media viewer currently fires the 'back' event inherited from overlay. A new event added to cancel button in mediaviewer to close the mediaviewer overlay when the button is clicked Bug: T94188 Change-Id: I5cb371fcbe1726981e3dc5092354625e2df35e6b --- M javascripts/modules/mediaViewer/ImageOverlay.js 1 file changed, 11 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/01/200201/1 diff --git a/javascripts/modules/mediaViewer/ImageOverlay.js b/javascripts/modules/mediaViewer/ImageOverlay.js index 733899e..226fe22 100644 --- a/javascripts/modules/mediaViewer/ImageOverlay.js +++ b/javascripts/modules/mediaViewer/ImageOverlay.js @@ -43,7 +43,8 @@ /** @inheritdoc */ events: $.extend( {}, Overlay.prototype.events, { - 'click .image-wrapper': 'onToggleDetails' + 'click .image-wrapper': 'onToggleDetails', + 'click .cancel': 'onExit' } ), /** @inheritdoc */ @@ -121,6 +122,15 @@ this._positionImage(); }, + /** +* Event handler to close media viewer on clicking cancel button. +*/ + onExit: function () { + ev.preventDefault(); + ev.stopPropagation(); + this.hide(); + } + /** @inheritdoc */ show: function () { Overlay.prototype.show.apply( this, arguments ); -- To view, visit https://gerrit.wikimedia.org/r/200201 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5cb371fcbe1726981e3dc5092354625e2df35e6b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/MobileFrontend Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] ChangeOpsMerge Case insensitive string check added - change (mediawiki...Wikibase)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/197909 Change subject: ChangeOpsMerge Case insensitive string check added .. ChangeOpsMerge Case insensitive string check added wbmergeitems adds alias when a duplicate label / alias already existed on target item, therefore a case insensitive string comparison added to generateLabelsChangeOps() for labels to avoid same labels with different case Bug: T91327 Change-Id: I67f0294c3fa07a8df71cb485decc885ef7f24dd7 --- M repo/includes/ChangeOp/ChangeOpsMerge.php 1 file changed, 1 insertion(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase refs/changes/09/197909/1 diff --git a/repo/includes/ChangeOp/ChangeOpsMerge.php b/repo/includes/ChangeOp/ChangeOpsMerge.php index 9aa152d..0ff160e 100644 --- a/repo/includes/ChangeOp/ChangeOpsMerge.php +++ b/repo/includes/ChangeOp/ChangeOpsMerge.php @@ -165,7 +165,7 @@ private function generateLabelsChangeOps() { foreach ( $this-fromItem-getLabels() as $langCode = $label ) { $toLabel = $this-toItem-getLabel( $langCode ); - if ( $toLabel === false || $toLabel === $label ) { + if ( $toLabel === false || strcasecmp( $toLabel, $label ) == 0 ) { $this-fromChangeOps-add( $this-getFingerprintChangeOpFactory()-newRemoveLabelOp( $langCode ) ); $this-toChangeOps-add( $this-getFingerprintChangeOpFactory()-newSetLabelOp( $langCode, $label ) ); } else { -- To view, visit https://gerrit.wikimedia.org/r/197909 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I67f0294c3fa07a8df71cb485decc885ef7f24dd7 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Sniff to check assignment expressions in while, if - change (mediawiki...codesniffer)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/196873 Change subject: Sniff to check assignment expressions in while,if .. Sniff to check assignment expressions in while,if Mediawiki Sniff to disallow assignment expressions within if and while clause as per php code conevntions Bug: T92744 Change-Id: Ia76818384d13a277bf7c31ee081ad3ff0df8df46 --- A MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php A MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_fail.php A MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_pass.php 3 files changed, 58 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/tools/codesniffer refs/changes/73/196873/1 diff --git a/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php b/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php new file mode 100644 index 000..c995f46 --- /dev/null +++ b/MediaWiki/Sniffs/ControlStructures/AssignmentInControlStructuresSniff.php @@ -0,0 +1,42 @@ +?php +/** + * Sniff to supress the use of: + * if( $a = foo() ) + * while( $a = foo() ) + */ +class MediaWiki_Sniffs_ControlStructures_AssignmentInControlStructuresSniff implements PHP_CodeSniffer_Sniff { + public function register() { + return array( + T_IF, + T_WHILE + ); + } + public function process( PHP_CodeSniffer_File $phpcsFile, $stackPtr ) { + $tokens = $phpcsFile-getTokens(); + $token = $tokens[$stackPtr]; + $type = $token['code']; + + // Skip invalid statement. + if ( isset($token['parenthesis_opener']) === false ) { + return; + } + + // get the bounds of the conditional part + $next = ++$token['parenthesis_opener']; + $end = --$token['parenthesis_closer']; + for (; $next = $end; ++$next) { + $code = $tokens[$next]['code']; + if( in_array( $code, PHP_CodeSniffer_Tokens::$assignmentTokens, true ) ) { + $error = 'Assignment expression not allowed within '.$tokens[$index]['content']; + if ( $type === T_IF ) { + $error .= if construct; + } else if ( $type === T_WHILE ) { + $error .= while construct; + } + $phpcsFile-addError($error, $stackPtr, 'NotAllowed'); + break; + } + } + } + +} diff --git a/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_fail.php b/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_fail.php new file mode 100644 index 000..af62f83 --- /dev/null +++ b/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_fail.php @@ -0,0 +1,8 @@ +?php +// fail test case for sniff for assignment expressions within if or while +if ( $i = foo() ) { + +} +while ( $row = $dbr-query( Query ) ) { + +} diff --git a/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_pass.php b/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_pass.php new file mode 100644 index 000..62ddcaa --- /dev/null +++ b/MediaWiki/Tests/files/ControlStructures/assignment_in_control_structures_pass.php @@ -0,0 +1,8 @@ +?php +// pass test case for sniff for assignment expressions within if or while +if ( $row 1 ) { + +} +while ( $row 1 ) { + +} -- To view, visit https://gerrit.wikimedia.org/r/196873 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia76818384d13a277bf7c31ee081ad3ff0df8df46 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/tools/codesniffer Gerrit-Branch: master Gerrit-Owner: Sumit asthana.sumi...@gmail.com ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] PhotoUploadOverlay and Progress use View##event - change (mediawiki...MobileFrontend)
Sumit has uploaded a new change for review. https://gerrit.wikimedia.org/r/196609 Change subject: PhotoUploadOverlay and Progress use View##event .. PhotoUploadOverlay and Progress use View##event PhotoUploadOverlay and PhotoUploadProgress made to use View##events Bug: T88568 Change-Id: I4004187ab3454a3976d5b84a57576156e78af935 --- M javascripts/modules/uploads/PhotoUploadOverlay.js M javascripts/modules/uploads/PhotoUploadProgress.js 2 files changed, 38 insertions(+), 14 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend refs/changes/09/196609/1 diff --git a/javascripts/modules/uploads/PhotoUploadOverlay.js b/javascripts/modules/uploads/PhotoUploadOverlay.js index f4566a1..79dcbb2 100644 --- a/javascripts/modules/uploads/PhotoUploadOverlay.js +++ b/javascripts/modules/uploads/PhotoUploadOverlay.js @@ -45,6 +45,14 @@ msg: mw.msg( 'mobile-frontend-photo-submit' ) } ] }, + /** @inheritdoc */ + events: $.extend( {}, Overlay.prototype.events, { + 'click .submit': 'onSubmit', + 'keyup textarea': 'onKeyUp', + // use input event too, Firefox doesn't fire keyup on many devices: + // https://bugzilla.mozilla.org/show_bug.cgi?id=737658 + 'input textarea': 'onKeyUp' + } ), className: 'overlay photo-overlay', @@ -218,20 +226,9 @@ Overlay.prototype.postRender.apply( this, arguments ); $submitButton = this.$( '.submit' ) - .prop( 'disabled', true ) - .on( 'click', function () { - self.schema.log( { - action: 'previewSubmit' - } ); - self._submit(); - } ); + .prop( 'disabled', true ); this.$description = this.$( 'textarea' ) - .microAutosize() - // use input event too, Firefox doesn't fire keyup on many devices: - // https://bugzilla.mozilla.org/show_bug.cgi?id=737658 - .on( 'keyup input', function () { - $submitButton.prop( 'disabled', self.$description.val() === '' ); - } ); + .microAutosize(); // make license links open in separate tabs this.$( '.license a' ).attr( 'target', '_blank' ); @@ -315,6 +312,23 @@ popup.show( mw.msg( 'mobile-frontend-photo-upload-error-file-type' ), 'toast error' ); self.hide( true ); } ); + }, + + /** +* event handler to submit +*/ + onSubmit: function () { + this.schema.log( { + action: 'previewSubmit' + } ); + this._submit(); + }, + + /** +* key up event handler +*/ + onKeyUp: function () { + this.$( '.submit' ).prop( 'disabled', this.$( 'textarea' ).val() === '' ); } } ); diff --git a/javascripts/modules/uploads/PhotoUploadProgress.js b/javascripts/modules/uploads/PhotoUploadProgress.js index cbc4547..63990fe 100644 --- a/javascripts/modules/uploads/PhotoUploadProgress.js +++ b/javascripts/modules/uploads/PhotoUploadProgress.js @@ -22,6 +22,10 @@ defaults: $.extend( {}, Overlay.prototype.defaults, { uploadingMsg: mw.msg( 'mobile-frontend-image-uploading' ) } ), + /** @inheritdoc */ + events: $.extend( {}, Overlay.prototype.events, { + 'click .submit': 'onSubmit' + } ), template: mw.template.get( 'mobile.uploads', 'PhotoUploadProgress.hogan' ), fullScreen: false, @@ -34,7 +38,6 @@ /** @inheritdoc */ postRender: function () { Overlay.prototype.postRender.apply( this, arguments ); - this.$( '.submit' ).on( 'click', $.proxy( this, 'emit', 'submit' ) ); }, /** @@ -77,6 +80,13 @@ this.$( '.right' ).remove(); } this.progressBar.setValue( value ); + }, + +