X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/25d5c58c5c8902812731ef8d202dd2f015771cb1..15ea756ae655d1ea009efa22a87155136c30fee3:/app/helpers/browse_helper.rb diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 8e0c7648f..c3e013650 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -77,7 +77,7 @@ module BrowseHelper elsif url = telephone_link(key, value) link_to h(value), url, :title => t("browse.tag_details.telephone_link", :phone_number => value) elsif colour_value = colour_preview(key, value) - %(
#{h(value)} ) + content_tag(:span, "", :class => "colour-preview-box", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value else linkify h(value) end @@ -192,7 +192,7 @@ module BrowseHelper end def colour_preview(key, value) - return nil unless (key =~ /^(|building:|ref:|roof:)colour$/ || key =~ /^(int_)?ref:colour(_(bg|tx))?$/) && !value.nil? + return nil unless key =~ /^(?>.+:)?colour$/ && !value.nil? # see discussion at https://github.com/openstreetmap/openstreetmap-website/pull/1779 # does value look like a colour? ( 3 or 6 digit hex code or w3c colour name) w3c_colors = %w[aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgrey darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray