moksha/examples/livegraph/__init__.py | 17 ------
moksha/examples/livegraph/livegraph.py | 66 -------------------------
moksha/examples/livegraph/static/livegraph.css | 6 --
moksha/examples/livegraph/static/livegraph.js | 42 ---------------
moksha/widgets/livegraph/__init__.py | 17 ++++++
moksha/widgets/livegraph/livegraph.py | 66 +++++++++++++++++++++++++
moksha/widgets/livegraph/static/livegraph.css | 6 ++
moksha/widgets/livegraph/static/livegraph.js | 42 +++++++++++++++
8 files changed, 131 insertions(+), 131 deletions(-)
New commits:
commit 41dde29c97ca624f952f3136e73cbe6029f13837
Author: Luke Macken <lmacken(a)redhat.com>
Date: Sat Jun 27 20:43:31 2009 -0400
Move moksha.examples.livegraph to moksha.widgets.livegraph, for now.
This app will probably eventually be encorporated with the demo application
diff --git a/moksha/examples/__init__.py b/moksha/examples/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/moksha/examples/livegraph/__init__.py
b/moksha/examples/livegraph/__init__.py
deleted file mode 100644
index 9241973..0000000
--- a/moksha/examples/livegraph/__init__.py
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is part of Moksha.
-# Copyright (C) 2008-2009 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <
http://www.gnu.org/licenses/>.
-
-from livegraph import *
diff --git a/moksha/examples/livegraph/livegraph.py
b/moksha/examples/livegraph/livegraph.py
deleted file mode 100644
index e346853..0000000
--- a/moksha/examples/livegraph/livegraph.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# This file is part of Moksha.
-# Copyright (C) 2008-2009 Red Hat, Inc.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as
-# published by the Free Software Foundation, either version 3 of the
-# License, 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 Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with this program. If not, see <
http://www.gnu.org/licenses/>.
-#
-# Authors: Luke Macken <lmacken(a)redhat.com>
-
-from random import random
-from datetime import timedelta
-
-from tw.api import CSSLink, JSLink, js_function
-
-from moksha.api.widgets import LiveWidget
-from moksha.api.streams import PollingDataStream
-
-class LiveGraphWidget(LiveWidget):
- """
- This is an example live graph widget based on Michael Carter's article
- "Scalable Real-Time Web Architecture, Part 2: A Live Graph with Orbited,
- MorbidQ, and js.io".
-
-
http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part...
- """
- params = ['id', 'onconnectedframe', 'onmessageframe']
- topic = 'graph_demo'
- onmessage = 'modify_graph(bars, frame.body)'
- javascript = [JSLink(filename='static/livegraph.js', modname=__name__)]
- css = [CSSLink(filename='static/livegraph.css', modname=__name__)]
- template = '<div id="${id}" />'
-
- def update_params(self, d):
- super(LiveGraphWidget, self).update_params(d)
- self.add_call(js_function('init_graph')(self.id))
-
-
-class LiveGraphDataStream(PollingDataStream):
- """
- This is the main data producer for our live graph widget.
- """
- frequency = timedelta(seconds=0.5)
-
- data_vector_length = 10
- delta_weight = 0.1
- max_value = 400 # NB: this in pixels
- data = [int(random()*max_value) for x in xrange(data_vector_length)]
-
- def poll(self):
- self.data = [
- min(max(datum + (random() - .5) * self.delta_weight *
- self.max_value, 0),
- self.max_value)
- for
- datum in self.data
- ]
- self.send_message('graph_demo', self.data)
diff --git a/moksha/examples/livegraph/static/livegraph.css
b/moksha/examples/livegraph/static/livegraph.css
deleted file mode 100644
index a4f3493..0000000
--- a/moksha/examples/livegraph/static/livegraph.css
+++ /dev/null
@@ -1,6 +0,0 @@
-.bar {
- background-color: #38f;
- height: 12px;
- width: 200px;
- margin: 3px 0px;
-}
diff --git a/moksha/examples/livegraph/static/livegraph.js
b/moksha/examples/livegraph/static/livegraph.js
deleted file mode 100644
index fe1664f..0000000
--- a/moksha/examples/livegraph/static/livegraph.js
+++ /dev/null
@@ -1,42 +0,0 @@
-// This file is part of Moksha.
-// Copyright (C) 2008-2009 Red Hat, Inc.
-//
-// This program is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Affero General Public License as
-// published by the Free Software Foundation, either version 3 of the
-// License, 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 Affero General Public License for more details.
-//
-// You should have received a copy of the GNU Affero General Public License
-// along with this program. If not, see <
http://www.gnu.org/licenses/>.
-
-var bars = [];
-var num_bars = 10;
-
-// Make ten bars that are blue
-var init_graph = function(container_name) {
-
- var container = document.getElementById(container_name);
- for (var i=0; i< num_bars; i++) {
- var bar = document.createElement('div');
- bar.className = "bar";
- bar.style.width = "100px";
- bars.push(bar);
- container.appendChild(bar);
- }
- // some pizazz... one bar gets to be red.
- bars[3].style.backgroundColor = "red";
-};
-
-// Change the length of the bars to match given numerical data
-var modify_graph = function(bars, payload) {
- var vals = JSON.parse(payload);
- for (var i=0; i<bars.length; i++) {
- var bar = bars[i];
- bar.style.width = vals[i] + "px";
- }
-}
diff --git a/moksha/widgets/livegraph/__init__.py b/moksha/widgets/livegraph/__init__.py
new file mode 100644
index 0000000..9241973
--- /dev/null
+++ b/moksha/widgets/livegraph/__init__.py
@@ -0,0 +1,17 @@
+# This file is part of Moksha.
+# Copyright (C) 2008-2009 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+
+from livegraph import *
diff --git a/moksha/widgets/livegraph/livegraph.py
b/moksha/widgets/livegraph/livegraph.py
new file mode 100644
index 0000000..e346853
--- /dev/null
+++ b/moksha/widgets/livegraph/livegraph.py
@@ -0,0 +1,66 @@
+# This file is part of Moksha.
+# Copyright (C) 2008-2009 Red Hat, Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, 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 Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <
http://www.gnu.org/licenses/>.
+#
+# Authors: Luke Macken <lmacken(a)redhat.com>
+
+from random import random
+from datetime import timedelta
+
+from tw.api import CSSLink, JSLink, js_function
+
+from moksha.api.widgets import LiveWidget
+from moksha.api.streams import PollingDataStream
+
+class LiveGraphWidget(LiveWidget):
+ """
+ This is an example live graph widget based on Michael Carter's article
+ "Scalable Real-Time Web Architecture, Part 2: A Live Graph with Orbited,
+ MorbidQ, and js.io".
+
+
http://cometdaily.com/2008/10/10/scalable-real-time-web-architecture-part...
+ """
+ params = ['id', 'onconnectedframe', 'onmessageframe']
+ topic = 'graph_demo'
+ onmessage = 'modify_graph(bars, frame.body)'
+ javascript = [JSLink(filename='static/livegraph.js', modname=__name__)]
+ css = [CSSLink(filename='static/livegraph.css', modname=__name__)]
+ template = '<div id="${id}" />'
+
+ def update_params(self, d):
+ super(LiveGraphWidget, self).update_params(d)
+ self.add_call(js_function('init_graph')(self.id))
+
+
+class LiveGraphDataStream(PollingDataStream):
+ """
+ This is the main data producer for our live graph widget.
+ """
+ frequency = timedelta(seconds=0.5)
+
+ data_vector_length = 10
+ delta_weight = 0.1
+ max_value = 400 # NB: this in pixels
+ data = [int(random()*max_value) for x in xrange(data_vector_length)]
+
+ def poll(self):
+ self.data = [
+ min(max(datum + (random() - .5) * self.delta_weight *
+ self.max_value, 0),
+ self.max_value)
+ for
+ datum in self.data
+ ]
+ self.send_message('graph_demo', self.data)
diff --git a/moksha/widgets/livegraph/static/livegraph.css
b/moksha/widgets/livegraph/static/livegraph.css
new file mode 100644
index 0000000..a4f3493
--- /dev/null
+++ b/moksha/widgets/livegraph/static/livegraph.css
@@ -0,0 +1,6 @@
+.bar {
+ background-color: #38f;
+ height: 12px;
+ width: 200px;
+ margin: 3px 0px;
+}
diff --git a/moksha/widgets/livegraph/static/livegraph.js
b/moksha/widgets/livegraph/static/livegraph.js
new file mode 100644
index 0000000..fe1664f
--- /dev/null
+++ b/moksha/widgets/livegraph/static/livegraph.js
@@ -0,0 +1,42 @@
+// This file is part of Moksha.
+// Copyright (C) 2008-2009 Red Hat, Inc.
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, 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 Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see <
http://www.gnu.org/licenses/>.
+
+var bars = [];
+var num_bars = 10;
+
+// Make ten bars that are blue
+var init_graph = function(container_name) {
+
+ var container = document.getElementById(container_name);
+ for (var i=0; i< num_bars; i++) {
+ var bar = document.createElement('div');
+ bar.className = "bar";
+ bar.style.width = "100px";
+ bars.push(bar);
+ container.appendChild(bar);
+ }
+ // some pizazz... one bar gets to be red.
+ bars[3].style.backgroundColor = "red";
+};
+
+// Change the length of the bars to match given numerical data
+var modify_graph = function(bars, payload) {
+ var vals = JSON.parse(payload);
+ for (var i=0; i<bars.length; i++) {
+ var bar = bars[i];
+ bar.style.width = vals[i] + "px";
+ }
+}