diff --git a/deluge/ui/webui/json_api.py b/deluge/ui/webui/json_api.py index 08b60fc31..5abe675c7 100644 --- a/deluge/ui/webui/json_api.py +++ b/deluge/ui/webui/json_api.py @@ -220,7 +220,7 @@ class json_rpc: "info_hash" the torrents info_hash } """ - return common.get_torrent_info(filename) + return common.get_torrent_info(filename.strip()) def add_torrents(self, torrents): """ @@ -242,8 +242,19 @@ class json_upload: def GET(self): pass + @deco.check_session 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(): component.get("PageManager").register_page("/json/rpc",json_rpc) diff --git a/deluge/ui/webui/templates/ajax/index.html b/deluge/ui/webui/templates/ajax/index.html index f9d15240b..57dd3acf9 100644 --- a/deluge/ui/webui/templates/ajax/index.html +++ b/deluge/ui/webui/templates/ajax/index.html @@ -6,7 +6,7 @@ - + diff --git a/deluge/ui/webui/templates/ajax/render/html/window_add_torrent_file.html b/deluge/ui/webui/templates/ajax/render/html/window_add_torrent_file.html index 4613f734a..dea031386 100644 --- a/deluge/ui/webui/templates/ajax/render/html/window_add_torrent_file.html +++ b/deluge/ui/webui/templates/ajax/render/html/window_add_torrent_file.html @@ -4,7 +4,7 @@
diff --git a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js index 31e7a9f21..24bd0c14f 100644 --- a/deluge/ui/webui/templates/ajax/static/js/deluge-add.js +++ b/deluge/ui/webui/templates/ajax/static/js/deluge-add.js @@ -100,7 +100,7 @@ Deluge.Widgets.AddTorrent.File = new Class({ Extends: Widgets.Window, options: { - width: 300, + width: 400, height: 100, title: _('From File') }, @@ -110,12 +110,18 @@ Deluge.Widgets.AddTorrent.File = new Class({ this.bound = { onLoad: this.onLoad.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', { src: '/template/render/html/window_add_torrent_file.html', - height: 100, - width: 300 + height: 65, + width: 390, + style: { + background: 'White', + overflow: 'hidden' + } }); this.iframe.addEvent('load', this.bound.onLoad); this.content.grab(this.iframe); @@ -135,7 +141,20 @@ Deluge.Widgets.AddTorrent.File = new Class({ }, 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) { this.table = this.element.getElement('table'); + alert('boo'); }, setTorrent: function(torrent) { diff --git a/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css b/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css index 3b1b65d46..8688b0a94 100644 --- a/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css +++ b/deluge/ui/webui/templates/ajax/static/themes/classic/iframe.css @@ -1,3 +1,8 @@ +html, body { + padding: 0; + margin: 0; +} + body { font-family: trebuchet ms; font-size: 0.7em; @@ -29,6 +34,11 @@ form input, form select { line-height: 20px; } +form torrentFileDiv { + position: relative; + opacity: 0; +} + form textarea { border:1px solid #23344b; background: #99acc3; @@ -39,7 +49,7 @@ form .disabled { color: Gray; } -form .deluge_button, button { +form button { background-color: #37506f; border:1px solid #68a; cursor: pointer; @@ -51,7 +61,7 @@ form .deluge_button, button { margin: 2px; } -form .deluge_button:hover, button:hover { +form button:hover { background-color:#68a; }