refinerycms 0.9.8.5 → 0.9.8.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/Gemfile +15 -21
  2. data/bin/refinerycms +9 -12
  3. data/changelog.md +164 -154
  4. data/db/migrate/20100913234704_create_refinery_schema.rb +151 -0
  5. data/db/migrate/20100926142529_add_value_type_to_refinery_settings.rb +9 -0
  6. data/db/migrate/20100929035252_add_missing_indexes_to_roles_users.rb +11 -0
  7. data/db/schema.rb +5 -1
  8. data/db/seeds/pages.rb +0 -39
  9. data/db/seeds/pages_for_inquiries.rb +40 -0
  10. data/vendor/refinerycms/authentication/app/models/roles_users.rb +6 -0
  11. data/vendor/refinerycms/authentication/features/lost_password.feature +1 -0
  12. data/vendor/refinerycms/authentication/features/manage_users.feature +1 -1
  13. data/vendor/refinerycms/authentication/features/step_definitions/lost_password.rb +2 -2
  14. data/vendor/refinerycms/authentication/features/support/factories.rb +1 -0
  15. data/vendor/refinerycms/authentication/spec/models/user_spec.rb +52 -0
  16. data/vendor/refinerycms/core/app/views/admin/_head.html.erb +1 -4
  17. data/vendor/refinerycms/core/app/views/shared/_menu.html.erb +11 -5
  18. data/vendor/refinerycms/core/app/views/shared/_menu_branch.html.erb +8 -8
  19. data/vendor/refinerycms/core/app/views/shared/admin/_make_sortable.html.erb +3 -2
  20. data/vendor/refinerycms/core/app/views/shared/admin/_sortable_list.html.erb +2 -3
  21. data/vendor/refinerycms/core/lib/core.rb +5 -5
  22. data/vendor/refinerycms/core/lib/generators/refinery_engine/refinery_engine_generator.rb +2 -2
  23. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/app/views/admin/plural_name/index.html.erb +11 -9
  24. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/db/seeds/plural_name.rb +1 -1
  25. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/lib/generators/refinerycms_plural_name_generator.rb +3 -3
  26. data/vendor/refinerycms/core/lib/generators/refinery_engine/templates/lib/plural_name.rb +1 -1
  27. data/vendor/refinerycms/core/lib/refinery/crud.rb +48 -28
  28. data/vendor/refinerycms/core/lib/refinery/helpers/menu_helper.rb +34 -4
  29. data/vendor/refinerycms/core/lib/refinery/plugin.rb +5 -5
  30. data/vendor/refinerycms/core/public/javascripts/rails.js +152 -0
  31. data/vendor/refinerycms/core/public/javascripts/refinery/admin.js +33 -13
  32. data/vendor/refinerycms/core/public/javascripts/wymeditor/jquery.refinery.wymeditor.js +191 -175
  33. data/vendor/refinerycms/core/public/stylesheets/refinery/refinery.css +80 -12
  34. data/vendor/refinerycms/dashboard/features/dashboard.feature +3 -1
  35. data/vendor/refinerycms/images/features/support/factories.rb +5 -0
  36. data/vendor/refinerycms/images/lib/images.rb +7 -35
  37. data/vendor/refinerycms/images/spec/models/image_spec.rb +50 -0
  38. data/vendor/refinerycms/images/spec/uploads/beach.jpeg +0 -0
  39. data/vendor/refinerycms/pages/features/manage_pages.feature +1 -1
  40. data/vendor/refinerycms/pages/features/step_definitions/page_steps.rb +19 -3
  41. data/vendor/refinerycms/pages/features/support/paths.rb +9 -1
  42. data/vendor/refinerycms/pages/features/visit_pages.feature +45 -0
  43. data/vendor/refinerycms/pages/spec/models/page_spec.rb +134 -4
  44. data/vendor/refinerycms/refinery.rb +1 -1
  45. data/vendor/refinerycms/resources/features/manage_files.feature +5 -1
  46. data/vendor/refinerycms/resources/features/step_definitions/file_steps.rb +2 -2
  47. data/vendor/refinerycms/resources/lib/resources.rb +8 -37
  48. data/vendor/refinerycms/resources/spec/models/resource_spec.rb +45 -0
  49. data/vendor/refinerycms/resources/spec/uploads/refinery_is_awesome.txt +1 -0
  50. data/vendor/refinerycms/settings/app/models/refinery_setting.rb +26 -12
  51. data/vendor/refinerycms/settings/features/manage_refinery_settings.feature +1 -1
  52. data/vendor/refinerycms/settings/spec/models/refinery_setting_spec.rb +101 -0
  53. metadata +37 -56
  54. data/db/migrate/20091109012126_add_missing_indexes.rb +0 -25
  55. data/db/migrate/20091130040711_add_down_for_maintenance_page.rb +0 -15
  56. data/db/migrate/20091207033335_add_superuser_to_users.rb +0 -12
  57. data/db/migrate/20100114092849_add_themes_table.rb +0 -19
  58. data/db/migrate/20100125003944_rename_title_to_name_on_user_plugins.rb +0 -9
  59. data/db/migrate/20100125033146_migrate_old_plugin_titles_to_plugin_names_for_users.rb +0 -61
  60. data/db/migrate/20100127004649_add_reset_code_to_users.rb +0 -9
  61. data/db/migrate/20100202034802_remove_custom_title_image_id_and_image_id_from_pages.rb +0 -13
  62. data/db/migrate/20100204011654_change_part_titles_to_titleized_version_for_new_format.rb +0 -13
  63. data/db/migrate/20100223211536_remove_themes_table.rb +0 -17
  64. data/db/migrate/20100305023036_change_users_columns_for_authlogic.rb +0 -54
  65. data/db/migrate/20100305023037_remove_unused_users_columns.rb +0 -15
  66. data/db/migrate/20100312155331_make_user_perishable_token_nullable.rb +0 -13
  67. data/db/migrate/20100312160327_make_user_persistence_token_nullable.rb +0 -13
  68. data/db/migrate/20100315203301_remove_state_from_users.rb +0 -9
  69. data/db/migrate/20100419001048_change_image_grid_thumbnail_size_and_regenerate.rb +0 -13
  70. data/db/migrate/20100522020225_rename_permissions_for_resources_plugin_to_files.rb +0 -15
  71. data/db/migrate/20100525084518_remove_take_down_for_maintenance_page.rb +0 -19
  72. data/db/migrate/20100525110237_add_small_and_large_thumbnail_sizes.rb +0 -14
  73. data/db/migrate/20100530205942_update_link_url_on_pages_from_inquiries_new_to_contact.rb +0 -31
  74. data/db/migrate/20100605132138_convert_resource_to_dragonfly.rb +0 -41
  75. data/db/migrate/20100605132208_convert_image_to_dragonfly.rb +0 -51
  76. data/db/migrate/20100606135207_change_thumbnail_sizes_for_dragonfly.rb +0 -17
  77. data/db/migrate/20100608062447_add_scoping_to_refinery_settings.rb +0 -9
  78. data/db/migrate/20100623220402_add_restricted_to_refinery_settings.rb +0 -9
  79. data/db/migrate/20100624024501_add_roles.rb +0 -24
  80. data/db/migrate/20100629081543_add_callback_proc_as_string_to_refinery_settings.rb +0 -9
  81. data/db/migrate/20100701053151_remove_superuser_from_users.rb +0 -20
  82. data/db/migrate/20100702022630_add_spam_to_inquiries.rb +0 -11
  83. data/db/migrate/20100708014636_ensure_user_plugins_use_name_and_not_title.rb +0 -9
  84. data/db/migrate/20100729221735_remove_page_translations_if_present.rb +0 -12
  85. data/db/migrate/20100826232810_move_inquiry_settings_to_refinery_settings.rb +0 -23
  86. data/db/migrate/20100831122919_move_page_to_nested_set.rb +0 -28
  87. data/db/migrate/20100913234704_add_cached_slug_to_pages.rb +0 -12
  88. data/db/seeds/inquiry_settings.rb +0 -2
@@ -0,0 +1,151 @@
1
+ class CreateRefinerySchema < ActiveRecord::Migration
2
+ def self.up
3
+ create_table ::Image.table_name, :force => true do |t|
4
+ t.string "image_mime_type"
5
+ t.string "image_name"
6
+ t.integer "image_size"
7
+ t.integer "image_width"
8
+ t.integer "image_height"
9
+ t.datetime "created_at"
10
+ t.datetime "updated_at"
11
+ t.string "image_uid"
12
+ t.string "image_ext"
13
+ end
14
+
15
+ create_table ::Inquiry.table_name, :force => true do |t|
16
+ t.string "name"
17
+ t.string "email"
18
+ t.string "phone"
19
+ t.text "message"
20
+ t.integer "position"
21
+ t.boolean "open", :default => true
22
+ t.datetime "created_at"
23
+ t.datetime "updated_at"
24
+ t.boolean "spam", :default => false
25
+ end
26
+
27
+ create_table ::InquirySetting.table_name, :force => true do |t|
28
+ t.string "name"
29
+ t.text "value"
30
+ t.boolean "destroyable"
31
+ t.datetime "created_at"
32
+ t.datetime "updated_at"
33
+ end
34
+
35
+ create_table ::PagePart.table_name, :force => true do |t|
36
+ t.integer "page_id"
37
+ t.string "title"
38
+ t.text "body"
39
+ t.integer "position"
40
+ t.datetime "created_at"
41
+ t.datetime "updated_at"
42
+ end
43
+
44
+ add_index ::PagePart.table_name, ["id"], :name => "index_#{::PagePart.table_name}_on_id"
45
+ add_index ::PagePart.table_name, ["page_id"], :name => "index_#{::PagePart.table_name}_on_page_id"
46
+
47
+ create_table ::Page.table_name, :force => true do |t|
48
+ t.string "title"
49
+ t.integer "parent_id"
50
+ t.integer "position"
51
+ t.string "path"
52
+ t.datetime "created_at"
53
+ t.datetime "updated_at"
54
+ t.string "meta_keywords"
55
+ t.text "meta_description"
56
+ t.boolean "show_in_menu", :default => true
57
+ t.string "link_url"
58
+ t.string "menu_match"
59
+ t.boolean "deletable", :default => true
60
+ t.string "custom_title"
61
+ t.string "custom_title_type", :default => "none"
62
+ t.boolean "draft", :default => false
63
+ t.string "browser_title"
64
+ t.boolean "skip_to_first_child", :default => false
65
+ t.integer "lft"
66
+ t.integer "rgt"
67
+ t.integer "depth"
68
+ t.string "cached_slug"
69
+ end
70
+
71
+ add_index ::Page.table_name, ["depth"], :name => "index_#{::Page.table_name}_on_depth"
72
+ add_index ::Page.table_name, ["id"], :name => "index_#{::Page.table_name}_on_id"
73
+ add_index ::Page.table_name, ["lft"], :name => "index_#{::Page.table_name}_on_lft"
74
+ add_index ::Page.table_name, ["parent_id"], :name => "index_#{::Page.table_name}_on_parent_id"
75
+ add_index ::Page.table_name, ["rgt"], :name => "index_#{::Page.table_name}_on_rgt"
76
+
77
+ create_table ::RefinerySetting.table_name, :force => true do |t|
78
+ t.string "name"
79
+ t.text "value"
80
+ t.boolean "destroyable", :default => true
81
+ t.datetime "created_at"
82
+ t.datetime "updated_at"
83
+ t.string "scoping"
84
+ t.boolean "restricted", :default => false
85
+ t.string "callback_proc_as_string"
86
+ end
87
+
88
+ add_index ::RefinerySetting.table_name, ["name"], :name => "index_#{::RefinerySetting.table_name}_on_name"
89
+
90
+ create_table ::Resource.table_name, :force => true do |t|
91
+ t.string "file_mime_type"
92
+ t.string "file_name"
93
+ t.integer "file_size"
94
+ t.datetime "created_at"
95
+ t.datetime "updated_at"
96
+ t.string "file_uid"
97
+ t.string "file_ext"
98
+ end
99
+
100
+ create_table ::Role.table_name, :force => true do |t|
101
+ t.string "title"
102
+ end
103
+
104
+ create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
105
+ t.integer "user_id"
106
+ t.integer "role_id"
107
+ end
108
+
109
+ create_table ::Slug.table_name, :force => true do |t|
110
+ t.string "name"
111
+ t.integer "sluggable_id"
112
+ t.integer "sequence", :default => 1, :null => false
113
+ t.string "sluggable_type", :limit => 40
114
+ t.string "scope", :limit => 40
115
+ t.datetime "created_at"
116
+ end
117
+
118
+ add_index ::Slug.table_name, ["name", "sluggable_type", "scope", "sequence"], :name => "index_#{::Slug.table_name}_on_name_and_sluggable_type_and_scope_and_sequence", :unique => true
119
+ add_index ::Slug.table_name, ["sluggable_id"], :name => "index_#{::Slug.table_name}_on_sluggable_id"
120
+
121
+ create_table ::UserPlugin.table_name, :force => true do |t|
122
+ t.integer "user_id"
123
+ t.string "name"
124
+ t.integer "position"
125
+ end
126
+
127
+ add_index ::UserPlugin.table_name, ["name"], :name => "index_#{::UserPlugin.table_name}_on_title"
128
+ add_index ::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::UserPlugin.table_name}", :unique => true
129
+
130
+ create_table ::User.table_name, :force => true do |t|
131
+ t.string "login", :null => false
132
+ t.string "email", :null => false
133
+ t.string "crypted_password", :null => false
134
+ t.string "password_salt", :null => false
135
+ t.string "persistence_token"
136
+ t.datetime "created_at"
137
+ t.datetime "updated_at"
138
+ t.string "perishable_token"
139
+ end
140
+
141
+ add_index ::User.table_name, ["id"], :name => "index_#{::User.table_name}_on_id"
142
+ end
143
+
144
+ def self.down
145
+ [::Image, ::Page, ::PagePart, ::RefinerySetting, ::Slug, ::User].reject{|m|
146
+ !(defined?(m) and m.respond_to?(:table_name))
147
+ }.each do |model|
148
+ drop_table model.table_name
149
+ end
150
+ end
151
+ end
@@ -0,0 +1,9 @@
1
+ class AddValueTypeToRefinerySettings < ActiveRecord::Migration
2
+ def self.up
3
+ add_column ::RefinerySetting.table_name, :form_value_type, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column ::RefinerySetting.table_name, :form_value_type
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
2
+ def self.up
3
+ add_index ::RolesUsers.table_name, [:role_id, :user_id]
4
+ add_index ::RolesUsers.table_name, [:user_id, :role_id]
5
+ end
6
+
7
+ def self.down
8
+ remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id]
9
+ remove_index ::RolesUsers.table_name, :column => [:user_id, :role_id]
10
+ end
11
+ end
data/db/schema.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  #
11
11
  # It's strongly recommended to check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(:version => 20100913234704) do
13
+ ActiveRecord::Schema.define(:version => 20100929035252) do
14
14
 
15
15
  create_table "images", :force => true do |t|
16
16
  t.string "image_mime_type"
@@ -95,6 +95,7 @@ ActiveRecord::Schema.define(:version => 20100913234704) do
95
95
  t.string "scoping"
96
96
  t.boolean "restricted", :default => false
97
97
  t.string "callback_proc_as_string"
98
+ t.string "form_value_type"
98
99
  end
99
100
 
100
101
  add_index "refinery_settings", ["name"], :name => "index_refinery_settings_on_name"
@@ -118,6 +119,9 @@ ActiveRecord::Schema.define(:version => 20100913234704) do
118
119
  t.integer "role_id"
119
120
  end
120
121
 
122
+ add_index "roles_users", ["role_id", "user_id"], :name => "index_roles_users_on_role_id_and_user_id"
123
+ add_index "roles_users", ["user_id", "role_id"], :name => "index_roles_users_on_user_id_and_role_id"
124
+
121
125
  create_table "slugs", :force => true do |t|
122
126
  t.string "name"
123
127
  t.integer "sluggable_id"
data/db/seeds/pages.rb CHANGED
@@ -41,42 +41,3 @@ about_us_page.parts.create({
41
41
  :body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
42
42
  :position => 1
43
43
  })
44
-
45
- contact_us_page = Page.create(:title => "Contact",
46
- :link_url => "/contact",
47
- :menu_match => "^/(inquiries|contact).*$",
48
- :deletable => false,
49
- :position => (page_position += 1))
50
- contact_us_page.parts.create({
51
- :title => "Body",
52
- :body => "<p>Get in touch with us. Just use the form below and we'll get back to you as soon as we can.</p>",
53
- :position => 0
54
- })
55
- contact_us_page.parts.create({
56
- :title => "Side Body",
57
- :body => "<p>163 Evergreen Terrace<br/>Happyville<br/>USA.<br/>Phone: 1-800 CALLUSNOW</p>",
58
- :position => 1
59
- })
60
- contact_us_page_position = -1
61
-
62
- thank_you_page = contact_us_page.children.create(:title => "Thank You",
63
- :link_url => "/contact/thank_you",
64
- :menu_match => "^/(inquiries|contact)/thank_you$",
65
- :show_in_menu => false,
66
- :deletable => false,
67
- :position => (contact_us_page_position += 1))
68
- thank_you_page.parts.create({
69
- :title => "Body",
70
- :body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><p><a href='/'>Return to the home page</a></p>",
71
- :position => 0
72
- })
73
-
74
- privacy_policy_page = contact_us_page.children.create(:title => "Privacy Policy",
75
- :deletable => true,
76
- :show_in_menu => false,
77
- :position => (contact_us_page_position += 1))
78
- privacy_policy_page.parts.create({
79
- :title => "Body",
80
- :body => "<p>We respect your privacy. We do not market, rent or sell our email list to any outside parties.</p><p>We need your e-mail address so that we can ensure that the people using our forms are bona fide. It also allows us to send you e-mail newsletters and other communications, if you opt-in. Your postal address is required in order to send you information and pricing, if you request it.</p><p>Please call us at 123 456 7890 if you have any questions or concerns.</p>",
81
- :position => 0
82
- })
@@ -0,0 +1,40 @@
1
+ page_position = Page.maximum(:position, :conditions => {:parent_id => nil})
2
+
3
+ contact_us_page = Page.create(:title => "Contact",
4
+ :link_url => "/contact",
5
+ :menu_match => "^/(inquiries|contact).*$",
6
+ :deletable => false,
7
+ :position => (page_position += 1))
8
+ contact_us_page.parts.create({
9
+ :title => "Body",
10
+ :body => "<p>Get in touch with us. Just use the form below and we'll get back to you as soon as we can.</p>",
11
+ :position => 0
12
+ })
13
+ contact_us_page.parts.create({
14
+ :title => "Side Body",
15
+ :body => "<p>163 Evergreen Terrace<br/>Happyville<br/>USA.<br/>Phone: 1-800 CALLUSNOW</p>",
16
+ :position => 1
17
+ })
18
+ contact_us_page_position = -1
19
+
20
+ thank_you_page = contact_us_page.children.create(:title => "Thank You",
21
+ :link_url => "/contact/thank_you",
22
+ :menu_match => "^/(inquiries|contact)/thank_you$",
23
+ :show_in_menu => false,
24
+ :deletable => false,
25
+ :position => (contact_us_page_position += 1))
26
+ thank_you_page.parts.create({
27
+ :title => "Body",
28
+ :body => "<p>We've received your inquiry and will get back to you with a response shortly.</p><p><a href='/'>Return to the home page</a></p>",
29
+ :position => 0
30
+ })
31
+
32
+ privacy_policy_page = contact_us_page.children.create(:title => "Privacy Policy",
33
+ :deletable => true,
34
+ :show_in_menu => false,
35
+ :position => (contact_us_page_position += 1))
36
+ privacy_policy_page.parts.create({
37
+ :title => "Body",
38
+ :body => "<p>We respect your privacy. We do not market, rent or sell our email list to any outside parties.</p><p>We need your e-mail address so that we can ensure that the people using our forms are bona fide. It also allows us to send you e-mail newsletters and other communications, if you opt-in. Your postal address is required in order to send you information and pricing, if you request it.</p><p>Please call us at 123 456 7890 if you have any questions or concerns.</p>",
39
+ :position => 0
40
+ })
@@ -0,0 +1,6 @@
1
+ class RolesUsers < ActiveRecord::Base
2
+
3
+ belongs_to :role
4
+ belongs_to :user
5
+
6
+ end
@@ -1,3 +1,4 @@
1
+ @refinerycms @users @users-password
1
2
  Feature: Lost Password
2
3
  In order to restore my password
3
4
  As a lost soul
@@ -1,4 +1,4 @@
1
- @users @users-manage
1
+ @refinerycms @users @users-manage
2
2
  Feature: Manage Users
3
3
  In order to control who can access my website's backend
4
4
  As an administrator
@@ -1,8 +1,8 @@
1
1
  Given /^I have a user with email "(.*)"$/ do |email|
2
- Factory(:user, :email => email)
2
+ Factory(:refinery_user, :email => email)
3
3
  end
4
4
 
5
5
  Given /^I am (not )?requesting password reset$/ do |action|
6
- @user = Factory(:user, :updated_at => 11.minutes.ago)
6
+ @user = Factory(:refinery_user, :updated_at => 11.minutes.ago)
7
7
  @user.reset_perishable_token! if action.nil?
8
8
  end
@@ -9,6 +9,7 @@ end
9
9
 
10
10
  Factory.define :refinery_user, :parent => :user do |u|
11
11
  u.roles { [ Role[:refinery] ] }
12
+
12
13
  u.after_create do |user|
13
14
  Refinery::Plugins.registered.each_with_index do |plugin, index|
14
15
  user.plugins.create(:name => plugin.name, :position => index)
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ Dir[File.expand_path('../../../features/support/factories.rb', __FILE__)].each {|f| require f}
4
+
5
+ describe User do
6
+ include AuthenticatedTestHelper
7
+
8
+ context "Roles" do
9
+ context "add_role" do
10
+ it "raises Exception when Role object is passed" do
11
+ user = Factory(:user)
12
+ lambda{ user.add_role(Role.new)}.should raise_exception
13
+ end
14
+
15
+ it "adds a Role to the User when role not yet assigned to User" do
16
+ user = Factory(:user)
17
+ lambda {
18
+ user.add_role(:new_role)
19
+ }.should change(user.roles, :count).by(1)
20
+ user.roles.collect(&:title).should include("NewRole")
21
+ end
22
+
23
+ it "does not add a Role to the User when this Role is already assigned to User" do
24
+ user = Factory(:refinery_user)
25
+ lambda {
26
+ user.add_role(:refinery)
27
+ }.should_not change(user.roles, :count).by(1)
28
+ user.roles.collect(&:title).should include("Refinery")
29
+ end
30
+ end
31
+
32
+ context "has_role" do
33
+ it "raises Exception when Role object is passed" do
34
+ user = Factory(:user)
35
+ lambda{ user.has_role?(Role.new)}.should raise_exception
36
+ end
37
+
38
+ it "returns the true if user has Role" do
39
+ user = Factory(:refinery_user)
40
+ user.has_role?(:refinery).should be_true
41
+ end
42
+
43
+ it "returns false if user hasn't the Role" do
44
+ user = Factory(:refinery_user)
45
+ user.has_role?(:refinery_fail).should be_false
46
+ end
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -25,10 +25,7 @@
25
25
 
26
26
  <%= jquery_include_tags(:caching => js_caching) -%>
27
27
 
28
- <% #TODO: Find out why the master branch doesn't work! %>
29
- <%#= javascript_include_tag 'http://github.com/rails/jquery-ujs/raw/master/src/rails.js' %>
30
- <%= javascript_include_tag 'http://github.com/rails/jquery-ujs/raw/f01a685c8200b76c4cc2c606accb135da5ad5444/src/rails.js' %>
31
-
28
+ <%= javascript_include_tag 'rails' %>
32
29
 
33
30
  <%= javascript_include_tag 'jquery/jquery.corner.js',
34
31
  'jquery/jquery.textTruncate.js',
@@ -3,14 +3,19 @@
3
3
  css ||= 'menu'
4
4
  hide_children = RefinerySetting.find_or_set(:menu_hide_children, false) unless defined?(hide_children)
5
5
  cache_key = [Refinery.base_cache_key]
6
+ cache_key << dom_id
6
7
  cache_key << (action_suffix ||= RefinerySetting.find_or_set(:refinery_menu_cache_action_suffix, "site_menu"))
7
- cache_key << extra_suffix if defined?(extra_suffix) and extra_suffix.present?
8
8
  cache_key << request.path
9
- cache(cache_key.compact.join('_')) do
10
- # Select top menu items unless 'roots' is passed in.
9
+ cache_if(RefinerySetting.find_or_set(:menu_cache_enabled, true), cache_key.compact.join('_')) do
10
+ # Select top menu items unless 'roots' is supplied.
11
11
  collection ||= @menu_pages
12
- roots ||= collection.select { |m| m.parent_id == nil }
13
- if roots.any?
12
+ # In order to match items that aren't shown in menu and highlight their associations.
13
+ # This can be supplied if the logic different in your case.
14
+ unless defined?(selected_item)
15
+ selected_item = collection.detect{|page| selected_page?(page)}
16
+ selected_item = @page if selected_item.nil?
17
+ end
18
+ if (roots ||= collection.select { |m| m.parent_id.nil? }).any?
14
19
  sibling_count = roots.size - 1
15
20
  -%>
16
21
  <nav id='<%= dom_id %>' class='<%= %W(#{css} clearfix).join(' ') %>'>
@@ -21,6 +26,7 @@
21
26
  :hide_children => hide_children,
22
27
  :sibling_count => sibling_count,
23
28
  :collection => collection,
29
+ :selected_item => selected_item,
24
30
  :apply_css => true #if you don't care about class='first' class='last' or class='selected' set apply_css to false for speed.
25
31
  }
26
32
  -%>
@@ -1,26 +1,26 @@
1
1
  <%
2
- css = if ((defined?(apply_css) && apply_css) || !defined?(apply_css)) and
3
- (classes = css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count||=nil)).any?
4
- "class='#{classes.join(' ')}'"
2
+ if !!local_assigns[:apply_css] and (classes = css_for_menu_branch(menu_branch, menu_branch_counter, sibling_count||=nil, collection, selected_item ||= nil)).any?
3
+ css = "class='#{classes.join(' ')}'"
5
4
  end
6
5
  dom_id = ("id='item_#{menu_branch_counter}'" if menu_branch.parent_id.nil? and menu_branch.title.present?)
7
6
 
8
7
  hide_children = (defined?(hide_children) && hide_children)
9
8
  children = hide_children ? [] : collection.select { |p| p.parent_id == menu_branch.id && p.in_menu? }
10
9
  -%>
11
- <li<%= ['', css, dom_id].join(' ').gsub(/\ *$/, '') %>>
12
- <%= link_to menu_branch.title, menu_branch.url %>
13
-
14
- <% if children.present? %>
10
+ <li<%= ['', css, dom_id].compact.join(' ').gsub(/\ *$/, '') %>>
11
+ <%= link_to menu_branch.title, menu_branch.url -%>
12
+ <% if children.present? -%>
15
13
  <ul class='clearfix'>
16
14
  <%=
17
15
  render :partial => "/shared/menu_branch",
18
16
  :collection => children,
19
17
  :locals => {
18
+ :apply_css => local_assigns[:apply_css],
20
19
  :hide_children => hide_children,
21
20
  :collection => collection,
21
+ :selected_item => selected_item,
22
22
  :sibling_count => children.size - 1
23
23
  } -%>
24
24
  </ul>
25
- <% end %>
25
+ <% end -%>
26
26
  </li>