tb_cms 1.2.3 → 1.3.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/javascripts/admin/cms/menu_items.js +39 -17
  4. data/app/assets/stylesheets/admin/cms/application.css +11 -0
  5. data/app/controllers/admin/menu_items_controller.rb +103 -113
  6. data/app/controllers/admin/menus_controller.rb +52 -53
  7. data/app/controllers/admin/pages_controller.rb +107 -111
  8. data/app/controllers/admin/snippets_controller.rb +16 -16
  9. data/app/controllers/cms/sitemaps_controller.rb +5 -5
  10. data/app/controllers/pages_controller.rb +30 -34
  11. data/app/helpers/cms/application_helper.rb +184 -212
  12. data/app/models/concerns/cms_deprecated_multisite.rb +3 -3
  13. data/app/models/spud_menu.rb +4 -4
  14. data/app/models/spud_menu_item.rb +58 -61
  15. data/app/models/spud_page.rb +63 -67
  16. data/app/models/spud_page_partial.rb +42 -44
  17. data/app/models/spud_page_partial_revision.rb +3 -3
  18. data/app/models/spud_snippet.rb +7 -7
  19. data/app/views/admin/menu_items/index.html.erb +1 -1
  20. data/lib/generators/spud/cms/layout_generator.rb +8 -8
  21. data/lib/spud_cms/configuration.rb +10 -10
  22. data/lib/spud_cms/engine.rb +28 -28
  23. data/lib/spud_cms/liquid_snippet.rb +5 -7
  24. data/lib/spud_cms/page_route.rb +1 -1
  25. data/lib/spud_cms/template_parser.rb +35 -40
  26. data/lib/spud_cms/test_files.rb +6 -6
  27. data/lib/spud_cms/version.rb +3 -3
  28. data/spec/controllers/admin/menu_items_controller_spec.rb +54 -56
  29. data/spec/controllers/admin/menus_controller_spec.rb +31 -37
  30. data/spec/controllers/admin/pages_controller_spec.rb +31 -36
  31. data/spec/controllers/admin/snippets_controller_spec.rb +1 -1
  32. data/spec/controllers/pages_controller_spec.rb +21 -21
  33. data/spec/dummy/config/application.rb +3 -4
  34. data/spec/dummy/config/boot.rb +1 -1
  35. data/spec/dummy/config/environments/production.rb +1 -1
  36. data/spec/dummy/config/environments/test.rb +3 -3
  37. data/spec/dummy/config.ru +1 -1
  38. data/spec/dummy/db/migrate/20141231214447_create_spud_users.tb_core.rb +12 -12
  39. data/spec/dummy/db/migrate/20141231214448_add_time_zone_to_spud_user.tb_core.rb +0 -1
  40. data/spec/dummy/db/migrate/20141231214449_add_scope_to_spud_admin_permissions.tb_core.rb +0 -1
  41. data/spec/dummy/db/migrate/20141231214452_create_spud_permissions.tb_core.rb +3 -3
  42. data/spec/dummy/db/migrate/20141231214453_create_spud_role_permissions.tb_core.rb +2 -2
  43. data/spec/dummy/db/migrate/20141231214455_create_spud_permalinks.tb_permalinks.rb +1 -1
  44. data/spec/dummy/db/migrate/20141231214456_add_site_id_to_spud_permalinks.tb_permalinks.rb +1 -1
  45. data/spec/dummy/db/migrate/20141231214457_modify_site_id_for_spud_permalinks.tb_permalinks.rb +4 -4
  46. data/spec/dummy/db/migrate/20141231214459_create_spud_pages.tb_cms.rb +1 -1
  47. data/spec/dummy/db/migrate/20141231214461_create_spud_menu_items.tb_cms.rb +3 -3
  48. data/spec/dummy/db/migrate/20141231214463_create_spud_page_partials.tb_cms.rb +1 -1
  49. data/spec/dummy/db/migrate/20141231214464_add_visibility_to_spud_pages.tb_cms.rb +2 -2
  50. data/spec/dummy/db/migrate/20141231214466_add_use_custom_url_name_to_spud_pages.tb_cms.rb +1 -1
  51. data/spec/dummy/db/migrate/20141231214468_add_menu_id_to_spud_menu_items.tb_cms.rb +1 -1
  52. data/spec/dummy/db/migrate/20141231214469_add_classes_to_spud_menu_items.tb_cms.rb +0 -1
  53. data/spec/dummy/db/migrate/20141231214470_add_site_id_to_spud_pages.tb_cms.rb +2 -2
  54. data/spec/dummy/db/migrate/20141231214471_add_site_id_to_spud_templates.tb_cms.rb +2 -2
  55. data/spec/dummy/db/migrate/20141231214472_add_site_id_to_spud_menus.tb_cms.rb +2 -2
  56. data/spec/dummy/db/migrate/20141231214473_create_spud_page_partial_revisions.tb_cms.rb +1 -1
  57. data/spec/dummy/db/migrate/20141231214475_modify_site_id_for_spud_pages.tb_cms.rb +8 -8
  58. data/spec/dummy/db/migrate/20141231214478_create_spud_page_liquid_tags.tb_cms.rb +1 -1
  59. data/spec/dummy/db/migrate/20141231214479_create_spud_snippets.tb_cms.rb +1 -2
  60. data/spec/dummy/db/migrate/20141231214480_change_liquid_tags_to_polymorphic.tb_cms.rb +2 -2
  61. data/spec/dummy/db/migrate/20141231214481_drop_spud_page_liquid_tags.tb_cms.rb +6 -8
  62. data/spec/dummy/db/migrate/20150108164814_remove_site_id_from_cms_tables.tb_cms.rb +1 -0
  63. data/spec/dummy/db/migrate/20150911185843_add_requires_password_change_to_spud_users.tb_core.rb +1 -1
  64. data/spec/dummy/db/migrate/20160215180157_create_tb_redirects.tb_redirects.rb +3 -3
  65. data/spec/dummy/db/schema.rb +142 -153
  66. data/spec/dummy/script/rails +2 -2
  67. data/spec/helpers/cms/application_helper_spec.rb +39 -41
  68. data/spec/models/spud_menu_item_spec.rb +13 -13
  69. data/spec/models/spud_page_partial_revision_spec.rb +1 -1
  70. data/spec/models/spud_page_partial_spec.rb +19 -20
  71. data/spec/models/spud_page_spec.rb +90 -91
  72. data/spec/models/spud_snippet_spec.rb +1 -1
  73. data/spec/rails_helper.rb +12 -6
  74. data/spec/spec_helper.rb +42 -44
  75. metadata +64 -38
  76. data/spec/authlogic_helper.rb +0 -2
@@ -2,21 +2,21 @@
2
2
  class CreateSpudUsers < ActiveRecord::Migration
3
3
  def change
4
4
  create_table :spud_users do |t|
5
-
5
+
6
6
  t.string :first_name
7
7
  t.string :last_name
8
8
  t.boolean :super_admin
9
- t.string :login, :null => false # optional, you can use email instead, or both
10
- t.string :email, :null => false # optional, you can use login instead, or both
11
- t.string :crypted_password, :null => false # optional, see below
12
- t.string :password_salt, :null => false # optional, but highly recommended
13
- t.string :persistence_token, :null => false # required
14
- t.string :single_access_token, :null => false # optional, see Authlogic::Session::Params
15
- t.string :perishable_token, :null => false # optional, see Authlogic::Session::Perishability
9
+ t.string :login, null: false # optional, you can use email instead, or both
10
+ t.string :email, null: false # optional, you can use login instead, or both
11
+ t.string :crypted_password, null: false # optional, see below
12
+ t.string :password_salt, null: false # optional, but highly recommended
13
+ t.string :persistence_token, null: false # required
14
+ t.string :single_access_token, null: false # optional, see Authlogic::Session::Params
15
+ t.string :perishable_token, null: false # optional, see Authlogic::Session::Perishability
16
16
 
17
17
  # Magic columns, just like ActiveRecord's created_at and updated_at. These are automatically maintained by Authlogic if they are present.
18
- t.integer :login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
19
- t.integer :failed_login_count, :null => false, :default => 0 # optional, see Authlogic::Session::MagicColumns
18
+ t.integer :login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
19
+ t.integer :failed_login_count, null: false, default: 0 # optional, see Authlogic::Session::MagicColumns
20
20
  t.datetime :last_request_at # optional, see Authlogic::Session::MagicColumns
21
21
  t.datetime :current_login_at # optional, see Authlogic::Session::MagicColumns
22
22
  t.datetime :last_login_at # optional, see Authlogic::Session::MagicColumns
@@ -24,7 +24,7 @@ class CreateSpudUsers < ActiveRecord::Migration
24
24
  t.string :last_login_ip # optional, see Authlogic::Session::MagicColumns
25
25
  t.timestamps
26
26
  end
27
- add_index :spud_users,:login
28
- add_index :spud_users,:email
27
+ add_index :spud_users, :login
28
+ add_index :spud_users, :email
29
29
  end
30
30
  end
@@ -2,6 +2,5 @@
2
2
  class AddTimeZoneToSpudUser < ActiveRecord::Migration
3
3
  def change
4
4
  add_column :spud_users, :time_zone, :string
5
-
6
5
  end
7
6
  end
@@ -2,6 +2,5 @@
2
2
  class AddScopeToSpudAdminPermissions < ActiveRecord::Migration
3
3
  def change
4
4
  add_column :spud_admin_permissions, :scope, :string
5
-
6
5
  end
7
6
  end
@@ -2,10 +2,10 @@
2
2
  class CreateSpudPermissions < ActiveRecord::Migration
3
3
  def change
4
4
  create_table :spud_permissions do |t|
5
- t.string :name, :null => false
6
- t.string :tag, :null => false
5
+ t.string :name, null: false
6
+ t.string :tag, null: false
7
7
  t.timestamps
8
8
  end
9
- add_index :spud_permissions, :tag, :unique => true
9
+ add_index :spud_permissions, :tag, unique: true
10
10
  end
11
11
  end
@@ -2,8 +2,8 @@
2
2
  class CreateSpudRolePermissions < ActiveRecord::Migration
3
3
  def change
4
4
  create_table :spud_role_permissions do |t|
5
- t.integer :spud_role_id, :null => false
6
- t.string :spud_permission_tag, :null => false
5
+ t.integer :spud_role_id, null: false
6
+ t.string :spud_permission_tag, null: false
7
7
  t.timestamps
8
8
  end
9
9
  add_index :spud_role_permissions, :spud_role_id
@@ -7,6 +7,6 @@ class CreateSpudPermalinks < ActiveRecord::Migration
7
7
  t.integer :attachment_id
8
8
  t.timestamps
9
9
  end
10
- add_index :spud_permalinks, [:attachment_type,:attachment_id], :name => "idx_permalink_attachment"
10
+ add_index :spud_permalinks, [:attachment_type, :attachment_id], name: 'idx_permalink_attachment'
11
11
  end
12
12
  end
@@ -2,6 +2,6 @@
2
2
  class AddSiteIdToSpudPermalinks < ActiveRecord::Migration
3
3
  def change
4
4
  add_column :spud_permalinks, :site_id, :integer
5
- add_index :spud_permalinks, :site_id, :name => "idx_permalinks_site_id"
5
+ add_index :spud_permalinks, :site_id, name: 'idx_permalinks_site_id'
6
6
  end
7
7
  end
@@ -1,12 +1,12 @@
1
1
  # This migration comes from tb_permalinks (originally 20120912123700)
2
2
  class ModifySiteIdForSpudPermalinks < ActiveRecord::Migration
3
3
  def up
4
- change_column :spud_permalinks, :site_id, :integer, :default => 0, :null => false
5
- SpudPermalink.where(:site_id => nil).each {|f| f.site_id = 0 ; f.save}
4
+ change_column :spud_permalinks, :site_id, :integer, default: 0, null: false
5
+ # SpudPermalink.where(:site_id => nil).each {|f| f.site_id = 0 ; f.save}
6
6
  end
7
7
 
8
8
  def down
9
- change_column :spud_permalinks, :site_id, :integer, :default => nil, :null => true
10
- SpudPermalink.where(:site_id => 0).each {|f| f.site_id = nil ; f.save}
9
+ change_column :spud_permalinks, :site_id, :integer, default: nil, null: true
10
+ # SpudPermalink.where(:site_id => 0).each {|f| f.site_id = nil ; f.save}
11
11
  end
12
12
  end
@@ -7,7 +7,7 @@ class CreateSpudPages < ActiveRecord::Migration
7
7
  t.datetime :publish_at
8
8
  t.integer :created_by
9
9
  t.integer :updated_by
10
- t.string :format,:default => "html"
10
+ t.string :format, default: 'html'
11
11
  t.integer :spud_page_id
12
12
  t.text :meta_description
13
13
  t.string :meta_keywords
@@ -6,13 +6,13 @@ class CreateSpudMenuItems < ActiveRecord::Migration
6
6
  t.integer :parent_id
7
7
  t.integer :item_type
8
8
  t.integer :spud_page_id
9
- t.integer :menu_order,:default => 0
9
+ t.integer :menu_order, default: 0
10
10
  t.string :url
11
11
 
12
12
  t.timestamps
13
13
  end
14
14
 
15
- add_index :spud_menu_items,[:parent_type,:parent_id]
16
- add_index :spud_menu_items,[:menu_order]
15
+ add_index :spud_menu_items, [:parent_type, :parent_id]
16
+ add_index :spud_menu_items, [:menu_order]
17
17
  end
18
18
  end
@@ -9,6 +9,6 @@ class CreateSpudPagePartials < ActiveRecord::Migration
9
9
 
10
10
  t.timestamps
11
11
  end
12
- add_index :spud_page_partials,:spud_page_id
12
+ add_index :spud_page_partials, :spud_page_id
13
13
  end
14
14
  end
@@ -1,7 +1,7 @@
1
1
  # This migration comes from tb_cms (originally 20120104194032)
2
2
  class AddVisibilityToSpudPages < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_pages, :visibility, :integer,:default => 0
5
- add_column :spud_pages, :published, :boolean,:default => true
4
+ add_column :spud_pages, :visibility, :integer, default: 0
5
+ add_column :spud_pages, :published, :boolean, default: true
6
6
  end
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # This migration comes from tb_cms (originally 20120111134754)
2
2
  class AddUseCustomUrlNameToSpudPages < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_pages, :use_custom_url_name, :boolean,:default => false
4
+ add_column :spud_pages, :use_custom_url_name, :boolean, default: false
5
5
  end
6
6
  end
@@ -3,6 +3,6 @@ class AddMenuIdToSpudMenuItems < ActiveRecord::Migration
3
3
 
4
4
  def change
5
5
  add_column :spud_menu_items, :spud_menu_id, :integer
6
- add_index :spud_menu_items,:spud_menu_id
6
+ add_index :spud_menu_items, :spud_menu_id
7
7
  end
8
8
  end
@@ -2,6 +2,5 @@
2
2
  class AddClassesToSpudMenuItems < ActiveRecord::Migration
3
3
  def change
4
4
  add_column :spud_menu_items, :classes, :string
5
-
6
5
  end
7
6
  end
@@ -1,7 +1,7 @@
1
1
  # This migration comes from tb_cms (originally 20120329132314)
2
2
  class AddSiteIdToSpudPages < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_pages, :site_id, :integer
5
- add_index :spud_pages,:site_id
4
+ add_column :spud_pages, :site_id, :integer
5
+ add_index :spud_pages, :site_id
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # This migration comes from tb_cms (originally 20120329132322)
2
2
  class AddSiteIdToSpudTemplates < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_templates, :site_id, :integer
5
- add_index :spud_templates,:site_id
4
+ add_column :spud_templates, :site_id, :integer
5
+ add_index :spud_templates, :site_id
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # This migration comes from tb_cms (originally 20120329132330)
2
2
  class AddSiteIdToSpudMenus < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_menus, :site_id, :integer
5
- add_index :spud_menus,:site_id
4
+ add_column :spud_menus, :site_id, :integer
5
+ add_index :spud_menus, :site_id
6
6
  end
7
7
  end
@@ -9,6 +9,6 @@ class CreateSpudPagePartialRevisions < ActiveRecord::Migration
9
9
  t.timestamps
10
10
  end
11
11
 
12
- add_index :spud_page_partial_revisions,[:spud_page_id,:name],:name => "revision_idx"
12
+ add_index :spud_page_partial_revisions, [:spud_page_id, :name], name: 'revision_idx'
13
13
  end
14
14
  end
@@ -1,16 +1,16 @@
1
1
  # This migration comes from tb_cms (originally 20120912121313)
2
2
  class ModifySiteIdForSpudPages < ActiveRecord::Migration
3
3
  def up
4
- change_column :spud_pages,:site_id,:integer,:default => 0,:null => false
5
- change_column :spud_templates,:site_id,:integer,:default => 0,:null => false
6
- change_column :spud_menus,:site_id,:integer,:default => 0,:null => false
7
- SpudPage.where(:site_id => nil).each {|f| f.site_id = 0 ; f.save}
8
- SpudMenu.where(:site_id => nil).each {|f| f.site_id = 0 ; f.save}
4
+ change_column :spud_pages, :site_id, :integer, default: 0, null: false
5
+ change_column :spud_templates, :site_id, :integer, default: 0, null: false
6
+ change_column :spud_menus, :site_id, :integer, default: 0, null: false
7
+ SpudPage.where(site_id: nil).each { |f| f.site_id = 0; f.save }
8
+ SpudMenu.where(site_id: nil).each { |f| f.site_id = 0; f.save }
9
9
  end
10
10
 
11
11
  def down
12
- change_column :spud_pages,:site_id,:integer,:default => nil,:null => true
13
- change_column :spud_templates,:site_id,:integer,:default => nil,:null => true
14
- change_column :spud_menus,:site_id,:integer,:default => nil,:null => true
12
+ change_column :spud_pages, :site_id, :integer, default: nil, null: true
13
+ change_column :spud_templates, :site_id, :integer, default: nil, null: true
14
+ change_column :spud_menus, :site_id, :integer, default: nil, null: true
15
15
  end
16
16
  end
@@ -7,6 +7,6 @@ class CreateSpudPageLiquidTags < ActiveRecord::Migration
7
7
  t.string :value
8
8
  t.timestamps
9
9
  end
10
- add_index :spud_page_liquid_tags, [:tag_name,:value]
10
+ add_index :spud_page_liquid_tags, [:tag_name, :value]
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ class CreateSpudSnippets < ActiveRecord::Migration
6
6
  t.text :content
7
7
  t.string :format
8
8
  t.text :content_processed
9
- t.integer :site_id, :default => 0
9
+ t.integer :site_id, default: 0
10
10
  t.timestamps
11
11
  end
12
12
 
@@ -14,5 +14,4 @@ class CreateSpudSnippets < ActiveRecord::Migration
14
14
  add_index :spud_snippets, :name
15
15
  end
16
16
 
17
-
18
17
  end
@@ -3,10 +3,10 @@ class ChangeLiquidTagsToPolymorphic < ActiveRecord::Migration
3
3
  def up
4
4
  rename_column :spud_page_liquid_tags, :spud_page_partial_id, :attachment_id
5
5
  add_column :spud_page_liquid_tags, :attachment_type, :string
6
- add_index :spud_page_liquid_tags, [:attachment_type, :attachment_id], :name => 'inde_spud_page_liquid_tags_on_attachment'
6
+ add_index :spud_page_liquid_tags, [:attachment_type, :attachment_id], name: 'inde_spud_page_liquid_tags_on_attachment'
7
7
  if defined?(SpudPageLiquidTag)
8
8
  SpudPageLiquidTag.all.each do |f|
9
- f.update_attributes(:attachment_type => "SpudPagePartial")
9
+ f.update_attributes(attachment_type: 'SpudPagePartial')
10
10
  end
11
11
  end
12
12
  end
@@ -7,12 +7,10 @@ class DropSpudPageLiquidTags < ActiveRecord::Migration
7
7
  def up
8
8
  if defined?(SpudLiquidTag)
9
9
  SpudPageLiquidTag.all.each do |tag|
10
- SpudLiquidTag.create({
11
- :attachment_id => tag.attachment_id,
12
- :attachment_type => tag.attachment_type,
13
- :tag_name => tag.tag_name,
14
- :value => tag.value
15
- })
10
+ SpudLiquidTag.create(attachment_id: tag.attachment_id,
11
+ attachment_type: tag.attachment_type,
12
+ tag_name: tag.tag_name,
13
+ value: tag.value)
16
14
  end
17
15
  end
18
16
  drop_table :spud_page_liquid_tags
@@ -26,7 +24,7 @@ class DropSpudPageLiquidTags < ActiveRecord::Migration
26
24
  t.string :value
27
25
  t.timestamps
28
26
  end
29
- add_index :spud_page_liquid_tags, [:tag_name,:value]
30
- add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id]
27
+ add_index :spud_page_liquid_tags, [:tag_name, :value]
28
+ add_index :spud_page_liquid_tags, [:attachment_type, :attachment_id]
31
29
  end
32
30
  end
@@ -5,6 +5,7 @@ class RemoveSiteIdFromCmsTables < ActiveRecord::Migration
5
5
  remove_column :spud_pages, :site_id
6
6
  remove_column :spud_snippets, :site_id
7
7
  end
8
+
8
9
  def down
9
10
  add_column :spud_menus, :site_id, :integer
10
11
  add_column :spud_pages, :site_id, :integer
@@ -1,6 +1,6 @@
1
1
  # This migration comes from tb_core (originally 20150610143438)
2
2
  class AddRequiresPasswordChangeToSpudUsers < ActiveRecord::Migration
3
3
  def change
4
- add_column :spud_users, :requires_password_change, :boolean, :default => false
4
+ add_column :spud_users, :requires_password_change, :boolean, default: false
5
5
  end
6
6
  end
@@ -4,12 +4,12 @@ class CreateTbRedirects < ActiveRecord::Migration
4
4
  create_table :tb_redirects do |t|
5
5
  t.string :owner_type
6
6
  t.integer :owner_id
7
- t.string :source, :null => false
8
- t.string :destination, :null => false
7
+ t.string :source, null: false
8
+ t.string :destination, null: false
9
9
  t.string :created_by
10
10
  t.timestamps null: false
11
11
  end
12
12
  add_index :tb_redirects, [:owner_type, :owner_id]
13
- add_index :tb_redirects, :source, :unique => true
13
+ add_index :tb_redirects, :source, unique: true
14
14
  end
15
15
  end