PageBus

Installation

Follow these steps to install this script on your wiki.

  1. Go to Service managmenent inside the Control Panel.
  2. Under Add Service, click Local and select type Extension.
  3. Enter a descriptive name and the SID: sid://mindtouch.com/2007/12/dekiscript
  4. Add "manifest" to the config section with value set to http://scripts.mindtouch.com/pagebus.xml
  5. Add extra configuration values as listed below under Configuration (If Configuration is not listed below, ignore this step.)
  6. Click on add service.

Related Links: DekiScript service, Extension Overview, DekiScript Overview, Extension Demos.


Overview

This extension contains functions for interacting with the PageBus. This script requires MindTouch Deki 1.8.3 or later.

Functions:

  1. pagebus.alert
  2. pagebus.filter
  3. pagebus.publish
  4. pagebus.republish

pagebus.alert(subscribe, title) : xml

Show messages on a channel in an alert window.

Parameters:

NameTypeDescription
subscribestr(optional) Subscribe to channel. (default: "*")
titlestr(optional) Dialog title. (default: nil)


pagebus.filter(subscribe, publish, field, pattern) : xml

Filter messages before copying them to another channel.

Parameters:

NameTypeDescription
subscribestrSubscribe to channel.
publishstrPublish on channel.
fieldstrField to test.
patternstrRegular expression pattern to use for test.


pagebus.publish(channel, message) : xml

Publish a message on a channel.

Parameters:

NameTypeDescription
channelstrChannel to publish mesage on.
messagemapMessage to send.


pagebus.republish(subscribe, publish, copy, add) : xml

Republish messages to another channel.

Parameters:

NameTypeDescription
subscribestrSubscribe to channel.
publishstrPublish on channel.
copymap(optional) Fields to copy. (default: all)
addmap(optional) Fields to add. (default: none)


Source Code

<extension>
  <title>MindTouch PageBus Extension</title>
  <copyright>Copyright (c) 2008 MindTouch, Inc.</copyright>
  <uri.help>http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/PageBus</uri.help>
  <label>PageBus</label>
  <namespace>pagebus</namespace>
  <description>This extension contains functions for interacting with the PageBus.</description>

  <function>
    <name>alert</name>
    <description>Show messages on a channel in an alert window.</description>
    <param name="subscribe" type="str" optional="true">Subscribe to channel. (default: "*")</param>
    <param name="title" type="str" optional="true">Dialog title. (default: nil)</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <head>
          <script type="text/javascript">
            DekiWiki.subscribe(<eval:js>args.subscribe ?? '*'</eval:js>, null, function(c, m, d) { var s = ''; for(var f in m) s += f + ': ' + m[f] + '\n'; alert(<eval:js>args.title ?? 'Alert Box'</eval:js>  + '\nchannel: [' + c + ']\n' + s); });
          </script>
        </head>
      </html>
    </return>
  </function>

  <function>
    <name>republish</name>
    <description>Republish messages to another channel.</description>
    <param name="subscribe" type="str">Subscribe to channel.</param>
    <param name="publish" type="str">Publish on channel.</param>
    <param name="copy" type="map" optional="true">Fields to copy. (default: all)</param>
    <param name="add" type="map" optional="true">Fields to add. (default: none)</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <head>
          <script type="text/javascript">
            DekiWiki.subscribe(<eval:js>args.subscribe</eval:js>, null, function(c, m, d) {
              var result = m;
              if(d.copy) {
                result = { };
                for(var key in d.copy) result[key] = m[d.copy[key]];
              }
              if(d.add) for(var key in d.add) result[key] = d.add[key];
              DekiWiki.publish(<eval:js>args.publish</eval:js>, result);
            }, { copy: <eval:js>args.copy</eval:js>, add: <eval:js>args.add</eval:js> });
          </script>
        </head>
      </html>
    </return>
  </function>

  <function>
    <name>filter</name>
    <description>Filter messages before copying them to another channel.</description>
    <param name="subscribe" type="str">Subscribe to channel.</param>
    <param name="publish" type="str">Publish on channel.</param>
    <param name="field" type="str">Field to test.</param>
    <param name="pattern" type="str">Regular expression pattern to use for test.</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <head>
          <script type="text/javascript">
            DekiWiki.subscribe(<eval:js>args.subscribe</eval:js>, null, function(c, m, d) {
              if(DekiWiki.hasValue(m[<eval:js>args.field</eval:js>]) &amp;&amp; d.regex.test(m[<eval:js>args.field</eval:js>])) {
                DekiWiki.publish(<eval:js>args.publish</eval:js>, m);
              }
            }, { regex: new RegExp(<eval:js>args.pattern</eval:js>) });
          </script>
        </head>
      </html>
    </return>
  </function>

  <function>
    <name>publish</name>
    <description>Publish a message on a channel.</description>
    <param name="channel" type="str">Channel to publish mesage on.</param>
    <param name="message" type="map">Message to send.</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <tail>
          <script type="text/javascript">
            DekiWiki.publish(<eval:js>args.channel</eval:js>, <eval:js>args.message</eval:js>);
          </script>
        </tail>
      </html>
    </return>
  </function>
</extension>

Tag page
Viewing 1 of 1 comments: view all
After searching Google for Pagebus, I'm assuming this extension is related to TIBCO PageBus (http://www.tibco.com/devnet/pagebus/default.jsp. ) Unfortunately, it is still not clear how to use this extension. An example and explanation would be beneficial. It looks like it could be used with other extensions to create mash ups.
Posted 15:56, 18 Mar 2008
Viewing 1 of 1 comments: view all
You must login to post a comment.
Powered by MindTouch Deki v.8.08