jenkins-bot has submitted this change and it was merged. Change subject: Add insertables for OSM website ......................................................................
Add insertables for OSM website * Variables: %{id} * Named html entities: © * Html links (if there are many links in a message, can cause display glitch) Change-Id: Ida045ee82df060b1159f9e76ecbc98ba50139138 --- A groups/OpenStreetMap/Insertables.php M groups/OpenStreetMap/OpenStreetMap.yaml 2 files changed, 34 insertions(+), 0 deletions(-) Approvals: Siebrand: Looks good to me, approved jenkins-bot: Verified diff --git a/groups/OpenStreetMap/Insertables.php b/groups/OpenStreetMap/Insertables.php new file mode 100644 index 0000000..b6005ab --- /dev/null +++ b/groups/OpenStreetMap/Insertables.php @@ -0,0 +1,30 @@ +<?php + +/** + * @author Niklas Laxström + * @license GPL-2.0+ + */ +class OSMInsertablesSuggester implements InsertablesSuggester { + public function getInsertables( $text ) { + $insertables = array(); + + // Variables and html entities + $matches = array(); + preg_match_all( '/%{[a-z_]+}|&[a-z]+;/', $text, $matches, PREG_SET_ORDER ); + $new = array_map( function( $match ) { + return new Insertable( $match[0], $match[0] ); + }, $matches ); + $insertables = array_merge( $insertables, $new ); + + // Links + $matches = array(); + preg_match_all( '~(<a.*?>).*?(</a>)~', $text, $matches, PREG_SET_ORDER ); + $new = array_map( function( $match ) { + return new Insertable( "{$match[1]}{$match[2]}", $match[1], $match[2] ); + }, $matches ); + $insertables = array_merge( $insertables, $new ); + + + return $insertables; + } +} diff --git a/groups/OpenStreetMap/OpenStreetMap.yaml b/groups/OpenStreetMap/OpenStreetMap.yaml index f423fce..c5c608c 100644 --- a/groups/OpenStreetMap/OpenStreetMap.yaml +++ b/groups/OpenStreetMap/OpenStreetMap.yaml @@ -43,8 +43,12 @@ checks: - OSMVariablesCheck +INSERTABLES: + class: OSMInsertablesSuggester + AUTOLOAD: OSMMessageChecker: Checker.php + OSMInsertablesSuggester: Insertables.php TAGS: optional: -- To view, visit https://gerrit.wikimedia.org/r/98397 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ida045ee82df060b1159f9e76ecbc98ba50139138 Gerrit-PatchSet: 1 Gerrit-Project: translatewiki Gerrit-Branch: master Gerrit-Owner: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Siebrand <siebr...@wikimedia.org> Gerrit-Reviewer: jenkins-bot _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits