widget_list 1.3.6 → 2.0.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.
- checksums.yaml +5 -13
- data/README.md +98 -711
- data/checkin_gem.sh +10 -10
- data/docs/legacy-readme.md +757 -0
- data/lib/extensions/action_controller_base.rb +21 -29
- data/lib/widget_list/engine.rb +1 -4
- data/lib/widget_list/railtie.rb +10 -33
- data/lib/widget_list/request_context.rb +5 -0
- data/lib/widget_list/sequel.rb +17 -41
- data/lib/widget_list/utils.rb +7 -7
- data/lib/widget_list/version.rb +1 -1
- data/lib/widget_list/widgets.rb +1 -2
- data/lib/widget_list.rb +217 -216
- data/publish_gem.sh +14 -35
- data/vendor/assets/stylesheets/{widget_list.css → widget_list.css.erb} +21 -21
- data/vendor/assets/stylesheets/{widgets.css → widgets.css.erb} +9 -9
- data/widget_list.gemspec +8 -10
- metadata +40 -28
|
@@ -1,33 +1,25 @@
|
|
|
1
1
|
require 'action_controller'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
module WidgetList
|
|
4
|
+
module ControllerContext
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def with_widget_list_request_context
|
|
8
|
+
RequestContext.session = session.to_h.deep_dup
|
|
9
|
+
RequestContext.server = request.env
|
|
10
|
+
RequestContext.request = request.filtered_parameters
|
|
11
|
+
|
|
12
|
+
yield
|
|
13
|
+
ensure
|
|
14
|
+
if RequestContext.used && RequestContext.session
|
|
15
|
+
%w[pageDisplayLimit DRILL_DOWNS CURRENT_GROUPING ROW_LIMIT list_checks SEARCH_FILTER LIST_SEQUENCE LIST_COL_SORT list_count DRILL_DOWN_FILTERS].each do |key|
|
|
16
|
+
session[key] = RequestContext.session[key] if RequestContext.session.key?(key)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
RequestContext.reset
|
|
10
20
|
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
11
23
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
# Store pre-defined widget_list session items to the actual session
|
|
15
|
-
|
|
16
|
-
%w(pageDisplayLimit DRILL_DOWNS CURRENT_GROUPING ROW_LIMIT list_checks SEARCH_FILTER LIST_SEQUENCE LIST_COL_SORT list_count DRILL_DOWN_FILTERS).each { |key|
|
|
17
|
-
self.session[key] = $_SESSION[key]
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
test= 1
|
|
21
|
-
end
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
ActionController::Base.instance_eval {
|
|
25
|
-
helper_method :globalize_request
|
|
26
|
-
|
|
27
|
-
helper_method :store_session
|
|
28
|
-
|
|
29
|
-
before_filter :globalize_request
|
|
30
|
-
|
|
31
|
-
after_filter :store_session
|
|
32
|
-
}
|
|
33
|
-
|
|
24
|
+
ActionController::Base.include(WidgetList::ControllerContext)
|
|
25
|
+
ActionController::Base.around_action :with_widget_list_request_context
|
data/lib/widget_list/engine.rb
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
module WidgetList
|
|
2
2
|
class Engine < Rails::Engine
|
|
3
|
-
#
|
|
4
|
-
initializer 'widget_list.load_static_assets' do |app|
|
|
5
|
-
app.middleware.use ::ActionDispatch::Static, "#{root}/vendor"
|
|
6
|
-
end
|
|
3
|
+
# Rails discovers gem assets in vendor/assets through its asset pipeline.
|
|
7
4
|
end
|
|
8
5
|
end
|
data/lib/widget_list/railtie.rb
CHANGED
|
@@ -1,42 +1,19 @@
|
|
|
1
1
|
module WidgetList
|
|
2
2
|
class Railtie < Rails::Railtie
|
|
3
|
-
|
|
4
|
-
config.before_configuration do
|
|
5
|
-
config_file = Rails.root.join("config", "widget-list.yml")
|
|
6
|
-
if config_file.file?
|
|
7
|
-
# WidgetList::List::connect
|
|
8
|
-
else
|
|
9
|
-
puts "\nWidget List config not found. Creating config/widget-list.yml. \n\nPlease configure it with the appropriate connections"
|
|
10
|
-
File.open(Rails.root.join("config", "widget-list.yml"), 'w') { |file|
|
|
11
|
-
file.write("#For connection examples see: http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html\n\n")
|
|
12
|
-
file.write("development:\n")
|
|
13
|
-
file.write(" :primary: sqlite:/\n")
|
|
14
|
-
file.write(" :secondary: sqlite:/\n")
|
|
15
|
-
file.write("\n")
|
|
16
|
-
file.write("test:\n")
|
|
17
|
-
file.write(" :primary: sqlite:/\n")
|
|
18
|
-
file.write(" :secondary: sqlite:/\n")
|
|
19
|
-
file.write("\n")
|
|
20
|
-
file.write("release:\n")
|
|
21
|
-
file.write(" :primary: sqlite:/\n")
|
|
22
|
-
file.write(" :secondary: sqlite:/\n")
|
|
23
|
-
file.write("\n")
|
|
24
|
-
file.write("production:\n")
|
|
25
|
-
file.write(" :primary: sqlite:/\n")
|
|
26
|
-
file.write(" :secondary: sqlite:/\n")
|
|
27
|
-
}
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
initializer "Include widget_list" do
|
|
3
|
+
initializer 'widget_list.database_adapters' do
|
|
32
4
|
ActiveSupport.on_load(:action_controller) do
|
|
33
|
-
|
|
34
|
-
require 'sequel'
|
|
35
|
-
end
|
|
5
|
+
require 'sequel'
|
|
36
6
|
require 'widget_list/sequel'
|
|
37
7
|
end
|
|
38
8
|
end
|
|
39
9
|
|
|
40
|
-
|
|
10
|
+
initializer 'widget_list.assets' do |app|
|
|
11
|
+
if defined?(Sprockets::Railtie) && app.config.respond_to?(:assets)
|
|
12
|
+
image_root = Pathname.new(__dir__).join('../..', 'vendor/assets/images').expand_path
|
|
13
|
+
images = Dir[image_root.join('**/*')].select { |path| File.file?(path) && %w[.gif .jpg .jpeg .png].include?(File.extname(path).downcase) }
|
|
14
|
+
app.config.assets.precompile += images.map { |path| Pathname.new(path).relative_path_from(image_root).to_s }
|
|
15
|
+
app.config.assets.precompile += %w[widget_list.css widgets.css widget_list.js]
|
|
16
|
+
end
|
|
17
|
+
end
|
|
41
18
|
end
|
|
42
19
|
end
|
data/lib/widget_list/sequel.rb
CHANGED
|
@@ -111,32 +111,14 @@ module Sequel
|
|
|
111
111
|
# or
|
|
112
112
|
# if get_database._select(get_database[:items].filter(:name => 'abc')) > 0
|
|
113
113
|
#
|
|
114
|
-
sql = ''
|
|
115
114
|
sql = _determine_type(sql_or_obj)
|
|
116
|
-
|
|
117
|
-
if self.class.name != 'WidgetListActiveRecord'
|
|
118
|
-
|
|
119
|
-
# build csv of bind to eval below (arguments need to be like this for raw SQL passed with bind in Sequel)
|
|
120
|
-
#
|
|
121
|
-
parameters = _convert_bind(bind)
|
|
122
|
-
|
|
123
|
-
# escape anything incoming in raw SQL such as bound items to create the ruby string to pass
|
|
124
|
-
#
|
|
125
|
-
sql.gsub!(/'/,"\\\\'")
|
|
126
|
-
else
|
|
127
|
-
|
|
128
|
-
_convert_active_record_bind(sql, bind)
|
|
129
|
-
|
|
130
|
-
end
|
|
131
|
-
|
|
132
115
|
sql = _bind(sql,replace_in_query)
|
|
133
116
|
|
|
134
117
|
# build rows array['COLUMN'][0] = 1234;
|
|
135
118
|
#
|
|
136
|
-
first = 1
|
|
137
119
|
cnt = 0
|
|
138
|
-
tmp = nil
|
|
139
120
|
@final_results = {}
|
|
121
|
+
@errors = false
|
|
140
122
|
if Rails.env == 'development'
|
|
141
123
|
Rails.logger.info(sql)
|
|
142
124
|
end
|
|
@@ -194,7 +176,7 @@ module Sequel
|
|
|
194
176
|
results = active_record_model.all.to_a if active_record_model.respond_to?('all')
|
|
195
177
|
results = active_record_model.to_a if active_record_model.respond_to?('to_a') && !group_match.nil?
|
|
196
178
|
else
|
|
197
|
-
results = active_record_model.find_by_sql(sql)
|
|
179
|
+
results = active_record_model.find_by_sql(bind.empty? ? sql : [sql, *bind])
|
|
198
180
|
end
|
|
199
181
|
|
|
200
182
|
(results||[]).each { |row|
|
|
@@ -232,27 +214,21 @@ module Sequel
|
|
|
232
214
|
@last_sql = sql_or_obj
|
|
233
215
|
end
|
|
234
216
|
else
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
@final_results[k.to_s.upcase] = []
|
|
243
|
-
end
|
|
244
|
-
@final_results[k.to_s.upcase] << v
|
|
245
|
-
}
|
|
246
|
-
first = 0
|
|
247
|
-
}
|
|
248
|
-
@last_sql = self['" + sql + "' " + parameters + "].get_sql
|
|
249
|
-
rescue Exception => e
|
|
250
|
-
Rails.logger.info(e)
|
|
251
|
-
@errors = true
|
|
252
|
-
@last_error = e.to_s
|
|
253
|
-
@last_sql = '" + sql + "' + \"\n\n\n\" + ' With Bind => ' + bind.inspect + ' And BindLegacy => ' + replace_in_query.inspect
|
|
217
|
+
begin
|
|
218
|
+
dataset = sql_or_obj.is_a?(Sequel::Dataset) ? sql_or_obj : fetch(sql, *bind)
|
|
219
|
+
dataset.each do |row|
|
|
220
|
+
cnt += 1
|
|
221
|
+
row.each do |key, value|
|
|
222
|
+
(@final_results[key.to_s.upcase] ||= []) << value
|
|
223
|
+
end
|
|
254
224
|
end
|
|
255
|
-
|
|
225
|
+
@last_sql = dataset.sql
|
|
226
|
+
rescue StandardError => e
|
|
227
|
+
Rails.logger.info(e)
|
|
228
|
+
@errors = true
|
|
229
|
+
@last_error = e.to_s
|
|
230
|
+
@last_sql = "#{sql}\nWith Bind => #{bind.inspect} And BindLegacy => #{replace_in_query.inspect}"
|
|
231
|
+
end
|
|
256
232
|
end
|
|
257
233
|
@final_count = cnt
|
|
258
234
|
return cnt
|
|
@@ -285,4 +261,4 @@ class WidgetListActiveRecord < Sequel::Database
|
|
|
285
261
|
|
|
286
262
|
@last_sql = ''
|
|
287
263
|
attr_accessor :last_sql
|
|
288
|
-
end
|
|
264
|
+
end
|
data/lib/widget_list/utils.rb
CHANGED
|
@@ -25,10 +25,10 @@ module WidgetList
|
|
|
25
25
|
def self.build_query_string(args)
|
|
26
26
|
q = []
|
|
27
27
|
args.each { |k,v|
|
|
28
|
-
if v.
|
|
29
|
-
q << {k => v}.
|
|
28
|
+
if v.is_a?(Hash) || v.respond_to?(:to_unsafe_h)
|
|
29
|
+
q << {k => (v.respond_to?(:to_unsafe_h) ? v.to_unsafe_h : v)}.to_query
|
|
30
30
|
else
|
|
31
|
-
q << k.to_s + '=' + CGI.escape(
|
|
31
|
+
q << k.to_s + '=' + CGI.escape(v.to_s)
|
|
32
32
|
end
|
|
33
33
|
}
|
|
34
34
|
q.join('&')
|
|
@@ -39,8 +39,8 @@ module WidgetList
|
|
|
39
39
|
def self.build_url(page='',args = {}, append_get=false)
|
|
40
40
|
qs = build_query_string(args)
|
|
41
41
|
getvars = ''
|
|
42
|
-
if append_get &&
|
|
43
|
-
getvars = build_query_string(
|
|
42
|
+
if append_get && WidgetList::RequestContext.request
|
|
43
|
+
getvars = build_query_string(WidgetList::RequestContext.request)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
unless page =~ /\?/
|
|
@@ -54,7 +54,7 @@ module WidgetList
|
|
|
54
54
|
def self.fill(tags = {}, template = '')
|
|
55
55
|
tpl = template.dup
|
|
56
56
|
tags.each { |k,v|
|
|
57
|
-
tpl = tpl.gsub(k.to_s
|
|
57
|
+
tpl = tpl.gsub(k.to_s) { v.to_s }
|
|
58
58
|
}
|
|
59
59
|
tpl
|
|
60
60
|
end
|
|
@@ -92,4 +92,4 @@ module WidgetList
|
|
|
92
92
|
|
|
93
93
|
end
|
|
94
94
|
|
|
95
|
-
end
|
|
95
|
+
end
|
data/lib/widget_list/version.rb
CHANGED
data/lib/widget_list/widgets.rb
CHANGED
|
@@ -62,7 +62,6 @@ module WidgetList
|
|
|
62
62
|
'<!--VALUE-->' => items['value'],
|
|
63
63
|
'<!--REQUIRED-->' => items['template_required'],
|
|
64
64
|
'<!--CHECKED-->' => items['checked'],
|
|
65
|
-
'<!--VALUE-->' => items['value'],
|
|
66
65
|
'<!--DISABLED-->' => items['disabled']
|
|
67
66
|
}
|
|
68
67
|
|
|
@@ -761,4 +760,4 @@ end
|
|
|
761
760
|
# require 'widget_list/utils'
|
|
762
761
|
# require 'widget_list/hash'
|
|
763
762
|
# require 'widget_list/tpl'
|
|
764
|
-
# puts WidgetList::Widgets.test_all
|
|
763
|
+
# puts WidgetList::Widgets.test_all
|