mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-07 08:58:38 +00:00
implement the server side part of ajax add from file
implement the client side javascript (file input still needs themeing)
This commit is contained in:
parent
5eb92ab9b7
commit
d919a452dd
5 changed files with 52 additions and 11 deletions
|
@ -220,7 +220,7 @@ class json_rpc:
|
||||||
"info_hash" the torrents info_hash
|
"info_hash" the torrents info_hash
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
return common.get_torrent_info(filename)
|
return common.get_torrent_info(filename.strip())
|
||||||
|
|
||||||
def add_torrents(self, torrents):
|
def add_torrents(self, torrents):
|
||||||
"""
|
"""
|
||||||
|
@ -242,8 +242,19 @@ class json_upload:
|
||||||
def GET(self):
|
def GET(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@deco.check_session
|
||||||
def POST(self, name=None):
|
def POST(self, name=None):
|
||||||
pass
|
import os
|
||||||
|
import shutil
|
||||||
|
import tempfile
|
||||||
|
vars = web.input(torrentFile = {})
|
||||||
|
vars.torrentFile
|
||||||
|
path = os.path.join(tempfile.gettempdir(), vars.torrentFile.filename)
|
||||||
|
tmp_file = open(path, 'w')
|
||||||
|
shutil.copyfileobj(vars.torrentFile.file, tmp_file)
|
||||||
|
tmp_file.close()
|
||||||
|
print path
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
component.get("PageManager").register_page("/json/rpc",json_rpc)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
<link rel="shortcut icon" href="$base/static/images/deluge-icon.png" type="image/png" />
|
||||||
<link rel="stylesheet" type="text/css" href="$base/template/static/css/mooui.css" />
|
<link rel="stylesheet" type="text/css" href="$base/template/static/css/mooui.css" />
|
||||||
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
<link rel="stylesheet" type="text/css" href="$base/template_style.css" />
|
||||||
<script src="$base/static/mootools-1.2.1-core-yc.js" type="text/javascript"></script>
|
<script src="$base/static/mootools-1.2-core.js" type="text/javascript"></script>
|
||||||
<script src="$base/static/mootools-1.2-more.js" type="text/javascript"></script>
|
<script src="$base/static/mootools-1.2-more.js" type="text/javascript"></script>
|
||||||
<script src="$base/template/static/js/Rpc.js" type="text/javascript"></script>
|
<script src="$base/template/static/js/Rpc.js" type="text/javascript"></script>
|
||||||
<script src="$base/static/mooui.js" type="text/javascript"></script>
|
<script src="$base/static/mooui.js" type="text/javascript"></script>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
</head>
|
</head>
|
||||||
<body style="background: none;">
|
<body style="background: none;">
|
||||||
<form method="post" action="/json/upload" enctype="multipart/form-data">
|
<form method="post" action="/json/upload" enctype="multipart/form-data">
|
||||||
<label>$_('File'):</label><input type="file" name="torrentFile" /> <br/>
|
<label>$_('File'):</label><div id="torrentFileDiv"><input type="file" name="torrentFile" /></div><br/>
|
||||||
<button class="ok">$_('Ok')</button><button class="cancel">$_('Cancel')</button>
|
<button class="ok">$_('Ok')</button><button class="cancel">$_('Cancel')</button>
|
||||||
</form>
|
</form>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -100,7 +100,7 @@ Deluge.Widgets.AddTorrent.File = new Class({
|
||||||
Extends: Widgets.Window,
|
Extends: Widgets.Window,
|
||||||
|
|
||||||
options: {
|
options: {
|
||||||
width: 300,
|
width: 400,
|
||||||
height: 100,
|
height: 100,
|
||||||
title: _('From File')
|
title: _('From File')
|
||||||
},
|
},
|
||||||
|
@ -110,12 +110,18 @@ Deluge.Widgets.AddTorrent.File = new Class({
|
||||||
this.bound = {
|
this.bound = {
|
||||||
onLoad: this.onLoad.bindWithEvent(this),
|
onLoad: this.onLoad.bindWithEvent(this),
|
||||||
onCancel: this.onCancel.bindWithEvent(this),
|
onCancel: this.onCancel.bindWithEvent(this),
|
||||||
onSubmit: this.onSubmit.bindWithEvent(this)
|
onSubmit: this.onSubmit.bindWithEvent(this),
|
||||||
|
onComplete: this.onComplete.bindWithEvent(this),
|
||||||
|
onGetInfoSuccess: this.onGetInfoSuccess.bindWithEvent(this)
|
||||||
};
|
};
|
||||||
this.iframe = new Element('iframe', {
|
this.iframe = new Element('iframe', {
|
||||||
src: '/template/render/html/window_add_torrent_file.html',
|
src: '/template/render/html/window_add_torrent_file.html',
|
||||||
height: 100,
|
height: 65,
|
||||||
width: 300
|
width: 390,
|
||||||
|
style: {
|
||||||
|
background: 'White',
|
||||||
|
overflow: 'hidden'
|
||||||
|
}
|
||||||
});
|
});
|
||||||
this.iframe.addEvent('load', this.bound.onLoad);
|
this.iframe.addEvent('load', this.bound.onLoad);
|
||||||
this.content.grab(this.iframe);
|
this.content.grab(this.iframe);
|
||||||
|
@ -135,7 +141,20 @@ Deluge.Widgets.AddTorrent.File = new Class({
|
||||||
},
|
},
|
||||||
|
|
||||||
onSubmit: function(e) {
|
onSubmit: function(e) {
|
||||||
alert('form sent');
|
this.iframe.addEvent('load', this.bound.onComplete);
|
||||||
|
this.iframe.set('opacity', 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
onComplete: function(e) {
|
||||||
|
filename = this.iframe.contentDocument.body.get('text');
|
||||||
|
Deluge.Client.get_torrent_info(filename, {
|
||||||
|
onSuccess: this.bound.onGetInfoSuccess
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onGetInfoSuccess: function(info) {
|
||||||
|
this.fireEvent('torrentAdded', info);
|
||||||
|
this.hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -219,6 +238,7 @@ Deluge.Widgets.AddTorrent.FilesTab = new Class({
|
||||||
|
|
||||||
onLoad: function(e) {
|
onLoad: function(e) {
|
||||||
this.table = this.element.getElement('table');
|
this.table = this.element.getElement('table');
|
||||||
|
alert('boo');
|
||||||
},
|
},
|
||||||
|
|
||||||
setTorrent: function(torrent) {
|
setTorrent: function(torrent) {
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
html, body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
font-family: trebuchet ms;
|
font-family: trebuchet ms;
|
||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
|
@ -29,6 +34,11 @@ form input, form select {
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form torrentFileDiv {
|
||||||
|
position: relative;
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
form textarea {
|
form textarea {
|
||||||
border:1px solid #23344b;
|
border:1px solid #23344b;
|
||||||
background: #99acc3;
|
background: #99acc3;
|
||||||
|
@ -39,7 +49,7 @@ form .disabled {
|
||||||
color: Gray;
|
color: Gray;
|
||||||
}
|
}
|
||||||
|
|
||||||
form .deluge_button, button {
|
form button {
|
||||||
background-color: #37506f;
|
background-color: #37506f;
|
||||||
border:1px solid #68a;
|
border:1px solid #68a;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -51,7 +61,7 @@ form .deluge_button, button {
|
||||||
margin: 2px;
|
margin: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
form .deluge_button:hover, button:hover {
|
form button:hover {
|
||||||
background-color:#68a;
|
background-color:#68a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue