[openstreetmap/openstreetmap-website] Write browse element icons as <img> (PR #5385)
Anton Khorev
notifications at github.com
Mon Dec 9 10:32:14 UTC 2024
@AntonKhorev commented on this pull request.
> @@ -1,15 +1,43 @@
module BrowseHelper
+ def element_icon(type, object)
+ icon_data = { :filename => "#{type}.svg" }
+
+ unless object.redacted?
+ target_tags = object.tags.find_all { |k, _v| BROWSE_ICONS.key? k.to_sym }.sort
+ title = target_tags.map { |k, v| "#{k}=#{v}" }.to_sentence unless target_tags.empty?
+
+ target_tags.each do |k, v|
+ k = k.to_sym
+ v = v.to_sym
+ if v != :* && BROWSE_ICONS[k].key?(v)
+ icon_data = BROWSE_ICONS[k][v]
+ elsif BROWSE_ICONS[k].key?(:*)
Now I have default priorities of 1 for type icons, 10 for `k=*` and 100 for `k=v`; and it's possible to set a different priority in `browse_icons.yml`. I did it to control which icon is shown in case of `building=yes` + `shop=unknown_shop_type`.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5385#discussion_r1875741426
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5385/review/2488390440 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241209/1c80e37f/attachment.htm>
More information about the rails-dev
mailing list