joshuaclayton-watchtower 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/Manifest +66 -0
- data/README.textile +34 -0
- data/Rakefile +35 -0
- data/app/controllers/watchtower_controller.rb +3 -0
- data/app/helpers/watchtower_helper.rb +27 -0
- data/app/models/watched_exception.rb +3 -0
- data/app/views/layouts/watchtower.erb +34 -0
- data/app/views/watchtower/_recordset.erb +10 -0
- data/app/views/watchtower/destroy.js.rjs +0 -0
- data/app/views/watchtower/destroy_multiple.js.rjs +6 -0
- data/app/views/watchtower/index.html.erb +59 -0
- data/app/views/watchtower/index.js.rjs +2 -0
- data/app/views/watchtower/show.html.erb +26 -0
- data/config/routes.rb +3 -0
- data/generators/watchtower/USAGE +1 -0
- data/generators/watchtower/templates/README +26 -0
- data/generators/watchtower/templates/migrations/create_watched_exceptions.rb +20 -0
- data/generators/watchtower/watchtower_generator.rb +12 -0
- data/generators/watchtower_assets/USAGE +1 -0
- data/generators/watchtower_assets/templates/public/javascripts/watchtower/jquery-1.3.2.min.js +19 -0
- data/generators/watchtower_assets/templates/public/javascripts/watchtower/jquery-ui-1.7.1.custom.min.js +160 -0
- data/generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.bindings.js +50 -0
- data/generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.events.js +102 -0
- data/generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.js +65 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/admin.css +60 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/ajax-loader.gif +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/bullet-black.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/buttons/sprite-gray.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/buttons/x.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign-red.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign-sm.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/edit-template.gif +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/success-badge.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/nav-admin-shadow.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/extras.css +86 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/forms.css +312 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/ie.css +31 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_222222_256x240.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_2e83ff_256x240.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_454545_256x240.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_888888_256x240.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/jquery-ui-1.7.1.custom.css +404 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/reset.css +235 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/screen.css +208 -0
- data/generators/watchtower_assets/templates/public/stylesheets/watchtower/watchtower.css +56 -0
- data/generators/watchtower_assets/watchtower_assets_generator.rb +19 -0
- data/lib/watchtower/application_controller_base.rb +40 -0
- data/lib/watchtower/controller_base.rb +54 -0
- data/lib/watchtower/watched_exception_base.rb +84 -0
- data/lib/watchtower/watched_exceptions_presenter.rb +23 -0
- data/lib/watchtower.rb +5 -0
- data/rails/init.rb +2 -0
- data/tasks/watchtower_tasks.rake +0 -0
- data/test/test_helper.rb +3 -0
- data/watchtower.gemspec +38 -0
- metadata +154 -0
@@ -0,0 +1,208 @@
|
|
1
|
+
/** =screen.css
|
2
|
+
************************************************************
|
3
|
+
@project Easel
|
4
|
+
@colordef #222222; dark gray (body copy)
|
5
|
+
************************************************************/
|
6
|
+
|
7
|
+
/** =fonts
|
8
|
+
************************************************************
|
9
|
+
@see http://unitinteractive.com/blog/2008/06/26/better-css-font-stacks/
|
10
|
+
@see http://www.sitepoint.com/article/eight-definitive-font-stacks/
|
11
|
+
@see http://stevecochrane.com/v3/2007/12/13/helvetica-neue-variants-for-use-on-the-web/
|
12
|
+
************************************************************/
|
13
|
+
body,
|
14
|
+
input, button, textarea {
|
15
|
+
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
|
16
|
+
letter-spacing: .025em;
|
17
|
+
}
|
18
|
+
pre,code,kbd,tt,samp {
|
19
|
+
font-family: "Andale Mono","Courier New",Courier,monospace;
|
20
|
+
}
|
21
|
+
|
22
|
+
/** =image replacement
|
23
|
+
************************************************************/
|
24
|
+
.replace {
|
25
|
+
text-indent: -999em; display: block; font-size: 0; overflow: hidden;
|
26
|
+
}
|
27
|
+
|
28
|
+
/** =site specific baseline
|
29
|
+
************************************************************/
|
30
|
+
body {
|
31
|
+
font-size: 12px;
|
32
|
+
line-height: 1.5; /* 18px */
|
33
|
+
color: #222;
|
34
|
+
}
|
35
|
+
|
36
|
+
/* =lists */
|
37
|
+
ol li { list-style: decimal; }
|
38
|
+
ul li { list-style: none; }
|
39
|
+
dt { font-weight: bold; }
|
40
|
+
ul li {
|
41
|
+
background: url(assets/images/bullet-black.png) no-repeat 0 .5em;
|
42
|
+
padding-left: .75em;
|
43
|
+
}
|
44
|
+
dt { font-weight: bold; }
|
45
|
+
dd { margin-bottom: .75em; }
|
46
|
+
|
47
|
+
/* =margins */
|
48
|
+
p, table, form, pre, ul, ol, dl, address, .box { margin-bottom: 1.5em; }
|
49
|
+
ul, ol { margin-top: 1.5em; }
|
50
|
+
ol, pre { margin-left: 1.5em; }
|
51
|
+
li { margin-bottom: .75em; line-height: 1.25; }
|
52
|
+
li ol, li ul { margin-bottom: 0; margin-top: .75em; }
|
53
|
+
|
54
|
+
li p, blockquote p { margin-bottom: .75em; }
|
55
|
+
|
56
|
+
/* =blockquote */
|
57
|
+
blockquote {
|
58
|
+
font-style: italic;
|
59
|
+
margin: 1.5em;
|
60
|
+
}
|
61
|
+
blockquote em,
|
62
|
+
blockquote cite { font-style: normal; }
|
63
|
+
|
64
|
+
/* =tables */
|
65
|
+
table { width:100%; border-collapse:separate; border-spacing:0; }
|
66
|
+
th { font-weight: bold; }
|
67
|
+
th, td { padding: 4px 10px; text-align: left; }
|
68
|
+
tr.alt td,
|
69
|
+
tr.alt th { background: #F4F4F4; }
|
70
|
+
tfoot { font-style: italic; }
|
71
|
+
caption { font-weight: bold; }
|
72
|
+
|
73
|
+
/* =links */
|
74
|
+
a { text-decoration: none; color: #5ec2dd ; }
|
75
|
+
a:hover { background-color: #5ec2dd ; color: #fff; }
|
76
|
+
.biglink-hover * {
|
77
|
+
color: #5ec2dd ;
|
78
|
+
}
|
79
|
+
.biglink {
|
80
|
+
cursor: pointer;
|
81
|
+
}
|
82
|
+
|
83
|
+
/* =headings */
|
84
|
+
h1,h2,h3,h4,h5,h6 { margin-bottom: .75em; font-weight: bold; }
|
85
|
+
h1,h2,h3 { line-height: 1; }
|
86
|
+
h4,h5,h6 { line-height: 1.2; }
|
87
|
+
h1 { font-size: 30px; }
|
88
|
+
h2 { font-size: 24px; }
|
89
|
+
h3 { font-size: 18px; }
|
90
|
+
h4 { font-size: 16px; }
|
91
|
+
h5 { font-size: 14px; }
|
92
|
+
h6 { font-size: 12px; }
|
93
|
+
|
94
|
+
/** =common
|
95
|
+
************************************************************/
|
96
|
+
|
97
|
+
/* =block */
|
98
|
+
.block {
|
99
|
+
display: block;
|
100
|
+
margin-bottom: 1.5em;
|
101
|
+
}
|
102
|
+
a.block img {
|
103
|
+
display: block;
|
104
|
+
}
|
105
|
+
|
106
|
+
/* =inline images */
|
107
|
+
p img, p img.left, p a.img.left img, p .captioned { margin: .75em 1.25em .75em 0; float:left; display: inline; }
|
108
|
+
p img.right, p a.img.right img, p .captioned.right { margin: .75em 0 .75em 1.25em; }
|
109
|
+
p .top, p .top img { margin-top: 0 !important; }
|
110
|
+
|
111
|
+
/* =margins */
|
112
|
+
.no-margin { margin-bottom: 0; }
|
113
|
+
.half-margin { margin-bottom: .75em; }
|
114
|
+
.double-margin { margin-bottom: 3em; }
|
115
|
+
|
116
|
+
/* =ruled list */
|
117
|
+
.ruled li {
|
118
|
+
border-bottom: 1px solid #ccc;
|
119
|
+
background: none;
|
120
|
+
padding: 0 0 .66em; /* adjust for border pixel */
|
121
|
+
margin: 0 0 .75em;
|
122
|
+
}
|
123
|
+
.ruled {
|
124
|
+
border-top: 1px solid #ccc;
|
125
|
+
padding-top: .75em;
|
126
|
+
}
|
127
|
+
|
128
|
+
/* =image frame */
|
129
|
+
.framed,
|
130
|
+
a.framed img {
|
131
|
+
border: 2px solid #d9d5ca;
|
132
|
+
}
|
133
|
+
a.framed:hover img {
|
134
|
+
border-color: #5ec2dd;
|
135
|
+
}
|
136
|
+
|
137
|
+
/* =text */
|
138
|
+
.small { font-size: 11px; }
|
139
|
+
.large { font-size: 16px; }
|
140
|
+
.caps, .numbers { letter-spacing: 0.1em }
|
141
|
+
.note {
|
142
|
+
font-size: 11px;
|
143
|
+
font-weight: normal;
|
144
|
+
}
|
145
|
+
.intro {
|
146
|
+
color: #ccc;
|
147
|
+
font-size: 18px;
|
148
|
+
margin-bottom: 1em;
|
149
|
+
}
|
150
|
+
|
151
|
+
/* inline nav */
|
152
|
+
.inav li {
|
153
|
+
border-left: 1px solid #BBB;
|
154
|
+
margin-left: .75em;
|
155
|
+
padding-left: .66em;
|
156
|
+
}
|
157
|
+
.inav li:first-child,
|
158
|
+
.inav .li-1 {
|
159
|
+
padding-left: 0;
|
160
|
+
margin-left: 0;
|
161
|
+
border-left: 0;
|
162
|
+
}
|
163
|
+
|
164
|
+
/* =captioned images */
|
165
|
+
.captioned img,
|
166
|
+
.captioned .img,
|
167
|
+
.captioned .caption{
|
168
|
+
display: block;
|
169
|
+
}
|
170
|
+
.captioned .img{
|
171
|
+
background: #000;
|
172
|
+
}
|
173
|
+
.captioned img{
|
174
|
+
float: none;
|
175
|
+
margin: 0 auto;
|
176
|
+
}
|
177
|
+
.captioned .caption {
|
178
|
+
font-size: 11px;
|
179
|
+
text-align: right;
|
180
|
+
color: #999;
|
181
|
+
}
|
182
|
+
.captioned {
|
183
|
+
margin-bottom: .75em;
|
184
|
+
display: block;
|
185
|
+
}
|
186
|
+
|
187
|
+
/** =layout
|
188
|
+
************************************************************/
|
189
|
+
body { background: #fff; }
|
190
|
+
|
191
|
+
.container { margin: 0 auto; width: ; }
|
192
|
+
|
193
|
+
.header { }
|
194
|
+
.footer { }
|
195
|
+
.content { }
|
196
|
+
|
197
|
+
.content-main { }
|
198
|
+
.content-right { }
|
199
|
+
.content-left { }
|
200
|
+
|
201
|
+
/** =navigation
|
202
|
+
************************************************************/
|
203
|
+
|
204
|
+
/** =header
|
205
|
+
************************************************************/
|
206
|
+
|
207
|
+
/** =footer
|
208
|
+
************************************************************/
|
@@ -0,0 +1,56 @@
|
|
1
|
+
.container { width: 950px; margin: 1em auto; }
|
2
|
+
.header { position: relative; }
|
3
|
+
.header, .content-header { margin-bottom: 1em; padding-bottom: 1em; border-bottom: 5px solid #ddd; }
|
4
|
+
.footer { text-align: right; padding: 1em 0 0; border-top: 5px solid #ddd; color: #aaa; font-size: 1.25em; }
|
5
|
+
.loading-progress {
|
6
|
+
position: absolute;
|
7
|
+
bottom: .5em;
|
8
|
+
right: 0;
|
9
|
+
padding: .125em .5em .125em 1.5em;
|
10
|
+
font-size: 1.5em;
|
11
|
+
font-weight: bold;
|
12
|
+
color: #777;
|
13
|
+
border: 1px solid #ddd;
|
14
|
+
display: none;
|
15
|
+
background: #f3f3f3 url(assets/images/ajax-loader.gif) no-repeat .4em center;
|
16
|
+
}
|
17
|
+
.content-header h2 { margin-bottom: .5em; }
|
18
|
+
.content-header h3 { margin-bottom: 0; }
|
19
|
+
.header h1 { color: #555; font-size: 4em; margin-bottom: 0; }
|
20
|
+
.header h1 a { color: inherit; background: transparent; }
|
21
|
+
.header h1 a:hover { color: #777; }
|
22
|
+
|
23
|
+
.content h2 { font-size: 2.75em; color: #999; }
|
24
|
+
.content h3 { font-size: 1.75em; color: #aaa; font-style: italic; font-weight: normal; }
|
25
|
+
|
26
|
+
.content dt { text-transform: uppercase; font-size: 1.5em; color: #555; }
|
27
|
+
.content dd { padding: 0 2em; }
|
28
|
+
.content dd.bt { padding: 0; }
|
29
|
+
.content dd code { font-size: 1.2em; }
|
30
|
+
|
31
|
+
.content .backtrace pre { margin: 0; background: #444; color: #ddd; padding: 1em; }
|
32
|
+
|
33
|
+
.filter-exception_class li, .filter-controller_action li { font-size: 1.25em; }
|
34
|
+
.filter { margin-bottom: 1.5em; }
|
35
|
+
.filter .group { margin-bottom: .25em; padding-bottom: .25em; border-bottom: 1px solid #eee; }
|
36
|
+
.filter .group div { font-size: 1.25em; }
|
37
|
+
|
38
|
+
ul.watched-exceptions { padding-top: 0; margin-top: 1em; }
|
39
|
+
ul.watched-exceptions li { position: relative; margin-bottom: 0; padding: 1em; cursor: pointer; }
|
40
|
+
ul.watched-exceptions li.selected { background: #f6f6f6; }
|
41
|
+
ul.watched-exceptions li.selected .exception-timestamp { color: #bbb; }
|
42
|
+
ul.watched-exceptions li.selected .exception-message { color: #888; }
|
43
|
+
.exception-class { font-size: 1.75em; font-weight: normal; margin-bottom: .25em; }
|
44
|
+
.exception-message { font-size: 1.25em; color: #aaa; font-style: italic; }
|
45
|
+
.exception-timestamp { position: absolute; right: .25em; top: .0825em; font-size: 3.5em; color: #ddd; font-style: italic; }
|
46
|
+
|
47
|
+
.pagination { margin-bottom: 1.5em; }
|
48
|
+
.pagination a, .pagination span { border: 1px solid #ddd; padding: .25em .625em; }
|
49
|
+
.pagination span.gap { border: none; }
|
50
|
+
.pagination span.current { border-color: #fff; font-weight: bold; }
|
51
|
+
.pagination span.disabled { font-style: italic; color: #aaa; }
|
52
|
+
|
53
|
+
.btn span { text-shadow: #111 2px 1px 2px;}
|
54
|
+
|
55
|
+
.active-filter button.btn { background-position: 100% -100px; }
|
56
|
+
.active-filter button.btn span { background-position: 0 -150px; }
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class WatchtowerAssetsGenerator < Rails::Generator::Base
|
2
|
+
|
3
|
+
def manifest
|
4
|
+
record do |m|
|
5
|
+
m.directory File.join("public", "stylesheets", "watchtower")
|
6
|
+
m.directory File.join("public", "stylesheets", "watchtower", "images")
|
7
|
+
m.directory File.join("public", "stylesheets", "watchtower", "assets", "images")
|
8
|
+
m.directory File.join("public", "stylesheets", "watchtower", "assets", "images", "buttons")
|
9
|
+
m.directory File.join("public", "stylesheets", "watchtower", "assets", "images", "icons")
|
10
|
+
m.directory File.join("public", "javascripts", "watchtower")
|
11
|
+
|
12
|
+
root = File.join(File.dirname(__FILE__), "templates")
|
13
|
+
Dir.glob(File.join(root, "**", "*.*")).each do |f|
|
14
|
+
file = f.gsub("#{root}/", "")
|
15
|
+
m.file file, file
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "ipaddr"
|
2
|
+
|
3
|
+
module Watchtower
|
4
|
+
module ApplicationControllerBase
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.class_eval do
|
8
|
+
def rescue_action_in_public_with_watchtower(*args)
|
9
|
+
WatchedException.create_from_exception(self, args.first)
|
10
|
+
rescue_action_in_public_without_watchtower(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method_chain :rescue_action_in_public, :watchtower
|
14
|
+
end
|
15
|
+
|
16
|
+
base.extend ClassMethods
|
17
|
+
end
|
18
|
+
|
19
|
+
module ClassMethods
|
20
|
+
def force_public_request_handling!
|
21
|
+
|
22
|
+
self.class_eval do
|
23
|
+
def consider_all_requests_local_with_override(*args)
|
24
|
+
false
|
25
|
+
end
|
26
|
+
|
27
|
+
def local_request_with_override?(*args)
|
28
|
+
false
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method_chain :consider_all_requests_local, :override
|
32
|
+
alias_method_chain :local_request?, :override
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Watchtower
|
2
|
+
module ControllerBase
|
3
|
+
def self.included(base)
|
4
|
+
base.send :include, InstanceMethods
|
5
|
+
base.class_eval do
|
6
|
+
before_filter :find_exception, :only => [:show, :destroy]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
|
12
|
+
def index
|
13
|
+
@watched_exceptions = WatchedExceptionsPresenter.new(params)
|
14
|
+
end
|
15
|
+
|
16
|
+
def show; end
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
@watched_exception.destroy
|
20
|
+
end
|
21
|
+
|
22
|
+
def destroy_multiple
|
23
|
+
@deleted_exceptions = WatchedException.find_all_by_id(params[:id].split(",").map(&:strip))
|
24
|
+
@deleted_exceptions.each do |watched_exception|
|
25
|
+
watched_exception.destroy
|
26
|
+
end
|
27
|
+
index
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def find_by_key?
|
33
|
+
@show_by_key || false
|
34
|
+
end
|
35
|
+
|
36
|
+
def find_by_id?
|
37
|
+
@show_by_id || false
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def find_exception
|
43
|
+
key = params[:id]
|
44
|
+
@watched_exception = WatchedException.find_by_key(key)
|
45
|
+
if @watched_exception
|
46
|
+
@show_by_key = true
|
47
|
+
return
|
48
|
+
end
|
49
|
+
@watched_exception = WatchedException.find(key)
|
50
|
+
@show_by_id = true if @watched_exception
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Watchtower
|
2
|
+
module WatchedExceptionBase
|
3
|
+
def self.included(base)
|
4
|
+
base.send :include, Callbacks
|
5
|
+
base.send :include, Validations
|
6
|
+
base.send :include, Scopes
|
7
|
+
base.send :include, InstanceMethods
|
8
|
+
base.extend ClassMethods
|
9
|
+
end
|
10
|
+
|
11
|
+
module Callbacks
|
12
|
+
def self.included(base)
|
13
|
+
base.send :include, InstanceMethods
|
14
|
+
base.before_validation_on_create :generate_key
|
15
|
+
base.before_save :generate_controller_action, :clean_backtrace
|
16
|
+
end
|
17
|
+
|
18
|
+
module InstanceMethods
|
19
|
+
def generate_key
|
20
|
+
self.key = ActiveSupport::SecureRandom.hex(12)
|
21
|
+
end
|
22
|
+
|
23
|
+
def generate_controller_action
|
24
|
+
self.controller_action = "#{self.controller_name}/#{self.action_name}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def clean_backtrace; end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Validations
|
32
|
+
def self.included(base)
|
33
|
+
base.validates_presence_of :key
|
34
|
+
base.validates_uniqueness_of :key
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module Scopes
|
39
|
+
def self.included(base)
|
40
|
+
base.class_eval do
|
41
|
+
default_scope :order => "#{WatchedException.quoted_table_name}.created_at DESC"
|
42
|
+
named_scope :recent, lambda {|*ct| ct = ct.first || 5; { :limit => ct }}
|
43
|
+
named_scope :search, lambda { |query| {
|
44
|
+
:conditions => [
|
45
|
+
[ :controller_name, :action_name,
|
46
|
+
:controller_action, :exception_class,
|
47
|
+
:parameters, :message].map { |attribute| "#{WatchedException.quoted_table_name}.#{attribute} LIKE :query"}.join(" OR "), {:query => query}
|
48
|
+
]
|
49
|
+
}}
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
module ClassMethods
|
56
|
+
def create_from_exception(controller, exception)
|
57
|
+
create! :exception_class => exception.class.name,
|
58
|
+
:controller_name => controller.controller_name,
|
59
|
+
:action_name => controller.action_name,
|
60
|
+
:backtrace => controller.send(:clean_backtrace, exception).first,
|
61
|
+
:request => controller.request.inspect,
|
62
|
+
:parameters => controller.request.parameters.inspect,
|
63
|
+
:format => controller.request.format.to_s,
|
64
|
+
:message => exception.message.to_s,
|
65
|
+
:application_path => ::RAILS_ROOT
|
66
|
+
end
|
67
|
+
|
68
|
+
def exception_classes
|
69
|
+
all(:select => "DISTINCT exception_class", :order => "exception_class").collect(&:exception_class)
|
70
|
+
end
|
71
|
+
|
72
|
+
def controller_actions
|
73
|
+
all(:select => "DISTINCT controller_action", :order => "controller_action").collect(&:controller_action)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
module InstanceMethods
|
78
|
+
def name
|
79
|
+
"#{self.exception_class} in #{self.controller_action}"
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class WatchedExceptionsPresenter
|
2
|
+
include Enumerable
|
3
|
+
|
4
|
+
def initialize(params)
|
5
|
+
scope = WatchedException
|
6
|
+
scope = scope.search("%#{params[:query]}%") if params[:query]
|
7
|
+
scope = scope.scoped_by_action_name(params[:action_name]) if params[:action_name]
|
8
|
+
scope = scope.scoped_by_controller_name(params[:controller_name]) if params[:controller_name]
|
9
|
+
scope = scope.scoped_by_controller_action(params[:controller_action]) if params[:controller_action]
|
10
|
+
scope = scope.scoped_by_exception_class(params[:exception_class]) if params[:exception_class]
|
11
|
+
scope = scope.scoped({:conditions => ["DATE(#{WatchedException.quoted_table_name}.created_at) >= ?", Date.parse(params[:start_at]).to_s(:db)]}) if params[:start_at]
|
12
|
+
scope = scope.scoped({:conditions => ["DATE(#{WatchedException.quoted_table_name}.created_at) <= ?", Date.parse(params[:end_at]).to_s(:db)]}) if params[:end_at]
|
13
|
+
@watched_exceptions = scope.paginate(:page => params[:page], :per_page => 10)
|
14
|
+
end
|
15
|
+
|
16
|
+
def each(&block)
|
17
|
+
@watched_exceptions.each(&block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def method_missing(call, *args)
|
21
|
+
@watched_exceptions.send call, *args
|
22
|
+
end
|
23
|
+
end
|
data/lib/watchtower.rb
ADDED
data/rails/init.rb
ADDED
File without changes
|
data/test/test_helper.rb
ADDED
data/watchtower.gemspec
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{watchtower}
|
5
|
+
s.version = "0.1.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Joshua Clayton"]
|
9
|
+
s.date = %q{2009-05-01}
|
10
|
+
s.description = %q{An exception logger for Rails 2.3}
|
11
|
+
s.email = %q{joshua.clayton@gmail.com}
|
12
|
+
s.extra_rdoc_files = ["lib/watchtower/application_controller_base.rb", "lib/watchtower/controller_base.rb", "lib/watchtower/watched_exception_base.rb", "lib/watchtower/watched_exceptions_presenter.rb", "lib/watchtower.rb", "README.textile", "tasks/watchtower_tasks.rake"]
|
13
|
+
s.files = ["app/controllers/watchtower_controller.rb", "app/helpers/watchtower_helper.rb", "app/models/watched_exception.rb", "app/views/layouts/watchtower.erb", "app/views/watchtower/_recordset.erb", "app/views/watchtower/destroy.js.rjs", "app/views/watchtower/destroy_multiple.js.rjs", "app/views/watchtower/index.html.erb", "app/views/watchtower/index.js.rjs", "app/views/watchtower/show.html.erb", "config/routes.rb", "generators/watchtower/templates/migrations/create_watched_exceptions.rb", "generators/watchtower/templates/README", "generators/watchtower/USAGE", "generators/watchtower/watchtower_generator.rb", "generators/watchtower_assets/templates/public/javascripts/watchtower/jquery-1.3.2.min.js", "generators/watchtower_assets/templates/public/javascripts/watchtower/jquery-ui-1.7.1.custom.min.js", "generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.bindings.js", "generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.events.js", "generators/watchtower_assets/templates/public/javascripts/watchtower/jquery.watchtower.js", "generators/watchtower_assets/templates/public/stylesheets/watchtower/admin.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/ajax-loader.gif", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/bullet-black.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/buttons/sprite-gray.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/buttons/x.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign-red.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign-sm.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/caution-sign.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/edit-template.gif", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/icons/success-badge.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/assets/images/nav-admin-shadow.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/extras.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/forms.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/ie.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_flat_0_aaaaaa_40x100.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_55_fbf9ee_1x400.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_65_ffffff_1x400.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_dadada_1x400.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_e6e6e6_1x400.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_glass_75_ffffff_1x400.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_highlight-soft_75_cccccc_1x100.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-bg_inset-soft_95_fef1ec_1x100.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_222222_256x240.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_2e83ff_256x240.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_454545_256x240.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_888888_256x240.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/images/ui-icons_cd0a0a_256x240.png", "generators/watchtower_assets/templates/public/stylesheets/watchtower/jquery-ui-1.7.1.custom.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/reset.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/screen.css", "generators/watchtower_assets/templates/public/stylesheets/watchtower/watchtower.css", "generators/watchtower_assets/USAGE", "generators/watchtower_assets/watchtower_assets_generator.rb", "lib/watchtower/application_controller_base.rb", "lib/watchtower/controller_base.rb", "lib/watchtower/watched_exception_base.rb", "lib/watchtower/watched_exceptions_presenter.rb", "lib/watchtower.rb", "Manifest", "MIT-LICENSE", "rails/init.rb", "Rakefile", "README.textile", "tasks/watchtower_tasks.rake", "test/test_helper.rb", "watchtower.gemspec"]
|
14
|
+
s.has_rdoc = true
|
15
|
+
s.homepage = %q{http://github.com/joshuaclayton/watchtower}
|
16
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Watchtower", "--main", "README.textile"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = %q{watchtower}
|
19
|
+
s.rubygems_version = %q{1.3.2}
|
20
|
+
s.summary = %q{An exception logger for Rails 2.3}
|
21
|
+
s.test_files = ["test/test_helper.rb"]
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
25
|
+
s.specification_version = 3
|
26
|
+
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
|
+
s.add_development_dependency(%q<activesupport>, [">= 0", ">= 2.3.0"])
|
29
|
+
s.add_development_dependency(%q<will_paginate>, [">= 0", ">= 2.3.4"])
|
30
|
+
else
|
31
|
+
s.add_dependency(%q<activesupport>, [">= 0", ">= 2.3.0"])
|
32
|
+
s.add_dependency(%q<will_paginate>, [">= 0", ">= 2.3.4"])
|
33
|
+
end
|
34
|
+
else
|
35
|
+
s.add_dependency(%q<activesupport>, [">= 0", ">= 2.3.0"])
|
36
|
+
s.add_dependency(%q<will_paginate>, [">= 0", ">= 2.3.4"])
|
37
|
+
end
|
38
|
+
end
|