whoops 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/controllers/events_controller.rb +10 -1
- data/app/models/whoops/event.rb +6 -6
- data/app/models/whoops/search_parser.rb +40 -0
- data/app/views/event_groups/index.html.haml +0 -1
- data/app/views/events/index.html.haml +18 -6
- data/app/views/layouts/whoops.html.haml +2 -2
- data/lib/generators/whoops/templates/assets/javascripts/{application.js → whoops.js} +1 -1
- data/lib/generators/whoops/templates/assets/stylesheets/sass/screen.scss +24 -15
- metadata +6 -5
@@ -3,10 +3,19 @@ class EventsController < ApplicationController
|
|
3
3
|
|
4
4
|
def index
|
5
5
|
@event_group = Whoops::EventGroup.find(params[:whoops_event_group_id])
|
6
|
-
|
6
|
+
|
7
|
+
events_base = @event_group.events
|
8
|
+
unless params[:query].blank?
|
9
|
+
conditions = Whoops::SearchParser.new(params[:query]).mongoid_conditions
|
10
|
+
events_base = events_base.where(conditions)
|
11
|
+
end
|
12
|
+
|
13
|
+
@events = events_base.desc(:event_time).paginate(
|
7
14
|
:page => params[:page],
|
8
15
|
:per_page => 20
|
9
16
|
)
|
17
|
+
|
18
|
+
puts 'test'
|
10
19
|
end
|
11
20
|
|
12
21
|
def show
|
data/app/models/whoops/event.rb
CHANGED
@@ -18,15 +18,15 @@ class Whoops::Event
|
|
18
18
|
event_group_params[:last_recorded_at] = params[:event_time]
|
19
19
|
|
20
20
|
event_group = Whoops::EventGroup.first(:conditions => event_group_params.slice(*Whoops::EventGroup.identifying_fields))
|
21
|
-
|
22
|
-
event_group.attributes = event_group_params
|
23
|
-
event_group.save
|
24
|
-
else
|
25
|
-
event_group = Whoops::EventGroup.create(event_group_params)
|
26
|
-
end
|
21
|
+
event_group ||= Whoops::EventGroup.create(event_group_params)
|
27
22
|
|
28
23
|
event_params = params.slice(*Whoops::Event.field_names)
|
29
24
|
event_group.events.create(event_params)
|
30
25
|
end
|
31
26
|
|
27
|
+
def self.search(query)
|
28
|
+
conditions = Whoops::SearchParser.new(query).mongoid_conditions
|
29
|
+
where(conditions)
|
30
|
+
end
|
31
|
+
|
32
32
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
class Whoops::SearchParser
|
2
|
+
attr_accessor :query
|
3
|
+
def initialize(query)
|
4
|
+
self.query = query
|
5
|
+
end
|
6
|
+
|
7
|
+
def mongoid_conditions
|
8
|
+
self.query.split("\n").inject({}) do |conditions, line|
|
9
|
+
line.strip!
|
10
|
+
next(conditions) if line.empty?
|
11
|
+
|
12
|
+
parsed = parse_line(line)
|
13
|
+
key = parsed[:method] ? parsed[:key].send(parsed[:method]) : parsed[:key]
|
14
|
+
|
15
|
+
conditions[key] = parsed[:value]
|
16
|
+
conditions
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def parse_line(line)
|
21
|
+
key, method, value = line.match(/([^\s]*?)(#[^\s]*)? ([^#]*)/)[1..3]
|
22
|
+
|
23
|
+
key = key.sub(/:$/, '').to_sym
|
24
|
+
method = method.gsub(/(^#|:$)/, '').to_sym if method
|
25
|
+
value = parse_value(value)
|
26
|
+
{
|
27
|
+
:key => key,
|
28
|
+
:method => method,
|
29
|
+
:value => value
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Allows user to enter hashes or array
|
34
|
+
def parse_value(value)
|
35
|
+
value = value.strip
|
36
|
+
# value = "!ruby/regexp \"#{value}\"" if value =~ /^\/.*\/$/
|
37
|
+
value.gsub!(/\/.*?\//, %Q{!ruby/regexp "\\0"})
|
38
|
+
return YAML.load(value)
|
39
|
+
end
|
40
|
+
end
|
@@ -2,11 +2,20 @@
|
|
2
2
|
= breadcrumbs(["Event Details", whoops_event_group_path(@event_group)])
|
3
3
|
|
4
4
|
- content_for :sidebar do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
.space
|
6
|
+
%h3 Instances
|
7
|
+
= will_paginate @event, :previous_label => "", :next_label => ""
|
8
|
+
%ul#instances
|
9
|
+
- @events.each_with_index do |event, index|
|
10
|
+
%li{:class => ("selected" if index == 0)}= link_to event.event_time.to_s(:whoops_default), event
|
11
|
+
.space
|
12
|
+
%h3 Search
|
13
|
+
%form
|
14
|
+
%ul
|
15
|
+
%li= text_area_tag :query, params[:query]
|
16
|
+
%li
|
17
|
+
%button search
|
18
|
+
%button reset
|
10
19
|
|
11
20
|
%article.module.width_full
|
12
21
|
%header
|
@@ -21,5 +30,8 @@
|
|
21
30
|
%header
|
22
31
|
%h3 Details
|
23
32
|
#event-details
|
24
|
-
|
33
|
+
- if @events.empty?
|
34
|
+
%p Your search returned no results.
|
35
|
+
- else
|
36
|
+
= render :partial => "events/details", :object => @events.first, :as => :event
|
25
37
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
/[if IE]
|
7
7
|
= stylesheet_link_tag 'ie.css', :media => 'screen, projection'
|
8
8
|
|
9
|
-
= javascript_include_tag 'jquery-1.5.2.min', 'jquery.equalHeight', 'jquery.tablesorter.min', '
|
9
|
+
= javascript_include_tag 'jquery-1.5.2.min', 'jquery.equalHeight', 'jquery.tablesorter.min', 'whoops.js'
|
10
10
|
= yield :extra_javascripts
|
11
11
|
= csrf_meta_tag
|
12
12
|
%body
|
@@ -21,7 +21,7 @@
|
|
21
21
|
.user
|
22
22
|
.breadcrumbs_container
|
23
23
|
%article.breadcrumbs
|
24
|
-
= link_to "
|
24
|
+
= link_to "Event List", whoops_event_groups_path, :class => ("current" if controller_name == 'event_groups')
|
25
25
|
= yield :breadcrumbs
|
26
26
|
/ end of secondary bar
|
27
27
|
%aside#sidebar.column
|
@@ -169,23 +169,25 @@ height: 24px;
|
|
169
169
|
line-height: 23px;
|
170
170
|
}
|
171
171
|
|
172
|
-
.breadcrumbs a.current, .breadcrumbs a.current:hover {
|
173
|
-
color: #9E9E9E;
|
174
|
-
font-weight: bold;
|
175
|
-
text-shadow: 0 1px 0 #fff;
|
176
|
-
text-decoration: none;
|
177
|
-
}
|
178
|
-
|
179
172
|
.breadcrumbs a:link, .breadcrumbs a:visited {
|
180
|
-
color: #44474F;
|
181
|
-
text-decoration: none;
|
182
|
-
text-shadow: 0 1px 0 #fff;
|
183
|
-
font-weight: bold;
|
173
|
+
color: #44474F;
|
174
|
+
text-decoration: none;
|
175
|
+
text-shadow: 0 1px 0 #fff;
|
176
|
+
font-weight: bold;
|
177
|
+
}
|
184
178
|
|
185
179
|
.breadcrumbs a:hover {
|
186
|
-
color: #222222;
|
180
|
+
color: #222222;
|
187
181
|
}
|
188
182
|
|
183
|
+
.breadcrumbs a.current, .breadcrumbs a:link.current, .breadcrumbs a.current:hover {
|
184
|
+
color: #9E9E9E;
|
185
|
+
font-weight: bold;
|
186
|
+
text-shadow: 0 1px 0 #fff;
|
187
|
+
text-decoration: none;
|
188
|
+
}
|
189
|
+
|
190
|
+
|
189
191
|
.breadcrumb_divider {
|
190
192
|
display: inline-block;
|
191
193
|
width: 12px;
|
@@ -311,9 +313,16 @@ text-decoration: none;
|
|
311
313
|
}
|
312
314
|
}
|
313
315
|
|
314
|
-
form
|
315
|
-
|
316
|
-
|
316
|
+
form {
|
317
|
+
li {
|
318
|
+
list-style:none;
|
319
|
+
padding:0 15px 0 0;
|
320
|
+
}
|
321
|
+
|
322
|
+
textarea {
|
323
|
+
height:100px;
|
324
|
+
width:100%;
|
325
|
+
}
|
317
326
|
}
|
318
327
|
}
|
319
328
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel Higginbotham
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- app/models/whoops/event.rb
|
255
255
|
- app/models/whoops/event_group.rb
|
256
256
|
- app/models/whoops/filter.rb
|
257
|
+
- app/models/whoops/search_parser.rb
|
257
258
|
- app/views/event_groups/_list.html.haml
|
258
259
|
- app/views/event_groups/index.html.haml
|
259
260
|
- app/views/events/_detail.html.haml
|
@@ -298,13 +299,13 @@ files:
|
|
298
299
|
- lib/generators/whoops/templates/assets/images/_ui/sidebar_divider.png
|
299
300
|
- lib/generators/whoops/templates/assets/images/_ui/sidebar_shadow.png
|
300
301
|
- lib/generators/whoops/templates/assets/images/_ui/table_sorter_header.png
|
301
|
-
- lib/generators/whoops/templates/assets/javascripts/application.js
|
302
302
|
- lib/generators/whoops/templates/assets/javascripts/hideshow.js
|
303
303
|
- lib/generators/whoops/templates/assets/javascripts/jquery-1.5.2.min.js
|
304
304
|
- lib/generators/whoops/templates/assets/javascripts/jquery.equalHeight.js
|
305
305
|
- lib/generators/whoops/templates/assets/javascripts/jquery.form.js
|
306
306
|
- lib/generators/whoops/templates/assets/javascripts/jquery.tablesorter.min.js
|
307
307
|
- lib/generators/whoops/templates/assets/javascripts/ui.js
|
308
|
+
- lib/generators/whoops/templates/assets/javascripts/whoops.js
|
308
309
|
- lib/generators/whoops/templates/assets/stylesheets/ie.css
|
309
310
|
- lib/generators/whoops/templates/assets/stylesheets/sass/_base.scss
|
310
311
|
- lib/generators/whoops/templates/assets/stylesheets/sass/ie.scss
|