upr.git  about / heads / tags
Upload Progress for Rack
blob cf0958a014f2fb40b7f87bac5b68f8aede954ffd 1911 bytes (raw)
$ git show HEAD:examples/rails_app-2.3.4/app/views/files/pull.html.erb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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
 
<html>
  <head>
<!-- http://rubyforge.org/pipermail/mongrel-users/2007-July/003747.html -->
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <title>streaming upload progress test</title>
    <%= javascript_include_tag 'ajax_pull/prototype-1_5_1.js' %>
    <%= javascript_include_tag 'ajax_pull/ajax_pull.js' %>
    <%= javascript_include_tag 'ajax_pull/upload_progress.js' %>
  </head>
  <body>
<%
upid = "#{Time.now.to_i}.#{rand}"
act = { :action => 'pull', :upload_id => upid }
opt = {
  :multipart => true,
  :target => 'upload-target',
  :onsubmit => "UploadProgress.begin('#{upid}')"
}
-%>

    <% if flash[:notice] %>
      <div class="notice"><%= flash[:notice] %></div>
    <% end %>
<p>
  This is a demo of <a href="http://upr.bogomips.org/">upr</a> in action
  with Ajax.Pull.  It only uses a single, streaming AJAX request instead
  of pulling.  It is based on <a
  href="http://rubyforge.org/pipermail/mongrel-users/2007-July/003747.html"
  >mongrel_<b>streaming</b>_upload_progress</a>
</p>
<p>
  This is different from the polling
  <a href="/">mongrel_upload_progress-compatible</a> version
  and also different from the polling
  <a href="/files/new">jQuery+nginx/lighttpd-compatible</a> version
</p>

    <p><%= link_to "#{upid} (single)",
          :action => 'status', :upload_id => upid %></p>
    <p><%= link_to "#{upid} (stream)",
           "/progress?long&upload_id=#{upid}" %></p>

    <% form_tag(act, opt) do %>
      <div><p><%= file_field_tag :data %></p></div>
      <p><%= submit_tag :Upload %></p>
    <% end %>

    <p>Below is the results <code>div</code></p>
    <div id="results">(nothing)</div>

    <p>Below is the progress bar <code>div</code></p>
    <div id="progress-bar"></div>

    <p>Below is the debug list</p>
    <ol id="debug"></ol>

    <iframe id="upload-target" name="upload-target" src="about:blank"></iframe>

  </body>
</html>

git clone https://yhbt.net/upr.git