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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://960.gs/css/reset.css" />
<link rel="stylesheet" href="http://960.gs/css/text.css" />
<link rel="stylesheet" href="http://960.gs/css/960.css" />
<link rel="stylesheet" type="text/css" media="all" href="{{url_for('static', filename='style.css')}}" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="{{url_for('static',filename='plupload/js/plupload.full.js')}}"></script>
<title>Fit</title>
</head>
<body>
<div id="header">
<h1><a href="/">Fit</a></h1>
<p>git clone {{url_for('static', filename='fit.git', _external=True)}}</p>
<form action="{{url_for('search')}}" method="get">
<input type="text" name="search" placeholder="Search for tags" />
<input type="submit" value="Search" />
</form>
</div>
<div id="content">
<ul class="flashes">
{% with messages = get_flashed_messages() %}
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
{% endwith %}
</ul>
<div id="container">
<h2>Upload</h2>
<form id="upload-form" method="POST" enctype="multipart/form-data" action="/">
<input type="file" name="file" />
<input type="text" name="tags" />
<input type="submit" />
</form>
<ul id="filelist"><li>No runtime found.</li></ul>
</div>
{% block body %}{% endblock %}
</div>
</body>
</html>
<script type="text/javascript">
// Custom example logic
$(function() {
var uploader = new plupload.Uploader({
runtimes : 'html5,flash,html4,silverlight',
browse_button : 'pickfiles',
container : 'container',
max_file_size : '10mb',
url : '{{url_for('index')}}',
flash_swf_url : '{{url_for('static',filename='plupload/js/plupload.flash.swf')}}',
silverlight_xap_url : '{{url_for('static',filename='plupload/js/plupload.silverlight.xap')}}',
multipart_params: {},
filters : [
{title : "Image files", extensions : "jpg,gif,png"},
{title : "Zip files", extensions : "zip"}
],
});
uploader.bind('Init', function(up, params) {
console.log("using runtime: " + params.runtime);
$('#upload-form').html('<p id="modern-form">'+
' <a id="pickfiles" href="#">Add files</a>|'+
' <a id="uploadfiles" href="#">Upload</a>'+
'</p>');
$('#filelist').html('<li id="no-files">No Files Added</li>');
});
$('#uploadfiles').live('click', function(e) {
uploader.start();
e.preventDefault();
});
uploader.init();
uploader.bind('BeforeUpload', function(up, file) {
uploader.settings.multipart_params.tags = $('input[name='+file.id +']').val();
});
uploader.bind('FilesAdded', function(up, files) {
$('#no-files').remove()
$.each(files, function(i, file) {
$('#filelist').append(
'<li id="' + file.id + '">' +
'<label for="">' +
file.name + ' (' + plupload.formatSize(file.size) + ')' +
'</label>' +
'<input type="text" placeholder="Tag" name="'+file.id+'" />' +
'<b></b>' +
'</li>');
});
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('UploadProgress', function(up, file) {
$('#' + file.id + " input").attr('disabled', true);
$('#' + file.id + " b").html(file.percent + "%");
});
uploader.bind('Error', function(up, err) {
$('#filelist').append("<div>Error: " + err.code +
", Message: " + err.message +
(err.file ? ", File: " + err.file.name : "") +
"</div>"
);
up.refresh(); // Reposition Flash/Silverlight
});
uploader.bind('FileUploaded', function(up, file) {
console.log(file);
});
});
</script>
|