thin_upload 0.0.1.pre1
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.
- data/Gemfile +7 -0
- data/Gemfile.lock +31 -0
- data/Manifest +44 -0
- data/README.rdoc +40 -0
- data/Rakefile +33 -0
- data/html/README_rdoc.html +133 -0
- data/html/Thin.html +149 -0
- data/html/Thin/Request.html +537 -0
- data/html/Thin/Server.html +194 -0
- data/html/created.rid +4 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +124 -0
- data/html/js/darkfish.js +116 -0
- data/html/js/jquery.js +32 -0
- data/html/js/quicksearch.js +114 -0
- data/html/js/thickbox-compressed.js +10 -0
- data/html/lib/thin_upload/parser_rb.html +54 -0
- data/html/lib/thin_upload/request_rb.html +54 -0
- data/html/lib/thin_upload_rb.html +54 -0
- data/html/rdoc.css +763 -0
- data/lib/thin_upload.rb +3 -0
- data/lib/thin_upload/request.rb +93 -0
- data/test/test_helper.rb +30 -0
- data/test/thin_upload/request_test.rb +91 -0
- data/thin_upload.gemspec +33 -0
- metadata +111 -0
@@ -0,0 +1,194 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
5
|
+
<head>
|
6
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
7
|
+
|
8
|
+
<title>Class: Thin::Server</title>
|
9
|
+
|
10
|
+
<link rel="stylesheet" href="../rdoc.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="../js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
13
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="../js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="../js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
|
17
|
+
</head>
|
18
|
+
<body id="top" class="class">
|
19
|
+
|
20
|
+
<div id="metadata">
|
21
|
+
<div id="home-metadata">
|
22
|
+
<div id="home-section" class="section">
|
23
|
+
<h3 class="section-header">
|
24
|
+
<a href="../index.html">Home</a>
|
25
|
+
<a href="../index.html#classes">Classes</a>
|
26
|
+
<a href="../index.html#methods">Methods</a>
|
27
|
+
</h3>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div id="file-metadata">
|
32
|
+
<div id="file-list-section" class="section">
|
33
|
+
<h3 class="section-header">In Files</h3>
|
34
|
+
<div class="section-body">
|
35
|
+
<ul>
|
36
|
+
|
37
|
+
<li><a href="../lib/thin_upload/request_rb.html?TB_iframe=true&height=550&width=785"
|
38
|
+
class="thickbox" title="lib/thin_upload/request.rb">lib/thin_upload/request.rb</a></li>
|
39
|
+
|
40
|
+
</ul>
|
41
|
+
</div>
|
42
|
+
</div>
|
43
|
+
|
44
|
+
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<div id="class-metadata">
|
48
|
+
|
49
|
+
<!-- Parent Class -->
|
50
|
+
<div id="parent-class-section" class="section">
|
51
|
+
<h3 class="section-header">Parent</h3>
|
52
|
+
|
53
|
+
<p class="link">Object</p>
|
54
|
+
|
55
|
+
</div>
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
<!-- Method Quickref -->
|
64
|
+
<div id="method-list-section" class="section">
|
65
|
+
<h3 class="section-header">Methods</h3>
|
66
|
+
<ul class="link-list">
|
67
|
+
|
68
|
+
<li><a href="#method-c-progress">::progress</a></li>
|
69
|
+
|
70
|
+
</ul>
|
71
|
+
</div>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
</div>
|
76
|
+
|
77
|
+
<div id="project-metadata">
|
78
|
+
|
79
|
+
|
80
|
+
<div id="fileindex-section" class="section project-section">
|
81
|
+
<h3 class="section-header">Files</h3>
|
82
|
+
<ul>
|
83
|
+
|
84
|
+
<li class="file"><a href="../README_rdoc.html">README.rdoc</a></li>
|
85
|
+
|
86
|
+
</ul>
|
87
|
+
</div>
|
88
|
+
|
89
|
+
|
90
|
+
<div id="classindex-section" class="section project-section">
|
91
|
+
<h3 class="section-header">Class/Module Index
|
92
|
+
<span class="search-toggle"><img src="../images/find.png"
|
93
|
+
height="16" width="16" alt="[+]"
|
94
|
+
title="show/hide quicksearch" /></span></h3>
|
95
|
+
<form action="#" method="get" accept-charset="utf-8" class="initially-hidden">
|
96
|
+
<fieldset>
|
97
|
+
<legend>Quicksearch</legend>
|
98
|
+
<input type="text" name="quicksearch" value=""
|
99
|
+
class="quicksearch-field" />
|
100
|
+
</fieldset>
|
101
|
+
</form>
|
102
|
+
|
103
|
+
<ul class="link-list">
|
104
|
+
|
105
|
+
<li><a href="../Thin.html">Thin</a></li>
|
106
|
+
|
107
|
+
<li><a href="../Thin/Request.html">Thin::Request</a></li>
|
108
|
+
|
109
|
+
<li><a href="../Thin/Server.html">Thin::Server</a></li>
|
110
|
+
|
111
|
+
</ul>
|
112
|
+
<div id="no-class-search-results" style="display: none;">No matching classes.</div>
|
113
|
+
</div>
|
114
|
+
|
115
|
+
|
116
|
+
</div>
|
117
|
+
</div>
|
118
|
+
|
119
|
+
<div id="documentation">
|
120
|
+
<h1 class="class">Thin::Server</h1>
|
121
|
+
|
122
|
+
<div id="description" class="description">
|
123
|
+
|
124
|
+
<p>Thin’s server class</p>
|
125
|
+
|
126
|
+
</div><!-- description -->
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
<div id="5Buntitled-5D" class="documentation-section">
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<!-- Methods -->
|
141
|
+
|
142
|
+
<div id="public-class-method-details" class="method-section section">
|
143
|
+
<h3 class="section-header">Public Class Methods</h3>
|
144
|
+
|
145
|
+
|
146
|
+
<div id="progress-method" class="method-detail ">
|
147
|
+
<a name="method-c-progress"></a>
|
148
|
+
|
149
|
+
|
150
|
+
<div class="method-heading">
|
151
|
+
<span class="method-name">progress</span><span
|
152
|
+
class="method-args">()</span>
|
153
|
+
<span class="method-click-advice">click to toggle source</span>
|
154
|
+
</div>
|
155
|
+
|
156
|
+
|
157
|
+
<div class="method-description">
|
158
|
+
|
159
|
+
<p>adding a hash to store all the upload progress in the server</p>
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
<div class="method-source-code" id="progress-source">
|
164
|
+
<pre>
|
165
|
+
<span class="ruby-comment"># File lib/thin_upload/request.rb, line 91</span>
|
166
|
+
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">progress</span>
|
167
|
+
<span class="ruby-identifier">@@progress</span><span class="ruby-operator">||=</span>{}
|
168
|
+
<span class="ruby-keyword">end</span></pre>
|
169
|
+
</div><!-- progress-source -->
|
170
|
+
|
171
|
+
</div>
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
</div><!-- progress-method -->
|
177
|
+
|
178
|
+
|
179
|
+
</div><!-- public-class-method-details -->
|
180
|
+
|
181
|
+
</div><!-- 5Buntitled-5D -->
|
182
|
+
|
183
|
+
|
184
|
+
</div><!-- documentation -->
|
185
|
+
|
186
|
+
<div id="validator-badges">
|
187
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
188
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
189
|
+
Rdoc Generator</a> 2</small>.</p>
|
190
|
+
</div>
|
191
|
+
|
192
|
+
</body>
|
193
|
+
</html>
|
194
|
+
|
data/html/created.rid
ADDED
Binary file
|
Binary file
|
data/html/images/bug.png
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/html/index.html
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>RDoc Documentation</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="js/jquery.js" type="text/javascript" charset="utf-8"></script>
|
14
|
+
<script src="js/thickbox-compressed.js" type="text/javascript" charset="utf-8"></script>
|
15
|
+
<script src="js/quicksearch.js" type="text/javascript" charset="utf-8"></script>
|
16
|
+
<script src="js/darkfish.js" type="text/javascript" charset="utf-8"></script>
|
17
|
+
|
18
|
+
</head>
|
19
|
+
<body class="indexpage">
|
20
|
+
|
21
|
+
|
22
|
+
<h1>RDoc Documentation</h1>
|
23
|
+
|
24
|
+
|
25
|
+
<div id="main">
|
26
|
+
|
27
|
+
<p><a href="http://travis-ci.org/dombesz/thin_upload"><img
|
28
|
+
src="http://travis-ci.org/dombesz/thin_upload.png" /></a></p>
|
29
|
+
|
30
|
+
|
31
|
+
<pre>gem install thin_upload --pre</pre>
|
32
|
+
|
33
|
+
<h1>Usage</h1>
|
34
|
+
|
35
|
+
<p>In your Gemfile</p>
|
36
|
+
|
37
|
+
<pre>gem "thin"
|
38
|
+
gem "thin_upload", "~> 0.0.1.pre"</pre>
|
39
|
+
|
40
|
+
<p>Note: Works only with thin server!</p>
|
41
|
+
|
42
|
+
<p>Upload progress is available for any file upload request.</p>
|
43
|
+
|
44
|
+
<p>Example:</p>
|
45
|
+
|
46
|
+
<pre><iframe id="upload_frame" name="upload_frame" style="width: 0px; height: 0px;"></iframe>
|
47
|
+
|
48
|
+
<%= form_tag(photos_path, {:multipart => true ,:target=>"upload_frame"}) do %>
|
49
|
+
<%= text_field_tag :uuid, UUID.new.generate %>
|
50
|
+
<%= file_field_tag :file %>
|
51
|
+
<p><%= submit_tag "Continue &rarr;".html_safe, :id=>'submit_form' %></p>
|
52
|
+
<% end %></pre>
|
53
|
+
|
54
|
+
<p>To have progress tracking, we need to send a +uuid param in the submited
|
55
|
+
form, and the +uuid param MUST be before the file field.</p>
|
56
|
+
|
57
|
+
<p>If you want to ask for progress use get request.</p>
|
58
|
+
|
59
|
+
<pre>$.getJSON('/progress?uuid='+$("#uuid").attr('value'),function(response){
|
60
|
+
//process response
|
61
|
+
}</pre>
|
62
|
+
|
63
|
+
<p>While your upload is processing you can request the progress from rack.</p>
|
64
|
+
|
65
|
+
<pre>@progress = request.env['rack.progress'][params[:uuid]]
|
66
|
+
@progress is an integer in range 0..100 or nil if doesn't exists</pre>
|
67
|
+
|
68
|
+
<p>Note: This is just an experiment, so I don’t know if it’s production ready.
|
69
|
+
Any suggestions are welcome.</p>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
<h2>Files</h2>
|
77
|
+
<ul>
|
78
|
+
|
79
|
+
<li class="file"><a href="README_rdoc.html">README.rdoc</a></li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
|
83
|
+
|
84
|
+
<h2 id="classes">Classes/Modules</h2>
|
85
|
+
<ul>
|
86
|
+
|
87
|
+
<li class="module"><a href="Thin.html">Thin</a></li>
|
88
|
+
|
89
|
+
<li class="class"><a href="Thin/Request.html">Thin::Request</a></li>
|
90
|
+
|
91
|
+
<li class="class"><a href="Thin/Server.html">Thin::Server</a></li>
|
92
|
+
|
93
|
+
</ul>
|
94
|
+
|
95
|
+
<h2 id="methods">Methods</h2>
|
96
|
+
<ul>
|
97
|
+
|
98
|
+
<li><a href="Thin/Server.html#method-c-progress">::progress — Thin::Server</a></li>
|
99
|
+
|
100
|
+
<li><a href="Thin/Request.html#method-i-cleanup_progress_hash">#cleanup_progress_hash — Thin::Request</a></li>
|
101
|
+
|
102
|
+
<li><a href="Thin/Request.html#method-i-new_parse">#new_parse — Thin::Request</a></li>
|
103
|
+
|
104
|
+
<li><a href="Thin/Request.html#method-i-parse">#parse — Thin::Request</a></li>
|
105
|
+
|
106
|
+
<li><a href="Thin/Request.html#method-i-progress">#progress — Thin::Request</a></li>
|
107
|
+
|
108
|
+
<li><a href="Thin/Request.html#method-i-scan_content">#scan_content — Thin::Request</a></li>
|
109
|
+
|
110
|
+
<li><a href="Thin/Request.html#method-i-store_progress">#store_progress — Thin::Request</a></li>
|
111
|
+
|
112
|
+
<li><a href="Thin/Request.html#method-i-thin_parse">#thin_parse — Thin::Request</a></li>
|
113
|
+
|
114
|
+
<li><a href="Thin/Request.html#method-i-uuid_found_or_limit_reached-3F">#uuid_found_or_limit_reached? — Thin::Request</a></li>
|
115
|
+
|
116
|
+
</ul>
|
117
|
+
|
118
|
+
<div id="validator-badges">
|
119
|
+
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
120
|
+
<p><small>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish
|
121
|
+
Rdoc Generator</a> 2</small>.</p>
|
122
|
+
</div>
|
123
|
+
</body>
|
124
|
+
</html>
|
data/html/js/darkfish.js
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Darkfish Page Functions
|
4
|
+
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
+
*
|
6
|
+
* Author: Michael Granger <mgranger@laika.com>
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* Provide console simulation for firebug-less environments */
|
11
|
+
if (!("console" in window) || !("firebug" in console)) {
|
12
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
13
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
14
|
+
|
15
|
+
window.console = {};
|
16
|
+
for (var i = 0; i < names.length; ++i)
|
17
|
+
window.console[names[i]] = function() {};
|
18
|
+
};
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Unwrap the first element that matches the given @expr@ from the targets and return them.
|
23
|
+
*/
|
24
|
+
$.fn.unwrap = function( expr ) {
|
25
|
+
return this.each( function() {
|
26
|
+
$(this).parents( expr ).eq( 0 ).after( this ).remove();
|
27
|
+
});
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
function showSource( e ) {
|
32
|
+
var target = e.target;
|
33
|
+
var codeSections = $(target).
|
34
|
+
parents('.method-detail').
|
35
|
+
find('.method-source-code');
|
36
|
+
|
37
|
+
$(target).
|
38
|
+
parents('.method-detail').
|
39
|
+
find('.method-source-code').
|
40
|
+
slideToggle();
|
41
|
+
};
|
42
|
+
|
43
|
+
function hookSourceViews() {
|
44
|
+
$('.method-description,.method-heading').click( showSource );
|
45
|
+
};
|
46
|
+
|
47
|
+
function toggleDebuggingSection() {
|
48
|
+
$('.debugging-section').slideToggle();
|
49
|
+
};
|
50
|
+
|
51
|
+
function hookDebuggingToggle() {
|
52
|
+
$('#debugging-toggle img').click( toggleDebuggingSection );
|
53
|
+
};
|
54
|
+
|
55
|
+
function hookQuickSearch() {
|
56
|
+
$('.quicksearch-field').each( function() {
|
57
|
+
var searchElems = $(this).parents('.section').find( 'li' );
|
58
|
+
var toggle = $(this).parents('.section').find('h3 .search-toggle');
|
59
|
+
// console.debug( "Toggle is: %o", toggle );
|
60
|
+
var qsbox = $(this).parents('form').get( 0 );
|
61
|
+
|
62
|
+
$(this).quicksearch( this, searchElems, {
|
63
|
+
noSearchResultsIndicator: 'no-class-search-results',
|
64
|
+
focusOnLoad: false
|
65
|
+
});
|
66
|
+
$(toggle).click( function() {
|
67
|
+
// console.debug( "Toggling qsbox: %o", qsbox );
|
68
|
+
$(qsbox).toggle();
|
69
|
+
});
|
70
|
+
});
|
71
|
+
};
|
72
|
+
|
73
|
+
function highlightTarget( anchor ) {
|
74
|
+
console.debug( "Highlighting target '%s'.", anchor );
|
75
|
+
|
76
|
+
$("a[name=" + anchor + "]").each( function() {
|
77
|
+
if ( !$(this).parent().parent().hasClass('target-section') ) {
|
78
|
+
console.debug( "Wrapping the target-section" );
|
79
|
+
$('div.method-detail').unwrap( 'div.target-section' );
|
80
|
+
$(this).parent().wrap( '<div class="target-section"></div>' );
|
81
|
+
} else {
|
82
|
+
console.debug( "Already wrapped." );
|
83
|
+
}
|
84
|
+
});
|
85
|
+
};
|
86
|
+
|
87
|
+
function highlightLocationTarget() {
|
88
|
+
console.debug( "Location hash: %s", window.location.hash );
|
89
|
+
if ( ! window.location.hash || window.location.hash.length == 0 ) return;
|
90
|
+
|
91
|
+
var anchor = window.location.hash.substring(1);
|
92
|
+
console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" );
|
93
|
+
|
94
|
+
highlightTarget( anchor );
|
95
|
+
};
|
96
|
+
|
97
|
+
function highlightClickTarget( event ) {
|
98
|
+
console.debug( "Highlighting click target for event %o", event.target );
|
99
|
+
try {
|
100
|
+
var anchor = $(event.target).attr( 'href' ).substring(1);
|
101
|
+
console.debug( "Found target anchor: %s", anchor );
|
102
|
+
highlightTarget( anchor );
|
103
|
+
} catch ( err ) {
|
104
|
+
console.error( "Exception while highlighting: %o", err );
|
105
|
+
};
|
106
|
+
};
|
107
|
+
|
108
|
+
|
109
|
+
$(document).ready( function() {
|
110
|
+
hookSourceViews();
|
111
|
+
hookDebuggingToggle();
|
112
|
+
hookQuickSearch();
|
113
|
+
highlightLocationTarget();
|
114
|
+
|
115
|
+
$('ul.link-list a').bind( "click", highlightClickTarget );
|
116
|
+
});
|