comfortable_mexican_sofa 1.12.8 → 1.12.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -3
  3. data/app/assets/fonts/comfy/admin/cms/lib/redactor-font.eot +0 -0
  4. data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +46 -11
  5. data/app/assets/javascripts/comfy/admin/cms/lib/redactor.js +1807 -570
  6. data/app/assets/stylesheets/comfy/admin/cms/bootstrap_overrides.sass +6 -1
  7. data/app/assets/stylesheets/comfy/admin/cms/lib/redactor.css +79 -52
  8. data/app/controllers/comfy/admin/cms/base_controller.rb +2 -1
  9. data/app/controllers/comfy/admin/cms/pages_controller.rb +4 -1
  10. data/app/controllers/comfy/cms/base_controller.rb +5 -5
  11. data/app/controllers/comfy/cms/content_controller.rb +4 -0
  12. data/app/helpers/comfy/cms_helper.rb +72 -70
  13. data/app/models/comfy/cms/file.rb +0 -1
  14. data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
  15. data/app/views/comfy/admin/cms/layouts/_index_branch.html.haml +2 -1
  16. data/config/environments/test.rb +2 -0
  17. data/config/initializers/comfortable_mexican_sofa.rb +12 -0
  18. data/config/locales/cs.yml +2 -3
  19. data/config/locales/da.yml +2 -3
  20. data/config/locales/de.yml +2 -3
  21. data/config/locales/en.yml +2 -3
  22. data/config/locales/es.yml +2 -3
  23. data/config/locales/fr.yml +2 -3
  24. data/config/locales/it.yml +2 -3
  25. data/config/locales/ja.yml +2 -3
  26. data/config/locales/nb.yml +2 -3
  27. data/config/locales/nl.yml +2 -3
  28. data/config/locales/pl.yml +40 -41
  29. data/config/locales/pt-BR.yml +2 -3
  30. data/config/locales/ru.yml +2 -3
  31. data/config/locales/sv.yml +2 -3
  32. data/config/locales/uk.yml +2 -3
  33. data/config/locales/zh-CN.yml +2 -3
  34. data/config/locales/zh-TW.yml +16 -17
  35. data/db/migrate/01_create_cms.rb +18 -25
  36. data/db/upgrade_migrations/08_upgrade_to_1_12_0.rb +2 -2
  37. data/doc/preview.png +0 -0
  38. data/lib/comfortable_mexican_sofa.rb +1 -0
  39. data/lib/comfortable_mexican_sofa/access_control/admin_authentication.rb +3 -2
  40. data/lib/comfortable_mexican_sofa/access_control/public_authorization.rb +8 -0
  41. data/lib/comfortable_mexican_sofa/configuration.rb +4 -0
  42. data/lib/comfortable_mexican_sofa/engine.rb +5 -1
  43. data/lib/comfortable_mexican_sofa/fixture/file.rb +22 -22
  44. data/lib/comfortable_mexican_sofa/tags/asset.rb +8 -3
  45. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  46. data/test/controllers/comfy/admin/cms/pages_controller_test.rb +22 -0
  47. data/test/controllers/comfy/cms/content_controller_test.rb +12 -0
  48. data/test/integration/access_control_test.rb +24 -1
  49. data/test/lib/fixtures/files_test.rb +29 -27
  50. data/test/lib/tags/asset_test.rb +42 -9
  51. data/test/test_helper.rb +8 -3
  52. metadata +5 -3
@@ -208,9 +208,6 @@ pt-BR:
208
208
  index:
209
209
  title: Arquivos
210
210
  new_link: Enviar Novo Arquivo
211
- edit: Editar
212
- delete: Excluir
213
- are_you_sure: Tem certeza?
214
211
  button: Enviar Arquivos
215
212
  new:
216
213
  title: Novo Arquivo
@@ -226,6 +223,8 @@ pt-BR:
226
223
  page_form:
227
224
  are_you_sure: Tem certeza?
228
225
  file:
226
+ edit: Editar
227
+ delete: Excluir
229
228
  are_you_sure: Tem certeza?
230
229
 
231
230
  categories:
@@ -208,9 +208,6 @@ ru:
208
208
  index:
209
209
  title: Файлы
210
210
  new_link: Загрузить новый файл
211
- edit: Редактировать
212
- delete: Удалить
213
- are_you_sure: Вы уверены?
214
211
  button: Загрузить файлы
215
212
  new:
216
213
  title: Новый файл
@@ -226,6 +223,8 @@ ru:
226
223
  page_form:
227
224
  are_you_sure: Вы уверены?
228
225
  file:
226
+ edit: Редактировать
227
+ delete: Удалить
229
228
  are_you_sure: Вы уверены?
230
229
 
231
230
  categories:
@@ -208,9 +208,6 @@ sv:
208
208
  index:
209
209
  title: Filer
210
210
  new_link: Ladda upp en ny fil
211
- edit: Ända
212
- delete: Delete
213
- are_you_sure: Är du säker?
214
211
  button: Ladda upp filer
215
212
  new:
216
213
  title: Ny Fil
@@ -226,6 +223,8 @@ sv:
226
223
  page_form:
227
224
  are_you_sure: Är du säker?
228
225
  file:
226
+ edit: Ända
227
+ delete: Delete
229
228
  are_you_sure: Är du säker?
230
229
 
231
230
  categories:
@@ -208,9 +208,6 @@ uk:
208
208
  index:
209
209
  title: Файли
210
210
  new_link: Завантажити новий файл
211
- edit: Редагувати
212
- delete: Видалити
213
- are_you_sure: Ви впевнені?
214
211
  button: Завантажити файли
215
212
  new:
216
213
  title: Новий файл
@@ -226,6 +223,8 @@ uk:
226
223
  page_form:
227
224
  are_you_sure: Ви впевнені?
228
225
  file:
226
+ edit: Редагувати
227
+ delete: Видалити
229
228
  are_you_sure: Ви впевнені?
230
229
 
231
230
  categories:
@@ -208,9 +208,6 @@ zh-CN:
208
208
  index:
209
209
  title: 文件
210
210
  new_link: 上传新文件
211
- edit: 编辑
212
- delete: 删除
213
- are_you_sure: 确定删除该文件吗?
214
211
  button: 上传文件
215
212
  new:
216
213
  title: 新文件
@@ -226,6 +223,8 @@ zh-CN:
226
223
  page_form:
227
224
  are_you_sure: 确定删除该文件吗?
228
225
  file:
226
+ edit: 编辑
227
+ delete: 删除
229
228
  are_you_sure: 确定删除该文件吗?
230
229
 
231
230
  categories:
@@ -27,8 +27,8 @@ zh-TW:
27
27
  comfy/cms/page:
28
28
  label: 頁面名稱
29
29
  layout_id: 佈局
30
- slug: Slug
31
- full_path: Full path
30
+ slug: 路徑名
31
+ full_path: 完整路徑
32
32
  parent_id: 上級
33
33
  target_page_id: 跳轉至
34
34
  content: 內容
@@ -53,7 +53,7 @@ zh-TW:
53
53
  cms:
54
54
  base:
55
55
  site_not_found: 沒有該站點
56
- fixtures_enabled: CMS夾具已經啟用,在此處的所有修改將被忽略。
56
+ fixtures_enabled: CMS 樣板已經啟用,在此處的所有修改將被忽略。
57
57
 
58
58
  sites: 站點
59
59
  layouts: 佈局
@@ -82,7 +82,7 @@ zh-TW:
82
82
  title: 編輯站點
83
83
  form:
84
84
  create: 創建站點
85
- cancel: Cancel
85
+ cancel: 取消
86
86
  update: 更新站點
87
87
  is_mirrored: 鏡像
88
88
 
@@ -147,14 +147,14 @@ zh-TW:
147
147
  select_target_page: 沒有跳轉
148
148
  preview: 預覽
149
149
  create: 創建頁面
150
- cancel: Cancel
150
+ cancel: 取消
151
151
  update: 更新頁面
152
152
  is_published: 發佈
153
- choose_link: Select page...
153
+ choose_link: 選擇頁面...
154
154
  form_blocks:
155
155
  no_tags: |-
156
- 佈局中沒有定義內容標籤。<br/>
157
- 編輯內容使其包含一個頁面或者field標籤。例如: <code>{{cms:page:content}}</code>
156
+ 佈局中沒有定義內容標記。<br/>
157
+ 編輯內容使其包含一個頁面或者欄位標記。例如: <code>{{cms:page:content}}</code>
158
158
 
159
159
  snippets:
160
160
  created: 片段創建成功
@@ -178,7 +178,7 @@ zh-TW:
178
178
  <<: *revision
179
179
  form:
180
180
  create: 創建片段
181
- cancel: Cancel
181
+ cancel: 取消
182
182
  update: 更新片段
183
183
 
184
184
  revisions:
@@ -192,10 +192,10 @@ zh-TW:
192
192
  full_path: 全路徑
193
193
  slug: 嵌條
194
194
  update: 更新到該修訂版本
195
- content: Content
196
- changes: Changes
197
- previous: Previous
198
- current: Current
195
+ content: 內容
196
+ changes: 變更
197
+ previous: 先前
198
+ current: 現在
199
199
 
200
200
  files:
201
201
  created: 文件上傳成功
@@ -208,9 +208,6 @@ zh-TW:
208
208
  index:
209
209
  title: 文件
210
210
  new_link: 上傳新文件
211
- edit: 編輯
212
- delete: 刪除
213
- are_you_sure: 確定刪除該文件嗎?
214
211
  button: 上傳文件
215
212
  new:
216
213
  title: 新文件
@@ -219,13 +216,15 @@ zh-TW:
219
216
  form:
220
217
  current_file: 當前文件
221
218
  create: 上傳文件
222
- cancel: Cancel
219
+ cancel: 取消
223
220
  update: 更新文件
224
221
  delete: 刪除
225
222
  are_you_sure: 確定刪除該文件嗎?
226
223
  page_form:
227
224
  are_you_sure: 確定刪除該文件嗎?
228
225
  file:
226
+ edit: 編輯
227
+ delete: 刪除
229
228
  are_you_sure: 確定刪除該文件嗎?
230
229
 
231
230
  categories:
@@ -1,14 +1,7 @@
1
1
  class CreateCms < ActiveRecord::Migration
2
-
2
+
3
3
  def self.up
4
-
5
- text_limit = case ActiveRecord::Base.connection.adapter_name
6
- when 'PostgreSQL'
7
- { }
8
- else
9
- { :limit => 16777215 }
10
- end
11
-
4
+
12
5
  # -- Sites --------------------------------------------------------------
13
6
  create_table :comfy_cms_sites do |t|
14
7
  t.string :label, :null => false
@@ -20,7 +13,7 @@ class CreateCms < ActiveRecord::Migration
20
13
  end
21
14
  add_index :comfy_cms_sites, :hostname
22
15
  add_index :comfy_cms_sites, :is_mirrored
23
-
16
+
24
17
  # -- Layouts ------------------------------------------------------------
25
18
  create_table :comfy_cms_layouts do |t|
26
19
  t.integer :site_id, :null => false
@@ -28,16 +21,16 @@ class CreateCms < ActiveRecord::Migration
28
21
  t.string :app_layout
29
22
  t.string :label, :null => false
30
23
  t.string :identifier, :null => false
31
- t.text :content, text_limit
32
- t.text :css, text_limit
33
- t.text :js, text_limit
24
+ t.text :content, :limit => 16777215
25
+ t.text :css, :limit => 16777215
26
+ t.text :js, :limit => 16777215
34
27
  t.integer :position, :null => false, :default => 0
35
28
  t.boolean :is_shared, :null => false, :default => false
36
29
  t.timestamps
37
30
  end
38
31
  add_index :comfy_cms_layouts, [:parent_id, :position]
39
32
  add_index :comfy_cms_layouts, [:site_id, :identifier], :unique => true
40
-
33
+
41
34
  # -- Pages --------------------------------------------------------------
42
35
  create_table :comfy_cms_pages do |t|
43
36
  t.integer :site_id, :null => false
@@ -47,7 +40,7 @@ class CreateCms < ActiveRecord::Migration
47
40
  t.string :label, :null => false
48
41
  t.string :slug
49
42
  t.string :full_path, :null => false
50
- t.text :content_cache, text_limit
43
+ t.text :content_cache, :limit => 16777215
51
44
  t.integer :position, :null => false, :default => 0
52
45
  t.integer :children_count, :null => false, :default => 0
53
46
  t.boolean :is_published, :null => false, :default => true
@@ -56,30 +49,30 @@ class CreateCms < ActiveRecord::Migration
56
49
  end
57
50
  add_index :comfy_cms_pages, [:site_id, :full_path]
58
51
  add_index :comfy_cms_pages, [:parent_id, :position]
59
-
52
+
60
53
  # -- Page Blocks --------------------------------------------------------
61
54
  create_table :comfy_cms_blocks do |t|
62
55
  t.string :identifier, :null => false
63
- t.text :content, text_limit
56
+ t.text :content, :limit => 16777215
64
57
  t.references :blockable, :polymorphic => true
65
58
  t.timestamps
66
59
  end
67
60
  add_index :comfy_cms_blocks, [:identifier]
68
61
  add_index :comfy_cms_blocks, [:blockable_id, :blockable_type]
69
-
62
+
70
63
  # -- Snippets -----------------------------------------------------------
71
64
  create_table :comfy_cms_snippets do |t|
72
65
  t.integer :site_id, :null => false
73
66
  t.string :label, :null => false
74
67
  t.string :identifier, :null => false
75
- t.text :content, text_limit
68
+ t.text :content, :limit => 16777215
76
69
  t.integer :position, :null => false, :default => 0
77
70
  t.boolean :is_shared, :null => false, :default => false
78
71
  t.timestamps
79
72
  end
80
73
  add_index :comfy_cms_snippets, [:site_id, :identifier], :unique => true
81
74
  add_index :comfy_cms_snippets, [:site_id, :position]
82
-
75
+
83
76
  # -- Files --------------------------------------------------------------
84
77
  create_table :comfy_cms_files do |t|
85
78
  t.integer :site_id, :null => false
@@ -96,17 +89,17 @@ class CreateCms < ActiveRecord::Migration
96
89
  add_index :comfy_cms_files, [:site_id, :file_file_name]
97
90
  add_index :comfy_cms_files, [:site_id, :position]
98
91
  add_index :comfy_cms_files, [:site_id, :block_id]
99
-
92
+
100
93
  # -- Revisions -----------------------------------------------------------
101
94
  create_table :comfy_cms_revisions, :force => true do |t|
102
95
  t.string :record_type, :null => false
103
96
  t.integer :record_id, :null => false
104
- t.text :data, text_limit
97
+ t.text :data, :limit => 16777215
105
98
  t.datetime :created_at
106
99
  end
107
100
  add_index :comfy_cms_revisions, [:record_type, :record_id, :created_at],
108
101
  :name => 'index_cms_revisions_on_rtype_and_rid_and_created_at'
109
-
102
+
110
103
  # -- Categories ---------------------------------------------------------
111
104
  create_table :comfy_cms_categories, :force => true do |t|
112
105
  t.integer :site_id, :null => false
@@ -115,7 +108,7 @@ class CreateCms < ActiveRecord::Migration
115
108
  end
116
109
  add_index :comfy_cms_categories, [:site_id, :categorized_type, :label], :unique => true,
117
110
  :name => 'index_cms_categories_on_site_id_and_cat_type_and_label'
118
-
111
+
119
112
  create_table :comfy_cms_categorizations, :force => true do |t|
120
113
  t.integer :category_id, :null => false
121
114
  t.string :categorized_type, :null => false
@@ -124,7 +117,7 @@ class CreateCms < ActiveRecord::Migration
124
117
  add_index :comfy_cms_categorizations, [:category_id, :categorized_type, :categorized_id], :unique => true,
125
118
  :name => 'index_cms_categorizations_on_cat_id_and_catd_type_and_catd_id'
126
119
  end
127
-
120
+
128
121
  def self.down
129
122
  drop_table :comfy_cms_sites
130
123
  drop_table :comfy_cms_layouts
@@ -65,11 +65,11 @@ class UpgradeTo1120 < ActiveRecord::Migration
65
65
  rename_table :comfy_cms_blocks, :cms_blocks
66
66
  rename_table :comfy_cms_snippets, :cms_snippets
67
67
  rename_table :comfy_cms_files, :cms_files
68
- rename_index :cms_revisions,
68
+ rename_index :comfy_cms_revisions,
69
69
  'index_cms_revisions_on_record_type_id_and_created',
70
70
  'index_cms_revisions_on_record_type_and_record_id_and_created_at'
71
71
  rename_table :comfy_cms_revisions, :cms_revisions
72
- rename_index :cms_categories,
72
+ rename_index :comfy_cms_categories,
73
73
  'index_cms_categories_on_site_id_and_cat_type_and_label',
74
74
  'index_cms_categories_on_site_id_and_categorized_type_and_label'
75
75
  rename_table :comfy_cms_categories, :cms_categories
Binary file
@@ -10,6 +10,7 @@ require_relative 'comfortable_mexican_sofa/routing'
10
10
  require_relative 'comfortable_mexican_sofa/access_control/admin_authentication'
11
11
  require_relative 'comfortable_mexican_sofa/access_control/admin_authorization'
12
12
  require_relative 'comfortable_mexican_sofa/access_control/public_authentication'
13
+ require_relative 'comfortable_mexican_sofa/access_control/public_authorization'
13
14
  require_relative 'comfortable_mexican_sofa/render_methods'
14
15
  require_relative 'comfortable_mexican_sofa/view_hooks'
15
16
  require_relative 'comfortable_mexican_sofa/form_builder'
@@ -2,8 +2,9 @@ module ComfortableMexicanSofa::AccessControl
2
2
  module AdminAuthentication
3
3
  # Set username and password in config/initializers/comfortable_mexican_sofa.rb
4
4
  # Like this:
5
- # ComfortableMexicanSofa::AccessControl::AdminAuthentication = 'myname'
6
- # ComfortableMexicanSofa::AccessControl::AdminAuthentication = 'mypassword'
5
+ # ComfortableMexicanSofa::AccessControl::AdminAuthentication.username = 'myname'
6
+ # ComfortableMexicanSofa::AccessControl::AdminAuthentication.password = 'mypassword'
7
+
7
8
 
8
9
  mattr_accessor :username,
9
10
  :password
@@ -0,0 +1,8 @@
1
+ module ComfortableMexicanSofa::AccessControl
2
+ module PublicAuthorization
3
+ # By default there's no authorization of any kind
4
+ def authorize
5
+ true
6
+ end
7
+ end
8
+ end
@@ -18,6 +18,9 @@ class ComfortableMexicanSofa::Configuration
18
18
  # Module that will handle authentication for public pages
19
19
  attr_accessor :public_auth
20
20
 
21
+ # Module that will handle authorization against public resources
22
+ attr_accessor :public_authorization
23
+
21
24
  # When arriving at /cms-admin you may chose to redirect to arbirtary path,
22
25
  # for example '/cms-admin/users'
23
26
  attr_accessor :admin_route_redirect
@@ -82,6 +85,7 @@ class ComfortableMexicanSofa::Configuration
82
85
  @admin_auth = 'ComfortableMexicanSofa::AccessControl::AdminAuthentication'
83
86
  @admin_authorization = 'ComfortableMexicanSofa::AccessControl::AdminAuthorization'
84
87
  @public_auth = 'ComfortableMexicanSofa::AccessControl::PublicAuthentication'
88
+ @public_authorization = 'ComfortableMexicanSofa::AccessControl::PublicAuthorization'
85
89
  @seed_data_path = nil
86
90
  @admin_route_redirect = ''
87
91
  @enable_sitemap = true
@@ -17,6 +17,10 @@ require 'plupload-rails'
17
17
 
18
18
  module ComfortableMexicanSofa
19
19
  class Engine < ::Rails::Engine
20
- # ...
20
+ config.to_prepare do
21
+ Dir.glob(Rails.root + "app/decorators/comfortable_mexican_sofa/*_decorator*.rb").each do |c|
22
+ require_dependency(c)
23
+ end
24
+ end
21
25
  end
22
26
  end
@@ -4,29 +4,29 @@ module ComfortableMexicanSofa::Fixture::File
4
4
  Dir["#{self.path}[^_]*"].each do |file_path|
5
5
  filename = ::File.basename(file_path)
6
6
  file = self.site.files.where(:file_file_name => filename).first || self.site.files.new
7
-
7
+
8
8
  # setting attributes
9
9
  categories = []
10
10
  if File.exists?(attrs_path = File.join(self.path, "_#{filename}.yml"))
11
11
  if fresh_fixture?(file, attrs_path)
12
12
  attrs = get_attributes(attrs_path)
13
-
14
- block = if (attrs['page'] && attrs['block']) && (page = self.site.pages.find_by_slug(attrs['page']))
13
+
14
+ block = if (attrs['page'] && attrs['block']) && (page = self.site.pages.find_by_full_path(attrs['page']))
15
15
  page.blocks.find_by_identifier(attrs['block'])
16
16
  end
17
-
17
+
18
18
  file.label = attrs['label']
19
19
  file.description = attrs['description']
20
20
  categories = attrs['categories']
21
21
  file.block = block
22
22
  end
23
23
  end
24
-
24
+
25
25
  # setting actual file
26
26
  if fresh_fixture?(file, file_path)
27
27
  file.file = open(file_path)
28
28
  end
29
-
29
+
30
30
  if file.changed? || self.force_import
31
31
  if file.save
32
32
  save_categorizations!(file, categories)
@@ -35,49 +35,49 @@ module ComfortableMexicanSofa::Fixture::File
35
35
  ComfortableMexicanSofa.logger.warn("[FIXTURES] Failed to import File \n#{file.errors.inspect}")
36
36
  end
37
37
  end
38
-
38
+
39
39
  self.fixture_ids << file.id
40
40
  end
41
-
41
+
42
42
  # cleaning up
43
43
  self.site.files.where('id NOT IN (?) AND block_id IS NULL', fixture_ids).each{ |s| s.destroy }
44
44
  end
45
45
  end
46
-
46
+
47
47
  class Exporter < ComfortableMexicanSofa::Fixture::Exporter
48
48
  def export!
49
49
  prepare_folder!(self.path)
50
-
50
+
51
51
  self.site.files.each do |file|
52
52
  file_path = File.join(self.path, file.file_file_name)
53
53
  block = file.block
54
- page = block.present?? block.page : nil
55
-
54
+ page = block.present?? block.blockable : nil
55
+
56
56
  # writing attributes
57
57
  open(::File.join(self.path, "_#{file.file_file_name}.yml"), 'w') do |f|
58
58
  f.write({
59
59
  'label' => file.label,
60
60
  'description' => file.description,
61
61
  'categories' => file.categories.map{|c| c.label},
62
- 'page' => page.present? ? page.slug : nil,
63
- 'block' => block.present? ? block.identifier : nil
62
+ 'page' => page.present?? page.full_path : nil,
63
+ 'block' => block.present?? block.identifier : nil
64
64
  }.to_yaml)
65
65
  end
66
-
66
+
67
67
  # writing content
68
68
  data_path = file.file.options[:storage] == :filesystem ?
69
69
  file.file.path :
70
70
  file.file.url
71
-
72
- unless ::File.exists?(data_path)
71
+
72
+ begin
73
+ open(::File.join(self.path, ::File.basename(file_path)), 'wb') do |f|
74
+ open(data_path) { |src| f.write(src.read) }
75
+ end
76
+ rescue Errno::ENOENT, OpenURI::HTTPError
73
77
  ComfortableMexicanSofa.logger.warn("[FIXTURES] No physical File \t #{file.file_file_name}")
74
78
  next
75
79
  end
76
-
77
- open(::File.join(self.path, ::File.basename(file_path)), 'wb') do |f|
78
- open(data_path) { |src| f.write(src.read) }
79
- end
80
-
80
+
81
81
  ComfortableMexicanSofa.logger.info("[FIXTURES] Exported File \t #{file.file_file_name}")
82
82
  end
83
83
  end