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

Florian Schäfer notifications at github.com
Thu Jul 24 21:45:50 UTC 2014


>          :url => "//www.wikidata.org/wiki/#{value}?uselang=#{I18n.locale}",
>          :title => value
> -      }
> +      }]
> +    elsif (
> +      # Key has to be one of the accepted wikidata-tags
> +      key =~ /(architect|artist|brand|operator|subject):wikidata/ and
> +      # Value has to be a semicolon-separated list of wikidata-IDs (whitespaces allowed before and after semicolons)
> +      value =~ /^[Qq][1-9][0-9]*(\s*;\s*[Qq][1-9][0-9]*)*$/
> +    )
> +      # Splitting at every semicolon to get an array of wikidata-IDs (some will be surrounded by whitespaces)
> +      ids = value.split(";")
> +      result = []
> +      for id in ids
> +        # Add a hash to the result-array for every wikidata-ID

@tomhughes thanks for your comments. I'm quite a newbie in Ruby, so I didn't realize, that using map would be a better solution. I'll revise my changes according to your recommendations.

Regarding the multiple values: No, it's not left over from etymology. For example for <code>brand:wikidata</code> it makes sense to allow multiple values, because a car-shop may sell more than one brand (see examples in my comment above). But the plain <code>wikidata</code>-tag establishes a 1:1-mapping of wikidata- and OSM-items. There won't be more than one wikidata-item representing the very same entity as one OSM-object.

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


More information about the rails-dev mailing list