Show last 30 papers on homepage

This commit is contained in:
Andreas Haller 2015-04-27 22:35:11 +02:00
parent 973af9f0d9
commit f71c083722
3 changed files with 19 additions and 16 deletions

View file

@ -1,8 +1,11 @@
class SearchController < ApplicationController class SearchController < ApplicationController
def index def index
@result = if params[:q].present? @show_search_result = params[:q].present?
@papers = if @show_search_result
# TODO: Add pagination # TODO: Add pagination
Paper.search(params[:q]).records Paper.search(params[:q]).records
else
Paper.last(30)
end end
end end
end end

View file

@ -0,0 +1,2 @@
= form_tag(search_path, method: :get)
= text_field_tag(:q, params[:q], placeholder: 'Suche…', autofocus: true)

View file

@ -1,22 +1,20 @@
div div
= form_tag(search_path, method: :get) = render 'search/form'
= text_field_tag(:q, params[:q], placeholder: 'Suche…', autofocus: true)
.clearfix .clearfix
- if @result - if @show_search_result
.left .left
| #{@result.size} Treffer | #{@papers.size} Treffer
.right .right
button.button. TODO: Suche Abbonieren button.button. TODO: Suche Abbonieren
div div
- if @result ul.no-bullet
ul.no-bullet - @papers.each do |doc|
- @result.each do |doc| li.search-result
li.search-result small = doc.paper_type
small = doc.paper_type '
' small = doc.originator
small = doc.originator '
' small = doc.published_at
small = doc.published_at = link_to doc.url, target: '_blank' do
= link_to doc.url, target: '_blank' do div = doc.name
div = doc.name