diff --git a/deluge/ui/web/index.html b/deluge/ui/web/index.html index 138978843..0ba4462a8 100644 --- a/deluge/ui/web/index.html +++ b/deluge/ui/web/index.html @@ -11,9 +11,13 @@ % endfor - + % for script in scripts: diff --git a/deluge/ui/web/js/deluge-all/Deluge.OptionsManager.js b/deluge/ui/web/js/deluge-all/00OptionsManager.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.OptionsManager.js rename to deluge/ui/web/js/deluge-all/00OptionsManager.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Client.js b/deluge/ui/web/js/deluge-all/Client.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Client.js rename to deluge/ui/web/js/deluge-all/Client.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.ConnectionManager.js b/deluge/ui/web/js/deluge-all/ConnectionManager.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.ConnectionManager.js rename to deluge/ui/web/js/deluge-all/ConnectionManager.js index 18fee3f83..10ebf1781 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.ConnectionManager.js +++ b/deluge/ui/web/js/deluge-all/ConnectionManager.js @@ -500,5 +500,4 @@ Copyright: } } }); - deluge.connectionManager = new Deluge.ConnectionManager(); })(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.js b/deluge/ui/web/js/deluge-all/Deluge.Details.js deleted file mode 100644 index b8a339fe0..000000000 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.js +++ /dev/null @@ -1,102 +0,0 @@ -/* -Script: Deluge.Details.js - Contains all objects and functions related to the lower details panel and - it's containing tabs. - -Copyright: - (C) Damien Churchill 2009-2010 - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, write to: - The Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor - Boston, MA 02110-1301, USA. - - In addition, as a special exception, the copyright holders give - permission to link the code of portions of this program with the OpenSSL - library. - You must obey the GNU General Public License in all respects for all of - the code used other than OpenSSL. If you modify file(s) with this - exception, you may extend this exception to your version of the file(s), - but you are not obligated to do so. If you do not wish to do so, delete - this exception statement from your version. If you delete this exception - statement from all source files in the program, then also delete it here. -*/ - -(function() { - Ext.namespace('Deluge.details'); - Deluge.details.TabPanel = Ext.extend(Ext.TabPanel, { - - constructor: function(config) { - config = Ext.apply({ - region: 'south', - id: 'torrentDetails', - split: true, - height: 220, - minSize: 100, - collapsible: true, - margins: '0 5 5 5', - activeTab: 0 - }, config); - Deluge.details.TabPanel.superclass.constructor.call(this, config); - }, - - clear: function() { - this.items.each(function(panel) { - if (panel.clear) { - panel.clear.defer(100, panel); - panel.disable(); - } - }); - }, - - - update: function(tab) { - var torrent = deluge.torrents.getSelected(); - if (!torrent) { - this.clear(); - return; - } - - this.items.each(function(tab) { - if (tab.disabled) tab.enable(); - }); - - tab = tab || this.getActiveTab(); - if (tab.update) tab.update(torrent.id); - }, - - /* Event Handlers */ - - // We need to add the events in onRender since Deluge.Torrents hasn't - // been created yet. - onRender: function(ct, position) { - Deluge.details.TabPanel.superclass.onRender.call(this, ct, position); - deluge.events.on('disconnect', this.clear, this); - deluge.torrents.on('rowclick', this.onTorrentsClick, this); - this.on('tabchange', this.onTabChange, this); - - deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { - if (!selModel.hasSelection()) this.clear(); - }, this); - }, - - onTabChange: function(panel, tab) { - this.update(tab); - }, - - onTorrentsClick: function(grid, rowIndex, e) { - this.update(); - } - }); - deluge.details = new Deluge.details.TabPanel(); -})(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.js b/deluge/ui/web/js/deluge-all/Deluge.js index 8c813b2d3..1fe2c8749 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.js +++ b/deluge/ui/web/js/deluge-all/Deluge.js @@ -91,7 +91,7 @@ Ext.state.Manager.setProvider(new Ext.state.CookieProvider()); })(); // Create the Deluge namespace -Deluge = { +Ext.apply(Deluge, { // private progressTpl: '
' + @@ -124,7 +124,7 @@ Deluge = { return String.format(Deluge.progressTpl, text, width, barWidth, textWidth); } -} +}); // Setup a space for plugins to insert themselves deluge.plugins = {}; diff --git a/deluge/ui/web/js/deluge-all/Deluge.EditTrackers.js b/deluge/ui/web/js/deluge-all/EditTrackers.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.EditTrackers.js rename to deluge/ui/web/js/deluge-all/EditTrackers.js index 55e7bd679..5491d9dab 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.EditTrackers.js +++ b/deluge/ui/web/js/deluge-all/EditTrackers.js @@ -338,5 +338,4 @@ Copyright: }); } }); - deluge.editTrackers = new Deluge.EditTrackers(); })(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.EventsManager.js b/deluge/ui/web/js/deluge-all/EventsManager.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.EventsManager.js rename to deluge/ui/web/js/deluge-all/EventsManager.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.FileBrowser.js b/deluge/ui/web/js/deluge-all/FileBrowser.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.FileBrowser.js rename to deluge/ui/web/js/deluge-all/FileBrowser.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Formatters.js b/deluge/ui/web/js/deluge-all/Formatters.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Formatters.js rename to deluge/ui/web/js/deluge-all/Formatters.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Keys.js b/deluge/ui/web/js/deluge-all/Keys.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Keys.js rename to deluge/ui/web/js/deluge-all/Keys.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Login.js b/deluge/ui/web/js/deluge-all/Login.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Login.js rename to deluge/ui/web/js/deluge-all/Login.js index 806200442..2ec12c77c 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Login.js +++ b/deluge/ui/web/js/deluge-all/Login.js @@ -154,5 +154,3 @@ Deluge.LoginWindow = Ext.extend(Ext.Window, { this.passwordField.setRawValue(''); } }); - -deluge.login = new Deluge.LoginWindow(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Menus.js b/deluge/ui/web/js/deluge-all/Menus.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Menus.js rename to deluge/ui/web/js/deluge-all/Menus.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.MoveStorage.js b/deluge/ui/web/js/deluge-all/MoveStorage.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.MoveStorage.js rename to deluge/ui/web/js/deluge-all/MoveStorage.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.MultiOptionsManager.js b/deluge/ui/web/js/deluge-all/MultiOptionsManager.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.MultiOptionsManager.js rename to deluge/ui/web/js/deluge-all/MultiOptionsManager.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Plugin.js b/deluge/ui/web/js/deluge-all/Plugin.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Plugin.js rename to deluge/ui/web/js/deluge-all/Plugin.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Remove.js b/deluge/ui/web/js/deluge-all/Remove.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Remove.js rename to deluge/ui/web/js/deluge-all/Remove.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Sidebar.js b/deluge/ui/web/js/deluge-all/Sidebar.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Sidebar.js rename to deluge/ui/web/js/deluge-all/Sidebar.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Statusbar.js b/deluge/ui/web/js/deluge-all/Statusbar.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Statusbar.js rename to deluge/ui/web/js/deluge-all/Statusbar.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Toolbar.js b/deluge/ui/web/js/deluge-all/Toolbar.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Toolbar.js rename to deluge/ui/web/js/deluge-all/Toolbar.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Torrents.js b/deluge/ui/web/js/deluge-all/Torrents.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Torrents.js rename to deluge/ui/web/js/deluge-all/Torrents.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.UI.js b/deluge/ui/web/js/deluge-all/UI.js similarity index 94% rename from deluge/ui/web/js/deluge-all/Deluge.UI.js rename to deluge/ui/web/js/deluge-all/UI.js index 71b437544..faffd50f8 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.UI.js +++ b/deluge/ui/web/js/deluge-all/UI.js @@ -49,6 +49,13 @@ deluge.ui = { * and set up various events that the UI will utilise. */ initialize: function() { + deluge.add = new Deluge.add.AddWindow(); + deluge.details = new Deluge.details.DetailsPanel(); + deluge.connectionManager = new Deluge.ConnectionManager(); + deluge.editTrackers = new Deluge.EditTrackers(); + deluge.login = new Deluge.LoginWindow(); + deluge.preferences = new Deluge.preferences.PreferencesWindow(); + this.MainPanel = new Ext.Panel({ id: 'mainPanel', iconCls: 'x-deluge-main-panel', diff --git a/deluge/ui/web/js/deluge-all/Deluge.Add.js b/deluge/ui/web/js/deluge-all/add/AddWindow.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Add.js rename to deluge/ui/web/js/deluge-all/add/AddWindow.js index 85fccff5b..8f0784181 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Add.js +++ b/deluge/ui/web/js/deluge-all/add/AddWindow.js @@ -550,4 +550,3 @@ Deluge.add.AddWindow = Ext.extend(Deluge.add.Window, { this.url.show(); } }); -deluge.add = new Deluge.add.AddWindow(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Add.File.js b/deluge/ui/web/js/deluge-all/add/File.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Add.File.js rename to deluge/ui/web/js/deluge-all/add/File.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Add.Infohash.js b/deluge/ui/web/js/deluge-all/add/Infohash.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Add.Infohash.js rename to deluge/ui/web/js/deluge-all/add/Infohash.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.Add.Url.js b/deluge/ui/web/js/deluge-all/add/Url.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.Add.Url.js rename to deluge/ui/web/js/deluge-all/add/Url.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.data.Peer.js b/deluge/ui/web/js/deluge-all/data/PeerRecord.js similarity index 96% rename from deluge/ui/web/js/deluge-all/Deluge.data.Peer.js rename to deluge/ui/web/js/deluge-all/data/PeerRecord.js index 528b8c7bb..e9132403c 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.data.Peer.js +++ b/deluge/ui/web/js/deluge-all/data/PeerRecord.js @@ -50,8 +50,7 @@ Deluge.data.Peer = Ext.data.Record.create([ type: 'string' }, { name: 'ip', - type: 'string', - sortType: Deluge.data.SortTypes.asIPAddress + type: 'string' }, { name: 'client', type: 'string' diff --git a/deluge/ui/web/js/deluge-all/Deluge.data.SortTypes.js b/deluge/ui/web/js/deluge-all/data/SortTypes.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.data.SortTypes.js rename to deluge/ui/web/js/deluge-all/data/SortTypes.js diff --git a/deluge/ui/web/js/deluge-all/Deluge.data.Torrent.js b/deluge/ui/web/js/deluge-all/data/TorrentRecord.js similarity index 100% rename from deluge/ui/web/js/deluge-all/Deluge.data.Torrent.js rename to deluge/ui/web/js/deluge-all/data/TorrentRecord.js diff --git a/deluge/ui/web/js/deluge-all/details/DetailsPanel.js b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js new file mode 100644 index 000000000..2e6113e01 --- /dev/null +++ b/deluge/ui/web/js/deluge-all/details/DetailsPanel.js @@ -0,0 +1,103 @@ +/* +Script: Deluge.Details.js + Contains all objects and functions related to the lower details panel and + it's containing tabs. + +Copyright: + (C) Damien Churchill 2009-2010 + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, write to: + The Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301, USA. + + In addition, as a special exception, the copyright holders give + permission to link the code of portions of this program with the OpenSSL + library. + You must obey the GNU General Public License in all respects for all of + the code used other than OpenSSL. If you modify file(s) with this + exception, you may extend this exception to your version of the file(s), + but you are not obligated to do so. If you do not wish to do so, delete + this exception statement from your version. If you delete this exception + statement from all source files in the program, then also delete it here. +*/ + +Ext.namespace('Deluge.details'); +Deluge.details.DetailsPanel = Ext.extend(Ext.TabPanel, { + + region: 'south', + id: 'torrentDetails', + split: true, + height: 220, + minSize: 100, + collapsible: true, + margins: '0 5 5 5', + activeTab: 0, + + initComponent: function() { + Deluge.details.DetailsPanel.superclass.initComponent.call(this); + this.add(new Deluge.details.StatusTab()); + this.add(new Deluge.details.DetailsTab()); + this.add(new Deluge.details.FilesTab()); + this.add(new Deluge.details.PeersTab()); + this.add(new Deluge.details.OptionsTab()); + }, + + clear: function() { + this.items.each(function(panel) { + if (panel.clear) { + panel.clear.defer(100, panel); + panel.disable(); + } + }); + }, + + + update: function(tab) { + var torrent = deluge.torrents.getSelected(); + if (!torrent) { + this.clear(); + return; + } + + this.items.each(function(tab) { + if (tab.disabled) tab.enable(); + }); + + tab = tab || this.getActiveTab(); + if (tab.update) tab.update(torrent.id); + }, + + /* Event Handlers */ + + // We need to add the events in onRender since Deluge.Torrents hasn't + // been created yet. + onRender: function(ct, position) { + Deluge.details.DetailsPanel.superclass.onRender.call(this, ct, position); + deluge.events.on('disconnect', this.clear, this); + deluge.torrents.on('rowclick', this.onTorrentsClick, this); + this.on('tabchange', this.onTabChange, this); + + deluge.torrents.getSelectionModel().on('selectionchange', function(selModel) { + if (!selModel.hasSelection()) this.clear(); + }, this); + }, + + onTabChange: function(panel, tab) { + this.update(tab); + }, + + onTorrentsClick: function(grid, rowIndex, e) { + this.update(); + } +}); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.Details.js b/deluge/ui/web/js/deluge-all/details/DetailsTab.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Details.Details.js rename to deluge/ui/web/js/deluge-all/details/DetailsTab.js index 900e65684..dbb65404a 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.Details.js +++ b/deluge/ui/web/js/deluge-all/details/DetailsTab.js @@ -112,4 +112,3 @@ Deluge.details.DetailsTab = Ext.extend(Ext.Panel, { this.oldData = data; } }); -deluge.details.add(new Deluge.details.DetailsTab()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.Files.js b/deluge/ui/web/js/deluge-all/details/FilesTab.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Details.Files.js rename to deluge/ui/web/js/deluge-all/details/FilesTab.js index 743c8a555..63085b763 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.Files.js +++ b/deluge/ui/web/js/deluge-all/details/FilesTab.js @@ -216,5 +216,4 @@ Copyright: root.firstChild.expand(); } }); - deluge.details.add(new Deluge.details.FilesTab()); })(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.Options.js b/deluge/ui/web/js/deluge-all/details/OptionsTab.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Details.Options.js rename to deluge/ui/web/js/deluge-all/details/OptionsTab.js index 3853d40b3..84b026e86 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.Options.js +++ b/deluge/ui/web/js/deluge-all/details/OptionsTab.js @@ -414,4 +414,3 @@ Deluge.details.OptionsTab = Ext.extend(Ext.form.FormPanel, { this.fields.stop_ratio.setDisabled(!stop_at_ratio); } }); -deluge.details.add(new Deluge.details.OptionsTab()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.Peers.js b/deluge/ui/web/js/deluge-all/details/PeersTab.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Details.Peers.js rename to deluge/ui/web/js/deluge-all/details/PeersTab.js index 930c443e6..7f3e53894 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.Peers.js +++ b/deluge/ui/web/js/deluge-all/details/PeersTab.js @@ -150,5 +150,4 @@ Copyright: store.sort(sortState.field, sortState.direction); } }); - deluge.details.add(new Deluge.details.PeersTab()); })(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Details.Status.js b/deluge/ui/web/js/deluge-all/details/StatusTab.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Details.Status.js rename to deluge/ui/web/js/deluge-all/details/StatusTab.js index bef770463..2148b300b 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Details.Status.js +++ b/deluge/ui/web/js/deluge-all/details/StatusTab.js @@ -119,4 +119,3 @@ Deluge.details.StatusTab = Ext.extend(Ext.Panel, { this.progressBar.updateProgress(status.progress / 100.0, text); } }); -deluge.details.add(new Deluge.details.StatusTab()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Bandwidth.js b/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Bandwidth.js rename to deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js index 2c8a76d74..2cf7e4f1b 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Bandwidth.js +++ b/deluge/ui/web/js/deluge-all/preferences/BandwidthPage.js @@ -216,4 +216,3 @@ Deluge.preferences.Bandwidth = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Bandwidth()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Cache.js b/deluge/ui/web/js/deluge-all/preferences/CachePage.js similarity index 97% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Cache.js rename to deluge/ui/web/js/deluge-all/preferences/CachePage.js index f464fc445..eb6ebc8c7 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Cache.js +++ b/deluge/ui/web/js/deluge-all/preferences/CachePage.js @@ -86,4 +86,3 @@ Deluge.preferences.Cache = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Cache()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Daemon.js b/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Daemon.js rename to deluge/ui/web/js/deluge-all/preferences/DaemonPage.js index ca5654cbb..ffc9d1782 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Daemon.js +++ b/deluge/ui/web/js/deluge-all/preferences/DaemonPage.js @@ -104,4 +104,3 @@ Deluge.preferences.Daemon = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Daemon()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Downloads.js b/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Downloads.js rename to deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js index 0d83f4c9a..63397bbaa 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Downloads.js +++ b/deluge/ui/web/js/deluge-all/preferences/DownloadsPage.js @@ -155,4 +155,3 @@ Deluge.preferences.Downloads = Ext.extend(Ext.FormPanel, { Deluge.preferences.Downloads.superclass.onShow.call(this); } }); -deluge.preferences.addPage(new Deluge.preferences.Downloads()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Encryption.js b/deluge/ui/web/js/deluge-all/preferences/EncryptionPage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Encryption.js rename to deluge/ui/web/js/deluge-all/preferences/EncryptionPage.js index bed23e9a9..396c4a001 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Encryption.js +++ b/deluge/ui/web/js/deluge-all/preferences/EncryptionPage.js @@ -116,4 +116,3 @@ Deluge.preferences.Encryption = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Encryption()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Interface.js b/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Interface.js rename to deluge/ui/web/js/deluge-all/preferences/InterfacePage.js index e30ff4a32..ef7dcb4fe 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Interface.js +++ b/deluge/ui/web/js/deluge-all/preferences/InterfacePage.js @@ -262,4 +262,3 @@ Deluge.preferences.Interface = Ext.extend(Ext.form.FormPanel, { this.certField.setDisabled(!checked); } }); -deluge.preferences.addPage(new Deluge.preferences.Interface()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Network.js b/deluge/ui/web/js/deluge-all/preferences/NetworkPage.js similarity index 93% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Network.js rename to deluge/ui/web/js/deluge-all/preferences/NetworkPage.js index 520075d22..1dab57bf2 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Network.js +++ b/deluge/ui/web/js/deluge-all/preferences/NetworkPage.js @@ -1,5 +1,5 @@ /* -Script: deluge.preferences.Network.js +Script: Deluge.preferences.Network.js The network preferences page. Copyright: @@ -38,15 +38,11 @@ Ext.namespace('Deluge.preferences'); * @extends Ext.form.FormPanel */ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { - constructor: function(config) { - config = Ext.apply({ - border: false, - title: _('Network'), - layout: 'form' - }, config); - Deluge.preferences.Network.superclass.constructor.call(this, config); - }, + border: false, + layout: 'form', + title: _('Network'), + initComponent: function() { Deluge.preferences.Network.superclass.initComponent.call(this); var optMan = deluge.preferences.getOptionsManager(); @@ -76,7 +72,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { } })); this.listenPorts = fieldset.add({ - xtype: 'uxspinnergroup', + xtype: 'spinnergroup', name: 'listen_ports', fieldLabel: '', labelSeparator: '', @@ -131,7 +127,7 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { } })); this.outgoingPorts = fieldset.add({ - xtype: 'uxspinnergroup', + xtype: 'spinnergroup', name: 'outgoing_ports', fieldLabel: '', labelSeparator: '', @@ -236,4 +232,3 @@ Deluge.preferences.Network = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Network()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Other.js b/deluge/ui/web/js/deluge-all/preferences/OtherPage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Other.js rename to deluge/ui/web/js/deluge-all/preferences/OtherPage.js index ff4368143..37f12bfb2 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Other.js +++ b/deluge/ui/web/js/deluge-all/preferences/OtherPage.js @@ -108,4 +108,3 @@ Deluge.preferences.Other = Ext.extend(Ext.form.FormPanel, { })); } }); -deluge.preferences.addPage(new Deluge.preferences.Other()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Plugins.js b/deluge/ui/web/js/deluge-all/preferences/PluginsPage.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Plugins.js rename to deluge/ui/web/js/deluge-all/preferences/PluginsPage.js index 66568aeef..87fee518b 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Plugins.js +++ b/deluge/ui/web/js/deluge-all/preferences/PluginsPage.js @@ -336,4 +336,3 @@ Deluge.preferences.Plugins = Ext.extend(Ext.Panel, { this.setInfo(); } }); -deluge.preferences.addPage(new Deluge.preferences.Plugins()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.js b/deluge/ui/web/js/deluge-all/preferences/PreferencesWindow.js similarity index 89% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.js rename to deluge/ui/web/js/deluge-all/preferences/PreferencesWindow.js index 4a3ab0286..5a911969b 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.js +++ b/deluge/ui/web/js/deluge-all/preferences/PreferencesWindow.js @@ -58,6 +58,8 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { plain: true, resizable: false, + pages: {}, + initComponent: function() { Deluge.preferences.PreferencesWindow.superclass.initComponent.call(this); @@ -104,10 +106,26 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { this.addButton(_('Apply'), this.onApply, this); this.addButton(_('Ok'), this.onOk, this); - this.pages = {}; this.optionsManager = new Deluge.OptionsManager(); this.on('afterrender', this.onAfterRender, this); this.on('show', this.onShow, this); + + this.initPages(); + }, + + initPages: function() { + deluge.preferences = this; + this.addPage(new Deluge.preferences.Downloads()); + //this.addPage(new Deluge.preferences.Network()); + this.addPage(new Deluge.preferences.Encryption()); + this.addPage(new Deluge.preferences.Bandwidth()); + this.addPage(new Deluge.preferences.Interface()); + this.addPage(new Deluge.preferences.Other()); + this.addPage(new Deluge.preferences.Daemon()); + this.addPage(new Deluge.preferences.Queue()); + this.addPage(new Deluge.preferences.Proxy()); + this.addPage(new Deluge.preferences.Cache()); + this.addPage(new Deluge.preferences.Plugins()); }, onApply: function(e) { @@ -142,6 +160,7 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { var name = page.title; store.add([new PreferencesRecord({name: name})]); page['bodyStyle'] = 'margin: 5px'; + page.preferences = this; this.pages[name] = this.configPanel.add(page); return this.pages[name]; }, @@ -211,4 +230,3 @@ Deluge.preferences.PreferencesWindow = Ext.extend(Ext.Window, { this.hide(); } }); -deluge.preferences = new Deluge.preferences.PreferencesWindow(); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Proxy.js b/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js similarity index 99% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Proxy.js rename to deluge/ui/web/js/deluge-all/preferences/ProxyPage.js index dd555e1d5..0b9a09544 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Proxy.js +++ b/deluge/ui/web/js/deluge-all/preferences/ProxyPage.js @@ -236,4 +236,3 @@ Deluge.preferences.Proxy = Ext.extend(Ext.form.FormPanel, { this.fireEvent('change', this, newValues, oldValues); } }); -deluge.preferences.addPage(new Deluge.preferences.Proxy()); diff --git a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Queue.js b/deluge/ui/web/js/deluge-all/preferences/QueuePage.js similarity index 98% rename from deluge/ui/web/js/deluge-all/Deluge.Preferences.Queue.js rename to deluge/ui/web/js/deluge-all/preferences/QueuePage.js index 901b41f70..1eff5c771 100644 --- a/deluge/ui/web/js/deluge-all/Deluge.Preferences.Queue.js +++ b/deluge/ui/web/js/deluge-all/preferences/QueuePage.js @@ -223,4 +223,3 @@ Deluge.preferences.Queue = Ext.extend(Ext.form.FormPanel, { this.removeAtRatio.setDisabled(!checked); } }); -deluge.preferences.addPage(new Deluge.preferences.Queue()); diff --git a/deluge/ui/web/js/ext-extensions/TreeGrid.js b/deluge/ui/web/js/ext-extensions/TreeGrid.js index 8e341775a..b6855cea0 100644 --- a/deluge/ui/web/js/ext-extensions/TreeGrid.js +++ b/deluge/ui/web/js/ext-extensions/TreeGrid.js @@ -4,6 +4,8 @@ * licensing@extjs.com * http://www.extjs.com/license */ +Ext.ns('Ext.ux.tree'); + /** * @class Ext.ux.tree.TreeGrid * @extends Ext.tree.TreePanel @@ -404,4 +406,4 @@ Ext.ux.tree.TreeGrid = Ext.extend(Ext.tree.TreePanel, { } }); -Ext.reg('treegrid', Ext.ux.tree.TreeGrid); \ No newline at end of file +Ext.reg('treegrid', Ext.ux.tree.TreeGrid); diff --git a/deluge/ui/web/server.py b/deluge/ui/web/server.py index 66384d8b1..ed6e4ad7a 100644 --- a/deluge/ui/web/server.py +++ b/deluge/ui/web/server.py @@ -38,6 +38,7 @@ import time import locale import shutil import urllib +import fnmatch import gettext import hashlib import logging @@ -240,7 +241,7 @@ class LookupResource(resource.Resource, component.Component): self.__paths = {} for directory in directories: self.addDirectory(directory) - + def addDirectory(self, directory, path=""): log.debug("Adding directory `%s` with path `%s`", directory, path) paths = self.__paths.setdefault(path, []) @@ -267,7 +268,7 @@ class LookupResource(resource.Resource, component.Component): filename = os.path.basename(request.path) for directory in self.__paths[path]: - if filename in os.listdir(directory): + if os.path.join(directory, filename): path = os.path.join(directory, filename) log.debug("Serving path: '%s'", path) mime_type = mimetypes.guess_type(path) @@ -277,6 +278,131 @@ class LookupResource(resource.Resource, component.Component): request.setResponseCode(http.NOT_FOUND) return "

404 - Not Found

" +class ScriptResource(resource.Resource, component.Component): + + def __init__(self): + resource.Resource.__init__(self) + component.Component.__init__(self, "Scripts") + self.__scripts = { + "normal": { + "scripts": {}, + "order": [] + }, + "debug": { + "scripts": {}, + "order": [] + }, + "dev": { + "scripts": {}, + "order": [] + } + } + + def add_script(self, path, filepath, type=None): + """ + Adds a script or scripts to the script resource. + + :param path: The path of the script (this supports globbing) + :type path: string + :param filepath: The physical location of the script + :type filepath: string + :keyword type: The type of script to add (normal, debug, dev) + :param type: string + """ + if type not in ("dev", "debug", "normal"): + type = "normal" + + self.__scripts[type]["scripts"][path] = filepath + self.__scripts[type]["order"].append(path) + + def add_script_folder(self, path, filepath, type=None, recurse=True): + """ + Adds a folder of scripts to the script resource. + + :param path: The path of the script (this supports globbing) + :type path: string + :param filepath: The physical location of the script + :type filepath: string + :keyword type: The type of script to add (normal, debug, dev) + :param type: string + :keyword recurse: Whether or not to recurse into other folders + :param recurse: bool + """ + if type not in ("dev", "debug", "normal"): + type = "normal" + + self.__scripts[type]["scripts"][path] = (filepath, recurse) + self.__scripts[type]["order"].append(path) + + def get_scripts(self, type=None): + """ + Returns a list of the scripts that can be used for producing + script tags. + + :keyword type: The type of scripts to get (normal, debug, dev) + :param type: string + """ + scripts = [] + if type not in ("dev", "debug", "normal"): + type = 'normal' + + _scripts = self.__scripts[type]["scripts"] + _order = self.__scripts[type]["order"] + + for path in _order: + filepath = _scripts[path] + + # this is a folder + if isinstance(filepath, tuple): + filepath, recurse = filepath + if recurse: + for dirpath, dirnames, filenames in os.walk(filepath, False): + files = fnmatch.filter(filenames, "*.js") + files.sort() + dirpath = dirpath[len(filepath)+1:] + if dirpath: + scripts.extend(['js/' + path + '/' + dirpath + '/' + f for f in files]) + else: + scripts.extend(['js/' + path + '/' + f for f in files]) + else: + files = fnmatch.filter(os.listdir('.'), "*.js") + else: + scripts.append("js/" + path) + return scripts + + def getChild(self, path, request): + if hasattr(request, "lookup_path"): + request.lookup_path = os.path.join(request.lookup_path, path) + else: + request.lookup_path = path + return self + + def render(self, request): + log.debug("Requested path: '%s'", request.lookup_path) + + for type in ("dev", "debug", "normal"): + scripts = self.__scripts[type]["scripts"] + for pattern in scripts: + if not request.lookup_path.startswith(pattern): + continue + + filepath = scripts[pattern] + if isinstance(filepath, tuple): + filepath = filepath[0] + + path = filepath + request.lookup_path[len(pattern):] + + if not os.path.isfile(path): + continue + + log.debug("Serving path: '%s'", path) + mime_type = mimetypes.guess_type(path) + request.setHeader("content-type", mime_type[0]) + return compress(open(path, "rb").read(), request) + + request.setResponseCode(http.NOT_FOUND) + return "

404 - Not Found

" + class TopLevel(resource.Resource): addSlash = True @@ -286,89 +412,6 @@ class TopLevel(resource.Resource): "css/deluge.css" ] - __scripts = [ - "js/ext-base.js", - "js/ext-all.js", - "js/ext-extensions.js", - "config.js", - "gettext.js", - "js/deluge-all.js" - ] - - __debug_scripts = [ - "js/ext-base-debug.js", - "js/ext-all-debug.js", - "js/ext-extensions-debug.js", - "config.js", - "gettext.js", - "js/deluge-all-debug.js" - ] - - __dev_scripts = [ - "js/ext-base-debug.js", - "js/ext-all-debug.js", - "js/ext-extensions/BufferView.js", - "js/ext-extensions/FileUploadField.js", - "js/ext-extensions/JSLoader.js", - "js/ext-extensions/Spinner.js", - "js/ext-extensions/SpinnerField.js", - "js/ext-extensions/StatusBar.js", - "js/ext-extensions/ToggleField.js", - "js/ext-extensions/TreeGridSorter.js", - "js/ext-extensions/TreeGridColumnResizer.js", - "js/ext-extensions/TreeGridNodeUI.js", - "js/ext-extensions/TreeGridLoader.js", - "js/ext-extensions/TreeGridColumns.js", - "js/ext-extensions/TreeGridRenderColumn.js", - "js/ext-extensions/TreeGrid.js", - "gettext.js", - "js/deluge-all/Deluge.js", - "js/deluge-all/Deluge.Formatters.js", - "js/deluge-all/Deluge.Menus.js", - "js/deluge-all/Deluge.data.SortTypes.js", - "js/deluge-all/Deluge.EventsManager.js", - "js/deluge-all/Deluge.OptionsManager.js", - "js/deluge-all/Deluge.MultiOptionsManager.js", - "js/deluge-all/Deluge.data.Peer.js", - "js/deluge-all/Deluge.data.Torrent.js", - "js/deluge-all/Deluge.Add.js", - "js/deluge-all/Deluge.Add.File.js", - "js/deluge-all/Deluge.Add.Url.js", - "js/deluge-all/Deluge.Add.Infohash.js", - "js/deluge-all/Deluge.Client.js", - "js/deluge-all/Deluge.ConnectionManager.js", - "js/deluge-all/Deluge.Details.js", - "js/deluge-all/Deluge.Details.Status.js", - "js/deluge-all/Deluge.Details.Details.js", - "js/deluge-all/Deluge.Details.Files.js", - "js/deluge-all/Deluge.Details.Peers.js", - "js/deluge-all/Deluge.Details.Options.js", - "js/deluge-all/Deluge.EditTrackers.js", - "js/deluge-all/Deluge.FileBrowser.js", - "js/deluge-all/Deluge.Keys.js", - "js/deluge-all/Deluge.Login.js", - "js/deluge-all/Deluge.MoveStorage.js", - "js/deluge-all/Deluge.Plugin.js", - "js/deluge-all/Deluge.Preferences.js", - "js/deluge-all/Deluge.Preferences.Downloads.js", - #"js/deluge-all/Deluge.Preferences.Network.js", - "js/deluge-all/Deluge.Preferences.Encryption.js", - "js/deluge-all/Deluge.Preferences.Bandwidth.js", - "js/deluge-all/Deluge.Preferences.Interface.js", - "js/deluge-all/Deluge.Preferences.Other.js", - "js/deluge-all/Deluge.Preferences.Daemon.js", - "js/deluge-all/Deluge.Preferences.Queue.js", - "js/deluge-all/Deluge.Preferences.Proxy.js", - "js/deluge-all/Deluge.Preferences.Cache.js", - "js/deluge-all/Deluge.Preferences.Plugins.js", - "js/deluge-all/Deluge.Remove.js", - "js/deluge-all/Deluge.Sidebar.js", - "js/deluge-all/Deluge.Statusbar.js", - "js/deluge-all/Deluge.Toolbar.js", - "js/deluge-all/Deluge.Torrents.js", - "js/deluge-all/Deluge.UI.js" - ] - def __init__(self): resource.Resource.__init__(self) self.putChild("css", LookupResource("Css", rpath("css"))) @@ -377,10 +420,26 @@ class TopLevel(resource.Resource): self.putChild("icons", LookupResource("Icons", rpath("icons"))) self.putChild("images", LookupResource("Images", rpath("images"))) - # Add the javascript resource with the development paths - js = LookupResource("Javascript", rpath("js")) - js.addDirectory(rpath("js", "ext-extensions"), "ext-extensions") - js.addDirectory(rpath("js", "deluge-all"), "deluge-all") + js = ScriptResource() + + # configure the dev scripts + js.add_script("ext-base.js", rpath("js", "ext-base-debug.js"), "dev") + js.add_script("ext-all.js", rpath("js", "ext-all-debug.js"), "dev") + js.add_script_folder("ext-extensions", rpath("js", "ext-extensions"), "dev") + js.add_script_folder("deluge-all", rpath("js", "deluge-all"), "dev") + + # configure the debug scripts + js.add_script("ext-base.js", rpath("js", "ext-base-debug.js"), "debug") + js.add_script("ext-all.js", rpath("js", "ext-all-debug.js"), "debug") + js.add_script("ext-extensions.js", rpath("js", "ext-extensions-debug.js"), "debug") + js.add_script("deluge-all.js", rpath("js", "deluge-all-debug.js"), "debug") + + # configure the normal scripts + js.add_script("ext-base.js", rpath("js", "ext-base.js"), "debug") + js.add_script("ext-all.js", rpath("js", "ext-all.js"), "debug") + js.add_script("ext-extensions.js", rpath("js", "ext-extensions.js"), "debug") + js.add_script("deluge-all.js", rpath("js", "deluge-all.js"), "debug") + self.putChild("js", js) self.putChild("json", JSON()) @@ -457,11 +516,14 @@ class TopLevel(resource.Resource): dev = False if dev: - scripts = self.dev_scripts[:] + mode = 'dev' elif debug: - scripts = self.debug_scripts[:] + mode = 'debug' else: - scripts = self.scripts[:] + mode = None + + scripts = component.get("Scripts").get_scripts(mode) + scripts.insert(0, "gettext.js") template = Template(filename=rpath("index.html")) request.setHeader("content-type", "text/html; charset=utf-8") @@ -484,12 +546,7 @@ class TopLevel(resource.Resource): web_config = component.get("Web").get_config() web_config["base"] = base config = dict([(key, web_config[key]) for key in UI_CONFIG_KEYS]) - js_config = """deluge = { - author: 'Damien Churchill ', - version: '%s', - config: %s -}""" % (common.get_version(), common.json.dumps(config)) - + js_config = common.json.dumps(config) return template.render(scripts=scripts, stylesheets=self.stylesheets, debug=debug, base=base, js_config=js_config)