From: Štefan Baebler Date: Tue, 7 Jul 2009 22:05:03 +0000 (+0000) Subject: Introducing comma as tag separator (if present, otherwise it behaves as before),... X-Git-Tag: live~6846 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/ebbcf63f0d910458ae255a84de794e3ccede7a7a Introducing comma as tag separator (if present, otherwise it behaves as before), allowing spaces in tags. fixes #2032 --- diff --git a/app/models/trace.rb b/app/models/trace.rb index 03dbeb0b3..692c20fc6 100644 --- a/app/models/trace.rb +++ b/app/models/trace.rb @@ -20,15 +20,23 @@ class Trace < ActiveRecord::Base end def tagstring - return tags.collect {|tt| tt.tag}.join(" ") + return tags.collect {|tt| tt.tag}.join(", ") end def tagstring=(s) - self.tags = s.split().collect {|tag| - tt = Tracetag.new - tt.tag = tag - tt - } + if s.include?',' + self.tags = s.split(/\s*,\s*/).collect {|tag| + tt = Tracetag.new + tt.tag = tag + tt + } + else + self.tags = s.split().collect {|tag| + tt = Tracetag.new + tt.tag = tag + tt + } + end end def large_picture= (data) diff --git a/app/views/trace/_trace.html.erb b/app/views/trace/_trace.html.erb index 4e1733148..d38fa2f4c 100644 --- a/app/views/trace/_trace.html.erb +++ b/app/views/trace/_trace.html.erb @@ -27,8 +27,8 @@ <%= t'trace.trace.by' %> <%=link_to h(trace.user.display_name), {:controller => 'user', :action => 'view', :display_name => trace.user.display_name} %> <% if !trace.tags.empty? %> <%= t'trace.trace.in' %> - <% trace.tags.each do |tag| %> - <%= link_to_tag tag.tag %> + <% trace.tags.each_with_index do |tag, index| %> + <%= link_to_tag tag.tag %><%=', ' if index+1 < trace.tags.count %> <% end %> <% end %> diff --git a/app/views/trace/view.html.erb b/app/views/trace/view.html.erb index 0688ec130..1001cadf9 100644 --- a/app/views/trace/view.html.erb +++ b/app/views/trace/view.html.erb @@ -36,8 +36,8 @@ <%= t'trace.view.tags' %> <% unless @trace.tags.empty? %> - <% @trace.tags.each do |tag| %> - <%= link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } %> + <% @trace.tags.each_with_index do |tag, index| %> + <%= link_to tag.tag, { :controller => 'trace', :action => 'list', :tag => tag.tag, :id => nil } %><%=', ' if index+1 < @trace.tags.count %> <% end %> <% else %> <%= t'trace.view.none' %>