rules_view 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.textile +129 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/app/views/layouts/rules_view.html.erb +43 -0
- data/app/views/re_view/template.html.erb +196 -0
- data/autotest/discover.rb +2 -0
- data/generators/install_generator.rb +41 -0
- data/generators/layout_generator.rb +41 -0
- data/generators/manifests/application.rb +116 -0
- data/generators/manifests/application.yml +8 -0
- data/generators/manifests/layout.rb +17 -0
- data/generators/manifests/layout.yml +5 -0
- data/generators/manifests/templates/app/views/layouts/rules_view_layout.html.erb +47 -0
- data/generators/manifests/templates/config/initializers/rules_view.rb +1 -0
- data/generators/manifests/templates/doc/README.rules_view +97 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery-1.4.2.min.js +154 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.autocomplete.pack.js +13 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.blockUI.js +486 -0
- data/generators/manifests/templates/public/javascripts/rules_view/jquery.fancybox-1.3.1.js +1077 -0
- data/generators/manifests/templates/public/javascripts/rules_view/re_view.js +148 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/ie.css +35 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/key.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/readme.txt +32 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/buttons/screen.css +97 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/fancy-type/screen.css +71 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/readme.txt +18 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/link-icons/screen.css +40 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/rtl/readme.txt +10 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/plugins/rtl/screen.css +110 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/print.css +29 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/screen.css +258 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/forms.css +65 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/grid.css +280 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/grid.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/ie.css +76 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/print.css +85 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/reset.css +45 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/blueprint/src/typography.css +106 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/blank.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_close.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_loading.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_nav_left.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_nav_right.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_e.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_n.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_ne.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_nw.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_s.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_se.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_sw.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_shadow_w.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_left.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_main.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_over.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancy_title_right.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox-x.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox-y.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/fancybox.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/fancybox/jquery.fancybox-1.3.1.css +363 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_box/shadowbox.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_box/whitebox.jpg +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/checked-off.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/checked-on.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/icon-add.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/icon-delete.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-add.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-remove.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/list-select.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-blue-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-blue-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-gray-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-gray-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-green-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-green-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-orange-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-orange-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-red-left.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_button/oval-red-right.gif +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_error/re-alert-close.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/images/re_view_navigate/breadcrumb.png +0 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/jquery.autocomplete.css +53 -0
- data/generators/manifests/templates/public/stylesheets/rules_view/rules_view.css +738 -0
- data/init.rb +1 -0
- data/lib/rules_view/alerts.rb +51 -0
- data/lib/rules_view/boxes.rb +25 -0
- data/lib/rules_view/buttons.rb +113 -0
- data/lib/rules_view/config.rb +21 -0
- data/lib/rules_view/defer.rb +30 -0
- data/lib/rules_view/engine.rb +28 -0
- data/lib/rules_view/form_builder.rb +62 -0
- data/lib/rules_view/form_fields.rb +41 -0
- data/lib/rules_view/form_styles.rb +112 -0
- data/lib/rules_view/model_loader.rb +64 -0
- data/lib/rules_view/navigate.rb +40 -0
- data/lib/rules_view.rb +20 -0
- data/rules_view.gemspec +239 -0
- data/spec/lib/rules_view/alerts_spec.rb +145 -0
- data/spec/lib/rules_view/boxes_spec.rb +49 -0
- data/spec/lib/rules_view/buttons_spec.rb +184 -0
- data/spec/lib/rules_view/defer_spec.rb +90 -0
- data/spec/lib/rules_view/form_builder_fields_spec.rb +184 -0
- data/spec/lib/rules_view/form_builder_spec.rb +19 -0
- data/spec/lib/rules_view/form_fields_spec.rb +219 -0
- data/spec/lib/rules_view/form_styles_spec.rb +290 -0
- data/spec/lib/rules_view/model_loader_spec.rb +202 -0
- data/spec/lib/rules_view/navigate_spec.rb +61 -0
- data/spec/rails_3_0_0_root/.gitignore +4 -0
- data/spec/rails_3_0_0_root/.rspec +1 -0
- data/spec/rails_3_0_0_root/Gemfile +13 -0
- data/spec/rails_3_0_0_root/Gemfile.lock +101 -0
- data/spec/rails_3_0_0_root/README +256 -0
- data/spec/rails_3_0_0_root/Rakefile +7 -0
- data/spec/rails_3_0_0_root/app/controllers/application_controller.rb +3 -0
- data/spec/rails_3_0_0_root/app/helpers/application_helper.rb +2 -0
- data/spec/rails_3_0_0_root/app/views/layouts/application.html.erb +14 -0
- data/spec/rails_3_0_0_root/autotest/discover.rb +2 -0
- data/spec/rails_3_0_0_root/config/application.rb +42 -0
- data/spec/rails_3_0_0_root/config/boot.rb +13 -0
- data/spec/rails_3_0_0_root/config/database.yml +22 -0
- data/spec/rails_3_0_0_root/config/environment.rb +5 -0
- data/spec/rails_3_0_0_root/config/environments/development.rb +26 -0
- data/spec/rails_3_0_0_root/config/environments/production.rb +49 -0
- data/spec/rails_3_0_0_root/config/environments/test.rb +35 -0
- data/spec/rails_3_0_0_root/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/rails_3_0_0_root/config/initializers/inflections.rb +10 -0
- data/spec/rails_3_0_0_root/config/initializers/mime_types.rb +5 -0
- data/spec/rails_3_0_0_root/config/initializers/secret_token.rb +7 -0
- data/spec/rails_3_0_0_root/config/initializers/session_store.rb +8 -0
- data/spec/rails_3_0_0_root/config/locales/en.yml +5 -0
- data/spec/rails_3_0_0_root/config/routes.rb +58 -0
- data/spec/rails_3_0_0_root/config.ru +4 -0
- data/spec/rails_3_0_0_root/db/seeds.rb +7 -0
- data/spec/rails_3_0_0_root/doc/README_FOR_APP +2 -0
- data/spec/rails_3_0_0_root/lib/tasks/.gitkeep +0 -0
- data/spec/rails_3_0_0_root/public/404.html +26 -0
- data/spec/rails_3_0_0_root/public/422.html +26 -0
- data/spec/rails_3_0_0_root/public/500.html +26 -0
- data/spec/rails_3_0_0_root/public/favicon.ico +0 -0
- data/spec/rails_3_0_0_root/public/images/rails.png +0 -0
- data/spec/rails_3_0_0_root/public/index.html +239 -0
- data/spec/rails_3_0_0_root/public/javascripts/application.js +2 -0
- data/spec/rails_3_0_0_root/public/javascripts/controls.js +965 -0
- data/spec/rails_3_0_0_root/public/javascripts/dragdrop.js +974 -0
- data/spec/rails_3_0_0_root/public/javascripts/effects.js +1123 -0
- data/spec/rails_3_0_0_root/public/javascripts/prototype.js +6001 -0
- data/spec/rails_3_0_0_root/public/javascripts/rails.js +175 -0
- data/spec/rails_3_0_0_root/public/robots.txt +5 -0
- data/spec/rails_3_0_0_root/public/stylesheets/.gitkeep +0 -0
- data/spec/rails_3_0_0_root/script/rails +6 -0
- data/spec/rails_3_0_0_root/spec/spec_helper.rb +27 -0
- data/spec/rails_3_0_0_root/vendor/plugins/.gitkeep +0 -0
- data/spec/spec_helper.rb +29 -0
- data/spec/support/create_memory_db.rb +2 -0
- data/tasks/rspec.rake +46 -0
- metadata +278 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Alerts
|
3
|
+
|
4
|
+
def re_alert
|
5
|
+
result = '<div id="re_alert">'.html_safe
|
6
|
+
|
7
|
+
unless flash[:error].blank?
|
8
|
+
result << '<div class="error"><strong>Error : </strong><span>'.html_safe
|
9
|
+
result << flash.delete(:error)
|
10
|
+
result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe
|
11
|
+
|
12
|
+
flash.delete(:success)
|
13
|
+
flash.delete(:notice)
|
14
|
+
end
|
15
|
+
|
16
|
+
unless flash[:success].blank?
|
17
|
+
result << '<div class="success"><strong>Success : </strong><span>'.html_safe
|
18
|
+
result << flash.delete(:success)
|
19
|
+
result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe
|
20
|
+
|
21
|
+
flash.delete(:notice)
|
22
|
+
end
|
23
|
+
|
24
|
+
unless flash[:notice].blank?
|
25
|
+
result << '<div class="notice"><strong>Warning : </strong><span>'.html_safe
|
26
|
+
result << flash.delete(:notice)
|
27
|
+
result << '</span><a class="re-alert-close" href="#">Close</a></div>'.html_safe
|
28
|
+
end
|
29
|
+
result << '</div>'.html_safe
|
30
|
+
|
31
|
+
return result
|
32
|
+
end
|
33
|
+
|
34
|
+
def re_alert_js
|
35
|
+
unless flash[:error].blank?
|
36
|
+
flash.delete(:success)
|
37
|
+
flash.delete(:notice)
|
38
|
+
return "$.re_error_message('".html_safe + escape_javascript(flash.delete(:error)) + "');".html_safe
|
39
|
+
end
|
40
|
+
unless flash[:success].blank?
|
41
|
+
flash.delete(:notice)
|
42
|
+
return "$.re_success_message('".html_safe + escape_javascript(flash.delete(:success)) + "');".html_safe
|
43
|
+
end
|
44
|
+
unless flash[:notice].blank?
|
45
|
+
return "$.re_notice_message('".html_safe + escape_javascript(flash.delete(:notice)) + "');".html_safe
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Boxes
|
3
|
+
def re_whitebox(&block)
|
4
|
+
result = ''.html_safe
|
5
|
+
result << '<div class="re-whitebox">'.html_safe
|
6
|
+
result << '<div class="re-whitebox-content">'.html_safe
|
7
|
+
result << capture(&block)
|
8
|
+
result << '<div class="clear"></div>'.html_safe
|
9
|
+
result << '</div>'.html_safe
|
10
|
+
result << '</div>'.html_safe
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
def re_shadowbox(&block)
|
15
|
+
result = ''.html_safe
|
16
|
+
result << '<div class="re-shadowbox-outer">'.html_safe
|
17
|
+
result << '<div class="re-shadowbox-inner">'.html_safe
|
18
|
+
result << capture(&block)
|
19
|
+
result << '<div class="clear"></div>'.html_safe
|
20
|
+
result << '</div>'.html_safe
|
21
|
+
result << '</div>'.html_safe
|
22
|
+
result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,113 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Buttons
|
3
|
+
|
4
|
+
def re_button_submit(title, color, options ={})
|
5
|
+
klass = "re-form-button-#{color} #{options[:class]}"
|
6
|
+
result = "<div class='re-form-button".html_safe
|
7
|
+
result << " span-#{options[:span]}" unless options[:span].blank?
|
8
|
+
result << "'>".html_safe
|
9
|
+
result << submit_tag(title, options.merge(:class=> klass).except(:span))
|
10
|
+
result << "</div>".html_safe
|
11
|
+
result
|
12
|
+
end
|
13
|
+
|
14
|
+
def re_button_submit_gray(title, options = {})
|
15
|
+
return re_button_submit(title, "gray", options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def re_button_submit_blue(title, options = {})
|
19
|
+
return re_button_submit(title, "blue", options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def re_button_submit_green(title, options = {})
|
23
|
+
return re_button_submit(title, "green", options)
|
24
|
+
end
|
25
|
+
|
26
|
+
def re_button_submit_orange(title, options = {})
|
27
|
+
return re_button_submit(title, "orange", options)
|
28
|
+
end
|
29
|
+
|
30
|
+
def re_button_submit_red(title, options = {})
|
31
|
+
return re_button_submit(title, "red", options)
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
def re_button_link(title, url, color, options = {})
|
36
|
+
klass = "re-form-button-#{color} #{options[:class]}"
|
37
|
+
result = "<div class='re-form-button".html_safe
|
38
|
+
result << " span-#{options[:span]}" unless options[:span].blank?
|
39
|
+
result << "'>".html_safe
|
40
|
+
result << link_to("<span>".html_safe + title + "</span>".html_safe, url, options.merge(:class=> klass).except(:span))
|
41
|
+
result << "</div>".html_safe
|
42
|
+
result
|
43
|
+
end
|
44
|
+
|
45
|
+
def re_button_link_gray(title, url, options = {})
|
46
|
+
return re_button_link(title, url, "gray", options)
|
47
|
+
end
|
48
|
+
|
49
|
+
def re_button_link_blue(title, url, options = {})
|
50
|
+
return re_button_link(title, url, "blue", options)
|
51
|
+
end
|
52
|
+
|
53
|
+
def re_button_link_green(title, url, options = {})
|
54
|
+
return re_button_link(title, url, "green", options)
|
55
|
+
end
|
56
|
+
|
57
|
+
def re_button_link_orange(title, url, options = {})
|
58
|
+
return re_button_link(title, url, "orange", options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def re_button_link_red(title, url, options = {})
|
62
|
+
return re_button_link(title, url, "red", options)
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
##############################
|
67
|
+
# nested buttons
|
68
|
+
def re_add_link(title, id)
|
69
|
+
link_to(title, "#", :class => 're-add-link', :id => "#{id}")
|
70
|
+
end
|
71
|
+
|
72
|
+
def re_remove_link(title, object_name, id)
|
73
|
+
return "" if id == 0
|
74
|
+
|
75
|
+
builder_id = object_name.gsub('[', '_').gsub(']', '')
|
76
|
+
link_to(title, "#", :class => 're-remove-link', :id => "#{builder_id}_remove")
|
77
|
+
end
|
78
|
+
|
79
|
+
def re_remove_field(object_name, id)
|
80
|
+
return "" if id == 0
|
81
|
+
|
82
|
+
builder_id = object_name.gsub('[', '_').gsub(']', '')
|
83
|
+
hidden_field_tag("#{object_name}[_delete]", "", :id => "#{builder_id}__delete")
|
84
|
+
end
|
85
|
+
|
86
|
+
#########################################################
|
87
|
+
## ADD and REMOVE BUTTONS
|
88
|
+
def re_button_add url, options = {}
|
89
|
+
klass = "re-button-add #{options[:class]}"
|
90
|
+
link_to("", url, options.merge(:class => klass))
|
91
|
+
end
|
92
|
+
|
93
|
+
def re_button_remove url, options = {}
|
94
|
+
klass = "re-button-remove #{options[:class]}"
|
95
|
+
link_to("", url, options.merge(:class => klass))
|
96
|
+
end
|
97
|
+
|
98
|
+
def re_button_select url, options = {}
|
99
|
+
klass = "re-button-select #{options[:class]}"
|
100
|
+
link_to("", url, options.merge(:class => klass))
|
101
|
+
end
|
102
|
+
|
103
|
+
def re_button_checked url, options = {}
|
104
|
+
klass = "re-button-checked #{options[:class]}"
|
105
|
+
link_to("", url, options.merge(:class => klass))
|
106
|
+
end
|
107
|
+
|
108
|
+
def re_button_unchecked url, options = {}
|
109
|
+
klass = "re-button-unchecked #{options[:class]}"
|
110
|
+
link_to("", url, options.merge(:class => klass))
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Config
|
3
|
+
|
4
|
+
@prefix_breadcrumbs = nil
|
5
|
+
def self.prefix_breadcrumbs
|
6
|
+
@prefix_breadcrumbs
|
7
|
+
end
|
8
|
+
def self.prefix_breadcrumbs=(prefix)
|
9
|
+
@prefix_breadcrumbs = prefix
|
10
|
+
end
|
11
|
+
|
12
|
+
@layout = nil
|
13
|
+
def self.layout
|
14
|
+
@layout
|
15
|
+
end
|
16
|
+
def self.layout=(layout)
|
17
|
+
@layout = layout
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Defer
|
3
|
+
|
4
|
+
def set_re_javascript_include(javascript_include_or_array)
|
5
|
+
content_for :defer_re_javascript_include do
|
6
|
+
javascript_include_tag(javascript_include_or_array)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_re_breadcrumbs(*crumbs)
|
11
|
+
content_for :defer_re_breadcrumbs do
|
12
|
+
if RulesView::Config.prefix_breadcrumbs
|
13
|
+
re_breadcrumbs(*([RulesView::Config.prefix_breadcrumbs] << crumbs).flatten)
|
14
|
+
else
|
15
|
+
re_breadcrumbs(*crumbs)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def set_re_breadcrumbs_right(*crumbs)
|
21
|
+
content_for :defer_re_breadcrumbs do
|
22
|
+
if RulesView::Config.prefix_breadcrumbs
|
23
|
+
re_breadcrumbs_right(*([RulesView::Config.prefix_breadcrumbs] + crumbs).flatten)
|
24
|
+
else
|
25
|
+
re_breadcrumbs_right(*crumbs)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rules_view"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module RulesView
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
|
7
|
+
initializer "rules_view.action_view" do |app|
|
8
|
+
ActionView::Base.send(:include, RulesView::Alerts)
|
9
|
+
ActionView::Base.send(:include, RulesView::Boxes)
|
10
|
+
ActionView::Base.send(:include, RulesView::Buttons)
|
11
|
+
ActionView::Base.send(:include, RulesView::Navigate)
|
12
|
+
ActionView::Base.send(:include, RulesView::Defer)
|
13
|
+
|
14
|
+
ActionView::Base.send(:include, RulesView::FormStyles)
|
15
|
+
ActionView::Base.send(:include, RulesView::FormFields)
|
16
|
+
ActionView::Base.send(:include, RulesView::FormBuilderView)
|
17
|
+
end
|
18
|
+
|
19
|
+
initializer "rules_view.action_controller" do |app|
|
20
|
+
ActionController::Base.send(:include, RulesView::ModelLoader)
|
21
|
+
end
|
22
|
+
|
23
|
+
generators do
|
24
|
+
require File.expand_path(File.dirname(__FILE__) + "./../../generators/install_generator")
|
25
|
+
require File.expand_path(File.dirname(__FILE__) + "./../../generators/layout_generator")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module RulesView
|
2
|
+
class FormBuilder < ActionView::Helpers::FormBuilder
|
3
|
+
|
4
|
+
include RulesView::FormStyles
|
5
|
+
|
6
|
+
%w(text_field password_field file_field text_area select date_select datetime_select time_select time_zone_select).each do |method|
|
7
|
+
src = <<-END_SRC
|
8
|
+
alias_method :orig_#{method}, :#{method}
|
9
|
+
|
10
|
+
def #{method}(method, *args)
|
11
|
+
options = args.extract_options!
|
12
|
+
|
13
|
+
error = @object && @object.respond_to?(:errors) ? @object.errors[method.to_sym] : nil
|
14
|
+
# @template.error_message_on(object || object_name, method)
|
15
|
+
options.reverse_merge!(:error => error) unless error.blank?
|
16
|
+
options.reverse_merge!(:span => @options[:span]) unless @options.nil? || @options[:span].blank?
|
17
|
+
|
18
|
+
field_label = options[:label] || method.to_s.titleize
|
19
|
+
form_label = re_build_form_label(label(method, field_label, re_options_exclude(options)), options.merge(:span => re_label_span(options)))
|
20
|
+
form_data = re_build_form_data(orig_#{method}(method, *(args << re_options_exclude(options))), options.merge(:span => re_data_span(options)))
|
21
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
22
|
+
end
|
23
|
+
END_SRC
|
24
|
+
module_eval src, __FILE__, __LINE__
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method :orig_check_box, :check_box
|
28
|
+
|
29
|
+
def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
|
30
|
+
error = @object && @object.respond_to?(:errors) ? @object.errors[method.to_sym] : nil
|
31
|
+
|
32
|
+
options.reverse_merge!(:error => error) unless error.blank?
|
33
|
+
options.reverse_merge!(:span => @options[:span]) unless @options.nil? || @options[:span].blank?
|
34
|
+
|
35
|
+
field_label = options[:label] || method.to_s.titleize
|
36
|
+
form_label = re_build_form_label(" ".html_safe, options.except(:required).merge(:span => re_label_span(options)))
|
37
|
+
form_data_label = re_build_form_label(label(method, field_label, re_options_exclude(options)), re_options_exclude(options).merge(:required => options[:required]))
|
38
|
+
form_data = re_build_form_data(orig_check_box(method, re_options_exclude(options), checked_value, unchecked_value), options.merge(:text => form_data_label, :class=>'re-form-field-checkbox', :span => re_data_span(options)))
|
39
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
40
|
+
end
|
41
|
+
|
42
|
+
def re_error_on(message)
|
43
|
+
return '' unless @object && @object.respond_to?(:errors)
|
44
|
+
return '' if @object.errors.empty?
|
45
|
+
re_error_on_tag(message)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
module FormBuilderView
|
50
|
+
[:form_for, :fields_for, :form_remote_for, :remote_form_for].each do |method|
|
51
|
+
src = <<-END_SRC
|
52
|
+
def re_#{method}(record_or_name_or_array, *args, &proc)
|
53
|
+
options = args.extract_options!
|
54
|
+
options[:builder] = RulesView::FormBuilder
|
55
|
+
|
56
|
+
#{method}(record_or_name_or_array, *(args << options), &proc)
|
57
|
+
end
|
58
|
+
END_SRC
|
59
|
+
module_eval src, __FILE__, __LINE__
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module RulesView
|
2
|
+
module FormFields
|
3
|
+
|
4
|
+
%w(text_field password_field file_field text_area select date_select datetime_select time_select time_zone_select).each do |method|
|
5
|
+
src = <<-END_SRC
|
6
|
+
def re_#{method}(label, name, value, *args)
|
7
|
+
options = args.extract_options!
|
8
|
+
|
9
|
+
form_label = re_build_form_label(label_tag(name, label, re_options_exclude(options)), options.merge(:span => re_label_span(options)))
|
10
|
+
form_data = re_build_form_data(#{method}_tag(name, value, *(args << re_options_exclude(options))), options.merge(:span => re_data_span(options)))
|
11
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
12
|
+
end
|
13
|
+
END_SRC
|
14
|
+
module_eval src, __FILE__, __LINE__
|
15
|
+
end
|
16
|
+
|
17
|
+
def re_check_box(label, name, value = "1", checked = false, options = {})
|
18
|
+
form_label = re_build_form_label(" ".html_safe, options.except(:required).merge(:span => re_label_span(options)))
|
19
|
+
form_data_label = re_build_form_label(label_tag(name, label, re_options_exclude(options)), re_options_exclude(options).merge(:required => options[:required]))
|
20
|
+
form_data = re_build_form_data(check_box_tag(name, value, checked, re_options_exclude(options)), options.merge(:text => form_data_label, :class=>'re-form-field-checkbox', :span => re_data_span(options)))
|
21
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
22
|
+
end
|
23
|
+
|
24
|
+
def re_form_text(label, text = "", options = {})
|
25
|
+
form_label = re_build_form_label(label, options.merge(:span => re_label_span(options)))
|
26
|
+
form_data = re_build_form_data("", options.merge(:text => text, :span => re_data_span(options)))
|
27
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
28
|
+
end
|
29
|
+
|
30
|
+
def re_form_blank(options = {})
|
31
|
+
form_label = re_build_form_label(" ".html_safe, options.merge(:span => re_label_span(options)))
|
32
|
+
form_data = re_build_form_data(" ".html_safe, options.merge(:span => re_data_span(options)))
|
33
|
+
re_build_form_field(form_label + form_data, options.merge(:span => re_field_span(options)))
|
34
|
+
end
|
35
|
+
|
36
|
+
def re_error_on(model, message)
|
37
|
+
return '' if model.errors.empty?
|
38
|
+
re_error_on_tag(message)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
module RulesView
|
2
|
+
module FormStyles
|
3
|
+
|
4
|
+
def re_build_form_field(value, options = {})
|
5
|
+
result = ''.html_safe
|
6
|
+
result << "<div class='re-form-field".html_safe
|
7
|
+
result << " re-form-disabled" if options.include?(:disabled) && options[:disabled]
|
8
|
+
result << " #{options[:class]}" if options.include?(:class)
|
9
|
+
result << " span-#{options[:span] || '12'}"
|
10
|
+
result << " clear'"
|
11
|
+
result << " id='form_field_#{options[:id]}'" unless options[:id].blank?
|
12
|
+
result << ">".html_safe
|
13
|
+
result << value
|
14
|
+
result << "</div>".html_safe
|
15
|
+
result
|
16
|
+
end
|
17
|
+
|
18
|
+
def re_build_form_label value, options = {}
|
19
|
+
result = "<div class='re-form-label".html_safe
|
20
|
+
result << "-error" if options.include?(:error) && !options[:error].blank?
|
21
|
+
result << " re-form-disabled" if options.include?(:disabled) && options[:disabled]
|
22
|
+
result << " #{options[:class]}" if options.include?(:class)
|
23
|
+
result << " span-#{options[:span] || '4'}"
|
24
|
+
result << "'"
|
25
|
+
result << " id='re_form_label_#{options[:id]}'" unless options[:id].blank?
|
26
|
+
result << ">".html_safe
|
27
|
+
result << value
|
28
|
+
if options.include?(:required) && options[:required]
|
29
|
+
result << "<span class='re-form-required".html_safe
|
30
|
+
result << " re-form-disabled" if options.include?(:disabled) && options[:disabled]
|
31
|
+
result << "'>*</span>".html_safe
|
32
|
+
end
|
33
|
+
result << "</div>".html_safe
|
34
|
+
result
|
35
|
+
end
|
36
|
+
|
37
|
+
def re_build_form_data value, options = {}
|
38
|
+
result = "<div class='re-form-data".html_safe
|
39
|
+
result << "-error" if options.include?(:error) && !options[:error].blank?
|
40
|
+
result << " re-form-disabled" if options.include?(:disabled) && options[:disabled]
|
41
|
+
result << " #{options[:class]}" if options.include?(:class)
|
42
|
+
result << " span-#{options[:span] || '8'}"
|
43
|
+
result << " last"
|
44
|
+
result << "'"
|
45
|
+
result << " id='form_data_#{options[:id]}'" if options.include?(:id)
|
46
|
+
result << ">".html_safe
|
47
|
+
result << value
|
48
|
+
if options.include?(:text) && !options[:text].blank?
|
49
|
+
result << "<span class='form-text'>".html_safe
|
50
|
+
result << options[:text]
|
51
|
+
result << "</span>".html_safe
|
52
|
+
end
|
53
|
+
if options.include?(:hint) && !options[:hint].blank? && (!options.include?(:error) || options[:error].blank?)
|
54
|
+
result << "<span class='form-hint'>".html_safe
|
55
|
+
result << options[:hint]
|
56
|
+
result << "</span>".html_safe
|
57
|
+
end
|
58
|
+
if options.include?(:error) && !options[:error].blank?
|
59
|
+
result << "<span class='form-error-message'>".html_safe
|
60
|
+
result << options[:error]
|
61
|
+
result << "</span>".html_safe
|
62
|
+
end
|
63
|
+
result << "</div>".html_safe
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
def re_options_exclude(options)
|
68
|
+
options.except(:error, :hint, :label, :text, :required, :span)
|
69
|
+
end
|
70
|
+
|
71
|
+
def re_label_span(options)
|
72
|
+
span = options[:span]
|
73
|
+
if span =~ %r{^\d+x\d+$}
|
74
|
+
return span.split("x")[0].to_i
|
75
|
+
elsif span =~ %r{^\d+$}
|
76
|
+
return span.to_i
|
77
|
+
end
|
78
|
+
|
79
|
+
return 4
|
80
|
+
end
|
81
|
+
|
82
|
+
def re_data_span(options)
|
83
|
+
span = options[:span]
|
84
|
+
if span =~ %r{^\d+x\d+$}
|
85
|
+
return span.split("x")[1].to_i
|
86
|
+
elsif span =~ %r{^\d+$}
|
87
|
+
if span.to_i < 8
|
88
|
+
return 8 - span.to_i
|
89
|
+
elsif span.to_i < 16
|
90
|
+
return 16 - span.to_i
|
91
|
+
else
|
92
|
+
return 24 - span.to_i
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
return 8
|
97
|
+
end
|
98
|
+
|
99
|
+
def re_field_span(options)
|
100
|
+
re_label_span(options) + re_data_span(options)
|
101
|
+
end
|
102
|
+
|
103
|
+
def re_error_on_tag(message)
|
104
|
+
result = ''.html_safe
|
105
|
+
result << '<div class="re-error"><p>'.html_safe
|
106
|
+
result << message
|
107
|
+
result << '</p></div>'.html_safe
|
108
|
+
result
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
@@ -0,0 +1,64 @@
|
|
1
|
+
module RulesView
|
2
|
+
module ModelLoader
|
3
|
+
# options
|
4
|
+
# => :parents array of required parent objects
|
5
|
+
# => :validate method on the model to validate against the parent
|
6
|
+
# => :param_id (default = id)
|
7
|
+
# => :find_by (default = find)
|
8
|
+
# => :redirect_path
|
9
|
+
def re_load_model(model_name, options = {})
|
10
|
+
model = re_find_model(model_name, options)
|
11
|
+
|
12
|
+
parent = options[:parents] == nil ? nil : options[:parents].last
|
13
|
+
if (model != nil && parent != nil)
|
14
|
+
if options[:validate]
|
15
|
+
model = nil if (instance_variable_get("@#{parent}") == nil || !model.send(options[:validate], instance_variable_get("@#{parent}")))
|
16
|
+
else
|
17
|
+
model = nil if (instance_variable_get("@#{parent}") == nil || (instance_variable_get("@#{parent}").id != model.send("#{parent}_id")))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
instance_variable_set("@#{model_name}", model)
|
22
|
+
|
23
|
+
if model == nil
|
24
|
+
flash[:error] = "Unable to load #{model_name.to_s.camelcase}."
|
25
|
+
redirect_path = model_index_path(model_name, options)
|
26
|
+
respond_to do |format|
|
27
|
+
format.html { redirect_to(redirect_path) }
|
28
|
+
format.js { render :text => "window.location.href = '#{redirect_path}';" }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
########################################################################
|
34
|
+
private
|
35
|
+
def re_find_model model_name, options
|
36
|
+
options.reverse_merge!({:find_by => :find, :param_id =>:id})
|
37
|
+
|
38
|
+
# puts "model : #{model_name}"
|
39
|
+
klass = Kernel.const_get("#{model_name}".camelcase)
|
40
|
+
model = klass ? klass.send(options[:find_by], params[options[:param_id]]) : nil
|
41
|
+
|
42
|
+
return model
|
43
|
+
rescue ActiveRecord::RecordNotFound, ActiveRecord::RecordInvalid
|
44
|
+
return nil
|
45
|
+
end
|
46
|
+
|
47
|
+
def model_index_path(model_name, options = {})
|
48
|
+
if options.include? :redirect_path
|
49
|
+
|
50
|
+
args = nil
|
51
|
+
if options[:parents]
|
52
|
+
options[:parents].each do |parent|
|
53
|
+
args = [] unless args
|
54
|
+
args << instance_variable_get("@#{parent}")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
args ? send(options[:redirect_path], args) : send(options[:redirect_path])
|
59
|
+
else
|
60
|
+
send("#{model_name.to_s.pluralize}_path")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module RulesView
|
2
|
+
module Navigate
|
3
|
+
|
4
|
+
def re_breadcrumbs *links
|
5
|
+
return if links.empty?
|
6
|
+
result = ''.html_safe
|
7
|
+
result << '<div class="re-breadcrumbs">'.html_safe
|
8
|
+
links[0 ... -1].each do |link|
|
9
|
+
result << link
|
10
|
+
result << "<span class='re-breadcrumbs-seperator'>></span>".html_safe
|
11
|
+
end
|
12
|
+
result << "<em>".html_safe
|
13
|
+
result << links[-1]
|
14
|
+
result << "</em>".html_safe
|
15
|
+
# result << "<span class='re-breadcrumbs-seperator'>></span>" if links[-1] == links[0]
|
16
|
+
result << '</div>'.html_safe
|
17
|
+
result
|
18
|
+
end
|
19
|
+
|
20
|
+
def re_breadcrumbs_right *links
|
21
|
+
return if links.empty?
|
22
|
+
result = ''.html_safe
|
23
|
+
result << '<div class="re-breadcrumbs">'.html_safe
|
24
|
+
links[0 ... -2].each do |link|
|
25
|
+
result << link
|
26
|
+
result << "<span class='re-breadcrumbs-seperator'>></span>".html_safe
|
27
|
+
end
|
28
|
+
result << "<em>".html_safe
|
29
|
+
result << links[-2]
|
30
|
+
result << "</em>".html_safe
|
31
|
+
# result << "<span class='re-breadcrumbs-seperator'>></span>" if links[-2] == links[0]
|
32
|
+
|
33
|
+
result << "<div class='re-breadcrumb-right'>".html_safe
|
34
|
+
result << links[-1]
|
35
|
+
result << "</div>".html_safe
|
36
|
+
result << '</div>'.html_safe
|
37
|
+
result
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/lib/rules_view.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
if defined?(Rails)
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/config")
|
3
|
+
|
4
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/form_styles")
|
5
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/form_fields")
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/form_builder")
|
7
|
+
|
8
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/buttons")
|
9
|
+
|
10
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/boxes")
|
11
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/navigate")
|
12
|
+
|
13
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/alerts")
|
14
|
+
|
15
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/defer")
|
16
|
+
|
17
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/model_loader")
|
18
|
+
|
19
|
+
require File.expand_path(File.dirname(__FILE__) + "/rules_view/engine")
|
20
|
+
end
|