mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
Query ES, show results
This commit is contained in:
parent
7cd9f207f5
commit
2abba45f4c
8 changed files with 44 additions and 12 deletions
4
Gemfile
4
Gemfile
|
@ -14,12 +14,10 @@ gem 'coffee-rails', '~> 4.0.0'
|
|||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
# gem 'therubyracer', platforms: :ruby
|
||||
gem 'slim-rails'
|
||||
|
||||
# Use jquery as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||
gem 'turbolinks'
|
||||
|
||||
# Assets
|
||||
gem 'foundation-rails'
|
||||
|
||||
|
@ -27,6 +25,8 @@ gem 'foundation-rails'
|
|||
gem 'omniauth'
|
||||
gem 'omniauth-browserid'
|
||||
|
||||
gem 'elasticsearch'
|
||||
|
||||
# bundle exec rake doc:rails generates the API under doc/api.
|
||||
gem 'sdoc', '~> 0.4.0', group: :doc
|
||||
|
||||
|
|
|
@ -44,6 +44,14 @@ GEM
|
|||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.8.0)
|
||||
elasticsearch (1.0.6)
|
||||
elasticsearch-api (= 1.0.6)
|
||||
elasticsearch-transport (= 1.0.6)
|
||||
elasticsearch-api (1.0.6)
|
||||
multi_json
|
||||
elasticsearch-transport (1.0.6)
|
||||
faraday
|
||||
multi_json
|
||||
erubis (2.7.0)
|
||||
execjs (2.2.2)
|
||||
faraday (0.9.0)
|
||||
|
@ -151,6 +159,7 @@ PLATFORMS
|
|||
DEPENDENCIES
|
||||
capybara
|
||||
coffee-rails (~> 4.0.0)
|
||||
elasticsearch
|
||||
foundation-rails
|
||||
jquery-rails
|
||||
launchy
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
||||
* file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
|
||||
*= require_self
|
||||
*= require foundation_and_overrides
|
||||
|
||||
*/
|
||||
|
||||
@import 'foundation_and_overrides';
|
||||
@import 'objects/search-result';
|
3
app/assets/stylesheets/objects/_search-result.scss
Normal file
3
app/assets/stylesheets/objects/_search-result.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
.search-result {
|
||||
border-bottom: 1px solid $table-border-color;
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
// Place all the styles related to the sessions controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -1,4 +1,8 @@
|
|||
class SearchController < ApplicationController
|
||||
def index
|
||||
@result = if params[:q].present?
|
||||
es = Elasticsearch::Client.new
|
||||
es.search index: 'loris', q: params[:q]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,8 +12,8 @@ body
|
|||
= content_tag :div, msg, class: name
|
||||
.row
|
||||
.large-8.columns
|
||||
h2#title
|
||||
= link_to 'Willkommen in Leipzig', root_path
|
||||
h1#title
|
||||
= link_to 'Stadtratmonitor Leipzig', root_path
|
||||
.large-4.columns
|
||||
ul.inline-list.right
|
||||
li = render 'login_button'
|
||||
|
|
|
@ -1,4 +1,21 @@
|
|||
= form_tag(search_path, method: :get)
|
||||
= label_tag(:q, 'Suche:')
|
||||
= text_field_tag(:q)
|
||||
= submit_tag 'Suchen', class: 'button'
|
||||
= text_field_tag(:q, params[:q], placeholder: 'Suche…')
|
||||
|
||||
.row
|
||||
- if @result
|
||||
.small-9.columns
|
||||
| #{@result['hits']['total']} Treffer
|
||||
.small-3.columns
|
||||
button.button.right TODO: Suche Abbonieren
|
||||
|
||||
- if @result
|
||||
ul.no-bullet
|
||||
- @result['hits']['hits'].each do |doc|
|
||||
li.search-result
|
||||
small = doc['_source']['paperType']
|
||||
'
|
||||
small = doc['_source']['originator'].join(', ')
|
||||
'
|
||||
small = doc['_source']['publishedDate']
|
||||
= link_to "https://ratsinfo.leipzig.de/bi/#{doc['_source']['mainFile']}", target: '_blank' do
|
||||
div = doc['_source']['name']
|
||||
|
|
Loading…
Reference in a new issue