Changes between Version 16 and Version 17 of Development/Plugins/WebUi/Examples


Ignore:
Timestamp:
09/23/2008 06:50:25 PM (13 years ago)
Author:
mvoncken
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Development/Plugins/WebUi/Examples

    v16 v17  
    77 
    88'''Tested and developed on deluge-svn/Deluge 1.1''' 
     9''updated with newer api for r.3857'' 
    910 
    1011[[PageOutline(1-3,index,inline)]] 
     
    7980}}} 
    8081=== Webui plugin === 
    81 Edit ~/prj/deluge/plugins/Df/df/webui.py and add this above ConfigForm 
     82Edit ~/prj/deluge/plugins/Df/df/webui.py and replace the df_page and WebUI classes 
    8283 
    8384Note that api.render.df automatically maps to df.html , because of the call to api.render.register_template_path (see http://webpy.org/) 
    8485{{{ 
    8586#!python 
    86 template_dir = os.path.join(os.path.dirname(__file__),"template") 
    87  
    8887class df_page(): 
    8988    #@api.deco.deluge_page #requires  login, see page_decorators.py for more decorators, 
     
    9190    def GET(self, args): 
    9291        df_result = sclient.df_get_df() 
    93         return api.render.df(df_result) #push data to templates/df.html 
     92        return api.render.df.df(df_result) #push data to templates/df.html  
    9493 
    95 class WebUI(object): #replace/remove the old WebUI class 
    96     def __init__(self, plugin_api, plugin_name): 
    97         log.debug("Df plugin initalized..") 
    98         self.plugin = plugin_api 
     94class WebUI(WebUIPluginBase): 
     95    #map url's to classes: [(url,class), ..] 
     96    urls = [('/df', df_page)] #<--modified url mapping. 
    9997 
    10098    def enable(self): 
    101         api.config_page_manager.register('plugins','df',ConfigForm) 
    102         api.render.register_template_path(template_dir) #<--added 
    103         api.page_manager.register_page('/df', df_page)  #<--added 
     99        api.config_page_manager.register('plugins', 'df' ,ConfigForm) 
    104100 
    105101    def disable(self): 
    106102        api.config_page_manager.unregister('df') 
    107         api.render.unregister_template_path(template_dir) #<--added 
    108         api.page_manager.unregister_page('/df')   #<--added 
    109103 
    110104}}} 
    111105 
     106 
     107* Remove template/default.html , it's not used in api.render.df anymore. 
    112108 
    113109=== Test webui page === 
     
    128124#!python 
    129125    def enable(self): 
    130         api.config_page_manager.register('plugins','df',ConfigForm) 
    131         api.render.register_template_path(template_dir) #<--added 
    132         api.page_manager.register_page('/df', df_page)  #<--added 
     126        api.config_page_manager.register('plugins', 'df' ,ConfigForm) 
    133127        api.menu_manager.register_admin_page("df", _("Disk usage"), "/df") #<--top menu 
    134128 
    135129    def disable(self): 
    136130        api.config_page_manager.unregister('df') 
    137         api.render.unregister_template_path(template_dir) #<--added 
    138         api.page_manager.unregister_page('/df')   #<--added 
    139131        api.menu_manager.unregister_admin_page("df") #<--top menu 
    140132}}}