muck-engine 0.1.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.
Files changed (155) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +23 -0
  3. data/Rakefile +67 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/admin/muck/base_controller.rb +24 -0
  6. data/app/helpers/muck_custom_form_builder.rb +186 -0
  7. data/app/helpers/muck_engine_helper.rb +60 -0
  8. data/app/models/country.rb +13 -0
  9. data/app/models/language.rb +3 -0
  10. data/app/models/state.rb +13 -0
  11. data/app/views/forms/_base_field.html.erb +11 -0
  12. data/app/views/forms/_color_picker_field.html.erb +27 -0
  13. data/app/views/forms/_default.html.erb +1 -0
  14. data/app/views/forms/_field.html.erb +3 -0
  15. data/app/views/forms/_field_with_tips.html.erb +4 -0
  16. data/app/views/forms/_menu_field.erb +4 -0
  17. data/app/views/forms/_menu_field.html.erb +3 -0
  18. data/app/views/forms/_tips.html.erb +7 -0
  19. data/app/views/layouts/admin.html.erb +39 -0
  20. data/app/views/layouts/default.html.erb +39 -0
  21. data/app/views/shared/_error_box.html.erb +7 -0
  22. data/app/views/shared/_field_error.html.erb +3 -0
  23. data/app/views/shared/_flash_error_box.html.erb +4 -0
  24. data/app/views/shared/_flash_messages.html.erb +7 -0
  25. data/app/views/shared/_growl.html.erb +11 -0
  26. data/app/views/shared/_growl_box.html.erb +3 -0
  27. data/app/views/shared/_no_result.html.erb +1 -0
  28. data/db/migrate/20090402234137_create_languages.rb +18 -0
  29. data/db/migrate/20090426041056_create_countries.rb +15 -0
  30. data/db/migrate/20090426041103_create_states.rb +18 -0
  31. data/install.rb +1 -0
  32. data/lib/action_controller/muck_application.rb +74 -0
  33. data/lib/active_record/muck_model.rb +34 -0
  34. data/lib/muck-engine.rb +5 -0
  35. data/locales/en.yml +17 -0
  36. data/public/images/arrow_down.gif +0 -0
  37. data/public/images/arrow_left.gif +0 -0
  38. data/public/images/arrow_right.gif +0 -0
  39. data/public/images/arrow_up.gif +0 -0
  40. data/public/images/icons/accept.png +0 -0
  41. data/public/images/icons/add.png +0 -0
  42. data/public/images/icons/delete.png +0 -0
  43. data/public/images/icons/vote.png +0 -0
  44. data/public/images/loading.gif +0 -0
  45. data/public/images/spinner.gif +0 -0
  46. data/public/javascripts/application.js +76 -0
  47. data/public/javascripts/fancyzoom.min.js +1 -0
  48. data/public/javascripts/jquery/jquery-ui.js +273 -0
  49. data/public/javascripts/jquery/jquery.form.js +637 -0
  50. data/public/javascripts/jquery/jquery.jgrowl.js +2 -0
  51. data/public/javascripts/jquery/jquery.js +19 -0
  52. data/public/javascripts/jquery/jquery.tips.js +69 -0
  53. data/public/stylesheets/admin.css +12 -0
  54. data/public/stylesheets/blueprint/ie.css +26 -0
  55. data/public/stylesheets/blueprint/liquid_screen.css +203 -0
  56. data/public/stylesheets/blueprint/plugins/buttons/icons/cross.png +0 -0
  57. data/public/stylesheets/blueprint/plugins/buttons/icons/key.png +0 -0
  58. data/public/stylesheets/blueprint/plugins/buttons/icons/tick.png +0 -0
  59. data/public/stylesheets/blueprint/plugins/buttons/readme.txt +32 -0
  60. data/public/stylesheets/blueprint/plugins/buttons/screen.css +97 -0
  61. data/public/stylesheets/blueprint/plugins/fancy-type/readme.txt +14 -0
  62. data/public/stylesheets/blueprint/plugins/fancy-type/screen.css +71 -0
  63. data/public/stylesheets/blueprint/plugins/link-icons/icons/doc.png +0 -0
  64. data/public/stylesheets/blueprint/plugins/link-icons/icons/email.png +0 -0
  65. data/public/stylesheets/blueprint/plugins/link-icons/icons/external.png +0 -0
  66. data/public/stylesheets/blueprint/plugins/link-icons/icons/feed.png +0 -0
  67. data/public/stylesheets/blueprint/plugins/link-icons/icons/im.png +0 -0
  68. data/public/stylesheets/blueprint/plugins/link-icons/icons/pdf.png +0 -0
  69. data/public/stylesheets/blueprint/plugins/link-icons/icons/visited.png +0 -0
  70. data/public/stylesheets/blueprint/plugins/link-icons/icons/xls.png +0 -0
  71. data/public/stylesheets/blueprint/plugins/link-icons/readme.txt +18 -0
  72. data/public/stylesheets/blueprint/plugins/link-icons/screen.css +40 -0
  73. data/public/stylesheets/blueprint/plugins/liquid/liquid.css +134 -0
  74. data/public/stylesheets/blueprint/plugins/liquid/src/liquid.css +197 -0
  75. data/public/stylesheets/blueprint/plugins/rtl/readme.txt +10 -0
  76. data/public/stylesheets/blueprint/plugins/rtl/screen.css +109 -0
  77. data/public/stylesheets/blueprint/print.css +30 -0
  78. data/public/stylesheets/blueprint/screen.css +251 -0
  79. data/public/stylesheets/blueprint/src/forms.css +49 -0
  80. data/public/stylesheets/blueprint/src/grid.css +213 -0
  81. data/public/stylesheets/blueprint/src/grid.png +0 -0
  82. data/public/stylesheets/blueprint/src/ie.css +59 -0
  83. data/public/stylesheets/blueprint/src/print.css +85 -0
  84. data/public/stylesheets/blueprint/src/reset.css +38 -0
  85. data/public/stylesheets/blueprint/src/typography.css +105 -0
  86. data/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-small_0_aaaaaa_40x40.png +0 -0
  87. data/public/stylesheets/jquery/cupertino/images/ui-bg_diagonals-thick_15_444444_40x40.png +0 -0
  88. data/public/stylesheets/jquery/cupertino/images/ui-bg_glass_100_f0f0f0_1x400.png +0 -0
  89. data/public/stylesheets/jquery/cupertino/images/ui-bg_glass_50_99c2ff_1x400.png +0 -0
  90. data/public/stylesheets/jquery/cupertino/images/ui-bg_glass_55_fbf5d0_1x400.png +0 -0
  91. data/public/stylesheets/jquery/cupertino/images/ui-bg_glass_80_e6e6e6_1x400.png +0 -0
  92. data/public/stylesheets/jquery/cupertino/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  93. data/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-hard_100_f9f9f9_1x100.png +0 -0
  94. data/public/stylesheets/jquery/cupertino/images/ui-bg_highlight-soft_100_e7eef3_1x100.png +0 -0
  95. data/public/stylesheets/jquery/cupertino/images/ui-icons_222222_256x240.png +0 -0
  96. data/public/stylesheets/jquery/cupertino/images/ui-icons_2694e8_256x240.png +0 -0
  97. data/public/stylesheets/jquery/cupertino/images/ui-icons_2e83ff_256x240.png +0 -0
  98. data/public/stylesheets/jquery/cupertino/images/ui-icons_72a7cf_256x240.png +0 -0
  99. data/public/stylesheets/jquery/cupertino/images/ui-icons_888888_256x240.png +0 -0
  100. data/public/stylesheets/jquery/cupertino/images/ui-icons_cd0a0a_256x240.png +0 -0
  101. data/public/stylesheets/jquery/cupertino/images/ui-icons_ffffff_256x240.png +0 -0
  102. data/public/stylesheets/jquery/cupertino/jquery-ui-1.7.1.custom.css +404 -0
  103. data/public/stylesheets/jquery/redmond/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  104. data/public/stylesheets/jquery/redmond/images/ui-bg_flat_55_fbec88_40x100.png +0 -0
  105. data/public/stylesheets/jquery/redmond/images/ui-bg_glass_75_d0e5f5_1x400.png +0 -0
  106. data/public/stylesheets/jquery/redmond/images/ui-bg_glass_85_dfeffc_1x400.png +0 -0
  107. data/public/stylesheets/jquery/redmond/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  108. data/public/stylesheets/jquery/redmond/images/ui-bg_gloss-wave_55_5c9ccc_500x100.png +0 -0
  109. data/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_f5f8f9_1x100.png +0 -0
  110. data/public/stylesheets/jquery/redmond/images/ui-bg_inset-hard_100_fcfdfd_1x100.png +0 -0
  111. data/public/stylesheets/jquery/redmond/images/ui-icons_217bc0_256x240.png +0 -0
  112. data/public/stylesheets/jquery/redmond/images/ui-icons_2e83ff_256x240.png +0 -0
  113. data/public/stylesheets/jquery/redmond/images/ui-icons_469bdd_256x240.png +0 -0
  114. data/public/stylesheets/jquery/redmond/images/ui-icons_6da8d5_256x240.png +0 -0
  115. data/public/stylesheets/jquery/redmond/images/ui-icons_cd0a0a_256x240.png +0 -0
  116. data/public/stylesheets/jquery/redmond/images/ui-icons_d8e7f3_256x240.png +0 -0
  117. data/public/stylesheets/jquery/redmond/images/ui-icons_f9bd01_256x240.png +0 -0
  118. data/public/stylesheets/jquery/redmond/jquery-ui-1.7.1.custom.css +404 -0
  119. data/public/stylesheets/jquery/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  120. data/public/stylesheets/jquery/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  121. data/public/stylesheets/jquery/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  122. data/public/stylesheets/jquery/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  123. data/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  124. data/public/stylesheets/jquery/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  125. data/public/stylesheets/jquery/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  126. data/public/stylesheets/jquery/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  127. data/public/stylesheets/jquery/smoothness/images/ui-icons_222222_256x240.png +0 -0
  128. data/public/stylesheets/jquery/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  129. data/public/stylesheets/jquery/smoothness/images/ui-icons_454545_256x240.png +0 -0
  130. data/public/stylesheets/jquery/smoothness/images/ui-icons_888888_256x240.png +0 -0
  131. data/public/stylesheets/jquery/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  132. data/public/stylesheets/jquery/smoothness/jquery-ui-1.7.1.custom.css +404 -0
  133. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  134. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  135. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_flat_10_000000_40x100.png +0 -0
  136. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  137. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  138. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  139. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  140. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  141. data/public/stylesheets/jquery/ui-lightness/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  142. data/public/stylesheets/jquery/ui-lightness/images/ui-icons_222222_256x240.png +0 -0
  143. data/public/stylesheets/jquery/ui-lightness/images/ui-icons_228ef1_256x240.png +0 -0
  144. data/public/stylesheets/jquery/ui-lightness/images/ui-icons_ef8c08_256x240.png +0 -0
  145. data/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffd27a_256x240.png +0 -0
  146. data/public/stylesheets/jquery/ui-lightness/images/ui-icons_ffffff_256x240.png +0 -0
  147. data/public/stylesheets/jquery/ui-lightness/jquery-ui-1.7.1.custom.css +404 -0
  148. data/public/stylesheets/reset.css +0 -0
  149. data/public/stylesheets/styles.css +76 -0
  150. data/rails/init.rb +3 -0
  151. data/tasks/languages.txt +183 -0
  152. data/test/muck_engine_test.rb +8 -0
  153. data/test/test_helper.rb +3 -0
  154. data/uninstall.rb +1 -0
  155. metadata +207 -0
@@ -0,0 +1 @@
1
+ <%= field_element %>
@@ -0,0 +1,3 @@
1
+ <div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="form-row">
2
+ <%= render :partial => 'forms/base_field', :locals => local_assigns %>
3
+ </div>
@@ -0,0 +1,4 @@
1
+ <div id="<%= field_name %>-container" class="form-row">
2
+ <%= render :partial => 'forms/base_field', :locals => local_assigns %>
3
+ <%= render :partial => 'forms/tips', :locals => local_assigns %>
4
+ </div>
@@ -0,0 +1,4 @@
1
+ <div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="chooseMenu">
2
+ <%= render :partial => 'forms/base_field', :locals => local_assigns %>
3
+ <%= render :partial => 'forms/tips', :locals => local_assigns %>
4
+ </div>
@@ -0,0 +1,3 @@
1
+ <div <%= wrapper_id.nil? ? '' : "id=\"#{wrapper_id}\"" -%> class="chooseMenu">
2
+ <%= render :partial => 'forms/base_field', :locals => local_assigns %>
3
+ </div>
@@ -0,0 +1,7 @@
1
+ <div id="<%= field_name %>-help" style="display:none;"><%= tip %></div>
2
+ <div id="<%= field_name %>-help-title" style="display:none;"><%= tip_title || label_name %></div>
3
+ <div id="<%= field_name %>-help-position" style="display:none;"><%= tip_position %></div>
4
+ <% if tip_key -%>
5
+ <div id="tip-key" style="display:none;"><%= tip_key %></div>
6
+ <div id="tip-id" style="display:none;"><%= field_name %></div>
7
+ <% end -%>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
3
+ <head>
4
+ <title><%= @page_title || GlobalConfig.application_name %></title>
5
+ <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />
6
+ <meta http-equiv="imagetoolbar" content="no" />
7
+ <meta name="distribution" content="all" />
8
+ <meta name="robots" content="all" />
9
+ <meta name="resource-type" content="document" />
10
+ <meta name="MSSmartTagsPreventParsing" content="true" />
11
+ <%= stylesheet_link_tag 'blueprint/print.css', :media => "print" %>
12
+ <!--[if IE]><link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
13
+ <%= stylesheet_link_tag %W{ reset styles blueprint/liquid_screen.css }, :cache => true %>
14
+ <%= javascript_include_tag %w{
15
+ jquery/jquery.js
16
+ jquery/jquery-ui.js
17
+ jquery/jrails.js
18
+ jquery/jquery.jgrowl.js
19
+ jquery/jquery.tips.js
20
+ application.js }, :cache => 'all_js_cached' %>
21
+ <%= javascript_tag %[const AUTH_TOKEN = #{form_authenticity_token.inspect};] if protect_against_forgery? %>
22
+ <%= yield :head -%>
23
+ </head>
24
+ <body>
25
+ <div class="container">
26
+ <div id="header">
27
+ <%= yield :header %>
28
+ </div>
29
+ <div id="content-wrapper">
30
+ <div id="content">
31
+ <%= yield :layout %>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <script type="text/javascript" language="JavaScript">
36
+ <%= yield :javascript %>
37
+ </script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,39 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
3
+ <head>
4
+ <title><%= @page_title || GlobalConfig.application_name %></title>
5
+ <meta http-equiv="content-type" content="text/xhtml; charset=utf-8" />
6
+ <meta http-equiv="imagetoolbar" content="no" />
7
+ <meta name="distribution" content="all" />
8
+ <meta name="robots" content="all" />
9
+ <meta name="resource-type" content="document" />
10
+ <meta name="MSSmartTagsPreventParsing" content="true" />
11
+ <%= stylesheet_link_tag 'blueprint/print.css', :media => "print" %>
12
+ <!--[if IE]><link rel="stylesheet" href="/stylesheets/blueprint/ie.css" type="text/css" media="screen, projection"><![endif]-->
13
+ <%= stylesheet_link_tag %W{ reset styles blueprint/screen.css }, :cache => true %>
14
+ <%= javascript_include_tag %w{
15
+ jquery/jquery.js
16
+ jquery/jquery-ui.js
17
+ jquery/jrails.js
18
+ jquery/jquery.jgrowl.js
19
+ jquery/jquery.tips.js
20
+ application.js }, :cache => 'all_js_cached' %>
21
+ <%= javascript_tag %[const AUTH_TOKEN = #{form_authenticity_token.inspect};] if protect_against_forgery? %>
22
+ <%= yield :head -%>
23
+ </head>
24
+ <body>
25
+ <div id="container">
26
+ <div id="header">
27
+ <%= yield :header %>
28
+ </div>
29
+ <div id="content-wrapper">
30
+ <div id="content">
31
+ <%= yield :layout %>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <script type="text/javascript" language="JavaScript">
36
+ <%= yield :javascript %>
37
+ </script>
38
+ </body>
39
+ </html>
@@ -0,0 +1,7 @@
1
+ <div <%=css_class%> id="errorExplanation" <%=error_styles%>>
2
+ <h2><%= title %></h2>
3
+ <%= flash_html %>
4
+ <%= field_errors %>
5
+ <%= extra_html %>
6
+ </div>
7
+ <%= render(:partial => 'shared/growl') -%>
@@ -0,0 +1,3 @@
1
+ <% if !field_error.nil? && field_error.errors.length > 0 -%>
2
+ <ul><%=field_error.errors.full_messages.map {|msg| content_tag(:li, msg)} %></ul>
3
+ <% end -%>
@@ -0,0 +1,4 @@
1
+ <div <%=css_class%> id="errorExplanation" <%=error_styles%>>
2
+ <%= flash_html %>
3
+ </div>
4
+ <%= render(:partial => 'shared/growl') -%>
@@ -0,0 +1,7 @@
1
+ <% if flash.keys.any? {|key| flash[key].length > 0} -%>
2
+ <div id="flashMessage" class="message">
3
+ <% flash.each do |key, msg| -%>
4
+ <%= content_tag :div, msg, :class => [key, " message"], :id => "notice_#{key}" %>
5
+ <% end -%>
6
+ </div>
7
+ <% end -%>
@@ -0,0 +1,11 @@
1
+ <% if GlobalConfig.growl -%>
2
+ <script type="text/javascript">
3
+ jQuery(document).ready(function() {
4
+ var message = jQuery('#errorExplanation').html();
5
+ var title = jQuery('#errorExplanation h2').html();
6
+ if(message) {
7
+ jQuery.jGrowl.info(message, {header:title});
8
+ }
9
+ });
10
+ </script>
11
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <% content_for :javascript do -%>
2
+ jQuery.jGrowl('<%=msg%>', <%=options%>);
3
+ <% end -%>
@@ -0,0 +1 @@
1
+ <p>No results were found for the search you specified.</p>
@@ -0,0 +1,18 @@
1
+ class CreateLanguages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :languages, :force => true do |t|
4
+ t.string :name
5
+ t.string :english_name
6
+ t.string :locale
7
+ t.boolean :supported, :default => true
8
+ t.integer :is_default, :default => false
9
+ end
10
+ add_index :languages, :name
11
+ add_index :languages, :locale
12
+ end
13
+
14
+ def self.down
15
+ drop_table :languages
16
+ end
17
+
18
+ end
@@ -0,0 +1,15 @@
1
+ class CreateCountries < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :countries, :force => true do |t|
4
+ t.string "name", :limit => 128, :default => "", :null => false
5
+ t.string "abbreviation", :limit => 3, :default => "", :null => false
6
+ t.integer "sort", :default => 1000, :null => false
7
+ end
8
+ add_index :countries, :name
9
+ add_index :countries, :abbreviation
10
+ end
11
+
12
+ def self.down
13
+ drop_table :countries
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class CreateStates < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :states, :force => true do |t|
4
+ t.string "name", :limit => 128, :default => "", :null => false
5
+ t.string "abbreviation", :limit => 3, :default => "", :null => false
6
+ t.integer "country_id", :limit => 8, :null => false
7
+ end
8
+
9
+ add_index :states, :country_id
10
+ add_index :states, :name
11
+ add_index :states, :abbreviation
12
+
13
+ end
14
+
15
+ def self.down
16
+ drop_table :states
17
+ end
18
+ end
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,74 @@
1
+ module ActionController
2
+
3
+ module MuckApplication
4
+
5
+ module ClassMethods
6
+
7
+ end
8
+
9
+ module InstanceMethods
10
+ private
11
+
12
+ def set_locale
13
+
14
+ # TODO add set local code
15
+ # http://zargony.com/2009/01/09/selecting-the-locale-for-a-request
16
+ # preferred_locales = request.headers['HTTP_ACCEPT_LANGUAGE'].split(',').map { |l| l.split(';').first }
17
+ # I18n.locale = preferred_locales.select { |l| I18n.available_locales.include?(l.to_sym) }
18
+ #
19
+ # if params[:locale] && I18n.available_locales.include?(params[:locale].to_sym)
20
+ # cookies['locale'] = { :value => params[:locale], :expires => 1.year.from_now }
21
+ # I18n.locale = params[:locale].to_sym
22
+ # elsif cookies['locale'] && I18n.available_locales.include?(cookies['locale'].to_sym)
23
+ # I18n.locale = cookies['locale'].to_sym
24
+ # end
25
+ #
26
+ # session[:locale] = params[:locale] if params[:locale]
27
+ # if http_lang = request.env["HTTP_ACCEPT_LANGUAGE"] and ! http_lang.blank?
28
+ # browser_locale = http_lang[/^[a-z]{2}/i].downcase + '-' + http_lang[3,2].upcase
29
+ # browser_locale.sub!(/-US/, '')
30
+ # end
31
+ # I18n.locale = session[:locale] || cookies[:locale] || browser_locale || I18n.default_locale || 'en'
32
+ #
33
+ # set_will_paginate_string if defined? WillPaginate
34
+ #
35
+ # #@locales_available ||= I18n.load_path.collect do |locale_file|
36
+ # # File.basename(File.basename(locale_file, '.rb'), '.yml')
37
+ # #end.uniq.sort
38
+ # @locales_available ||= [["English", "en"]]
39
+ end
40
+
41
+ def setup_paging
42
+ @page = (params[:page] || 1).to_i
43
+ @page = 1 if @page < 1
44
+ @per_page = (params[:per_page] || (RAILS_ENV=='test' ? 1 : 40)).to_i
45
+ end
46
+
47
+ def set_will_paginate_string
48
+ # Because I18n.locale are dynamically determined in ApplicationController,
49
+ # it should not put in config/initializers/will_paginate.rb
50
+ WillPaginate::ViewHelpers.pagination_options[:previous_label] = t('common.previous_page')
51
+ WillPaginate::ViewHelpers.pagination_options[:next_label] = t('common.next_page')
52
+ end
53
+
54
+ def get_redirect_to
55
+ if params[:redirect_to]
56
+ redirect_to params[:redirect_to]
57
+ else
58
+ yield
59
+ end
60
+ end
61
+
62
+ end
63
+
64
+ def self.included(receiver)
65
+ receiver.extend ClassMethods
66
+ receiver.class_eval do
67
+ include InstanceMethods
68
+ before_filter :set_locale
69
+ end
70
+ end
71
+
72
+ end
73
+
74
+ end
@@ -0,0 +1,34 @@
1
+ module ActiveRecord
2
+
3
+ module MuckModel
4
+
5
+ module ClassMethods
6
+
7
+ end
8
+
9
+ module InstanceMethods
10
+
11
+ def dom_id(prefix='')
12
+ display_id = new_record? ? "new" : id.to_s
13
+ prefix.to_s <<( '_') unless prefix.blank?
14
+ prefix.to_s << "#{self.class.name.underscore}"
15
+ prefix != :bare ? "#{prefix.to_s.underscore}_#{display_id}" : display_id
16
+ end
17
+
18
+ def errors_to_s
19
+ errors.map do |e, m|
20
+ "#{e.humanize unless e == "base"} #{m}\n"
21
+ end.to_s.chomp
22
+ end
23
+ end
24
+
25
+ def self.included(receiver)
26
+ receiver.extend ClassMethods
27
+ receiver.class_eval do
28
+ include InstanceMethods
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -0,0 +1,5 @@
1
+ ActionController::Base.send :include, ActionController::MuckApplication
2
+ ActiveRecord::Base.send :include, ActiveRecord::MuckModel
3
+ ActionController::Base.send :helper, MuckEngineHelper
4
+
5
+ I18n.load_path += Dir[ File.join(File.dirname(__FILE__), '..', 'locales', '*.{rb,yml}') ]
data/locales/en.yml ADDED
@@ -0,0 +1,17 @@
1
+ en:
2
+ muck:
3
+ forms:
4
+ please_enter_a_value: Please enter a value for {{label}}
5
+ general:
6
+ yes: Yes
7
+ no: No
8
+ save: Save
9
+ disable: Enable
10
+ enable: Disable
11
+ deactivate: Deactivate
12
+ activate: Activate
13
+ enabled: Enabled?
14
+ general_info: General info
15
+ help: Help
16
+ settings_saved: Settings have been saved.
17
+ delete: Delete
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,76 @@
1
+ //jQuery.noConflict();
2
+
3
+ jQuery(document).ajaxSend(function(event, request, settings) {
4
+ if (typeof(AUTH_TOKEN) == "undefined") return;
5
+ settings.data = settings.data || "";
6
+ settings.data += (settings.data ? "&" : "") + "authenticity_token=" + encodeURIComponent(AUTH_TOKEN);
7
+ });
8
+
9
+ function setup_submit_delete(){
10
+ jQuery(".submit-delete").click(function() {
11
+ // if(!confirm("Are you sure?")){
12
+ // return false;
13
+ // }
14
+ jQuery(this).parents('.delete-container').fadeOut();
15
+ var form = jQuery(this).parents('form');
16
+ jQuery.post(form.attr('action') + '.json', form.serialize(),
17
+ function(data){
18
+ var json = eval('(' + data + ')');
19
+ if(!json.success){
20
+ jQuery.jGrowl.info(json.message);
21
+ }
22
+ });
23
+ return false;
24
+ });
25
+ jQuery(".submit-delete-js").click(function() {
26
+ // if(!confirm("Are you sure?")){
27
+ // return false;
28
+ // }
29
+ jQuery(this).parents('.delete-container').fadeOut();
30
+ var form = jQuery(this).parents('form');
31
+ jQuery.post(form.attr('action') + '.js', form.serialize(),
32
+ function(data){
33
+ });
34
+ return false;
35
+ });
36
+ }
37
+
38
+ function show_hide_obj (ary_objs_to_show, ary_objs_to_hide)
39
+ {
40
+ for (i=0;i<ary_objs_to_show.length;i++) {
41
+ if (obj_to_show = document.getElementById(ary_objs_to_show[i])) obj_to_show.style.display="";
42
+ if (tab = document.getElementById('anchor'+ary_objs_to_show[i])) tab.className = 'curTab';
43
+ }
44
+ for (i=0;i<ary_objs_to_hide.length;i++) {
45
+ if (obj_to_hide = document.getElementById(ary_objs_to_hide[i])) obj_to_hide.style.display="none";
46
+ if (tab = document.getElementById('anchor'+ary_objs_to_hide[i])) tab.className = '';
47
+ }
48
+ }
49
+
50
+ jQuery.jGrowl.defaults.position = 'center';
51
+
52
+ jQuery.jGrowl.info = function(msg){
53
+ jQuery.jGrowl(msg, {sticky:true});
54
+ }
55
+
56
+ jQuery.jGrowl.warn = function(msg){
57
+ jQuery.jGrowl(msg);
58
+ }
59
+
60
+ jQuery.jGrowl.error = function(msg){
61
+ jQuery.jGrowl(msg, {sticky:true,header:"Please correct the following errors:"});
62
+ }
63
+
64
+ jQuery(document).ready(function() {
65
+ jQuery("#global-login").focus(function() {
66
+ jQuery("#global-login").val("");
67
+ });
68
+
69
+ jQuery("#global-password").focus(function() {
70
+ jQuery("#global-password").val("");
71
+ });
72
+
73
+ jQuery("#quick-login-submit").click(function() {
74
+ jQuery("#quick-login").submit();
75
+ });
76
+ });