vzaar_uploader 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 55d740b0359c427281edc4ee77c843586a4004c0
4
+ data.tar.gz: f07775688aa612c15d29471dc28f8a9562b39142
5
+ SHA512:
6
+ metadata.gz: 1e301bb61ce9021353f17c61b222ce5891ef209d5e273fabaeeeca219bbfc3a1780a9d62fadf9732c3d3c6187e2b267a23979c5ae4a2de88c130a2ac20b5bc2b
7
+ data.tar.gz: 8331f82cc958a8c6eaf3adaf1e4763f7b5eda463c5dca5a8423788dcb9f899dbb6ad58c5884eb93aa80aede673544aabca3cc76b526bb97464fce6dc6e384ec6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 Owen Peredo
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # VzaarUploader
2
+ Vzaar video uploader plugin for Camaleon CMS.
3
+ All videos uploaded using Camaleon Media Browser will be saved in Vzaar Server.
4
+
5
+ ## Installation
6
+ * Add gem to you Gemfile
7
+ ```
8
+ gem 'vzaar_uploader'
9
+ gem 'vzaar_api', git: 'git@github.com:vzaar/vzaar-api-ruby.git', branch: 'version-2.0.0-alpha'
10
+ ```
11
+ * Install gem
12
+ ```
13
+ bundle install
14
+ ```
15
+ * Active plugin in admin panel
16
+
17
+ * Configure plugin settings to enter Vzaar API settings
18
+
19
+
20
+ ## Usage
21
+ * Go to admin panel -> settings -> Content Groups
22
+
23
+ * Add/Edit a Content Group to enable Featured Video for its contents
24
+
25
+ * After enabled a featured video, this will be shown below featured image on create content
26
+
27
+ * Include video player js library in your assets
28
+ ```
29
+ //= require plugins/vzaar_uploader/vzaar
30
+ ```
31
+ * In your html template render your featured video like this:
32
+ ```
33
+ <div class="featured_video">
34
+ <%= video_tag @post.get_meta('featured_video') %>
35
+ </div>
36
+ ```
37
+
38
+ ## Contributing
39
+ Contribution directions go here.
40
+
41
+ ## License
42
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'VzaarUploader'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task default: :test
File without changes
@@ -0,0 +1,10 @@
1
+ $ ->
2
+ $.fn.VzaarPlayer = ()->
3
+ this.each ->
4
+ video = $(this)
5
+ src = $(this).attr('src') || $(this).find('source').attr('src')
6
+ if src.search('vzaar.com') >= 0
7
+ $(this).replaceWith("""<iframe id="vzvd-10456199" #{if video.attr("width") then "width='#{video.attr("width")}'" else ""} #{if video.attr("height") then "width='#{video.attr("height")}'" else ""} name="vzvd-10456199" title="video player" class="video-player" type="text/html" frameborder="0" allowfullscreen allowTransparency="true" mozallowfullscreen webkitAllowFullScreen src="#{src}"></iframe>""")
8
+
9
+ $('video').not('exclude_vzaar_iframe').each ->
10
+ $(this).VzaarPlayer()
@@ -0,0 +1,18 @@
1
+ class Plugins::VzaarUploader::AdminController < CamaleonCms::Apps::PluginsAdminController
2
+ include Plugins::VzaarUploader::MainHelper
3
+ def index
4
+ end
5
+
6
+ # show settings form
7
+ def settings
8
+ end
9
+
10
+ # save values from settings form
11
+ def save_settings
12
+ @plugin.set_options(params[:options]) if params[:options].present? # save option values
13
+ @plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values
14
+ @plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values
15
+ redirect_to url_for(action: :settings), notice: 'Settings Saved Successfully'
16
+ end
17
+ # add custom methods below ....
18
+ end
@@ -0,0 +1,77 @@
1
+ module Plugins::VzaarUploader::MainHelper
2
+ def self.included(klass)
3
+ # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views
4
+ end
5
+
6
+ # here all actions on going to active
7
+ # you can run sql commands like this:
8
+ # results = ActiveRecord::Base.connection.execute(query);
9
+ # plugin: plugin model
10
+ def vzaar_uploader_on_active(plugin)
11
+ end
12
+
13
+ # here all actions on going to inactive
14
+ # plugin: plugin model
15
+ def vzaar_uploader_on_inactive(plugin)
16
+ end
17
+
18
+ # hook listener to add settings link below the title of current plugin (if it is installed)
19
+ # args: {plugin (Hash), links (Array)}
20
+ # permit to add unlimmited of links...
21
+ def vzaar_uploader_on_plugin_options(args)
22
+ args[:links] << link_to('Settings', admin_plugins_vzaar_uploader_settings_path)
23
+ end
24
+
25
+ # hook listener to read custom videos uploaded to vzaar
26
+ # attrs: {prefix, data}
27
+ def vzaar_uploader_list_objects(args)
28
+ files = current_site.get_meta(vzaar_uploader_cacke_key, {})
29
+ res = files[args[:prefix]] || {}
30
+ args[:data] = args[:data].deep_merge(res)
31
+ end
32
+
33
+ #owen2345/secret
34
+ # custom hook to upload videos to vzaar server
35
+ def vzaar_uploader_before_upload(args)
36
+ if args[:klass].class.validate_file_format(args[:key], 'video')
37
+ key = args[:key]
38
+ key = "/#{key}" unless key.starts_with?('/')
39
+ # VzaarApi.client_id = 'munch-mule-hiatt'
40
+ # VzaarApi.auth_token = 'R2p5zsS6AxNGncKrxdpw'
41
+ VzaarApi.client_id = current_plugin.get_option('client_id')
42
+ VzaarApi.auth_token = current_plugin.get_option('auth_token')
43
+ file_path = args[:file].is_a?(String) ? args[:file] : args[:file].path
44
+ video = VzaarApi::Video.create(path: file_path)
45
+ args[:result_data] = {
46
+ "name" => File.basename(key),
47
+ "key" => key,
48
+ "url" => "//view.vzaar.com/#{video.id}/player",
49
+ "is_folder" => false,
50
+ "size" => File.size(file_path).round(2),
51
+ "format" => 'video',
52
+ "deleteUrl" => '',
53
+ "thumb" => '',
54
+ 'type' => (MIME::Types.type_for(file_path).first.content_type rescue ""),
55
+ 'created_at' => File.mtime(file_path),
56
+ 'dimension' => ''
57
+ }
58
+ args[:klass].cache_item(args[:result_data], nil, vzaar_uploader_cacke_key)
59
+ end
60
+ end
61
+
62
+ def vzaar_uploader_cacke_key
63
+ "vzaar_files_#{current_site.id}"
64
+ end
65
+
66
+ # show post form sidebar to upload featured video
67
+ def vzaar_post_form_sidebar_custom_html(args)
68
+ if @post_type.get_option('enable_vzaar_featured_video', false)
69
+ args[:html] << render(plugin_view('admin/post_sidebar'))
70
+ end
71
+ end
72
+
73
+ # add extra post type setting to enable or disable featured videos for from current post type
74
+ def vzaar_post_type_settings_admin(args)
75
+ args[:html] << render(plugin_view('admin/post_type_settings'))
76
+ end
77
+ end
@@ -0,0 +1,6 @@
1
+ # class Plugins::VzaarUploader::VzaarUploader < ActiveRecord::Base
2
+ # belongs_to :site, class_name: "CamleonCms::Site"
3
+
4
+ # here create your models normally
5
+ # notice: your tables in database will be plugins_vzaar_uploader in plural (check rails documentation)
6
+ # end
@@ -0,0 +1,51 @@
1
+ <% url = params[:meta][:featured_video] rescue false || @post.get_meta("featured_video", "") %>
2
+ <% if @post.manage_picture?(@post_type) %>
3
+ <div class="panel panel-default panel-lite">
4
+ <div class="panel-heading">
5
+ <h3 class="panel-title">Featured Video</h3>
6
+ <ul class="panel-controls">
7
+ <li><a href="#" class="panel-collapse"><span class="fa fa-angle-down"></span></a></li>
8
+ </ul>
9
+ </div>
10
+ <div class="panel-body ">
11
+ <div class="form-group">
12
+ <div id="feature-video" class="gallery">
13
+ <a class="gallery-item" style="width: 100%; padding: 0; <%= 'display: none;' unless url.present? %>" href="#" title="Thumbnail" data-gallery="">
14
+ <div class="image">
15
+ <img src="<%= url.sub('/player', '/thumb') %>" class="img-rounded img-responsive" alt="Thumbnail">
16
+ <span class="btn btn-primary btn-xs" onclick="cama_vzaar_upload_featured_video_clear($(this))"><i class="fa fa-times"></i></span>
17
+ </div>
18
+ </a>
19
+ <input data-error-place='#feature-image ~ .validation-errors:first' class="required" name="meta[featured_video]" type="hidden" value="<%= url %>"/>
20
+ </div>
21
+ <a href="#" class="btn btn-default" onclick="cama_vzaar_upload_featured_video($(this)); return false;"><i class="fa fa-upload"></i> Upload Featured Video</a>
22
+ <div class="validation-errors"></div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+ <script>
28
+ function cama_vzaar_upload_featured_video_clear(ele){
29
+ var p = ele.closest('.form-group');
30
+ p.find('input').val('');
31
+ p.find('.gallery-item').hide();
32
+ }
33
+ function cama_vzaar_upload_featured_video(ele){
34
+ var p = ele.closest('.form-group');
35
+ // url: //view.vzaar.com/10456199/player
36
+ // thumb: 'https://view.vzaar.com/10456199/thumb'
37
+ $.fn.upload_filemanager($.extend({
38
+ formats: "video",
39
+ selected: function (image) {
40
+ var url = image.url;
41
+ /*if(url.search('vzaar') < 0){
42
+ alert('Invalid Vzaar video')
43
+ return;
44
+ }*/
45
+ p.find('input').val(url);
46
+ p.find('img').attr('src', url.replace('/player', '/thumb'))
47
+ p.find('.gallery-item').show();
48
+ }
49
+ }));
50
+ }
51
+ </script>
@@ -0,0 +1,4 @@
1
+ <div class="form-group">
2
+ <input name="meta[is_required_picture]" type="hidden" value="false"/>
3
+ <label class="check0"><%= check_box_tag 'meta[enable_vzaar_featured_video]', true, @post_type.get_option('enable_vzaar_featured_video', false) %> Enable Featured Video</label>
4
+ </div>
@@ -0,0 +1,9 @@
1
+ <%#= javascript_include_tag plugin_asset("my_file.js") %>
2
+ <div class="panel panel-default">
3
+ <div class="panel-heading">
4
+ <h4>My Title</h4>
5
+ </div>
6
+ <div class="panel-body">
7
+ <p>Plugin ready to use in admin panel!.</p>
8
+ </div>
9
+ </div>
@@ -0,0 +1,21 @@
1
+ <div class="panel panel-default">
2
+ <div class="panel-heading">
3
+ <h4>Vzaar Video Server Settings</h4>
4
+ </div>
5
+ <div class="panel-body">
6
+ <%= form_tag(url_for(action: :save_settings), class: 'validate') do %>
7
+ <div class="alert alert-info">Please generate your API <a href="https://app.vzaar.com/settings/api" target="_blank">here.</a></div>
8
+ <div class="form-group">
9
+ <label>Vzaar Auth Secret (Client ID)</label>
10
+ <%= text_field_tag 'options[client_id]', @plugin.get_option('client_id'), class: 'form-control required' %>
11
+ </div>
12
+ <div class="form-group">
13
+ <label>Vzaar Auth Token</label>
14
+ <%= text_field_tag 'options[auth_token]', @plugin.get_option('auth_token'), class: 'form-control required' %>
15
+ </div>
16
+ <div class="form-group text-right">
17
+ <%= submit_tag 'Save Settings', class: 'btn btn-primary' %>
18
+ </div>
19
+ <% end %>
20
+ </div>
21
+ </div>
@@ -0,0 +1,2 @@
1
+ <%#= javascript_include_tag plugin_gem_asset("js/my_file.js") %>
2
+ Plugin ready to use! in frontend.
@@ -0,0 +1,2 @@
1
+ You can create your layouts here.
2
+ To load your custom layout you can use: layout: plugin_layout(<layout_name>) in your controller
@@ -0,0 +1,19 @@
1
+ {
2
+ "title": "Vzaar Uploader",
3
+ "descr": "",
4
+ "key": "vzaar_uploader", // must be the name of the folder of your plugin, sample: app/views/plugins/<my_plugin> ==> 'my_plugin'
5
+ "helpers": [
6
+ "Plugins::VzaarUploader::MainHelper"
7
+ ],
8
+ "hooks": {
9
+ "on_active": ["vzaar_uploader_on_active"],
10
+ "on_inactive": ["vzaar_uploader_on_inactive"],
11
+ "plugin_options": ["vzaar_uploader_on_plugin_options"],
12
+ "uploader_list_objects": ["vzaar_uploader_list_objects"],
13
+ "uploader_aws_before_upload": ["vzaar_uploader_before_upload"],
14
+ "uploader_local_before_upload": ["vzaar_uploader_before_upload"],
15
+ "post_form_sidebar_custom_html": ["vzaar_post_form_sidebar_custom_html"],
16
+ "post_type_settings_admin": ["vzaar_post_type_settings_admin"]
17
+ //here you can add all your hooks (read documentation)
18
+ }
19
+ }
@@ -0,0 +1,5 @@
1
+ #Rails.application.config.to_prepare do
2
+ # CamaleonCms::Site.class_eval do
3
+ # has_many :attack, class_name: "Plugins::Attack::Models::Attack"
4
+ # end
5
+ # end
data/config/routes.rb ADDED
@@ -0,0 +1,31 @@
1
+ Rails.application.routes.draw do
2
+
3
+ scope PluginRoutes.system_info["relative_url_root"] do
4
+ scope '(:locale)', locale: /#{PluginRoutes.all_locales}/, :defaults => { } do
5
+ # frontend
6
+ namespace :plugins do
7
+ namespace 'vzaar_uploader' do
8
+ get 'index' => 'front#index'
9
+ end
10
+ end
11
+ end
12
+
13
+ #Admin Panel
14
+ scope :admin, as: 'admin', path: PluginRoutes.system_info['admin_path_name'] do
15
+ namespace 'plugins' do
16
+ namespace 'vzaar_uploader' do
17
+ controller :admin do
18
+ get :index
19
+ get :settings
20
+ post :save_settings
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ # main routes
27
+ #scope 'vzaar_uploader', module: 'plugins/vzaar_uploader/', as: 'vzaar_uploader' do
28
+ # Here my routes for main routes
29
+ #end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :vzaar_uploader do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,4 @@
1
+ module VzaarUploader
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module VzaarUploader
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,5 @@
1
+ require "vzaar_uploader/engine"
2
+
3
+ module VzaarUploader
4
+ # Your code goes here...
5
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vzaar_uploader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Owen Peredo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-06-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: camaleon_cms
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 2.4.3.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 2.4.3.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Vzaar video uploader plugin for Camaleon CMS.
56
+ email:
57
+ - owenperedo@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/config/vzaar_uploader_manifest.js
66
+ - app/assets/javascripts/plugins/vzaar_uploader/vzaar.coffee
67
+ - app/controllers/plugins/vzaar_uploader/admin_controller.rb
68
+ - app/helpers/plugins/vzaar_uploader/main_helper.rb
69
+ - app/models/plugins/vzaar_uploader/vzaar_uploader.rb
70
+ - app/views/plugins/vzaar_uploader/admin/_post_sidebar.html.erb
71
+ - app/views/plugins/vzaar_uploader/admin/_post_type_settings.html.erb
72
+ - app/views/plugins/vzaar_uploader/admin/index.html.erb
73
+ - app/views/plugins/vzaar_uploader/admin/settings.html.erb
74
+ - app/views/plugins/vzaar_uploader/front/index.html.erb
75
+ - app/views/plugins/vzaar_uploader/layouts/readme.txt
76
+ - config/camaleon_plugin.json
77
+ - config/initializers/custom_models.rb
78
+ - config/routes.rb
79
+ - lib/tasks/vzaar_uploader_tasks.rake
80
+ - lib/vzaar_uploader.rb
81
+ - lib/vzaar_uploader/engine.rb
82
+ - lib/vzaar_uploader/version.rb
83
+ homepage: ''
84
+ licenses:
85
+ - MIT
86
+ metadata: {}
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.6.10
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: Vzaar video uploader plugin for Camaleon CMS.
107
+ test_files: []