Apache Solr open-source search software
handy rake addition to list routes
Erik Hatchercb0cb9359e7d
diff --git a/client/ruby/flare/app/controllers/browse_controller.rb b/client/ruby/flare/app/controllers/browse_controller.rbindex c8779aae217..ab8c14d17c0 100644--- a/client/ruby/flare/app/controllers/browse_controller.rb+++ b/client/ruby/flare/app/controllers/browse_controller.rb@@ -78,7 +78,7 @@ class BrowseController < ApplicationControllerreq = Solr::Request::Standard.new(:query => query,:filter_queries => filters,:facets => {:fields => [field],- :mincount => 1, :limit => limit, :prefix => prefix+ :mincount => 1, :limit => limit, :prefix => prefix, :missing => true, :sort => :count},:rows => 0)diff --git a/client/ruby/flare/app/controllers/sparklines_controller.rb b/client/ruby/flare/app/controllers/sparklines_controller.rbnew file mode 100644index 00000000000..1c69f290525--- /dev/null+++ b/client/ruby/flare/app/controllers/sparklines_controller.rb@@ -0,0 +1,40 @@+class SparklinesController < ApplicationController++ # Handles requests for sparkline graphs from views.+ #+ # Params are generated by the sparkline_tag helper method.+ #+ def index+ # Make array from comma-delimited list of data values+ ary = []+ if params.has_key?('results') && !params['results'].nil?+ params['results'].split(',').each do |s|+ ary << s.to_i+ end+ end++ send_data( Sparklines.plot( ary, params ),+ :disposition => 'inline',+ :type => 'image/png',+ :filename => "spark_#{params[:type]}.png" )+ end+++ # Use this type of method for sparklines that can be cached. (Doesn't work with the helper.)+ #+ # To make caching easier, add a line like this to config/routes.rb:+ # map.sparklines "sparklines/:action/:id/image.png", :controller => "sparklines"+ #+ # Then reference it with the named route:+ # image_tag sparklines_url(:action => 'show', :id => 42)+ def show+ send_data(Sparklines.plot(+ [42, 37, 89, 74, 70, 50, 40, 30, 40, 50],+ :type => 'bar', :above_color => 'orange'+ ),+ :disposition => 'inline',+ :type => 'image/png',+ :filename => "sparkline.png")+ end++enddiff --git a/client/ruby/flare/app/views/browse/facet.rhtml b/client/ruby/flare/app/views/browse/facet.rhtmlindex 782981c9d95..16b53579aee 100755--- a/client/ruby/flare/app/views/browse/facet.rhtml+++ b/client/ruby/flare/app/views/browse/facet.rhtml@@ -1,3 +1,3 @@-<% @facets.each do |value,count| %>- <%= link_to value, :action => 'add_filter', :field_name => params[:field_name], :value => value %> (<%=count%>)+<% @facets.each do |f| %>+ <%= link_to (f.name ? f.name : '#### NO VALUE ###'), :action => 'add_filter', :field_name => params[:field_name], :value => f.name %> (<%=f.value%>)<% end%>\ No newline at end of filediff --git a/client/ruby/flare/app/views/browse/index.rhtml b/client/ruby/flare/app/views/browse/index.rhtmlindex 0b0f104b608..ac7a76f0bed 100644--- a/client/ruby/flare/app/views/browse/index.rhtml+++ b/client/ruby/flare/app/views/browse/index.rhtml@@ -8,13 +8,16 @@<% @facet_fields.each do |field|%><h4><%=link_to field, :action => 'facet', :field_name => field%></h4><ul>- <% @response.field_facets(field).each do |k,v| %>- <li><%= link_to "#{k} (#{v})", :action => 'add_filter', :field_name=>field, :value=>k%></li>+ <% @response.field_facets(field).each do |f| %>+ <li>+ <%= sparkline_tag [(f.value * 100.0 / @response.total_hits).ceil], :type => 'pie', :diameter => 20, :share_color => 'blue'%>+ <%= link_to "#{f.name} (#{f.value})", :action => 'add_filter', :field_name=>field, :value=>f.name%>+ </li><% end %></ul><% end %>-</div>-</div>+<%=link_to image_tag("simile-exhibit.png"), :controller => :simile, :action => :exhibit %>+</div></div><div>Queries:@@ -52,6 +55,7 @@ Filters:+<!-- <h3>index info</h3><%=debug @info %><h3>search/facet response header</h3><%=debug @response.data['responseHeader']%> -->diff --git a/client/ruby/flare/lib/tasks/routes.rake b/client/ruby/flare/lib/tasks/routes.rakenew file mode 100755index 00000000000..3fecf372f25--- /dev/null+++ b/client/ruby/flare/lib/tasks/routes.rake@@ -0,0 +1,22 @@+# The ASF licenses this file to You under the Apache License, Version 2.0+# (the "License"); you may not use this file except in compliance with+# the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++# Borrowed from <http://pastie.caboo.se/23100>, by Josh Susser+desc "Print out all the currently defined routes, with names."+task :routes => :environment do+ name_col_width = ActionController::Routing::Routes.named_routes.routes.keys.sort {|a,b| a.to_s.size <=> b.to_s.size}.last.to_s.size+ ActionController::Routing::Routes.routes.each do |route|+ name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s+ name = name.ljust(name_col_width + 1)+ puts "#{name}#{route}"+ end+end\ No newline at end of file