oxen_media 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.bowerrc +3 -0
  3. data/.envrc +1 -0
  4. data/.gitignore +11 -0
  5. data/.rspec +3 -0
  6. data/.ruby-version +1 -0
  7. data/Gemfile +16 -0
  8. data/Gemfile.lock +331 -0
  9. data/Guardfile +135 -0
  10. data/MIT-LICENSE +20 -0
  11. data/README.rdoc +31 -0
  12. data/Rakefile +15 -0
  13. data/app/assets/images/oxen_media/.keep +0 -0
  14. data/app/assets/javascripts/jsrender.min.js +4 -0
  15. data/app/assets/javascripts/jsrender.min.js.map +463 -0
  16. data/app/assets/javascripts/oxen_media.js +3 -0
  17. data/app/assets/javascripts/oxen_media/.keep +0 -0
  18. data/app/assets/javascripts/oxen_media/carrier_wave_cropper.js.coffee +22 -0
  19. data/app/assets/javascripts/oxen_media/media.js.coffee +469 -0
  20. data/app/assets/javascripts/oxen_media/medium_pane.js.coffee +107 -0
  21. data/app/assets/javascripts/templates/selected_files.html +35 -0
  22. data/app/assets/stylesheets/media.css +10 -0
  23. data/app/assets/stylesheets/oxen_media/.keep +0 -0
  24. data/app/assets/stylesheets/scaffold.css +56 -0
  25. data/app/controllers/.keep +0 -0
  26. data/app/controllers/media_controller.rb +106 -0
  27. data/app/helpers/.keep +0 -0
  28. data/app/helpers/media_helper.rb +2 -0
  29. data/app/mailers/.keep +0 -0
  30. data/app/models/.keep +0 -0
  31. data/app/models/concerns/roleable.rb +61 -0
  32. data/app/models/medium.rb +25 -0
  33. data/app/policies/oxen_medium_policy.rb +12 -0
  34. data/app/uploaders/medium_uploader.rb +106 -0
  35. data/app/views/.keep +0 -0
  36. data/app/views/media/_fields.html.haml +42 -0
  37. data/app/views/media/_form.html.haml +48 -0
  38. data/app/views/media/_media.html.haml +18 -0
  39. data/app/views/media/_medium.html.haml +25 -0
  40. data/app/views/media/_medium_fields.html.haml +4 -0
  41. data/app/views/media/create.js.haml +2 -0
  42. data/app/views/media/crop.html.haml +3 -0
  43. data/app/views/media/edit.html.haml +2 -0
  44. data/app/views/media/index.html.haml +29 -0
  45. data/app/views/media/index.json.jbuilder +4 -0
  46. data/app/views/media/new.html.erb +5 -0
  47. data/app/views/media/show.html.haml +21 -0
  48. data/app/views/media/show.json.jbuilder +1 -0
  49. data/app/views/media/update_crop.js.haml +1 -0
  50. data/bin/rails +12 -0
  51. data/config/initializers/backtrace_silencers.rb +9 -0
  52. data/config/initializers/carrier_wave.rb +11 -0
  53. data/config/initializers/simple_form.rb +14 -0
  54. data/config/locales/media.en.yml +20 -0
  55. data/config/routes.rb +6 -0
  56. data/db/migrate/20150629071720_create_media.rb +13 -0
  57. data/lib/generators/media/USAGE +8 -0
  58. data/lib/generators/media/media_generator.rb +48 -0
  59. data/lib/generators/media/templates/medium.rb +13 -0
  60. data/lib/oxen_media.rb +7 -0
  61. data/lib/oxen_media/engine.rb +19 -0
  62. data/lib/oxen_media/version.rb +3 -0
  63. data/lib/tasks/oxen_media_tasks.rake +4 -0
  64. data/oxen_media.gemspec +59 -0
  65. data/test/controllers/media_controller_test.rb +49 -0
  66. data/test/fixtures/media.yml +17 -0
  67. data/test/integration/oxen_media_test.rb +7 -0
  68. data/test/lib/generators/media_generator_test.rb +14 -0
  69. data/test/models/medium_test.rb +7 -0
  70. data/test/test_helper.rb +13 -0
  71. metadata +387 -0
data/app/views/.keep ADDED
File without changes
@@ -0,0 +1,42 @@
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"}}
@@ -0,0 +1,48 @@
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")
@@ -0,0 +1,18 @@
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?
@@ -0,0 +1,25 @@
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" }
@@ -0,0 +1,4 @@
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'
@@ -0,0 +1,2 @@
1
+ .col.s4
2
+ = render 'medium', medium: resource
@@ -0,0 +1,3 @@
1
+ = form_for resource do |f|
2
+ = f.cropbox :medium
3
+ / f.previewbox :medium, width: 300, height: 300
@@ -0,0 +1,2 @@
1
+ - @disabled = false
2
+ = render 'form'
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,4 @@
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
@@ -0,0 +1,5 @@
1
+ <h1>New Medium</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', media_path %>
@@ -0,0 +1,21 @@
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
@@ -0,0 +1 @@
1
+ json.extract! @medium, :id, :label, :imageable_id, :imageable_type, :media, :lng_lat, :file_size, :created_at, :updated_at
@@ -0,0 +1 @@
1
+ = image_tag resource.medium, class: 'activator'
data/bin/rails ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/oxen_media/engine', __FILE__)
6
+
7
+ # Set up gems listed in the Gemfile.
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
9
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
10
+
11
+ require 'rails/all'
12
+ require 'rails/engine/commands'
@@ -0,0 +1,9 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't
4
+ # wish to see in your backtraces.
5
+ Rails.backtrace_cleaner.add_silencer { |line| line =~ /rvm/ }
6
+
7
+ # You can also remove all the silencers if you're trying to debug a problem
8
+ # that might stem from framework code.
9
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,11 @@
1
+ if Rails.env.production?
2
+ # CarrierWave.configure do |config|
3
+ # config.fog_credentials = {
4
+ # # Configuration for Amazon S3
5
+ # :provider => 'AWS',
6
+ # :aws_access_key_id => ENV['S3_ACCESS_KEY'],
7
+ # :aws_secret_access_key => ENV['S3_SECRET_KEY']
8
+ # }
9
+ # config.fog_directory = ENV['S3_BUCKET']
10
+ # end
11
+ end
@@ -0,0 +1,14 @@
1
+ # Use this setup block to configure all options available in SimpleForm.
2
+ SimpleForm.setup do |config|
3
+ # Wrappers are used by the form builder to generate a
4
+ # complete input. You can remove any component from the
5
+ # wrapper, change the order or even add your own to the
6
+ # stack. The options given below are used to wrap the
7
+ # whole input.
8
+
9
+ config.wrappers :info_hidden, :tag => 'span' do |b| # , :class => 'input-field col s12'
10
+ b.use :html5
11
+ b.use :input
12
+ end
13
+
14
+ end
@@ -0,0 +1,20 @@
1
+ en:
2
+ success:
3
+ created: '%{resource} was created successfully'
4
+ updated: '%{resource} was updated successfully'
5
+ deleted: '%{resource} was deleted successfully'
6
+
7
+ flash:
8
+ actions:
9
+ create:
10
+ notice: "%{resource_name} was successfully created."
11
+ update:
12
+ notice: "%{resource_name} was successfully updated."
13
+ destroy:
14
+ notice: "%{resource_name} was successfully destroyed."
15
+ alert: "%{resource_name} could not be destroyed."
16
+ alert_html: "<strong>OH NOES!</strong> You did it wrong!"
17
+
18
+ # posts:
19
+ # create:
20
+ # notice: "Your post was created and will be published soon"
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ resources :media do
3
+ get :crop
4
+ post :update_crop
5
+ end
6
+ end
@@ -0,0 +1,13 @@
1
+ class CreateMedia < ActiveRecord::Migration
2
+ def change
3
+ create_table :media do |t|
4
+ t.string :title
5
+ t.references :imageable, polymorphic: true, index: true
6
+ t.string :medium
7
+ t.string :lng_lat
8
+ t.text :description
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ rails generate media Thing
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,48 @@
1
+ class MediaGenerator < Rails::Generators::NamedBase
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ include Rails::Generators::Migration
5
+ def self.source_root
6
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
7
+ end
8
+
9
+ def self.next_migration_number(dirname)
10
+ if ActiveRecord::Base.timestamped_migrations
11
+ Time.new.utc.strftime("%Y%m%d%H%M%S")
12
+ else
13
+ "%.3d" % (current_migration_number(dirname) + 1)
14
+ end
15
+ end
16
+
17
+ def create_migration_file
18
+ migration_template 'medium.rb', 'db/migrate/create_media.rb'
19
+ end
20
+
21
+ end
22
+ #
23
+ # require 'rails/generators'
24
+ # require 'rails/generators/migration'
25
+ #
26
+ # module OxenAccount
27
+ # module Generators
28
+ # class AccountGenerator < Rails::Generators::Base
29
+ # include Rails::Generators::Migration
30
+ # def self.source_root
31
+ # @source_root ||= File.join(File.dirname(__FILE__), 'templates')
32
+ # end
33
+ #
34
+ # def self.next_migration_number(dirname)
35
+ # if ActiveRecord::Base.timestamped_migrations
36
+ # Time.new.utc.strftime("%Y%m%d%H%M%S")
37
+ # else
38
+ # "%.3d" % (current_migration_number(dirname) + 1)
39
+ # end
40
+ # end
41
+ #
42
+ # def create_migration_file
43
+ # migration_template 'account.rb', 'db/migrate/create_accounts.rb'
44
+ # migration_template 'user_permission.rb', 'db/migrate/create_user_permissions.rb'
45
+ # end
46
+ # end
47
+ # end
48
+ # end
@@ -0,0 +1,13 @@
1
+ class CreateMedia < ActiveRecord::Migration
2
+ def change
3
+ create_table :media do |t|
4
+ t.string :title
5
+ t.references :imageable, polymorphic: true, index: true
6
+ t.string :medium
7
+ t.string :lng_lat
8
+ t.text :description
9
+
10
+ t.timestamps null: false
11
+ end
12
+ end
13
+ end
data/lib/oxen_media.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "oxen_media/version"
2
+ require "oxen_media/engine"
3
+ require "carrierwave/crop"
4
+ require "carrierwave"
5
+
6
+ module OxenMedia
7
+ end
@@ -0,0 +1,19 @@
1
+ module OxenMedia
2
+ class Engine < ::Rails::Engine
3
+ # config.autoload_paths << File.expand_path("../concerns", __FILE__)
4
+ #
5
+ # config.generators do |g|
6
+ # g.test_framework :rspec,
7
+ # :fixture => false,
8
+ # :fixtures => true,
9
+ # :view_specs => false,
10
+ # :helper_specs => false,
11
+ # :routing_specs => false,
12
+ # :controller_specs => true,
13
+ # :request_specs => true
14
+ # g.fixture_replacement :factory_girl, :dir => "spec/factories"
15
+ # g.assets false
16
+ # g.helper false
17
+ # end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module OxenMedia
2
+ VERSION = "0.0.2"
3
+ end