Google Wave Testing

Just testing out some embedded wave stuff. I'm planning on working on a habari plugin for this. If all you see is the Wave login, then you won't be able to do anything with this. Those that do have a wave login should be able to use the wave.

If you don't see the wave login... Well, I've been having mixed results with that but think I've got the cause nailed down now.



 
 

Google Analytics Dashboard Plugin

It's finished! I've uploaded the plugin to the -extras repo, so you can grab it there. The current version requires Habari 0.7 to run. I've gone ahead and made a 0.6 branch. I don't have 0.6 installed anywhere right now to test, so if you get the chance to, let me know if it works or not. Once I find out I'll make a tag for it.

The plugin allows you to create your own dashboard modules for any reports that you want to see. Each module is made up from a XML file which tells the plugin what info we need from Google Analytics, and a PHP template that is used to output the modules display.

The templates have access to all of the data from the report. This way if you need to override anything that the plugin functions would handle you can. A perfect example is actually in one of the default modules, Content Overview. That template outputs the module pane without using any internal functions:

<ul class="items">
	<?php foreach ( $data[1] as $k => $v ) { ?>
	<li class="item clear">
		<span class="message pct75 minor"><?php echo $k; ?></span>
		<span class="date pct15 minor"><?php echo $v; ?> views</span>
		<span class="comments pct10"><?php echo number_format( (($v / $data_total) * 100), 2); ?>%</span>
	</li>
	<?php } ?>
</ul>

As I mentioned, you can also override any builtin functions that you need to. Googles GeoMap Visualization doesn't seem to properly detect the width of the DIV that it's contained in, so it tends to be wider than what your div actually is. To work around this, in the template, we actually add in a little detection and do the chart options there instead of in the map_overlay.xml.

<div id="div_<?php echo $slug; ?>"></div>
<script type="text/javascript">
// Get the actual width of the div
var divWidth = document.getElementById("div_<?php echo $slug; ?>").offsetWidth;
// Load up our GeoMap options instead of using builtin $js_opts
var opts = { 
	height: 200,
	width: divWidth,
	showLegend: false
};
<?php echo $js_data; ?>
<?php echo $js_draw; ?>
</script>

So to create your own dashboard modules, just create your report_name.xml and report_name.php in the custom directory. All of your custom modules should go here. I've split this up so that you can upgrade the plugin without losing any custom modules you have already done.

Just to show you how flexible this is, I'll cover how to create a Visitors vs Pageviews module for your dashboard. (Don't worry about copying all of this out. It's available as example_report_1 in the custom directory.) First, we'll create the XML that tells the plugin what dimensions and metrics we want to pull from Google Analytics.

<?xml version="1.0" encoding="utf-8" ?>
<report>
	<name>Visits vs Pageviews</name>
	<type>linechart</type>
	<opts>height: 200, backgroundColor: 'FAFAFA', legendBackgroundColor: 'FAFAFA', legend: 'bottom'</opts>
	<sort>none</sort>
 
	<dataReference order="1">
		<dimensions>ga:month,ga:day</dimensions>
		<metrics>ga:visits</metrics>
		<sort>ga:month</sort>
	</dataReference>
	<dataReference order="2">
		<dimensions>ga:month,ga:day</dimensions>
		<metrics>ga:pageviews</metrics>
		<sort>ga:month</sort>
	</dataReference>
 
	<dataTypes>
		<row type="string">Date</row>
		<row type="number">Visitors</row>
		<row type="number">Pageviews</row>
	</dataTypes>
</report>

And here's the PHP template that it uses:

<div id="div_<?php echo $slug; ?>"></div>
<script type="text/javascript">
	var opts = { <?php echo $js_opts; ?> };
	<?php echo $js_data; ?>
	<?php echo $js_draw; ?>
</script>

Pretty simple, huh? This will output the following on your dashboard module:

example_report_1.jpg

Any questions/problems, you can leave a comment here or catch me in #habari.

 
 

Habari Google Analytics Plugin

So I've started on a Google Analytics plugin for Habari. It pulls the information from your analytics account and displays it on the dashboard. Here's what it currently looks like:

Habari Google Analytics Plugin

Yes, I know. It still needs some tweaking. I'm hoping to get this to a point that I can release it up to extras soon. Currently there are four dashboard modules:

  • Traffic Sources Overview
  • Content Overview
  • Visitors Overview
  • Map Overlay

These are the same modules that show up on your Analytics desktop as well. The graphs and map are generated using the Google Visualization API, so they're interactive. Click on a data point and get the information for that particular metric.

If you have any suggestions for some other pre-canned reports, let me know.

 
 

Habari plugins post r3624

So I tend to run the trunk version of Habari here on this site. As a result, there was a change that came along with r3624 in regards to plugins. (That would be version 0.7-alpha for those not paying attention.) Previously your plugin would have something along these lines:

class MyPlugin extends Plugin
{
  function info()
  {
    return array(
      'name' => 'My Plugin',
      'version' => '1.0',
      'url' => 'http://habariproject.org/',
      'author' => 'Habari Community',
      'authorurl' => 'http://habariproject.org/',
      'license' => 'Apache License 2.0',
      'description' => 'Description'
    );
  }
}

Now, with r3624 this function is no longer allowed in the plugin code. This information has been moved out to the .xml file that should be with your plugin. (You have been using the .xml that should be there, right?!) Guess what? There's even a Pluggable schema file and a validation tool available to test out your plugins .xml file. Just as reference, if you're looking to update some plugins that you currently use, the above code would end up in a .xml file that looks like:

<?xml version="1.0" encoding="utf-8" ?> 
<pluggable type="plugin">
	<name>My Plugin</name>
	<license url="http://www.apache.org/licenses/LICENSE-2.0.html">Apache Software License 2.0</license>
	<author url="http://habariproject.org/">Habari Community</author>
	<version>1.0</version>
	<url>http://habariproject.org/</url>
	<description><![CDATA[Description]]></description>
	<copyright>2009</copyright>
</pluggable>

After updating my site here, I had to go through and update a few plugins myself that were sitting out in -extras, as well as a few that are not hosted there (which I find very annoying). If you are using a plugin from -extras that isn't already updated, please make sure to let the author know. Maybe even save them some work and shoot over your changes.

There were also some changes to the layout that should be used in -extras, so make sure to check in branches for a 0.7-0.x instead of using trunk now.

 
 

Habari Brightkite Plugin

Last night I cranked out a quick and dirty Brightkite plugin for Habari. It pulls the most current checked in data and displays that along with a map on your site. Here on this site, it outputs something along these lines:

brightkite_plugin.jpg

Or I could have just pointed you to my sidebar to the right to see it in action here. To use the plugin you'll need a Google Maps API Key to generate the images. If you don't already have one, you can get one for free from here.

The latest version can be grabbed from the Habari Extras repo. Installation instructions are up on the wiki here. Feel free to contact me if you hit any issues.