comfortable_mexican_sofa 2.0.17 → 2.0.18
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.
- checksums.yaml +5 -5
- data/.gitignore +2 -1
- data/.travis.yml +4 -3
- data/app/controllers/comfy/admin/base_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/categories_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/layouts_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/sites_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/snippets_controller.rb +1 -1
- data/app/controllers/comfy/admin/cms/translations_controller.rb +1 -1
- data/app/controllers/comfy/cms/assets_controller.rb +1 -1
- data/app/controllers/comfy/cms/base_controller.rb +1 -1
- data/app/controllers/comfy/cms/content_controller.rb +6 -11
- data/app/models/comfy/cms/file.rb +8 -7
- data/app/models/comfy/cms/page.rb +10 -3
- data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
- data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +1 -1
- data/app/views/kaminari/comfy/_first_page.html.haml +1 -1
- data/comfortable_mexican_sofa.gemspec +1 -1
- data/config/environments/test.rb +4 -0
- data/config/initializers/comfortable_mexican_sofa.rb +10 -1
- data/config/locales/pl.yml +20 -20
- data/db/cms_seeds/sample-site/pages/index/cms logo.png +0 -0
- data/db/cms_seeds/sample-site/pages/index/content.html +1 -0
- data/lib/comfortable_mexican_sofa/configuration.rb +25 -14
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +2 -0
- data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +2 -0
- data/lib/comfortable_mexican_sofa/content/tags/mixins/file_content.rb +16 -11
- data/lib/comfortable_mexican_sofa/content/tags/page_file_link.rb +2 -0
- data/lib/comfortable_mexican_sofa/engine.rb +9 -1
- data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +1 -1
- data/lib/comfortable_mexican_sofa/render_methods.rb +2 -0
- data/lib/comfortable_mexican_sofa/seeds.rb +6 -4
- data/lib/comfortable_mexican_sofa/seeds/page/importer.rb +1 -1
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/lib/generators/comfy/scaffold/templates/controller.rb.tt +1 -1
- data/lib/tasks/cms_seeds.rake +8 -6
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: e514b33709fbc091e1fd7d85698df4aca91754f9534e846b0d3c9fd01b5ceec2
|
|
4
|
+
data.tar.gz: 9e3a60b2ac680e17bdc69e8f4d544dffcb433537b957e51e2bf155a10f2e3f17
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af4880c26e4a7e7cac684928a01630727b0fb1cb038a1222352850e6c77efbc48aeee95887e7d447f16d8409fe0dec3ec51dc9ab49e4a1b4ab756a4a60be26ad
|
|
7
|
+
data.tar.gz: f2cc0e1ac9c9d1b1f4dc9542f9f1b5be37d17dbc2f1273eb43c69db0fbb1b8ad42c5f611f135e11e5412622a68d9aa20f79e47b49000644f096d4273734d000d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
class Comfy::Admin::BaseController < ComfortableMexicanSofa.config.
|
|
3
|
+
class Comfy::Admin::BaseController < ComfortableMexicanSofa.config.admin_base_controller.to_s.constantize
|
|
4
4
|
|
|
5
5
|
include Comfy::Paginate
|
|
6
6
|
|
|
@@ -32,7 +32,7 @@ class Comfy::Admin::Cms::LayoutsController < Comfy::Admin::Cms::BaseController
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def update
|
|
35
|
-
@layout.
|
|
35
|
+
@layout.update!(layout_params)
|
|
36
36
|
flash[:success] = I18n.t("comfy.admin.cms.layouts.updated")
|
|
37
37
|
redirect_to action: :edit, id: @layout
|
|
38
38
|
rescue ActiveRecord::RecordInvalid
|
|
@@ -33,7 +33,7 @@ class Comfy::Admin::Cms::SitesController < Comfy::Admin::Cms::BaseController
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def update
|
|
36
|
-
@site.
|
|
36
|
+
@site.update!(site_params)
|
|
37
37
|
flash[:success] = I18n.t("comfy.admin.cms.sites.updated")
|
|
38
38
|
redirect_to action: :edit, id: @site
|
|
39
39
|
rescue ActiveRecord::RecordInvalid
|
|
@@ -32,7 +32,7 @@ class Comfy::Admin::Cms::SnippetsController < Comfy::Admin::Cms::BaseController
|
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
def update
|
|
35
|
-
@snippet.
|
|
35
|
+
@snippet.update!(snippet_params)
|
|
36
36
|
flash[:success] = I18n.t("comfy.admin.cms.snippets.updated")
|
|
37
37
|
redirect_to action: :edit, id: @snippet
|
|
38
38
|
rescue ActiveRecord::RecordInvalid
|
|
@@ -28,7 +28,7 @@ class Comfy::Admin::Cms::TranslationsController < Comfy::Admin::Cms::BaseControl
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def update
|
|
31
|
-
@translation.
|
|
31
|
+
@translation.update!(translation_params)
|
|
32
32
|
flash[:success] = I18n.t("comfy.admin.cms.translations.updated")
|
|
33
33
|
redirect_to action: :edit, id: @translation
|
|
34
34
|
rescue ActiveRecord::RecordInvalid
|
|
@@ -21,11 +21,11 @@ class Comfy::Cms::ContentController < Comfy::Cms::BaseController
|
|
|
21
21
|
respond_to do |format|
|
|
22
22
|
format.html { render_page }
|
|
23
23
|
format.json do
|
|
24
|
-
|
|
25
|
-
json_page[:content] = render_to_string(
|
|
24
|
+
@cms_page.content = render_to_string(
|
|
26
25
|
inline: @cms_page.content_cache,
|
|
27
26
|
layout: false
|
|
28
27
|
)
|
|
28
|
+
json_page = @cms_page.as_json(ComfortableMexicanSofa.config.page_to_json_options)
|
|
29
29
|
render json: json_page
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -44,7 +44,7 @@ protected
|
|
|
44
44
|
# it's possible to control mimetype of a page by creating a `mime_type` field
|
|
45
45
|
def mime_type
|
|
46
46
|
mime_block = @cms_page.fragments.detect { |f| f.identifier == "mime_type" }
|
|
47
|
-
mime_block&.content || "text/html"
|
|
47
|
+
mime_block&.content&.strip || "text/html"
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def app_layout
|
|
@@ -73,15 +73,10 @@ protected
|
|
|
73
73
|
# Getting page and setting content_cache and fragments data if we need to
|
|
74
74
|
# serve translation data
|
|
75
75
|
def find_cms_page_by_full_path(full_path)
|
|
76
|
-
@cms_page
|
|
77
|
-
@cms_layout = @cms_page.layout
|
|
76
|
+
@cms_page = @cms_site.pages.published.find_by!(full_path: full_path)
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if @cms_page.translations.any? && @cms_site.locale != I18n.locale.to_s
|
|
82
|
-
@cms_page.translate!(I18n.locale)
|
|
83
|
-
@cms_layout = @cms_page.layout
|
|
84
|
-
end
|
|
78
|
+
@cms_page.translate!
|
|
79
|
+
@cms_layout = @cms_page.layout
|
|
85
80
|
|
|
86
81
|
@cms_page
|
|
87
82
|
|
|
@@ -21,10 +21,12 @@ class Comfy::Cms::File < ActiveRecord::Base
|
|
|
21
21
|
belongs_to :site
|
|
22
22
|
|
|
23
23
|
# -- Callbacks ---------------------------------------------------------------
|
|
24
|
+
before_validation :assign_label, on: :create
|
|
24
25
|
before_create :assign_position
|
|
25
26
|
after_save :process_attachment
|
|
26
27
|
|
|
27
28
|
# -- Validations -------------------------------------------------------------
|
|
29
|
+
validates :label, presence: true
|
|
28
30
|
validates :file, presence: true, on: :create
|
|
29
31
|
|
|
30
32
|
# -- Scopes ------------------------------------------------------------------
|
|
@@ -34,13 +36,6 @@ class Comfy::Cms::File < ActiveRecord::Base
|
|
|
34
36
|
where("active_storage_blobs.content_type LIKE 'image/%'").references(:blob)
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
# -- Instance Methods --------------------------------------------------------
|
|
38
|
-
def label
|
|
39
|
-
l = read_attribute(:label)
|
|
40
|
-
return l if l.present?
|
|
41
|
-
attachment.attached? ? attachment.filename.to_s : nil
|
|
42
|
-
end
|
|
43
|
-
|
|
44
39
|
protected
|
|
45
40
|
|
|
46
41
|
def assign_position
|
|
@@ -48,6 +43,12 @@ protected
|
|
|
48
43
|
self.position = max ? max + 1 : 0
|
|
49
44
|
end
|
|
50
45
|
|
|
46
|
+
# TODO: Change db schema not to set blank string
|
|
47
|
+
def assign_label
|
|
48
|
+
return if label.present?
|
|
49
|
+
self.label = file&.original_filename
|
|
50
|
+
end
|
|
51
|
+
|
|
51
52
|
def process_attachment
|
|
52
53
|
return if @file.blank?
|
|
53
54
|
attachment.attach(@file)
|
|
@@ -7,9 +7,11 @@ class Comfy::Cms::Page < ActiveRecord::Base
|
|
|
7
7
|
include Comfy::Cms::WithFragments
|
|
8
8
|
include Comfy::Cms::WithCategories
|
|
9
9
|
|
|
10
|
-
cms_acts_as_tree counter_cache: :children_count
|
|
10
|
+
cms_acts_as_tree counter_cache: :children_count, order: :position
|
|
11
11
|
cms_has_revisions_for :fragments_attributes
|
|
12
12
|
|
|
13
|
+
attr_accessor :content
|
|
14
|
+
|
|
13
15
|
# -- Relationships -----------------------------------------------------------
|
|
14
16
|
belongs_to :site
|
|
15
17
|
belongs_to :target_page,
|
|
@@ -88,8 +90,13 @@ class Comfy::Cms::Page < ActiveRecord::Base
|
|
|
88
90
|
|
|
89
91
|
# This method will mutate page object by transfering attributes from translation
|
|
90
92
|
# for a given locale.
|
|
91
|
-
def translate!
|
|
92
|
-
|
|
93
|
+
def translate!
|
|
94
|
+
# If site locale same as page's or there's no translastions, we do nothing
|
|
95
|
+
if site.locale == I18n.locale.to_s || translations.blank?
|
|
96
|
+
return
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
translation = translations.published.find_by!(locale: I18n.locale)
|
|
93
100
|
self.layout = translation.layout
|
|
94
101
|
self.label = translation.label
|
|
95
102
|
self.content_cache = translation.content_cache
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
%li{data: {id: file.id}}
|
|
2
2
|
:ruby
|
|
3
3
|
file_tag = cms_file_link_tag(file)
|
|
4
|
-
thumb_url = url_for(file.attachment.variant(combine_options: Comfy::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.
|
|
4
|
+
thumb_url = url_for(file.attachment.variant(combine_options: Comfy::Cms::File::VARIANT_SIZE[:thumb])) if file.attachment.variable?
|
|
5
5
|
.row
|
|
6
6
|
.col-md-5.item
|
|
7
7
|
.item-controls.d-none.d-lg-block
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.fragment-attachments
|
|
2
2
|
- attachments.each do |attachment|
|
|
3
3
|
:ruby
|
|
4
|
-
thumb_url = if attachment.
|
|
4
|
+
thumb_url = if attachment.variable?
|
|
5
5
|
url_for(attachment.variant(combine_options: Comfy::Cms::File::VARIANT_SIZE[:thumb]))
|
|
6
6
|
end
|
|
7
7
|
filename = attachment.filename.to_s
|
data/config/environments/test.rb
CHANGED
|
@@ -48,4 +48,8 @@ defined?(ComfortableMexicanSofa::Application) && ComfortableMexicanSofa::Applica
|
|
|
48
48
|
config.active_job.queue_adapter = :inline
|
|
49
49
|
|
|
50
50
|
config.action_view.raise_on_missing_translations = true
|
|
51
|
+
|
|
52
|
+
# TODO: This is temporary fix so TravisCI runs until Rails 5.2.3 is out.
|
|
53
|
+
# See: https://github.com/rails/rails/pull/35607
|
|
54
|
+
config.secret_key_base = SecureRandom.hex(64)
|
|
51
55
|
end
|
|
@@ -5,7 +5,10 @@ ComfortableMexicanSofa.configure do |config|
|
|
|
5
5
|
# config.cms_title = 'ComfortableMexicanSofa CMS Engine'
|
|
6
6
|
|
|
7
7
|
# Controller that is inherited from CmsAdmin::BaseController
|
|
8
|
-
# config.
|
|
8
|
+
# config.admin_base_controller = 'ApplicationController'
|
|
9
|
+
|
|
10
|
+
# Controller that Comfy::Cms::BaseController will inherit from
|
|
11
|
+
# config.public_base_controller = 'ApplicationController'
|
|
9
12
|
|
|
10
13
|
# Module responsible for authentication. You can replace it with your own.
|
|
11
14
|
# It simply needs to have #authenticate method. See http_auth.rb for reference.
|
|
@@ -77,6 +80,12 @@ ComfortableMexicanSofa.configure do |config|
|
|
|
77
80
|
# Reveal partials that can be overwritten in the admin area.
|
|
78
81
|
# Default is false.
|
|
79
82
|
# config.reveal_cms_partials = false
|
|
83
|
+
#
|
|
84
|
+
# Customize the returned content json data
|
|
85
|
+
# include fragments in content json
|
|
86
|
+
# config.content_json_options = {
|
|
87
|
+
# include: [:fragments]
|
|
88
|
+
# }
|
|
80
89
|
end
|
|
81
90
|
|
|
82
91
|
# Default credentials for ComfortableMexicanSofa::AccessControl::AdminAuthentication
|
data/config/locales/pl.yml
CHANGED
|
@@ -6,7 +6,7 @@ pl:
|
|
|
6
6
|
comfy/cms/page: Strona
|
|
7
7
|
comfy/cms/snippet: Snippet
|
|
8
8
|
comfy/cms/file: Plik
|
|
9
|
-
comfy/cms/translation:
|
|
9
|
+
comfy/cms/translation: Tłumaczenie
|
|
10
10
|
|
|
11
11
|
attributes:
|
|
12
12
|
comfy/cms/site:
|
|
@@ -41,10 +41,10 @@ pl:
|
|
|
41
41
|
label: Tytuł
|
|
42
42
|
content: Zawartość
|
|
43
43
|
comfy/cms/translation:
|
|
44
|
-
locale:
|
|
45
|
-
label:
|
|
46
|
-
layout_id:
|
|
47
|
-
is_published:
|
|
44
|
+
locale: Język
|
|
45
|
+
label: Nazwa
|
|
46
|
+
layout_id: Szablon
|
|
47
|
+
is_published: Opublikowano
|
|
48
48
|
|
|
49
49
|
comfy:
|
|
50
50
|
cms:
|
|
@@ -144,7 +144,7 @@ pl:
|
|
|
144
144
|
create: Utwórz stronę
|
|
145
145
|
cancel: Anuluj
|
|
146
146
|
update: Uaktualnij stronę
|
|
147
|
-
choose_link:
|
|
147
|
+
choose_link: Wybierz stronę...
|
|
148
148
|
|
|
149
149
|
fragments:
|
|
150
150
|
form_fragments:
|
|
@@ -153,25 +153,25 @@ pl:
|
|
|
153
153
|
Dodaj do jego treści tag strony lub pola, np. <code>{{cms:wysiwyg content}}</code>
|
|
154
154
|
|
|
155
155
|
translations:
|
|
156
|
-
created:
|
|
157
|
-
creation_failure:
|
|
158
|
-
updated:
|
|
159
|
-
update_failure:
|
|
160
|
-
deleted:
|
|
161
|
-
not_found:
|
|
156
|
+
created: Tłumaczenie zostało utworzone
|
|
157
|
+
creation_failure: Błąd przy tworzeniu tlumaczenia
|
|
158
|
+
updated: Tłumaczenie zostało uaktualnione
|
|
159
|
+
update_failure: Błąd przy uaktualnianiu tłumaczenia
|
|
160
|
+
deleted: Tłumaczenie zostało usunięte
|
|
161
|
+
not_found: Nie znaleziono tłumaczenia
|
|
162
162
|
|
|
163
163
|
new:
|
|
164
|
-
title:
|
|
164
|
+
title: Nowe tłumaczenie
|
|
165
165
|
edit:
|
|
166
|
-
title:
|
|
166
|
+
title: Edytuj tłumaczenie
|
|
167
167
|
form:
|
|
168
|
-
preview:
|
|
169
|
-
create:
|
|
170
|
-
update:
|
|
171
|
-
cancel:
|
|
168
|
+
preview: Podgląd
|
|
169
|
+
create: Utwórz tłumaczenie
|
|
170
|
+
update: Uaktualnij tłumaczenie
|
|
171
|
+
cancel: Anuluj
|
|
172
172
|
sidebar:
|
|
173
|
-
new:
|
|
174
|
-
confirm:
|
|
173
|
+
new: Nowe tłumaczenie
|
|
174
|
+
confirm: Jesteś pewien?
|
|
175
175
|
|
|
176
176
|
snippets:
|
|
177
177
|
created: Snippet został utworzony
|
|
Binary file
|
|
@@ -7,7 +7,11 @@ class ComfortableMexicanSofa::Configuration
|
|
|
7
7
|
|
|
8
8
|
# Controller that is inherited from CmsAdmin::BaseController
|
|
9
9
|
# 'ApplicationController' is the default
|
|
10
|
-
attr_accessor :
|
|
10
|
+
attr_accessor :admin_base_controller
|
|
11
|
+
|
|
12
|
+
# Controller that Comfy::Cms::BaseController will inherit from
|
|
13
|
+
# 'ApplicationController' is the default
|
|
14
|
+
attr_accessor :public_base_controller
|
|
11
15
|
|
|
12
16
|
# Module that will handle authentication to access cms-admin area
|
|
13
17
|
attr_accessor :admin_auth
|
|
@@ -76,21 +80,27 @@ class ComfortableMexicanSofa::Configuration
|
|
|
76
80
|
# Auto-setting parameter derived from the routes
|
|
77
81
|
attr_accessor :public_cms_path
|
|
78
82
|
|
|
83
|
+
# Customize returned content from `page.to_json`
|
|
84
|
+
# Default is set to `methods: [:content], except: [:content_cache]`
|
|
85
|
+
# For example: include fragments into json data with `config.page_to_json_options = { include: [:fragments] }`
|
|
86
|
+
attr_accessor :page_to_json_options
|
|
87
|
+
|
|
79
88
|
# Configuration defaults
|
|
80
89
|
def initialize
|
|
81
|
-
@cms_title
|
|
82
|
-
@
|
|
83
|
-
@
|
|
84
|
-
@
|
|
85
|
-
@
|
|
86
|
-
@
|
|
87
|
-
@
|
|
88
|
-
@
|
|
89
|
-
@
|
|
90
|
-
@
|
|
91
|
-
@
|
|
92
|
-
@
|
|
93
|
-
@
|
|
90
|
+
@cms_title = "ComfortableMexicanSofa CMS Engine"
|
|
91
|
+
@admin_base_controller = "ApplicationController"
|
|
92
|
+
@public_base_controller = "ApplicationController"
|
|
93
|
+
@admin_auth = "ComfortableMexicanSofa::AccessControl::AdminAuthentication"
|
|
94
|
+
@admin_authorization = "ComfortableMexicanSofa::AccessControl::AdminAuthorization"
|
|
95
|
+
@public_auth = "ComfortableMexicanSofa::AccessControl::PublicAuthentication"
|
|
96
|
+
@public_authorization = "ComfortableMexicanSofa::AccessControl::PublicAuthorization"
|
|
97
|
+
@seed_data_path = nil
|
|
98
|
+
@admin_route_redirect = ""
|
|
99
|
+
@enable_sitemap = true
|
|
100
|
+
@enable_seeds = false
|
|
101
|
+
@seeds_path = File.expand_path("db/cms_seeds", Rails.root)
|
|
102
|
+
@revisions_limit = 25
|
|
103
|
+
@locales = {
|
|
94
104
|
"ca" => "Català",
|
|
95
105
|
"cs" => "Česky",
|
|
96
106
|
"da" => "Dansk",
|
|
@@ -122,6 +132,7 @@ class ComfortableMexicanSofa::Configuration
|
|
|
122
132
|
@hostname_aliases = nil
|
|
123
133
|
@reveal_cms_partials = false
|
|
124
134
|
@public_cms_path = nil
|
|
135
|
+
@page_to_json_options = { methods: [:content], except: [:content_cache] }
|
|
125
136
|
end
|
|
126
137
|
|
|
127
138
|
end
|
|
@@ -11,6 +11,7 @@ require_relative "./mixins/file_content"
|
|
|
11
11
|
# `resize` - imagemagic option. For example: "100x50>"
|
|
12
12
|
# `gravity` - imagemagic option. For example: "center"
|
|
13
13
|
# `crop` - imagemagic option. For example: "100x50+0+0"
|
|
14
|
+
# `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
|
|
14
15
|
#
|
|
15
16
|
class ComfortableMexicanSofa::Content::Tag::File < ComfortableMexicanSofa::Content::Tag::Fragment
|
|
16
17
|
|
|
@@ -27,6 +28,7 @@ class ComfortableMexicanSofa::Content::Tag::File < ComfortableMexicanSofa::Conte
|
|
|
27
28
|
super
|
|
28
29
|
@as = options["as"] || "url"
|
|
29
30
|
@label = options["label"]
|
|
31
|
+
@class = options["class"]
|
|
30
32
|
@variant_attrs = options.slice("resize", "gravity", "crop")
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -11,6 +11,7 @@ require_relative "./mixins/file_content"
|
|
|
11
11
|
# `resize` - imagemagic option. For example: "100x50>"
|
|
12
12
|
# `gravity` - imagemagic option. For example: "center"
|
|
13
13
|
# `crop` - imagemagic option. For example: "100x50+0+0"
|
|
14
|
+
# `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
|
|
14
15
|
#
|
|
15
16
|
class ComfortableMexicanSofa::Content::Tag::FileLink < ComfortableMexicanSofa::Content::Tag
|
|
16
17
|
|
|
@@ -31,6 +32,7 @@ class ComfortableMexicanSofa::Content::Tag::FileLink < ComfortableMexicanSofa::C
|
|
|
31
32
|
options = params.extract_options!
|
|
32
33
|
@identifier = params[0]
|
|
33
34
|
@as = options["as"] || "url"
|
|
35
|
+
@class = options["class"]
|
|
34
36
|
@variant_attrs = options.slice("resize", "gravity", "crop")
|
|
35
37
|
|
|
36
38
|
unless @identifier.present?
|
|
@@ -12,26 +12,31 @@ module ComfortableMexicanSofa::Content::Tag::Mixins
|
|
|
12
12
|
def content(file: self.file, as: self.as, variant_attrs: self.variant_attrs, label: self.label)
|
|
13
13
|
return "" unless file
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
file = file.variant(combine_options: variant_attrs)
|
|
17
|
-
end
|
|
15
|
+
url_helpers = Rails.application.routes.url_helpers
|
|
18
16
|
|
|
19
|
-
|
|
17
|
+
attachment_url =
|
|
18
|
+
if variant_attrs.present? && file.image?
|
|
19
|
+
variant = file.variant(combine_options: variant_attrs)
|
|
20
|
+
url_helpers.rails_representation_path(variant, only_path: true)
|
|
21
|
+
else
|
|
22
|
+
url_helpers.rails_blob_path(file, only_path: true)
|
|
23
|
+
end
|
|
20
24
|
|
|
21
25
|
case as
|
|
22
26
|
when "link"
|
|
23
|
-
"<a href='#{
|
|
27
|
+
"<a href='#{attachment_url}'#{html_class_attribute} target='_blank'>#{label}</a>"
|
|
24
28
|
when "image"
|
|
25
|
-
"<img src='#{
|
|
29
|
+
"<img src='#{attachment_url}'#{html_class_attribute} alt='#{label}'/>"
|
|
26
30
|
else
|
|
27
|
-
|
|
31
|
+
attachment_url
|
|
28
32
|
end
|
|
29
33
|
end
|
|
30
34
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
def
|
|
34
|
-
|
|
35
|
+
private
|
|
36
|
+
|
|
37
|
+
def html_class_attribute
|
|
38
|
+
return if @class.blank?
|
|
39
|
+
" class='#{@class}'"
|
|
35
40
|
end
|
|
36
41
|
|
|
37
42
|
end
|
|
@@ -20,6 +20,7 @@ require_relative "./mixins/file_content"
|
|
|
20
20
|
# `resize` - imagemagick option. For example: "100x50>"
|
|
21
21
|
# `gravity` - imagemagick option. For example: "center"
|
|
22
22
|
# `crop` - imagemagick option. For example: "100x50+0+0"
|
|
23
|
+
# `class` - any html classes that you want on the result link or image tag. For example "class1 class2"
|
|
23
24
|
#
|
|
24
25
|
class ComfortableMexicanSofa::Content::Tag::PageFileLink < ComfortableMexicanSofa::Content::Tag
|
|
25
26
|
|
|
@@ -44,6 +45,7 @@ class ComfortableMexicanSofa::Content::Tag::PageFileLink < ComfortableMexicanSof
|
|
|
44
45
|
options = params.extract_options!
|
|
45
46
|
@identifier = params[0]
|
|
46
47
|
@as = options["as"] || "url"
|
|
48
|
+
@class = options["class"]
|
|
47
49
|
@variant_attrs = options.slice("resize", "gravity", "crop")
|
|
48
50
|
@filename = options["filename"]
|
|
49
51
|
|
|
@@ -8,11 +8,19 @@ require "active_link_to"
|
|
|
8
8
|
require "kramdown"
|
|
9
9
|
require "jquery-rails"
|
|
10
10
|
require "haml-rails"
|
|
11
|
-
require "
|
|
11
|
+
require "sassc-rails"
|
|
12
12
|
|
|
13
13
|
module ComfortableMexicanSofa
|
|
14
14
|
class Engine < ::Rails::Engine
|
|
15
15
|
|
|
16
|
+
initializer "comfortable_mexican_sofa.setup_assets" do
|
|
17
|
+
::ComfortableMexicanSofa::Engine.config.assets.precompile += %w[
|
|
18
|
+
comfy/admin/cms/application.js
|
|
19
|
+
comfy/admin/cms/application.css
|
|
20
|
+
comfy/admin/cms/lib/redactor-font.eot
|
|
21
|
+
]
|
|
22
|
+
end
|
|
23
|
+
|
|
16
24
|
config.to_prepare do
|
|
17
25
|
Dir.glob(Rails.root + "app/decorators/comfortable_mexican_sofa/*_decorator*.rb").each do |c|
|
|
18
26
|
require_dependency(c)
|
|
@@ -60,7 +60,7 @@ module ComfortableMexicanSofa::HasRevisions
|
|
|
60
60
|
# Assigning whatever is found in revision data and attempting to save the object
|
|
61
61
|
def restore_from_revision(revision)
|
|
62
62
|
return unless revision.record == self
|
|
63
|
-
|
|
63
|
+
update!(revision.data)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
end
|
|
@@ -67,6 +67,8 @@ module ComfortableMexicanSofa::RenderMethods
|
|
|
67
67
|
raise ComfortableMexicanSofa::MissingPage, path
|
|
68
68
|
end
|
|
69
69
|
|
|
70
|
+
@cms_page.translate!
|
|
71
|
+
|
|
70
72
|
@cms_layout = @cms_page.layout
|
|
71
73
|
if (cms_fragments = options.delete(:cms_fragments)).present?
|
|
72
74
|
cms_fragments.each do |identifier, value|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
module ComfortableMexicanSofa::Seeds
|
|
4
4
|
|
|
5
|
+
SEED_CLASSES = %w[Layout Page Snippet File].freeze
|
|
6
|
+
|
|
5
7
|
class Error < StandardError; end
|
|
6
8
|
|
|
7
9
|
require "mimemagic"
|
|
@@ -26,8 +28,8 @@ module ComfortableMexicanSofa::Seeds
|
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
29
|
-
def import!
|
|
30
|
-
|
|
31
|
+
def import!(classes = SEED_CLASSES)
|
|
32
|
+
classes.each do |klass|
|
|
31
33
|
klass = "ComfortableMexicanSofa::Seeds::#{klass}::Importer"
|
|
32
34
|
klass.constantize.new(from, to).import!
|
|
33
35
|
end
|
|
@@ -78,8 +80,8 @@ module ComfortableMexicanSofa::Seeds
|
|
|
78
80
|
self.site = Comfy::Cms::Site.where(identifier: from).first!
|
|
79
81
|
end
|
|
80
82
|
|
|
81
|
-
def export!
|
|
82
|
-
|
|
83
|
+
def export!(classes = SEED_CLASSES)
|
|
84
|
+
classes.each do |klass|
|
|
83
85
|
klass = "ComfortableMexicanSofa::Seeds::#{klass}::Exporter"
|
|
84
86
|
klass.constantize.new(from, to).export!
|
|
85
87
|
end
|
|
@@ -187,7 +187,7 @@ module ComfortableMexicanSofa::Seeds::Page
|
|
|
187
187
|
# ActiveStorage and a list of ids of old attachements to destroy
|
|
188
188
|
def files_content(record, identifier, path, frag_content)
|
|
189
189
|
# preparing attachments
|
|
190
|
-
files = frag_content.split.collect do |filename|
|
|
190
|
+
files = frag_content.split("\n").collect do |filename|
|
|
191
191
|
file_handler = File.open(File.join(path, filename))
|
|
192
192
|
{
|
|
193
193
|
io: file_handler,
|
|
@@ -29,7 +29,7 @@ class Admin::<%= class_name.pluralize %>Controller < Comfy::Admin::BaseControlle
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
def update
|
|
32
|
-
@<%= file_name %>.
|
|
32
|
+
@<%= file_name %>.update!(<%= file_name %>_params)
|
|
33
33
|
flash[:success] = '<%= class_name.titleize %> updated'
|
|
34
34
|
redirect_to action: :show, id: @<%= file_name %>
|
|
35
35
|
rescue ActiveRecord::RecordInvalid
|
data/lib/tasks/cms_seeds.rake
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
namespace :comfy do
|
|
4
4
|
namespace :cms_seeds do
|
|
5
|
-
desc "Import CMS Seed data into database (from: folder name, to: site identifier)"
|
|
5
|
+
desc "Import CMS Seed data into database (from: folder name, to: site identifier, klasses: class name[s])"
|
|
6
6
|
|
|
7
|
-
task :import, %i[from to] => [:environment] do |_t, args|
|
|
7
|
+
task :import, %i[from to klasses] => [:environment] do |_t, args|
|
|
8
8
|
from = args[:from]
|
|
9
9
|
to = args[:to] || from
|
|
10
|
+
klasses = args[:klasses].nil? ? nil : args[:klasses].split
|
|
10
11
|
|
|
11
12
|
puts "Importing CMS Seed data from Folder [#{from}] to Site [#{to}] ..."
|
|
12
13
|
|
|
@@ -14,15 +15,16 @@ namespace :comfy do
|
|
|
14
15
|
logger = ComfortableMexicanSofa.logger
|
|
15
16
|
ComfortableMexicanSofa.logger = Logger.new(STDOUT)
|
|
16
17
|
|
|
17
|
-
ComfortableMexicanSofa::Seeds::Importer.new(from, to).import!
|
|
18
|
+
ComfortableMexicanSofa::Seeds::Importer.new(from, to).import!(klasses)
|
|
18
19
|
|
|
19
20
|
ComfortableMexicanSofa.logger = logger
|
|
20
21
|
end
|
|
21
22
|
|
|
22
|
-
desc "Export database data into CMS Seed files (from: site identifier, to: folder name)"
|
|
23
|
-
task :export, %i[from to] => [:environment] do |_t, args|
|
|
23
|
+
desc "Export database data into CMS Seed files (from: site identifier, to: folder name, klasses: class name[s])"
|
|
24
|
+
task :export, %i[from to klasses] => [:environment] do |_t, args|
|
|
24
25
|
from = args[:from]
|
|
25
26
|
to = args[:to] || from
|
|
27
|
+
classes = args[:classes]&.split
|
|
26
28
|
|
|
27
29
|
puts "Exporting CMS data from Site [#{from}] to Folder [#{to}] ..."
|
|
28
30
|
|
|
@@ -30,7 +32,7 @@ namespace :comfy do
|
|
|
30
32
|
logger = ComfortableMexicanSofa.logger
|
|
31
33
|
ComfortableMexicanSofa.logger = Logger.new(STDOUT)
|
|
32
34
|
|
|
33
|
-
ComfortableMexicanSofa::Seeds::Exporter.new(from, to).export!
|
|
35
|
+
ComfortableMexicanSofa::Seeds::Exporter.new(from, to).export!(classes)
|
|
34
36
|
|
|
35
37
|
ComfortableMexicanSofa.logger = logger
|
|
36
38
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: comfortable_mexican_sofa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.0.
|
|
4
|
+
version: 2.0.18
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Oleg Khabarov
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2019-03-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: active_link_to
|
|
@@ -137,19 +137,19 @@ dependencies:
|
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
138
|
version: 5.0.0
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
|
-
name:
|
|
140
|
+
name: sassc-rails
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
143
|
- - ">="
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version:
|
|
145
|
+
version: 2.0.0
|
|
146
146
|
type: :runtime
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
150
|
- - ">="
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version:
|
|
152
|
+
version: 2.0.0
|
|
153
153
|
description: ComfortableMexicanSofa is a powerful Rails 5.2+ CMS Engine
|
|
154
154
|
email:
|
|
155
155
|
- oleg@khabarov.ca
|
|
@@ -536,6 +536,7 @@ files:
|
|
|
536
536
|
- db/cms_seeds/sample-site/layouts/default/nested/content.html
|
|
537
537
|
- db/cms_seeds/sample-site/pages/index/child_a/content.html
|
|
538
538
|
- db/cms_seeds/sample-site/pages/index/child_b/content.html
|
|
539
|
+
- db/cms_seeds/sample-site/pages/index/cms logo.png
|
|
539
540
|
- db/cms_seeds/sample-site/pages/index/content.es.html
|
|
540
541
|
- db/cms_seeds/sample-site/pages/index/content.fr.html
|
|
541
542
|
- db/cms_seeds/sample-site/pages/index/content.html
|
|
@@ -633,8 +634,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
633
634
|
- !ruby/object:Gem::Version
|
|
634
635
|
version: '0'
|
|
635
636
|
requirements: []
|
|
636
|
-
|
|
637
|
-
rubygems_version: 2.5.1
|
|
637
|
+
rubygems_version: 3.0.3
|
|
638
638
|
signing_key:
|
|
639
639
|
specification_version: 4
|
|
640
640
|
summary: Rails 5.2+ CMS Engine
|