r77981 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77980‎ | r77981 | r77982 >
Date:14:53, 7 December 2010
Author:platonides
Status:resolved (Comments)
Tags:
Comment:
Show the source on preview for CSS and Javascript pages.
Add pages in MediaWiki namespace into that group (bug 10871).
Only normal <pre> formatting is being used since ShowRawCssJs
hook directly sends things out to the output.
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/EditPage.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesQqq.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/EditPage.php
@@ -1878,17 +1878,28 @@
18791879 }
18801880
18811881 # don't parse user css/js, show message about preview
1882 - # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here
 1882+ # XXX: stupid php bug won't let us use $wgTitle->isCssJsSubpage() here -- This note has been there since r3530. Sure the bug was fixed time ago?
18831883
1884 - if ( $this->isCssJsSubpage ) {
 1884+ if ( $this->isCssJsSubpage || $this->mTitle->isCssOrJsPage() ) {
 1885+ $level = 'user';
 1886+ if ( $this->mTitle->getNamespace() == NS_MEDIAWIKI ) {
 1887+ $level = 'global';
 1888+ }
 1889+
18851890 if (preg_match( "/\\.css$/", $this->mTitle->getText() ) ) {
1886 - $previewtext = "<div id='mw-usercsspreview'>\n" . wfMsg( 'usercsspreview' ) . "\n</div>";
1887 - } else if (preg_match( "/\\.js$/", $this->mTitle->getText() ) ) {
1888 - $previewtext = "<div id='mw-userjspreview'>\n" . wfMsg( 'userjspreview' ) . "\n</div>";
 1891+ $previewtext = "<div id='mw-{$level}csspreview'>\n" . wfMsg( "{$level}csspreview" ) . "\n</div>";
 1892+ $class = "mw-code mw-js";
 1893+ } elseif (preg_match( "/\\.js$/", $this->mTitle->getText() ) ) {
 1894+ $previewtext = "<div id='mw-{$level}jspreview'>\n" . wfMsg( "{$level}jspreview" ) . "\n</div>";
 1895+ $class = "mw-code mw-js";
 1896+ } else {
 1897+ throw new MWException( 'A CSS/JS (sub)page but which is not css nor js!' );
18891898 }
 1899+
18901900 $parserOptions->setTidy( true );
18911901 $parserOutput = $wgParser->parse( $previewtext, $this->mTitle, $parserOptions );
18921902 $previewHTML = $parserOutput->mText;
 1903+ $previewHTML .= "<pre class=\"$class\" dir=\"ltr\">\n" . htmlspecialchars( $this->textbox1 ) . "\n</pre>\n";
18931904 } else {
18941905 $rt = Title::newFromRedirectArray( $this->textbox1 );
18951906 if ( $rt ) {
Index: trunk/phase3/languages/messages/MessagesQqq.php
@@ -838,6 +838,10 @@
839839 'clearyourcache' => 'Text at the top of .js/.css pages',
840840 'usercssyoucanpreview' => "Text displayed on every css page. The 'Show preview' part should be the same as {{msg-mw|showpreview}} (or you can use <nowiki>{{int:showpreview}}</nowiki>).",
841841 'userjsyoucanpreview' => 'Text displayed on every js page.',
 842+'usercsspreview' => 'Text displayed on preview of every user .css subpage',
 843+'userjspreview' => 'Text displayed on preview of every user .js subpage',
 844+'globalcsspreview' => 'Text displayed on preview of .css pages in MediaWiki namespace',
 845+'globaljspreview' => 'Text displayed on preview of .js pages in MediaWiki namespace',
842846 'updated' => '{{Identical|Updated}}',
843847 'previewnote' => 'Note displayed when clicking on Show preview',
844848 'editing' => "Shown as page title when editing a page. \$1 is the name of the page that is being edited. Example: \"''Editing Main Page''\".",
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1300,6 +1300,10 @@
13011301 '''It has not yet been saved!'''",
13021302 'userjspreview' => "'''Remember that you are only testing/previewing your user JavaScript.'''
13031303 '''It has not yet been saved!'''",
 1304+'globalcsspreview' => "'''Remember that you are only previewing this global CSS.'''
 1305+'''It has not yet been saved!'''",
 1306+'globaljspreview' => "'''Remember that you are only previewing this global JavaScript code.'''
 1307+'''It has not yet been saved!'''",
13041308 'userinvalidcssjstitle' => "'''Warning:''' There is no skin \"\$1\".
13051309 Custom .css and .js pages use a lowercase title, e.g. {{ns:user}}:Foo/vector.css as opposed to {{ns:user}}:Foo/Vector.css.",
13061310 'updated' => '(Updated)',
Index: trunk/phase3/RELEASE-NOTES
@@ -467,6 +467,8 @@
468468 * rebuildFileCache.php no longer creates inappropriate cache files for redirects
469469 * (bug 23119) WikiError class and subclasses are now marked as deprecated
470470 * (bug 18372) $wgFileExtensions will now override $wgFileBlacklist
 471+* (bug 10871) Javascript and CSS pages in MediaWiki namespace are no longer treated
 472+ as wikitext on preview.
471473
472474 === API changes in 1.17 ===
473475 * (bug 22738) Allow filtering by action type on query=logevent.

Follow-up revisions

RevisionCommit summaryAuthorDate
r77982Follow up r77981platonides14:55, 7 December 2010
r77994follow-up r77981: Fix class: mw-js -> mw-css for the CSS section...raymond17:25, 7 December 2010
r78230Follow up r77981,r77982. Rename the new globalcsspreview/globaljspreview to s...platonides22:44, 11 December 2010
r784371.17: Merge tagged revisions from trunk: r77878, r77981, r77982, r77994, r780...catrope14:14, 15 December 2010

Comments

#Comment by MZMcBride (talk | contribs)   16:18, 7 December 2010

Using "global" here might cause confusion later when Wikimedia-wide CSS/JS pages are implemented.

#Comment by VasilievVV (talk | contribs)   21:29, 7 December 2010

Please rename it to "site-wide" or something like that. Term "global" is usually used for things global across a wikifarm, and will indeed cause confusion when Wikimedia-wide user resources are implemented.

#Comment by Platonides (talk | contribs)   00:06, 8 December 2010

I originally named it system but didn't feel it was appropiate. I can't think on an appropiate name, without being ambiguous (eg. wikicss).

#Comment by Nikerabbit (talk | contribs)   07:44, 8 December 2010

site or site-wide css?

#Comment by Platonides (talk | contribs)   22:38, 8 December 2010

sitecsspreview? May be.

Any other suggestion out there?

#Comment by MZMcBride (talk | contribs)   23:05, 8 December 2010

sitecsspreview / sitejspreview seem fine to me. I was going to suggest commoncsspreview / commonjspreview, but that has a different kind of connotation, I think.

#Comment by Catrope (talk | contribs)   21:52, 14 December 2010

Messages were renamed in r78230. Contents weren't changed, but that's a fixme on that rev. Marking resolved.

Status & tagging log