Posted Mon, 14 Nov 2005
I revisted my tagsearch implementation this evening and realized I could make it both much simpler and much more powerful. I now support queries with mixed and/or syntax. "and" has higher precedence - so:
http://www.timfanelli.com/tags/python/folksonomy+ruby/blosxonomy
Will return all posts the are tagged ( "python" and "folksonomy" ) or ( "ruby" and "blosxonomy" )
This is accomplished by taking the request string that matches /^\/tags/(.*)/ and splitting it
first on +. I then take each element in the resulting array, split on / and find entries
that match all the tags. The results are appended together to build the final response.
This is all accomplished in a few simple lines:
m = Regexp::compile( config['tags_path'] + "/(.*)", Regexp::IGNORECASE ).match( pathinfo )
if m
ortags = m[1].split('+')
ortags.each { |andtags| app['entries'] |= fel.getEntriesWithAllTags( andtags.split('/') ) }
end
Where fel is my File Entry Locator. I envision this changing a little bit when I design the
SQL Entry Locator, and supporting queries directly in the locator API.
Again, this feature will be released with Blosxonomy 0.6.
add to del.icio.us



