Nikerabbit has uploaded a new change for review.
https://gerrit.wikimedia.org/r/98397
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(-)
git pull ssh://gerrit.wikimedia.org:29418/translatewiki
refs/changes/97/98397/1
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: newchange
Gerrit-Change-Id: Ida045ee82df060b1159f9e76ecbc98ba50139138
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Nikerabbit <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits