oxen_media 0.0.6 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/components/dropzone.js.jsx.coffee +298 -0
  3. data/app/assets/javascripts/components/photocard.js.jsx.coffee +77 -0
  4. data/app/assets/javascripts/components/photos.js.jsx.coffee +68 -0
  5. data/app/assets/javascripts/oxen_media.js +1 -3
  6. data/app/assets/stylesheets/oxen_media/drop_zone.css +86 -0
  7. data/app/assets/stylesheets/oxen_media.css +3 -0
  8. data/app/controllers/photos_controller.rb +26 -0
  9. data/app/models/ox_photo.rb +17 -0
  10. data/app/policies/ox_photo_policy.rb +3 -0
  11. data/app/uploaders/photo_uploader.rb +53 -0
  12. data/app/views/photos/_photo.html.haml +11 -0
  13. data/app/views/photos/create.js.haml +1 -0
  14. data/app/views/photos/index.json.jbuilder +5 -0
  15. data/lib/oxen_media/version.rb +1 -1
  16. data/lib/oxen_media.rb +1 -1
  17. data/oxen_media.gemspec +4 -4
  18. metadata +15 -86
  19. data/app/assets/javascripts/jsrender.min.js +0 -4
  20. data/app/assets/javascripts/jsrender.min.js.map +0 -463
  21. data/app/assets/javascripts/oxen_media/carrier_wave_cropper.js.coffee +0 -22
  22. data/app/assets/javascripts/oxen_media/media.js.coffee +0 -469
  23. data/app/assets/javascripts/oxen_media/medium_pane.js.coffee +0 -107
  24. data/app/assets/javascripts/templates/selected_files.html +0 -35
  25. data/app/assets/stylesheets/media.css +0 -10
  26. data/app/assets/stylesheets/scaffold.css +0 -56
  27. data/app/controllers/media_controller.rb +0 -106
  28. data/app/helpers/media_helper.rb +0 -2
  29. data/app/models/medium.rb +0 -25
  30. data/app/policies/oxen_medium_policy.rb +0 -12
  31. data/app/uploaders/medium_uploader.rb +0 -153
  32. data/app/views/media/_fields.html.haml +0 -42
  33. data/app/views/media/_form.html.haml +0 -48
  34. data/app/views/media/_media.html.haml +0 -18
  35. data/app/views/media/_medium.html.haml +0 -25
  36. data/app/views/media/_medium_fields.html.haml +0 -4
  37. data/app/views/media/create.js.haml +0 -2
  38. data/app/views/media/crop.html.haml +0 -3
  39. data/app/views/media/edit.html.haml +0 -2
  40. data/app/views/media/index.html.haml +0 -29
  41. data/app/views/media/index.json.jbuilder +0 -4
  42. data/app/views/media/new.html.erb +0 -5
  43. data/app/views/media/show.html.haml +0 -21
  44. data/app/views/media/show.json.jbuilder +0 -1
  45. data/app/views/media/update_crop.js.haml +0 -1
  46. /data/app/assets/javascripts/{oxen_media/.keep → components/.gitkeep} +0 -0
@@ -1,106 +0,0 @@
1
- class MediaController < AbstractResourcesController
2
-
3
- def update_crop
4
- authorize resource
5
- result = resource.new_record? ? resource.save(resource_params) : resource.update_attributes(resource_params)
6
- render layout: false
7
- end
8
-
9
- def crop
10
- authorize resource
11
- render layout: false
12
- end
13
- #
14
- # def index
15
- # authorize Medium
16
- # render :json => resources.collect { |p| p.to_jq_upload }.to_json
17
- # end
18
- #
19
- # def create
20
- # authorize Medium
21
- # p_attr = resource_params #params[:media]
22
- # p_attr[:media] = p_attr[:media].first if p_attr[:media].class == Array
23
- #
24
- # @resource = Medium.new(p_attr)
25
- # if @resource.save
26
- # respond_to do |format|
27
- # format.html {
28
- # render :json => [@resource.to_jq_upload].to_json,
29
- # :content_type => 'text/html',
30
- # :layout => false
31
- # }
32
- # format.json {
33
- # render :json => { :files => [@resource.to_jq_upload] }
34
- # }
35
- # end
36
- # else
37
- # render :json => [{:error => "custom_failure"}], :status => 304
38
- # end
39
- # end
40
- #
41
- # def destroy
42
- # authorize Medium
43
- # @resource = Medium.find(params[:id])
44
- # @resource.destroy
45
- # render :json => true
46
- # end
47
- #
48
- #
49
-
50
- # before_action :set_medium, only: [:show, :edit, :update, :destroy]
51
- #
52
- # # GET /media
53
- # def index
54
- # @media = Medium.all
55
- # end
56
- #
57
- # # GET /media/1
58
- # def show
59
- # end
60
- #
61
- # # GET /media/new
62
- # def new
63
- # @medium = Medium.new
64
- # end
65
- #
66
- # # GET /media/1/edit
67
- # def edit
68
- # end
69
- #
70
- # # POST /media
71
- # def create
72
- # @medium = Medium.new(medium_params)
73
- #
74
- # if @medium.save
75
- # redirect_to @medium, notice: 'Medium was successfully created.'
76
- # else
77
- # render :new
78
- # end
79
- # end
80
- #
81
- # # PATCH/PUT /media/1
82
- # def update
83
- # if @medium.update(medium_params)
84
- # redirect_to @medium, notice: 'Medium was successfully updated.'
85
- # else
86
- # render :edit
87
- # end
88
- # end
89
- #
90
- # # DELETE /media/1
91
- # def destroy
92
- # @medium.destroy
93
- # redirect_to media_url, notice: 'Medium was successfully destroyed.'
94
- # end
95
-
96
- private
97
- # Use callbacks to share common setup or constraints between actions.
98
- # def set_medium
99
- # @medium = Medium.find(params[:id])
100
- # end
101
-
102
- # Only allow a trusted parameter "white list" through.
103
- def resource_params
104
- params.require(:medium).permit(:title, :imageable_id, :imageable_type, :medium, :medium_crop_w, :medium_crop_h, :medium_crop_y, :medium_crop_x, :lng_lat, :description)
105
- end
106
- end
@@ -1,2 +0,0 @@
1
- module MediaHelper
2
- end
data/app/models/medium.rb DELETED
@@ -1,25 +0,0 @@
1
- class Medium < AbstractResource
2
- belongs_to :imageable, polymorphic: true
3
- belongs_to :account
4
-
5
- mount_uploader :medium, MediumUploader
6
- crop_uploaded :medium
7
- #
8
- # # attr_accessible :upload
9
- # # has_attached_file :upload
10
- # #
11
- include Rails.application.routes.url_helpers
12
-
13
- def to_jq_upload
14
- {
15
- "name" => self.medium.filename,
16
- "size" => self.medium.size,
17
- "url" => self.medium.url,
18
- "thumbnailUrl" => self.medium.url,
19
- "deleteUrl" => media_url(self, host: 'localhost:3000').gsub( '.','/'),
20
- "deleteType" => "DELETE"
21
- # "error": "Filetype not allowed"
22
- }
23
- end
24
-
25
- end
@@ -1,12 +0,0 @@
1
- class OxenMediumPolicy < AbstractResourcePolicy
2
-
3
- def crop?
4
- # @current_user.admin?
5
- true
6
- end
7
-
8
- def update_crop?
9
- true
10
- end
11
-
12
- end
@@ -1,153 +0,0 @@
1
- # encoding: utf-8
2
- require 'carrierwave/processing/mime_types'
3
- require 'carrierwave/crop'
4
- require 'carrierwave'
5
-
6
- class MediumUploader < CarrierWave::Uploader::Base
7
-
8
- # Include RMagick or MiniMagick support:
9
- # include CarrierWave::RMagick
10
- # include CarrierWave::MiniMagick
11
- include CarrierWave::MiniMagick
12
- include CarrierWave::MimeTypes
13
- include CarrierWave::Crop::Uploader
14
- # include CarrierWave::Processing::MiniMagick
15
-
16
- process :set_content_type
17
- process crop: :medium, if: :is_image?
18
-
19
- version :thumb do
20
- process resize_to_fill: [200, 150], if: :is_image?
21
-
22
- # if self.is_pdf?
23
- # asset_path "2.jpg"
24
- # elsif is_doc?
25
- # asset_path "2.jpg"
26
- # else
27
- # asset_path "1.JPG"
28
- # end
29
- end
30
-
31
- # process resize_to_limit: [400, 400]
32
- # process :strip # strip image of all profiles and comments
33
- # process :resize_to_fill => [200, 200]
34
- # process :quality => 90 # Set JPEG/MIFF/PNG compression level (0-100)
35
- # # process :convert => 'png'
36
- # process :colorspace => :rgb # Set colorspace to rgb or cmyk
37
- # process :blur => [0, 8] #reduce image noise and reduce detail levels [radius,sigma]
38
-
39
- def _url version
40
- case content_type
41
- when /docx?|document$/; "1.JPG"
42
- when /pdf$/; "2.jpg"
43
- when /^image/; url
44
- else default_url
45
- end
46
- end
47
-
48
-
49
- # if Rails.env.production?
50
- # storage :fog
51
- # else
52
- storage :file
53
- # end
54
-
55
- # Override the directory where uploaded files will be stored.
56
- # This is a sensible default for uploaders that are meant to be mounted:
57
- def store_dir
58
- "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
59
- end
60
-
61
- # Provide a default URL as a default if there hasn't been a file uploaded:
62
- def default_url
63
- # For Rails 3.1+ asset pipeline compatibility:
64
- ActionController::Base.helpers.asset_path("" + [version_name, "default.jpg"].compact.join('_'))
65
-
66
- # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
67
- end
68
-
69
-
70
- resize_to_limit(1024, 768)
71
-
72
-
73
- # Process files as they are uploaded:
74
- # process :scale => [200, 300]
75
- #
76
- # def scale(width, height)
77
- # # do something
78
- # end
79
-
80
-
81
- # Add a white list of extensions which are allowed to be uploaded.
82
- # For images you might use something like this:
83
- def extension_white_list
84
- %w(jpg jpeg gif png)
85
- end
86
-
87
- # Override the filename of the uploaded files:
88
- # Avoid using model.id or version_name here, see uploader/store.rb for details.
89
- # def filename
90
- # "something.jpg" if original_filename
91
- # end
92
-
93
-
94
- version :large do
95
- process :crop
96
- end
97
-
98
- version :preview do
99
- process :crop
100
- resize_to_limit(690, 518)
101
- end
102
-
103
- version :thumb do
104
- process :crop
105
- resize_to_fill(100, 100)
106
- end
107
-
108
-
109
- def crop
110
- if model.crop_x.present?
111
- manipulate! do |img|
112
- x = model.crop_x.to_i
113
- y = model.crop_y.to_i
114
- w = model.crop_w.to_i
115
- h = model.crop_h.to_i
116
- img = img.crop(x, y, w, h)
117
- img
118
- end
119
- end
120
- end
121
-
122
- def convert_to_grayscale
123
- manipulate! do |img|
124
- img.colorspace = Magick::GRAYColorspace
125
- img
126
- end
127
- end
128
-
129
- def brightness
130
- manipulate! do |img|
131
- img.modulate(1.20, 0.5, 1.2)
132
- end
133
- end
134
-
135
- # Override the filename of the uploaded files:
136
- # Avoid using model.id or version_name here, see uploader/store.rb for details.
137
- # def filename
138
- # "something.jpg" if original_filename
139
- # end
140
-
141
- def is_image? picture
142
- picture.content_type =~ /jpg|png|gif/
143
- end
144
-
145
- def is_pdf? picture
146
- picture.content_type =~ /pdf/
147
- end
148
-
149
- def is_doc? picture
150
- picture.content_type =~ /docx?$/
151
- end
152
-
153
- end
@@ -1,42 +0,0 @@
1
- -# = f.error_notification
2
- .form-inputs
3
- .div.hidden
4
- = m.input :imageable_id, as: :hidden, wrapper: :info_hidden
5
- = m.input :imageable_type, as: :hidden, wrapper: :info_hidden
6
- = m.input :lng_lat, as: :hidden, wrapper: :info_hidden
7
-
8
- .form-group.fileupload-buttonbar
9
- .row
10
- .col.s12
11
- // The fileinput-button span is used to style the file input field as button
12
- = m.file_field :medium, multiple: true, name: "medium[medium]", id: "medium_medium"
13
- %span.btn.hover_green.fileinput-button{ style: "margin-left: 12px"}
14
- %i.material-icons add
15
- %span.hide-on-med-and-down= t('.add_files')
16
-
17
- %span.btn.hover_green.start
18
- %i.material-icons file_upload
19
- %span.hide-on-med-and-down= t('.start_upload')
20
-
21
- -# %span.btn.hover_yellow.cancel
22
- -# %i.material-icons cancel
23
- -# %span.hide-on-med-and-down= t('.cancel_upload')
24
-
25
- %span.btn.delete
26
- %i.material-icons delete
27
- %span.hide-on-med-and-down= t('.delete')
28
- %span.fileNum
29
- %span.fileSize
30
-
31
- %input.toggle{ type: "checkbox" }
32
-
33
- .col.s12
34
- // The global progress bar
35
- .progress.fileupload-progress.fade{ style: "display:none"}
36
- .determinate{ style:"width:0%;"}
37
-
38
- // The loading indicator is shown during image processing
39
- // .fileupload-loading
40
- %br
41
- // The table listing the files available for upload/download
42
- .row.files{ data: {toggle: "modal-gallery", target: "#modal-gallery"}}
@@ -1,48 +0,0 @@
1
- :css
2
- input[type='file'] { display: none }
3
- /*.dropbox { background-color: transparent }*/
4
- /*.files img { max-height: 50px }*/
5
- .green-background { background-color: #607d8b }
6
- .card.small.uploaded { width: 100%; float: left; margin-top: 20px; margin-right: 10px; }
7
- .card .card-action { padding: 0px; margin: 0px; bottom: 5px }
8
- .card .card-action a { margin-right: 0px; margin-bottom: -5px; margin-left: 10px}
9
- .card-action .row { margin-bottom: 0px }
10
- /*.card .card-image { height: 150px }*/
11
- .card .card-image.uploaded { position: relative; max-height: 75% }
12
- .progress { position: absolute }
13
- .preview img, .card-image img { max-width: 100%; max-height: 100% }
14
- .card .card-content .card-title.activator { font-size: 7px; color: black; background-color: transparent; line-height: 8px }
15
- .progress { width: 70% }
16
- .card .card-title { font-size: 9px }
17
- .activator:hover { cursor: pointer }
18
-
19
- @media only screen and (max-width: 320px) { .card.small.uploaded { height: 75px } }
20
- @media only screen and (min-width: 321px) and (max-width: 480px) { .card.small.uploaded { height: 100px } }
21
- @media only screen and (min-width: 481px) and (max-width: 768px) { .card.small.uploaded { height: 125px } }
22
- @media only screen and (min-width: 769px) and (max-width: 960px) { .card.small.uploaded { height: 175px } }
23
- @media only screen and (min-width: 961px) and (max-width: 992px) { .card.small.uploaded { height: 230px } }
24
- @media only screen and (min-width: 993px) and (max-width: 1024px) { .card.small.uploaded { height: 150px } }
25
- @media only screen and (min-width: 1025px) and (max-width: 1240px) { .card.small.uploaded { height: 190px } }
26
- @media only screen and (min-width: 1241px) { .card.small.uploaded { height: 230px } }
27
- /*@media only screen and (min-width: 1600px) { .card .card-image.uploaded { max-height: 85% } }*/
28
-
29
- .card .card-image.uploaded { height: 85% }
30
-
31
- - unless f
32
- = simple_form_for(resource.media.build, html: { id: "fileupload", role: 'form', multipart: true } ) do |m|
33
- = render partial: 'media/fields', locals: { m: m}
34
-
35
- - else
36
- -# this is a really bad hack!
37
- -# but the (extra) form command totally f***'s up the parent form
38
- - simple_form_for(resource.media.build, html: { id: "fileupload", role: 'form', multipart: true } ) do |m|
39
- - @m = m
40
- = render partial: 'media/fields', locals: {m: @m}
41
-
42
- / Modal Structure
43
- #modal1.modal
44
- .modal-content{ style: "height: 90%;overflow: scroll;" }
45
- %h4 Fill this
46
-
47
- .modal-footer{ style: "height: 10%; bottom: 0px; "}
48
- %a.close-modal.waves-effect.waves-green.btn{ href: "#!"}= t("submit")
@@ -1,18 +0,0 @@
1
- :css
2
- .uris ul.collection .collection-item.avatar { min-height: 40px !important; }
3
-
4
- %h5{ style: "padding-left: 10px"}
5
- = t( "#{resource_class.to_s.pluralize.underscore}.media")
6
- %span{ class: "#{medialist}"}
7
-
8
- - unless @disabled
9
- = render partial: 'media/form', locals: {resource: resource, f: f}
10
- -# = link_to url, class: 'new_medium right btn hover_green' do
11
- -# %i.material-icons add
12
- -# %span.hide-on-med-and-down= t('.medium.new')
13
-
14
-
15
- .row{ id: "#{medialist}"}
16
- - resource.media.each do |medium|
17
- .col.s4
18
- = render 'media/medium', medium: medium unless medium.new_record?
@@ -1,25 +0,0 @@
1
- .card.small.uploaded{ id: "medium-#{medium.id}", data: { id: "#{medium.id}"}}
2
- -# , class: "#{'medium' unless @disabled===true}"
3
- .card-image.uploaded.waves-effect.waves-block.waves-light
4
- = image_tag medium.medium._url(:thumb), class: 'activator'
5
- .card-action
6
- .row
7
- .col.s12
8
- / %strong.error.text-danger
9
- / TODO 18-10-2015 picture properties and edit/crop does not work
10
- -# %i.material-icons.activator.right{ style: "margin-top: 6px; margin-left: 5px"} more_vert
11
- -# = link_to medium, class: 'edit_link right', data: { url: '/media', name: "#{medium.title}", id: "#{medium.id}", remove: "#medium-#{medium.id}" } do
12
- -# %i.material-icons.green-text.small{ title: "#{t('.edit')}", style: "margin-top: 5px"} edit
13
- = link_to medium, class: 'delete_link right', data: { url: '/media', name: "#{medium.title}", id: "#{medium.id}", remove: "#medium-#{medium.id}" } do
14
- %i.material-icons.red-text.small{ title: "#{t('.delete')}", style: "margin-top: 5px"} delete
15
-
16
- .card-reveal
17
- %span.card-title.grey-text.text-darken-4
18
- Billed egenskaber
19
- %i.material-icons.right close
20
- %p
21
- %span.card-title.grey-text.text-darken-4= (medium.title.blank? ? medium.medium.filename : medium.title)
22
- %p
23
- %input.string.optional{ name: "media[medium#{medium.id}][title]", placeholder: "Titel" }
24
- %p
25
- %textarea.text.optional.materialize-textarea{ name: "media[medium#{medium.id}][description]", placeholder: "Beskrivelse" }
@@ -1,4 +0,0 @@
1
- .card.small.uploaded{ id: "medium-#{m.object.id}", data: { id: "#{m.object.id}"}}
2
- -# , class: "#{'medium' unless @disabled===true}"
3
- .card-image.uploaded.waves-effect.waves-block.waves-light
4
- = image_tag m.object.medium._url(:thumb), class: 'activator'
@@ -1,2 +0,0 @@
1
- .col.s4
2
- = render 'medium', medium: resource
@@ -1,3 +0,0 @@
1
- = form_for resource do |f|
2
- = f.cropbox :medium
3
- / f.previewbox :medium, width: 300, height: 300
@@ -1,2 +0,0 @@
1
- - @disabled = false
2
- = render 'form'
@@ -1,29 +0,0 @@
1
- %h1 Listing media
2
-
3
- %table
4
- %thead
5
- %tr
6
- %th Label
7
- %th Imageable
8
- %th Media
9
- %th Lng lat
10
- %th File size
11
- %th
12
- %th
13
- %th
14
-
15
- %tbody
16
- - @media.each do |medium|
17
- %tr
18
- %td= medium.label
19
- %td= medium.imageable
20
- %td= medium.media
21
- %td= medium.lng_lat
22
- %td= medium.file_size
23
- %td= link_to 'Show', medium
24
- %td= link_to 'Edit', edit_medium_path(medium)
25
- %td= link_to 'Destroy', medium, :method => :delete, :data => { :confirm => 'Are you sure?' }
26
-
27
- %br
28
-
29
- = link_to 'New Medium', new_medium_path
@@ -1,4 +0,0 @@
1
- json.array!(@media) do |medium|
2
- json.extract! medium, :id, :label, :imageable_id, :imageable_type, :media, :lng_lat, :file_size
3
- json.url medium_url(medium, format: :json)
4
- end
@@ -1,5 +0,0 @@
1
- <h1>New Medium</h1>
2
-
3
- <%= render 'form' %>
4
-
5
- <%= link_to 'Back', media_path %>
@@ -1,21 +0,0 @@
1
- %p#notice= notice
2
-
3
- %p
4
- %b Title:
5
- = resource.title
6
- %p
7
- %b Imageable:
8
- = link_to 'imageable',resource.imageable
9
- %p
10
- %b Media:
11
- = image_tag resource.medium
12
- %p
13
- %b Lng lat:
14
- = resource.lng_lat
15
- %p
16
- %b File size:
17
- / = resource.file_size
18
-
19
- = link_to 'Edit', edit_medium_path(resource)
20
- \|
21
- = link_to 'Back', media_path
@@ -1 +0,0 @@
1
- json.extract! @medium, :id, :label, :imageable_id, :imageable_type, :media, :lng_lat, :file_size, :created_at, :updated_at
@@ -1 +0,0 @@
1
- = image_tag resource.medium, class: 'activator'