diff --git a/deluge/plugins/label/label/core.py b/deluge/plugins/label/label/core.py index 929a2381b..25edd54fb 100644 --- a/deluge/plugins/label/label/core.py +++ b/deluge/plugins/label/label/core.py @@ -53,14 +53,10 @@ LABEL = "label" CONFIG_DEFAULTS = { "torrent_labels":{}, #torrent_id:label_id "labels":{}, #label_id:{name:value} - "hide_zero_hits":False, - "gtk_alfa":False, - "show_states":True, - "show_trackers":True, - "show_labels":True + "auto_add_trackers":[] } -CORE_OPTIONS = ["hide_zero_hits", "gtk_alfa", "show_states", "show_trackers", "show_labels","auto_add","auto_add_trackers"] +CORE_OPTIONS = ["auto_add_trackers"] OPTIONS_DEFAULTS = { "apply_max":False, @@ -77,8 +73,7 @@ OPTIONS_DEFAULTS = { "apply_move_completed":False, "move_completed":False, "move_completed_path":"", - "auto_add":False, - "auto_add_trackers":[], + "auto_add":False } NO_LABEL = "No Label" @@ -296,11 +291,11 @@ class Core(CorePluginBase): self.config.save() - def export_get_global_options(self): - "see : label_set_global_options" + def export_get_config(self): + "see : label_set_config" return dict ( (k,self.config[k] ) for k in CORE_OPTIONS) - def export_set_global_options(self, options): + def export_set_config(self, options): """global_options:""" for key in CORE_OPTIONS: if options.has_key(key): diff --git a/deluge/plugins/label/label/data/test1.js b/deluge/plugins/label/label/data/label.js similarity index 100% rename from deluge/plugins/label/label/data/test1.js rename to deluge/plugins/label/label/data/label.js diff --git a/deluge/plugins/label/label/gtkui/label_config.py b/deluge/plugins/label/label/gtkui/label_config.py index c41b13a59..06f476f69 100644 --- a/deluge/plugins/label/label/gtkui/label_config.py +++ b/deluge/plugins/label/label/gtkui/label_config.py @@ -68,7 +68,7 @@ class LabelConfig(object): return pkg_resources.resource_filename("label", os.path.join("data", filename)) def load_settings(self ,widget = None , data = None): - aclient.label_get_global_options(self.cb_global_options) + aclient.label_get_config(self.cb_global_options) def cb_global_options(self, options): log.debug("options=%s" % options) @@ -80,5 +80,5 @@ class LabelConfig(object): def on_apply_prefs(self): options = {} #update options dict here. - aclient.label_set_global_options(None, options) + aclient.label_set_config(None, options) diff --git a/deluge/plugins/label/label/template/config.html b/deluge/plugins/label/label/template/config.html new file mode 100644 index 000000000..1dc4f27bf --- /dev/null +++ b/deluge/plugins/label/label/template/config.html @@ -0,0 +1,19 @@ +$def with (labels) + +$for label in labels: + + + + + +
$label
+ +

Options

+ diff --git a/deluge/plugins/label/label/template/options.html b/deluge/plugins/label/label/template/options.html new file mode 100644 index 000000000..b1f83e99b --- /dev/null +++ b/deluge/plugins/label/label/template/options.html @@ -0,0 +1,10 @@ +$def with (label_id) +$:render.basic_header(_("Label Options")) +

$label_id Options.

+
+
+ label= $label_id +
+
+ +$:render.footer() \ No newline at end of file diff --git a/deluge/plugins/label/label/template/part_label_filters.html b/deluge/plugins/label/label/template/part_label_filters.html deleted file mode 100644 index 62272ea3b..000000000 --- a/deluge/plugins/label/label/template/part_label_filters.html +++ /dev/null @@ -1,53 +0,0 @@ -$def with (filter_items) - -
- - - -
-
-
$_('Keyword')
- - -$if get('filter_cat') == "keyword": - $if get('filter_value'): - $_('Clear') - -

- - -$for cat in ["state", "tracker", "label"]: -
$cat
- -
-
- - - - diff --git a/deluge/plugins/label/label/webui.py b/deluge/plugins/label/label/webui.py new file mode 100644 index 000000000..d713503cd --- /dev/null +++ b/deluge/plugins/label/label/webui.py @@ -0,0 +1,142 @@ +# +# webui.py +# +# Copyright (C) 2008 Martijn Voncken +# +# Basic plugin template created by: +# Copyright (C) 2008 Martijn Voncken +# Copyright (C) 2007, 2008 Andrew Resch ('andar') +# +# Deluge is free software. +# +# You may 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 of the License, or (at your option) +# any later version. +# +# deluge 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 deluge. 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 + +import os +from deluge.common import fspeed +from deluge.log import LOG as log +from deluge.ui.client import sclient, aclient +from deluge.plugins.webuipluginbase import WebUIPluginBase +from deluge import component + +api = component.get("WebPluginApi") +forms = api.forms + +#pages: +class options: + @api.deco.deluge_page + def GET(self, label_id): + return api.render.label.options(label_id) + +class add: + @api.deco.deluge_page + def GET(self, label_id): + return api.render.label.options(label_id) + +class remove: + @api.deco.deluge_page + def GET(self, label_id): + return api.render.label.options(label_id) + + +class WebUI(WebUIPluginBase): + include_javascript = ["/label/data/label.js"] + urls = [ + ('/label/options/(.*)', options), + ('/label/add', add), + ('/label/remove/(.*)', remove) + ] + + def enable(self): + api.config_page_manager.register('plugins', 'label' ,ConfigForm) + + def disable(self): + api.config_page_manager.deregister('label') + +#options: + """ + todo (see gtkui) + sensitive_groups = [ + ("apply_max", ["max_download_speed", "max_upload_speed", "max_upload_slots", "max_connections"]), + ("apply_queue", ["is_auto_managed", "stop_at_ratio"]), + ("stop_at_ratio", ["remove_at_ratio", "stop_ratio"]), #nested + ("apply_move_completed", ["move_completed"]), + ("move_completed", ["move_completed_path"]), #nested + ("auto_add", ["auto_add_trackers"]) + ] +""" +class OptionsForm(forms.Form): + #maximum: + apply_max = forms.CheckBox(_("apply_max")) + max_download_speed = forms.DelugeInt(_("max_download_speed")) + max_upload_speed = forms.DelugeInt(_("max_upload_speed")) + max_upload_slots = forms.DelugeInt(_("max_upload_slots")) + max_connections = forms.DelugeInt(_("max_connections")) + + #queue: + apply_queue = forms.CheckBox(_("apply_queue")) + is_auto_managed = forms.CheckBox(_("is_auto_managed")) + stop_at_ratio = forms.CheckBox(_("stop_at_ratio")) + stop_ratio = forms.DelugeInt(_("stop_ratio")) + remove_at_ratio = forms.CheckBox(_("remove_at_ratio")) + + #location: + apply_move_completed = forms.CheckBox(_("apply_move_completed")) + move_completed = forms.CheckBox(_("move_completed")) + move_completed_path = forms.CharField(label=_("move_completed_path")) + + #tracker: + auto_add_trackers = forms.CharField(label=_("auto_add_trackers"), widget=forms.Textarea) + auto_add = forms.CheckBox(_("auto_add")) + + + +#config: +class ConfigForm(forms.Form): + """ + custom config page + too complex for the default config framework + """ + #meta: + title = _("Label") + info = _("Work in progress..") + + #load/save: + def initial_data(self): + return sclient.label_get_config() + + def save(self, data): + cfg = dict(data) + sclient.label_set_config(cfg) + + def pre_html(self): + """ custom config html/template""" + labels = sclient.label_get_labels() + return api.render.label.config(labels) + + + + #django newforms magic: define config fields: + #test = forms.CharField(label=_("Test config value")) diff --git a/deluge/plugins/label/label/webui/__init__.py b/deluge/plugins/label/label/webui/__init__.py deleted file mode 100644 index e330c5dc9..000000000 --- a/deluge/plugins/label/label/webui/__init__.py +++ /dev/null @@ -1,64 +0,0 @@ -# -# blocklist/webui.py -# -# Copyright (C) 2008 Martijn Voncken - -# -# Deluge is free software. -# -# You may 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 of the License, or (at your option) -# any later version. -# -# deluge 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 deluge. 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. - -import os -from deluge.log import LOG as log -from deluge.ui.client import sclient -from deluge import component -import ui - -import config -import pages -from deluge.plugins.webuipluginbase import WebUIPluginBase - - -#TODO: use more additions to WebUIPluginBase, thish whould be and example -lougin. -class WebUI(WebUIPluginBase): - include_javascript = ["/label/data/test1.js"] - - def enable(self): - log.debug("**HERE**") - pages.register() - config.register() - - def disable(self): - log.debug("**HERE**") - pages.deregister() - config.deregister() - - - - - - diff --git a/deluge/plugins/label/label/webui/config.py b/deluge/plugins/label/label/webui/config.py deleted file mode 100644 index 0d2360f5a..000000000 --- a/deluge/plugins/label/label/webui/config.py +++ /dev/null @@ -1,151 +0,0 @@ -# -# Copyright (C) 2008 Martijn Voncken -# -# Deluge is free software. -# -# You may 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 of the License, or (at your option) -# any later version. -# -# deluge 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 deluge. 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. - -import os -from deluge.log import LOG as log -from deluge.ui.client import sclient -from deluge import component - -api = component.get("WebPluginApi") -forms = api.forms - -class LabelUpdateCfgForm(forms.Form): - """ - a config form based on django forms. - see webui.lib.newforms_plus, config_forms, etc. - """ - #meta: - title = _("Labels") - - def get_selected(self): - selected = api.web.input(label = None).label - labels = sclient.label_get_labels() - if not selected: - if labels: - selected = labels[0] - return selected - - def pre_html(self): - selected = self.get_selected() - html = _("Select Label") + ":" - for label in sclient.label_get_labels(): - html += """ - %(label)s  """ % {"label":label} - html += "

%s

" % selected - return html - #load/save: - def initial_data(self): - label_id = self.get_selected() - return sclient.label_get_options(label_id) - - def save(self, data): - label_id = self.get_selected() - apply = data.apply - delete = data.delete - - if delete: - sclient.label_remove(label_id) - raise Exception("DELETED") - else: - del data["apply"] - del data["delete"] - sclient.label_set_options(label_id, dict(data), apply) - - #input fields : - apply_max = forms.CheckBox(_("Apply Maximum settings on add")) - max_connections = forms.DelugeInt(_("Maximum Connections")) - max_download_speed = forms.DelugeFloat(_("Maximum Download Speed (Kib/s)")) - max_upload_speed = forms.DelugeFloat(_("Maximum Upload Speed (Kib/s)")) - max_upload_slots = forms.DelugeInt(_("Maximum Upload Slots")) - move_completed_to = forms.ServerFolder(_("Move completed to"), required=False) - - apply = forms.CheckBox(_("Apply")) - delete = forms.CheckBox(_("Delete")) - - - -class LabelAddCfgForm(forms.Form): - """ - a config form based on django forms. - see webui.lib.newforms_plus, config_forms, etc. - """ - #meta: - title = _("Add Label") - - #load/save: - def initial_data(self): - return { } - - def save(self, data): - sclient.label_add(data.label) - - label = forms.CharField(_("Label")) - -class LabelCfgForm(forms.Form): - """ - global settings. - """ - #meta: - title = _("General") - - #load/save: - def initial_data(self): - return sclient.label_get_global_options() - - def save(self, data): - return sclient.label_set_global_options(dict(data)) - - hide_zero_hits = forms.CheckBox(_("Hide filter items with 0 hits")) - #gtk_alfa = forms.CheckBox(_("gtk_alfa")) - - - - -def register(): - api.config_page_manager.register('label','label_general',LabelCfgForm) - api.config_page_manager.register('label','label_update',LabelUpdateCfgForm) - api.config_page_manager.register('label','label_add',LabelAddCfgForm) - -def deregister(): - api.config_page_manager.deregister('label_general') - api.config_page_manager.deregister('label_update') - api.config_page_manager.deregister('label_add') - - - - - - - - - - - diff --git a/deluge/plugins/label/label/webui/pages.py b/deluge/plugins/label/label/webui/pages.py deleted file mode 100644 index 03ac8ac66..000000000 --- a/deluge/plugins/label/label/webui/pages.py +++ /dev/null @@ -1,79 +0,0 @@ -# -# -# Copyright (C) 2008 Martijn Voncken -# -# Deluge is free software. -# -# You may 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 of the License, or (at your option) -# any later version. -# -# deluge 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 deluge. 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. - -import os -from deluge.log import LOG as log -from deluge.ui.client import sclient -from deluge import component - -api = component.get("WebPluginApi") - -template_dir = os.path.join(os.path.dirname(__file__),"template") - -class torrent_label: - @api.deco.deluge_page - @api.deco.torrent_list - def GET(self, torrent_list): - torrent_str = ",".join([t.id for t in torrent_list]) - labels = sclient.label_get_labels() - return api.render.torrent_label(torrent_str , torrent_list , labels) - - @api.deco.check_session - @api.deco.torrent_ids - def POST(self, torrent_ids): - label =api.web.input(label = None).label - for id in torrent_ids: - sclient.label_set_torrent(id , label) - api.utils.do_redirect() - - -def register(): - api.render.register_template_path(template_dir) - api.page_manager.register_page('/torrent/label/(.*)', torrent_label) - api.menu_manager.register_toolbar_item("label",_("Label"), "label.png" ,2, - "GET","/torrent/label/", True) - -def deregister(): - api.render.deregister_template_path(template_dir) - api.page_manager.deregister_page('/torrent/label/(.*)') - api.menu_manager.deregister_toolbar_item("label") - - - - - - - - - - - diff --git a/deluge/plugins/label/label/webui/ui.py b/deluge/plugins/label/label/webui/ui.py deleted file mode 100644 index 4c6ac4aaa..000000000 --- a/deluge/plugins/label/label/webui/ui.py +++ /dev/null @@ -1,53 +0,0 @@ -# -# blocklist/ui.py -# -# Copyright (C) 2007 Andrew Resch ('andar') -# Copyright (C) 2008 Mark Stahler ('kramed') - -# -# Deluge is free software. -# -# You may 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 of the License, or (at your option) -# any later version. -# -# deluge 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 deluge. 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. - -import gettext -import locale -import pkg_resources -import deluge.component -from deluge.ui.client import aclient as client -from deluge.log import LOG as log - -class UI: - def __init__(self, plugin_api, plugin_name): - self.plugin = plugin_api - - def enable(self): - pass - - def disable(self): - pass - - \ No newline at end of file diff --git a/deluge/plugins/label/setup.py b/deluge/plugins/label/setup.py index f0973fd8e..70424fcf0 100644 --- a/deluge/plugins/label/setup.py +++ b/deluge/plugins/label/setup.py @@ -58,7 +58,7 @@ setup( license=__license__, long_description=__long_description__, - packages=[__plugin_name__.lower(), "label.gtkui", "label.webui"], + packages=[__plugin_name__.lower(), "label.gtkui"], package_data = __pkg_data__, entry_points=""" diff --git a/deluge/plugins/stats/stats/test_total.py b/deluge/plugins/stats/stats/test_total.py index c1810089b..ff64877ca 100644 --- a/deluge/plugins/stats/stats/test_total.py +++ b/deluge/plugins/stats/stats/test_total.py @@ -16,3 +16,8 @@ print_totals(sclient.stats_get_totals()) print "==session totals==" print_totals(sclient.stats_get_session_totals()) + + + + + diff --git a/deluge/ui/webui/templates/white/basic_header.html b/deluge/ui/webui/templates/white/basic_header.html new file mode 100644 index 000000000..91ff5991f --- /dev/null +++ b/deluge/ui/webui/templates/white/basic_header.html @@ -0,0 +1,20 @@ +$def with (title) + + + + + Deluge:$title + + + + + + + + + $for js in include_javascript: + + + + +
\ No newline at end of file diff --git a/deluge/ui/webui/templates/white/header.html b/deluge/ui/webui/templates/white/header.html index 04bcab3bb..ae3dc28ab 100644 --- a/deluge/ui/webui/templates/white/header.html +++ b/deluge/ui/webui/templates/white/header.html @@ -1,24 +1,5 @@ $def with (title, active_tab="NONE") - - - - - Deluge:$title - - - - - - - - - $for js in include_javascript: - - - - -
- +$:render.basic_header(title)