Page MenuHomePhabricator

add an explicit action=view_source to present a page's markup
Closed, InvalidPublic

Description

Author: info

Description:
"Copy markup from page Xyz" is an extremely common instruction when telling people how to make edits in MediaWiki. Yet this is extremely complicated and prone to error. If users just visit the page, they don't get the markup, but if you tell users to edit page Xyz, select its markup and copy it, the moment users visit they're presented a UI that doesn't match what you want them to do — it encourages them to edit, tells them to preview, asks for a summary, etc. It also wastes CPU, MediaWiki renders the page, then renders the complicated editing UI.

Instead MediaWiki should have a dedicated action to view markup.

The code for this action is already present in MediaWiki! On many wikis, if you view a protected page, the [edit] tab turns into [View source], and if you choose the edit action you're presented with an uneditable text box with the markup and "You can view and copy the source of this page". See e.g. http://semanticweb.org/index.php?title=MediaWiki:Smw_import_foaf&action=edit So all that's needed is an action that triggers this behavior, with a slightly different introductory paragraph. Maybe reuse the optional parameter &preview to show what the markup looks like.

Notes:

  • I have a mild preference for action=view_markup because I confuse MediaWiki's "view source" with my browser's "View source", but I don't feel strongly about the terminology.
  • action=raw eventually provides the markup of a page, but it's way too user-unfriendly: it triggers a download dialog and "What should Firefox do with this file", and lacks the explanatory "You can view and copy the source of this page".
  • http://www.mediawiki.org/wiki/Manual:Creating_pages_with_preloaded_text discusses workarounds for for the specific case of creating a new page from a template, e.g. using the CreateBox extension.

Version: unspecified
Severity: enhancement

Details

Reference
bz19681

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:40 PM
bzimport set Reference to bz19681.
bzimport added a subscriber: Unknown Object (MLST).

Maybe there should be
action=raw&Content-Type=text/plain or
action=raw&content-type=text/plain etc.
or format=text/plain... (sounds like the API)
type of overriding possibilities...

It also wastes CPU, MediaWiki renders the page, then renders the
complicated editing UI.

The editing UI is rendered-client (toolbar et al.). Messages are cached.
It's not a problem.

info wrote:

(In reply to comment #1)

Maybe there should be
action=raw&Content-Type=text/plain or
action=raw&content-type=text/plain etc.
or format=text/plain... (sounds like the API)
type of overriding possibilities...

That's a different bug, you're welcome to file it. This bug requests the same user-friendly, in-wiki presentation of markup that action=edit ''already'' implements (but only when the page is protected).

herd wrote:

(In reply to comment #3)

(In reply to comment #1)

Maybe there should be
action=raw&Content-Type=text/plain or
action=raw&content-type=text/plain etc.
or format=text/plain... (sounds like the API)
type of overriding possibilities...

That's a different bug, you're welcome to file it.

Bug 8775 "ctype=text/plain" is WONTFIX. See bug for details.

And bug2845#c13 says why they don't just use text/plain in the first place.

Source is available in editing view. There's no benefit to adding a second way to get at the same thing, but arbitrarily restricted.

Just to note: There's a fresh request for this feature in https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28proposals%29&oldid=669859859#New_button:_View_source

An editor also notes that there's a gadget at Zhwiki which does this (though it only seems to work if we use a zh-variant interface language, so don't try to test it out in English/etc!) It just adds extra "edit" section-links and tab with &viewsource=1 appended.
https://zh.wikipedia.org/wiki/MediaWiki:Gadget-ViewSourceMode.js and screenshot:

Screenshot from 2015-07-04 12:40:40.png (409×985 px, 139 KB)