https://www.mediawiki.org/wiki/Special:Code/MediaWiki/108096
Revision: 108096 Author: ashley Date: 2012-01-04 23:11:52 +0000 (Wed, 04 Jan 2012) Log Message: ----------- BlogPage: ResourceLoader fixes, dropped backwards compatibility and of course, the obligatory version number bump. I had to take out the edit buttons from Special:CreateBlogPost because the current edit page JS (resources/mediawiki.action/mediawiki.action.edit.js) doesn't seem to be flexible enough and I didn't feel like duplicating lots and lots of both PHP and JS code. Modified Paths: -------------- trunk/extensions/BlogPage/Blog.php trunk/extensions/BlogPage/BlogHooks.php trunk/extensions/BlogPage/CreateBlogPost.js trunk/extensions/BlogPage/SpecialArticleLists.php trunk/extensions/BlogPage/SpecialArticlesHome.php trunk/extensions/BlogPage/SpecialCreateBlogPost.php Modified: trunk/extensions/BlogPage/Blog.php =================================================================== --- trunk/extensions/BlogPage/Blog.php 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/Blog.php 2012-01-04 23:11:52 UTC (rev 108096) @@ -5,7 +5,7 @@ * * @file * @ingroup Extensions - * @version 2.0 + * @version 2.1 * @author David Pean <david.p...@gmail.com> * @author Jack Phoenix <j...@countervandalism.net> * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later @@ -18,7 +18,7 @@ // Extension credits that will show up on Special:Version $wgExtensionCredits['other'][] = array( 'name' => 'BlogPage', - 'version' => '2.0', + 'version' => '2.1', 'author' => array( 'David Pean', 'Jack Phoenix' ), 'description' => 'Blogging system with commenting and voting features, ' . '[[Special:CreateBlogPost|a special page to create blog posts]] and ' . @@ -50,11 +50,11 @@ $wgResourceModules['ext.blogPage.create'] = $blogResourceTemplate + array( 'styles' => 'CreateBlogPost.css', 'scripts' => 'CreateBlogPost.js', + //'dependencies' => 'mediawiki.action.edit', 'messages' => array( 'blog-js-create-error-need-content', 'blog-js-create-error-need-title', 'blog-js-create-error-page-exists' - ), - 'position' => 'top' // available since r85616 + ) ); // Default setup for displaying sections Modified: trunk/extensions/BlogPage/BlogHooks.php =================================================================== --- trunk/extensions/BlogPage/BlogHooks.php 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/BlogHooks.php 2012-01-04 23:11:52 UTC (rev 108096) @@ -36,11 +36,7 @@ $wgOut->enableClientCache( false ); // Add CSS - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { - $wgOut->addModules( 'ext.blogPage' ); - } else { - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/BlogPage.css' ); - } + $wgOut->addModules( 'ext.blogPage' ); // This originally used $wgTitle but I saw no point in that, so I // changed that as per Chad et al. @@ -59,6 +55,7 @@ */ public static function allowShowEditBlogPage( $editPage ) { global $wgOut, $wgUser; + if( $editPage->mTitle->getNamespace() == NS_BLOG ) { if( $wgUser->isAnon() ) { // anons can't edit blog pages if( !$editPage->mTitle->exists() ) { @@ -74,6 +71,7 @@ return false; } } + return true; } Modified: trunk/extensions/BlogPage/CreateBlogPost.js =================================================================== --- trunk/extensions/BlogPage/CreateBlogPost.js 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/CreateBlogPost.js 2012-01-04 23:11:52 UTC (rev 108096) @@ -27,12 +27,12 @@ // name var title = document.getElementById( 'title' ).value; if ( !title || title == '' ) { - alert( _BLOG_NEEDS_TITLE ); + alert( mw.msg( 'blog-js-create-error-need-title' ) ); return ''; } var pageBody = document.getElementById( 'pageBody' ).value; if ( !pageBody || pageBody == '' ) { - alert( _BLOG_NEEDS_CONTENT ); + alert( mw.msg( 'blog-js-create-error-need-content' ) ); return ''; } @@ -41,8 +41,26 @@ if( r.responseText.indexOf( 'OK' ) >= 0 ) { document.editform.submit(); } else { - alert( _BLOG_PAGE_EXISTS ); + alert( mw.msg( 'blog-js-create-error-page-exists' ) ); } }); } -}; \ No newline at end of file +}; + +jQuery( document ).ready( function() { + // Tag cloud + jQuery( 'a.tag-cloud-entry' ).each( function( index ) { + var that = jQuery( this ); + that.click( function() { + CreateBlogPost.insertTag( + that.data( 'blog-slashed-tag' ), + that.data( 'blog-tag-number' ) + ); + } ); + } ); + + // Save button + jQuery( 'input[name="wpSave"]' ).click( function() { + CreateBlogPost.performChecks(); + } ); +} ); \ No newline at end of file Modified: trunk/extensions/BlogPage/SpecialArticleLists.php =================================================================== --- trunk/extensions/BlogPage/SpecialArticleLists.php 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/SpecialArticleLists.php 2012-01-04 23:11:52 UTC (rev 108096) @@ -34,11 +34,7 @@ // @todo FIXME: this should be loaded when including the special page, // too, but if ( $this->including() ) does nothing, prolly because of // the parser cache - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { - $wgOut->addModules( 'ext.blogPage.articlesHome' ); - } else { - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/ArticlesHome.css' ); - } + $wgOut->addModules( 'ext.blogPage.articlesHome' ); $imgPath = $wgScriptPath . '/extensions/BlogPage/images/'; Modified: trunk/extensions/BlogPage/SpecialArticlesHome.php =================================================================== --- trunk/extensions/BlogPage/SpecialArticlesHome.php 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/SpecialArticlesHome.php 2012-01-04 23:11:52 UTC (rev 108096) @@ -30,11 +30,7 @@ $wgSupressPageTitle = true; // Add CSS - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { - $wgOut->addModules( 'ext.blogPage.articlesHome' ); - } else { - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/ArticlesHome.css' ); - } + $wgOut->addModules( 'ext.blogPage.articlesHome' ); if( !$type ) { $type = 'popular'; Modified: trunk/extensions/BlogPage/SpecialCreateBlogPost.php =================================================================== --- trunk/extensions/BlogPage/SpecialCreateBlogPost.php 2012-01-04 23:00:48 UTC (rev 108095) +++ trunk/extensions/BlogPage/SpecialCreateBlogPost.php 2012-01-04 23:11:52 UTC (rev 108096) @@ -5,7 +5,7 @@ * * @file * @ingroup Extensions - * @date 16 July 2011 + * @date 4 January 2012 */ class SpecialCreateBlogPost extends SpecialPage { @@ -24,7 +24,7 @@ * @param $par Mixed: parameter passed to the special page or null */ public function execute( $par ) { - global $wgOut, $wgUser, $wgRequest, $wgContLang, $wgScriptPath, $wgHooks; + global $wgOut, $wgUser, $wgRequest, $wgContLang; // If the user can't create blog posts, display an error if( !$wgUser->isAllowed( 'createblogpost' ) ) { @@ -47,19 +47,8 @@ // Set page title, robot policies, etc. $this->setHeaders(); - // i18n for JS - $wgHooks['MakeGlobalVariablesScript'][] = 'SpecialCreateBlogPost::addJSGlobals'; - // Add CSS & JS - if ( defined( 'MW_SUPPORTS_RESOURCE_MODULES' ) ) { - $wgOut->addModules( array( - 'mediawiki.legacy.edit', 'ext.blogPage.create' - ) ); - } else { - $wgOut->addExtensionStyle( $wgScriptPath . '/extensions/BlogPage/CreateBlogPost.css' ); - $wgOut->addScriptFile( $wgScriptPath . '/extensions/BlogPage/CreateBlogPost.js' ); - $wgOut->addScriptFile( 'edit.js' ); // for the edit toolbar - } + $wgOut->addModules( 'ext.blogPage.create' ); // If the request was POSTed, we haven't submitted a request yet AND // we have a title, create the page...otherwise just display the @@ -225,7 +214,11 @@ '</span><br />'; // The EditPage toolbar wasn't originally present here but I figured // that adding it might be more helpful than anything else. - $output .= EditPage::getEditToolbar(); + // Guess what...turns out that resources/mediawiki.action/mediawiki.action.edit.js + // assumes way too many things and no longer is suitable for different + // editing interfaces, such as this special page. + // I miss the old edit.js... + //$output .= EditPage::getEditToolbar(); $output .= '<textarea class="createbox" tabindex="' . $this->tabCounter . '" accesskey="," name="pageBody" id="pageBody" rows="10" cols="80"></textarea><br /><br />'; $this->tabCounter++; @@ -253,7 +246,7 @@ $slashedTag = str_replace( "'", "\'", $tag ); } $tagcloud .= " <span id=\"tag-{$tagnumber}\" style=\"font-size:{$cloud->tags[$tag]['size']}{$cloud->tags_size_type}\"> - <a class=\"tag-cloud-entry\" onclick=\"javascript:CreateBlogPost.insertTag('" . $slashedTag . "',{$tagnumber});\">{$tag}</a> + <a class=\"tag-cloud-entry\" data-blog-slashed-tag=\"" . $slashedTag . "\" data-blog-tag-number=\"{$tagnumber}\">{$tag}</a> </span>"; $tagnumber++; } @@ -313,8 +306,8 @@ $output .= "\n" . $this->displayFormPageCategories() . "\n"; $output .= "\n" . $this->displayCopyrightWarning() . "\n"; - $output .= '<input type="button" onclick="CreateBlogPost.performChecks()" value="' . - wfMsg( 'blog-create-button' ) . '" name="wpSave" class="createsubmit site-button" accesskey="s" title="' . + $output .= '<input type="button" value="' . wfMsg( 'blog-create-button' ) . + '" name="wpSave" class="createsubmit site-button" accesskey="s" title="' . wfMsg( 'tooltip-save' ) . ' [alt-s]" /> <input type="hidden" value="" name="wpSection" /> <input type="hidden" value="" name="wpEdittime" /> @@ -352,17 +345,4 @@ return 'OK'; } } - - /** - * Add i18n messages for the JS file. - * - * @param $vars Array: array of pre-existing JavaScript globals - * @return Boolean: true - */ - public static function addJSGlobals( $vars ) { - $vars['_BLOG_NEEDS_CONTENT'] = wfMsg( 'blog-js-create-error-need-content' ); - $vars['_BLOG_NEEDS_TITLE'] = wfMsg( 'blog-js-create-error-need-title' ); - $vars['_BLOG_PAGE_EXISTS'] = wfMsg( 'blog-js-create-error-page-exists' ); - return true; - } } \ No newline at end of file _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs