Skip to content

Commit db4d39f

Browse files
committed
Initial
0 parents  commit db4d39f

26 files changed

+2754
-0
lines changed

.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.pyc
2+
*~
3+
*.swp
4+
*.swo
5+
.project
6+
.pydevproject
7+
.settings/*
8+
9+
MINDS
10+
11+
.hg/*
12+
.hgignore

LICENSE

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Copyright (C) 2012, Cyrill Popov
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7+
the Software, and to permit persons to whom the Software is furnished to do so,
8+
subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Yet another plugin for uploading files to the server using Django and JQuery.
2+
3+
Based on jQuery-File-Upload written by Sebastian Tschan (https://github.com/blueimp/jQuery-File-Upload).
4+
5+
The project is still in its infancy.

jquery_uploader/__init__.py

Whitespace-only changes.

jquery_uploader/management/__init__.py

Whitespace-only changes.

jquery_uploader/management/commands/__init__.py

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# -*- coding: utf-8 -*-
2+
import datetime, os
3+
4+
from django.core.management.base import NoArgsCommand
5+
6+
from jquery_uploader.settings import *
7+
8+
9+
class Command(NoArgsCommand):
10+
def handle_noargs(self, **options):
11+
days_diff = datetime.datetime.today() - datetime.timedelta(days=uploader_days_diff)
12+
files = os.listdir(uploader_root)
13+
for name in files:
14+
full_name = os.path.join(uploader_root, name)
15+
file_date = datetime.datetime.fromtimestamp(os.stat(full_name).st_mtime)
16+
if file_date < days_diff:
17+
print 'Delete %s' % full_name
18+
os.unlink(full_name)

jquery_uploader/settings.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
from django.conf import settings
4+
5+
uploader_days_diff = getattr(settings, 'JQUERY_UPLOADER_DAYS_DIFF', 1)
6+
7+
uploader_root_rel = getattr(settings, 'JQUERY_UPLOADER_ROOT', 'jquery_uploader')
8+
uploader_root = os.path.join(settings.MEDIA_ROOT, uploader_root_rel)
9+
10+
uploader_url = os.path.join(settings.MEDIA_URL, getattr(settings, 'JQUERY_UPLOADER_URL', 'jquery_uploader'))
11+
12+
if not os.path.exists(uploader_root):
13+
os.makedirs(uploader_root)
14+
15+
uploader_size = getattr(settings, 'JQUERY_UPLOADER_THUMB_SIZE', (80, 80))
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
/*
2+
* jQuery File Upload jQuery UI Plugin 1.2
3+
* https://github.com/blueimp/jQuery-File-Upload
4+
*
5+
* Copyright 2012, Sebastian Tschan
6+
* https://blueimp.net
7+
*
8+
* Licensed under the MIT license:
9+
* http://www.opensource.org/licenses/MIT
10+
*/
11+
12+
/*jslint nomen: true */
13+
/*global define, window */
14+
15+
(function (factory) {
16+
'use strict';
17+
if (typeof define === 'function' && define.amd) {
18+
// Register as an anonymous AMD module:
19+
define(['jquery', './jquery.fileupload-ui.js'], factory);
20+
} else {
21+
// Browser globals:
22+
factory(window.jQuery);
23+
}
24+
}(function ($) {
25+
'use strict';
26+
$.widget('blueimpJUI.fileupload', $.blueimpUI.fileupload, {
27+
options: {
28+
sent: function (e, data) {
29+
if (data.context && data.dataType &&
30+
data.dataType.substr(0, 6) === 'iframe') {
31+
// Iframe Transport does not support progress events.
32+
// In lack of an indeterminate progress bar, we set
33+
// the progress to 100%, showing the full animated bar:
34+
data.context
35+
.find('.progress').progressbar(
36+
'option',
37+
'value',
38+
100
39+
);
40+
}
41+
},
42+
progress: function (e, data) {
43+
if (data.context) {
44+
data.context.find('.progress').progressbar(
45+
'option',
46+
'value',
47+
parseInt(data.loaded / data.total * 100, 10)
48+
);
49+
}
50+
},
51+
progressall: function (e, data) {
52+
var $this = $(this);
53+
$this.find('.fileupload-progress')
54+
.find('.progress').progressbar(
55+
'option',
56+
'value',
57+
parseInt(data.loaded / data.total * 100, 10)
58+
).end()
59+
.find('.progress-extended').each(function () {
60+
$(this).html(
61+
$this.data('fileupload')
62+
._renderExtendedProgress(data)
63+
);
64+
});
65+
}
66+
},
67+
_renderUpload: function (func, files) {
68+
var node = $.blueimpUI.fileupload.prototype
69+
._renderUpload.call(this, func, files),
70+
showIconText = $(window).width() > 480;
71+
node.find('.progress').empty().progressbar();
72+
node.find('.start button').button({
73+
icons: {primary: 'ui-icon-circle-arrow-e'},
74+
text: showIconText
75+
});
76+
node.find('.cancel button').button({
77+
icons: {primary: 'ui-icon-cancel'},
78+
text: showIconText
79+
});
80+
return node;
81+
},
82+
_renderDownload: function (func, files) {
83+
var node = $.blueimpUI.fileupload.prototype
84+
._renderDownload.call(this, func, files),
85+
showIconText = $(window).width() > 480;
86+
node.find('.delete button').button({
87+
icons: {primary: 'ui-icon-trash'},
88+
text: showIconText
89+
});
90+
return node;
91+
},
92+
_transition: function (node) {
93+
var that = this,
94+
deferred = $.Deferred();
95+
if (node.hasClass('fade')) {
96+
node.fadeToggle(function () {
97+
deferred.resolveWith(node);
98+
});
99+
} else {
100+
deferred.resolveWith(node);
101+
}
102+
return deferred;
103+
},
104+
_create: function () {
105+
$.blueimpUI.fileupload.prototype._create.call(this);
106+
this.element
107+
.find('.fileupload-buttonbar')
108+
.find('.fileinput-button').each(function () {
109+
var input = $(this).find('input:file').detach();
110+
$(this)
111+
.button({icons: {primary: 'ui-icon-plusthick'}})
112+
.append(input);
113+
})
114+
.end().find('.start')
115+
.button({icons: {primary: 'ui-icon-circle-arrow-e'}})
116+
.end().find('.cancel')
117+
.button({icons: {primary: 'ui-icon-cancel'}})
118+
.end().find('.delete')
119+
.button({icons: {primary: 'ui-icon-trash'}})
120+
.end().find('.progress').empty().progressbar();
121+
},
122+
destroy: function () {
123+
this.element
124+
.find('.fileupload-buttonbar')
125+
.find('.fileinput-button').each(function () {
126+
var input = $(this).find('input:file').detach();
127+
$(this)
128+
.button('destroy')
129+
.append(input);
130+
})
131+
.end().find('.start')
132+
.button('destroy')
133+
.end().find('.cancel')
134+
.button('destroy')
135+
.end().find('.delete')
136+
.button('destroy')
137+
.end().find('.progress').progressbar('destroy');
138+
$.blueimpUI.fileupload.prototype.destroy.call(this);
139+
}
140+
});
141+
}));
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
@charset 'UTF-8';
2+
/*
3+
* jQuery File Upload UI Plugin CSS 6.3
4+
* https://github.com/blueimp/jQuery-File-Upload
5+
*
6+
* Copyright 2010, Sebastian Tschan
7+
* https://blueimp.net
8+
*
9+
* Licensed under the MIT license:
10+
* http://www.opensource.org/licenses/MIT
11+
*/
12+
13+
.fileinput-button {
14+
position: relative;
15+
overflow: hidden;
16+
float: left;
17+
margin-right: 5px;
18+
}
19+
.fileinput-button input {
20+
position: absolute;
21+
top: 0;
22+
right: 0;
23+
margin: 0;
24+
border: solid transparent;
25+
border-width: 0 0 100px 200px;
26+
opacity: 0;
27+
filter: alpha(opacity=0);
28+
-moz-transform: translate(-300px, 0) scale(4);
29+
direction: ltr;
30+
cursor: pointer;
31+
}
32+
.fileupload-buttonbar .ui-button,
33+
.fileupload-buttonbar .toggle {
34+
margin-bottom: 5px;
35+
}
36+
.files .progress {
37+
width: 200px;
38+
}
39+
.files .progress,
40+
.fileupload-buttonbar .progress {
41+
height: 20px;
42+
}
43+
.files .ui-progressbar-value,
44+
.fileupload-buttonbar .ui-progressbar-value {
45+
background: url(./jquery_uploader_progressbar.gif);
46+
}
47+
.fileupload-buttonbar .fade,
48+
.files .fade {
49+
display: none;
50+
}
51+
.fileupload-loading {
52+
position: absolute;
53+
left: 50%;
54+
width: 128px;
55+
height: 128px;
56+
background: url(./jquery_uploader_loading.gif) center no-repeat;
57+
display: none;
58+
}
59+
.fileupload-processing .fileupload-loading {
60+
display: block;
61+
}
62+
63+
/* Fix for IE 6: */
64+
*html .fileinput-button {
65+
margin-right: -2px;
66+
}
67+
*html .fileinput-button .ui-button-text {
68+
line-height: 24px;
69+
}
70+
*html .fileupload-buttonbar .ui-button {
71+
margin-left: 3px;
72+
}
73+
74+
/* Fix for IE 7: */
75+
*+html .fileinput-button {
76+
margin-right: 1px;
77+
}
78+
*+html .fileinput-button .ui-button-text {
79+
line-height: 24px;
80+
}
81+
*+html .fileupload-buttonbar .ui-button {
82+
margin-left: 3px;
83+
}
84+
85+
@media (max-width: 480px) {
86+
.files .preview * {
87+
width: 40px;
88+
}
89+
.files .name * {
90+
width: 80px;
91+
display: inline-block;
92+
word-wrap: break-word;
93+
}
94+
.files .progress {
95+
width: 20px;
96+
}
97+
.files .delete {
98+
width: 60px;
99+
}
100+
}
101+
102+
/* Fix for Webkit (Safari, Chrome) */
103+
@media screen and (-webkit-min-device-pixel-ratio:0) {
104+
.fileinput-button {
105+
margin-top: 2px;
106+
}
107+
}

0 commit comments

Comments
 (0)