docs/main/LiveWidget.rst | 44 +++++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 25 deletions(-)
New commits: commit dff14a2249fb223cc853270ff49519cc7d216188 Author: Luke Macken lmacken@redhat.com Date: Wed Feb 4 06:48:21 2009 -0500
Some Live Widget documentation improvements
diff --git a/docs/main/LiveWidget.rst b/docs/main/LiveWidget.rst index d0d9ba8..f1d9709 100644 --- a/docs/main/LiveWidget.rst +++ b/docs/main/LiveWidget.rst @@ -23,8 +23,12 @@ the 'stuff' message topic, and will perform an `alert` upon new messages. template = "Hi, I'm a live widget!"
-The Live Feed Widget --------------------- +Live Feeds +---------- + +A Live Feed Demo Widget +~~~~~~~~~~~~~~~~~~~~~~~ +
.. code-block:: python
@@ -34,9 +38,11 @@ The Live Feed Widget :tabs: demo, source, template, parameters :size: large
--------------------------------------------------------------------------------- +The Live Feed Widget +~~~~~~~~~~~~~~~~~~~~
-Moksha provides an example :class:`LiveFeedWidget` that displays messages from the `feed_example` topic, using jQuery. +The :class:`LiveFeedWidget` itself is just a simple :class:`LiveWidget` that +uses a little bit of jQuery to add and remove feed entries from a list.
.. code-block:: python
@@ -45,32 +51,20 @@ Moksha provides an example :class:`LiveFeedWidget` that displays messages from t
class LiveFeedWidget(LiveWidget): """ A live streaming feed widget """ - topic = 'feed_example' + params = { + 'url': 'The feed URL', + 'topic': 'A topic or list of topics to subscribe to', + 'feed': 'A moksha Feed object', + } + template = '${feed(id=id, url=url)}' onmessage = """ $.each(json, function() { $("#${id} ul li:last").remove(); - $("<li/>").hide().html( + $("<li/>").html( $("<a/>") .attr("href", this.link) .text(this.title)) - .prependTo($("#${id} ul")) - .show(); + .prependTo($("#${id} ul")); }); """ - template = '${feed()}' - url = None - - def update_params(self, d): - super(LiveFeedWidget, self).update_params(d) - d['feed'] = Feed(d['id'], url=d.url) - -Using the LiveFeedWidget ------------------------- - -.. code-block:: python - - from moksha.api.widgets.feed import LiveFeedWidget - - class MyLiveWidget(LiveFeedWidget): - topic = 'feeds.myfeed' - url = 'http://foo.com/bar.xml' + feed = Feed()