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
10 changes: 4 additions & 6 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ Built: when someone creates a new article, a **Start from** choice on the edit p
offers every template whose name starts with `Start ` (for example
`Template:Start Extension`) and fills the text box with its text. The templates are
ordinary wiki pages, so they have versions, approval and permissions, and there is no
separate admin page. See the README.
separate admin page. See the README. An encyclopedia-style skeleton, `Template:Start Article`
(Overview, History, See also, References), comes from the starter templates repository,
[`phpbbmodders/wiki-templates`](https://github.com/phpbbmodders/wiki-templates), and boards
install it from the ACP like the other starter templates.

Not built:

- A starter skeleton that comes with the extension (an encyclopedia-style article with
`Overview`, `History` and `References` headings). It would fit the starter templates
repository, [`phpbbmodders/wiki-templates`](https://github.com/phpbbmodders/wiki-templates),
better than code in the extension.
- Starting from an existing article, or a template that asks for values first.


## Categories

Built: `[[Category:Name]]` in an article puts it in a category, a category page
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/starter_templates_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ public function test_an_adapted_template_with_its_header_is_accepted()
$this->assertSame('', starter_templates::problem('Small', self::HEADER . '[size=85]{{{1}}}[/size]'));
}

public function test_the_repositorys_own_work_is_accepted()
{
$own = "<noinclude>\nSource: phpBB Modders (own work)\nLicence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/\n</noinclude>== Overview ==";
$this->assertSame('', starter_templates::problem('Start Article', $own));
$this->assertSame('WIKI_STARTER_NO_ATTRIBUTION', starter_templates::problem('Start Article', str_replace('phpBB Modders (own work)', 'Somebody', $own)));
}

public function test_a_template_without_source_or_licence_is_refused()
{
$this->assertSame('WIKI_STARTER_NO_ATTRIBUTION', starter_templates::problem('Small', '[size=85]{{{1}}}[/size]'));
Expand Down
4 changes: 3 additions & 1 deletion wiki/starter_templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,10 @@ public static function problem($name, $text)
{
return 'WIKI_STARTER_BAD_NAME';
}
// A source page on another wiki, or the repository's own work (a Start template, say),
// and the licence either way
if (!preg_match('#\A<noinclude>(.*?)</noinclude>#s', $text, $header)
|| !preg_match('#^Source: https://\S+/Template:\S+$#m', $header[1])
|| !preg_match('#^Source: (?:https://\S+/Template:\S+|phpBB Modders \(own work\))$#m', $header[1])
|| !preg_match('#^Licence: CC BY-SA 4\.0, https://creativecommons\.org/licenses/by-sa/4\.0/$#m', $header[1]))
{
return 'WIKI_STARTER_NO_ATTRIBUTION';
Expand Down
Loading