r111647 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111646‎ | r111647 | r111648 >
Date:16:05, 16 February 2012
Author:robin
Status:ok (Comments)
Tags:
Comment:
(Bug 31417) Content-holding div needs an ID.
Since the introduction of the class mw-content-ltr/rtl, it has been used to get the page text which is very bad because there are two class names and it is not always on the same place (if at all). This ID will always hold the bodytext (excluding categories, ArticleFeedback, ...).
Modified paths:
  • /trunk/phase3/RELEASE-NOTES-1.20 (modified) (history)
  • /trunk/phase3/includes/SkinTemplate.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/SkinTemplate.php
@@ -397,18 +397,23 @@
398398 $tpl->set( 'bottomscripts', $this->bottomScripts() );
399399 $tpl->set( 'printfooter', $this->printSource() );
400400
401 - # Add a <div class="mw-content-ltr/rtl"> around the body text
 401+ # An ID that includes the actual body text; without categories, contentSub, ...
 402+ $realBodyAttribs = array( 'id' => 'mw-content-text' );
 403+
 404+ # Add a mw-content-ltr/rtl class to be able to style based on text direction
 405+ # when the content is different from the UI language, i.e.:
402406 # not for special pages or file pages AND only when viewing AND if the page exists
403407 # (or is in MW namespace, because that has default content)
404408 if( !in_array( $title->getNamespace(), array( NS_SPECIAL, NS_FILE ) ) &&
405409 in_array( $request->getVal( 'action', 'view' ), array( 'view', 'historysubmit' ) ) &&
406410 ( $title->exists() || $title->getNamespace() == NS_MEDIAWIKI ) ) {
407411 $pageLang = $title->getPageLanguage();
408 - $realBodyAttribs = array( 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(),
409 - 'class' => 'mw-content-'.$pageLang->getDir() );
410 - $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
 412+ $realBodyAttribs['lang'] = $pageLang->getHtmlCode();
 413+ $realBodyAttribs['dir'] = $pageLang->getDir();
 414+ $realBodyAttribs['class'] = 'mw-content-'.$pageLang->getDir();
411415 }
412416
 417+ $out->mBodytext = Html::rawElement( 'div', $realBodyAttribs, $out->mBodytext );
413418 $tpl->setRef( 'bodytext', $out->mBodytext );
414419
415420 # Language links
Index: trunk/phase3/RELEASE-NOTES-1.20
@@ -17,6 +17,8 @@
1818 * (bug 32341) Add upload by URL domain limitation.
1919 * &useskin=default will now always display the default skin. Useful for users with a
2020 preference for the non-default skin to look at something using the default skin.
 21+* (bug 31417) New ID mw-content-text around the actual page text, without categories,
 22+ contentSub, ... The same div often also contains the class mw-content-ltr/rtl.
2123
2224 === Bug fixes in 1.20 ===
2325 * (bug 30245) Use the correct way to construct a log page title.

Follow-up revisions

RevisionCommit summaryAuthorDate
r113932MFT r111647reedy17:10, 15 March 2012
r113933MFT r111647reedy17:12, 15 March 2012
r113934Move RELEASE-NOTES after merging r111647 into 1.19 in r113933reedy17:14, 15 March 2012

Comments

#Comment by SPQRobin (talk | contribs)   16:08, 16 February 2012

I hope the ID name doesn't collide with other IDs. Google search didn't give me any exact matches.

Also, to my surprise, mw-content-ltr shows up as a google search suggestion, which means a lot of people wondered what it is :-S

#Comment by George Orwell III (talk | contribs)   22:08, 8 March 2012

A lot of people on en.wikisource were wondering how to use the ms-content-ltr container to replace an interim container scheme used for dynamic layouts of transcluded content once it went through the ProofReading process. This additional ID generated skin-wide would greatly help cut down on the amount of local .js currently needed (not to mention help stop abusing #contentSub where the interim container is being dynamically moved to).

Any chance this revision slated for 1.20wmf with the new ID attribute generation could be hurried along? Patching the current wikisource deployed version sooner rather than later sure could go a long way in undoing our dynamic layout mess moving forward. TIA - GOIII

#Comment by SPQRobin (talk | contribs)   22:59, 10 March 2012

I'm tagging this with 1.19wmf1 so if possible/allowed it will be deployed to WMF wikis.

Btw, I made the page Manual:Interface/IDs and classes which hopefully clears up usage of a few common IDs/classes (it's still a rather short list). Maybe it could become as helpful as Manual:Interface/JavaScript :)

#Comment by Reedy (talk | contribs)   16:49, 15 March 2012

Should this go into 1.19 aswell?

#Comment by SPQRobin (talk | contribs)   22:14, 15 March 2012

I see you did so already.. that's even better I suppose :)

Status & tagging log