public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
slight fix to tag searching in assets

git-svn-id: http://svn.techno-weenie.net/projects/mephisto/trunk@2435 
567b1171-46fb-0310-a4c9-b4bef9110e78
technoweenie (author)
Sat Nov 04 11:15:22 -0800 2006
commit  a360da4c676d81c71de14672437ec9ac25898c89
tree    7d2ea8f4b18b132404fd5bad03bd0731649d3486
parent  9e1205a80ce8d9ffb507f75cedc388efb5001178
...
113
114
115
116
 
117
118
119
...
113
114
115
 
116
117
118
119
0
@@ -113,7 +113,7 @@ class Admin::AssetsController < Admin::BaseController
0
             
0
             if params[:conditions].has_key?(:tags)
0
               options[:include] << :tags
0
- options[:conditions] << Asset.send(:sanitize_sql, ["(taggings.taggable_type = 'Asset' and tags.name IN (?))", Tag.parse(params[:q])])
0
+ options[:conditions] << Asset.send(:sanitize_sql, ["(taggings.taggable_type = 'Asset' and tags.name IN (?))", Tag.parse(params[:q].chomp("%"))])
0
             end
0
           end
0
         
...
7
8
9
 
 
 
 
 
 
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 
 
 
 
 
24
25
26
...
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
 
 
 
 
 
 
 
 
21
22
23
24
25
26
27
28
0
@@ -7,20 +7,22 @@ class Tag < ActiveRecord::Base
0
     end
0
 
0
     # parses a comma separated list of tags into tag names
0
+ # handles all kinds of different tags. (comma seperated, space seperated (in quotation marks))
0
+ # should handle most the common keyword formats.
0
+ #
0
+ # e.g.: b'log, emacs fun, rails, ruby => "b'log", "emacs fun", "rails", "ruby"
0
+ # "b'log" "emacs fun" "rails" "ruby" => "b'log", "emacs fun", "rails", "ruby"
0
+ # 'b\'log' 'emacs fun' 'rails' 'ruby' => "b'log", "emacs fun", "rails", "ruby"
0
     #
0
     # Tag.parse('a, b, c')
0
     # # => ['a', 'b', 'c']
0
     def parse(list)
0
       return list if list.is_a?(Array)
0
- # more robust does handle all kinds of different tags. (comma seperated, space seperated (in quotation marks))
0
- # should handle most the common keyword formats.
0
- # e.g.: b'log, emacs fun, rails, ruby => "b'log", "emacs fun", "rails", "ruby"
0
- # "b'log" "emacs fun" "rails" "ruby" => "b'log", "emacs fun", "rails", "ruby"
0
- # 'b\'log' 'emacs fun' 'rails' 'ruby' => "b'log", "emacs fun", "rails", "ruby"
0
- #
0
- list.scan(/((?: |)['"]{0,1})['"]?(.*?)(?:[,'"]|$)(?:\1(?: |$))/).collect{ |tag| tag.last }.uniq.delete_if{ |tag| tag == "" }
0
- # the old version for legacy comparison.
0
- #list.split(',').collect! { |s| s.gsub(/[^\w\ ]+/, '').downcase.strip }.delete_if { |s| s.blank? }
0
+ returning list.scan(/((?: |)['"]{0,1})['"]?(.*?)(?:[,'"]|$)(?:\1(?: |$))/) do |tags|
0
+ tags.collect! &:last
0
+ tags.uniq!
0
+ tags.delete_if &:blank?
0
+ end
0
     end
0
 
0
     # Parses comma separated tag list and returns tags for them.

Comments

    No one has commented yet.