Re-namespacing a bit to clear out some fairly old stuff from the top level

This commit is contained in:
Dan Buch
2013-01-22 19:10:10 -05:00
parent ab43fb0146
commit 92f7543872
485 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
end

View File

@@ -0,0 +1,30 @@
module SolrHelper
$select_url = 'http://localhost:8983/solr/select/'
$redis = '/home/me/repos/redis.git/src/redis-cli'
def get_results(search)
cached = `#{$redis} GET "query:#{search}"`
if cached.strip().length > 0
# puts "cached=#{cached}"
xml_results = REXML::Document.new cached
else
raw_results = open("#{$select_url}?q=#{search}").read
# puts "caching '#{raw_results}'"
`#{$redis} SET "query:#{search}" '#{raw_results}'`
xml_results = REXML::Document.new raw_results
end
results = []
REXML::XPath.each(xml_results, '//result/doc') do |doc|
results.push({
:id => doc.elements['./str[@name="id"]'],
:description => doc.elements['./str[@name="name"]']
})
end
return results
end
end