comfortable_mexican_sofa 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/app/assets/stylesheets/comfy/admin/cms/base.sass +1 -1
  4. data/app/controllers/comfy/admin/cms/revisions/base_controller.rb +47 -0
  5. data/app/controllers/comfy/admin/cms/revisions/layout_controller.rb +15 -0
  6. data/app/controllers/comfy/admin/cms/revisions/page_controller.rb +22 -0
  7. data/app/controllers/comfy/admin/cms/revisions/snippet_controller.rb +15 -0
  8. data/app/controllers/comfy/admin/cms/revisions/translation_controller.rb +23 -0
  9. data/app/views/comfy/admin/cms/layouts/edit.html.haml +2 -2
  10. data/app/views/comfy/admin/cms/pages/edit.html.haml +3 -4
  11. data/app/views/comfy/admin/cms/revisions/_sidebar.html.haml +2 -0
  12. data/app/views/comfy/admin/cms/revisions/show.html.haml +2 -3
  13. data/app/views/comfy/admin/cms/snippets/edit.html.haml +2 -3
  14. data/app/views/comfy/admin/cms/translations/_sidebar.html.haml +1 -1
  15. data/app/views/comfy/admin/cms/translations/edit.html.haml +3 -4
  16. data/config/environments/development.rb +2 -0
  17. data/config/environments/test.rb +2 -0
  18. data/config/locales/cs.yml +7 -12
  19. data/config/locales/da.yml +7 -12
  20. data/config/locales/de.yml +7 -12
  21. data/config/locales/en.yml +7 -12
  22. data/config/locales/es.yml +7 -12
  23. data/config/locales/fr.yml +7 -12
  24. data/config/locales/it.yml +7 -12
  25. data/config/locales/ja.yml +7 -12
  26. data/config/locales/nb.yml +7 -12
  27. data/config/locales/nl.yml +7 -12
  28. data/config/locales/pl.yml +7 -12
  29. data/config/locales/pt-BR.yml +7 -12
  30. data/config/locales/ru.yml +7 -12
  31. data/config/locales/sk.yml +7 -12
  32. data/config/locales/sv.yml +7 -12
  33. data/config/locales/tr.yml +7 -12
  34. data/config/locales/uk.yml +7 -12
  35. data/config/locales/zh-CN.yml +7 -12
  36. data/config/locales/zh-TW.yml +7 -12
  37. data/lib/comfortable_mexican_sofa/routes/cms_admin.rb +19 -14
  38. data/lib/comfortable_mexican_sofa/version.rb +1 -1
  39. data/test/controllers/comfy/admin/cms/revisions/layout_controller_test.rb +62 -0
  40. data/test/controllers/comfy/admin/cms/revisions/page_controller_test.rb +87 -0
  41. data/test/controllers/comfy/admin/cms/revisions/snippet_controller_test.rb +59 -0
  42. data/test/controllers/comfy/admin/cms/revisions/translation_controller_test.rb +69 -0
  43. data/test/gemfiles/Gemfile.rails.5.2 +1 -21
  44. data/test/integration/access_control_test.rb +9 -9
  45. metadata +12 -4
  46. data/app/controllers/comfy/admin/cms/revisions_controller.rb +0 -67
  47. data/test/controllers/comfy/admin/cms/revisions_controller_test.rb +0 -248
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2bc7965bfa47a37f8d1217bd041709ce13d46e6d
4
- data.tar.gz: 84a087c57db21caceeea2ed16fb4273e7e7f6adf
3
+ metadata.gz: b44e849fc5e9ae2bf75d22a0976d8852f30e1606
4
+ data.tar.gz: 7a26fcd671fb42318a968aa3f6ede11d67d233ba
5
5
  SHA512:
6
- metadata.gz: a514cb92363623a5686f9f09347e3ef500788d5cecfddf12df793097970bbaaea26e571909920bbfc5a54592dddadb2fd338857e8cbcecb02597ae5684397e7e
7
- data.tar.gz: 5bc3dd4e4d1508f47a00d8374b787fc808eda804cdf217fbf595de06f82e38d26259813847e4295f6891df47d233879a25f3d2ced369047042aae7224c67d395
6
+ metadata.gz: 2c102b76ac471fda8769a9dfbfb29289c1133c3c963ebddc3cbe4d5b69714fa7a294c30979e3a2634c5ebdf26ec9efe983f860b2bb860608c97d84abbabef39d
7
+ data.tar.gz: 7d704fc6e99d1fead6caaa51ff00f033a4a20941aa29f079b227a143bf97251830382dcf708296cf7ee8f89e5de29bbc4364298d536e9d37fc5d2f8bc19c212f
data/README.md CHANGED
@@ -97,4 +97,4 @@ Twitter: [@GroceryBagHead](https://twitter.com/grocerybaghead)
97
97
 
98
98
  ComfortableMexicanSofa is released under the [MIT license](https://github.com/comfy/comfortable-mexican-sofa/raw/master/LICENSE)
99
99
 
100
- Copyright 20010-2017 Oleg Khabarov
100
+ Copyright 2010-2017 Oleg Khabarov
@@ -228,7 +228,7 @@ body#comfy
228
228
  width: 100%
229
229
 
230
230
  // -- Revisions --------------------------------------------------------------
231
- &.c-comfy-admin-cms-revisions
231
+ &[class*="c-comfy-admin-cms-revisions-"], &[class*="c-comfy-admin-blog-revisions-"]
232
232
  .label
233
233
  padding: 15px 0
234
234
  font-weight: bold
@@ -0,0 +1,47 @@
1
+ class Comfy::Admin::Cms::Revisions::BaseController < Comfy::Admin::Cms::BaseController
2
+
3
+ helper_method :record_path
4
+
5
+ before_action :load_record
6
+ before_action :load_revision, except: :index
7
+ before_action :authorize
8
+
9
+ def index
10
+ revision = @record.revisions.order(created_at: :desc).first
11
+ if revision
12
+ redirect_to action: :show, id: revision.id
13
+ else
14
+ redirect_to record_path
15
+ end
16
+ end
17
+
18
+ def show
19
+ @current_content = @record.revision_fields.inject({}){|c, f| c[f] = @record.send(f); c }
20
+ @versioned_content = @record.revision_fields.inject({}){|c, f| c[f] = @revision.data[f]; c }
21
+
22
+ render "comfy/admin/cms/revisions/show"
23
+ end
24
+
25
+ def revert
26
+ @record.restore_from_revision(@revision)
27
+ flash[:success] = I18n.t('comfy.admin.cms.revisions.reverted')
28
+ redirect_to record_path
29
+ end
30
+
31
+ protected
32
+
33
+ def load_record
34
+ raise "not implemented"
35
+ end
36
+
37
+ def load_revision
38
+ @revision = @record.revisions.find(params[:id])
39
+ rescue ActiveRecord::RecordNotFound
40
+ flash[:danger] = I18n.t('comfy.admin.cms.revisions.not_found')
41
+ redirect_to record_path
42
+ end
43
+
44
+ def record_path
45
+ raise "no implemented"
46
+ end
47
+ end
@@ -0,0 +1,15 @@
1
+ class Comfy::Admin::Cms::Revisions::LayoutController < Comfy::Admin::Cms::Revisions::BaseController
2
+
3
+ private
4
+
5
+ def load_record
6
+ @record = @site.layouts.find(params[:layout_id])
7
+ rescue ActiveRecord::RecordNotFound
8
+ flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
9
+ redirect_to comfy_admin_cms_site_layouts_path(@site)
10
+ end
11
+
12
+ def record_path
13
+ edit_comfy_admin_cms_site_layout_path(@site, @record)
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ class Comfy::Admin::Cms::Revisions::PageController < Comfy::Admin::Cms::Revisions::BaseController
2
+
3
+ def show
4
+ @current_content = @record.fragments.inject({}){|c, b| c[b.identifier] = b.content; c }
5
+ @versioned_content = @record.fragments.inject({}){|c, b| c[b.identifier] = @revision.data['fragments_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
6
+
7
+ render "comfy/admin/cms/revisions/show"
8
+ end
9
+
10
+ private
11
+
12
+ def load_record
13
+ @record = @site.pages.find(params[:page_id])
14
+ rescue ActiveRecord::RecordNotFound
15
+ flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
16
+ redirect_to comfy_admin_cms_site_pages_path(@site)
17
+ end
18
+
19
+ def record_path
20
+ edit_comfy_admin_cms_site_page_path(@site, @record)
21
+ end
22
+ end
@@ -0,0 +1,15 @@
1
+ class Comfy::Admin::Cms::Revisions::SnippetController < Comfy::Admin::Cms::Revisions::BaseController
2
+
3
+ private
4
+
5
+ def load_record
6
+ @record = @site.snippets.find(params[:snippet_id])
7
+ rescue ActiveRecord::RecordNotFound
8
+ flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
9
+ redirect_to comfy_admin_cms_site_snippets_path(@site)
10
+ end
11
+
12
+ def record_path
13
+ edit_comfy_admin_cms_site_snippet_path(@site, @record)
14
+ end
15
+ end
@@ -0,0 +1,23 @@
1
+ class Comfy::Admin::Cms::Revisions::TranslationController < Comfy::Admin::Cms::Revisions::BaseController
2
+
3
+ def show
4
+ @current_content = @record.fragments.inject({}){|c, b| c[b.identifier] = b.content; c }
5
+ @versioned_content = @record.fragments.inject({}){|c, b| c[b.identifier] = @revision.data['fragments_attributes'].detect{|r| r[:identifier] == b.identifier}.try(:[], :content); c }
6
+
7
+ render "comfy/admin/cms/revisions/show"
8
+ end
9
+
10
+ private
11
+
12
+ def load_record
13
+ @page = @site.pages.find(params[:page_id])
14
+ @record = @page.translations.find(params[:translation_id])
15
+ rescue ActiveRecord::RecordNotFound
16
+ flash[:danger] = I18n.t('comfy.admin.cms.revisions.record_not_found')
17
+ redirect_to comfy_admin_cms_site_pages_path(@site)
18
+ end
19
+
20
+ def record_path
21
+ edit_comfy_admin_cms_site_page_translation_path(@site, @page, @record)
22
+ end
23
+ end
@@ -1,6 +1,6 @@
1
1
  - content_for :right_column do
2
- .box.revisions
3
- = link_to t('.revision', count: @layout.revisions.count), comfy_admin_cms_site_layout_revisions_path(@site, @layout), class: "btn btn-info d-block"
2
+ - link = comfy_admin_cms_site_layout_revisions_path(@site, @layout)
3
+ = render "comfy/admin/cms/revisions/sidebar", record: @layout, link: link
4
4
 
5
5
  .page-header
6
6
  %h2= t('.title')
@@ -1,8 +1,7 @@
1
1
  - content_for :right_column do
2
- .box.revisions
3
- = link_to t('.revision', count: @page.revisions.count), comfy_admin_cms_site_page_revisions_path(@site, @page), class: 'btn btn-info d-block'
4
-
5
- = render partial: "comfy/admin/cms/translations/sidebar"
2
+ - link = comfy_admin_cms_site_page_revisions_path(@site, @page)
3
+ = render "comfy/admin/cms/revisions/sidebar", record: @page, link: link
4
+ = render "comfy/admin/cms/translations/sidebar"
6
5
 
7
6
  .page-header
8
7
  %h2= t('.title')
@@ -0,0 +1,2 @@
1
+ .box.revisions
2
+ = link_to t('.revision', count: record.revisions.count), link, class: "btn btn-info d-block"
@@ -1,6 +1,6 @@
1
1
  - content_for :right_column do
2
2
  .box.revisions
3
- - @record.revisions.each do |revision|
3
+ - @record.revisions.order(created_at: :desc).each do |revision|
4
4
  = active_link_to l(revision.created_at, format: :short), {id: revision.id}, class: "btn btn-sm btn-outline-light d-block text-primary mb-1"
5
5
 
6
6
  .page-header
@@ -8,7 +8,6 @@
8
8
  = t('.title')
9
9
  = @record.class.to_s.demodulize
10
10
 
11
-
12
11
  .row.d-none.d-lg-flex
13
12
  .col-lg-10.ml-auto
14
13
  .row
@@ -34,4 +33,4 @@
34
33
  = comfy_form_for @revision, url: {action: :revert} do |form|
35
34
  = form.form_actions do
36
35
  = form.submit t('.update'), class: "btn btn-primary"
37
- = link_to t(".cancel"), record_path(@record), class: "btn btn-link"
36
+ = link_to t(".cancel"), record_path, class: "btn btn-link"
@@ -1,7 +1,6 @@
1
1
  - content_for :right_column do
2
- .box.revisions
3
- = link_to comfy_admin_cms_site_snippet_revisions_path(@site, @snippet), class: "btn btn-info d-block" do
4
- = t('.revision', count: @snippet.revisions.count)
2
+ - link = comfy_admin_cms_site_snippet_revisions_path(@site, @snippet)
3
+ = render "comfy/admin/cms/revisions/sidebar", record: @snippet, link: link
5
4
 
6
5
  .page-header
7
6
  %h2= t('.title')
@@ -2,7 +2,7 @@
2
2
  - @page.translations.each do |translation|
3
3
  .btn-group.btn-group-sm.d-flex.mb-1
4
4
  - url = edit_comfy_admin_cms_site_page_translation_path(@site, @page, translation)
5
- - badge = content_tag(:span, translation.locale, class: "badge badge-light")
5
+ - badge = content_tag(:span, translation.locale, class: "badge badge-primary")
6
6
  - name = "#{badge} #{translation.label}".html_safe
7
7
  - published_css_class = translation.is_published? ? "published" : "draft"
8
8
  = link_to name, url, class: "#{published_css_class} translation btn btn-outline-light w-100"
@@ -1,8 +1,7 @@
1
1
  - content_for :right_column do
2
- .box.revisions
3
- = link_to t('.revision', count: @translation.revisions.count), comfy_admin_cms_site_page_translation_revisions_path(@site, @page, @translation), class: "btn btn-info d-block"
4
-
5
- = render partial: "comfy/admin/cms/translations/sidebar"
2
+ - link = comfy_admin_cms_site_page_translation_revisions_path(@site, @page, @translation)
3
+ = render "comfy/admin/cms/revisions/sidebar", record: @translation, link: link
4
+ = render "comfy/admin/cms/translations/sidebar"
6
5
 
7
6
  .page-header
8
7
  %h2= t('.title')
@@ -57,4 +57,6 @@ defined?(ComfortableMexicanSofa::Application) && ComfortableMexicanSofa::Applica
57
57
  config.file_watcher = ActiveSupport::EventedFileUpdateChecker
58
58
 
59
59
  config.active_job.queue_adapter = :inline
60
+
61
+ config.action_view.raise_on_missing_translations = true
60
62
  end
@@ -44,4 +44,6 @@ defined?(ComfortableMexicanSofa::Application) && ComfortableMexicanSofa::Applica
44
44
  # config.action_view.raise_on_missing_translations = true
45
45
 
46
46
  config.active_job.queue_adapter = :inline
47
+
48
+ config.action_view.raise_on_missing_translations = true
47
49
  end
@@ -110,12 +110,6 @@ cs:
110
110
  title: Nové rozložení
111
111
  edit:
112
112
  title: Úprava rozložení
113
- revision: &revision
114
- zero: Žádné revize
115
- one: '%{count} revize'
116
- few: '%{count} revize'
117
- many: '%{count} revizí'
118
- other: '%{count} revizí'
119
113
  form:
120
114
  select_parent_layout: Zvolte rodičovské rozložení
121
115
  select_app_layout: Zvolte rozložení aplikace
@@ -145,8 +139,6 @@ cs:
145
139
  title: Nová stránka
146
140
  edit:
147
141
  title: Úprava stránky
148
- revision:
149
- <<: *revision
150
142
  form:
151
143
  select_target_page: Bez přesměrování
152
144
  preview: Náhled
@@ -171,8 +163,6 @@ cs:
171
163
  title: New Translation
172
164
  edit:
173
165
  title: Editing Translation
174
- revision:
175
- <<: *revision
176
166
  form:
177
167
  preview: Preview
178
168
  create: Create
@@ -201,8 +191,6 @@ cs:
201
191
  title: Nový úryvek
202
192
  edit:
203
193
  title: Upravit úryvek
204
- revision:
205
- <<: *revision
206
194
  form:
207
195
  create: Vytvořit úryvek
208
196
  cancel: Zrušit
@@ -222,6 +210,13 @@ cs:
222
210
  changes: Změny
223
211
  previous: Předchozí
224
212
  current: Aktuální
213
+ sidebar:
214
+ revision:
215
+ zero: Žádné revize
216
+ one: '%{count} revize'
217
+ few: '%{count} revize'
218
+ many: '%{count} revizí'
219
+ other: '%{count} revizí'
225
220
 
226
221
  files:
227
222
  created: Soubory nahrány
@@ -110,12 +110,6 @@ da:
110
110
  title: Nyt layout
111
111
  edit:
112
112
  title: Rdiger layout
113
- revision: &revision
114
- zero: Ingen revisioner
115
- one: '%{count} revision'
116
- few: '%{count} revisioner'
117
- many: '%{count} revisioner'
118
- other: '%{count} revisioner'
119
113
  form:
120
114
  select_parent_layout: Vælg overordnet layout
121
115
  select_app_layout: Vælg applikationens layout
@@ -145,8 +139,6 @@ da:
145
139
  title: Ny side
146
140
  edit:
147
141
  title: Rediger side
148
- revision:
149
- <<: *revision
150
142
  form:
151
143
  select_target_page: Ingen viderestilling
152
144
  preview: Preview
@@ -171,8 +163,6 @@ da:
171
163
  title: New Translation
172
164
  edit:
173
165
  title: Editing Translation
174
- revision:
175
- <<: *revision
176
166
  form:
177
167
  preview: Preview
178
168
  create: Create
@@ -201,8 +191,6 @@ da:
201
191
  title: Ny snippet
202
192
  edit:
203
193
  title: Rediger snippet
204
- revision:
205
- <<: *revision
206
194
  form:
207
195
  create: Opret snippet
208
196
  cancel: Annuller
@@ -222,6 +210,13 @@ da:
222
210
  changes: Ændringer
223
211
  previous: Forrige
224
212
  current: Nuværende
213
+ sidebar:
214
+ revision:
215
+ zero: Ingen revisioner
216
+ one: '%{count} revision'
217
+ few: '%{count} revisioner'
218
+ many: '%{count} revisioner'
219
+ other: '%{count} revisioner'
225
220
 
226
221
  files:
227
222
  created: Filer sendt
@@ -110,12 +110,6 @@ de:
110
110
  title: Neues Layout
111
111
  edit:
112
112
  title: Layout bearbeiten
113
- revision: &revision
114
- zero: Keine Versionen
115
- one: '%{count} Version'
116
- few: '%{count} Versionen'
117
- many: '%{count} Versionen'
118
- other: '%{count} Versionen'
119
113
  form:
120
114
  select_parent_layout: Übergeordnetes Layout auswählen
121
115
  select_app_layout: Grundlegendes Layout auswählen
@@ -145,8 +139,6 @@ de:
145
139
  title: Seite erstellen
146
140
  edit:
147
141
  title: Seite bearbeiten
148
- revision:
149
- <<: *revision
150
142
  form:
151
143
  select_target_page: Keine Weiterleitung
152
144
  preview: Vorschau
@@ -171,8 +163,6 @@ de:
171
163
  title: New Translation
172
164
  edit:
173
165
  title: Editing Translation
174
- revision:
175
- <<: *revision
176
166
  form:
177
167
  preview: Preview
178
168
  create: Create
@@ -201,8 +191,6 @@ de:
201
191
  title: Schnipsel erstellen
202
192
  edit:
203
193
  title: Schnipsel bearbeiten
204
- revision:
205
- <<: *revision
206
194
  form:
207
195
  create: Schnipsel erstellen
208
196
  cancel: Abbrechen
@@ -222,6 +210,13 @@ de:
222
210
  changes: Änderungen
223
211
  previous: Vorherige Version
224
212
  current: Aktuell
213
+ sidebar:
214
+ revision:
215
+ zero: Keine Versionen
216
+ one: '%{count} Version'
217
+ few: '%{count} Versionen'
218
+ many: '%{count} Versionen'
219
+ other: '%{count} Versionen'
225
220
 
226
221
  files:
227
222
  created: Datei hochgeladen
@@ -110,12 +110,6 @@ en:
110
110
  title: New Layout
111
111
  edit:
112
112
  title: Editing Layout
113
- revision: &revision
114
- zero: No Revisions
115
- one: '%{count} Revision'
116
- few: '%{count} Revisions'
117
- many: '%{count} Revisions'
118
- other: '%{count} Revisions'
119
113
  form:
120
114
  select_parent_layout: Select Parent Layout
121
115
  select_app_layout: Select Application Layout
@@ -145,8 +139,6 @@ en:
145
139
  title: New Page
146
140
  edit:
147
141
  title: Editing Page
148
- revision:
149
- <<: *revision
150
142
  form:
151
143
  select_target_page: No Redirect
152
144
  preview: Preview
@@ -171,8 +163,6 @@ en:
171
163
  title: New Translation
172
164
  edit:
173
165
  title: Editing Translation
174
- revision:
175
- <<: *revision
176
166
  form:
177
167
  preview: Preview
178
168
  create: Create
@@ -201,8 +191,6 @@ en:
201
191
  title: New Snippet
202
192
  edit:
203
193
  title: Editing Snippet
204
- revision:
205
- <<: *revision
206
194
  form:
207
195
  create: Create Snippet
208
196
  cancel: Cancel
@@ -222,6 +210,13 @@ en:
222
210
  changes: Changes
223
211
  previous: Previous
224
212
  current: Current
213
+ sidebar:
214
+ revision:
215
+ zero: No Revisions
216
+ one: '%{count} Revision'
217
+ few: '%{count} Revisions'
218
+ many: '%{count} Revisions'
219
+ other: '%{count} Revisions'
225
220
 
226
221
  files:
227
222
  created: Files uploaded