mirror of
https://github.com/elastic/logstash.git
synced 2025-04-23 22:27:21 -04:00
- Start using haml.
This commit is contained in:
parent
49af98b731
commit
8fd6ca9422
7 changed files with 57 additions and 8 deletions
|
@ -10,34 +10,51 @@ require "sinatra/async"
|
|||
#require "haml"
|
||||
require "erb"
|
||||
require "ap"
|
||||
#require"sass/plugin/rack"
|
||||
|
||||
class EventMachine::ConnectionError < RuntimeError; end
|
||||
|
||||
class LogStashWeb < Sinatra::Base
|
||||
register Sinatra::Async
|
||||
set :haml, :format => :html5
|
||||
set :logging, true
|
||||
|
||||
aget '/style.css' do
|
||||
headers "Content-Type" => "text/css; charset=utf8"
|
||||
body sass :style
|
||||
end
|
||||
|
||||
aget '/' do
|
||||
body haml :"main/index"
|
||||
end # '/'
|
||||
|
||||
aget '/search' do
|
||||
http = EventMachine::HttpRequest.new("http://localhost:9200/_search")
|
||||
esreq = {
|
||||
"sort" => [
|
||||
{ "received_timestamp" => "desc" }
|
||||
],
|
||||
"query" => {
|
||||
"query_string" => {
|
||||
"query" => params[:q]
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
req = http.get :body => esreq.to_json
|
||||
req.callback do
|
||||
headers req.response_header
|
||||
data = JSON.parse(req.response)
|
||||
@hits = data["hits"]["hits"]
|
||||
body erb :search
|
||||
p data
|
||||
@hits = data["hits"]["hits"] rescue []
|
||||
body haml :"search/results"
|
||||
end
|
||||
req.errback do
|
||||
body "Failed."
|
||||
end
|
||||
end
|
||||
end # '/search'
|
||||
end
|
||||
|
||||
#Sass::Plugin::Rack.new( \
|
||||
Rack::Handler::Thin.run(
|
||||
Rack::CommonLogger.new( \
|
||||
Rack::ShowExceptions.new( \
|
||||
|
|
4
web/views/header.haml
Normal file
4
web/views/header.haml
Normal file
|
@ -0,0 +1,4 @@
|
|||
.logo
|
||||
logstash
|
||||
|
||||
|
11
web/views/layout.haml
Normal file
11
web/views/layout.haml
Normal file
|
@ -0,0 +1,11 @@
|
|||
!!! 5
|
||||
%html
|
||||
%head
|
||||
%title= @title || "Default title"
|
||||
%link{ :rel => "stylesheet", :href => "/style.css", :type => "text/css" }
|
||||
%body
|
||||
#header
|
||||
=haml :header, :layout => false
|
||||
#content
|
||||
=yield
|
||||
#footer
|
5
web/views/main/index.haml
Normal file
5
web/views/main/index.haml
Normal file
|
@ -0,0 +1,5 @@
|
|||
%form.search{ :action => "/search" }
|
||||
%label{ :for => "q" }
|
||||
%input.query{ :type => "text", :name => "q" }
|
||||
%input{ :type => "submit" }
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
<% @hits.each do |hit| %>
|
||||
<%= hit["_source"].inspect %>
|
||||
<p>
|
||||
<% end %>
|
3
web/views/search/results.haml
Normal file
3
web/views/search/results.haml
Normal file
|
@ -0,0 +1,3 @@
|
|||
- @hits.each do |hit|
|
||||
%pre
|
||||
= hit["_source"].inspect
|
13
web/views/style.sass
Normal file
13
web/views/style.sass
Normal file
|
@ -0,0 +1,13 @@
|
|||
body
|
||||
margin: 0
|
||||
padding: 0
|
||||
#header
|
||||
border-top: 4px solid black
|
||||
border-bottom: 1px solid black
|
||||
background-color: lightgreen
|
||||
padding-left: 1em
|
||||
width: 100%
|
||||
|
||||
.logo
|
||||
font-size: 130%
|
||||
font-weight: bold
|
Loading…
Add table
Add a link
Reference in a new issue