widget_list 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +8 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/widget_list.iml +10 -0
- data/.idea/workspace.xml +579 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +2 -7
- data/Rakefile +0 -0
- data/lib/extensions/action_controller_base.rb +33 -0
- data/lib/widget_list.rb +0 -0
- data/lib/widget_list/engine.rb +8 -0
- data/lib/widget_list/hash.rb +78 -0
- data/lib/widget_list/md5.rb +0 -0
- data/lib/widget_list/railtie.rb +32 -0
- data/lib/widget_list/sequel.rb +151 -0
- data/lib/widget_list/string.rb +42 -0
- data/lib/widget_list/tpl.rb +186 -0
- data/lib/widget_list/utils.rb +85 -0
- data/lib/widget_list/version.rb +1 -1
- data/lib/widget_list/widgets.rb +732 -0
- data/vendor/assets/images/buttons/regular/green/leftside-regular-btn.png +0 -0
- data/vendor/assets/images/buttons/regular/green/rightside-regular-btn.png +0 -0
- data/vendor/assets/images/buttons/small/green/leftside-small-btn.png +0 -0
- data/vendor/assets/images/buttons/small/green/rightside-small-btn.png +0 -0
- data/vendor/assets/images/catbar-bg.png +0 -0
- data/vendor/assets/images/gobblecons/README.rtf +128 -0
- data/vendor/assets/images/gobblecons/black/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/black/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-24(2).png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-square-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-triangle-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/dark-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/light-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/add-small-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-square-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-triangle-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/lime/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/download-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-16-alt.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/search-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/search-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/mid-gray/trash-34.png +0 -0
- data/vendor/assets/images/gobblecons/orange/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/orange/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/orange/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/purple/add-16.png +0 -0
- data/vendor/assets/images/gobblecons/purple/add-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/red-orange/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/super-dark-gray/trash-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/add-circle-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/add-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/down-arrow-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/down-arrow-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/edit-34.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-solid-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/export-solid-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-arrows-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-circle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-square-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/share-triangle-24.png +0 -0
- data/vendor/assets/images/gobblecons/teal/trash-16.png +0 -0
- data/vendor/assets/images/gobblecons/teal/trash-24.png +0 -0
- data/vendor/assets/images/grad.png +0 -0
- data/vendor/assets/images/input_text_left.png +0 -0
- data/vendor/assets/images/input_text_right.png +0 -0
- data/vendor/assets/images/list-loader.gif +0 -0
- data/vendor/assets/images/long-text.jpg +0 -0
- data/vendor/assets/images/page-back.gif +0 -0
- data/vendor/assets/images/page-next.gif +0 -0
- data/vendor/assets/images/select-multiple-left.png +0 -0
- data/vendor/assets/images/select-multiple-right.png +0 -0
- data/vendor/assets/images/select-multiple.gif +0 -0
- data/vendor/assets/images/text-field-long.gif +0 -0
- data/vendor/assets/images/text-field-medium-notes.gif +0 -0
- data/vendor/assets/images/text-field-medium-tiny.gif +0 -0
- data/vendor/assets/images/text-field-shipping.gif +0 -0
- data/vendor/assets/images/text-field-small.gif +0 -0
- data/vendor/assets/images/text-field-tiny.gif +0 -0
- data/vendor/assets/images/text-field.gif +0 -0
- data/vendor/assets/images/th_header.gif +0 -0
- data/vendor/assets/javascripts/widget_list.js +696 -0
- data/vendor/assets/stylesheets/widget_list.css +775 -0
- data/vendor/assets/stylesheets/widgets.css +117 -0
- metadata +241 -1
data/Gemfile
CHANGED
File without changes
|
data/LICENSE.txt
CHANGED
File without changes
|
data/README.md
CHANGED
@@ -51,14 +51,9 @@ Or install it yourself as:
|
|
51
51
|
|
52
52
|
### #2 - Run bundle exec rails s to have widget_list create config/widget-list.yml
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
*= require widget_list
|
57
|
-
*= require widgets
|
54
|
+
Configure your connection settings for your primary or secondary widget_list connections.
|
58
55
|
|
59
|
-
|
60
|
-
|
61
|
-
//= require widget_list
|
56
|
+
http://sequel.rubyforge.org/rdoc/files/doc/opening_databases_rdoc.html
|
62
57
|
|
63
58
|
### Example Calling Page That Sets up Config and calls WidgetList.render
|
64
59
|
|
data/Rakefile
CHANGED
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
|
3
|
+
ActionController::Base.class_eval {
|
4
|
+
private
|
5
|
+
def globalize_request
|
6
|
+
# Create super global PHP variables
|
7
|
+
$_SESSION = self.session
|
8
|
+
$_SERVER = self.env
|
9
|
+
$_REQUEST = self.request.filtered_parameters
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
def store_session
|
14
|
+
# Store pre-defined widget_list session items to the actual session
|
15
|
+
|
16
|
+
%w(pageDisplayLimit DRILL_DOWNS DRILL_DOWNS ROW_LIMIT list_checks SEARCH_FILTER LIST_SEQUENCE LIST_COL_SORT list_count DRILL_DOWNS 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
|
+
|
data/lib/widget_list.rb
CHANGED
File without changes
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
# Merges self with another hash, recursively.
|
4
|
+
#
|
5
|
+
# This code was lovingly stolen from some random gem:
|
6
|
+
# http://gemjack.com/gems/tartan-0.1.1/classes/Hash.html
|
7
|
+
#
|
8
|
+
# Thanks to whoever made it.
|
9
|
+
|
10
|
+
def deep_merge(hash)
|
11
|
+
target = dup
|
12
|
+
|
13
|
+
hash.keys.each do |key|
|
14
|
+
if hash[key].is_a? Hash and self[key].is_a? Hash
|
15
|
+
target[key] = target[key].deep_merge(hash[key])
|
16
|
+
next
|
17
|
+
end
|
18
|
+
|
19
|
+
target[key] = hash[key]
|
20
|
+
end
|
21
|
+
|
22
|
+
target
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
# From: http://www.gemtacular.com/gemdocs/cerberus-0.2.2/doc/classes/Hash.html
|
27
|
+
# File lib/cerberus/utils.rb, line 42
|
28
|
+
|
29
|
+
def deep_merge!(second)
|
30
|
+
second.each_pair do |k,v|
|
31
|
+
if self[k].is_a?(Hash) and second[k].is_a?(Hash)
|
32
|
+
self[k].deep_merge!(second[k])
|
33
|
+
else
|
34
|
+
self[k] = second[k]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
#-----------------
|
41
|
+
|
42
|
+
# cf. http://subtech.g.hatena.ne.jp/cho45/20061122
|
43
|
+
def deep_merge2(other)
|
44
|
+
deep_proc = Proc.new { |k, s, o|
|
45
|
+
if s.kind_of?(Hash) && o.kind_of?(Hash)
|
46
|
+
next s.merge(o, &deep_proc)
|
47
|
+
end
|
48
|
+
next o
|
49
|
+
}
|
50
|
+
merge(other, &deep_proc)
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def deep_merge3(second)
|
55
|
+
|
56
|
+
# From: http://www.ruby-forum.com/topic/142809
|
57
|
+
# Author: Stefan Rusterholz
|
58
|
+
|
59
|
+
merger = proc { |key,v1,v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
|
60
|
+
self.merge(second, &merger)
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
|
65
|
+
def keep_merge(hash)
|
66
|
+
target = dup
|
67
|
+
hash.keys.each do |key|
|
68
|
+
if hash[key].is_a? Hash and self[key].is_a? Hash
|
69
|
+
target[key] = target[key].keep_merge(hash[key])
|
70
|
+
next
|
71
|
+
end
|
72
|
+
#target[key] = hash[key]
|
73
|
+
target.update(hash) { |key, *values| values.flatten.uniq }
|
74
|
+
end
|
75
|
+
target
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
data/lib/widget_list/md5.rb
CHANGED
File without changes
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module WidgetList
|
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: mysql://root:root@localhost:3306/my_database\n")
|
18
|
+
file.write(" :secondary: mysql://root:root@localhost:3306/my_database\n")
|
19
|
+
file.write("\n")
|
20
|
+
file.write("release:\n")
|
21
|
+
file.write(" :primary: mysql://root:root@localhost:3306/my_database\n")
|
22
|
+
file.write(" :secondary: mysql://root:root@localhost:3306/my_database\n")
|
23
|
+
file.write("\n")
|
24
|
+
file.write("production:\n")
|
25
|
+
file.write(" :primary: mysql://root:root@localhost:3306/my_database\n")
|
26
|
+
file.write(" :secondary: mysql://root:root@localhost:3306/my_database\n")
|
27
|
+
}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,151 @@
|
|
1
|
+
module Sequel
|
2
|
+
class Database
|
3
|
+
@final_results = {}
|
4
|
+
attr_accessor :final_results
|
5
|
+
|
6
|
+
@errors = false
|
7
|
+
attr_accessor :errors
|
8
|
+
|
9
|
+
@last_error = ''
|
10
|
+
attr_accessor :last_error
|
11
|
+
|
12
|
+
@final_count = 0
|
13
|
+
attr_accessor :final_count
|
14
|
+
|
15
|
+
@last_sql = ''
|
16
|
+
attr_accessor :last_sql
|
17
|
+
|
18
|
+
def _convert_bind(bind=[])
|
19
|
+
parameters = ''
|
20
|
+
unless bind.empty?
|
21
|
+
all = []
|
22
|
+
(bind||{}).each { |v|
|
23
|
+
if v.class.name.downcase == 'string'
|
24
|
+
all << "'" + v.gsub(/'/,"\\\\'") + "'"
|
25
|
+
else
|
26
|
+
all << v
|
27
|
+
end
|
28
|
+
}
|
29
|
+
parameters = "," + all.join(' ,')
|
30
|
+
end
|
31
|
+
parameters
|
32
|
+
end
|
33
|
+
|
34
|
+
# _exec, pass a block and iterate the total rows
|
35
|
+
#
|
36
|
+
# example
|
37
|
+
#
|
38
|
+
=begin
|
39
|
+
$DATABASE._exec {|i|
|
40
|
+
asdf = "#{WidgetList::List.get_database.final_results['NAME'][i]}"
|
41
|
+
}
|
42
|
+
=end
|
43
|
+
#
|
44
|
+
# Alternatively you could
|
45
|
+
=begin
|
46
|
+
WidgetList::List.get_database.final_results['ID'].each_with_index { |id,k|
|
47
|
+
name = WidgetList::List.get_database.final_results['NAME'][k]
|
48
|
+
price = WidgetList::List.get_database.final_results['PRICE'][k]
|
49
|
+
}
|
50
|
+
=end
|
51
|
+
|
52
|
+
def _exec
|
53
|
+
if block_given?
|
54
|
+
WidgetList::List.get_database.final_count.times {|i|
|
55
|
+
yield i
|
56
|
+
}
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def _determine_type(sql_or_obj)
|
61
|
+
if sql_or_obj.class.name.downcase != 'string' && sql_or_obj.class.name.to_s.split('::').last.downcase == 'dataset'
|
62
|
+
sql = sql_or_obj.get_sql()
|
63
|
+
elsif sql_or_obj.class.name.downcase == 'string'
|
64
|
+
sql = sql_or_obj
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# probably not needed really
|
69
|
+
def _update(sql_or_obj,bind={})
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
# @param [Object] replace_in_query
|
74
|
+
def _bind(sql='',replace_in_query={})
|
75
|
+
if !replace_in_query.empty? && replace_in_query.class.name == 'Hash'
|
76
|
+
tmp = {}
|
77
|
+
replace_in_query.each { |k, v|
|
78
|
+
new_key = ':' + k.to_s
|
79
|
+
tmp[ new_key ] = v
|
80
|
+
}
|
81
|
+
sql = WidgetList::Utils::fill(tmp, sql)
|
82
|
+
end
|
83
|
+
sql
|
84
|
+
end
|
85
|
+
|
86
|
+
# @param [Object or String] sql_or_obj
|
87
|
+
# will either take raw SQL or a Sequel object
|
88
|
+
# @param [Array] bind
|
89
|
+
# will be replacements for ? ? in your query. Must be in sequence
|
90
|
+
# @param [Hash] replace_in_query
|
91
|
+
# will be a traditional php bind hash {'BIND'=>'value'}. which will replace :BIND in the query. thanks mwild
|
92
|
+
|
93
|
+
def _select(sql_or_obj, bind=[], replace_in_query={})
|
94
|
+
# supporting either
|
95
|
+
# if WidgetList::List.get_database._select('select * from items where name = ? AND price > ?', ['abc', 37]) > 0
|
96
|
+
# or
|
97
|
+
# if WidgetList::List.get_database._select(WidgetList::List.get_database[:items].filter(:name => 'abc')) > 0
|
98
|
+
#
|
99
|
+
sql = ''
|
100
|
+
sql = _determine_type(sql_or_obj)
|
101
|
+
|
102
|
+
# build csv of bind to eval below (arguments need to be like this for raw SQL passed with bind in Sequel)
|
103
|
+
#
|
104
|
+
parameters = _convert_bind(bind)
|
105
|
+
|
106
|
+
# escape anything incoming in raw SQL such as bound items to create the ruby string to pass
|
107
|
+
#
|
108
|
+
sql.gsub!(/'/,"\\\\'")
|
109
|
+
|
110
|
+
sql = _bind(sql,replace_in_query)
|
111
|
+
|
112
|
+
# build rows array['COLUMN'][0] = 1234;
|
113
|
+
#
|
114
|
+
first = 1
|
115
|
+
cnt = 0
|
116
|
+
WidgetList::List.get_database.final_results = {}
|
117
|
+
|
118
|
+
Rails.logger.info(sql)
|
119
|
+
|
120
|
+
eval("
|
121
|
+
begin
|
122
|
+
WidgetList::List.get_database.errors = false
|
123
|
+
WidgetList::List.get_database['" + sql + "' " + parameters + "].each { |row|
|
124
|
+
cnt += 1
|
125
|
+
row.each { |k,v|
|
126
|
+
if first == 1
|
127
|
+
WidgetList::List.get_database.final_results[k.to_s.upcase] = []
|
128
|
+
end
|
129
|
+
WidgetList::List.get_database.final_results[k.to_s.upcase] << v
|
130
|
+
}
|
131
|
+
first = 0
|
132
|
+
}
|
133
|
+
WidgetList::List.get_database.last_sql = WidgetList::List.get_database['" + sql + "' " + parameters + "].get_sql
|
134
|
+
rescue Exception => e
|
135
|
+
Rails.logger.info(e)
|
136
|
+
WidgetList::List.get_database.errors = true
|
137
|
+
WidgetList::List.get_database.last_error = e.to_s
|
138
|
+
WidgetList::List.get_database.last_sql = '" + sql + "' + \"\n\n\n\" + ' With Bind => ' + bind.inspect + ' And BindLegacy => ' + replace_in_query.inspect
|
139
|
+
end
|
140
|
+
")
|
141
|
+
WidgetList::List.get_database.final_count = cnt
|
142
|
+
return cnt
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
class Dataset
|
147
|
+
def get_sql
|
148
|
+
select_sql()
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class String
|
2
|
+
|
3
|
+
#ruby returns nil when nothing is stripped
|
4
|
+
def strip_or_self
|
5
|
+
tmp = self.strip!
|
6
|
+
if tmp.nil?
|
7
|
+
self
|
8
|
+
else
|
9
|
+
tmp
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def split_it(char)
|
14
|
+
tmp = self.split(char)
|
15
|
+
if tmp.nil?
|
16
|
+
[self]
|
17
|
+
else
|
18
|
+
tmp
|
19
|
+
end
|
20
|
+
end
|
21
|
+
=begin
|
22
|
+
def fill(pieces={})
|
23
|
+
WidgetList::Utils::fill(pieces,self)
|
24
|
+
end
|
25
|
+
=end
|
26
|
+
|
27
|
+
=begin
|
28
|
+
def [](*args)
|
29
|
+
obj = self.dup
|
30
|
+
unless obj.nil?
|
31
|
+
if args.first.class.name == 'Integer'
|
32
|
+
obj = []
|
33
|
+
else
|
34
|
+
obj = {}
|
35
|
+
end
|
36
|
+
obj[args.first]
|
37
|
+
end
|
38
|
+
obj
|
39
|
+
end
|
40
|
+
=end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
|
2
|
+
$G_TEMPLATE = {'widget' =>
|
3
|
+
{'required'=> '<div class="required">*</div>'
|
4
|
+
}
|
5
|
+
}
|
6
|
+
|
7
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
8
|
+
{'input'=>
|
9
|
+
{'default' =>
|
10
|
+
'
|
11
|
+
<div class="<!--OUTER_CLASS-->" style="<!--OUTER_STYLE-->" id="<!--OUTER_ID-->">
|
12
|
+
<div class="<!--INNER_CLASS-->" style="<!--INNER_STYLE-->">
|
13
|
+
<input <!--EVENT_ATTRIBUTES--> <!--READONLY--> type="<!--INPUT_TYPE-->" class="<!--INPUT_CLASS-->" style="<!--INPUT_STYLE-->" id="<!--ID-->" name="<!--NAME-->" title="<!--TITLE-->" value="<!--VALUE-->" maxlength="<!--MAX_LENGTH-->">
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
<!--REQUIRED-->'
|
17
|
+
}
|
18
|
+
}
|
19
|
+
})
|
20
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
21
|
+
{'input'=>
|
22
|
+
{'search' =>
|
23
|
+
'
|
24
|
+
<div class="<!--OUTER_CLASS-->" style="<!--OUTER_STYLE-->" onclick="<!--OUTER_ACTION-->">
|
25
|
+
<div class="<!--INNER_CLASS-->" style="<!--INNER_STYLE-->">
|
26
|
+
<input <!--READONLY--> <!--EVENT_ATTRIBUTES--> type="text" class="<!--INPUT_CLASS-->" style="<!--INPUT_STYLE-->" id="<!--ID-->" name="<!--NAME-->" title="<!--TITLE-->" value="<!--VALUE-->" maxlength="<!--MAX_LENGTH-->">
|
27
|
+
</div>
|
28
|
+
<div class="widget-search-arrow <!--ARROW_EXTRA_CLASS-->" onclick="<!--ARROW_ACTION-->"></div>
|
29
|
+
<!--MAGNIFIER-->
|
30
|
+
<div id="<!--ID-->_results" class="widget-search-drilldown" style="">
|
31
|
+
<div class="widget-search-content"><!--SEARCH_FORM--></div>
|
32
|
+
</div>
|
33
|
+
</div>'
|
34
|
+
}
|
35
|
+
}
|
36
|
+
})
|
37
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
38
|
+
{'radio'=>
|
39
|
+
{'default' =>
|
40
|
+
'
|
41
|
+
<input type="radio" class="<!--INPUT_CLASS-->" style="<!--INPUT_STYLE-->" id="<!--ID-->" name="<!--NAME-->" title="<!--TITLE-->" value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--CHECKED-->>
|
42
|
+
<!--REQUIRED-->'
|
43
|
+
}
|
44
|
+
}
|
45
|
+
})
|
46
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
47
|
+
{'checkbox'=>
|
48
|
+
{'default' =>
|
49
|
+
'
|
50
|
+
<input type="checkbox" class="<!--INPUT_CLASS-->" style="<!--INPUT_STYLE-->" id="<!--ID-->" name="<!--NAME-->" value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--CHECKED-->>
|
51
|
+
<!--REQUIRED-->'
|
52
|
+
}
|
53
|
+
}
|
54
|
+
})
|
55
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
56
|
+
{'selectbox_nostyle'=>
|
57
|
+
{'wrapper' =>
|
58
|
+
'
|
59
|
+
<select <!--DISABLED_FLG--> class="<!--CLASS-->" id="<!--ID-->" style="<!--STYLE-->" name="<!--NAME-->" <!--MULTIPLE--> size="<!--SIZE-->" onchange="<!--ONCHANGE-->" <!--ATTRIBUTES-->><!--OPTIONS--></select> <!--REQUIRED-->'
|
60
|
+
}
|
61
|
+
}
|
62
|
+
})
|
63
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
64
|
+
{'selectbox'=>
|
65
|
+
{'wrapper' =>
|
66
|
+
'
|
67
|
+
<div class="<!--OUTER_CLASS-->" style="<!--OUTER_STYLE-->" onclick="<!--OUTER_ACTION-->">
|
68
|
+
<div class="<!--INNER_CLASS-->" style="<!--INNER_STYLE-->">
|
69
|
+
<select border="0" <!--DISABLED_FLG--> class="<!--CLASS-->" id="<!--ID-->" style="<!--STYLE-->" name="<!--NAME-->" <!--MULTIPLE--> size="<!--SIZE-->" onchange="<!--ONCHANGE-->" <!--ATTRIBUTES-->><!--OPTIONS--></select>
|
70
|
+
</div>
|
71
|
+
</div>
|
72
|
+
<!--REQUIRED-->'
|
73
|
+
}
|
74
|
+
}
|
75
|
+
})
|
76
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
77
|
+
{'selectbox'=>
|
78
|
+
{'option' =>
|
79
|
+
'
|
80
|
+
<option value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--SELECTED-->><!--CONTENT--></option>'
|
81
|
+
}
|
82
|
+
}
|
83
|
+
})
|
84
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
85
|
+
{'selectbox'=>
|
86
|
+
{'option_showid' =>
|
87
|
+
'<option value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--SELECTED-->><!--CONTENT--> (<!--VALUE-->)</option>'
|
88
|
+
}
|
89
|
+
}
|
90
|
+
})
|
91
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
92
|
+
{'selectbox'=>
|
93
|
+
{'option_showid_left' =>
|
94
|
+
'<option value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--SELECTED-->>(<!--VALUE-->) <!--CONTENT--></option>'
|
95
|
+
}
|
96
|
+
}
|
97
|
+
})
|
98
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
99
|
+
{'selectbox'=>
|
100
|
+
{'initial' =>
|
101
|
+
'
|
102
|
+
<option value="<!--VALUE-->" onclick="<!--ONCLICK-->" <!--SELECTED-->><!--CONTENT--></option>'
|
103
|
+
}
|
104
|
+
}
|
105
|
+
})
|
106
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
107
|
+
{'selectbox'=>
|
108
|
+
{'passive' =>
|
109
|
+
'
|
110
|
+
<span class="<!--CLASS-->" id="<!--ID-->" name="<!--NAME-->" size="<!--SIZE-->" <!--ATTRIBUTES-->><!--OPTIONS--></span>'
|
111
|
+
}
|
112
|
+
}
|
113
|
+
})
|
114
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
115
|
+
{'selectfreeflow'=>
|
116
|
+
{'wrapper' =>
|
117
|
+
'
|
118
|
+
<div class="<!--OUTER_CLASS-->" style="<!--OUTER_STYLE-->" onclick="<!--OUTER_ACTION-->">
|
119
|
+
<div class="<!--INNER_CLASS-->" style="<!--INNER_STYLE-->">
|
120
|
+
<!--SELECT_ONE_TEXT-->
|
121
|
+
</div>
|
122
|
+
<div class="widget-select-freeflow-arrow <!--ARROW_EXTRA_CLASS-->" style="" onclick="<!--ARROW_ACTION-->"></div>
|
123
|
+
|
124
|
+
<div id="select_freeflow_<!--ID-->" class="widget-select-freeflow-drilldown">
|
125
|
+
<ul class="widget-select-freeflow-content">
|
126
|
+
<!--OPTIONS-->
|
127
|
+
</ul>
|
128
|
+
</div>
|
129
|
+
</div>'
|
130
|
+
}
|
131
|
+
}
|
132
|
+
})
|
133
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
134
|
+
{'selectfreeflow'=>
|
135
|
+
{'option' =>
|
136
|
+
'
|
137
|
+
<li onclick="<!--ONCLICK-->" class="<!--SELECTED-->">
|
138
|
+
<input type="hidden" name="select_free_option_name<!--NAME-->[]" name="select_option_<!--NAME-->_id_<!--COUNTER-->" value="<!--VALUE-->">
|
139
|
+
<!--CONTENT-->
|
140
|
+
</li>'
|
141
|
+
}
|
142
|
+
}
|
143
|
+
})
|
144
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
145
|
+
{'button'=>
|
146
|
+
{'default' =>
|
147
|
+
'
|
148
|
+
<!--FRM_SUBMIT-->
|
149
|
+
<a class="<!--BUTTON_CLASS-->" style="<!--BUTTON_STYLE-->" onclick="<!--BUTTON_ONCLICK-->" name="<!--NAME-->" id="<!--ID-->">
|
150
|
+
<!--BUTTON_LABEL-->
|
151
|
+
</a>'
|
152
|
+
}
|
153
|
+
}
|
154
|
+
})
|
155
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
156
|
+
{'container'=>
|
157
|
+
{'row' =>
|
158
|
+
'<tr><!--CONTENT--></tr>'
|
159
|
+
}
|
160
|
+
}
|
161
|
+
})
|
162
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
163
|
+
{'container'=>
|
164
|
+
{'col' =>
|
165
|
+
{'pre_text' =>
|
166
|
+
'<td colspan="<!--COL_SPAN-->" id="<!--ID-->" class="<!--CLASS-->"><div class="container-label"><!--PRE_TEXT--></div> <!--CONTENT--></td>'
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
})
|
171
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
172
|
+
{'container'=>
|
173
|
+
{'col' =>
|
174
|
+
{'standard' =>
|
175
|
+
'<td colspan="<!--COL_SPAN-->" id="<!--ID-->" class="<!--CLASS-->"><!--CONTENT--></td>'
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
})
|
180
|
+
$G_TEMPLATE.deep_merge!({'widget' =>
|
181
|
+
{'container'=>
|
182
|
+
{'wrapper' =>
|
183
|
+
'<form method="post" id="<!--FORM_ID-->"><table class="<!--OUTER_CLASS-->" id="<!--OUTER_ID-->"><!--CONTENT--></table>'
|
184
|
+
}
|
185
|
+
}
|
186
|
+
})
|