From: Andy Allan Date: Wed, 24 Jan 2024 11:39:28 +0000 (+0000) Subject: Merge pull request #4401 from KasperFranz/buried-wikidata X-Git-Tag: live~741 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/e7ddfe10846f89b5eeec4bf4f4dc03057a744009?hp=-c Merge pull request #4401 from KasperFranz/buried-wikidata Add buried to list of secondary Wiki prefixes --- e7ddfe10846f89b5eeec4bf4f4dc03057a744009 diff --combined app/helpers/browse_tags_helper.rb index 04d9a6c20,ffb88b43f..bbe4c63b1 --- a/app/helpers/browse_tags_helper.rb +++ b/app/helpers/browse_tags_helper.rb @@@ -1,7 -1,7 +1,7 @@@ module BrowseTagsHelper # https://wiki.openstreetmap.org/wiki/Key:wikipedia#Secondary_Wikipedia_links # https://wiki.openstreetmap.org/wiki/Key:wikidata#Secondary_Wikidata_links - SECONDARY_WIKI_PREFIXES = "architect|artist|brand|flag|genus|name:etymology|network|operator|species|subject".freeze + SECONDARY_WIKI_PREFIXES = "architect|artist|brand|buried|flag|genus|name:etymology|network|operator|species|subject".freeze def format_key(key) if url = wiki_link("key", key) @@@ -34,13 -34,9 +34,13 @@@ end safe_join(phones, "; ") elsif colour_value = colour_preview(key, value) - tag.span("", :class => "colour-preview-box float-end m-1 border border-dark border-opacity-10", :"data-colour" => colour_value, :title => t("browse.tag_details.colour_preview", :colour_value => colour_value)) + colour_value + svg = tag.svg :width => 14, :height => 14, :class => "float-end m-1" do + concat tag.title t("browse.tag_details.colour_preview", :colour_value => colour_value) + concat tag.rect :x => 0.5, :y => 0.5, :width => 13, :height => 13, :fill => colour_value, :stroke => "#2222" + end + svg + colour_value else - safe_join(value.split(";").map { |x| linkify(h(x)) }, ";") + safe_join(value.split(";", -1).map { |x| linkify(h(x)) }, ";") end end diff --combined test/helpers/browse_tags_helper_test.rb index 83c397b7d,76bd04f3b..f47c215c0 --- a/test/helpers/browse_tags_helper_test.rb +++ b/test/helpers/browse_tags_helper_test.rb @@@ -22,12 -22,6 +22,12 @@@ class BrowseTagsHelperTest < ActionView html = format_value("unknown", "unknown") assert_dom_equal "unknown", html + html = format_value("unknown", "abc;def") + assert_dom_equal "abc;def", html + + html = format_value("unknown", "foo;") + assert_dom_equal "foo;", html + html = format_value("addr:street", "Rue de l'Amigo") assert_dom_equal "Rue de l'Amigo", html @@@ -54,9 -48,7 +54,9 @@@ assert_dom_equal "File:Test.jpg", html html = format_value("colour", "#f00") - assert_dom_equal %(#f00), html + dom = Rails::Dom::Testing.html_document_fragment.parse html + assert_select dom, "svg>rect>@fill", "#f00" + assert_match(/#f00$/, html) html = format_value("email", "foo@example.com") assert_dom_equal "foo@example.com", html @@@ -140,6 -132,11 +140,11 @@@ assert_equal "//www.wikidata.org/entity/Q24?uselang=en", links[0][:url] assert_equal "Q24", links[0][:title] + # This verified buried is working + links = wikidata_links("buried:wikidata", "Q24") + assert_equal "//www.wikidata.org/entity/Q24?uselang=en", links[0][:url] + assert_equal "Q24", links[0][:title] + links = wikidata_links("species:wikidata", "Q26899") assert_equal "//www.wikidata.org/entity/Q26899?uselang=en", links[0][:url] assert_equal "Q26899", links[0][:title]