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
@@ -0,0 +1,57 @@
1
+ =dsml-button( $bg: $primaryColor, $text-color: #fcfcfc, $font-size: 1.2em, $hover: true, $fa: false )
2
+ display: inline-block
3
+ font-size: $font-size
4
+ font-weight: 700
5
+ line-height: 3.0em
6
+ color: $text-color
7
+ border: 1px solid darken( $bg, 6% )
8
+ background-color: $bg
9
+ background: linear-gradient( $bg, darken( $bg, 5% ) )
10
+ border-radius: 2px
11
+ padding: 0 15px
12
+ cursor: pointer
13
+ text-align: center
14
+ text-decoration: none
15
+ margin: 0px
16
+ cursor: default
17
+ text-transform: uppercase
18
+ @if $hover
19
+ cursor: pointer
20
+ &:hover
21
+ background: darken( $bg, 4% )
22
+ box-shadow: darken( $bg, 10% ) 0 0 5px 0 inset
23
+ color: lighten( $text-color, 6% )
24
+ @if $fa
25
+ @extend .fa-#{$fa}
26
+ &:before
27
+ @extend .fa
28
+ margin-right: 10px
29
+
30
+ // input wrapper buttons
31
+
32
+ =dsml-input-button($bg: $primaryColor, $text-color: #fcfcfc, $fa: false, $size: 1.2em, $fa-size: 1.2em)
33
+ +dsml-button($bg, $text-color)
34
+ padding: 0
35
+ line-height: 1
36
+ input, button
37
+ font-size: $size
38
+ border: none
39
+ background: none
40
+ padding: 0 20px
41
+ line-height: 3.0em
42
+ cursor: pointer
43
+ color: $text-color
44
+ font-weight: 700
45
+ text-transform: uppercase
46
+ @if $fa
47
+ @extend .fa
48
+ @extend .fa-#{$fa}
49
+ input, button
50
+ padding-left: 45px
51
+ &:before
52
+ @extend .fa
53
+ position: absolute
54
+ top: 50%
55
+ margin-top: -0.5em
56
+ left: 20px
57
+ font-size: $fa-size
@@ -0,0 +1,36 @@
1
+ // Icons with hidden text
2
+
3
+ =dsml-icon($fa, $size: 1.4em)
4
+ display: inline-block
5
+ margin: 0 6px
6
+ text-align: left
7
+ position: relative
8
+ font-size: $size
9
+ width: 1em
10
+ text-indent: -9999px
11
+ color: #4f4f4f
12
+ @extend .fa
13
+ @extend .fa-#{$fa}
14
+ &:before
15
+ text-indent: 0
16
+ position: absolute
17
+ top: 50%
18
+ right: 50%
19
+ margin: -0.5em -0.5em 0 0
20
+ z-index: 2
21
+ &:hover
22
+ &:before
23
+ color: $primaryColor
24
+
25
+
26
+ // Icons with text
27
+
28
+ =dsml-icon_text($fa, $font-size: 1.3em)
29
+ display: inline-block
30
+ margin: 0 20px 0 0
31
+ @extend .fa-#{$fa}
32
+ font-size: $font-size
33
+ &:before
34
+ margin-right: 4px
35
+ @extend .fa
36
+
@@ -0,0 +1,23 @@
1
+ =notification-text( $color, $fa )
2
+ margin: 10px 0
3
+ position: relative
4
+ clear: both
5
+ padding: 10px 10px 10px 40px
6
+ border: 1px dashed $color
7
+ color: $color
8
+ font-size: 1.3em
9
+ font-style: italic
10
+ line-height: 1.4em
11
+ border-radius: 2px
12
+ @extend .fa-#{$fa}
13
+ &:before
14
+ @extend .fa
15
+ font-size: 1.8em
16
+ position: absolute
17
+ left: 10px
18
+ top: 50%
19
+ margin-top: -0.5em
20
+ ul
21
+ font-size: 1em
22
+ list-style: inside circle
23
+
@@ -2,9 +2,14 @@ module DSMediaLibrary
2
2
  class FoldersController < ApplicationController
3
3
  expose :folder
4
4
 
5
+ def index
6
+ helper = FormHelper::MediaLibrary.from_params(params)
7
+ render "ds_media_library/form_helper/show", locals: { helper: helper}, layout: false
8
+ end
9
+
5
10
  def new
6
11
  @folder = DSMediaLibrary::Folder.new
7
- render "ds_media_library/resources/folder_form"
12
+ render "ds_media_library/manage/folders/form"
8
13
  end
9
14
 
10
15
  def create
@@ -14,7 +19,7 @@ module DSMediaLibrary
14
19
 
15
20
  def edit
16
21
  @folder = DSMediaLibrary::Folder.find(params[:id])
17
- render "ds_media_library/resources/folder_form"
22
+ render "ds_media_library/manage/folders/form"
18
23
  end
19
24
 
20
25
  def update
@@ -5,11 +5,12 @@ module DSMediaLibrary
5
5
  def index
6
6
  @root = DSMediaLibrary::Folder.root
7
7
  @folders = folders_with_children
8
+ render "ds_media_library/manage/index"
8
9
  end
9
10
 
10
11
  def new
11
12
  @resource = DSNode::Resource.new
12
- render :form
13
+ render "ds_media_library/manage/resources/form"
13
14
  end
14
15
 
15
16
  def create
@@ -20,7 +21,7 @@ module DSMediaLibrary
20
21
  end
21
22
 
22
23
  def edit
23
- render :form
24
+ render "ds_media_library/manage/resources/form"
24
25
  end
25
26
 
26
27
  def update
@@ -3,13 +3,28 @@ require "active_support/number_helper"
3
3
  module DSMediaLibrary
4
4
  module FormHelper
5
5
  def media_library field, label: field.to_s.humanize, multiple: false, optional: false, dimensions: nil, helptext: nil, preview: true, required: false, &block
6
- helper = MediaLibrary.new(object.send(field), field, label, multiple, optional, dimensions, helptext, preview, required, block)
7
- @template.render "ds_media_library/form_helper", form: self, helper: helper
6
+ selected_ids = Array(object.send(field)).map(&:id)
7
+ helper = MediaLibrary.new(selected_ids, field, label, multiple, optional, dimensions, helptext, preview, required)
8
+ @template.render "ds_media_library/form_helper/media_library_helper", form: self, helper: helper, &block
8
9
  end
9
10
 
10
- class MediaLibrary < Struct.new(:object, :field, :label, :multiple, :optional, :dimensions, :helptext, :preview, :required, :block)
11
- def ids
12
- Array(object).map(&:id)
11
+ class MediaLibrary < Struct.new(:ids, :field, :label, :multiple, :optional, :dimensions, :helptext, :preview, :required)
12
+ def self.from_params params
13
+ new(
14
+ Array(params[:ids] || []).map(&:to_i),
15
+ params[:field],
16
+ params[:label],
17
+ params[:multiple] == "true",
18
+ params[:optional] == "true",
19
+ params[:dimensions],
20
+ params[:helptext],
21
+ params[:preview] == "true",
22
+ params[:required] == "true",
23
+ )
24
+ end
25
+
26
+ def selected_resources
27
+ DSNode::Resource.find(ids)
13
28
  end
14
29
 
15
30
  def single_field
@@ -24,14 +39,6 @@ module DSMediaLibrary
24
39
  end
25
40
  end
26
41
 
27
- def remove_field_name
28
- if multiple
29
- :"remove_#{single_field}_ids"
30
- else
31
- :"remove_#{field}"
32
- end
33
- end
34
-
35
42
  def field_id_name
36
43
  if multiple
37
44
  :"#{single_field}_ids"
@@ -40,6 +47,10 @@ module DSMediaLibrary
40
47
  end
41
48
  end
42
49
 
50
+ def field_type
51
+ multiple ? "checkbox" : "radio"
52
+ end
53
+
43
54
  def html_id
44
55
  "media-modal-#{field}"
45
56
  end
@@ -72,10 +83,6 @@ module DSMediaLibrary
72
83
  root.resources
73
84
  end
74
85
 
75
- def original_file_name
76
- object.original_file_name if object.present?
77
- end
78
-
79
86
  private
80
87
 
81
88
  def number_with_delimiter number
@@ -0,0 +1,10 @@
1
+ li
2
+ input.dsml-expand-input type="checkbox" id="#{helper.field}-folder-#{folder.id}"
3
+ .dsml-media-container
4
+ label.dsml-expand-label.dsml-folder-link for="#{helper.field}-folder-#{folder.id}" = folder.name
5
+
6
+ - if folder.children.any? || folder.resources.any?
7
+ ul.dsml-media-nest
8
+ = render collection: folder.children, partial: "ds_media_library/form_helper/folder", as: :folder, locals: { helper: helper }
9
+ = render collection: folder.resources, partial: "ds_media_library/form_helper/resource", as: :resource, locals: { helper: helper }
10
+
@@ -0,0 +1,46 @@
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.dsml-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.dsml-modal-input type="checkbox" id=helper.html_id
12
+ .dsml-modal-wrapper
13
+ .dsml-modal-bg
14
+ .dsml-modal-content
15
+ label.dsml-modal-close for=helper.html_id
16
+ .borders
17
+ .media-wrapper data-load-url=ds_media_library.folders_path(helper.to_h)
18
+ p Loading...
19
+ - helper.selected_resources.each do |resource|
20
+ input.hidden name="ds_media_library" type="checkbox" value=resource.id checked=true data=resource.attributes
21
+
22
+ dl.dsml-playlist-media id="dsml-selected-media-#{helper.html_id}"
23
+
24
+ script#dsml-media-preview-template type="text/x-html-template"
25
+ dfn.dsml-preview-form
26
+ .dsml-preview-wrapper
27
+ - if helper.preview
28
+ | <{{type}} src="{{url}}" controls=true />
29
+
30
+ - if helper.multiple
31
+ = form.check_box helper.field_id_name, { multiple: true, checked: true, id: "#{helper.field_id_name}_{{id}}" }, "{{id}}", nil
32
+ label for="#{helper.field_id_name}_{{id}}"
33
+ span Remove #{helper.label.downcase.singularize} {{index}}
34
+
35
+ - else
36
+ = form.check_box helper.field_id_name, { checked: true }, "{{id}}", ""
37
+ - if helper.optional
38
+ = form.label helper.field_id_name do
39
+ span Remove #{helper.label.downcase}
40
+
41
+ = yield if block_given?
42
+
43
+ dt
44
+ figcaption
45
+ | {{resourcesoriginalfilename}}
46
+
@@ -0,0 +1,6 @@
1
+ li.dsml-resource class=("hidden" if resource.hidden?)
2
+ .dsml-media-container
3
+ label.dsml-expand-label
4
+ input.dsml-modal-input.media-choice name="ds_media_library" type=helper.field_type value=resource.id checked=helper.ids.include?(resource.id) data=resource.attributes
5
+ span.dsml-media-link alt=resource.original_file_name = resource.original_file_name
6
+
@@ -0,0 +1,10 @@
1
+ .dsml-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.
2
+
3
+ = link_to "Open all folders", "#", class: "dsml-open-all-label", data: { "dsml-toggle-all-checkboxes" => ".dsml-expand-input" }
4
+
5
+ label.hidden for="dsml-search-media" Search media library
6
+ input.dsml-text#dsml-search-media type="text" placeholder="Type keywords to search media" data-dsml-search-media=".dsml-resource"
7
+ ul.dsml-media-nav#dsml-media-tree
8
+ = render collection: helper.root_folders, partial: "ds_media_library/form_helper/folder", as: :folder, locals: { helper: helper }
9
+ = render collection: helper.root_resources, partial: "ds_media_library/form_helper/resource", as: :resource, locals: { helper: helper }
10
+
@@ -0,0 +1,14 @@
1
+ li.dsml-folder
2
+ input type="checkbox" class="dsml-expand-input" id="folder-#{folder.id}"
3
+ .dsml-media-container
4
+ label.dsml-expand-label.dsml-folder-link for="folder-#{folder.id}" = folder.name
5
+ .dsml-media-links
6
+ = link_to "Edit folder", [:edit, folder], class: "dsml-edit-icon", title: "Edit folder"
7
+ = link_to "Delete folder", folder, method: :delete, class: "dsml-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.dsml-media-nest
12
+ = render collection: folder.children, partial: "ds_media_library/manage/folders/folder"
13
+ = render collection: folder.resources, partial: "ds_media_library/manage/resources/resource"
14
+
@@ -1,5 +1,5 @@
1
1
  = content_for :breadcrumbs do
2
- ul.breadcrumb-nav
2
+ ul.dsml-breadcrumb-nav
3
3
  li = link_to "Media Library", :root
4
4
  li
5
5
  = folder.new_record? ? "New" : "Edit"
@@ -9,11 +9,11 @@
9
9
  = form_for folder do |form|
10
10
  fieldset
11
11
  .field
12
- = form.label :parent_id, "Parent folder", class: "optional"
12
+ = form.label :parent_id, "Parent folder", class: "dsml-optional"
13
13
  = form.collection_select :parent_id, form.object.all_folders, :id, :name, include_blank: " -- none -- "
14
14
  .field
15
15
  = form.label :name, "Folder name"
16
- = form.text_field :name, class: "name-input"
16
+ = form.text_field :name, class: "dsml-name-input"
17
17
 
18
- = render "shared/submit", name: "folder"
18
+ = render "ds_media_library/manage/submit", name: "folder"
19
19
 
@@ -0,0 +1,30 @@
1
+ .dsml
2
+ = content_for :breadcrumbs do
3
+ ul.dsml-breadcrumb-nav
4
+ li Media Library
5
+
6
+ = form_tag nil, method: :put do
7
+ input type="checkbox" id="dsml-select-media"
8
+ .dsml-table-buttons-flex
9
+ .dsml-buttons-left
10
+ = link_to "Open all folders", "#", class: "dsml-open-all-label", data: { "dsml-toggle-all-checkboxes" => ".dsml-expand-input" }
11
+ label.dsml-select-media-button for="dsml-select-media" Select multiple media
12
+ .field.dsml-move-selected
13
+ label.dsml-move-selected-label for="dsml-folder-id" Move selected to:
14
+ select#dsml-folder-id name="folder_id"
15
+ - folders.each do |folder|
16
+ option value=folder.id
17
+ = "- " * folder.depth
18
+ = folder.name
19
+ button.dsml-move-button Move
20
+
21
+ .dsml-buttons-right
22
+ = link_to "Add new folder", [:new, :folder], class: "dsml-add-button"
23
+ = link_to "Add new media", [:new, :resource], class: "dsml-add-button"
24
+
25
+ label.hidden for="dsml-search-media" Search media library
26
+ input.dsml-text#dsml-search-media type="text" placeholder="Type keywords to search media" data-dsml-search-media=".dsml-resource"
27
+ ul.dsml-media-nav#dsml-media-tree
28
+ = render collection: root.children, partial: "ds_media_library/manage/folders/folder"
29
+ = render collection: root.resources, partial: "ds_media_library/manage/resources/resource"
30
+
@@ -1,8 +1,8 @@
1
1
  - if !defined?(preview) then preview = true
2
2
 
3
3
  - if image.present?
4
- dfn.preview-form
5
- .preview-wrapper
4
+ dfn.dsml-preview-form
5
+ .dsml-preview-wrapper
6
6
  - if preview
7
7
  - if image.video?
8
8
  = video_tag image.url, controls: true
@@ -0,0 +1,12 @@
1
+ li.dsml-resource class=("hidden" if resource.hidden?)
2
+ .dsml-media-container
3
+ input.dsml-move-input type="checkbox" name="resource_ids[]" id="media-#{resource.id}" value=resource.id
4
+ label.dsml-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.dsml-move-span.dsml-media-link alt=resource.original_file_name = resource.original_file_name
7
+
8
+ .dsml-media-links
9
+ = link_to "Edit media", edit_resource_path(resource), class: "dsml-edit-icon", title: "Edit media"
10
+ = link_to "Delete media", resource_path(resource), method: :delete, class: "dsml-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,5 +1,5 @@
1
1
  = content_for :breadcrumbs do
2
- ul.breadcrumb-nav
2
+ ul.dsml-breadcrumb-nav
3
3
  li = link_to "Media Library", :root
4
4
  li
5
5
  = resource.new_record? ? "New" : "Edit"
@@ -25,7 +25,7 @@
25
25
  = form.label :file, "Upload media"
26
26
  = form.file_field :file, multiple: resource.new_record?
27
27
  - unless form.object.new_record?
28
- = render "shared/image_preview", image: form.object
28
+ = render "ds_media_library/manage/resources/image_preview", image: form.object
29
29
 
30
- = render "shared/submit", name: "media"
30
+ = render "ds_media_library/manage/submit", name: "media"
31
31
 
data/bin/server CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "rack"
3
3
  require_relative "../dummy/app"
4
- Rack::Server.start(app: Dummy::App)
4
+ Rack::Server.start(app: Dummy::App, Host: "0.0.0.0", Port: 3000)
5
5
 
data/bin/setup CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env bash
2
2
  set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
3
+ gem install bundler --conservative
5
4
  bundle check || bundle install
@@ -41,4 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_dependency "coffee-rails"
42
42
  spec.add_dependency "jquery-rails"
43
43
  spec.add_dependency "jquery-ui-rails"
44
+ spec.add_dependency "font-awesome-rails"
44
45
  end
data/dummy/app.rb CHANGED
@@ -1,53 +1,6 @@
1
1
  require 'bundler/setup'
2
2
  require "rails/all"
3
3
  require "ds_media_library"
4
-
5
- module Dummy; end
6
-
7
- class Dummy::App < Rails::Application
8
- config.secret_key_base = "test"
9
- config.eager_load = false
10
- config.logger = Logger.new("/dev/stdout")
11
- config.logger = Logger.new("/dev/null")
12
- end
13
-
14
- ENV["DATABASE_URL"] = "sqlite3:tmp/test.sqlite3"
15
-
16
- Dummy::App.initialize!
17
-
18
- class ApplicationController < ActionController::Base
19
- def self.expose *methods
20
- methods.each do |method|
21
- attr_reader method
22
- helper_method method
23
- end
24
- end
25
-
26
- layout "test"
27
-
28
- def show
29
- @widget = Widget.first_or_create!
30
- end
31
-
32
- def update
33
- Widget.first_or_create!.update! params.require(:widget).permit!
34
- redirect_to "/", notice: "Widget updated"
35
- end
36
- end
37
-
38
- Dummy::App.routes.draw do
39
- mount DSMediaLibrary::Engine => "/media_library"
40
- root to: "application#show"
41
- patch "/" => "application#update"
42
- end
43
-
44
- # app's soft delete leaves files in place, so clean them up
45
- at_exit do
46
- begin
47
- Rails.public_path.rmtree
48
- rescue Errno::ENOENT
49
- end
50
- end
51
-
4
+ require_relative "./config"
52
5
  require_relative "./database"
53
6
  require_relative "./views"
data/dummy/config.rb ADDED
@@ -0,0 +1,55 @@
1
+ module Dummy; end
2
+
3
+ class Dummy::App < Rails::Application
4
+ config.secret_key_base = "test"
5
+ config.eager_load = false
6
+ config.logger = Logger.new("/dev/stdout")
7
+
8
+ initializer "log level" do
9
+ Rails.logger.level = Logger::WARN
10
+ end
11
+ end
12
+
13
+ ENV["DATABASE_URL"] = "sqlite3:tmp/test.sqlite3"
14
+
15
+ Dummy::App.initialize!
16
+
17
+ class ApplicationController < ActionController::Base
18
+ def self.expose *methods
19
+ methods.each do |method|
20
+ attr_reader method
21
+ helper_method method
22
+ end
23
+ end
24
+
25
+ layout "test"
26
+
27
+ def show
28
+ @widget = Widget.first_or_create!
29
+ end
30
+
31
+ def update
32
+ widget = Widget.first_or_create!
33
+ widget_params = params.require(:widget).permit!
34
+ widget.update! widget_params
35
+
36
+ DSNode::Resource.update(params[:resources].keys, params[:resources].values) if params[:resources]
37
+
38
+ redirect_to "/", notice: "Widget updated"
39
+ end
40
+ end
41
+
42
+ Dummy::App.routes.draw do
43
+ mount DSMediaLibrary::Engine => "/media_library"
44
+ root to: "application#show"
45
+ patch "/" => "application#update"
46
+ end
47
+
48
+ # app's soft delete leaves files in place, so clean them up
49
+ at_exit do
50
+ begin
51
+ Rails.public_path.rmtree
52
+ rescue Errno::ENOENT
53
+ end
54
+ end
55
+
data/dummy/database.rb CHANGED
@@ -13,6 +13,9 @@ ActiveRecord::Migration.suppress_messages do
13
13
  create_table "widgets", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
14
14
  t.integer "cat_picture_id"
15
15
  t.string "dog_picture_ids"
16
+ t.string "baby_picture_id"
17
+ t.string "baby_name"
18
+ t.string "embarassing_picture_ids"
16
19
  end
17
20
 
18
21
  create_table "folders", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
@@ -44,6 +47,7 @@ ActiveRecord::Migration.suppress_messages do
44
47
  t.datetime "updated_at", null: false
45
48
  t.integer "folder_id"
46
49
  t.boolean "hidden", default: false
50
+ t.string "context"
47
51
  end
48
52
  end
49
53
  end
@@ -51,5 +55,7 @@ end
51
55
  class Widget < ActiveRecord::Base
52
56
  ds_resource :cat_picture
53
57
  belongs_to_many_ds_resources :dog_pictures
58
+ ds_resource :baby_picture
59
+ belongs_to_many_ds_resources :embarassing_pictures
54
60
  end
55
61