summaryrefslogtreecommitdiffstats
path: root/module/web
diff options
context:
space:
mode:
authorGravatar therazer <devnull@localhost> 2010-11-09 21:30:54 +0100
committerGravatar therazer <devnull@localhost> 2010-11-09 21:30:54 +0100
commitfa078c84b81f891aa800ca602fbc7d7ec3d02753 (patch)
tree8431575a6a27dab13700b538ccc4e94cba2e9c87 /module/web
parentaccount reloadData fix (diff)
downloadpyload-fa078c84b81f891aa800ca602fbc7d7ec3d02753.tar.xz
added browser for files, too + little patches
Diffstat (limited to 'module/web')
-rw-r--r--module/web/media/default/css/pathchooser.css19
-rw-r--r--module/web/pyload/urls.py6
-rw-r--r--module/web/pyload/views.py33
-rw-r--r--module/web/templates/default/pathchooser.html29
-rw-r--r--module/web/templates/default/settings.html9
5 files changed, 69 insertions, 27 deletions
diff --git a/module/web/media/default/css/pathchooser.css b/module/web/media/default/css/pathchooser.css
index 2573c2eb1..f660b7c5a 100644
--- a/module/web/media/default/css/pathchooser.css
+++ b/module/web/media/default/css/pathchooser.css
@@ -1,24 +1,33 @@
-TABLE {
+table {
border: 1px dotted #888888;
font-family: sans-serif;
font-size: 10pt;
}
-TH {
+th {
background-color: #525252;
color: #E0E0E0;
}
-TABLE, TR, TD {
+table, tr, td {
background-color: #F0F0F0;
}
-A, A:visited {
+a, a:visited {
text-decoration: none;
font-weight: bold;
}
-.file {
+.file_directory {
+ color: #c0c0c0;
+}
+.path_directory {
+ color: #3c3c3c;
+}
+.file_file {
+ color: #3c3c3c;
+}
+.path_file {
color: #c0c0c0;
}
diff --git a/module/web/pyload/urls.py b/module/web/pyload/urls.py
index 6523d711a..fe85c1096 100644
--- a/module/web/pyload/urls.py
+++ b/module/web/pyload/urls.py
@@ -17,8 +17,10 @@ urlpatterns = patterns('pyload',
(r'^logs/(?P<item>\d+)$', 'views.logs',{}, 'logs'),
(r'^package_ui.js$', 'views.package_ui', {}, 'package_ui'),
(r'^$', 'views.home',{}, 'home'),
- url(r'^pathchooser/(?P<path>.*)', 'views.path', name='path'),
- url(r'^pathchooser/$', 'views.root', name='root'),
+ url(r'^pathchooser/(?P<path>.*)', 'views.path', {'type':'folder'}, name='path'),
+ url(r'^pathchooser/$', 'views.root', {'type':'folder'}, name='pathroot'),
+ url(r'^filechooser/(?P<path>.*)', 'views.path', {'type':'file'}, name='file'),
+ url(r'^filechooser/$', 'views.root', {'type':'file'}, name='fileroot'),
)
urlpatterns += patterns('django.contrib.auth',
diff --git a/module/web/pyload/views.py b/module/web/pyload/views.py
index a9d3830ed..09bb72704 100644
--- a/module/web/pyload/views.py
+++ b/module/web/pyload/views.py
@@ -379,21 +379,26 @@ def package_ui(request):
@login_required
@permission('pyload.can_change_status')
@check_server
-def root(request):
+def root(request, type):
cwd = os.getcwd()
- return HttpResponseRedirect(reverse('path', args=[cwd[1:]]))
+ return HttpResponseRedirect(reverse('path', args=[cwd[1:], type]))
@login_required
@permission('pyload.can_change_status')
@check_server
-def path(request, path):
+def path(request, path, type):
- files = []
+ if os.path.isfile(path):
+ oldfile = path
+ path = os.path.dirname(path)
+ else:
+ oldfile = ''
+
if os.path.isdir(path):
cwd = path
else:
cwd = os.getcwd()
-
+
if cwd[-1] == '/':
parentdir = os.path.split(cwd[:-1])[0]
else:
@@ -403,19 +408,21 @@ def path(request, path):
folders = os.listdir(cwd)
except:
folders = []
-
+
+ files = []
+
for f in folders:
- data = {'name': f[:50],
- 'size': '',
- 'modified': '',
- 'type': 'file',
- 'fullpath': ''}
+ data = {}
+ data['name']: f
data['fullpath'] = os.path.join(cwd, f)
data['sort'] = data['fullpath'].lower()
data['modified'] = datetime.fromtimestamp(int(os.path.getmtime(os.path.join(cwd, f))))
data['ext'] = os.path.splitext(f)[1]
+
if os.path.isdir(os.path.join(cwd, f)):
data['type'] = 'dir'
+ else:
+ data['type'] = 'file'
if os.path.isfile(os.path.join(cwd, f)):
data['size'] = os.path.getsize(os.path.join(cwd, f))
@@ -426,11 +433,13 @@ def path(request, path):
data['size'] = data['size'] / 1024.
units = ('', 'K','M','G','T')
data['unit'] = units[power]+'Byte'
+ else:
+ data['size'] = ''
files.append(data)
files = sorted(files, key=itemgetter('type', 'sort'))
- return render_to_response(join(settings.TEMPLATE, 'pathchooser.html'), {'cwd': cwd, 'files': files, 'parentdir': parentdir}, RequestContext(request))
+ return render_to_response(join(settings.TEMPLATE, 'pathchooser.html'), {'cwd': cwd, 'files': files, 'parentdir': parentdir, 'type': type, 'oldfile': oldfile}, RequestContext(request))
diff --git a/module/web/templates/default/pathchooser.html b/module/web/templates/default/pathchooser.html
index 3c5329f09..100754cad 100644
--- a/module/web/templates/default/pathchooser.html
+++ b/module/web/templates/default/pathchooser.html
@@ -11,16 +11,29 @@
{
close();
}
+ function setInvalid() {
+ document.forms[0].send.disabled = 'disabled';
+ document.forms[0].p.style.color = '#FF0000';
+ }
+ function setValid() {
+ document.forms[0].send.disabled = '';
+ document.forms[0].p.style.color = '#000000';
+ }
+ function setFile(file)
+ {
+ document.forms[0].p.value = file;
+ setValid();
+
+ }
</script>
<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}css/pathchooser.css"/>
</head>
-<body>
+<body{% ifequal type 'file' %}{% if not oldfile %} onload="setInvalid();"{% endif %}{% endifequal %}>
<center>
<form method="get" action="?" onSubmit="chosen();" onReset="exit();">
- <input type="text" name="p" value="{{ cwd }}" size="60">
- <input type="submit" value="Ok">
+ <input type="text" name="p" value="{{ oldfile|default:cwd }}" size="60" onfocus="setValid();">
+ <input type="submit" value="Ok" name="send">
</form>
-
<table border="0" cellspacing="0" cellpadding="3" width="90%">
<tr>
<th>Name</th>
@@ -30,12 +43,16 @@
</tr>
<tr>
<td colspan="4">
- <a href="{% url path parentdir %}"><span class="parentdir">parent directory</span></a>
+ <a href="{% ifequal type 'folder' %}{% url path parentdir %}{% else %}{% url file parentdir %}{% endifequal %}"><span class="parentdir">parent directory</span></a>
</td>
</tr>
{% for file in files %}
<tr>
- <td class="name">{% ifequal file.type 'dir' %}<a href="{% url path file.fullpath %}"><span class="directory">{{ file.name|truncate:25 }}</a></span>{% else %}<span class="file">{{ file.name|truncate:25 }}{% endifequal %}</span></td>
+ {% ifequal type 'folder' %}
+ <td class="name">{% ifequal file.type 'dir' %}<a href="{% url path file.fullpath %}" title="{{ file.fullpath }}"><span class="path_directory">{{ file.name|truncate:25 }}</span></a>{% else %}<span class="path_file">{{ file.name|truncate:25 }}{% endifequal %}</span></td>
+ {% else %}
+ <td class="name">{% ifequal file.type 'dir' %}<a href="{% url file file.fullpath %}" title="{{ file.fullpath }}"><span class="file_directory">{{ file.name|truncate:25 }}</span></a>{% else %}<a href="#" onclick="setFile('{{ file.fullpath }}');" title="{{ file.fullpath }}"><span class="file_file">{{ file.name|truncate:25 }}{% endifequal %}</span></a></td>
+ {% endifequal %}
<td class="size">{{ file.size|floatformat:-2 }} {{ file.unit }}</td>
<td class="type">{% ifequal file.type 'dir' %}directory{% else %}{{ file.ext }}{% endifequal %}</td>
<td class="mtime">{{ file.modified|date:"d.m.Y - H:i:s" }}</td>
diff --git a/module/web/templates/default/settings.html b/module/web/templates/default/settings.html
index ab1a445db..79ec62d19 100644
--- a/module/web/templates/default/settings.html
+++ b/module/web/templates/default/settings.html
@@ -116,9 +116,14 @@
{% else %}
{% ifequal option.type "folder" %}
<input name="{{configname}}|{{skey}}|{{okey}}" type="text" id="{{skey}}|{{okey}}" value="{{option.value}}"/>
- <input name="browsebutton" type="button" onClick="ifield = document.getElementById('{{skey}}|{{okey}}'); pathchooser = window.open('{% if option.value %}{% url path option.value %}{% else %}{% url root %}{% endif %}', 'pathchooser', 'scrollbars=yes,toolbar=no,menubar=no,statusbar=no,width=650,height=300'); pathchooser.ifield = ifield; window.ifield = ifield;" value="{% trans "Browse" %}"/>
+ <input name="browsebutton" type="button" onclick="ifield = document.getElementById('{{skey}}|{{okey}}'); pathchooser = window.open('{% if option.value %}{% url path option.value %}{% else %}{% url pathroot %}{% endif %}', 'pathchooser', 'scrollbars=yes,toolbar=no,menubar=no,statusbar=no,width=650,height=300'); pathchooser.ifield = ifield; window.ifield = ifield;" value="{% trans "Browse" %}"/>
{% else %}
- <input id="{{skey}}|{{okey}}" name="{{configname}}|{{skey}}|{{okey}}" type="text" value="{{option.value}}"/>
+ {% ifequal option.type "file" %}
+ <input name="{{configname}}|{{skey}}|{{okey}}" type="text" id="{{skey}}|{{okey}}" value="{{option.value}}"/>
+ <input name="browsebutton" type="button" onclick="ifield = document.getElementById('{{skey}}|{{okey}}'); filechooser = window.open('{% if option.value %}{% url file option.value %}{% else %}{% url fileroot %}{% endif %}', 'filechooser', 'scrollbars=yes,toolbar=no,menubar=no,statusbar=no,width=650,height=300'); filechooser.ifield = ifield; window.ifield = ifield;" value="{% trans "Browse" %}"/>
+ {% else %}
+ <input id="{{skey}}|{{okey}}" name="{{configname}}|{{skey}}|{{okey}}" type="text" value="{{option.value}}"/>
+ {% endifequal %}
{% endifequal %}
{% endif %}
{% endifequal %}