Jump to content

Extension:UploadWizard/CustomWikiTextLicenseFeature

From mediawiki.org

Update: This feature was implemented. See task T31249. 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 task T31249, "add custom license wikitext option". Be bold and edit this if we're getting it wrong.


User stories

[edit]

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 {{free screenshot|license={{BSD}}}} 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 {{PD-old}}.
  • An inexperienced user misunderstands some oral directions and types in [[free screenshot|license=[[BSD]]]]. The software doesn't let her proceed to the next step, and tells her where the error is.

Envisioned implementation

[edit]
  • 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. - {{subst:uwl}} has been used in the past, but that literally means "uploaded without license". Is there something that is more like {{FlickrReview}}, 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

[edit]

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

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

Nongoals

[edit]
  • 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

[edit]
mockup of feature desired
Mockup of imagined implementation of described feature
mockup of feature desired
Mockup of imagined implementation of described feature

Snippets

[edit]

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.

<div class="mwe-upwiz-deed-license-group">
  <div>
    <a class="mwe-upwiz-deed-license-group-head mwe-upwiz-toggler mwe-upwiz-toggler-open mwe-upwiz-more-options">
      Enter a custom wikitext license
    </a>
  </div>
  <div class="mwe-upwiz-toggler-content" style="margin-bottom: 1em;">
    <div class="mwe-upwiz-deed-license-group-subhead" style="width: 100%; float: left;">
      <div style="float: right; width: 9em; padding-left: 1em;">
        <button type="button" id="previewCustom" style="width: 100%" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-button-text ui-button-textonly" role="button">
          <span class="ui-button-text">Preview</span>
        </button>
      </div>
      <div style="margin-right: 10em;">
        <textarea width="100%" rows=1></textarea>
      </div>
      <div class="ui-helper-clearfix"></div>
    </div>
  </div>
</div>