type_station 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/type_station/editables/file_editor.js.coffee +5 -1
- data/app/assets/javascripts/type_station/editables/text_html_editor.js.coffee +3 -3
- data/app/controllers/type_station/file_controller.rb +15 -0
- data/app/presenters/type_station/base_presenter.rb +5 -4
- data/app/presenters/type_station/content_presenter.rb +17 -1
- data/app/presenters/type_station/presenter.rb +2 -2
- data/config/routes.rb +2 -0
- data/lib/type_station/blocks/field.rb +2 -1
- data/lib/type_station/version.rb +2 -2
- data/spec/dummy/app/views/pages/index_other.html.erb +6 -0
- data/spec/dummy/log/development.log +4708 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1057bd97781bd01e53c6be1c18815331 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f14bda8290314a0fd6c175fcad55e69 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3203d681677ab8bf95858a71dca72ad1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4c48023968030daffd8c05e4e1ea78bf +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6694f57666543a152f6f95b772233bd3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/722eee3ce416c20905dda68eab3d517e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/82cfb0f0bcd16b930ec1befc0d5cd8b8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/83c193129690d0c85c5370d822c4da82 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9a5b201b4dddc98127641bcf852a4ea8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a0c3540cd0a5390bd8985db285d1574f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/aa9f5420651d522078eadd9de8350d35 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/afa9de4377b9615980b737000fc68a2a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b3b877cfd5c63c892cfe8c6248e3d003 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bb1b5b9fd84c67b2b994666f8162e79b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bf1e850366946d51a864f66042acb16d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c4b181c541556124b2275b0ae4a94461 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf6bd170bc3f231ca9da6434bd53359b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ddf237d5e172776d2061090bbf8fc6a5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e1bc9024b810c879e24aa1de0f013358 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ea306a2a3565b22cd16bf45555e751b5 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f8a56681cc92b0dba2c2fdb753933a8b +0 -0
- data/vendor/assets/javascripts/medium-editor.js +6640 -2088
- data/vendor/assets/stylesheets/medium-editor/medium-editor.css +154 -136
- data/vendor/assets/stylesheets/medium-editor/medium-editor.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/beagle.css +78 -0
- data/vendor/assets/stylesheets/medium-editor/themes/beagle.min.css +1 -0
- data/vendor/assets/stylesheets/medium-editor/themes/bootstrap.css +17 -17
- data/vendor/assets/stylesheets/medium-editor/themes/bootstrap.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/default.css +25 -25
- data/vendor/assets/stylesheets/medium-editor/themes/default.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/flat.css +1 -0
- data/vendor/assets/stylesheets/medium-editor/themes/flat.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/mani.css +5 -4
- data/vendor/assets/stylesheets/medium-editor/themes/mani.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/roman.css +7 -6
- data/vendor/assets/stylesheets/medium-editor/themes/roman.min.css +1 -1
- data/vendor/assets/stylesheets/medium-editor/themes/tim.css +67 -0
- data/vendor/assets/stylesheets/medium-editor/themes/tim.min.css +1 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c8cbbcecb160a2bcd25a314804510fc1a3a21e9
|
4
|
+
data.tar.gz: 3478676189a52355a610d94d5b24a6959aabc930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b27ef6da2a32344e526014f74101cb20f4384315f241379059f1fd572d0a6403fbd3d98264702476cf003ea0efb730df5655b960d905f89d76ef6f0eb975116c
|
7
|
+
data.tar.gz: c65c7fa87ee5d133901c83673f0f6dcfdbf101d9ae2bedfaf6a65ed303fa1031df598221b839267f193ff248518076f3302f243f7b0aeb5483c301ad8a24c328
|
@@ -23,7 +23,11 @@ buildUploader = (editor) ->
|
|
23
23
|
for imageTag in $('.ts-editable-image-tag', $element)
|
24
24
|
$(imageTag).attr('src', $.cloudinary.url(data.result.public_id, $.extend({}, {format: data.result.format}, $(imageTag).data())))
|
25
25
|
for linkTag in $('.ts-editable-link-tag', $element)
|
26
|
-
|
26
|
+
if data.result.type == "private"
|
27
|
+
url = $(linkTag).data('download-url').replace('IDENTIFIER', data.result.public_id).replace('FORMAT', data.result.format)
|
28
|
+
$(linkTag).attr('href', url)
|
29
|
+
else
|
30
|
+
$(linkTag).attr('href', $.cloudinary.url(data.result.public_id, {resource_type: 'raw', format: data.result.format}))
|
27
31
|
$(this).prop('disabled', false)
|
28
32
|
$('.ts-progress-bar').remove()
|
29
33
|
|
@@ -42,11 +42,11 @@ class @TypeStation.TextHtmlEditor
|
|
42
42
|
# checkLinkFormat: true
|
43
43
|
|
44
44
|
@editor = new MediumEditor @$el, editorOptions
|
45
|
-
@editor.
|
45
|
+
@editor.destroy()
|
46
46
|
@$el.attr('data-ts-id', @data.id).attr('data-ts-field', @data.field)
|
47
47
|
|
48
48
|
enable: ->
|
49
|
-
@editor.
|
49
|
+
@editor.setup()
|
50
50
|
self = @
|
51
51
|
eventName = if isIE() then 'keyup' else 'input'
|
52
52
|
@$el.on eventName, ->
|
@@ -59,5 +59,5 @@ class @TypeStation.TextHtmlEditor
|
|
59
59
|
updateGlobalValue($(@), $(@).html())
|
60
60
|
|
61
61
|
disable: ->
|
62
|
-
@editor.
|
62
|
+
@editor.destroy()
|
63
63
|
@$el.off 'input'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TypeStation
|
2
|
+
class FileController < TypeStation::ApplicationController
|
3
|
+
|
4
|
+
def download
|
5
|
+
redirect_to private_download_url
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def private_download_url
|
11
|
+
Cloudinary::Utils.private_download_url(params[:identifier], params[:format], attachment: true, expires_at: 1.minute.from_now )
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module TypeStation
|
2
2
|
class BasePresenter
|
3
3
|
|
4
|
-
def initialize(object, template)
|
4
|
+
def initialize(object, template, options = {})
|
5
5
|
@object = object
|
6
6
|
@template = template
|
7
|
+
@options = options
|
7
8
|
end
|
8
9
|
|
9
10
|
private
|
@@ -21,10 +22,10 @@ module TypeStation
|
|
21
22
|
def markdown(text)
|
22
23
|
Redcarpet.new(text, :hard_wrap, :filter_html, :autolink).to_html.html_safe
|
23
24
|
end
|
24
|
-
|
25
|
+
|
25
26
|
def method_missing(*args, &block)
|
26
27
|
@template.send(*args, &block)
|
27
28
|
end
|
28
|
-
|
29
|
+
|
29
30
|
end
|
30
|
-
end
|
31
|
+
end
|
@@ -9,7 +9,7 @@ module TypeStation
|
|
9
9
|
|
10
10
|
def link(default, html_options = nil, &block)
|
11
11
|
css_class = html_options.delete(:class) if html_options.include?(:class)
|
12
|
-
content_tag(:a, nil, html_options.merge({class: ['ts-editable-link-tag', css_class], href: (
|
12
|
+
content_tag(:a, nil, html_options.merge({class: ['ts-editable-link-tag', css_class], href: link_href(default), data: link_data_attribute }), &block)
|
13
13
|
end
|
14
14
|
|
15
15
|
def value_is_hash?
|
@@ -26,5 +26,21 @@ module TypeStation
|
|
26
26
|
@sanitized_value ||= Rails::Html::WhiteListSanitizer.new.sanitize(content)
|
27
27
|
end
|
28
28
|
|
29
|
+
def link_href(default)
|
30
|
+
if content.present?
|
31
|
+
if @options[:private]
|
32
|
+
type_station.download_url(identifier: content['identifier'], format: content['format'])
|
33
|
+
else
|
34
|
+
cloudinary_url(content['identifier'], format: content['format'])
|
35
|
+
end
|
36
|
+
else
|
37
|
+
default
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def link_data_attribute
|
42
|
+
@options[:private] ? {download_url: type_station.download_url(identifier: 'IDENTIFIER', format: 'FORMAT')} : nil
|
43
|
+
end
|
44
|
+
|
29
45
|
end
|
30
46
|
end
|
@@ -39,7 +39,7 @@ module TypeStation
|
|
39
39
|
content_attribute = @object.get name
|
40
40
|
|
41
41
|
if content_attribute.present?
|
42
|
-
content_presenter = ContentPresenter.new(content_attribute, h)
|
42
|
+
content_presenter = ContentPresenter.new(content_attribute, h, options)
|
43
43
|
|
44
44
|
if content_presenter.value_is_hash?
|
45
45
|
content += h.capture(content_presenter, &block)
|
@@ -47,7 +47,7 @@ module TypeStation
|
|
47
47
|
content += content_presenter.value
|
48
48
|
end
|
49
49
|
else
|
50
|
-
content += h.capture(ContentPresenter.new(nil,h), &block)
|
50
|
+
content += h.capture(ContentPresenter.new(nil,h, options), &block)
|
51
51
|
end
|
52
52
|
|
53
53
|
TypeStation::Blocks::Field.new(h.type_station_authorise, @object, options).render(content)
|
data/config/routes.rb
CHANGED
@@ -18,7 +18,8 @@ module TypeStation
|
|
18
18
|
def data_options
|
19
19
|
case options[:type]
|
20
20
|
when :image, :file
|
21
|
-
|
21
|
+
upload_option = options[:private].present? ? { type: 'private' } : {}
|
22
|
+
{ cloudinary: (Cloudinary::Utils.sign_request(Cloudinary::Uploader.build_upload_params(upload_option), {}) rescue {}) }
|
22
23
|
else
|
23
24
|
nil
|
24
25
|
end
|
data/lib/type_station/version.rb
CHANGED
@@ -121,6 +121,12 @@
|
|
121
121
|
<%- end %>
|
122
122
|
<%- end %>
|
123
123
|
|
124
|
+
<%= p.field :private_file, type: :file, private: true do |file| %>
|
125
|
+
<%= file.link 'http://lorempixel.com/400/200/', class: 'text', title: 'hello' do %>
|
126
|
+
Private
|
127
|
+
<%- end %>
|
128
|
+
<%- end %>
|
129
|
+
|
124
130
|
|
125
131
|
<h1>
|
126
132
|
<%= p.create :team do %>
|