['Development'] ['Development/Plugins'] = Webui Examples = == Adding a page to the webui == === Intro === Webui templates are dumb, they get passed data from python, and can't call uiclient api's directly. They are there to format the data, not to execute logic. Template language: http://webpy.org/templetor == Flow of the data == ''Disclaimer, MVC is a highly abused therm, and i'm abusing it here.'' {{{ deluged->xmlrpc->uiclient-> webui -> data passed as arguments to template. ('Model' ) ('controller') ('view') }}} == Example : a df page in webui == This example assumes you have deluge svn checked out to "~/src/deluge" And that your plugin-development-directory is "~/prj/deluge/plugins" This plugin will add a page to deluge that display the output of "df -h" to a page in the webui. === Create a new plugin === {{{ cd ~/prj/deluge/plugins python ~/src/deluge/deluge/scripts/create_plugin.py --name Df --basepath . --author-name "My Name" --author-email "deluge@example.com" }}} === Restart deluge(d) and enable the plugin in the gtk-ui. === * Add a core method. Add this method to ~/prj/deluge/plugins/Df/df/core.py {{{ #!python def export_get_df(self): "returns the result of 'df -h' as a string" import subprocess return subprocess.call(["df","-h"]) }}} === Test the new method. === create ~/prj/deluge/plugins/df/Df/test.py ; Contents: {{{ #!python from deluge.ui.client import sclient sclient.set_core_uri() print sclient.df_get_df() #export method is prefixed by plugin-name. }}} === Execute test === {{{ cd ~/prj/deluge/plugins/Df/df killall deluged & deluged && python test.py }}} Fix any errors until the test outputs the desired result. == todo, webui part ==