comfortable_mexican_sofa 2.0.7 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -5
- data/CONTRIBUTING.md +8 -5
- data/LICENSE +1 -1
- data/README.md +12 -6
- data/app/assets/javascripts/comfy/admin/cms/base.js.coffee +28 -8
- data/app/views/comfy/admin/cms/files/_file.html.haml +1 -1
- data/app/views/comfy/admin/cms/files/index.html.haml +9 -12
- data/app/views/comfy/admin/cms/fragments/_form_fragment_attachments.html.haml +1 -1
- data/app/views/layouts/comfy/admin/cms/_footer_js.html.haml +0 -6
- data/app/views/layouts/comfy/admin/cms/_head.html.haml +5 -0
- data/comfortable_mexican_sofa.gemspec +0 -3
- data/config/initializers/comfortable_mexican_sofa.rb +0 -12
- data/lib/comfortable_mexican_sofa/content/tags/file.rb +7 -10
- data/lib/comfortable_mexican_sofa/content/tags/file_link.rb +7 -12
- data/lib/comfortable_mexican_sofa/extensions/has_revisions.rb +1 -1
- data/lib/comfortable_mexican_sofa/version.rb +1 -1
- data/test/gemfiles/{Gemfile.rails.5.2 → 5.2.gemfile} +0 -0
- data/test/integration/meta_variables_test.rb +27 -0
- data/test/lib/content/tags/file_link_test.rb +7 -10
- data/test/lib/content/tags/file_test.rb +5 -10
- data/test/lib/content/tags/files_test.rb +3 -8
- metadata +4 -4
- data/test/integration/js_variables_test.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb7afcd2d6042c08dd39429cbf714394ab50b286
|
4
|
+
data.tar.gz: 1ad39a72dc37a220429932e9df775373b7ee83c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6421a3b93ae6e47689a3fff0066334c4fe8da857d363863d35cf292a757972faa0ff54ae079ab317753549c6d0e435c1a37842e8f592d9ce4547794ad3d1ba88
|
7
|
+
data.tar.gz: 3eb62f07989bf29b0b0d15409b989b806c44da21a1357c19a3694ae4c7b6099a5d410f25c9abec25cbb3dc056d4e54e1f5565fdc5f79f7b8fe1ac7d5c423c6ac
|
data/.travis.yml
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 2.2.
|
4
|
-
- 2.3.
|
5
|
-
- 2.4.
|
3
|
+
- 2.2.9
|
4
|
+
- 2.3.6
|
5
|
+
- 2.4.3
|
6
|
+
- 2.5.0
|
6
7
|
gemfile:
|
7
|
-
- test/gemfiles/
|
8
|
+
- test/gemfiles/5.2.gemfile
|
8
9
|
branches:
|
9
10
|
only:
|
10
11
|
- master
|
@@ -14,6 +15,9 @@ addons:
|
|
14
15
|
apt:
|
15
16
|
packages:
|
16
17
|
- google-chrome-stable
|
18
|
+
before_install:
|
19
|
+
- gem update --system
|
20
|
+
- gem update bundler
|
17
21
|
before_script:
|
18
22
|
- wget http://chromedriver.storage.googleapis.com/2.34/chromedriver_linux64.zip
|
19
23
|
- unzip chromedriver_linux64.zip
|
@@ -28,4 +32,4 @@ script:
|
|
28
32
|
- bundle exec rake db:migrate
|
29
33
|
- bundle exec rake test
|
30
34
|
- SKIP_COV=true bundle exec rake test:system
|
31
|
-
- bundle exec rubocop
|
35
|
+
- bundle exec rubocop
|
data/CONTRIBUTING.md
CHANGED
@@ -9,10 +9,12 @@ Fork the project. Optionally, create a branch you want to work on.
|
|
9
9
|
### 2. Get it running locally
|
10
10
|
|
11
11
|
- Install gem dependencies with `bundle install`
|
12
|
-
- There's nothing to configure, by default database is SQLite so it will be
|
13
|
-
Just run `rake db:migrate`
|
14
|
-
- Make sure that existing tests are passing by running `rake test`
|
15
|
-
-
|
12
|
+
- There's nothing to configure, by default database is SQLite so it will be
|
13
|
+
created for you. Just run `bundle exec rake db:migrate`
|
14
|
+
- Make sure that existing tests are passing by running `bundle exec rake test`
|
15
|
+
- There are system tests that can be run with `bundle exec rake test:system`.
|
16
|
+
You need to have `chromedriver` installed for that.
|
17
|
+
- You should be able to start the app via `bin/rails s` and navigate to http://localhost:3000/admin
|
16
18
|
|
17
19
|
### 3. Hack away
|
18
20
|
|
@@ -29,4 +31,5 @@ Fork the project. Optionally, create a branch you want to work on.
|
|
29
31
|
|
30
32
|
### 5. Done!
|
31
33
|
|
32
|
-
If everything is good your changes will be merged into master branch. Eventually
|
34
|
+
If everything is good your changes will be merged into master branch. Eventually
|
35
|
+
a new version of gem will be published.
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ comfy_route :cms, path: "/"
|
|
50
50
|
|
51
51
|
## Quick Start Guide
|
52
52
|
|
53
|
-
After finishing installation you should be able to navigate to http://
|
53
|
+
After finishing installation you should be able to navigate to http://localhost:3000/admin
|
54
54
|
|
55
55
|
Default username and password is 'username' and 'password'. You probably want to change it right away. Admin credentials (among other things) can be found and changed in the cms initializer: [/config/initializers/comfortable\_mexican\_sofa.rb](https://github.com/comfy/comfortable-mexican-sofa/blob/master/config/initializers/comfortable_mexican_sofa.rb)
|
56
56
|
|
@@ -73,7 +73,7 @@ Once you have a layout, you may start creating pages and populating content. It'
|
|
73
73
|
|
74
74
|
For more information please refer to [Wiki](https://github.com/comfy/comfortable-mexican-sofa/wiki).
|
75
75
|
|
76
|
-
![Admin Area Preview](
|
76
|
+
![Admin Area Preview](doc/preview.jpg)
|
77
77
|
|
78
78
|
#### Old Versions
|
79
79
|
|
@@ -83,6 +83,14 @@ With Rails 4.2 and 5.0 use gem version [1.12.10](https://rubygems.org/gems/comfo
|
|
83
83
|
|
84
84
|
With Rails 3.0 use gem version [1.8.5](https://rubygems.org/gems/comfortable_mexican_sofa/versions/1.8.5)
|
85
85
|
|
86
|
+
#### Contributing
|
87
|
+
|
88
|
+
ComfortableMexicanSofa repository can be ran like a regular Rails application in
|
89
|
+
development environment. It's as easy to work on as any other Rails app out there.
|
90
|
+
For more detail take a look at [CONTRIBUTING](CONTRIBUTING.md)
|
91
|
+
|
92
|
+
[![Help Contribute to Open Source](https://www.codetriage.com/comfy/comfortable-mexican-sofa/badges/users.svg)](https://www.codetriage.com/comfy/comfortable-mexican-sofa)
|
93
|
+
|
86
94
|
#### Help and Contact
|
87
95
|
|
88
96
|
Gitter: https://gitter.im/comfy/comfortable-mexican-sofa
|
@@ -91,10 +99,8 @@ Twitter: [@GroceryBagHead](https://twitter.com/grocerybaghead)
|
|
91
99
|
|
92
100
|
#### Acknowledgements
|
93
101
|
|
94
|
-
|
102
|
+
Thanks to [Roman Almeida](https://github.com/nasmorn) for contributing OEM License for [Redactor Text Editor](http://imperavi.com/redactor)
|
95
103
|
|
96
104
|
---
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
Copyright 2010-2017 Oleg Khabarov
|
106
|
+
Copyright 2010-2018 Oleg Khabarov. Released under the [MIT license](LICENSE)
|
@@ -20,8 +20,25 @@ window.CMS.init = ->
|
|
20
20
|
CMS.page_update_preview()
|
21
21
|
CMS.categories()
|
22
22
|
CMS.files()
|
23
|
+
CMS.upload_queue()
|
23
24
|
CMS.diff()
|
24
25
|
|
26
|
+
|
27
|
+
window.CMS.upload_queue = ->
|
28
|
+
if $("#cms-uploader").length
|
29
|
+
uploader_url = $("meta[name='cms-uploader-url']").attr("content")
|
30
|
+
token_name = $("meta[name='cms-uploader-token-name']").attr("content")
|
31
|
+
token_value = $("meta[name='cms-uploader-token-value']").attr("content")
|
32
|
+
session_name = $("meta[name='cms-uploader-session-name']").attr("content")
|
33
|
+
session_value = $("meta[name='cms-uploader-session-value']").attr("content")
|
34
|
+
|
35
|
+
window.CMS.uploader $("#cms-uploader"),
|
36
|
+
url: uploader_url,
|
37
|
+
multipart_params:
|
38
|
+
"#{token_name}": token_value,
|
39
|
+
"#{session_name}": session_value
|
40
|
+
|
41
|
+
|
25
42
|
window.CMS.slugify = ->
|
26
43
|
slugify = (str) ->
|
27
44
|
# Trim string and lower case.
|
@@ -80,18 +97,21 @@ window.CMS.wysiwyg = ->
|
|
80
97
|
if (csrf_param != undefined && csrf_token != undefined)
|
81
98
|
params = csrf_param + "=" + encodeURIComponent(csrf_token)
|
82
99
|
|
100
|
+
file_upload_path = $("meta[name='cms-file-upload-path']").attr("content")
|
101
|
+
pages_path = $("meta[name='cms-pages-path']").attr("content")
|
102
|
+
|
83
103
|
$('textarea.rich-text-editor, textarea[data-cms-rich-text]').redactor
|
84
104
|
minHeight: 160
|
85
105
|
autoresize: true
|
86
|
-
imageUpload: "#{
|
87
|
-
imageManagerJson: "#{
|
88
|
-
fileUpload: "#{
|
89
|
-
fileManagerJson: "#{
|
90
|
-
definedLinks: "#{
|
106
|
+
imageUpload: "#{file_upload_path}?source=redactor&type=image&#{params}"
|
107
|
+
imageManagerJson: "#{file_upload_path}?source=redactor&type=image"
|
108
|
+
fileUpload: "#{file_upload_path}?source=redactor&type=file&#{params}"
|
109
|
+
fileManagerJson: "#{file_upload_path}?source=redactor&type=file"
|
110
|
+
definedLinks: "#{pages_path}?source=redactor"
|
91
111
|
buttonSource: true
|
92
112
|
formatting: ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6']
|
93
113
|
plugins: ['imagemanager', 'filemanager', 'table', 'video', 'definedlinks']
|
94
|
-
lang:
|
114
|
+
lang: $("meta[name='cms-locale']").attr("content")
|
95
115
|
convertDivs: false
|
96
116
|
|
97
117
|
|
@@ -140,11 +160,11 @@ window.CMS.timepicker = ->
|
|
140
160
|
$('input[type=text][data-cms-datetime]').flatpickr
|
141
161
|
format: 'yyyy-mm-dd hh:ii'
|
142
162
|
enableTime: true
|
143
|
-
locale:
|
163
|
+
locale: $("meta[name='cms-locale']").attr("content")
|
144
164
|
|
145
165
|
$('input[type=text][data-cms-date]').flatpickr
|
146
166
|
format: 'yyyy-mm-dd',
|
147
|
-
locale:
|
167
|
+
locale: $("meta[name='cms-locale']").attr("content")
|
148
168
|
|
149
169
|
|
150
170
|
window.CMS.page_fragments = ->
|
@@ -9,7 +9,7 @@
|
|
9
9
|
.item-title
|
10
10
|
- if file.attachment.image?
|
11
11
|
- variant = file.attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])
|
12
|
-
- thumb = image_tag
|
12
|
+
- thumb = image_tag(url_for(variant), size: "200x150")
|
13
13
|
= link_to file.attachment, target: "_blank", data: {toggle: "page-file-popover", content: thumb} do
|
14
14
|
= file.label
|
15
15
|
|
@@ -1,3 +1,12 @@
|
|
1
|
+
- content_for :head do
|
2
|
+
|
3
|
+
- uploader_url = comfy_admin_cms_site_files_path(@site, source: :plupload, categories: params[:categories])
|
4
|
+
%meta{name: "cms-uploader-url", content: uploader_url}
|
5
|
+
%meta{name: "cms-uploader-token-name", content: request_forgery_protection_token}
|
6
|
+
%meta{name: "cms-uploader-token-value", content: form_authenticity_token}
|
7
|
+
%meta{name: "cms-uploader-session-name", content: Rails.application.config.session_options[:key]}
|
8
|
+
%meta{name: "cms-uploader-session-value", content: request.session_options[:id]}
|
9
|
+
|
1
10
|
- content_for :right_column do
|
2
11
|
= render "comfy/admin/cms/categories/index", type: "Comfy::Cms::File"
|
3
12
|
|
@@ -18,15 +27,3 @@
|
|
18
27
|
= comfy_admin_partial "comfy/admin/cms/partials/files_after"
|
19
28
|
|
20
29
|
= comfy_paginate @files
|
21
|
-
|
22
|
-
- content_for :javascript do
|
23
|
-
:javascript
|
24
|
-
$(function(){
|
25
|
-
window.CMS.uploader($("#cms-uploader"), {
|
26
|
-
url: '#{comfy_admin_cms_site_files_path(@site, source: :plupload, category: params[:category])}',
|
27
|
-
multipart_params: {
|
28
|
-
'#{request_forgery_protection_token}': '#{form_authenticity_token}',
|
29
|
-
'#{Rails.application.config.session_options[:key]}': '#{request.session_options[:id]}'
|
30
|
-
}
|
31
|
-
});
|
32
|
-
});
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- attachments.each do |attachment|
|
3
3
|
- if attachment.image?
|
4
4
|
- variant = attachment.variant(Comfy::Cms::File::VARIANT_SIZE[:thumb])
|
5
|
-
- thumb = image_tag
|
5
|
+
- thumb = image_tag(url_for(variant), size: "200x150")
|
6
6
|
.btn.btn-outline-light
|
7
7
|
= link_to attachment.filename, attachment, {data: {toggle: "page-file-popover", content: thumb}}
|
8
8
|
%label.custom-control.custom-checkbox
|
@@ -2,11 +2,5 @@
|
|
2
2
|
|
3
3
|
= javascript_include_tag "comfy/admin/cms/application", "data-turbolinks-track": "reload"
|
4
4
|
|
5
|
-
- if @site && @site.persisted?
|
6
|
-
:javascript
|
7
|
-
CMS.file_upload_path = '#{comfy_admin_cms_site_files_path(@site)}';
|
8
|
-
CMS.pages_path = '#{comfy_admin_cms_site_pages_path(@site)}';
|
9
|
-
CMS.locale = '#{I18n.locale}';
|
10
|
-
|
11
5
|
- if content_for(:javascript)
|
12
6
|
= yield :javascript
|
@@ -7,6 +7,11 @@
|
|
7
7
|
|
8
8
|
= csrf_meta_tag
|
9
9
|
|
10
|
+
- if @site && @site.persisted?
|
11
|
+
%meta{name: "cms-file-upload-path", content: comfy_admin_cms_site_files_path(@site)}
|
12
|
+
%meta{name: "cms-pages-path", content: comfy_admin_cms_site_pages_path(@site)}
|
13
|
+
%meta{name: "cms-locale", content: I18n.locale}
|
14
|
+
|
10
15
|
= stylesheet_link_tag "comfy/admin/cms/application", media: "all", "data-turbolinks-track": "reload"
|
11
16
|
|
12
17
|
= yield :head
|
@@ -10,10 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.summary = "Rails 5.2+ CMS Engine"
|
11
11
|
s.description = "ComfortableMexicanSofa is a powerful Rails 5.2+ CMS Engine"
|
12
12
|
s.license = "MIT"
|
13
|
-
|
14
13
|
s.files = `git ls-files`.split("\n")
|
15
|
-
s.platform = Gem::Platform::RUBY
|
16
|
-
s.require_paths = ["lib"]
|
17
14
|
|
18
15
|
s.required_ruby_version = ">= 2.2.2"
|
19
16
|
|
@@ -36,18 +36,6 @@ ComfortableMexicanSofa.configure do |config|
|
|
36
36
|
# Path where seeds can be located.
|
37
37
|
# config.seeds_path = File.expand_path('db/cms_seeds', Rails.root)
|
38
38
|
|
39
|
-
# Importing fixtures into Database
|
40
|
-
# To load fixtures into the database just run this rake task:
|
41
|
-
# local: $ rake comfortable_mexican_sofa:fixtures:import FROM=example.local TO=localhost
|
42
|
-
# Heroku: $ heroku run rake comfortable_mexican_sofa:fixtures:import FROM=example.local TO=yourapp.herokuapp.com
|
43
|
-
# From indicates folder the fixtures are in and to is the Site hostname you have defined in the database.
|
44
|
-
|
45
|
-
# Exporting fixtures into Files
|
46
|
-
# If you need to dump database contents into fixture files run:
|
47
|
-
# local: $ rake comfortable_mexican_sofa:fixtures:export FROM=localhost TO=example.local
|
48
|
-
# Heroku: $ heroku run rake comfortable_mexican_sofa:fixtures:export FROM=yourapp.herokuapp.com TO=example.local
|
49
|
-
# This will create example.local folder and dump all content from example.com Site.
|
50
|
-
|
51
39
|
# Content for Layouts, Pages and Snippets has a revision history. You can revert
|
52
40
|
# a previous version using this system. You can control how many revisions per
|
53
41
|
# object you want to keep. Set it to 0 if you wish to turn this feature off.
|
@@ -12,6 +12,8 @@ class ComfortableMexicanSofa::Content::Tag::File < ComfortableMexicanSofa::Conte
|
|
12
12
|
|
13
13
|
attr_reader :as, :variant_attrs
|
14
14
|
|
15
|
+
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
16
|
+
|
15
17
|
def initialize(context, params_string)
|
16
18
|
super
|
17
19
|
@as = options["as"] || "url"
|
@@ -26,13 +28,15 @@ class ComfortableMexicanSofa::Content::Tag::File < ComfortableMexicanSofa::Conte
|
|
26
28
|
file = file.variant(@variant_attrs)
|
27
29
|
end
|
28
30
|
|
31
|
+
url = rails_blob_path(file, only_path: true)
|
32
|
+
|
29
33
|
case @as
|
30
34
|
when "link"
|
31
|
-
"<a href='#{
|
35
|
+
"<a href='#{url}' target='_blank'>#{label}</a>"
|
32
36
|
when "image"
|
33
|
-
"<img src='#{
|
37
|
+
"<img src='#{url}' alt='#{label}'/>"
|
34
38
|
else
|
35
|
-
|
39
|
+
url
|
36
40
|
end
|
37
41
|
end
|
38
42
|
|
@@ -65,13 +69,6 @@ protected
|
|
65
69
|
@label || attachment && attachment.filename
|
66
70
|
end
|
67
71
|
|
68
|
-
def url_for(attachment)
|
69
|
-
ApplicationController.render(
|
70
|
-
inline: "<%= url_for(@attachment) %>",
|
71
|
-
assigns: { attachment: attachment }
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
72
|
end
|
76
73
|
|
77
74
|
ComfortableMexicanSofa::Content::Renderer.register_tag(
|
@@ -12,6 +12,8 @@ class ComfortableMexicanSofa::Content::Tag::FileLink < ComfortableMexicanSofa::C
|
|
12
12
|
|
13
13
|
attr_reader :identifier, :as, :variant_attrs
|
14
14
|
|
15
|
+
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
16
|
+
|
15
17
|
def initialize(context, params_string)
|
16
18
|
super
|
17
19
|
|
@@ -41,25 +43,18 @@ class ComfortableMexicanSofa::Content::Tag::FileLink < ComfortableMexicanSofa::C
|
|
41
43
|
attachment = attachment.variant(@variant_attrs)
|
42
44
|
end
|
43
45
|
|
46
|
+
url = rails_blob_path(attachment, only_path: true)
|
47
|
+
|
44
48
|
case @as
|
45
49
|
when "link"
|
46
|
-
"<a href='#{
|
50
|
+
"<a href='#{url}' target='_blank'>#{label}</a>"
|
47
51
|
when "image"
|
48
|
-
"<img src='#{
|
52
|
+
"<img src='#{url}' alt='#{label}'/>"
|
49
53
|
else
|
50
|
-
|
54
|
+
url
|
51
55
|
end
|
52
56
|
end
|
53
57
|
|
54
|
-
protected
|
55
|
-
|
56
|
-
def url_for(attachment)
|
57
|
-
ApplicationController.render(
|
58
|
-
inline: "<%= url_for(@attachment) %>",
|
59
|
-
assigns: { attachment: attachment }
|
60
|
-
)
|
61
|
-
end
|
62
|
-
|
63
58
|
end
|
64
59
|
|
65
60
|
ComfortableMexicanSofa::Content::Renderer.register_tag(
|
@@ -7,7 +7,7 @@ module ComfortableMexicanSofa::HasRevisions
|
|
7
7
|
module ClassMethods
|
8
8
|
|
9
9
|
def cms_has_revisions_for(*fields)
|
10
|
-
include ComfortableMexicanSofa::HasRevisions::InstanceMethods
|
10
|
+
include ComfortableMexicanSofa::HasRevisions::InstanceMethods
|
11
11
|
|
12
12
|
attr_accessor :revision_data
|
13
13
|
|
File without changes
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative "../test_helper"
|
2
|
+
|
3
|
+
class MetaVariablesIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
+
|
5
|
+
def test_redactor_js_variables
|
6
|
+
site = comfy_cms_sites(:default)
|
7
|
+
r :get, comfy_admin_cms_site_pages_path(site)
|
8
|
+
assert_response :success
|
9
|
+
|
10
|
+
assert_select "meta[name='cms-file-upload-path'][content='#{comfy_admin_cms_site_files_path(site)}']"
|
11
|
+
assert_select "meta[name='cms-pages-path'][content='#{comfy_admin_cms_site_pages_path(site)}']"
|
12
|
+
assert_select "meta[name='cms-locale'][content='en']"
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_plupload_js_variables
|
16
|
+
site = comfy_cms_sites(:default)
|
17
|
+
r :get, comfy_admin_cms_site_files_path(site)
|
18
|
+
assert_response :success
|
19
|
+
|
20
|
+
assert_select "meta[name='cms-uploader-url']"
|
21
|
+
assert_select "meta[name='cms-uploader-token-name']"
|
22
|
+
assert_select "meta[name='cms-uploader-token-value']"
|
23
|
+
assert_select "meta[name='cms-uploader-session-name']"
|
24
|
+
assert_select "meta[name='cms-uploader-session-value']"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -2,18 +2,13 @@ require_relative "../../../test_helper"
|
|
2
2
|
|
3
3
|
class ContentTagsFileLinkTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
+
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
6
|
+
|
5
7
|
setup do
|
6
8
|
@page = comfy_cms_pages(:default)
|
7
9
|
@file = comfy_cms_files(:default)
|
8
10
|
end
|
9
11
|
|
10
|
-
def url_for(attachment)
|
11
|
-
ApplicationController.render(
|
12
|
-
inline: "<%= url_for(@attachment) %>",
|
13
|
-
assigns: { attachment: attachment }
|
14
|
-
)
|
15
|
-
end
|
16
|
-
|
17
12
|
# -- Tests -------------------------------------------------------------------
|
18
13
|
|
19
14
|
def test_init
|
@@ -51,21 +46,23 @@ class ContentTagsFileLinkTest < ActiveSupport::TestCase
|
|
51
46
|
|
52
47
|
def test_content
|
53
48
|
tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, @file.id)
|
54
|
-
out =
|
49
|
+
out = rails_blob_path(tag.file.attachment, only_path: true)
|
55
50
|
assert_equal out, tag.content
|
56
51
|
assert_equal out, tag.render
|
57
52
|
end
|
58
53
|
|
59
54
|
def test_content_as_link
|
60
55
|
tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "#{@file.id}, as: link")
|
61
|
-
|
56
|
+
url = rails_blob_path(tag.file.attachment, only_path: true)
|
57
|
+
out = "<a href='#{url}' target='_blank'>default file</a>"
|
62
58
|
assert_equal out, tag.content
|
63
59
|
assert_equal out, tag.render
|
64
60
|
end
|
65
61
|
|
66
62
|
def test_content_as_image
|
67
63
|
tag = ComfortableMexicanSofa::Content::Tag::FileLink.new(@page, "#{@file.id}, as: image")
|
68
|
-
|
64
|
+
url = rails_blob_path(tag.file.attachment, only_path: true)
|
65
|
+
out = "<img src='#{url}' alt='default file'/>"
|
69
66
|
assert_equal out, tag.content
|
70
67
|
assert_equal out, tag.render
|
71
68
|
end
|
@@ -2,17 +2,12 @@ require_relative "../../../test_helper"
|
|
2
2
|
|
3
3
|
class ContentTagsFileTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
+
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
6
|
+
|
5
7
|
setup do
|
6
8
|
@page = comfy_cms_pages(:default)
|
7
9
|
end
|
8
10
|
|
9
|
-
def url_for(attachment)
|
10
|
-
ApplicationController.render(
|
11
|
-
inline: "<%= url_for(@attachment) %>",
|
12
|
-
assigns: { attachment: attachment }
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
11
|
# -- Tests -------------------------------------------------------------------
|
17
12
|
|
18
13
|
def test_init
|
@@ -36,20 +31,20 @@ class ContentTagsFileTest < ActiveSupport::TestCase
|
|
36
31
|
def test_content
|
37
32
|
frag = comfy_cms_fragments(:file)
|
38
33
|
tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, frag.identifier)
|
39
|
-
assert_equal
|
34
|
+
assert_equal rails_blob_path(frag.attachments.first, only_path: true), tag.content
|
40
35
|
end
|
41
36
|
|
42
37
|
def test_content_as_link
|
43
38
|
frag = comfy_cms_fragments(:file)
|
44
39
|
tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: link")
|
45
|
-
out = "<a href='#{
|
40
|
+
out = "<a href='#{rails_blob_path(frag.attachments.first, only_path: true)}' target='_blank'>fragment.jpg</a>"
|
46
41
|
assert_equal out, tag.content
|
47
42
|
end
|
48
43
|
|
49
44
|
def test_content_as_image
|
50
45
|
frag = comfy_cms_fragments(:file)
|
51
46
|
tag = ComfortableMexicanSofa::Content::Tag::File.new(@page, "#{frag.identifier}, as: image")
|
52
|
-
out = "<img src='#{
|
47
|
+
out = "<img src='#{rails_blob_path(frag.attachments.first, only_path: true)}' alt='fragment.jpg'/>"
|
53
48
|
assert_equal out, tag.content
|
54
49
|
end
|
55
50
|
|
@@ -2,17 +2,12 @@ require_relative "../../../test_helper"
|
|
2
2
|
|
3
3
|
class ContentTagsFilesTest < ActiveSupport::TestCase
|
4
4
|
|
5
|
+
delegate :rails_blob_path, to: "Rails.application.routes.url_helpers"
|
6
|
+
|
5
7
|
setup do
|
6
8
|
@page = comfy_cms_pages(:default)
|
7
9
|
end
|
8
10
|
|
9
|
-
def url_for(attachment)
|
10
|
-
ApplicationController.render(
|
11
|
-
inline: "<%= url_for(@attachment) %>",
|
12
|
-
assigns: { attachment: attachment }
|
13
|
-
)
|
14
|
-
end
|
15
|
-
|
16
11
|
# -- Tests -------------------------------------------------------------------
|
17
12
|
|
18
13
|
def test_init
|
@@ -38,7 +33,7 @@ class ContentTagsFilesTest < ActiveSupport::TestCase
|
|
38
33
|
frag.update_attribute(:tag, "files")
|
39
34
|
frag.update_attribute(:files, fixture_file_upload("files/image.jpg", "image/jpeg"))
|
40
35
|
tag = ComfortableMexicanSofa::Content::Tag::Files.new(@page, frag.identifier)
|
41
|
-
out = frag.attachments.map { |a|
|
36
|
+
out = frag.attachments.map { |a| rails_blob_path(a, only_path: true) }.join(" ")
|
42
37
|
assert_equal out, tag.content
|
43
38
|
end
|
44
39
|
|
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.8
|
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: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_link_to
|
@@ -667,7 +667,7 @@ files:
|
|
667
667
|
- test/fixtures/views/render_test/_test.html.erb
|
668
668
|
- test/fixtures/views/render_test/new.html.erb
|
669
669
|
- test/fixtures/views/render_test/render_layout.html.erb
|
670
|
-
- test/gemfiles/
|
670
|
+
- test/gemfiles/5.2.gemfile
|
671
671
|
- test/generators/cms_assets_generator_test.rb
|
672
672
|
- test/generators/cms_controllers_generator_test.rb
|
673
673
|
- test/generators/cms_generator_test.rb
|
@@ -677,7 +677,7 @@ files:
|
|
677
677
|
- test/helpers/cms_helper_test.rb
|
678
678
|
- test/integration/access_control_test.rb
|
679
679
|
- test/integration/i18n_test.rb
|
680
|
-
- test/integration/
|
680
|
+
- test/integration/meta_variables_test.rb
|
681
681
|
- test/integration/render_cms_test.rb
|
682
682
|
- test/integration/routing_test.rb
|
683
683
|
- test/integration/seeds_test.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative "../test_helper"
|
2
|
-
|
3
|
-
class JsVariablesIntegrationTest < ActionDispatch::IntegrationTest
|
4
|
-
|
5
|
-
def test_redactor_js_variables
|
6
|
-
site = comfy_cms_sites(:default)
|
7
|
-
r :get, comfy_admin_cms_site_pages_path(site)
|
8
|
-
assert_response :success
|
9
|
-
|
10
|
-
js_vars = <<-HTML.strip_heredoc
|
11
|
-
<script>
|
12
|
-
CMS.file_upload_path = '#{comfy_admin_cms_site_files_path(site)}';
|
13
|
-
CMS.pages_path = '#{comfy_admin_cms_site_pages_path(site)}';
|
14
|
-
CMS.locale = 'en';
|
15
|
-
</script>
|
16
|
-
HTML
|
17
|
-
|
18
|
-
assert response.body.match(js_vars)
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|