Author: damoxc

Revision: 5794

Log:
        fix up the webui side of the plugin, even if it is skeletal

Diff:
Added: trunk/deluge/plugins/stats/stats/data/stats.js
===================================================================
--- trunk/deluge/plugins/stats/stats/data/stats.js                              
(rev 0)
+++ trunk/deluge/plugins/stats/stats/data/stats.js      2009-10-01 10:35:46 UTC 
(rev 5794)
@@ -0,0 +1,48 @@
+/*
+Script: stats.js
+    The javascript client-side code for the Stats plugin.
+
+Copyright:
+    (C) Damien Churchill 2009 <[email protected]>
+    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 3, 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.
+*/
+
+StatsPlugin = Ext.extend(Deluge.Plugin, {
+    constructor: function(config) {
+        config = Ext.apply({
+            name: "Stats"
+        }, config);
+        StatsPlugin.superclass.constructor.call(this, config);
+    },
+
+    onDisable: function() {
+    },
+
+    onEnable: function() {
+    }
+});
+new StatsPlugin();
\ No newline at end of file

Modified: trunk/deluge/plugins/stats/stats/webui.py
===================================================================
--- trunk/deluge/plugins/stats/stats/webui.py   2009-10-01 10:33:50 UTC (rev 
5793)
+++ trunk/deluge/plugins/stats/stats/webui.py   2009-10-01 10:35:46 UTC (rev 
5794)
@@ -1,12 +1,8 @@
 #
 # webui.py
 #
-# Copyright (C) 2008 Martijn Voncken <[email protected]>
+# Copyright (C) 2009 Damien Churchill <[email protected]>
 #
-# Basic plugin template created by:
-# Copyright (C) 2008 Martijn Voncken <[email protected]>
-# Copyright (C) 2007, 2008 Andrew Resch <[email protected]>
-#
 # Deluge is free software.
 #
 # You may redistribute it and/or modify it under the terms of the
@@ -36,103 +32,23 @@
 #    statement from all source files in the program, then also delete it here.
 #
 #
-#    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.ui.client import client
 from deluge import component
-import graph
+from deluge.plugins.pluginbase import WebPluginBase
 
-api = component.get("WebPluginApi")
-forms = api.forms
+from common import get_resource
 
-#pages:
-class graph_page:
-    @api.deco.deluge_page
-    def GET(self, args):
-        return api.render.stats.graph()
-
-class network_png:
-    @api.deco.check_session
-    def GET(self, args):
-        aclient.force_call(True) #bug, invalid data in async queue?
-        self.data = ''
-        vars = api.web.input(width = 600, height = 150)
-        api.web.header("Content-Type", "image/png")
-        g = graph.Graph()
-        g.add_stat('download_rate', color=graph.green)
-        g.add_stat('upload_rate', color=graph.blue)
-        g.set_left_axis(formatter=fspeed, min=10240)
-        g.async_request()
-        aclient.force_call(True)
-        surface = g.draw(int(vars.width), int(vars.height))
-        surface.write_to_png(self)
-        print self.data
-
-    def write(self, str): #file like object for pango; write_to_png
-        self.data += str
-
-class connections_png:
-    @api.deco.check_session
-    def GET(self, args):
-        "testing, not a final graph"
-        aclient.force_call(True) #bug, invalid data in async queue?
-        self.data = ''
-        vars = api.web.input(width = 600, height = 150)
-        api.web.header("Content-Type", "image/png")
-        g = graph.Graph()
-        g.add_stat('dht_nodes', color=graph.orange)
-        g.add_stat('dht_cache_nodes', color=graph.blue)
-        g.add_stat('dht_torrents', color=graph.green)
-        g.add_stat('num_connections', color=graph.darkred) #testing : non dht
-        g.set_left_axis(formatter=str, min=10)
-        g.async_request()
-        aclient.force_call(True)
-        surface = g.draw(int(vars.width), int(vars.height))
-        surface.write_to_png(self)
-        print self.data
-
-    def write(self, str): #file like object for pango; write_to_png
-        self.data += str
-
-class WebUI(WebUIPluginBase):
-    #map url's to classes: [(url,class), ..]
-    urls = [
-        ('/graph', graph_page),
-        ('/graph/network.png', network_png),
-        ('/graph/connections.png', connections_png)
-    ]
-
+class WebUI(WebPluginBase):
+    
+    scripts = [get_resource("stats.js")]
+    
+    # The enable and disable methods are not scrictly required on the WebUI
+    # plugins. They are only here if you need to register images/stylesheets
+    # with the webserver.
     def enable(self):
-        api.config_page_manager.register('plugins', 'stats' ,ConfigForm)
-        api.menu_manager.register_admin_page("stats", _("Stats"), "/graph") 
#<--top menu
+        log.debug("Stats Web plugin enabled!")
 
     def disable(self):
-        api.config_page_manager.deregister('stats')
-        api.menu_manager.deregister_admin_page("stats") #<--top menu
-
-
-class ConfigForm(forms.Form):
-    #meta:
-    title = _("Graph")
-
-    #load/save:
-    def initial_data(self):
-        return sclient.graph_get_config()
-
-    def save(self, data):
-        cfg = dict(data)
-        sclient.graph_set_config(cfg)
-
-    #django newforms magic: define config fields:
-    test = forms.CharField(label=_("Test config value"))
+        log.debug("Stats Web plugin disabled!")



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to