jenkins-bot has submitted this change and it was merged.

Change subject: Add suggester for iNaturalist
......................................................................


Add suggester for iNaturalist

Change-Id: If5ba4837bdcd8e30442c6e3c3cf125e86d272d16
---
A groups/iNaturalist/Suggester.php
M groups/iNaturalist/iNaturalist.yaml
2 files changed, 25 insertions(+), 0 deletions(-)

Approvals:
  Siebrand: Looks good to me, approved
  jenkins-bot: Verified

Objections:
  Nikerabbit: There's a problem with this change, please improve



diff --git a/groups/iNaturalist/Suggester.php b/groups/iNaturalist/Suggester.php
new file mode 100644
index 0000000..b40a3c0
--- /dev/null
+++ b/groups/iNaturalist/Suggester.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * @author Niklas Laxström
+ * @license GPL-2.0+
+ */
+class INaturalistSuggester 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 );
+
+               return $insertables;
+       }
+}
diff --git a/groups/iNaturalist/iNaturalist.yaml 
b/groups/iNaturalist/iNaturalist.yaml
index 37b17cd..6e8b60f 100644
--- a/groups/iNaturalist/iNaturalist.yaml
+++ b/groups/iNaturalist/iNaturalist.yaml
@@ -28,8 +28,12 @@
   checks:
     - INaturalistVariablesCheck
 
+INSERTABLES:
+  class: InaturalistSuggester
+
 AUTOLOAD:
   INaturalistMessageChecker: Checker.php
+  INaturalistSuggester: Suggester.php
 
 TAGS:
   optional:

-- 
To view, visit https://gerrit.wikimedia.org/r/271004
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: If5ba4837bdcd8e30442c6e3c3cf125e86d272d16
Gerrit-PatchSet: 1
Gerrit-Project: translatewiki
Gerrit-Branch: master
Gerrit-Owner: Siebrand <[email protected]>
Gerrit-Reviewer: Nikerabbit <[email protected]>
Gerrit-Reviewer: Siebrand <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to