PageBus is an event and message bus implemented in JavaScript that enables disparate Ajax elements in a Web page to broadcast and listen for events and messages published on topic names. In addition to basic publish and subscribe APIs, PageBus supports hierarchical topic names and the use of token wildcards within those hierarchical topic names providing a rich means to listen for both general as well as specific information.

PageBus is open source software by TIBCO. It is included with MindTouch and does not need to be downloaded separately.

Inside MindTouch, you can connect a component (such as a Google map) to a PageBus channel, and then publish information to that channel (such as map co-ordinates), which will then cause anything listening to the channel to update (draw the new location on the map).

Vendor
MindTouch
Type Script
Categories Misc
Requires MindTouch Core 1.8.3 or later
Status Stable
License Free/Open Source
Manifest http://scripts.mindtouch.com/pagebus.xml

 

Install Script
To add  this script to your site, enter the address of your MindTouch installation (ex: http://www.mindtouch.com) and click the Add Script button.  This will open your control panel and prepopulate the necessary values.  You will still need to manually add configuration settings if required.  Note that no changes are made to your site until you confirm the action in your control panel.
Your site address:     


Table of Contents

Description

This extension contains functions for interacting with the PageBus.

See also How to add a script, Using the Extension Dialog, Learn about DekiScript, Extensions Directory.


Functions

pagebus.alert(subscribe : str, title : str) : 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 : str, publish : str, field : str, pattern : str) : 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.log(subscribe : str) : xml

Log messages on a channel in debug console.

Parameters:

NameTypeDescription
subscribestr(optional) Subscribe to channel. (default: "*")


pagebus.publish(channel : str, message : any) : xml

Publish a message on a channel.

Parameters:

NameTypeDescription
channelstrChannel to publish mesage on.
messageanyMessage to send.


pagebus.publishmany(channel : str, messages : list) : xml

Publish a list of messages on a channel.

Parameters:

NameTypeDescription
channelstrChannel to publish mesages on.
messageslistList of messages to send.


pagebus.republish(subscribe : str, publish : str, copy : map, add : map) : 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)


Script Source

<extension>
  <title>MindTouch PageBus Extension</title>
  <copyright>Copyright (c) 2006-2009 MindTouch Inc.</copyright>
  <uri.help>http://developer.mindtouch.com/App_Catalog/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>log</name>
		<description>Log messages on a channel in debug console.</description>
		<param name="subscribe" type="str" optional="true">Subscribe to channel. (default: "*")</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(typeof console != 'undefined') console.log('channel [%s] => %o', c, m); });
					</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="any">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>

  <function>
    <name>publishmany</name>
    <description>Publish a list of messages on a channel.</description>
    <param name="channel" type="str">Channel to publish mesages on.</param>
    <param name="messages" type="list">List of messages to send.</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <tail>
          <script type="text/javascript">
            <eval:foreach var="message" in="args.messages">DekiWiki.publish(<eval:js>args.channel</eval:js>, <eval:js>message</eval:js>);</eval:foreach>
          </script>
        </tail>
      </html>
    </return>
  </function>
</extension>

Tag page (Edit tags)
Viewing 7 of 7 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
Pagebus is used in the DHTML Extension:
http://wiki.developer.mindtouch.com/MindTouch_Deki/Extensions/DHtml
Posted 13:17, 6 Nov 2008
An explanation of PageBus can be found here:

http://wiki.developer.mindtouch.com/index.php?title=MindTouch_Deki/FAQ/Extensions/How_do_I...Take_advantage_of_the_Dapper_extension%3F/Dapper_%26_PageBus
Posted 13:49, 29 Nov 2008
If you want to read the values from the pagebus use http://developer.mindtouch.com/Deki/Extensions/DHtml#dhtml.span(subscribe.2c_field.2c_html)_.3a_xml
Posted 13:53, 3 Jun 2009
What is the persistence of data on the pagebus? Is it good for only one session on that one page, or if a user navigates to another page does that data stay in tact? ...between users?
Posted 18:26, 3 Dec 2009
@jonverve persistence is only for the current page and for the current user; to persistent information across pages for a single user use user properties
Posted 21:15, 3 Dec 2009
Excellent, thanks for the speedy response!!!! @SteveB
Posted 23:05, 3 Dec 2009
Viewing 7 of 7 comments: view all
You must login to post a comment.