oxen_media 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bowerrc +3 -0
- data/.envrc +1 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/Gemfile +16 -0
- data/Gemfile.lock +331 -0
- data/Guardfile +135 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +31 -0
- data/Rakefile +15 -0
- data/app/assets/images/oxen_media/.keep +0 -0
- data/app/assets/javascripts/jsrender.min.js +4 -0
- data/app/assets/javascripts/jsrender.min.js.map +463 -0
- data/app/assets/javascripts/oxen_media.js +3 -0
- data/app/assets/javascripts/oxen_media/.keep +0 -0
- data/app/assets/javascripts/oxen_media/carrier_wave_cropper.js.coffee +22 -0
- data/app/assets/javascripts/oxen_media/media.js.coffee +469 -0
- data/app/assets/javascripts/oxen_media/medium_pane.js.coffee +107 -0
- data/app/assets/javascripts/templates/selected_files.html +35 -0
- data/app/assets/stylesheets/media.css +10 -0
- data/app/assets/stylesheets/oxen_media/.keep +0 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/media_controller.rb +106 -0
- data/app/helpers/.keep +0 -0
- data/app/helpers/media_helper.rb +2 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/concerns/roleable.rb +61 -0
- data/app/models/medium.rb +25 -0
- data/app/policies/oxen_medium_policy.rb +12 -0
- data/app/uploaders/medium_uploader.rb +106 -0
- data/app/views/.keep +0 -0
- data/app/views/media/_fields.html.haml +42 -0
- data/app/views/media/_form.html.haml +48 -0
- data/app/views/media/_media.html.haml +18 -0
- data/app/views/media/_medium.html.haml +25 -0
- data/app/views/media/_medium_fields.html.haml +4 -0
- data/app/views/media/create.js.haml +2 -0
- data/app/views/media/crop.html.haml +3 -0
- data/app/views/media/edit.html.haml +2 -0
- data/app/views/media/index.html.haml +29 -0
- data/app/views/media/index.json.jbuilder +4 -0
- data/app/views/media/new.html.erb +5 -0
- data/app/views/media/show.html.haml +21 -0
- data/app/views/media/show.json.jbuilder +1 -0
- data/app/views/media/update_crop.js.haml +1 -0
- data/bin/rails +12 -0
- data/config/initializers/backtrace_silencers.rb +9 -0
- data/config/initializers/carrier_wave.rb +11 -0
- data/config/initializers/simple_form.rb +14 -0
- data/config/locales/media.en.yml +20 -0
- data/config/routes.rb +6 -0
- data/db/migrate/20150629071720_create_media.rb +13 -0
- data/lib/generators/media/USAGE +8 -0
- data/lib/generators/media/media_generator.rb +48 -0
- data/lib/generators/media/templates/medium.rb +13 -0
- data/lib/oxen_media.rb +7 -0
- data/lib/oxen_media/engine.rb +19 -0
- data/lib/oxen_media/version.rb +3 -0
- data/lib/tasks/oxen_media_tasks.rake +4 -0
- data/oxen_media.gemspec +59 -0
- data/test/controllers/media_controller_test.rb +49 -0
- data/test/fixtures/media.yml +17 -0
- data/test/integration/oxen_media_test.rb +7 -0
- data/test/lib/generators/media_generator_test.rb +14 -0
- data/test/models/medium_test.rb +7 -0
- data/test/test_helper.rb +13 -0
- 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,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,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,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,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,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
|