mirror of
https://github.com/codex-storage/deluge.git
synced 2025-02-26 01:55:15 +00:00
consolidate manager-componets
This commit is contained in:
parent
dcc10b7819
commit
0eaa0aca27
@ -1,20 +0,0 @@
|
||||
0.5.7
|
||||
SSL
|
||||
torrent/add http-post for private sites
|
||||
rename reannounce->update-tracker.
|
||||
queued displays as seeding/downloading
|
||||
|
||||
|
||||
0.5.7 advanced layout
|
||||
fonts
|
||||
fix auto-refresh-layout
|
||||
buttons
|
||||
hide 0.0 kbps like in gtk-ui
|
||||
update-tracker.
|
||||
|
||||
0.6
|
||||
prepare for cat:
|
||||
filters on status (prepare for cat)
|
||||
filters on tracker
|
||||
categories
|
||||
greasemonkey : private sites.
|
@ -2,7 +2,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Copyright (C) Martijn Voncken 2007 <mvoncken@gmail.com>
|
||||
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
|
||||
#
|
||||
# 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
|
||||
@ -32,12 +32,24 @@
|
||||
#
|
||||
|
||||
"""
|
||||
register toolbar and menu items.
|
||||
future : required for plugin-api.
|
||||
"""
|
||||
from utils import logcall
|
||||
from render import template
|
||||
deluge components.
|
||||
|
||||
MenuManager:add torrent-menu-items and torrent-detail tabs.
|
||||
PageManager: add pages(urls)
|
||||
PluginManager: deluge plugin manager
|
||||
ConfigPageManager: add config pages(tabs)
|
||||
|
||||
These managers/components are accesible as:
|
||||
|
||||
from deluge import component
|
||||
manager = component.get("ClassName")
|
||||
|
||||
"""
|
||||
from deluge import component
|
||||
import lib.newforms_plus as forms
|
||||
from deluge.ui.client import aclient
|
||||
from deluge import component, pluginmanagerbase
|
||||
from deluge.configmanager import ConfigManager
|
||||
|
||||
class TOOLBAR_FLAGS:
|
||||
generic = 0
|
||||
@ -54,6 +66,7 @@ class MenuManager(component.Component):
|
||||
|
||||
|
||||
#register vars in template.
|
||||
from render import template
|
||||
template.Template.globals["admin_pages"] = self.admin_pages
|
||||
template.Template.globals["detail_tabs"] = self.detail_tabs
|
||||
template.Template.globals["toolbar_items"] = self.toolbar_items
|
||||
@ -88,5 +101,77 @@ class MenuManager(component.Component):
|
||||
del self.detail_tabs[i]
|
||||
return
|
||||
|
||||
__menu_manager = MenuManager()
|
||||
class PageManager(component.Component):
|
||||
"""
|
||||
web,py 0.2 mapping hack..
|
||||
see deluge_webserver.py
|
||||
"""
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "PageManager")
|
||||
self.page_classes = {}
|
||||
self.urls = []
|
||||
|
||||
def register_pages(self, url_list, class_list):
|
||||
self.urls += url_list
|
||||
self.page_classes.update(class_list)
|
||||
|
||||
def register_page(self, url, klass):
|
||||
self.urls.append(url)
|
||||
self.urls.append(klass.__name__)
|
||||
self.page_classes[klass.__name__] = klass
|
||||
|
||||
def unregister_page(self, url):
|
||||
raise NotImplemenetedError()
|
||||
#self.page_classes[klass.__name__] = None
|
||||
|
||||
class PluginManager(pluginmanagerbase.PluginManagerBase,
|
||||
component.Component):
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "WebPluginManager")
|
||||
self.config = ConfigManager("webui.conf")
|
||||
pluginmanagerbase.PluginManagerBase.__init__(
|
||||
self, "webui.conf", "deluge.plugin.webui")
|
||||
|
||||
def start(self):
|
||||
"""Start the plugin manager"""
|
||||
# Update the enabled_plugins from the core
|
||||
aclient.get_enabled_plugins(self._on_get_enabled_plugins)
|
||||
|
||||
def stop(self):
|
||||
# Disable the plugins
|
||||
self.disable_plugins()
|
||||
|
||||
|
||||
def _on_get_enabled_plugins(self, enabled_plugins):
|
||||
log.debug("Webui has these plugins enabled: %s", enabled_plugins)
|
||||
self.config["enabled_plugins"] = enabled_plugins
|
||||
|
||||
# Enable the plugins that are enabled in the config and core
|
||||
self.enable_plugins()
|
||||
|
||||
class ConfigPageManager(component.Component):
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "ConfigPageManager")
|
||||
self.groups = []
|
||||
self.blocks = forms.utils.datastructures.SortedDict()
|
||||
|
||||
def register(self, group, name, form):
|
||||
if not group in self.groups:
|
||||
self.groups.append(group)
|
||||
form.group = group
|
||||
self.blocks[name] = form
|
||||
|
||||
def unregister(self, name):
|
||||
del self.blocks[name]
|
||||
|
||||
|
||||
def register():
|
||||
__plugin_manager = PluginManager()
|
||||
__menu_manager = MenuManager()
|
||||
__page_manager = PageManager()
|
||||
__config_page_manager = ConfigPageManager()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
|
||||
#
|
||||
# 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 2, 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.
|
||||
|
||||
|
||||
from utils import logcall
|
||||
from render import template
|
||||
from deluge import component
|
||||
import lib.newforms_plus as forms
|
||||
|
||||
class ConfigPageManager(component.Component):
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "ConfigPageManager")
|
||||
self.groups = []
|
||||
self.blocks = forms.utils.datastructures.SortedDict()
|
||||
|
||||
def register(self, group, name, form):
|
||||
if not group in self.groups:
|
||||
self.groups.append(group)
|
||||
form.group = group
|
||||
self.blocks[name] = form
|
||||
|
||||
def unregister(self, name):
|
||||
del self.blocks[name]
|
||||
|
||||
__config_page_manager = ConfigPageManager()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -34,6 +34,7 @@ import locale
|
||||
from deluge.configmanager import ConfigManager
|
||||
import pkg_resources
|
||||
from deluge.ui.client import sclient
|
||||
import components
|
||||
|
||||
# Initialize gettext
|
||||
locale.setlocale(locale.LC_MESSAGES, '')
|
||||
@ -49,12 +50,7 @@ gettext.install("deluge",
|
||||
pkg_resources.resource_filename(
|
||||
"deluge", "i18n"))
|
||||
|
||||
|
||||
#self registering components:
|
||||
import plugin_manager #registers as "WebPluginManager"
|
||||
import menu_manager #registers as "MenuManager"
|
||||
import config_page_manager #registers as "ConfigPageManager"
|
||||
import page_manager #registers as "PageManager"
|
||||
components.register() #after gettext!!
|
||||
|
||||
from debugerror import deluge_debugerror
|
||||
from render import render
|
||||
|
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Copyright (C) Martijn Voncken 2007 <mvoncken@gmail.com>
|
||||
#
|
||||
# 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 2, 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.
|
||||
#
|
||||
|
||||
from deluge import component
|
||||
|
||||
class PageManager(component.Component):
|
||||
"""
|
||||
web,py 0.2 mapping hack..
|
||||
see deluge_webserver.py
|
||||
"""
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "PageManager")
|
||||
self.page_classes = {}
|
||||
self.urls = []
|
||||
|
||||
def register_pages(self, url_list, class_list):
|
||||
self.urls += url_list
|
||||
self.page_classes.update(class_list)
|
||||
|
||||
def register_page(self, url, klass):
|
||||
self.urls.append(url)
|
||||
self.urls.append(klass.__name__)
|
||||
self.page_classes[klass.__name__] = klass
|
||||
|
||||
def unregister_page(self, url):
|
||||
raise NotImplemenetedError()
|
||||
#self.page_classes[klass.__name__] = None
|
||||
|
||||
__page_manager = PageManager()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,69 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
#
|
||||
# Copyright (C) Martijn Voncken 2008 <mvoncken@gmail.com>
|
||||
#
|
||||
# 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 2, 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.
|
||||
#
|
||||
|
||||
from deluge import component, pluginmanagerbase
|
||||
from deluge.configmanager import ConfigManager
|
||||
from deluge.log import LOG as log
|
||||
from deluge.ui.client import aclient as client
|
||||
|
||||
|
||||
class PluginManager(pluginmanagerbase.PluginManagerBase,
|
||||
component.Component):
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "WebPluginManager")
|
||||
self.config = ConfigManager("webui.conf")
|
||||
pluginmanagerbase.PluginManagerBase.__init__(
|
||||
self, "webui.conf", "deluge.plugin.webui")
|
||||
|
||||
def start(self):
|
||||
"""Start the plugin manager"""
|
||||
# Update the enabled_plugins from the core
|
||||
client.get_enabled_plugins(self._on_get_enabled_plugins)
|
||||
|
||||
def stop(self):
|
||||
# Disable the plugins
|
||||
self.disable_plugins()
|
||||
|
||||
|
||||
def _on_get_enabled_plugins(self, enabled_plugins):
|
||||
log.debug("Webui has these plugins enabled: %s", enabled_plugins)
|
||||
self.config["enabled_plugins"] = enabled_plugins
|
||||
|
||||
# Enable the plugins that are enabled in the config and core
|
||||
self.enable_plugins()
|
||||
|
||||
|
||||
__plugin_manager = PluginManager()
|
||||
|
||||
|
||||
|
@ -54,5 +54,5 @@ menu.register_toolbar_item("queue_up",_("Up"), "queue-up.png" ,TB.torrent_list,
|
||||
menu.register_toolbar_item("queue_down",_("Down"), "queue-down.png" ,TB.torrent_list, "POST","/torrent/queue/down/", True)
|
||||
menu.register_toolbar_item("details",_("Details"), "details.png" ,TB.torrent, "GET","/torrent/info/", True)
|
||||
menu.register_toolbar_item("move",_("Move"), "move.png" ,TB.torrent_list,"POST","/torrent/move/", True)
|
||||
menu.register_toolbar_item("reannounce",_("Reannounce"), "view-refresh.png" ,TB.torrent_list, "POST","'/torrent/reannounce/", False)
|
||||
menu.register_toolbar_item("recheck",_("Recheck"), "view-refresh.png" ,TB.torrent_list, "POST","'/torrent/recheck/", False)
|
||||
menu.register_toolbar_item("reannounce",_("Reannounce"), "view-refresh.png" ,TB.torrent_list, "POST","/torrent/reannounce/", False)
|
||||
menu.register_toolbar_item("recheck",_("Recheck"), "view-refresh.png" ,TB.torrent_list, "POST","/torrent/recheck/", False)
|
||||
|
Loading…
x
Reference in New Issue
Block a user