[openstreetmap/openstreetmap-website] Added color preview box in tag browser sidebar (#1779)

Štefan Baebler notifications at github.com
Tue Mar 6 11:12:26 UTC 2018


stefanb commented on this pull request.



> @@ -188,4 +190,16 @@ def telephone_link(_key, value)
 
     "tel:#{value_no_whitespace}"
   end
+
+  def colour_preview(key, value)
+    return nil unless (key =~ /^(|building:|ref:|roof:)colour$/ || key =~ /^(int_)?ref:colour(_(bg|tx))?$/) && !value.nil?

If we just look at the existing data and disregard the wiki, we should 
* also make the "u" in "colour" optional. - https://taginfo.openstreetmap.org/search?q=color
* allow any optional prefix and suffix, not requiring any special separators
* drop the case sensitivity

Which makes the regex boild down to simple:
```
/colou?r/i
```
which can be understood that the editor wanted to tag some colour property and if the value indeed looks like a colour (hex code or valid w3c value) we can provide the preview.

Or we could require some common key structure. According to https://taginfo.openstreetmap
require some common key structure. According to https://taginfo.openstreetmap.org/search?q=colour we could generalize it to:
* alow any optional prefix, separated by colon (:) or underscore (_)
* allow any optional suffix, separated by colon (:) or underscore (_)
* insist on british spelling with "u"
* require lowercase
```
/^(.+[:_])?colour([:_].+)?$/
```

Both generalizations would allow us to preview all sorts of future colour tags, even unforeseen enforcements:
![image](https://user-images.githubusercontent.com/319826/37027467-a363018e-2131-11e8-926d-bce7edf77343.png)

What level of generalization did you have in mind? 
* any tag or any tag that looks like it is related to colour
* any structure or some specific separators
* any spelling (british or us also)
* any case (upper, lower, whatever)


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/1779#discussion_r172483571
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20180306/a81cdbe8/attachment-0001.html>


More information about the rails-dev mailing list