[MediaWiki-commits] [Gerrit] Only load mw.PopUpMediaTransform on pages that plausibly nee... - change (mediawiki...TimedMediaHandler)
jenkins-bot has submitted this change and it was merged. Change subject: Only load mw.PopUpMediaTransform on pages that plausibly need it .. Only load mw.PopUpMediaTransform on pages that plausibly need it Rather than load mw.PopUpMediaTransform unconditionally, rely on the parser hook to cover most cases, and use TimedMediaHandlerHooks::pageOutputHook to cover the rest: namely, special pages that are liable to include timed media. Bug: 0 Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b --- M TimedMediaHandler.hooks.php 1 file changed, 45 insertions(+), 3 deletions(-) Approvals: Brian Wolff: Looks good to me, approved jenkins-bot: Verified diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index 2fac670..20ee06d 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -104,9 +104,12 @@ // Add parser hook $wgParserOutputHooks['TimedMediaHandler'] = array( 'TimedMediaHandler', 'outputHook' ); - // We should probably move this script output to a parser function but not working correctly in - // dynamic contexts ( for example in special upload, when there is an existing file warning. ) + // Use a BeforePageDisplay hook to load the styles in pages that pull in media dynamically. + // (Special:Upload, for example, when there is an existing file warning.) $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook'; + + // Make sure modules are loaded on image pages that don't have a media file in the wikitext. + $wgHooks['ImageOpenShowImageInlineBefore'][] = 'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore'; // Exclude transcoded assets from normal thumbnail purging // ( a maintenance script could handle transcode asset purging) @@ -146,6 +149,19 @@ $wgHooks[ 'NewRevisionFromEditComplete' ][] = 'TimedMediaHandlerHooks::onNewRevisionFromEditComplete'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::checkSchemaUpdates'; + return true; + } + + /** +* @param $imagePage ImagePage +* @param $wgOut OutputPage +* @return bool +*/ + public static function onImageOpenShowImageInlineBefore( $imagePage, $out ) { + $handler = $imagePage-getDisplayedFile()-getHandler(); + if ( $handler !== false $handler instanceof TimedMediaHandler ) { + TimedMediaHandler::outputHook( $out, null, null ); + } return true; } @@ -342,12 +358,38 @@ } /** +* Add JavaScript and CSS for special pages that may include timed media +* but which will not fire the parser hook. +* +* FIXME: There ought to be a better interface for determining whether the +* page is liable to contain timed media. +* * @param $out OutputPage * @param $sk * @return bool */ static function pageOutputHook( $out, $sk ){ - $out-addModules( 'mw.PopUpMediaTransform' ); + $title = $out-getTitle(); + $namespace = $title-getNamespace(); + $addModules = false; + + if ( $namespace === NS_CATEGORY || $namespace === NS_TIMEDTEXT ) { + $addModules = true; + } + + if ( $title-isSpecialPage() ) { + list( $name, /* subpage */ ) = SpecialPageFactory::resolveAlias( $title-getDBkey() ); + if ( stripos( $name, 'file' ) !== false || stripos( $name, 'image' ) !== false + || $name === 'Search' || $name === 'GlobalUsage' ) { + $addModules = true; + } + } + + if ( $addModules ) { + $out-addModules( 'mw.PopUpMediaTransform' ); + $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/99597 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b Gerrit-PatchSet: 7 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: Brian Wolff bawolff...@gmail.com Gerrit-Reviewer: Legoktm legoktm.wikipe...@gmail.com Gerrit-Reviewer: Mdale md...@wikimedia.org Gerrit-Reviewer: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org
[MediaWiki-commits] [Gerrit] Only load mw.PopUpMediaTransform on pages that plausibly nee... - change (mediawiki...TimedMediaHandler)
Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/108649 Change subject: Only load mw.PopUpMediaTransform on pages that plausibly need it .. Only load mw.PopUpMediaTransform on pages that plausibly need it Rather than load mw.PopUpMediaTransform unconditionally, rely on the parser hook to cover most cases, and use TimedMediaHandlerHooks::pageOutputHook to cover the rest: namely, special pages that are liable to include timed media. Bug: 0 Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b --- M TimedMediaHandler.hooks.php 1 file changed, 45 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/49/108649/1 diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index 47a7f6e..064 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -104,9 +104,12 @@ // Add parser hook $wgParserOutputHooks['TimedMediaHandler'] = array( 'TimedMediaHandler', 'outputHook' ); - // We should probably move this script output to a parser function but not working correctly in - // dynamic contexts ( for example in special upload, when there is an existing file warning. ) + // Use a BeforePageDisplay hook to load the styles in pages that pull in media dynamically. + // (Special:Upload, for example, when there is an existing file warning.) $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook'; + + // Make sure modules are loaded on image pages that don't have a media file in the wikitext. + $wgHooks['ImageOpenShowImageInlineBefore'][] = 'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore'; // Exclude transcoded assets from normal thumbnail purging // ( a maintenance script could handle transcode asset purging) @@ -146,6 +149,19 @@ $wgHooks[ 'NewRevisionFromEditComplete' ][] = 'TimedMediaHandlerHooks::onNewRevisionFromEditComplete'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::checkSchemaUpdates'; + return true; + } + + /** +* @param $imagePage ImagePage +* @param $wgOut OutputPage +* @return bool +*/ + public static function onImageOpenShowImageInlineBefore( $imagePage, $out ) { + $handler = $imagePage-getDisplayedFile()-getHandler(); + if ( $handler !== false $handler instanceof TimedMediaHandler ) { + TimedMediaHandler::outputHook( $out, null, null ); + } return true; } @@ -342,13 +358,38 @@ } /** +* Add JavaScript and CSS for special pages that may include timed media +* but which will not fire the parser hook. +* +* FIXME: There ought to be a better interface for determining whether the +* page is liable to contain timed media. +* * @param $out OutputPage * @param $sk * @return bool */ static function pageOutputHook( $out, $sk ){ - $out-addModules( 'mw.PopUpMediaTransform' ); - $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + $title = $out-getTitle(); + $namespace = $title-getNamespace(); + $addModules = false; + + if ( $namespace === NS_CATEGORY || $namespace === NS_TIMEDTEXT ) { + $addModules = true; + } + + if ( $title-isSpecialPage() ) { + list( $name, /* subpage */ ) = SpecialPageFactory::resolveAlias( $title-getDBkey() ); + if ( stripos( $name, 'file' ) !== false || stripos( $name, 'image' ) !== false + || $name === 'Search' || $name === 'GlobalUsage' ) { + $addModules = true; + } + } + + if ( $addModules ) { + $out-addModules( 'mw.PopUpMediaTransform' ); + $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/108649 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: wmf/1.23wmf10 Gerrit-Owner: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Only load mw.PopUpMediaTransform on pages that plausibly nee... - change (mediawiki...TimedMediaHandler)
jenkins-bot has submitted this change and it was merged. Change subject: Only load mw.PopUpMediaTransform on pages that plausibly need it .. Only load mw.PopUpMediaTransform on pages that plausibly need it Rather than load mw.PopUpMediaTransform unconditionally, rely on the parser hook to cover most cases, and use TimedMediaHandlerHooks::pageOutputHook to cover the rest: namely, special pages that are liable to include timed media. Bug: 0 Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b --- M TimedMediaHandler.hooks.php 1 file changed, 45 insertions(+), 4 deletions(-) Approvals: Ori.livneh: Looks good to me, approved jenkins-bot: Verified diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index 47a7f6e..064 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -104,9 +104,12 @@ // Add parser hook $wgParserOutputHooks['TimedMediaHandler'] = array( 'TimedMediaHandler', 'outputHook' ); - // We should probably move this script output to a parser function but not working correctly in - // dynamic contexts ( for example in special upload, when there is an existing file warning. ) + // Use a BeforePageDisplay hook to load the styles in pages that pull in media dynamically. + // (Special:Upload, for example, when there is an existing file warning.) $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook'; + + // Make sure modules are loaded on image pages that don't have a media file in the wikitext. + $wgHooks['ImageOpenShowImageInlineBefore'][] = 'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore'; // Exclude transcoded assets from normal thumbnail purging // ( a maintenance script could handle transcode asset purging) @@ -146,6 +149,19 @@ $wgHooks[ 'NewRevisionFromEditComplete' ][] = 'TimedMediaHandlerHooks::onNewRevisionFromEditComplete'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::checkSchemaUpdates'; + return true; + } + + /** +* @param $imagePage ImagePage +* @param $wgOut OutputPage +* @return bool +*/ + public static function onImageOpenShowImageInlineBefore( $imagePage, $out ) { + $handler = $imagePage-getDisplayedFile()-getHandler(); + if ( $handler !== false $handler instanceof TimedMediaHandler ) { + TimedMediaHandler::outputHook( $out, null, null ); + } return true; } @@ -342,13 +358,38 @@ } /** +* Add JavaScript and CSS for special pages that may include timed media +* but which will not fire the parser hook. +* +* FIXME: There ought to be a better interface for determining whether the +* page is liable to contain timed media. +* * @param $out OutputPage * @param $sk * @return bool */ static function pageOutputHook( $out, $sk ){ - $out-addModules( 'mw.PopUpMediaTransform' ); - $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + $title = $out-getTitle(); + $namespace = $title-getNamespace(); + $addModules = false; + + if ( $namespace === NS_CATEGORY || $namespace === NS_TIMEDTEXT ) { + $addModules = true; + } + + if ( $title-isSpecialPage() ) { + list( $name, /* subpage */ ) = SpecialPageFactory::resolveAlias( $title-getDBkey() ); + if ( stripos( $name, 'file' ) !== false || stripos( $name, 'image' ) !== false + || $name === 'Search' || $name === 'GlobalUsage' ) { + $addModules = true; + } + } + + if ( $addModules ) { + $out-addModules( 'mw.PopUpMediaTransform' ); + $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/108649 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: wmf/1.23wmf10 Gerrit-Owner: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Only load mw.PopUpMediaTransform on pages that plausibly nee... - change (mediawiki...TimedMediaHandler)
Ori.livneh has uploaded a new change for review. https://gerrit.wikimedia.org/r/108650 Change subject: Only load mw.PopUpMediaTransform on pages that plausibly need it .. Only load mw.PopUpMediaTransform on pages that plausibly need it Rather than load mw.PopUpMediaTransform unconditionally, rely on the parser hook to cover most cases, and use TimedMediaHandlerHooks::pageOutputHook to cover the rest: namely, special pages that are liable to include timed media. Bug: 0 Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b --- M TimedMediaHandler.hooks.php 1 file changed, 45 insertions(+), 4 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/50/108650/1 diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index b43f1ce..0ac3070 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -104,9 +104,12 @@ // Add parser hook $wgParserOutputHooks['TimedMediaHandler'] = array( 'TimedMediaHandler', 'outputHook' ); - // We should probably move this script output to a parser function but not working correctly in - // dynamic contexts ( for example in special upload, when there is an existing file warning. ) + // Use a BeforePageDisplay hook to load the styles in pages that pull in media dynamically. + // (Special:Upload, for example, when there is an existing file warning.) $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook'; + + // Make sure modules are loaded on image pages that don't have a media file in the wikitext. + $wgHooks['ImageOpenShowImageInlineBefore'][] = 'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore'; // Exclude transcoded assets from normal thumbnail purging // ( a maintenance script could handle transcode asset purging) @@ -146,6 +149,19 @@ $wgHooks[ 'NewRevisionFromEditComplete' ][] = 'TimedMediaHandlerHooks::onNewRevisionFromEditComplete'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::checkSchemaUpdates'; + return true; + } + + /** +* @param $imagePage ImagePage +* @param $wgOut OutputPage +* @return bool +*/ + public static function onImageOpenShowImageInlineBefore( $imagePage, $out ) { + $handler = $imagePage-getDisplayedFile()-getHandler(); + if ( $handler !== false $handler instanceof TimedMediaHandler ) { + TimedMediaHandler::outputHook( $out, null, null ); + } return true; } @@ -342,13 +358,38 @@ } /** +* Add JavaScript and CSS for special pages that may include timed media +* but which will not fire the parser hook. +* +* FIXME: There ought to be a better interface for determining whether the +* page is liable to contain timed media. +* * @param $out OutputPage * @param $sk * @return bool */ static function pageOutputHook( $out, $sk ){ - $out-addModules( 'mw.PopUpMediaTransform' ); - $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + $title = $out-getTitle(); + $namespace = $title-getNamespace(); + $addModules = false; + + if ( $namespace === NS_CATEGORY || $namespace === NS_TIMEDTEXT ) { + $addModules = true; + } + + if ( $title-isSpecialPage() ) { + list( $name, /* subpage */ ) = SpecialPageFactory::resolveAlias( $title-getDBkey() ); + if ( stripos( $name, 'file' ) !== false || stripos( $name, 'image' ) !== false + || $name === 'Search' || $name === 'GlobalUsage' ) { + $addModules = true; + } + } + + if ( $addModules ) { + $out-addModules( 'mw.PopUpMediaTransform' ); + $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/108650 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: wmf/1.23wmf11 Gerrit-Owner: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
[MediaWiki-commits] [Gerrit] Only load mw.PopUpMediaTransform on pages that plausibly nee... - change (mediawiki...TimedMediaHandler)
jenkins-bot has submitted this change and it was merged. Change subject: Only load mw.PopUpMediaTransform on pages that plausibly need it .. Only load mw.PopUpMediaTransform on pages that plausibly need it Rather than load mw.PopUpMediaTransform unconditionally, rely on the parser hook to cover most cases, and use TimedMediaHandlerHooks::pageOutputHook to cover the rest: namely, special pages that are liable to include timed media. Bug: 0 Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b --- M TimedMediaHandler.hooks.php 1 file changed, 45 insertions(+), 4 deletions(-) Approvals: Ori.livneh: Looks good to me, approved jenkins-bot: Verified diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index b43f1ce..0ac3070 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -104,9 +104,12 @@ // Add parser hook $wgParserOutputHooks['TimedMediaHandler'] = array( 'TimedMediaHandler', 'outputHook' ); - // We should probably move this script output to a parser function but not working correctly in - // dynamic contexts ( for example in special upload, when there is an existing file warning. ) + // Use a BeforePageDisplay hook to load the styles in pages that pull in media dynamically. + // (Special:Upload, for example, when there is an existing file warning.) $wgHooks['BeforePageDisplay'][] = 'TimedMediaHandlerHooks::pageOutputHook'; + + // Make sure modules are loaded on image pages that don't have a media file in the wikitext. + $wgHooks['ImageOpenShowImageInlineBefore'][] = 'TimedMediaHandlerHooks::onImageOpenShowImageInlineBefore'; // Exclude transcoded assets from normal thumbnail purging // ( a maintenance script could handle transcode asset purging) @@ -146,6 +149,19 @@ $wgHooks[ 'NewRevisionFromEditComplete' ][] = 'TimedMediaHandlerHooks::onNewRevisionFromEditComplete'; $wgHooks['LoadExtensionSchemaUpdates'][] = 'TimedMediaHandlerHooks::checkSchemaUpdates'; + return true; + } + + /** +* @param $imagePage ImagePage +* @param $wgOut OutputPage +* @return bool +*/ + public static function onImageOpenShowImageInlineBefore( $imagePage, $out ) { + $handler = $imagePage-getDisplayedFile()-getHandler(); + if ( $handler !== false $handler instanceof TimedMediaHandler ) { + TimedMediaHandler::outputHook( $out, null, null ); + } return true; } @@ -342,13 +358,38 @@ } /** +* Add JavaScript and CSS for special pages that may include timed media +* but which will not fire the parser hook. +* +* FIXME: There ought to be a better interface for determining whether the +* page is liable to contain timed media. +* * @param $out OutputPage * @param $sk * @return bool */ static function pageOutputHook( $out, $sk ){ - $out-addModules( 'mw.PopUpMediaTransform' ); - $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + $title = $out-getTitle(); + $namespace = $title-getNamespace(); + $addModules = false; + + if ( $namespace === NS_CATEGORY || $namespace === NS_TIMEDTEXT ) { + $addModules = true; + } + + if ( $title-isSpecialPage() ) { + list( $name, /* subpage */ ) = SpecialPageFactory::resolveAlias( $title-getDBkey() ); + if ( stripos( $name, 'file' ) !== false || stripos( $name, 'image' ) !== false + || $name === 'Search' || $name === 'GlobalUsage' ) { + $addModules = true; + } + } + + if ( $addModules ) { + $out-addModules( 'mw.PopUpMediaTransform' ); + $out-addModuleStyles( 'mw.PopUpMediaTransform' ); + } + return true; } -- To view, visit https://gerrit.wikimedia.org/r/108650 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7a6da6c62ceae1dae2feb05b57b2df91b482ad8b Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: wmf/1.23wmf11 Gerrit-Owner: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: Ori.livneh o...@wikimedia.org Gerrit-Reviewer: jenkins-bot ___ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits