diff --git a/dab_mechanic/mediawiki_api.py b/dab_mechanic/mediawiki_api.py index 26d7a20..f681af3 100644 --- a/dab_mechanic/mediawiki_api.py +++ b/dab_mechanic/mediawiki_api.py @@ -43,3 +43,18 @@ def get_content(title: str) -> str: data = call(params) rev: str = data["query"]["pages"][0]["revisions"][0]["content"] return rev + + +def compare(title: str, new_text: str) -> str: + """Generate a diff for the new article text.""" + params: dict[str, str | int] = { + "format": "json", + "formatversion": 2, + "action": "compare", + "fromtitle": title, + "toslots": "main", + "totext-main": new_text, + "prop": "diff", + } + diff: str = call(params)["compare"]["body"] + return diff diff --git a/templates/save.html b/templates/preview.html similarity index 100% rename from templates/save.html rename to templates/preview.html