jenkins-bot has submitted this change and it was merged. Change subject: Ignore book title ......................................................................
Ignore book title Titles parsed from {{Book}} templates are usually irrelevant and should be ignored (we don't want to show the title of some book containing the image instead of the name of the image). Book templates will have to be ignored completely anyway (#937) so this commit is really just about cleaning up the template parser configuration. Also add test for extracting the title. Change-Id: I27879afbaefe40a879a34eccdf7515a6f9bbe3e2 Mingle: https://wikimedia.mingle.thoughtworks.com/projects/multimedia/cards/589 --- M TemplateParser.php M tests/phpunit/ParserTestHelper.php M tests/phpunit/TemplateParserTest.php 3 files changed, 16 insertions(+), 1 deletion(-) Approvals: Gilles: Looks good to me, approved jenkins-bot: Verified diff --git a/TemplateParser.php b/TemplateParser.php index e667752..0e37366 100644 --- a/TemplateParser.php +++ b/TemplateParser.php @@ -51,7 +51,6 @@ # of source than "Source" does. 'fileinfotpl_src' => 'Credit', 'fileinfotpl_art_title' => 'ObjectName', - 'fileinfotpl_book_title' => 'ObjectName', 'fileinfotpl_perm' => 'Permission', 'fileinfotpl_credit' => 'Attribution', ); diff --git a/tests/phpunit/ParserTestHelper.php b/tests/phpunit/ParserTestHelper.php index e765b59..ec7e51d 100644 --- a/tests/phpunit/ParserTestHelper.php +++ b/tests/phpunit/ParserTestHelper.php @@ -34,6 +34,10 @@ 'manylang' => 'File_Sikh_pilgrim_at_the_Golden_Temple_(Harmandir_Sahib)_in_Amritsar,_India.jpg', // an image with a relatively long description 'big' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg', + // information-like template with a title field + 'title' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg', + // Book + Photograph templates + 'book' => 'File_Askaris_im_Warschauer_Getto_-_1943.jpg', ); /** diff --git a/tests/phpunit/TemplateParserTest.php b/tests/phpunit/TemplateParserTest.php index e6c11fc..b14e0ae 100644 --- a/tests/phpunit/TemplateParserTest.php +++ b/tests/phpunit/TemplateParserTest.php @@ -2,6 +2,8 @@ use CommonsMetadata\TemplateParser; +require_once __DIR__ . "/ParserTestHelper.php"; + /** * @covers CommonsMetadata\TemplateParser * @group Extensions/CommonsMetadata @@ -178,6 +180,16 @@ $data, TemplateParser::INFORMATION_FIELDS_KEY ); } + /** + * Some templates (such as {{Photograph}}) have a title field + */ + public function testTitle() { + $data = $this->parseTestHTML( 'title' ); + $this->assertFieldEquals( 'ObjectName', '<span class="fn"><span style="font-size:0.9em">German: ' + . '<i>Askaris, die mit eingesetzt waren</i></span><span style="font-weight:bold"><br>' + . '<i>Askaris used during the operation</i></span></span>', $data, TemplateParser::INFORMATION_FIELDS_KEY ); + } + // -------------------- license tests -------------------- -- To view, visit https://gerrit.wikimedia.org/r/169334 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I27879afbaefe40a879a34eccdf7515a6f9bbe3e2 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/extensions/CommonsMetadata Gerrit-Branch: master Gerrit-Owner: Gergő Tisza <gti...@wikimedia.org> Gerrit-Reviewer: Gilles <gdu...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits