diff --git a/docs/TODO.md b/docs/TODO.md index 2858b35..f47eb63 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -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 diff --git a/tests/unit/starter_templates_test.php b/tests/unit/starter_templates_test.php index 1f5f330..6b4c693 100644 --- a/tests/unit/starter_templates_test.php +++ b/tests/unit/starter_templates_test.php @@ -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 = "\nSource: phpBB Modders (own work)\nLicence: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/\n== 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]')); diff --git a/wiki/starter_templates.php b/wiki/starter_templates.php index 09e010a..6163436 100644 --- a/wiki/starter_templates.php +++ b/wiki/starter_templates.php @@ -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(.*?)#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';