diff --git a/deluge/ui/webui/webui_plugin/config.py b/deluge/ui/webui/webui_plugin/config.py index c4c3ab3f2..6d0c9c062 100644 --- a/deluge/ui/webui/webui_plugin/config.py +++ b/deluge/ui/webui/webui_plugin/config.py @@ -29,6 +29,8 @@ # this exception statement from your version. If you delete this exception # statement from all source files in the program, then also delete it here. +#TODO: rename to config_manager.py + import lib.newforms_plus as forms import page_decorators as deco import lib.webpy022 as web diff --git a/deluge/ui/webui/webui_plugin/pages.py b/deluge/ui/webui/webui_plugin/pages.py index 26511e632..a8f80a610 100644 --- a/deluge/ui/webui/webui_plugin/pages.py +++ b/deluge/ui/webui/webui_plugin/pages.py @@ -42,6 +42,11 @@ from config import config_page from torrent_options import torrent_options from torrent_move import torrent_move + +#plugin like api's +import menu_manager +from menu_manager import TB + #import forms # from debugerror import deluge_debugerror @@ -61,6 +66,39 @@ import os #special/complex pages: from torrent_add import torrent_add +#plugin-like api's : register + +menu_manager.register_admin_page("config", _("Config"), "/config/") +menu_manager.register_admin_page("connect", _("Connect"), "/connect") +menu_manager.register_admin_page("about", _("About"), "/about") +menu_manager.register_admin_page("logout", _("Logout"), "/logout") + +menu_manager.register_detail_tab("details", _("Details"), "tab_meta") +menu_manager.register_detail_tab("files", _("Files"), "tab_files") +menu_manager.register_detail_tab("options", _("Options"), "tab_options") + +menu_manager.register_toolbar_item("add", _("Add"), "list-add.png" , TB.generic, + "GET","/torrent/add/", True) +menu_manager.register_toolbar_item("delete",_("Delete"), "list-remove.png" ,TB.torrent_list, + "GET","/torrent/delete/" , True) +menu_manager.register_toolbar_item("stop",_("Stop"), "pause.png" ,TB.torrent_list, + "POST","/torrent/stop/", True) +menu_manager.register_toolbar_item("start",_("Start"), "start.png" ,TB.torrent_list, + "POST","/torrent/start/", True) +menu_manager.register_toolbar_item("queue_up",_("Up"), "queue-up.png" ,TB.torrent_list, + "POST","/torrent/queue/up/", True) +menu_manager.register_toolbar_item("queue_down",_("Down"), "queue-down.png" ,TB.torrent_list, + "POST","/torrent/queue/down/", True) +menu_manager.register_toolbar_item("details",_("Details"), "details.png" ,TB.torrent, + "GET","/torrent/info/", True) +menu_manager.register_toolbar_item("move",_("Move"), "move.png" ,TB.torrent_list, + "POST","/torrent/move/", True) + +menu_manager.register_toolbar_item("reannounce",_("Reannounce"), "view-refresh.png" ,TB.torrent_list, + "POST","'/torrent/reannounce/", False) +menu_manager.register_toolbar_item("recheck",_("Recheck"), "view-refresh.png" ,TB.torrent_list, + "POST","'/torrent/recheck/", False) + #routing: urls = ( "/login", "login", diff --git a/deluge/ui/webui/webui_plugin/render.py b/deluge/ui/webui/webui_plugin/render.py index 60aafc264..f14b11ec9 100644 --- a/deluge/ui/webui/webui_plugin/render.py +++ b/deluge/ui/webui/webui_plugin/render.py @@ -66,6 +66,10 @@ class subclassed_render(object): else: return getattr(self.base_template, attr) + def __getitem__(self, item): + "for plugins/templates" + return getattr(self, item) + render = subclassed_render() def error_page(error): diff --git a/deluge/ui/webui/webui_plugin/templates/advanced/index.html b/deluge/ui/webui/webui_plugin/templates/advanced/index.html index 99305f446..9348c3162 100644 --- a/deluge/ui/webui/webui_plugin/templates/advanced/index.html +++ b/deluge/ui/webui/webui_plugin/templates/advanced/index.html @@ -12,51 +12,14 @@ $for t in torrent_list:
- +$for id, title, image, flag, method, url, important in toolbar_items: + $if important: + - - - - - - - - - - - - - - - - - - $:category_tabs(all_torrents) +$:category_tabs(all_torrents)
diff --git a/deluge/ui/webui/webui_plugin/templates/advanced/torrent_info_inner.html b/deluge/ui/webui/webui_plugin/templates/advanced/torrent_info_inner.html index 7e0d31d59..735301689 100644 --- a/deluge/ui/webui/webui_plugin/templates/advanced/torrent_info_inner.html +++ b/deluge/ui/webui/webui_plugin/templates/advanced/torrent_info_inner.html @@ -7,16 +7,12 @@ $def with (torrent, active_tab) -$:render.part_tab_button('details', _("Details"), active_tab) -$:render.part_tab_button('files', _("Files"), active_tab) -$:render.part_tab_button('options', _("Options"), active_tab) +$for id, title, tab in detail_tabs: + $:render.part_tab_button(id, title, active_tab) -$if active_tab == 'details': - $:render.tab_meta(torrent) -$if active_tab == 'files': - $:render.tab_files(torrent) -$if active_tab == 'options': - $:render.tab_options(torrent) +$for id, title, tab in detail_tabs: + $if active_tab == id: + $:render[tab](torrent) diff --git a/deluge/ui/webui/webui_plugin/templates/deluge/admin_toolbar.html b/deluge/ui/webui/webui_plugin/templates/deluge/admin_toolbar.html index 7b047cf11..c46ad6af3 100644 --- a/deluge/ui/webui/webui_plugin/templates/deluge/admin_toolbar.html +++ b/deluge/ui/webui/webui_plugin/templates/deluge/admin_toolbar.html @@ -1,10 +1,10 @@ $def with (active_tab)
- Config - - Connect - About - Logout +$for id, title, url in admin_pages: + $title
- diff --git a/deluge/ui/webui/webui_plugin/templates/deluge/torrent_info.html b/deluge/ui/webui/webui_plugin/templates/deluge/torrent_info.html index 270bce8ae..0dfa9722f 100644 --- a/deluge/ui/webui/webui_plugin/templates/deluge/torrent_info.html +++ b/deluge/ui/webui/webui_plugin/templates/deluge/torrent_info.html @@ -2,34 +2,13 @@ $def with (torrent) $:(render.header(torrent.message + '/' + torrent.name))
+$for id, title, image, flag, method, url, important in toolbar_items: + $if (flag > 0) and (id != 'details'): + $:render.part_button(method, (url + str(torrent.id)), title, 'tango/' + image) -$if (torrent.action == 'start'): - $:render.part_button('POST', '/torrent/start/' + str(torrent.id), _('Resume'), 'tango/start.png') -$else: - $:render.part_button('POST', '/torrent/stop/' + str(torrent.id), _('Pause'), 'tango/pause.png') - - -$:render.part_button('GET', '/torrent/delete/' + str(torrent.id), _('Remove'), 'tango/list-remove.png') -$:render.part_button('POST', '/torrent/reannounce/' + str(torrent.id), _('Reannounce'), 'tango/view-refresh.png') -$:render.part_button('POST', '/torrent/recheck/' + str(torrent.id), _('Recheck'), 'tango/view-refresh.png') - -$:render.part_button('POST', '/torrent/queue/up/' + str(torrent.id), _('Queue Up'), 'tango/queue-up.png') -$:render.part_button('POST', '/torrent/queue/down/' + str(torrent.id), _('Queue Down'), 'tango/queue-down.png') - -$:render.part_button('GET', '/torrent/move/' + str(torrent.id), _('Move'), 'tango/move.png') - -

$_('Details')

-$:render.tab_meta(torrent) - -

$_('Options')

- -$:render.tab_options(torrent) - - -

$_('Files')

- -$:render.tab_files(torrent) - +$for id, title, tab in detail_tabs: +

$title

+ $:render[tab](torrent)