Module: Plugins::VzaarUploader::MainHelper
- Included in:
- AdminController
- Defined in:
- app/helpers/plugins/vzaar_uploader/main_helper.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#vzaar_post_form_sidebar_custom_html(args) ⇒ Object
show post form sidebar to upload featured video.
-
#vzaar_post_type_settings_admin(args) ⇒ Object
add extra post type setting to enable or disable featured videos for from current post type.
-
#vzaar_uploader_before_upload(args) ⇒ Object
owen2345/secret custom hook to upload videos to vzaar server.
- #vzaar_uploader_cacke_key ⇒ Object
-
#vzaar_uploader_list_objects(args) ⇒ Object
hook listener to read custom videos uploaded to vzaar attrs: data.
-
#vzaar_uploader_on_active(plugin) ⇒ Object
here all actions on going to active you can run sql commands like this: results = ActiveRecord::Base.connection.execute(query); plugin: plugin model.
-
#vzaar_uploader_on_inactive(plugin) ⇒ Object
here all actions on going to inactive plugin: plugin model.
-
#vzaar_uploader_on_plugin_options(args) ⇒ Object
hook listener to add settings link below the title of current plugin (if it is installed) args: (Hash), links (Array) permit to add unlimmited of links…
Class Method Details
.included(klass) ⇒ Object
2 3 4 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 2 def self.included(klass) # klass.helper_method [:my_helper_method] rescue "" # here your methods accessible from views end |
Instance Method Details
#vzaar_post_form_sidebar_custom_html(args) ⇒ Object
show post form sidebar to upload featured video
67 68 69 70 71 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 67 def (args) if @post_type.get_option('enable_vzaar_featured_video', false) args[:html] << render(plugin_view('admin/post_sidebar')) end end |
#vzaar_post_type_settings_admin(args) ⇒ Object
add extra post type setting to enable or disable featured videos for from current post type
74 75 76 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 74 def vzaar_post_type_settings_admin(args) args[:html] << render(plugin_view('admin/post_type_settings')) end |
#vzaar_uploader_before_upload(args) ⇒ Object
owen2345/secret custom hook to upload videos to vzaar server
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 35 def vzaar_uploader_before_upload(args) if args[:klass].class.validate_file_format(args[:key], 'video') key = args[:key] key = "/#{key}" unless key.starts_with?('/') # VzaarApi.client_id = 'munch-mule-hiatt' # VzaarApi.auth_token = 'R2p5zsS6AxNGncKrxdpw' VzaarApi.client_id = current_plugin.get_option('client_id') VzaarApi.auth_token = current_plugin.get_option('auth_token') file_path = args[:file].is_a?(String) ? args[:file] : args[:file].path video = VzaarApi::Video.create(path: file_path) args[:result_data] = { "name" => File.basename(key), "key" => key, "url" => "//view.vzaar.com/#{video.id}/player", "is_folder" => false, "size" => File.size(file_path).round(2), "format" => 'video', "deleteUrl" => '', "thumb" => '', 'type' => (MIME::Types.type_for(file_path).first.content_type rescue ""), 'created_at' => File.mtime(file_path), 'dimension' => '' } args[:klass].cache_item(args[:result_data], nil, vzaar_uploader_cacke_key) end end |
#vzaar_uploader_cacke_key ⇒ Object
62 63 64 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 62 def vzaar_uploader_cacke_key "vzaar_files_#{current_site.id}" end |
#vzaar_uploader_list_objects(args) ⇒ Object
hook listener to read custom videos uploaded to vzaar attrs: data
27 28 29 30 31 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 27 def vzaar_uploader_list_objects(args) files = current_site.(vzaar_uploader_cacke_key, {}) res = files[args[:prefix]] || {} args[:data] = args[:data].with_indifferent_access.deep_merge(res) end |
#vzaar_uploader_on_active(plugin) ⇒ Object
here all actions on going to active you can run sql commands like this: results = ActiveRecord::Base.connection.execute(query); plugin: plugin model
10 11 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 10 def vzaar_uploader_on_active(plugin) end |
#vzaar_uploader_on_inactive(plugin) ⇒ Object
here all actions on going to inactive plugin: plugin model
15 16 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 15 def vzaar_uploader_on_inactive(plugin) end |
#vzaar_uploader_on_plugin_options(args) ⇒ Object
hook listener to add settings link below the title of current plugin (if it is installed) args: (Hash), links (Array) permit to add unlimmited of links…
21 22 23 |
# File 'app/helpers/plugins/vzaar_uploader/main_helper.rb', line 21 def (args) args[:links] << link_to('Settings', admin_plugins_vzaar_uploader_settings_path) end |