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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/type_station/editables/file_editor.js.coffee +5 -1
  3. data/app/assets/javascripts/type_station/editables/text_html_editor.js.coffee +3 -3
  4. data/app/controllers/type_station/file_controller.rb +15 -0
  5. data/app/presenters/type_station/base_presenter.rb +5 -4
  6. data/app/presenters/type_station/content_presenter.rb +17 -1
  7. data/app/presenters/type_station/presenter.rb +2 -2
  8. data/config/routes.rb +2 -0
  9. data/lib/type_station/blocks/field.rb +2 -1
  10. data/lib/type_station/version.rb +2 -2
  11. data/spec/dummy/app/views/pages/index_other.html.erb +6 -0
  12. data/spec/dummy/log/development.log +4708 -0
  13. data/spec/dummy/tmp/cache/assets/development/sprockets/1057bd97781bd01e53c6be1c18815331 +0 -0
  14. data/spec/dummy/tmp/cache/assets/development/sprockets/2f14bda8290314a0fd6c175fcad55e69 +0 -0
  15. data/spec/dummy/tmp/cache/assets/development/sprockets/3203d681677ab8bf95858a71dca72ad1 +0 -0
  16. data/spec/dummy/tmp/cache/assets/development/sprockets/4c48023968030daffd8c05e4e1ea78bf +0 -0
  17. data/spec/dummy/tmp/cache/assets/development/sprockets/6694f57666543a152f6f95b772233bd3 +0 -0
  18. data/spec/dummy/tmp/cache/assets/development/sprockets/722eee3ce416c20905dda68eab3d517e +0 -0
  19. data/spec/dummy/tmp/cache/assets/development/sprockets/82cfb0f0bcd16b930ec1befc0d5cd8b8 +0 -0
  20. data/spec/dummy/tmp/cache/assets/development/sprockets/83c193129690d0c85c5370d822c4da82 +0 -0
  21. data/spec/dummy/tmp/cache/assets/development/sprockets/9a5b201b4dddc98127641bcf852a4ea8 +0 -0
  22. data/spec/dummy/tmp/cache/assets/development/sprockets/a0c3540cd0a5390bd8985db285d1574f +0 -0
  23. data/spec/dummy/tmp/cache/assets/development/sprockets/aa9f5420651d522078eadd9de8350d35 +0 -0
  24. data/spec/dummy/tmp/cache/assets/development/sprockets/afa9de4377b9615980b737000fc68a2a +0 -0
  25. data/spec/dummy/tmp/cache/assets/development/sprockets/b3b877cfd5c63c892cfe8c6248e3d003 +0 -0
  26. data/spec/dummy/tmp/cache/assets/development/sprockets/bb1b5b9fd84c67b2b994666f8162e79b +0 -0
  27. data/spec/dummy/tmp/cache/assets/development/sprockets/bf1e850366946d51a864f66042acb16d +0 -0
  28. data/spec/dummy/tmp/cache/assets/development/sprockets/c4b181c541556124b2275b0ae4a94461 +0 -0
  29. data/spec/dummy/tmp/cache/assets/development/sprockets/cf6bd170bc3f231ca9da6434bd53359b +0 -0
  30. data/spec/dummy/tmp/cache/assets/development/sprockets/ddf237d5e172776d2061090bbf8fc6a5 +0 -0
  31. data/spec/dummy/tmp/cache/assets/development/sprockets/e1bc9024b810c879e24aa1de0f013358 +0 -0
  32. data/spec/dummy/tmp/cache/assets/development/sprockets/ea306a2a3565b22cd16bf45555e751b5 +0 -0
  33. data/spec/dummy/tmp/cache/assets/development/sprockets/f8a56681cc92b0dba2c2fdb753933a8b +0 -0
  34. data/vendor/assets/javascripts/medium-editor.js +6640 -2088
  35. data/vendor/assets/stylesheets/medium-editor/medium-editor.css +154 -136
  36. data/vendor/assets/stylesheets/medium-editor/medium-editor.min.css +1 -1
  37. data/vendor/assets/stylesheets/medium-editor/themes/beagle.css +78 -0
  38. data/vendor/assets/stylesheets/medium-editor/themes/beagle.min.css +1 -0
  39. data/vendor/assets/stylesheets/medium-editor/themes/bootstrap.css +17 -17
  40. data/vendor/assets/stylesheets/medium-editor/themes/bootstrap.min.css +1 -1
  41. data/vendor/assets/stylesheets/medium-editor/themes/default.css +25 -25
  42. data/vendor/assets/stylesheets/medium-editor/themes/default.min.css +1 -1
  43. data/vendor/assets/stylesheets/medium-editor/themes/flat.css +1 -0
  44. data/vendor/assets/stylesheets/medium-editor/themes/flat.min.css +1 -1
  45. data/vendor/assets/stylesheets/medium-editor/themes/mani.css +5 -4
  46. data/vendor/assets/stylesheets/medium-editor/themes/mani.min.css +1 -1
  47. data/vendor/assets/stylesheets/medium-editor/themes/roman.css +7 -6
  48. data/vendor/assets/stylesheets/medium-editor/themes/roman.min.css +1 -1
  49. data/vendor/assets/stylesheets/medium-editor/themes/tim.css +67 -0
  50. data/vendor/assets/stylesheets/medium-editor/themes/tim.min.css +1 -0
  51. metadata +7 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1e2c875af09a5e3f22fa771972baa78601b82b7
4
- data.tar.gz: e0fadc81b6d37579e9f7326260935361edf801ff
3
+ metadata.gz: 5c8cbbcecb160a2bcd25a314804510fc1a3a21e9
4
+ data.tar.gz: 3478676189a52355a610d94d5b24a6959aabc930
5
5
  SHA512:
6
- metadata.gz: 4bf929a7bf80ee79adb0c8abd741777ef3d186181aaf91ce3c98cc5e47f5963fdf42d3952ac3352602cfacd37752a008d5a28b0aae19bdfbc3730fe4e0b6f9db
7
- data.tar.gz: 64c468374ad6d1c4e6412f5735932c485ab444fddeab91722d981db9d5a2a57955db9f98b33025b2d9ee0ed91e746f02017cfb157bc3f43d3260dc5d08f3d074
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
- $(linkTag).attr('href', $.cloudinary.url(data.result.public_id, {resource_type: 'raw', format: data.result.format}))
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.deactivate()
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.activate()
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.deactivate()
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: (content.present? ? cloudinary_url(content['identifier'], format: content['format']) : default)}), &block)
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
@@ -9,5 +9,7 @@ TypeStation::Engine.routes.draw do
9
9
  end
10
10
  end
11
11
 
12
+ get 'file-download/:identifier' => 'file#download', as: :download
13
+
12
14
  match "*path", to: "pages#show", via: :all
13
15
  end
@@ -18,7 +18,8 @@ module TypeStation
18
18
  def data_options
19
19
  case options[:type]
20
20
  when :image, :file
21
- { cloudinary: (Cloudinary::Utils.sign_request(Cloudinary::Uploader.build_upload_params({}), {}) rescue {}) }
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
@@ -1,8 +1,8 @@
1
1
  module TypeStation
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 3
5
- TINY = 4
4
+ MINOR = 4
5
+ TINY = 0
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
8
  end
@@ -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 %>