Page MenuHomePhabricator

Selectable wikitext templates (!26)
Closed, ResolvedPublic

Description

Summary

The published wikitext for each file is currently generated from a single hard-coded template (likely {{Information}}). Let the user pick a different template — including a custom one — and have that choice flow through both the editing experience (so wikitext previews match the chosen template) and publishing.

Behavior

  • Template picker: a setting that selects which wikitext template the published wikitext is built from (e.g. {{Information}} (default), {{Artwork}}, {{Photograph}}, {{Book}}, plus a "custom template" option).
  • Editing-time consistency: the wikitext preview (T425879) reflects the currently selected template, not the default.
  • Column suggestions on switch: switching to a template that requires fields the user hasn't added as columns triggers a hint:
    • "Template X uses fields A, B, C — add them as columns?" with a one-click action to add the missing columns.
    • Encourage but don't force; the user might intentionally leave a field blank.
  • Custom template support: the user can paste their own template definition with named field placeholders, and pick which existing column maps to which field.

UI placement

Lives next to the existing Columns modal — these settings are siblings ("which fields do I want?" + "how is the wikitext built from those fields?"). Rename the existing Columns button to "Templates and columns" and have the modal expose both sections.

Relationship to other tasks

  • T425879 (wikitext preview) — the preview output must reflect the selected template.
  • T425864 (per-column dropdown) — already adds per-column settings; this is the global complement.

Out of scope

  • Editing template definitions on Commons itself.
  • Auto-detecting which template is "right" for a given file.

Acceptance

  • User can pick from at least: {{Information}} (default), {{Artwork}}, {{Photograph}}, {{Book}}, custom.
  • The wikitext preview and the published wikitext both reflect the selected template.
  • Switching to a template with unmapped fields prompts the user to add the missing columns.
  • The "Columns" button is renamed to "Templates and columns" and the modal shows both sections.

Source

User feedback session, 2026-05-10.

Event Timeline

Daanvr moved this task from To do to Doing on the Tool-upload-workbench board.

MR: https://gitlab.wikimedia.org/daanvr/upload-workbench/-/merge_requests/26
Preview: https://upload-workbench.toolforge.org/mr-26/

Quick research notes (template fields used by each Commons template, captured during implementation):

  • {{Information}} — description, date, source, author, permission, other_versions
  • {{Artwork}} — artist, title, description, date, medium, dimensions, institution, location, references, object_history, credit_line, inscriptions, notes, accession_number, source, permission, other_versions
  • {{Photograph}} — photographer, title, description, depicted people, depicted place, date, medium, dimensions, institution, department, references, object history, exhibition history, credit line, inscriptions, notes, accession number, source, permission, other_versions
  • {{Book}} — Author, Translator, Editor, Illustrator, Title, Subtitle, Series title, Volume, Edition, Publisher, Printer, Date, City, Language, Description, Source, Permission, Image, Pageoverview, Wikisource, Homecat, Other_versions, ISBN, LCCN, OCLC, Other_fields

Each builtin template only maps the params for which the workbench already has a column (the rest are left empty). Custom templates use {{field:KEY}} placeholders against any workbench column key.

Well it is going in the right direction, however I I would like some more clarity on which columns are related to which template. Uh also maybe the possibility to hide columns that are not in that template. Um Also it said it add um a add columns for this template, but I didn't see which one and if any were added

Daanvr renamed this task from Wikitext templates to Selectable wikitext templates (!26).May 11 2026, 2:12 PM

Iterated per feedback (commit b850123):

  1. Per-row template badges in the Columns tab — each column now shows a small inline badge surfacing its relationship to the active template (|description= for direct field mappings, custom for custom-template placeholders, recommended for the broader hint list). The column ↔ template wiring is visible directly on the row, no need to switch tabs.
  1. New "In <Template>" filter chip on the Columns tab — quick way to hide every column that isn't used by the chosen template; counts the in-template columns next to the chip label like the other legend filters.
  1. After clicking "Add N columns" the user now lands on the Columns tab pre-filtered to the active template, sees a banner naming the columns that were just enabled (by label, not raw key), and the matching rows flash-highlight for ~4 s. Previously the action ran silently.

Bonus: the Templates tab's "Columns this template uses" section now splits direct field mappings from recommended-only columns and renders each entry as "Column label → |param=" with a green/grey enabled-dot, instead of bare key codes.

Preview updated: https://upload-workbench.toolforge.org/mr-26/

Released as v0.12.0 (MR !26 merged into main).