smklib 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/app/assets/images/add.png +0 -0
- data/app/assets/images/button_cancel.png +0 -0
- data/app/assets/images/button_ok.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_block.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_bold.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_center.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_italic.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_left.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_right.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_strike.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_sub.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_super.png +0 -0
- data/app/assets/images/cmseditor/16x16/text_under.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_block.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_bold.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_center.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_italic.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_left.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_right.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_strike.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_sub.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_super.png +0 -0
- data/app/assets/images/cmseditor/22x22/text_under.png +0 -0
- data/app/assets/images/trashcan_empty.png +0 -0
- data/app/assets/javascripts/collapsable.js +56 -0
- data/app/assets/javascripts/hide_show.js +39 -0
- data/app/assets/javascripts/jscalendar-1.0/calendar-setup.js +200 -0
- data/app/assets/javascripts/jscalendar-1.0/calendar.js +1806 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-af.js +39 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-al.js +101 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-bg.js +124 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-big5-utf8.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-big5.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-br.js +108 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ca.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-cs-utf8.js +65 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-cs-win.js +65 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-da.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-de.js +124 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-du.js +45 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-el.js +89 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-en.js +127 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-es.js +129 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-fi.js +98 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-fr.js +125 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-he-utf8.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-hr-utf8.js +49 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-hr.js +0 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-hu.js +124 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-it.js +124 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-jp.js +45 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ko-utf8.js +120 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ko.js +120 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-lt-utf8.js +114 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-lt.js +114 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-lv.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-nl.js +73 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-no.js +114 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-pl-utf8.js +93 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-pl.js +56 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-pt.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ro.js +66 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ru.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-ru_win_.js +123 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-si.js +94 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-sk.js +99 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-sp.js +110 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-sv.js +93 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-tr.js +58 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/calendar-zh.js +119 -0
- data/app/assets/javascripts/jscalendar-1.0/lang/cn_utf8.js +123 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/active-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/dark-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/hover-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/menuarrow.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/normal-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/rowhover-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/status-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/theme.css +236 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/title-bg.gif +0 -0
- data/app/assets/stylesheets/jscalendar-1.0/skins/aqua/today-bg.gif +0 -0
- data/app/views/error_mailer/snapshot.rhtml +71 -0
- data/lib/smklib.rb +6 -0
- data/lib/smklib/array_ext.rb +76 -0
- data/lib/smklib/browsers.rb +69 -0
- data/lib/smklib/builder_ext.rb +103 -0
- data/lib/smklib/date_ext.rb +23 -0
- data/lib/smklib/debug_support.rb +27 -0
- data/lib/smklib/error_mailer.rb +70 -0
- data/lib/smklib/hash_ext.rb +19 -0
- data/lib/smklib/htmlutils.rb +604 -0
- data/lib/smklib/movable_children.rb +28 -0
- data/lib/smklib/object_ext.rb +34 -0
- data/lib/smklib/php_serialize.rb +309 -0
- data/lib/smklib/railtie.rb +6 -0
- data/lib/smklib/somekool_scaffold.rb +198 -0
- data/lib/smklib/super_looking_list.rb +63 -0
- data/lib/smklib/version.rb +11 -0
- data/vendor/calendar_helper.rb +100 -0
- data/vendor/htmltokenizer.rb +259 -0
- metadata +158 -0
Binary file
|
Binary file
|
@@ -0,0 +1,71 @@
|
|
1
|
+
<style>
|
2
|
+
<!--
|
3
|
+
|
4
|
+
* {font-size:9pt;font-family:verdana, helvetica, arial, sans-serif; line-height: 1.7em; }
|
5
|
+
p { margin: 0 }
|
6
|
+
-->
|
7
|
+
</style>
|
8
|
+
<h2>Error report</h2>
|
9
|
+
|
10
|
+
<table border="0">
|
11
|
+
<tr><td>Message</td><td><%= @v_exception.message %></td></tr>
|
12
|
+
<%
|
13
|
+
require 'uri'
|
14
|
+
request_uri = @v_env['REQUEST_URI'].match(@v_env['HTTP_HOST']) ? @v_env['REQUEST_URI'].split(@v_env['HTTP_HOST'])[1] : @v_env['REQUEST_URI']
|
15
|
+
uri_path, uri_query = request_uri.split('?')
|
16
|
+
uri_extra = 'local_request=1'
|
17
|
+
host, port = @v_env['HTTP_HOST'].split(':')
|
18
|
+
go_url_hash = {:host => host, :path => uri_path, :query => uri_query.to_s.empty? ? uri_extra : "#{uri_query}&#{uri_extra}"}
|
19
|
+
go_url_hash.merge!(:port => port) if port.to_i > 0 and port.to_i != 80
|
20
|
+
go_url = URI::HTTP.build(go_url_hash)
|
21
|
+
%>
|
22
|
+
<tr><td>Location</td><td><a href='<%= go_url %>'><%= go_url %></a></td></tr>
|
23
|
+
<tr><td>Client IP</td><td><%= @v_env['REMOTE_ADDR'] %><%= (@v_env['REMOTE_ADDR'] == "24.85.69.203") ? ' UberOFFICE' : '' %></td></tr>
|
24
|
+
<tr><td>Client IP on Forward</td><td><%= @v_env['HTTP_X_FORWARDED_FOR'] %><%= (@v_env['HTTP_X_FORWARDED_FOR'] == "24.85.69.203") ? ' UberOFFICE' : '' %></td></tr>
|
25
|
+
<tr><td>Date</td><td><%= Time.now %></td></tr>
|
26
|
+
<tr><td>Controller</td><td><%= @v_params.delete('controller') %></td></tr>
|
27
|
+
<tr><td>Action</td><td><%= @v_params.delete('action') %></td></tr>
|
28
|
+
<tr><td>Query</td><td><%= @v_env['QUERY_STRING'] %></td></tr>
|
29
|
+
<tr><td>Method</td><td><%= @v_env['REQUEST_METHOD'] %></td></tr>
|
30
|
+
<tr><td>SSL</td><td><%= @v_env['SERVER_PORT'].to_i == 443 ? "true" : "false" %></td></tr>
|
31
|
+
<tr><td>Agent</td><td><%= @v_env['HTTP_USER_AGENT'] %></td></tr>
|
32
|
+
<% if @v_session['user'] -%>
|
33
|
+
<tr><td>User id</td><td><%= @v_session['user'].id %></td></tr>
|
34
|
+
<tr><td>User name</td><td><%= @v_session['user'].fullname %></td></tr>
|
35
|
+
<tr><td>User email</td><td><%= @v_session['user'].email %></td></tr>
|
36
|
+
<tr><td>Registered</td><td><%= @v_session['user'].ctime %></td></tr>
|
37
|
+
<% end -%>
|
38
|
+
</table>
|
39
|
+
|
40
|
+
<h3>Backtrace</h3>
|
41
|
+
<pre><%= @v_trace.to_a.join("\n") -%></pre>
|
42
|
+
|
43
|
+
<h3>Params</h3>
|
44
|
+
<hr/>
|
45
|
+
<% for key, val in @v_params -%>
|
46
|
+
<p><b><%= key %></b></p>
|
47
|
+
<p><%= val.to_yaml.to_a.join("</p>\n<p> ") %></p>
|
48
|
+
<% end if @v_params -%>
|
49
|
+
|
50
|
+
<h3>Session</h3>
|
51
|
+
<hr/>
|
52
|
+
<% for key, val in @v_session -%>
|
53
|
+
<p><b><%= key %></b></p>
|
54
|
+
<p><%= val.to_yaml.to_a.join("</p>\n<p> ") %></p>
|
55
|
+
<% end if @v_session -%>
|
56
|
+
|
57
|
+
<h3>Environment</h3>
|
58
|
+
<hr/>
|
59
|
+
<table border="0">
|
60
|
+
<% for key, val in @v_env -%>
|
61
|
+
<tr>
|
62
|
+
<td>
|
63
|
+
<small><b><%= key %></b></small>
|
64
|
+
|
65
|
+
</td>
|
66
|
+
<td>
|
67
|
+
<small><%= val %></small>
|
68
|
+
</td>
|
69
|
+
</tr>
|
70
|
+
<% end if @v_env -%>
|
71
|
+
</table>
|
data/lib/smklib.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
class Array
|
2
|
+
|
3
|
+
def multi_slice(*slice_size)
|
4
|
+
return self if slice_size.empty?
|
5
|
+
tmp_out = []
|
6
|
+
index = 0
|
7
|
+
n = 0
|
8
|
+
while(index < size)
|
9
|
+
ss = slice_size[n] || slice_size.first
|
10
|
+
tmp_out << slice(index, ss)
|
11
|
+
index += ss
|
12
|
+
n += 1
|
13
|
+
end
|
14
|
+
tmp_out
|
15
|
+
end
|
16
|
+
|
17
|
+
# takes an array of hashes and an array of ordered hash keys
|
18
|
+
# creates a nested array based on the elements of the hashes
|
19
|
+
# name the last elt in the key array 'count' if you want to pair the last two elements
|
20
|
+
def create_nested_array(keys)
|
21
|
+
h_count = self[0].length # count the number of elements in the hash - assumes all are the same length
|
22
|
+
old_vals = Hash.new # keep a record of elements already recorded
|
23
|
+
o = Array.new # create output variable
|
24
|
+
str,str_eval = nil # create temp variable for holding code to execute
|
25
|
+
has_count_column = keys.last == 'count'
|
26
|
+
h_end = (has_count_column) ? h_count - 2 : h_count - 1
|
27
|
+
|
28
|
+
self.each do |a|
|
29
|
+
current = o
|
30
|
+
keys.each_with_index do |k,i|
|
31
|
+
begin
|
32
|
+
unless (i >= h_end and has_count_column)
|
33
|
+
#if ((i != h_end) || (keys.last != 'count'))
|
34
|
+
if a[k] != old_vals[k]
|
35
|
+
current << [ a[k], [] ]
|
36
|
+
keys[i+1..keys.length].each { |q| old_vals[q] = nil }
|
37
|
+
end
|
38
|
+
current = current.last.last # reference the value array
|
39
|
+
else
|
40
|
+
current << [a[k], a['count']] if (i == h_end)
|
41
|
+
end
|
42
|
+
old_vals[k] = a[k] # record element we just looked at
|
43
|
+
rescue Exception => e
|
44
|
+
raise "Error: #{e.inspect}, " +
|
45
|
+
"current = #{current.inspect}, " +
|
46
|
+
"a[k] = #{a[k].inspect} and a[k] != old_vals[k] = #{(a[k] != old_vals[k]).inspect}, " +
|
47
|
+
"a = #{a.inspect}, " +
|
48
|
+
"o = #{o.to_yaml}, " +
|
49
|
+
"self = #{self.to_yaml}, "
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
o
|
54
|
+
end
|
55
|
+
|
56
|
+
def randomize
|
57
|
+
self.sort { |l,r| rand(2) - 1 }
|
58
|
+
end
|
59
|
+
|
60
|
+
def randomize!
|
61
|
+
self.sort! { |l,r| rand(2) - 1 }
|
62
|
+
end
|
63
|
+
|
64
|
+
def to_double_array
|
65
|
+
self.each_with_index { |x,i| self[i] = [x,x] }
|
66
|
+
self
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def search_array_of_hash(data, value, key="value", text="label")
|
71
|
+
return_text = ""
|
72
|
+
data.each do |x|
|
73
|
+
return_text = x.to_hash[text.to_sym] if x.to_hash[key.to_sym].to_s == value.to_s
|
74
|
+
end
|
75
|
+
return_text
|
76
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module SMKLib
|
2
|
+
module Browsers
|
3
|
+
def is_mobile_browser?(ua)
|
4
|
+
mobile_browsers = [
|
5
|
+
'DoCoMo',
|
6
|
+
'alcatel',
|
7
|
+
'auditautomatic',
|
8
|
+
'ericsson',
|
9
|
+
'lg-g7000',
|
10
|
+
'mitsu',
|
11
|
+
'mot-.*',
|
12
|
+
'nokian-gage',
|
13
|
+
'opwv-sdk',
|
14
|
+
'panasonic-[xg].*',
|
15
|
+
'philips-.*',
|
16
|
+
'r380',
|
17
|
+
'r600',
|
18
|
+
'sagem-3xxx',
|
19
|
+
'sagem-9xx',
|
20
|
+
'sagem-myx-.*',
|
21
|
+
'samsung-sgh-[xevtasrn][0-9][0-9][0-9].*',
|
22
|
+
'sec-sgh[cpqsavdex][0-9][0-9][0-9]',
|
23
|
+
'sharp-tq-gx[0-9][0-9]',
|
24
|
+
'sonyericsson',
|
25
|
+
'alcatel',
|
26
|
+
'ericssona2628s',
|
27
|
+
'ericssonr320',
|
28
|
+
'lg-[cfgltG0-9]*',
|
29
|
+
'sie-[acfxvmniedsklt0-9]*',
|
30
|
+
'sagem-m.*',
|
31
|
+
'mot-[-abvcetdf0-9]*',
|
32
|
+
'nokia[0-9]*',
|
33
|
+
'panasonic',
|
34
|
+
't66',
|
35
|
+
'n21i',
|
36
|
+
'n22i',
|
37
|
+
'ts21i',
|
38
|
+
'portalmmm',
|
39
|
+
'ipcheck',
|
40
|
+
'cnf2'
|
41
|
+
]
|
42
|
+
is_it = false
|
43
|
+
modified_ua = ua.gsub(/[+ ]/, '_')
|
44
|
+
mobile_browsers.each do |x|
|
45
|
+
is_it = true if modified_ua.match(/^#{x}/)
|
46
|
+
end
|
47
|
+
return is_it
|
48
|
+
end
|
49
|
+
|
50
|
+
def user_agent
|
51
|
+
ua = request.env['HTTP_USER_AGENT']
|
52
|
+
if ua.nil?
|
53
|
+
"31337_h4x0r"
|
54
|
+
elsif ua.match(/Opera/)
|
55
|
+
"Opera"
|
56
|
+
elsif ua.match(/MSIE/)
|
57
|
+
"MSIE"
|
58
|
+
elsif ua.match(/Safari/)
|
59
|
+
"Safari"
|
60
|
+
elsif ua.match(/KHTML/)
|
61
|
+
"KHTML"
|
62
|
+
elsif is_mobile_browser?(ua)
|
63
|
+
"Mobile"
|
64
|
+
else # we are not making a difference for other browsers.
|
65
|
+
"Mozilla" # standard
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
require 'RMagick'
|
2
|
+
require 'smklib/array_ext'
|
3
|
+
|
4
|
+
class Builder::XmlMarkup
|
5
|
+
|
6
|
+
# Builder Transaction ...
|
7
|
+
|
8
|
+
class AbortTransaction < ::RuntimeError; end
|
9
|
+
|
10
|
+
def transaction!(&block)
|
11
|
+
old_target = @target
|
12
|
+
@target = ''
|
13
|
+
begin
|
14
|
+
yield
|
15
|
+
@target = old_target + @target
|
16
|
+
rescue AbortTransaction => e
|
17
|
+
@target = old_target
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def ignore_abort!(val = true)
|
22
|
+
@ignore_abort = val
|
23
|
+
end
|
24
|
+
|
25
|
+
def abort!
|
26
|
+
raise AbortTransaction, "abort" unless @ignore_abort
|
27
|
+
end
|
28
|
+
|
29
|
+
# Build Extensions ...
|
30
|
+
|
31
|
+
class << self
|
32
|
+
attr_accessor :environment
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_ua
|
36
|
+
env = ENV
|
37
|
+
env = Builder::XmlMarkup.environment if Builder::XmlMarkup.environment
|
38
|
+
env['HTTP_USER_AGENT']
|
39
|
+
end
|
40
|
+
|
41
|
+
def tight_table(options = {})
|
42
|
+
table({ "cellspacing" => 0, "cellpadding" => 0, "border" => 0 }.merge(options)) { yield }
|
43
|
+
end
|
44
|
+
|
45
|
+
#cells is an array of objects that respond to to_s
|
46
|
+
def table_row(cells, tr_options = {}, td_options = {})
|
47
|
+
tr(tr_options) { cells.each_with_index { |i,k| td(td_options[k] || {}) { self << i.to_s } } }
|
48
|
+
end
|
49
|
+
|
50
|
+
def sortable_column_header(label, link, options = {})
|
51
|
+
#th({"x" => "y"}.merge(options)) do
|
52
|
+
th(options) do
|
53
|
+
if !label.empty?
|
54
|
+
a("href" => link) { self << " #{label} " }
|
55
|
+
else
|
56
|
+
self << " "
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def real_filename(filename)
|
62
|
+
if defined?(RAILS_ROOT)
|
63
|
+
RAILS_ROOT + "/public/" + filename
|
64
|
+
else
|
65
|
+
filename
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def get_img_size(filename)
|
70
|
+
im = Magick::Image.read(real_filename(filename)).first
|
71
|
+
return [im.columns, im.rows]
|
72
|
+
end
|
73
|
+
|
74
|
+
def img(options = {})
|
75
|
+
if get_ua =~ /MSIE 6.*Windows/
|
76
|
+
if options[:src] =~ /\.png$/
|
77
|
+
options[:style] = "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='#{options[:src]}', sizingMethod='scale');" + options[:style].to_s
|
78
|
+
options[:width], options[:height] = get_img_size(options[:src]) unless options[:width] && options[:height]
|
79
|
+
options[:src] = '/images/spacer.gif'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
if block_given?
|
83
|
+
method_missing(:img, options, yield)
|
84
|
+
else
|
85
|
+
method_missing(:img, options)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def nbsp(count=1)
|
90
|
+
self << (1..count).collect{ " " }.join
|
91
|
+
end
|
92
|
+
|
93
|
+
def ob2(ob, *extra, &block)
|
94
|
+
# yes this is kind of ugly but makes this a soft dependancy on OdlumBox2
|
95
|
+
ob = Class.const_get('OdlumBox2').new(ob) if ob.kind_of? Hash
|
96
|
+
div(*extra) do
|
97
|
+
ob.render(self) { |xml|
|
98
|
+
yield
|
99
|
+
}
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'gettext/rails'
|
2
|
+
|
3
|
+
class Date
|
4
|
+
if Object.respond_to?('_')
|
5
|
+
raise "ye"
|
6
|
+
MONTHNAMES = [nil, _("January"), _("February"), _("March"), _("April"), _("May"), _("June"), _("July"), _("August"), _("September"), _("October"), _("November"), _("December")]
|
7
|
+
DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
|
8
|
+
ABBR_MONTHNAMES = [nil, _("Jan"), _("Feb"), _("Mar"), _("Apr"), _("May"), _("Jun"), _("Jul"), _("Aug"), _("Sep"), _("Oct"), _("Nov"), _("Dec")]
|
9
|
+
ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
|
10
|
+
elsif Locale.get.to_s == 'en'
|
11
|
+
MONTHNAMES = [nil] + %w(January February March April May June July August September October November December)
|
12
|
+
DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
|
13
|
+
ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
14
|
+
ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
|
15
|
+
elsif Locale.get.to_s == 'ja'
|
16
|
+
MONTHNAMES = [nil] + %w(一月 二月 三月 四月 五月 六月 七月 八月 九月 十月 十一月 十二月)
|
17
|
+
DAYNAMES = %w(Sunday Monday Tuesday Wednesday Thursday Friday Saturday)
|
18
|
+
ABBR_MONTHNAMES = [nil] + %w(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)
|
19
|
+
ABBR_DAYNAMES = %w(Sun Mon Tue Wed Thu Fri Sat)
|
20
|
+
else
|
21
|
+
raise 'unsupported language'
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_dependency 'smklib/object_ext'
|
2
|
+
|
3
|
+
module DebugSupport
|
4
|
+
|
5
|
+
def self.append_features(base)
|
6
|
+
super
|
7
|
+
base.before_filter :initialize_timing, :check_local_request
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize_timing
|
11
|
+
@time = Time.now
|
12
|
+
end
|
13
|
+
|
14
|
+
def local_request?
|
15
|
+
#session['local_request'] == 1
|
16
|
+
consider_all_requests_local or session['local_request'] == 1
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_local_request
|
20
|
+
val = params['local_request'].to_i
|
21
|
+
default = consider_all_requests_local ? 1 : 0
|
22
|
+
session['local_request'] ||= default
|
23
|
+
session['local_request'] = val if val.in? [1, 0] unless params['local_request'].nil?
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module SoftRaise
|
2
|
+
def soft_raise
|
3
|
+
exception = nil
|
4
|
+
ErrorMailer.deliver_snapshot('somekool@somekool.net', 'FRES:Warning Mailer <error@somekool.net>', exception, clean_backtrace(exception), session.instance_variable_get("@data"), params, request.env)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
module ErrorMailerSupport
|
9
|
+
|
10
|
+
#attr_accessor :error_mailer_to
|
11
|
+
|
12
|
+
#def self.append_features(base)
|
13
|
+
# super
|
14
|
+
# base.before_filter :initialize_error_mailer
|
15
|
+
#end
|
16
|
+
|
17
|
+
def error_mailer_recipients
|
18
|
+
'somekool@somekool.net'
|
19
|
+
end
|
20
|
+
|
21
|
+
def error_mailer_from
|
22
|
+
'[AppName]:Error Mailer <error@somekool.net>'
|
23
|
+
end
|
24
|
+
|
25
|
+
def log_error(exception)
|
26
|
+
super(exception)
|
27
|
+
|
28
|
+
begin
|
29
|
+
ErrorMailer.deliver_snapshot(error_mailer_recipients, error_mailer_from, exception, clean_backtrace(exception),
|
30
|
+
session.instance_variable_get("@data"), params, request.env) unless local_request?
|
31
|
+
rescue => e
|
32
|
+
logger.error(e)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def rescue_action_in_public(exception) #:doc:
|
37
|
+
case exception.class.to_s
|
38
|
+
when "ActionController::RoutingError", "ActionController::UnknownAction"
|
39
|
+
render :file => "#{RAILS_ROOT}/public/smklib/404.html", :status => 404
|
40
|
+
when "Mysql::Error"
|
41
|
+
render :file => "#{RAILS_ROOT}/public/smklib/500-mysql.html", :status => 500
|
42
|
+
else
|
43
|
+
render :file => "#{RAILS_ROOT}/public/smklib/500.html", :status => 500
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
class ErrorMailer < ActionMailer::Base
|
50
|
+
|
51
|
+
def snapshot(rcpt, from, exception, trace, p_session, p_params, p_env, sent_on = Time.now)
|
52
|
+
@recipients = rcpt
|
53
|
+
@from = from
|
54
|
+
if exception.class.to_s == "ActionController::UnknownAction"
|
55
|
+
@subject = "[NotFound] #{exception.class.to_s} in #{p_env['REQUEST_URI']}"
|
56
|
+
else
|
57
|
+
@subject = "[Error] #{exception.class.to_s} in #{p_env['REQUEST_URI']}"
|
58
|
+
end
|
59
|
+
@sent_on = sent_on
|
60
|
+
@body["v_exception"] = exception
|
61
|
+
@body["v_trace"] = trace
|
62
|
+
@body["v_session"] = p_session
|
63
|
+
@body["v_params"] = p_params
|
64
|
+
@body["v_env"] = p_env
|
65
|
+
content_type "text/html"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
#ErrorMailer.template_root = "#{RAILS_ROOT}/vendor/smklib/app/views"
|
70
|
+
|