Jump to content

CiteFix: Difference between revisions

From mediawiki.org
Content deleted Content added
Remove nonexistent category
...
Line 143: Line 143:


[[Category:Wikimedia tools]]
[[Category:Wikimedia tools]]
[[Category:Wikipedia gadgets]]

Revision as of 00:10, 25 July 2026

Manual on MediaWiki Tools
CiteFix
Release status: beta
Author(s) Jayprakash, Gopavasanth, Sarthak
License MIT
Download No link
Issues : Open tasks · Report a bug

CiteFix is a MediaWiki gadget and server-side tool that helps Wikipedia editors identify and repair common citation errors in articles. It analyses the current article's wikitext, applies applicable fixes, and opens the edit page with the corrected wikitext preloaded alongside a live diff, allowing editors to review every change before deciding whether to publish or discard it. CiteFix never publishes edits automatically. The editor is always in control. The tool currently focuses on repairing common citation issues such as:

The tool currently focuses on repairing common citation issues, including:

Additional citation error types will be supported as the tool evolves.

Features

  • Fixes malformed or invalid URLs in CS1 citation templates ({{Cite web }}, {{Cite news }}, {{Cite journal }}, etc.)
  • Restores broken named references (<ref name="x"/> with no matching definition) by searching revision history and sibling articles
  • Inserts {{Reflist }} or {{Notelist }} when references are present but no reference list exists
  • Deduplicates repeated reference definitions
  • Adds a CiteFix button to the article tab bar alongside Read, Edit, and View history
  • Automatically opens the "Show changes" diff view for editor review
  • Auto-fills the edit summary with Fixed citation errors using CiteFix

How it works

  1. The editor clicks the CiteFix button on any Wikipedia article.
  2. The gadget sends the article title to the CiteFix backend API hosted on Wikimedia Cloud Services.
  3. The backend fetches the article's latest wikitext via the MediaWiki Action API, applies all relevant citation fixes in a single pass, and returns the corrected wikitext.
  4. The gadget redirects the editor to the article's edit page, injects the corrected wikitext into the editor, and automatically clicks "Show changes".
  5. The editor reviews the proposed diff and chooses to publish, modify, or discard the changes.

Supported fix categories

Category Description
cs1 Removes or corrects malformed URLs in CS1 citation template parameters (url=, archive-url=)
broken_ref Restores self-closing <ref name="…"/> tags that have no matching definition, by searching page history and related articles
missing_reflist Inserts {{Reflist }} or {{Notelist }} when the article uses references but has no reference list
duplicate_ref Collapses duplicate <ref> definitions with the same name into a single definition with self-closing reuses

Installation

As a personal userscript

Add the following line to your Special:MyPage/common.js:

mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Gopavasanth/UserScripts/Citefix.js&action=raw&ctype=text/javascript');

Or copy the full script from the repository directly into your common.js.

As a wiki gadget (sysops)

  1. Copy the userscript into MediaWiki:Gadget-CiteFix.js.
  2. Add the following to MediaWiki:Gadgets-definition:
* CiteFix[ResourceLoader|default=false]|CiteFix.js

API

The CiteFix backend exposes a public REST API hosted at https://citefix.wmcloud.org/api.

Fix endpoint

POST /api/fix

Request body:

{
  "language": "en",
  "category": ["cs1", "broken_ref", "missing_reflist", "duplicate_ref"],
  "page": "Article title"
}

Response:

{
  "id": "abc123",
  "no_changes": false
}

Retrieve corrected wikitext

POST /api/newcontent/{id}

Response:

{
  "metadata": { "language": "en", "page": "Article title" },
  "original": "…original wikitext…",
  "revision": "…corrected wikitext…"
}

The fix and newcontent endpoints are public and do not require authentication. The edit endpoint (which submits changes to Wikipedia) requires OAuth authentication.


Demo

Architecture

Component Technology Description
Gadget / userscript JavaScript (vanilla) Runs inside MediaWiki; adds the CiteFix button, calls the API, injects wikitext, triggers diff view
Backend API Python / Flask Hosted on Wikimedia Cloud Services; fetches wikitext, applies fixes, stores result in Redis
Storage Redis Temporarily caches fix results (1 hour TTL) between the fix and edit steps
Authentication OAuth 1.0a Required only for the edit endpoint; fix and diff endpoints are public

Repository

See also