Vzaar::ViewHelpers

Public Instance Methods

include_vzaar_javascripts() click to toggle source
    # File lib/rails/views/view_helpers.rb, line 7
 7:     def include_vzaar_javascripts
 8:       javascript_include_tag 'vzaar/json_parse', 'vzaar/swfupload', 'vzaar/handlers', 
 9:         'vzaar/swfupload.queue', 'vzaar/fileprogress'
10:     end
vzaar_basic_uploader(options = {}) click to toggle source

TODO: documentation if using metadata you should change x-amz-meta-title and x-amz-meta-profile to relevant values using javascript TODO: change to use Vzaar.connection

    # File lib/rails/views/view_helpers.rb, line 42
42:     def vzaar_basic_uploader(options = {})
43:       default_options = {
44:         :success_action_redirect => nil,
45:         :include_metadata => false,
46:         :vzaar_params => {}
47:       }
48:       options = default_options.merge options
49:       vz = Vzaar::Base.new options[:vzaar_params]
50:       signature = vz.signature options
51:       upload_form = %{
52:         <form action="http://#{signature.bucket}.s3.amazonaws.com/" method="post" 
53:           enctype="multipart/form-data" id="uploadToS3">
54:                 <div class="uploadFieldsWrapper" style="width:490px; float:left">
55:                               <input type="hidden" name="key" value="#{signature.key}">
56:                               <input type="hidden" name="AWSAccessKeyId" value="#{signature.aws_access_key}">
57:                               <input type="hidden" name="acl" value="#{signature.acl}"> 
58:                               <input type="hidden" name="success_action_status" value="201">
59:                               <input type="hidden" name="policy" value="#{signature.policy}">
60:                               <input type="hidden" name="signature" value="#{signature.signature}">
61:       }
62:       if signature.profile and signature.title
63:         upload_form += %{
64:             <input id='vzaar-title' type="hidden" name="x-amz-meta-title"
65:               value="#{signature.title}">
66:             <input id='vzaar-profile' type="hidden" name="x-amz-meta-profile"
67:               value="#{signature.profile}">
68:         }
69:       end
70:       if signature.success_action_redirect
71:         upload_form += %{
72:             <input type="hidden" name="success_action_redirect"
73:               value="#{signature.success_action_redirect}">
74:         }
75:       end
76:       upload_form += %{
77:                   <label class='videoFileStep'>video file to be uploaded</label>
78:                   <input name="file" type="file" id="fileField" onchange="EnableBasicButton();"> 
79:             <br />
80:             <input name="upload" type="submit" />
81:                 </div> 
82:         </form>
83:       }
84:       upload_form
85:     end
vzaar_flash_uploader(options = {}) click to toggle source

<%=

    vzaar_flash_uploader :vzaar_params => {},
      :success_url => 'http://localhost/videos/'

%>

TODO: Handle succuess url correctly

    # File lib/rails/views/view_helpers.rb, line 24
24:     def vzaar_flash_uploader(options = {})
25:       default_options = {
26:         :flash_request => true,
27:         :connection => Vzaar.connection
28:       }
29:       options = default_options.merge options
30:       connection = options[:connection]
31:       signature = connection.signature options
32:       result = ''
33:       result += flash_uploader_script signature, options
34:       result += flash_uploader_html
35:       result
36:     end

Private Instance Methods

flash_uploader_html() click to toggle source
     # File lib/rails/views/view_helpers.rb, line 161
161:       def flash_uploader_html
162:         result = %{
163:           <div id="content">
164:             <form id="vzaar_upload" action="" method="post" enctype="multipart/form-data">
165:               <div class="fieldset flash" id="fsUploadProgress">
166:                 <span class="legend">Upload Queue</span>
167:               </div>
168:               <span id="spanButtonPlaceHolder"></span>
169:             </form>
170:           </div>
171:         }
172:         result
173:       end
flash_uploader_post_params(signature) click to toggle source
    # File lib/rails/views/view_helpers.rb, line 89
89:       def flash_uploader_post_params(signature)
90:         result = {}
91:         result[:AWSAccessKeyId] = signature.aws_access_key
92:         result[:key] = signature.key
93:         result[:acl] = signature.acl
94:         result[:policy] = signature.policy
95:         result[:signature] = signature.signature
96:         result[:success_action_status] = '201'
97:         result['content-type'] = 'binary/octet-stream'
98:         result
99:       end
flash_uploader_script(signature, options = {}) click to toggle source
     # File lib/rails/views/view_helpers.rb, line 101
101:       def flash_uploader_script(signature, options = {})
102:         result = ''
103:         result += %{
104:           <script type="text/javascript">
105:         }
106:         if options[:success_url]
107:           url = options[:success_url]
108:           url += url.include?('?') ? '&' : '?'
109:           url += "guid=" + signature.guid
110:           result += "var successURL = '#{url}';"
111:         end
112:         result += %{
113:           var swfu;
114:           window.onload = function () {
115:             swfu = new SWFUpload({
116:               upload_url: "http://#{signature.bucket}.s3.amazonaws.com/",
117:               http_success : [201], 
118:               assume_success_timeout : 0,
119:               // File Upload Settings
120:               file_post_name: 'file',
121:               file_types : "*.*",
122:               file_types_description : "All Files",
123:               file_upload_limit : "10",
124:               file_queue_limit : 0,
125:               // Event Handler Settings - these functions as defined in handlers.js
126:               file_queued_handler : fileQueued,
127:               file_queue_error_handler : fileQueueError,
128:               file_dialog_complete_handler : fileDialogComplete,
129:               upload_start_handler : uploadStart,
130:               upload_progress_handler : uploadProgress,
131:               upload_error_handler : uploadError,
132:               upload_success_handler : uploadSuccess,
133:               upload_complete_handler : uploadComplete,
134:               // Button Settings
135:               button_width: "65",
136:               button_height: "29",
137:               button_placeholder_id: "spanButtonPlaceHolder",
138:               button_text: '<span class="theFont">Browse</span>',
139:               button_text_style: ".theFont { font-size: 16; }",
140:               button_text_left_padding: 6,
141:               button_text_top_padding: 3,
142:               button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
143:               button_cursor: SWFUpload.CURSOR.HAND,
144:               moving_average_history_size: 10,
145:               // Flash Settings
146:               flash_url : "/flash/vzaar/swfupload.swf",
147:               flash9_url : "/flash/vzaar/swfupload_fp9.swf",
148:               custom_settings : {
149:                 progressTarget : "fsUploadProgress",
150:                 uploaded_files : []
151:               },
152:               // Debug Settings
153:               debug: false
154:             });
155:           };
156:           </script>
157:         }
158:         result
159:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.