Add variant of MediaWiki:Pagetitle for customizing the main page
Closed, ResolvedPublic

Description

Author: rememberthedot

Description:
There's been some discussion recently at [[Wikipedia:Village pump (technical)]] about moving the main page to [[Portal:Wikipedia]]. Essentially, this would make it easier to deal with Wikipedia articles from a technical standpoint, because bot and script developers would not have to worry about adding special code for the main page.

However, concerns have been raised about how "Portal:Wikipedia - Wikipedia, the free encyclopedia" isn't very intuitive. Come to think of it, "Main Page - Wikipedia, the free encyclopedia" isn't all that intuitive either.

It would be nice if we could change the <title> for the main page to simply "Wikipedia, the free encyclopedia". This would be more intuitive and make more sense when people go to bookmark the page, since their bookmark titles would start with the word "Wikipedia" and not "Main Page" or "Portal:Wikipedia".

So, could we create a page (perhaps [[MediaWiki:Pagetitle-mainpage]]) to grant this kind of customization?


Version: unspecified
Severity: enhancement

bzimport added a subscriber: wikibugs-l.
bzimport set Reference to bz15007.
bzimport created this task.Via LegacyAug 2 2008, 2:36 AM
DanielFriesen added a comment.Via ConduitAug 2 2008, 6:27 AM

Browse around Wikia's source code:
http://svn.wikia-code.com

All the wiki at Wikia don't show the pagetitle on the mainpage. They've already got a feature like that so if you can find the code you can just fix it up and put it in Wikimedia's SVN.

DanielFriesen added a comment.Via ConduitAug 4 2008, 11:56 PM

Ok, scratch that. Wikia made a mass change to [[MediaWiki:Pagetitle]] that makes use of parserfunctions on each page load.

Actually, rather than a separate message. Why not the same one?

The pagetitle is a one line thing. Nothing should be on a second line. So why not use that to create a variant of it?

$1 - {{SITENAME}}
{{SITENAME}}

Second line will be used on the main page if it exists. Falls back to the first line.

bzimport added a comment.Via ConduitAug 6 2008, 3:11 AM

rememberthedot wrote:

Proposed patch

I created a patch to create a new message, [[MediaWiki:Mainpagetitle]]. The patch is based off the latest SVN source files (as of yesterday, at least) and includes diff files in universal diff format.

[[MediaWiki:Mainpagetitle]] defaults to {{MediaWiki:Pagetitle}}, so by default it simply adopts the behavior of [[MediaWiki:Pagetitle]]. I think that this works well, though there may be a more efficient way to do this.

For example, with this patch the English Wikipedia could set [[MediaWiki:Mainpagetitle]] to simply "Wikipedia, the free encyclopedia" for simplicity and intuitiveness when bookmarking Wikipedia etc. When editing or doing other actions, "Editing Main Page - Wikipedia, the free encyclopedia" (or whatever other title) would still appear as before.

So, what do you think?

attachment Mainpagetitle patch.zip ignored as obsolete

DanielFriesen added a comment.Via ConduitAug 6 2008, 3:41 AM

Firstly, rather than {{MediaWiki:Pagetitle}}, {{int:pagetitle}} would be better.
Secondly, mainpagetitle is a poor message name. It's not right away apparent that it is a variant of pagetitle and doesn't leave much room if the feature is expanded to other pages in the future.
And thirdly, rather than parsing the message with those transclusions a more reliable and standard way to do this would be to default to '-' and test for that or wfEmptyMsg so that actual emptiness will fallback to the default.

bzimport added a comment.Via ConduitAug 6 2008, 5:17 AM

rememberthedot wrote:

Proposed patch, version 2

OK, I've redone it, hopefully this will be better. The message name is now [[MediaWiki:Pagetitle-view-mainpage]], which describes exactly what it is: A variant of pagetitle used when viewing the main page.

Pagetitle-view-mainpage defaults to an empty string. So, as long as Pagetitle-view-mainpage is an empty string, OutputPage.php will use [[MediaWiki:Pagetitle]] instead.

I looked at using wfEmptyMsg, but it seems that this function only says whether or not the message is in the defined list of MediaWiki messages. Since it's probably a good idea to have Pagetitle-view-mainpage in the list, wfEmptyMsg doesn't seem to be appropriate here.

attachment Pagetitle-view-mainpage patch.zip ignored as obsolete

bzimport added a comment.Via ConduitAug 6 2008, 6:02 PM

ayg wrote:

Please submit patches as single unified diff files. To generate them, check out a copy of the software with an SVN client and use the command "svn diff". (In TortoiseSVN this is something like "Create Patch" from the context menu -- check docs.) If you didn't use Subversion to check out the software, as a second option, you should create the unified diffs and then concatenate them into a single text file that you post as an attachment here. The first method is preferred because it's simpler to do once you've set up, the result can always be applied with a single use of "patch -p0", and it automatically provides useful info like the exact revision you're diffing from. Please see examples in other bugs, e.g., bug 15053.

You're right that wfEmptyMsg() is wrong here: that's for undefined messages, not ones that contain no content. The patch looks good.

bzimport added a comment.Via ConduitAug 6 2008, 6:14 PM

ayg wrote:

Same as RememberTheDot's patch, in proper format (with addition to message lists too)

Hmm, problem. What if something else sets the page title to the contents of 'mainpage'? I don't think this is the right layer to be adding this at. It should be something like $wgTitle->isMainPage(), not some attempt to figure that out through comparing strings that could hypothetically mean anything. The Article class would be the right place to do it, but setPageTitle() doesn't allow that. Maybe a new OutputPage::setRawPageTitle() that skips the 'pagetitle' stuff? I'd talk to Brion, if he doesn't like the implementation it will get reverted.

Also, a couple more stylistic comments: 1) Use proper K&R brace style ("} else {" all on one line, not "}\nelse {"). 2) Do something like diff ... > /tmp/diff (or > C:\temp\diff.txt as the case may be). Don't try to copy off the terminal: it turns all tabs to spaces.

Attached: diff

bzimport added a comment.Via ConduitAug 6 2008, 7:26 PM

ayg wrote:

A couple more notes, just FYI:

  • I moved the special-casing to Article.php, using OutputPage::setHTMLTitle().
  • We needed wfMsgForContent() here, not wfMsg(). The article title shouldn't vary based on the interface language, and certainly the page we consider to be the main page shouldn't!
  • There's no need to pass the $name parameter, since it will always equal MediaWiki:Mainpage, and in the rare event that changes, someone can manually update MediaWiki:Pagetitle-view-mainpage as well. Plus, if the message is used, it probably won't contain the main page's name at all -- that's the point.

I checked in a modified version of RememberTheDot's patch in r38730. (I forgot to credit him in the commit message, but I added him to CREDITS.)

bzimport added a comment.Via ConduitAug 7 2008, 3:02 AM

rememberthedot wrote:

Hey, thanks for fixing up my patch and adding it to MediaWiki! Thanks also for the advice about MediaWiki coding style and making patches - I'm using Tortise SVN, and I see now that it has a quite painless "Create patch" option, which is much better than me copying-and-pasting from the console to a text file. I'll remember this for when I make future patches.

Oh, and the attribution in CREDITS is fine; I am honored to be listed. Honestly, I would be happy just knowing that I helped, even if you didn't attribute me at all.

Add Comment