old_sql 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +0 -2
- data/app/controllers/old_sql/report_controller.rb +12 -2
- data/app/views/old_sql/errors/401.html.erb +25 -0
- data/app/views/old_sql/report/print.html.erb +1 -1
- data/lib/extensions/action_controller/base.rb +0 -4
- data/lib/generators/old_sql/copy_assets_generator.rb +38 -0
- data/lib/generators/old_sql/old_sql_generator.rb +5 -0
- data/lib/old_sql.rb +31 -0
- metadata +7 -27
data/Gemfile
CHANGED
@@ -9,6 +9,7 @@ module OldSql
|
|
9
9
|
|
10
10
|
helper_method :jqgrid_col_model
|
11
11
|
helper_method :jqgrid_col_names
|
12
|
+
helper_method :strip_html
|
12
13
|
|
13
14
|
layout "old_sql/report.html.erb"
|
14
15
|
|
@@ -61,7 +62,7 @@ module OldSql
|
|
61
62
|
@report[:rows].each do |row|
|
62
63
|
rec = []
|
63
64
|
row[:cell].each do |cell|
|
64
|
-
rec <<
|
65
|
+
rec << strip_html(cell.to_s).gsub("\n","")
|
65
66
|
end
|
66
67
|
csv << rec
|
67
68
|
end
|
@@ -97,7 +98,7 @@ module OldSql
|
|
97
98
|
|
98
99
|
private
|
99
100
|
def ensure_old_sql_admin!
|
100
|
-
|
101
|
+
render_error(Exception.new "Old SQL Access Denied.") unless current_user.old_sql_admin?
|
101
102
|
end
|
102
103
|
|
103
104
|
def _init
|
@@ -154,6 +155,15 @@ module OldSql
|
|
154
155
|
return nil
|
155
156
|
end
|
156
157
|
end
|
158
|
+
|
159
|
+
def render_error(exception)
|
160
|
+
logger.error(exception)
|
161
|
+
render :template => "old_sql/errors/401.html.erb", :status => 401
|
162
|
+
end
|
163
|
+
|
164
|
+
def strip_html html
|
165
|
+
OldSql.strip_html html
|
166
|
+
end
|
157
167
|
end
|
158
168
|
end
|
159
169
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>You are not authorized to access this page. (401)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/401.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>You are not authorized to access this page.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module OldSql
|
2
|
+
class CopyAssetsGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path('../templates', __FILE__)
|
4
|
+
|
5
|
+
desc "Old SQL Copy Assets"
|
6
|
+
|
7
|
+
def copy_assets
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
def create_old_sql_dirs
|
12
|
+
empty_directory "#{app_path}/public/stylesheets/old_sql"
|
13
|
+
empty_directory "#{app_path}/app/views/layouts/old_sql"
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_old_sql_files
|
17
|
+
copy_file "#{gem_path}/public/stylesheets/old_sql/old_sql.css", "#{app_path}/public/stylesheets/old_sql/old_sql.css"
|
18
|
+
copy_file "#{gem_path}/app/views/layouts/old_sql/report.html.erb", "#{app_path}/app/views/layouts/old_sql/report.html.erb"
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def app_path
|
24
|
+
app_path = Rails.public_path.split("/")
|
25
|
+
app_path.delete_at(-1)
|
26
|
+
app_path = app_path.join("/")
|
27
|
+
app_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def gem_path
|
31
|
+
gem_path = __FILE__
|
32
|
+
gem_path = gem_path.split("/")
|
33
|
+
gem_path = gem_path[0..-5]
|
34
|
+
gem_path = gem_path.join("/")
|
35
|
+
gem_path
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -15,6 +15,11 @@ Devise, but want use another model than the default 'user' you can provide the
|
|
15
15
|
custom model name as an argument:
|
16
16
|
|
17
17
|
rails g old_sql:install member
|
18
|
+
|
19
|
+
To copy file assets, old_sql.css and the layout for the report view, to your
|
20
|
+
installation, execute:
|
21
|
+
|
22
|
+
rails g old_sql:copy_assets
|
18
23
|
|
19
24
|
"
|
20
25
|
end
|
data/lib/old_sql.rb
CHANGED
@@ -35,6 +35,37 @@ module OldSql
|
|
35
35
|
def self.setup
|
36
36
|
yield self
|
37
37
|
end
|
38
|
+
|
39
|
+
def self.strip_html html
|
40
|
+
text = html.
|
41
|
+
gsub(/( |\n|\s)+/im, ' ').squeeze(' ').strip.
|
42
|
+
gsub(/<([^\s]+)[^>]*(src|href)=\s*(.?)([^>\s]*)\3[^>]*>\4<\/\1>/i, '\4')
|
43
|
+
|
44
|
+
links = []
|
45
|
+
linkregex = /<[^>]*(src|href)=\s*(.?)([^>\s]*)\2[^>]*>\s*/i
|
46
|
+
while linkregex.match(text)
|
47
|
+
links << $~[3]
|
48
|
+
text.sub!(linkregex, "[#{links.size}]")
|
49
|
+
end
|
50
|
+
|
51
|
+
text = CGI.unescapeHTML(
|
52
|
+
text.
|
53
|
+
gsub(/<(script|style)[^>]*>.*<\/\1>/im, '').
|
54
|
+
gsub(/<!--.*-->/m, '').
|
55
|
+
gsub(/<hr(| [^>]*)>/i, "___\n").
|
56
|
+
gsub(/<li(| [^>]*)>/i, "\n* ").
|
57
|
+
gsub(/<blockquote(| [^>]*)>/i, '> ').
|
58
|
+
gsub(/<(br)(| [^>]*)>/i, "\n").
|
59
|
+
gsub(/<(\/h[\d]+|p)(| [^>]*)>/i, "\n\n").
|
60
|
+
gsub(/<[^>]*>/, '')
|
61
|
+
).lstrip.gsub(/\n[ ]+/, "\n") + "\n"
|
62
|
+
|
63
|
+
for i in (0...links.size).to_a
|
64
|
+
text = text + "\n [#{i+1}] <#{CGI.unescapeHTML(links[i])}>" unless links[i].nil?
|
65
|
+
end
|
66
|
+
links = nil
|
67
|
+
text
|
68
|
+
end
|
38
69
|
end
|
39
70
|
|
40
71
|
require 'extensions/action_controller/base'
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: old_sql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.
|
5
|
+
version: 1.4.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Eddie Gonzales
|
@@ -13,7 +13,7 @@ cert_chain: []
|
|
13
13
|
date: 2011-06-11 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: devise
|
17
17
|
requirement: &id001 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
@@ -23,31 +23,9 @@ dependencies:
|
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: devise
|
28
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
29
|
-
none: false
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: "0"
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: cancan
|
39
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
40
|
-
none: false
|
41
|
-
requirements:
|
42
|
-
- - ">="
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
version: "0"
|
45
|
-
type: :runtime
|
46
|
-
prerelease: false
|
47
|
-
version_requirements: *id003
|
48
26
|
- !ruby/object:Gem::Dependency
|
49
27
|
name: jeweler
|
50
|
-
requirement: &
|
28
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
51
29
|
none: false
|
52
30
|
requirements:
|
53
31
|
- - ">="
|
@@ -55,7 +33,7 @@ dependencies:
|
|
55
33
|
version: "0"
|
56
34
|
type: :development
|
57
35
|
prerelease: false
|
58
|
-
version_requirements: *
|
36
|
+
version_requirements: *id002
|
59
37
|
description: OldSQL is a Rails Engine database reporting gem that uses plain old SQL
|
60
38
|
email: egonzales@pureplay.com
|
61
39
|
executables: []
|
@@ -72,6 +50,7 @@ files:
|
|
72
50
|
- Rakefile
|
73
51
|
- app/controllers/old_sql/report_controller.rb
|
74
52
|
- app/views/layouts/old_sql/report.html.erb
|
53
|
+
- app/views/old_sql/errors/401.html.erb
|
75
54
|
- app/views/old_sql/report/datagrid.html.erb
|
76
55
|
- app/views/old_sql/report/index.html.erb
|
77
56
|
- app/views/old_sql/report/print.html.erb
|
@@ -79,6 +58,7 @@ files:
|
|
79
58
|
- config/routes.rb
|
80
59
|
- lib/extensions/action_controller/base.rb
|
81
60
|
- lib/generators/old_sql/USAGE
|
61
|
+
- lib/generators/old_sql/copy_assets_generator.rb
|
82
62
|
- lib/generators/old_sql/install_devise_migrations_generator.rb
|
83
63
|
- lib/generators/old_sql/install_generator.rb
|
84
64
|
- lib/generators/old_sql/install_migrations_generator.rb
|
@@ -200,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
200
180
|
requirements:
|
201
181
|
- - ">="
|
202
182
|
- !ruby/object:Gem::Version
|
203
|
-
hash: -
|
183
|
+
hash: -2148067506136069246
|
204
184
|
segments:
|
205
185
|
- 0
|
206
186
|
version: "0"
|