diff --git a/README.md b/README.md index 9655da9..ffaa4e8 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Ready-made templates for the [phpBB Modders wiki extension](https://github.com/phpbbmodders/phpbb-ext-wiki), adapted from Wikipedia's and other Wikimedia wikis' for what the wiki can do, so a board can start with a useful set instead of writing every template from nothing. -The hatnotes `{{Main}}`, `{{See also}}`, `{{Further}}` and `{{About}}` are in [`templates/`](templates/) so far. The plan for this repository is in the wiki extension's [`docs/TODO/todo-wiki-templates-repo.md`](https://github.com/phpbbmodders/phpbb-ext-wiki/blob/main/docs/TODO/todo-wiki-templates-repo.md). +So far [`templates/`](templates/) holds the hatnotes `{{Main}}`, `{{See also}}`, `{{Further}}` and `{{About}}`; the message boxes `{{Ambox}}`, `{{Update}}`, `{{Unreferenced}}`, `{{More citations needed}}` and `{{Under construction}}`; the stub boxes `{{Asbox}}` and `{{Stub}}`; and `{{Nowrap}}`. The plan for this repository is in the wiki extension's [`docs/TODO/todo-wiki-templates-repo.md`](https://github.com/phpbbmodders/phpbb-ext-wiki/blob/main/docs/TODO/todo-wiki-templates-repo.md). ## Why a separate repository @@ -127,6 +127,8 @@ Licence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/ The header meets what Wikipedia asks of a reuser: it links the page copied and its history (which lists the authors), says the copy was changed, and states the licence. It sits inside ``, so it shows on the template's own page on the board but not in the articles that use it. +Since the header is the documentation on the template's page, a template call written in it is run there. Only `Example:` and `Expect:` lines may hold `{{` or `}}`; write a function's name without braces anywhere else, such as "#if". + The [Check](.github/workflows/check.yml) workflow runs [`tools/check_headers.py`](tools/check_headers.py) on every push and pull request. It fails when a template is missing any of these lines, still says `Changes: TODO`, or still has a `Needs adapting:` line: ```bash diff --git a/data/templates.json b/data/templates.json index c329c09..0952f65 100644 --- a/data/templates.json +++ b/data/templates.json @@ -20,6 +20,13 @@ "status": "adapted", "title": "Template:Unreferenced" }, + "enwiki:1627975": { + "name": "Nowrap", + "reason": "", + "revid": 692794261, + "status": "adapted", + "title": "Template:Nowrap" + }, "enwiki:1721254": { "name": "See also", "reason": "", diff --git a/templates/About.wiki b/templates/About.wiki index d4cc859..1452db7 100644 --- a/templates/About.wiki +++ b/templates/About.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:About History: https://en.wikipedia.org/w/index.php?title=Template:About&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:About&oldid=1044582448 (09/16/2021 12:56 AM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:About): one other use and its article, with "other uses" and PAGENAME (disambiguation) when left out; no further use and article pairs, no section or text options; between the two sentences, since {{#if:}} trims a plain space there; shown in italics instead of the hatnote style, since the wiki allows no
; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:About): one other use and its article, with "other uses" and PAGENAME (disambiguation) when left out; no further use and article pairs, no section or text options; between the two sentences, since #if trims a plain space there; shown in italics instead of the hatnote style, since the wiki allows no
; removed the source's documentation and categories. Example: {{About|the forum software|the bulletin board in general|Bulletin board}} Example: {{About|the forum software}} Example: {{About||the bulletin board in general|Bulletin board}} diff --git a/templates/Ambox.wiki b/templates/Ambox.wiki index 2d08cda..4b19615 100644 --- a/templates/Ambox.wiki +++ b/templates/Ambox.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:Ambox History: https://en.wikipedia.org/w/index.php?title=Template:Ambox&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:Ambox&oldid=1377691028 (09/30/2026 4:25 PM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:Message box): a one-cell table with the text, or the issue and the fix, and the date in brackets; no image, type colours, small, talk or category options, since the wiki allows no images in templates, no styles and no
; where {{#if:}} would trim a space; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:Message box): a one-cell table with the text, or the issue and the fix, and the date in brackets; no image, type colours, small, talk or category options, since the wiki allows no images in templates, no styles and no
; where #if would trim a space; removed the source's documentation and categories. Example: {{Ambox|issue=This article needs work.|fix=Please help.}} Example: {{Ambox|text=Plain notice text.}} Example: {{Ambox|issue=Needs work.|date=October 2026}} diff --git a/templates/Asbox.wiki b/templates/Asbox.wiki index ec04784..3540cd1 100644 --- a/templates/Asbox.wiki +++ b/templates/Asbox.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:Article_stub_box History: https://en.wikipedia.org/w/index.php?title=Template:Article_stub_box&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:Article_stub_box&oldid=1271057113 (01/22/2025 12:12 PM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:Article stub box): a one-cell table; "You can help Wikipedia" names the board instead ({{SITENAME}}); no image, no link to the edit page, no v t e links, no category options; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:Article stub box): a one-cell table; "You can help Wikipedia" names the board instead (the SITENAME magic word); no image, no link to the edit page, no v t e links, no category options; removed the source's documentation and categories. Example: {{Asbox|subject=software|name=Template:Software-stub}} Expect: This software article is a stub. You can help {{SITENAME}} by adding missing information. Example: {{Asbox|name=Template:X-stub}} diff --git a/templates/Further.wiki b/templates/Further.wiki index 6f2d6d8..e35fc20 100644 --- a/templates/Further.wiki +++ b/templates/Further.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:Further History: https://en.wikipedia.org/w/index.php?title=Template:Further&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:Further&oldid=1337132284 (02/07/2026 5:55 PM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no topic or selfref options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since {{#if:}} trims a plain space there; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no topic or selfref options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since #if trims a plain space there; removed the source's documentation and categories. Example: {{Further|Styles}} Example: {{Further|Styles|Templates}} Licence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/templates/Main.wiki b/templates/Main.wiki index 86a33fc..0a06f60 100644 --- a/templates/Main.wiki +++ b/templates/Main.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:Main History: https://en.wikipedia.org/w/index.php?title=Template:Main&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:Main&oldid=1363280785 (07/09/2026 5:15 AM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no selfref or category options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since {{#if:}} trims a plain space there; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no selfref or category options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since #if trims a plain space there; removed the source's documentation and categories. Example: {{Main|History of phpBB}} Example: {{Main|Installation|Upgrading}} Example: {{Main|A|B|C}} diff --git a/templates/Nowrap.wiki b/templates/Nowrap.wiki new file mode 100644 index 0000000..78cbba8 --- /dev/null +++ b/templates/Nowrap.wiki @@ -0,0 +1,10 @@ + +Source: https://en.wikipedia.org/wiki/Template:Nowrap +History: https://en.wikipedia.org/w/index.php?title=Template:Nowrap&action=history +Revision: https://en.wikipedia.org/w/index.php?title=Template:Nowrap&oldid=692794261 (11/28/2015 10:13 AM UTC) +Adapted by phpBB Modders. +Changes: rewritten without the the wiki does not allow: every space in the text becomes a non-breaking space (#replace with an empty search), so the words stay on one line; unlike the original, the text can still break at a hyphen; removed the source's documentation and categories. +Example: {{Nowrap|keep these words together}} +Example: {{Nowrap|10 km}} +Licence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/ +{{#replace:{{{1}}}|| }} diff --git a/templates/See also.wiki b/templates/See also.wiki index f1c8622..fd84a80 100644 --- a/templates/See also.wiki +++ b/templates/See also.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:See_also History: https://en.wikipedia.org/w/index.php?title=Template:See_also&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:See_also&oldid=1292725734 (05/28/2025 1:34 PM UTC) Adapted by phpBB Modders. -Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no ifexists, selfref or category options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since {{#if:}} trims a plain space there; removed the source's documentation and categories. +Changes: rewritten in plain wiki text without Lua (Module:Labelled list hatnote): up to five articles, with their l1 to l5 link texts, listed as A, A and B, or A, B, and C; no ifexists, selfref or category options; shown in italics instead of the hatnote style, since the wiki allows no
; before "and", since #if trims a plain space there; removed the source's documentation and categories. Example: {{See also|Configuration}} Example: {{See also|Configuration|Permissions}} Example: {{See also|A|B|C}} diff --git a/templates/Under construction.wiki b/templates/Under construction.wiki index e5a517b..1d714b8 100644 --- a/templates/Under construction.wiki +++ b/templates/Under construction.wiki @@ -3,7 +3,7 @@ Source: https://en.wikipedia.org/wiki/Template:Under_construction History: https://en.wikipedia.org/w/index.php?title=Template:Under_construction&action=history Revision: https://en.wikipedia.org/w/index.php?title=Template:Under_construction&oldid=1379314703 (10/09/2026 4:59 AM UTC) Adapted by phpBB Modders. -Changes: rewritten as a call to the Ambox here instead of Mbox; left out the sentence with the time of the last edit (REVISIONTIMESTAMP, which the wiki does not have) and the suggestion to use {{In use}}, which is not in this repository; no user, image or category options; removed the source's documentation and categories. +Changes: rewritten as a call to the Ambox here instead of Mbox; left out the sentence with the time of the last edit (REVISIONTIMESTAMP, which the wiki does not have) and the suggestion to use the In use template, which is not in this repository; no user, image or category options; removed the source's documentation and categories. Example: {{Under construction}} Expect: This article or section is undergoing significant expansion or restructuring. You are welcome to assist in its construction by editing it as well. Please remove this notice if this article or section has not been edited in several days. Licence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/ diff --git a/tests/test_tools.py b/tests/test_tools.py index 770b21e..c592b53 100644 --- a/tests/test_tools.py +++ b/tests/test_tools.py @@ -89,7 +89,7 @@ def test_lua_templatestyles_and_unsupported_functions_are_flagged(self): "{{#if:a|b}}{{#tag:ref|x}}{{formatnum:5}}{{lc:A}}" "{{PAGENAME}}{{BASEPAGENAME}}{{CURRENTYEAR}}") self.assertEqual(fetch_template.needs(text), [ - "Lua ({{#invoke:}})", "TemplateStyles", + "Lua (#invoke)", "TemplateStyles", "unsupported #tag, BASEPAGENAME, formatnum"]) def test_translate_markup_is_flagged(self): @@ -124,7 +124,7 @@ def write(self, directory, header, body="{{{1}}}"): return path def test_fetched_header_is_held_back_until_adapted(self): - header = fetch_template.header(ENWIKI, PAGE, ["Lua ({{#invoke:}})"], + header = fetch_template.header(ENWIKI, PAGE, ["Lua (#invoke)"], True) self.assertIn("&oldid=1292725734 (07/09/2026 5:15 AM UTC)", header) self.assertNotIn("{{Documentation}}", header) @@ -134,6 +134,17 @@ def test_fetched_header_is_held_back_until_adapted(self): "the list of changes still says TODO", "still needs adapting (see its Needs adapting line)"]) + def test_calls_are_only_allowed_in_example_and_expect_lines(self): + header = fetch_template.header(ENWIKI, PAGE, [], True).replace( + "Changes: TODO.", "Changes: uses {{#if:}} now.").replace( + "Licence:", "Example: {{See also|A}}\nExpect: See also: A\n" + "Licence:") + with tempfile.TemporaryDirectory() as directory: + self.assertEqual(check_headers.problems( + self.write(directory, header)), + ["a header line other than Example and Expect holds {{ or " + "}}, which the board would run: Changes"]) + def test_adapted_header_passes(self): header = fetch_template.header(ENWIKI, PAGE, [], True).replace( "Changes: TODO.", "Changes: rewritten without Lua.") diff --git a/tools/check_headers.py b/tools/check_headers.py index 57130cd..a86aec1 100755 --- a/tools/check_headers.py +++ b/tools/check_headers.py @@ -18,7 +18,9 @@ https://creativecommons.org/licenses/by-sa/4.0/; and no "Needs adapting:" line, which tools/fetch_template.py writes while a -template still uses what the wiki cannot run. +template still uses what the wiki cannot run. Only "Example:" and "Expect:" +lines may hold {{ or }}: the header is the template page's documentation on +a board, so a call anywhere else in it would be run there. Input: the templates directory (default: templates/ next to this script's parent). Output: one line per problem on stderr. Exit status: 0 when every @@ -102,6 +104,14 @@ def problems(path: Path) -> list: if not pattern.search(header.group(1))] if re.search(r"^Changes: TODO\b", header.group(1), re.M): found.append("the list of changes still says TODO") + # The header is the template page's documentation on a board, so a call + # written in it would be run there; only examples are meant to be + for line in header.group(1).splitlines(): + if ("{{" in line or "}}" in line) and not line.startswith( + ("Example: ", "Expect: ")): + found.append("a header line other than Example and Expect holds " + "{{ or }}, which the board would run: " + + line.split(":")[0]) if re.search(r"^Needs adapting:", header.group(1), re.M): found.append("still needs adapting (see its Needs adapting line)") return found diff --git a/tools/fetch_template.py b/tools/fetch_template.py index 0f02f8e..0891c24 100755 --- a/tools/fetch_template.py +++ b/tools/fetch_template.py @@ -307,7 +307,7 @@ def needs(text: str) -> list: """What in a template's text the phpBB Modders wiki cannot run.""" problems = [] if re.search(r"\{\{\s*#invoke\s*:", text, re.IGNORECASE): - problems.append("Lua ({{#invoke:}})") + problems.append("Lua (#invoke)") if re.search(r"", text,