[openstreetmap-website] Link prefixed Wikidata-tags to wikidata.org (#788)

Tom Hughes notifications at github.com
Thu Jul 24 21:19:23 UTC 2014


> @@ -61,8 +61,17 @@ def format_key(key)
>    def format_value(key, value)
>      if wp = wikipedia_link(key, value)
>        link_to h(wp[:title]), wp[:url], :title => t('browse.tag_details.wikipedia_link', :page => wp[:title])
> -    elsif wdt = wikidata_link(key, value)
> -      link_to h(wdt[:title]), wdt[:url], :title => t('browse.tag_details.wikidata_link', :page => wdt[:title])
> +    elsif wdt = wikidata_links(key, value)
> +      # IMPORTANT: Note that wikidata_links() returns an array of hashes, unlike for example wikipedia_link(),
> +      # which just returns one such hash.
> +      # Thus we have to iterate over it here.
> +      result = ''
> +      for item in wdt
> +        # adding a link to the result-string
> +        result += ';'+link_to(item[:title], item[:url], :title => t('browse.tag_details.wikidata_link', :page => item[:title].strip))
> +      end
> +      # Format the result and remove the superfluous semicolon, which was added in the for-loop above
> +      simple_format(result[1..-1]);

Why do we want to use `simple_format` here? We don't do that for any of the other cases?

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/788/files#r15373616
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20140724/ce2df8f8/attachment.html>


More information about the rails-dev mailing list