Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

So far [`templates/`](templates/) holds the hatnotes `{{Main}}`, `{{See also}}`, `{{Further}}`, `{{About}}`, `{{Distinguish}}`, `{{For}}`, `{{Other uses}}` and `{{Redirect}}`; the message boxes `{{Ambox}}`, `{{Update}}`, `{{Unreferenced}}`, `{{More citations needed}}`, `{{Primary sources}}`, `{{Cleanup}}`, `{{Confusing}}`, `{{Technical}}`, `{{Expand section}}` and `{{Under construction}}`; the stub boxes `{{Asbox}}` and `{{Stub}}`; the inline helpers `{{Nowrap}}`, `{{Small}}`, `{{Large}}` and `{{Center}}`; `{{Blockquote}}` (phpBB's quote box) and `{{Template link}}`, which shows a template's name in braces as a link; `{{Infobox}}`, a table of labelled facts that other infoboxes can be built on; `{{Cite web}}`, a citation of a web page in Wikipedia's style; and `{{Navbox}}`, a box of links to related articles that the reader opens and closes (wiki extension 1.1.0-a2 and later). The plan this repository was built to, now completed, is archived in the wiki extension's [`docs/TODO/archive/archive1.md`](https://github.com/phpbbmodders/phpbb-ext-wiki/blob/main/docs/TODO/archive/archive1.md#starter-templates-repository-completed-10142026).
So far [`templates/`](templates/) holds the hatnotes `{{Main}}`, `{{See also}}`, `{{Further}}`, `{{About}}`, `{{Distinguish}}`, `{{For}}`, `{{Other uses}}` and `{{Redirect}}`; the message boxes `{{Ambox}}`, `{{Update}}`, `{{Unreferenced}}`, `{{More citations needed}}`, `{{Primary sources}}`, `{{Cleanup}}`, `{{Confusing}}`, `{{Technical}}`, `{{Expand section}}` and `{{Under construction}}`; the stub boxes `{{Asbox}}` and `{{Stub}}`; the inline helpers `{{Nowrap}}`, `{{Small}}`, `{{Large}}` and `{{Center}}`; `{{Blockquote}}` (phpBB's quote box) and `{{Template link}}`, which shows a template's name in braces as a link; `{{Infobox}}`, a table of labelled facts that other infoboxes can be built on; `{{Cite web}}`, a citation of a web page in Wikipedia's style; `{{Navbox}}`, a box of links to related articles that the reader opens and closes (wiki extension 1.1.0-a2 and later); and `Start Article`, the repository's own skeleton for an encyclopedia-style article, which the board's **Start from** choice offers when someone creates a new article. The plan this repository was built to, now completed, is archived in the wiki extension's [`docs/TODO/archive/archive1.md`](https://github.com/phpbbmodders/phpbb-ext-wiki/blob/main/docs/TODO/archive/archive1.md#starter-templates-repository-completed-10142026).

## Why a separate repository

Expand Down
19 changes: 19 additions & 0 deletions templates/Start Article.wiki
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<noinclude>
Source: phpBB Modders (own work)
A starting point for an encyclopedia-style article. When someone creates a new article, the Start from choice above the edit form offers it as "Article" and fills the text box with everything below this box, to replace with the real text. It is not meant to be included in an article.
Licence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/
</noinclude>[b]Subject[/b] is (one sentence saying what it is).

== Overview ==
(What it is, what it does, and who it is for.)

== History ==
(How it began and how it has changed.)

== See also ==
[list]
[*][[Related article]]
[/list]

== References ==
(Where the facts above come from, one source per line.)
15 changes: 15 additions & 0 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,21 @@ def test_calls_are_only_allowed_in_example_and_expect_lines(self):
["a header line other than Example and Expect holds {{ or "
"}}, which the board would run: Changes"])

def test_own_work_needs_only_its_source_line_and_licence(self):
own = ("<noinclude>\nSource: phpBB Modders (own work)\n"
"Licence: CC BY-SA 4.0, " + check_headers.LICENCE_URL + "\n"
"</noinclude>== Overview ==")
with tempfile.TemporaryDirectory() as directory:
path = self.write(directory, own)
self.assertEqual(check_headers.problems(path), [])
no_licence = own.replace(check_headers.LICENCE_URL, "")
path = self.write(directory, no_licence)
self.assertEqual(check_headers.problems(path),
["header has no licence notice"])
other = own.replace("phpBB Modders (own work)", "somebody")
self.assertIn("header has no source URL",
check_headers.problems(self.write(directory, other)))

def test_adapted_header_passes(self):
header = fetch_template.header(ENWIKI, PAGE, [], True).replace(
"Changes: TODO.", "Changes: rewritten without Lua.")
Expand Down
21 changes: 15 additions & 6 deletions tools/check_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@
* the licence notice, a link to
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. 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.
A template written here rather than adapted, such as a Start template for new
articles, says "Source: phpBB Modders (own work)" instead of the Source and
History lines, and needs no list of changes; it carries the same licence
notice, so the repository stays under one licence.

There must be no "Needs adapting:" line, which tools/fetch_template.py
writes while a 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
Expand Down Expand Up @@ -63,6 +68,8 @@
"licence notice": re.compile(re.escape(LICENCE_URL)),
}
HEADER = re.compile(r"\A<noinclude>(.*?)</noinclude>", re.S)
# A template written here, not adapted from another wiki
OWN_WORK = re.compile(r"^Source: phpBB Modders \(own work\)$", re.M)


def source_problems(text: str) -> list:
Expand Down Expand Up @@ -99,9 +106,11 @@ def problems(path: Path) -> list:
header = HEADER.match(text)
if not header:
return ["does not start with a <noinclude> header"]
found = source_problems(header.group(1))
own_work = bool(OWN_WORK.search(header.group(1)))
found = [] if own_work else source_problems(header.group(1))
found += [f"header has no {name}" for name, pattern in REQUIRED.items()
if not pattern.search(header.group(1))]
if not pattern.search(header.group(1))
and not (own_work and name == "list of changes")]
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
Expand Down
5 changes: 5 additions & 0 deletions tools/compare_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

sys.path.insert(0, str(Path(__file__).resolve().parent))
import fetch_template # noqa: E402
import check_headers # noqa: E402

REPO = Path(__file__).resolve().parent.parent
RENDERER = Path(__file__).resolve().parent / "render_on_board.php"
Expand Down Expand Up @@ -224,6 +225,10 @@ def main() -> int:
failed = 0
plan = []
for name in names:
# Written here, so there is no source wiki to compare with
if check_headers.OWN_WORK.search(templates[name]):
print(f"SKIPPED {name}: own work, no source wiki to compare with")
continue
examples = EXAMPLE.findall(templates[name])
try:
site = site_of(templates[name])
Expand Down
Loading