Extension:UploadWizard/CustomWikiTextLicenseFeature

Update: This feature was implemented. See. It does pretty much everything described below. It uses a trivial wikitext parser (good enough for a single MediaWiki template, which is all we expect there). Not-so-trivially, it also tries to determine if that template is a descendant of Category:Licenses.

This is a first draft of what we would like to see in a feature which fixes, "add custom license wikitext option". Be bold and edit this if we're getting it wrong.

User stories
Note: user stories do not ever say how something is implemented, they just tell the story of what can be accomplished.
 * An experienced user is uploading a third-party image. She would like to use a license which we do not offer in the drop-down list. She is able to enter the wikitext that, when parsed, produces the license.
 * A user goes to the helpdesk to ask how to upload a screenshot of a particular old unix program. They are told to "Use UploadWizard and paste in as a custom license". They can follow those instructions easily and it all works.
 * An inexperienced user is confused by the suggestion to "add wikitext here" and writes instead "I don't know what I'm supposed to put here, but this is a postcard from the 1920 World's Fair". An experienced admin fixes this to.
 * An inexperienced user misunderstands some oral directions and types in license=[[BSD]] . The software doesn't let her proceed to the next step, and tells her where the error is.

Envisioned implementation

 * A simple textarea where the user can add wikitext, which is faithfully copied into the created File: page.
 * However, when the user chooses to add a custom license, we silently add a template flagging this file for license review. -  has been used in the past, but that literally means "uploaded without license". Is there something that is more like , which indicates the license should be reviewed? Please research this.
 * When the user has typed something that is not all whitespace, and parses correctly, they can get a preview of the license.
 * The preview button is disabled if the textarea is empty or only contains whitespace.
 * The preview is obtained by the usual api methods to parse wikitext.
 * The preview takes the form of a modal floating window that the user can close, in the usual jQuery style.
 * The user cannot submit unparseable wikitext as a license. If they try, an error is shown in red, much as other validity errors on the page are shown.
 * Parsing errors are not shown unless the user has pressed the "next" button.
 * In practice, this means writing a custom validation handler for this field, like the others.

Why we need to flag the custom license
We can't know in advance if it's a good license or not. In principle, it is be possible to parse the license, and then decide if at some point it invokes a template that is in Category:License_tags. But such a parser is not available to us at the moment. (Still, some trivial checking might be possible, with regular expressions and checks to see if those licenses were members of the right Category...)

Nice to have

 * Can we prepopulate the same license if they ever upload other things? Make it a silently set preference, or perhaps use the cookie?

Nongoals

 * Offering custom licenses for own-work images. We are still going to strongly urge people to use CC BY-SA 3.0, or the other licenses currently in the "own-work" radio button section.

Mockups




Snippets
To achieve the above layout, a DOM structure like the mockups above can be created to be something like this HTML below. But see the manner in which the other licenses are rendered.

 Enter a custom wikitext license   Preview 