ds_media_library 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.DS_Store +0 -0
  3. data/.gitignore +1 -0
  4. data/README.md +1 -1
  5. data/app/assets/javascripts/ds_media_library.coffee +66 -16
  6. data/app/assets/stylesheets/_breadcrumb-nav.sass +25 -0
  7. data/app/assets/stylesheets/_help-text.sass +5 -0
  8. data/app/assets/stylesheets/_media-tree.sass +194 -0
  9. data/app/assets/stylesheets/_modal.sass +65 -0
  10. data/app/assets/stylesheets/_placeholders.sass +43 -0
  11. data/app/assets/stylesheets/_preview-media.sass +88 -0
  12. data/app/assets/stylesheets/ds_media_library.sass +139 -0
  13. data/app/assets/stylesheets/mixins/_buttons.sass +57 -0
  14. data/app/assets/stylesheets/mixins/_icons.sass +36 -0
  15. data/app/assets/stylesheets/mixins/_notification-text.sass +23 -0
  16. data/app/controllers/ds_media_library/folders_controller.rb +7 -2
  17. data/app/controllers/ds_media_library/resources_controller.rb +3 -2
  18. data/{lib → app/helpers}/ds_media_library/form_helper.rb +24 -17
  19. data/app/views/ds_media_library/form_helper/_folder.html.slim +10 -0
  20. data/app/views/ds_media_library/form_helper/_media_library_helper.html.slim +46 -0
  21. data/app/views/ds_media_library/form_helper/_resource.html.slim +6 -0
  22. data/app/views/ds_media_library/form_helper/show.html.slim +10 -0
  23. data/app/views/{shared → ds_media_library/manage}/_submit.html.slim +0 -0
  24. data/app/views/ds_media_library/manage/folders/_folder.html.slim +14 -0
  25. data/app/views/ds_media_library/{resources/folder_form.html.slim → manage/folders/form.html.slim} +4 -4
  26. data/app/views/ds_media_library/manage/index.html.slim +30 -0
  27. data/app/views/{shared → ds_media_library/manage/resources}/_image_preview.html.slim +2 -2
  28. data/app/views/ds_media_library/manage/resources/_resource.html.slim +12 -0
  29. data/app/views/ds_media_library/{resources → manage/resources}/form.html.slim +3 -3
  30. data/bin/server +1 -1
  31. data/bin/setup +1 -2
  32. data/ds_media_library.gemspec +1 -0
  33. data/dummy/app.rb +1 -48
  34. data/dummy/config.rb +55 -0
  35. data/dummy/database.rb +6 -0
  36. data/dummy/views.rb +14 -65
  37. data/lib/ds_media_library/engine.rb +4 -2
  38. data/lib/ds_media_library/version.rb +1 -1
  39. data/lib/ds_media_library.rb +0 -1
  40. metadata +40 -15
  41. data/app/assets/javascripts/toggle_all_checkboxes.coffee +0 -6
  42. data/app/views/ds_media_library/_folder.html.slim +0 -11
  43. data/app/views/ds_media_library/_form_helper.html.slim +0 -30
  44. data/app/views/ds_media_library/_image_preview.html.slim +0 -17
  45. data/app/views/ds_media_library/_resource.html.slim +0 -27
  46. data/app/views/ds_media_library/resources/_folder.html.slim +0 -14
  47. data/app/views/ds_media_library/resources/_resource.html.slim +0 -12
  48. data/app/views/ds_media_library/resources/index.html.slim +0 -28
data/dummy/views.rb CHANGED
@@ -21,68 +21,7 @@ end
21
21
  ApplicationController.prepend_view_path InMemoryResolver.new
22
22
 
23
23
  InMemoryResolver.store["layouts/test"] = <<-SLIM
24
- sass:
25
- .hidden
26
- display: none
27
-
28
- .media-nest
29
- display: none
30
-
31
- .expand-input:checked ~ .media-nest
32
- display: block
33
-
34
- .media-button, .flash-notice, .flash-alert
35
- text-transform: uppercase
36
-
37
- .modal-input
38
- opacity: 0.001
39
- &:checked ~ .modal-wrapper
40
- left: 0
41
- opacity: 1
42
- .modal-content
43
- display: inline-block
44
- .modal-bg
45
- background: white
46
- opacity: 1
47
-
48
- .modal-wrapper
49
- position: fixed
50
- display: -webkit-flex
51
- display: flex
52
- top: 0
53
- left: -100vw
54
- width: 100vw
55
- height: 100vh
56
- z-index: 9999
57
- text-align: left
58
-
59
- .modal-bg
60
- background: rgba(#808080, 0.85)
61
- opacity: 0
62
- position: absolute
63
- z-index: 2
64
- width: 100vw
65
- height: 100vh
66
- top: 0
67
- left: 0
68
-
69
- .modal-content
70
- display: none
71
- margin: auto 0
72
- width: 94vw
73
- height: 100vh
74
- padding: 40px
75
- z-index: 3
76
-
77
- .modal-close
78
- position: absolute
79
- top: -10px
80
- right: 40px
81
- margin: 0
82
- width: 40px
83
- height: 40px
84
- line-height: 40px
85
- text-align: center
24
+ = stylesheet_link_tag "ds_media_library"
86
25
 
87
26
  h1 TEST
88
27
 
@@ -102,13 +41,23 @@ SLIM
102
41
  InMemoryResolver.store["application/show"] = <<-SLIM
103
42
  = form_for @widget, url: "/" do |form|
104
43
  .field
105
- = form.label :cat_picture
106
- = form.media_library :cat_picture
44
+ = form.label :cat_picture, class: "dsml-label"
45
+ = form.media_library :cat_picture, optional: true
107
46
 
108
47
  .field
109
- = form.label :dog_pictures
48
+ = form.label :dog_pictures, class: "dsml-label"
110
49
  = form.media_library :dog_pictures, multiple: true
111
50
 
51
+ .field
52
+ = form.media_library :baby_picture do
53
+ = form.label :baby_name
54
+ = form.text_field :baby_name
55
+
56
+ .field
57
+ = form.media_library :embarassing_pictures, multiple: true, preview: false do
58
+ label for="resource_{{id}}_context" Embarassing picture {{index}} context
59
+ input type="text" id="resource_{{id}}_context" name="resources[{{id}}][context]" value="{{context}}"
60
+
112
61
  = form.submit "Save"
113
62
  SLIM
114
63
 
@@ -1,5 +1,7 @@
1
1
  require "ds_node"
2
2
  require "slim"
3
+ require "sass-rails"
4
+ require "font-awesome-rails"
3
5
  require "jquery-rails"
4
6
  require "jquery-ui-rails"
5
7
  require "coffee-rails"
@@ -17,13 +19,13 @@ module DSMediaLibrary
17
19
  belongs_to :folder, class_name: "DSMediaLibrary::Folder", required: false
18
20
 
19
21
  def css_class
20
- "media-link"
22
+ "dsml-media-link"
21
23
  end
22
24
  end
23
25
  end
24
26
 
25
27
  initializer "ds_media_library.assets" do
26
- config.assets.precompile += %w( ds_media_library.js )
28
+ config.assets.precompile += %w( ds_media_library.css ds_media_library.js )
27
29
  end
28
30
 
29
31
  isolate_namespace DSMediaLibrary
@@ -1,3 +1,3 @@
1
1
  module DSMediaLibrary
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,5 +1,4 @@
1
1
  require "ds_media_library/version"
2
- require "ds_media_library/form_helper"
3
2
  require "ds_media_library/engine"
4
3
 
5
4
  module DSMediaLibrary
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ds_media_library
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-25 00:00:00.000000000 Z
11
+ date: 2017-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -276,6 +276,20 @@ dependencies:
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
278
  version: '0'
279
+ - !ruby/object:Gem::Dependency
280
+ name: font-awesome-rails
281
+ requirement: !ruby/object:Gem::Requirement
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
286
+ type: :runtime
287
+ prerelease: false
288
+ version_requirements: !ruby/object:Gem::Requirement
289
+ requirements:
290
+ - - ">="
291
+ - !ruby/object:Gem::Version
292
+ version: '0'
279
293
  description: Downstream Media Library Rails Engine
280
294
  email:
281
295
  - micah@botandrose.com
@@ -283,6 +297,7 @@ executables: []
283
297
  extensions: []
284
298
  extra_rdoc_files: []
285
299
  files:
300
+ - ".DS_Store"
286
301
  - ".gitignore"
287
302
  - ".rspec"
288
303
  - ".ruby-gemset"
@@ -293,32 +308,42 @@ files:
293
308
  - README.md
294
309
  - Rakefile
295
310
  - app/assets/javascripts/ds_media_library.coffee
296
- - app/assets/javascripts/toggle_all_checkboxes.coffee
311
+ - app/assets/stylesheets/_breadcrumb-nav.sass
312
+ - app/assets/stylesheets/_help-text.sass
313
+ - app/assets/stylesheets/_media-tree.sass
314
+ - app/assets/stylesheets/_modal.sass
315
+ - app/assets/stylesheets/_placeholders.sass
316
+ - app/assets/stylesheets/_preview-media.sass
317
+ - app/assets/stylesheets/ds_media_library.sass
318
+ - app/assets/stylesheets/mixins/_buttons.sass
319
+ - app/assets/stylesheets/mixins/_icons.sass
320
+ - app/assets/stylesheets/mixins/_notification-text.sass
297
321
  - app/controllers/ds_media_library/folders_controller.rb
298
322
  - app/controllers/ds_media_library/resources_controller.rb
323
+ - app/helpers/ds_media_library/form_helper.rb
299
324
  - app/models/ds_media_library/folder.rb
300
- - app/views/ds_media_library/_folder.html.slim
301
- - app/views/ds_media_library/_form_helper.html.slim
302
- - app/views/ds_media_library/_image_preview.html.slim
303
- - app/views/ds_media_library/_resource.html.slim
304
- - app/views/ds_media_library/resources/_folder.html.slim
305
- - app/views/ds_media_library/resources/_resource.html.slim
306
- - app/views/ds_media_library/resources/folder_form.html.slim
307
- - app/views/ds_media_library/resources/form.html.slim
308
- - app/views/ds_media_library/resources/index.html.slim
309
- - app/views/shared/_image_preview.html.slim
310
- - app/views/shared/_submit.html.slim
325
+ - app/views/ds_media_library/form_helper/_folder.html.slim
326
+ - app/views/ds_media_library/form_helper/_media_library_helper.html.slim
327
+ - app/views/ds_media_library/form_helper/_resource.html.slim
328
+ - app/views/ds_media_library/form_helper/show.html.slim
329
+ - app/views/ds_media_library/manage/_submit.html.slim
330
+ - app/views/ds_media_library/manage/folders/_folder.html.slim
331
+ - app/views/ds_media_library/manage/folders/form.html.slim
332
+ - app/views/ds_media_library/manage/index.html.slim
333
+ - app/views/ds_media_library/manage/resources/_image_preview.html.slim
334
+ - app/views/ds_media_library/manage/resources/_resource.html.slim
335
+ - app/views/ds_media_library/manage/resources/form.html.slim
311
336
  - bin/console
312
337
  - bin/server
313
338
  - bin/setup
314
339
  - config/routes.rb
315
340
  - ds_media_library.gemspec
316
341
  - dummy/app.rb
342
+ - dummy/config.rb
317
343
  - dummy/database.rb
318
344
  - dummy/views.rb
319
345
  - lib/ds_media_library.rb
320
346
  - lib/ds_media_library/engine.rb
321
- - lib/ds_media_library/form_helper.rb
322
347
  - lib/ds_media_library/version.rb
323
348
  - tmp/.keep
324
349
  homepage: https://github.com/botandrose/ds_media_library
@@ -1,6 +0,0 @@
1
- $ ->
2
- $("[data-toggle-all-checkboxes]").click (event) ->
3
- event.preventDefault()
4
- $checkboxes = $(this.getAttribute("data-toggle-all-checkboxes"))
5
- $checkboxes.prop checked: !$checkboxes.is(":checked")
6
-
@@ -1,11 +0,0 @@
1
- li
2
- input.expand-input type="checkbox" id="#{helper.field}-folder-#{folder.id}"
3
- .media-container
4
- label.expand-label.folder-link for="#{helper.field}-folder-#{folder.id}" = folder.name
5
-
6
- - if folder.children.any? || folder.resources.any?
7
- ul.media-nest
8
- - with_options locals: { form: form, helper: helper } do |options|
9
- = options.render collection: folder.children, partial: "ds_media_library/folder", as: :folder
10
- = options.render collection: folder.resources, partial: "ds_media_library/resource", as: :resource
11
-
@@ -1,30 +0,0 @@
1
- .media-library data-media-library=helper.html_id data-media-library-ids=helper.ids required=helper.required
2
- = form.label helper.file_field_name, helper.label, class: helper.label_css_class
3
-
4
- - if helper.helptext
5
- .ratio-text = helper.helptext
6
-
7
- label.media-button for=helper.html_id Media library
8
- em or
9
- = form.file_field helper.file_field_name, multiple: helper.multiple
10
-
11
- input.modal-input type="checkbox" id=helper.html_id
12
- .modal-wrapper
13
- .modal-bg
14
- .modal-content
15
- label.modal-close for=helper.html_id
16
- .borders
17
- .media-wrapper
18
- .info-text Choose a media file below to associate with this field. You can manage media in the <a href="/media_library">Media Library</a>. <br />Note that changing a file in the library will update it across all associated media fields in this app.
19
-
20
- = link_to "Open all folders", "#", class: "open-all-label", data: { "toggle-all-checkboxes" => ".expand-input" }
21
-
22
- input.text#search_media type="text" placeholder="Type keywords to search media (case sensitive)"
23
-
24
- ul.media-nav
25
- - with_options locals: { form: form, helper: helper } do |options|
26
- = options.render collection: helper.root_folders, partial: "ds_media_library/folder", as: :folder
27
- = options.render collection: helper.root_resources, partial: "ds_media_library/resource", as: :resource
28
-
29
- dl.playlist-media id="selected_media_#{helper.html_id}"
30
-
@@ -1,17 +0,0 @@
1
- - if !defined?(preview) then preview = true
2
-
3
- - if image.present?
4
- dfn.preview-form
5
- .preview-wrapper
6
- - if preview
7
- - if image.video?
8
- = video_tag image.url, controls: true
9
- - else
10
- = image_tag image.url
11
-
12
- = yield
13
-
14
- - unless defined?(hide_file_name) && hide_file_name
15
- dt
16
- figcaption = image.original_file_name
17
-
@@ -1,27 +0,0 @@
1
- li.resource class=("hidden" if resource.hidden?)
2
- .media-container
3
- label.expand-label
4
- - if helper.multiple
5
- input.modal-input.media-choice type="checkbox" value=resource.id checked=form.object.send(helper.field_id_name).include?(resource.id)
6
- - else
7
- = form.radio_button helper.field_id_name, resource.id, class: "modal-input media-choice"
8
-
9
- span.media-link alt=resource.original_file_name
10
- = resource.original_file_name
11
-
12
- script.media-preview-template type="text/x-html-template"
13
- = render "ds_media_library/image_preview", image: resource, preview: helper.preview do
14
- - if helper.multiple
15
- = form.check_box helper.field_id_name, { multiple: true, checked: true }, resource.id, nil
16
- = form.check_box helper.remove_field_name, { multiple: true }, resource.id, nil
17
- = form.label :"#{helper.remove_field_name}_#{resource.id}" do
18
- span Remove #{helper.label.downcase.singularize} {{index}}
19
-
20
- - else
21
- - if helper.optional
22
- = form.check_box helper.remove_field_name
23
- = form.label helper.remove_field_name do
24
- span Remove #{helper.label.downcase}
25
-
26
- - helper.block.call(resource) if helper.block
27
-
@@ -1,14 +0,0 @@
1
- li
2
- input type="checkbox" class="expand-input" id="folder-#{folder.id}"
3
- .media-container
4
- label.expand-label.folder-link for="folder-#{folder.id}" = folder.name
5
- .media-links
6
- = link_to "Edit folder", [:edit, folder], class: "edit-icon", title: "Edit folder"
7
- = link_to "Delete folder", folder, method: :delete, class: "delete-icon", title: "Delete folder",
8
- data: { confirm: "Are you sure you want to delete this folder? This will move any folders and resources it may contain up into its parent folder." }
9
-
10
- - if folder.children.any? || folder.resources.any?
11
- ul.media-nest
12
- = render collection: folder.children, partial: "ds_media_library/resources/folder"
13
- = render collection: folder.resources, partial: "ds_media_library/resources/resource"
14
-
@@ -1,12 +0,0 @@
1
- li.resource class=("hidden" if resource.hidden?)
2
- .media-container
3
- input.move-input type="checkbox" name="resource_ids[]" id="media-#{resource.id}" value=resource.id
4
- label.expand-label for="media-#{resource.id}"
5
- = link_to resource.original_file_name, edit_resource_path(resource), class: resource.css_class, alt: resource.original_file_name
6
- / span.move-span.media-link alt=resource.original_file_name = resource.original_file_name
7
-
8
- .media-links
9
- = link_to "Edit media", edit_resource_path(resource), class: "edit-icon", title: "Edit media"
10
- = link_to "Delete media", resource_path(resource), method: :delete, class: "delete-icon", title: "Delete media",
11
- data: { confirm: "Are you sure you want to delete this media item? Note that this will just remove it from the media library." }
12
-
@@ -1,28 +0,0 @@
1
- = content_for :breadcrumbs do
2
- ul.breadcrumb-nav
3
- li Media Library
4
-
5
- = form_tag nil, method: :put do
6
- input type="checkbox" id="select-media"
7
- .table-buttons-flex
8
- .buttons-left
9
- = link_to "Open all folders", "#", class: "open-all-label", data: { "toggle-all-checkboxes" => ".expand-input" }
10
- label.select-media-button for="select-media" Select multiple media
11
- .field.move-selected
12
- label.move-selected-label for="folder_id" Move selected to:
13
- select#folder_id name="folder_id"
14
- - folders.each do |folder|
15
- option value=folder.id
16
- = "- " * folder.depth
17
- = folder.name
18
- button.move-button Move
19
-
20
- .buttons-right
21
- = link_to "Add new folder", [:new, :folder], class: "add-button"
22
- = link_to "Add new media", [:new, :resource], class: "add-button"
23
-
24
- input.text#search_media type="text" placeholder="Type keywords to search media (case sensitive)"
25
- ul.media-nav
26
- = render collection: root.children, partial: "ds_media_library/resources/folder"
27
- = render collection: root.resources, partial: "ds_media_library/resources/resource"
28
-