PBwiki plugins

 

PBwiki plugins are a simple way to bring in services and content from third parties. We have plugins for photo slide shows, calendars, videos, and so on.

 

We're actively seeking out new plugins that will help our users get more done (e.g., plan events, share content more easily, use spreadsheets online, etc). Business terms differ for each plugin, but the general overview is: Our users get the best tools, and you get access to a large community of active users. In the past, we've worked with a number of vendors, including 30 Boxes for their calendar, which was featured on TechCrunch and other sites. As Narendra Rocherolle, the founder of 30 Boxes, noted, "We have seen a sustained 10-15% increase in new accounts" from the PBwiki partnership.

 

We'll outline what's involved in integrating your services with the PBwiki community here.

 

 

Technical Overview

Generally, we'll need to decide on a shared secret (a few hundred bits of random data) to ensure correctness and then we can work together to call the correct remote url on your server, in addition to any particular arguments necessary for your plugin to work. In some cases this might mean just the name of the wiki (which you can consider to be globally unique for those users entitled to see or edit that wiki) and it might include names or email addresses, public-vs-private flags, and so on depending on the application.

 

 

Plugin definition

 

Here's our php code for a trivial plugin -- this code is run when a wiki page containing a 'demo' plugin is rendered for display, and the output of the renderer callback is substituted for the plugin placeholder: 

 

<?php

 

function plugin_demo_renderer($context) {

  $k_demo_shared_secret = 'i-am-not-a-very-good-shared-secret';

  $k_demo_hash_method = 'md5';

 

  $wiki = get_meta('wikiname');

  $wiki .= '.' . conf_get('general::domain'); //'pbwiki.com', e.g.

 

  $auth = policy_may_edit($context['page'])?1:0; //0=r 1=rw

 

  $urlargs = "mode=pbwiki&user=$wiki&authlevel=$auth";

  $signature = $k_demo_hash_method($k_demo_shared_secret . $urlargs);

  $urlargs .= "&key=$signature";

 

  $k_demo_badge_block = <<<EOT

<!-- Start of demo iframe -->

<iframe width="800" scrolling="no" height="300" frameborder="0" style="border: medium none ; overflow: hidden;" src="http://pbwiki.com/plugin_example.php?$urlargs"> </iframe>

<!-- End of demo iframe -->

EOT;

 

  return $k_demo_badge_block;

}

 

 

$GLOBALS['plugins']['demo'] = array(

                                    'enabled'=>is_dev(),

                                    'category'=>'Examples',

                                    'uncacheable'=>1,

                                    'displayname'=>'A demo plugin for this wiki',

                                    'description'=>'Demonstration',

                                    'subdescription'=>'Currently, there are no options to be configured for this plugin.  Press "Next" to see a preview.',

                                    'url'=>'http://example.com',

                                    'inputs'=>array( 

                                                    //none, this is effectively a placeholder

                                                    'size'=>array(

                                                                  'type'=>'hidden', //could be 'pulldown', for example

                                                                  'values'=>array('S'=>'Small','L'=>'Large'),

                                                                  'default'=>'L',

                                                                  ),

                                                    ),

                                    'hints'=>array(

                                                   'width'=>800,

                                                   'height'=>300,

                                                   ),

                                    'renderers'=>array( 

                                                       'Standard'=>'plugin_demo_renderer',

                                                       ), 

                                    );

?>

 

Output

 

Here's what the output of that kind of plugin looks like in a page:

 

 

 

Third-party code

 

And here's the code on the 'remote' side to make that output -- this would be running on the third party's servers. It doesn't have to be in php but this is a good example of validating the url signature:

<?php

 

print "<h4>This is an example pbwiki iframe plugin</h4>";

 

$k_demo_shared_secret = 'i-am-not-a-very-good-shared-secret'; 

$k_demo_hash_method = 'md5'; 

 

$args = array('mode','user','authlevel');

$qstring = '';

foreach($args as $k) {

  if($qstring) { $qstring .= '&'; }

  $qstring .= "$k=" . stripslashes($_GET[$k]);

}

 

print "<p>Query string: " . $_SERVER['REQUEST_URI'] . "</p>";

 

$signed_by_us = $k_demo_hash_method($k_demo_shared_secret . $qstring);

$signature_from_them = $_GET['key'];

print "<p>Query as signed by us: <strong>$signed_by_us</strong></p>";

print "<p>Signature according to request: <strong>$signature_from_them</strong></p>";

print "<p>";

if($signed_by_us == $signature_from_them) {

  print "<em>Signature matches, so I trust the following arguments.</em>";

 } else {

  print "<em>Signatures DO NOT MATCH, so I don't trust the following arguments.</em>";

 }

print "</p>";

 

print "<ul>";

foreach($_GET as $k=>$v) {

  print "<li>" . strip_tags($k) . ": " . strip_tags($v) . "</li>";

}

print "</ul>";

 

?>

 

 

Plugins we're especially interested in

  • Spreadsheet
  • Educational plugins (lesson plans, homework, etc)
  • Audio plugins that let users talk to each other
  • Forums/discussion groups

 

Get in touch

If you have a web service/tool that could be useful for the PBwiki community, please get in touch with Ramit Sethi.


Page Information

  • 1 year ago [history]
  • View page source
  • You're not logged in
  • No tags yet learn more

Wiki Information

Recent PBwiki Blog Posts