diff --git a/app/controllers/municipios_controller.rb b/app/controllers/municipios_controller.rb index 316e95e..c82e4de 100644 --- a/app/controllers/municipios_controller.rb +++ b/app/controllers/municipios_controller.rb @@ -9,27 +9,17 @@ def show end + def cities_by_query + search_by_query + end + def search - q = params[:q] - - @results = Municipio.search(q) - - meta :title => "Resultados de la búsqueda '#{q}' - lospresus.de", - :description => "Resultados de la búsqueda '#{q}' en lospresus.de", - :keywords => "presupuestos, ayuntamientos, gastos, ingresos, subvenciones, municipios, municipal, dinero público, gasto público" - + search_by_query(:limit => 10) render :layout => false end def search_for_compare - q = params[:q] - - @results = Municipio.search(q) - - meta :title => "Resultados de la búsqueda '#{q}' - lospresus.de", - :description => "Resultados de la búsqueda '#{q}' en lospresus.de", - :keywords => "presupuestos, ayuntamientos, gastos, ingresos, subvenciones, municipios, municipal, dinero público, gasto público" - + search_by_query(:limit => 10) render :layout => false end @@ -57,4 +47,14 @@ def find_muni def year_context @year = params[:year] || Date.today.year - 1 end + def search_by_query(options={}) + q = params[:q] + + @results = Municipio.search(q, options) + + meta :title => "Resultados de la búsqueda '#{q}' - lospresus.de", + :description => "Resultados de la búsqueda '#{q}' en lospresus.de", + :keywords => "presupuestos, ayuntamientos, gastos, ingresos, subvenciones, municipios, municipal, dinero público, gasto público" + + end end \ No newline at end of file diff --git a/app/models/municipio.rb b/app/models/municipio.rb index 6e50687..da00f4e 100644 --- a/app/models/municipio.rb +++ b/app/models/municipio.rb @@ -29,8 +29,8 @@ def demographics_for(year) def budget_for(year) presupuestos.for_year(year).first end - def self.search(query) - Municipio.find(:all, :conditions => ['nombre LIKE ?', "%#{query}%"], :limit => 10) + def self.search(query, options) + Municipio.find(:all, options.merge(:conditions => ['nombre LIKE ?', "%#{query}%"])) end def to_param diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb index 469d25b..9607ca0 100644 --- a/app/views/home/index.html.erb +++ b/app/views/home/index.html.erb @@ -1,5 +1,5 @@ - \ No newline at end of file +<% end %> \ No newline at end of file diff --git a/app/views/municipios/cities_by_query.html.erb b/app/views/municipios/cities_by_query.html.erb new file mode 100644 index 0000000..5ae738f --- /dev/null +++ b/app/views/municipios/cities_by_query.html.erb @@ -0,0 +1,16 @@ +<% content_for :header_title do %> + LO QUE BUSCAS +<% end %> + + +<% unless @results.blank? %> + +<% else %> + +<% end %> diff --git a/app/views/shared/_header.html.erb b/app/views/shared/_header.html.erb index c8c2137..07afca6 100644 --- a/app/views/shared/_header.html.erb +++ b/app/views/shared/_header.html.erb @@ -4,11 +4,13 @@

Los presupuestos de <%= yield :header_title %>

Las cosas claras y el chocolate espeso

- -
- - - -
+ + <% form_tag(cities_by_query_path, {:method => :get}) do %> +
+ + + +
+ <% end %> \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 3c5476e..8736023 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,6 +8,7 @@ map.with_options(:controller => 'municipios') do |muni| muni.city_search '/search', :action => 'search' + muni.cities_by_query '/municipios', :action => 'cities_by_query' muni.city_card '/:id', :action => 'show' muni.city_search_for_compare '/:id/search_for_compare', :action => 'search_for_compare' muni.city_evolution '/:id/evolucion', :action => 'evolution' diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 4e6498b..b419ab6 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -47,7 +47,7 @@ $(document).ready(function () { $('#budget_timeline').jcarousel({ // Configuration goes here - scroll: 3, + scroll: 6, start: 1, initCallback: budget_timeline_callback, buttonNextHTML: null,