Geekout: Video on Maps for Cable Access TV

I recently did some Drupal development work for Cambridge Community Television. As part of the really amazing work they are doing combining new media with traditional Cable Access Television, CCTV has been mapping videos their members produce. They call this project the Mediamap.

I was really excited to work on the Mediamap with CCTV because of my long involvement with Cable Access Television, most notably the now-defunct DigitalBicycle Project and the community maintained directory of Cable Access Stations I built and administer: MappingAccess.com.

Despite CCTV running their website on Drupal, their first proof-of-concept version of the Mediamap was created manually, using the very capable Mapbuilder.net service and copy-and-pasted embedded flash video. While simple from a technological standpoint, they were running to problems optimizing the workflow of updating the map; changes had to be made via the Mapbuilder.net interface, with a single username and password, then manually parsed to remove some coding irregularities, and finally copy and pasted whole into a page on their website.

I was asked to improve the workflow and ultimately take fuller advantage of Drupal’s built-in user management and content management features. For instance, taking advantage of CCTV’s current member submitted video capabilities and flowing them into the map as an integrated report, not a separate and parallel system.

In my discussions with them, a couple of issues came up. Foremost was that CCTV was running an older version of Drupal: 4.7. While still quite powerful, many newer features and contributed modules were not available for this earlier release. The current version of Drupal, 5.1, has many rich, well-developed utilities for creating reports and mapping them: Content Construction Kit (CCK) + Views + Gmap + Location. As it was though, with the older version, I would have to develop the additional functionality manually.

The following is a description, with code examples, of the functionality I created for the Mediamap. Additionally, following this initial development, CCTV upgraded their Drupal installation to 5.1, giving me the opportunity to demonstrate the ease and power of Drupal’s most recent release—rendering blissfully obsolete most of the custom coding I had done.

Location and Gmap was used in both versions for storing geographic data and hooking into the Google Map API. One of Drupal’s great strengths is the both the diversity of contributed modules, and the flexibility with which a developer can use them.

Adding additional content fields

CCTV already has a process in which member’s can submit content nodes. In 4.7, the easiest way to add additional data fields to these was with a custom NodeAPI module. CCTV was interested in using embedded flash video, primarily from Blip.tv, but also Google Video or YouTube if the flexibility was needed. To simplify the process, we decided on just adding the cut-and-paste embed code to a custom content field in existing nodes.

To do this, I created a new module that invoked hook_nodeapi:
/**
* Implementation of hook_nodeapi
*/
function cambridge_mediamap_nodeapi(&$node, $op, $teaser, $page) {
switch ($op) {

case 'validate':
if (variable_get('cambridge_mediamap_'. $node->type, TRUE)) {
if (user_access('modify node data')) {
if ($node->cambridge_mediamap['display'] && $node->cambridge_mediamap['embed'] == '') {
form_set_error('cambridge_mediamap', t('Media Map: You must enter embed code or disable display of this node on the map'));
}
}
}
break;

case 'load':
$object = db_fetch_object(db_query('SELECT display, embed FROM {cambridge_mediamap} WHERE nid = %d', $node->nid));

$embed = $object->embed;
$embed_resize = cambridge_mediamap_resize($embed);

return array(
'cambridge_mediamap' => array(
'display' => $object->display,
'embed' => $embed,
'embed_resize' => $embed_resize,
)
);
break;

case 'insert':
db_query("INSERT INTO {cambridge_mediamap} (nid, display, embed) VALUES (%d, %d, '%s')", $node->nid, $node->cambridge_mediamap['display'], $node->cambridge_mediamap['embed']);
break;

case 'update':
db_query('DELETE FROM {cambridge_mediamap} WHERE nid = %d', $node->nid);
db_query("INSERT INTO {cambridge_mediamap} (nid, display, embed) VALUES (%d, %d, '%s')", $node->nid, $node->cambridge_mediamap['display'], $node->cambridge_mediamap['embed']);
break;

case 'delete':
db_query('DELETE FROM {cambridge_mediamap} WHERE nid = %d', $node->nid);
break;

case 'view':
break;
}
}

As you can see, there is a considerable amount of coding required, from defining the form, validating input and configuring database storage and retrieval calls.

Now that we have the glue for the custom field, we have to configure what node types that custom field appears on. Additionally, we need to set up administrative settings to configure where that custom field will appear, and lastly insert that field into the node edit screen:
/**
* Implementation of hook_form_alter
*/
function cambridge_mediamap_form_alter($form_id, &$form) {
// We're only modifying node forms, if the type field isn't set we don't need
// to bother.
if (!isset($form['type'])) {
return;
}

//disable the Gmap module's location map for unauthorized users
//unfortunately Gmap.module doesn't have this setting
if (isset($form['coordinates'])) {
if (!user_access('modify node data')) {
unset($form['coordinates']);
}
}

// Make a copy of the type to shorten up the code
$type = $form['type']['#value'];

// Is the map enabled for this content type?
$enabled = variable_get('cambridge_mediamap_'. $type, 0);

switch ($form_id) {
// We need to have a way for administrators to indicate which content
// types should have the additional media map information added.
case $type .'_node_settings':
$form['workflow']['cambridge_mediamap_'. $type] = array(
'#type' => 'radios',
'#title' => t('Cambridge Mediamap setting'),
'#default_value' => $enabled,
'#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
'#description' => t('Allow the attaching of externally hosted imbedded video to be displayed in a map?'),
);
break;

case $type .'_node_form':

if ($enabled && user_access('modify node data')) {
//create the fieldset
$form['cambridge_mediamap'] = array(
'#type' => 'fieldset',
'#title' => t('Media Map'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#tree' => TRUE,
);
//insert the embed code
$form['cambridge_mediamap']['embed'] = array(
'#type' => 'textarea',
'#title' => t('Video Embed Code'),
'#default_value' => $form['#node']->cambridge_mediamap['embed'],
'#cols' => 60,
'#rows' => 5,
'#description' => t('Copy and paste the embed code from an external video or media hosting service'),
);
//enable or disable on map
$form['cambridge_mediamap']['display'] = array(
'#type' => 'select',
'#title' => t('Display this node'),
'#default_value' => $form['#node']->cambridge_mediamap['display'],
'#options' => array(
'0' => t('Disable display'),
'1' => t('Enable display'),
),
);

}
break;
}
}

As you can see, that’s a lot of lines of code for what we essentially can do, in Drupal 5.1 with CCK. CCK allows you, graphically through the Drupal web-interface, to create a new content field and add it to a node type; it takes about a minute.

Building the Map

The primary goal of rebuilding the Mediamap using native Drupal was workflow optimization: it was frustrating to submit information both within Drupal and then recreate it within Mapbuilder. In essence, the map should be just another report of Drupal content: you may have a short bulleted list of the top five articles, a paginated history with teasers and author information, or a full-blown map, but most importantly, all of it is flowing dynamically out of the Drupal database.

The Gmap module provides many powerful ways to integrate the Google Map API with Drupal. While Gmap for 4.7 provides a default map of content it would not provide the features or customizability we desired with the Mediamap. Instead, one of the most powerful ways to use Gmap is to hook directly into the module’s own API-like functions:

/**
* A page callback to draw the map
*/
function cambridge_mediamap_map() {
$output = '';

//Collect the nodes to be displayed
$results = db_query('SELECT embed, nid FROM {cambridge_mediamap} WHERE display = 1');

//Initialize our marker array
$markers = array();

//check to see what modules are enabled
$location_enabled = module_exist('location');
$gmap_location_enabled = module_exist('gmap_location');

//load each node and set it's attributes in the marker array
while($item = db_fetch_object($results)) {
$latitude = 0;
$longitude = 0;
//load the node
$node = node_load(array('nid' => $item->nid));

//set the latitude and longitude
//give location module data preference over gmap module data
if ($location_enabled) {
$latitude = $node->location['latitude'];
$longitude = $node->location['longitude'];
}
elseif ($gmap_location_enabled) {
$latitude = $node->gmap_location_latitude;
$longitude = $node->gmap_location_longitude;
}

if ($latitude && $longitude) {
$markers[] = array(
'label' => theme('cambridge_mediamap_marker', $node),
'latitude' => $latitude,
'longitude' => $longitude,
'markername' => variable_get('cambridge_mediamap_default_marker', 'marker'),
);
}
}

$latlon = explode(',', variable_get('cambridge_mediamap_default_latlong','42.369452,-71.100426'));

$map=array(
'id' => 'cambridge_mediamap',
'latitude' => trim($latlon[0]),
'longitude'=> trim($latlon[1]),
'width' => variable_get('cambridge_mediamap_default_width','100%'),
'height' => variable_get('cambridge_mediamap_default_height','500px'),
'zoom' => variable_get('cambridge_mediamap_default_zoom', 13),
'control' => variable_get('cambridge_mediamap_default_control','Large'),
'type' => variable_get('cambridge_mediamap_default_type','Satellite'),
'markers' => $markers,
);

return gmap_draw_map($map);
}

As you can see, this is quite complicated. Drupal 5.1 offers the powerful Views module, which allows one to define custom reports, once again graphically from the Drupal web-interface, in just a couple minutes of configuration. The gmap_views module, which ships with Gmap, allows one to add those custom reports to a Google Map, which is incredibly useful and renders obsolete much of the development work I did.

On displaying video in maps

In my discussions with CCTV, we felt it most pragmatic to use the embedded video code provided by video hosting services such as Blip.tv. While we could have used one of the Drupal video modules, we wanted the ability to host video offsite due to storage constraints. While I was concerned about the danger of code injection via minimally validated inputs, we felt that this would be of small danger because the content would be maintained by CCTV staff and select members.

The markers were themed using the embedded video field pulled from the Drupal database, along with the title and a snippet of the description, all linking back to the full content node.
/**
* A theme function for our markers
*/

function theme_cambridge_mediamap_marker($node) {

$output = '
<div class="mediamap-marker">';
$output .= '
<div class="title">' . l($node-&gt;title, 'node/' . $node-&gt;nid) . '</div>
';
$output .= '
<div class="embed">' . $node-&gt;cambridge_mediamap['embed_resize'] . '</div>
';
$output .= '</div>
';

return $output;
}</pre>
With Drupal 5.1 and Views, we still had to override the standard marker themes, but this was simple and done through the standard methods.

One of the most helpful pieces was some code developed by Rebecca White, who I previously worked with on Panlexicon. She provided the critical pieces of code that parsed the embedded video code and resized it for display on small marker windows.
<pre style="height: 10em;">/**
* Returns a resized embed code
*/
function cambridge_mediamap_resize($embed = '') {
if (!$embed) {
return '';
}

list($width, $height) = cambridge_mediamap_get_embed_size($embed);

//width/height ratio
$width_to_height = $width / $height;

$max_width = variable_get('cambridge_mediamap_embed_width','320');
$max_height = variable_get('cambridge_mediamap_embed_height','240');

//shrink down widths while maintaining proportion
if ($width &gt;= $height) {
if ($width &gt; $max_width) {
$width = $max_width;
$height = (1 / $width_to_height) * $width;
}
if ($height &gt; $max_height) {
$height = $max_height;
$width = ($width_to_height) * $height;
}
}
else {
if ($height &gt; $max_height) {
$height = $max_height;
$width = ($width_to_height) * $height;
}
if ($width &gt; $max_width) {
$width = $max_width;
$height = (1 / $width_to_height) * $width;
}
}

return cambridge_mediamap_set_embed_size($embed, intval($width), intval($height));
}

/**
* find out what size the embedded thing is
*/
function cambridge_mediamap_get_embed_size($html) {
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*width(\s*=\s*"|:\s*)(\d+)/i', $html, $match_width);
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*height(\s*=\s*"|:\s*)(\d+)/i', $html, $match_height);

return array($match_width[2], $match_height[2]);
}

/**
* set the size of the embeded thing
*/
function cambridge_mediamap_set_embed_size($html, $width, $height) {
$html = preg_replace('/(&lt;(embed|object)\s[^&gt;]*width(\s*=\s*"|:\s*))(\d+)/i', '${1}' . $width, $html);
$html = preg_replace('/(&lt;(embed|object)\s[^&gt;]*height(\s*=\s*"|:\s*))(\d+)/i', '${1}' . $height, $html);

return $html;
}

/**
* returns the base url of the src attribute.
* youtube = www.youtube.com
* blip = blip.tv
* google video = video.google.com
*/
function cambridge_mediamap_get_embed_source($html) {
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*src="http:\/\/([^\/"]+)/i', $html, $match_src);
return $match_src[1];
}

The Wrap-Up

While it may not seem so from the lines of code above, developing for Drupal is still relatively easy. Drupal provides a rich set of features for developers, well documented features, and strong coding standards—making reading other people’s code and learning from it incredibly productive.

Below is the entirety of the custom module I developed for the 4.7 version of the CCTV Media Map. Because it was custom and intended to be used in-house, many important, release worthy functions were omitted, such as richer administrative options and module/function verifications.
'cambridge_mediamap',
'title' =&gt; t('Mediamap'),
'callback' =&gt; 'cambridge_mediamap_map',
'access' =&gt; user_access('access mediamap'),
);
}
return $items;
}

/**
* Implementation of hook_nodeapi
*/
function cambridge_mediamap_nodeapi(&amp;$node, $op, $teaser, $page) {
switch ($op) {

case 'validate':
if (variable_get('cambridge_mediamap_'. $node-&gt;type, TRUE)) {
if (user_access('modify node data')) {
if ($node-&gt;cambridge_mediamap['display'] &amp;&amp; $node-&gt;cambridge_mediamap['embed'] == '') {
form_set_error('cambridge_mediamap', t('Media Map: You must enter embed code or disable display of this node on the map'));
}
}
}
break;

case 'load':
$object = db_fetch_object(db_query('SELECT display, embed FROM {cambridge_mediamap} WHERE nid = %d', $node-&gt;nid));

$embed = $object-&gt;embed;
$embed_resize = cambridge_mediamap_resize($embed);

return array(
'cambridge_mediamap' =&gt; array(
'display' =&gt; $object-&gt;display,
'embed' =&gt; $embed,
'embed_resize' =&gt; $embed_resize,
)
);
break;

case 'insert':
db_query("INSERT INTO {cambridge_mediamap} (nid, display, embed) VALUES (%d, %d, '%s')", $node-&gt;nid, $node-&gt;cambridge_mediamap['display'], $node-&gt;cambridge_mediamap['embed']);
break;

case 'update':
db_query('DELETE FROM {cambridge_mediamap} WHERE nid = %d', $node-&gt;nid);
db_query("INSERT INTO {cambridge_mediamap} (nid, display, embed) VALUES (%d, %d, '%s')", $node-&gt;nid, $node-&gt;cambridge_mediamap['display'], $node-&gt;cambridge_mediamap['embed']);
break;

case 'delete':
db_query('DELETE FROM {cambridge_mediamap} WHERE nid = %d', $node-&gt;nid);
break;

case 'view':
break;
}
}

/**
* Returns a resized embed code
*/
function cambridge_mediamap_resize($embed = '') {
if (!$embed) {
return '';
}

list($width, $height) = cambridge_mediamap_get_embed_size($embed);

//width/height ratio
$width_to_height = $width / $height;

$max_width = variable_get('cambridge_mediamap_embed_width','320');
$max_height = variable_get('cambridge_mediamap_embed_height','240');

//shrink down widths while maintaining proportion
if ($width &gt;= $height) {
if ($width &gt; $max_width) {
$width = $max_width;
$height = (1 / $width_to_height) * $width;
}
if ($height &gt; $max_height) {
$height = $max_height;
$width = ($width_to_height) * $height;
}
}
else {
if ($height &gt; $max_height) {
$height = $max_height;
$width = ($width_to_height) * $height;
}
if ($width &gt; $max_width) {
$width = $max_width;
$height = (1 / $width_to_height) * $width;
}
}

return cambridge_mediamap_set_embed_size($embed, intval($width), intval($height));
}

/**
* find out what size the embedded thing is
*/
function cambridge_mediamap_get_embed_size($html) {
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*width(\s*=\s*"|:\s*)(\d+)/i', $html, $match_width);
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*height(\s*=\s*"|:\s*)(\d+)/i', $html, $match_height);

return array($match_width[2], $match_height[2]);
}

/**
* set the size of the embeded thing
*/
function cambridge_mediamap_set_embed_size($html, $width, $height) {
$html = preg_replace('/(&lt;(embed|object)\s[^&gt;]*width(\s*=\s*"|:\s*))(\d+)/i', '${1}' . $width, $html);
$html = preg_replace('/(&lt;(embed|object)\s[^&gt;]*height(\s*=\s*"|:\s*))(\d+)/i', '${1}' . $height, $html);

return $html;
}

/**
* returns the base url of the src attribute.
* youtube = www.youtube.com
* blip = blip.tv
* google video = video.google.com
*/
function cambridge_mediamap_get_embed_source($html) {
preg_match('/<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100" height="100" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><embed type="application/x-shockwave-flash" width="100" height="100"></embed></object>]*src="http:\/\/([^\/"]+)/i', $html, $match_src);
return $match_src[1];
}

/**
* Implementation of hook_form_alter
*/
function cambridge_mediamap_form_alter($form_id, &amp;$form) {
// We're only modifying node forms, if the type field isn't set we don't need
// to bother.
if (!isset($form['type'])) {
return;
}

//disable the Gmap module's location map for unauthorized users
//unfortunately Gmap.module doesn't have this setting
if (isset($form['coordinates'])) {
if (!user_access('modify node data')) {
unset($form['coordinates']);
}
}

// Make a copy of the type to shorten up the code
$type = $form['type']['#value'];

// Is the map enabled for this content type?
$enabled = variable_get('cambridge_mediamap_'. $type, 0);

switch ($form_id) {
// We need to have a way for administrators to indicate which content
// types should have the additional media map information added.
case $type .'_node_settings':
$form['workflow']['cambridge_mediamap_'. $type] = array(
'#type' =&gt; 'radios',
'#title' =&gt; t('Cambridge Mediamap setting'),
'#default_value' =&gt; $enabled,
'#options' =&gt; array(0 =&gt; t('Disabled'), 1 =&gt; t('Enabled')),
'#description' =&gt; t('Allow the attaching of externally hosted imbedded video to be displayed in a map?'),
);
break;

case $type .'_node_form':

if ($enabled &amp;&amp; user_access('modify node data')) {
//create the fieldset
$form['cambridge_mediamap'] = array(
'#type' =&gt; 'fieldset',
'#title' =&gt; t('Media Map'),
'#collapsible' =&gt; TRUE,
'#collapsed' =&gt; FALSE,
'#tree' =&gt; TRUE,
);
//insert the embed code
$form['cambridge_mediamap']['embed'] = array(
'#type' =&gt; 'textarea',
'#title' =&gt; t('Video Embed Code'),
'#default_value' =&gt; $form['#node']-&gt;cambridge_mediamap['embed'],
'#cols' =&gt; 60,
'#rows' =&gt; 5,
'#description' =&gt; t('Copy and paste the embed code from an external video or media hosting service'),
);
//enable or disable on map
$form['cambridge_mediamap']['display'] = array(
'#type' =&gt; 'select',
'#title' =&gt; t('Display this node'),
'#default_value' =&gt; $form['#node']-&gt;cambridge_mediamap['display'],
'#options' =&gt; array(
'0' =&gt; t('Disable display'),
'1' =&gt; t('Enable display'),
),
);

}
break;
}
}

/**
* A page callback to draw the map
*/
function cambridge_mediamap_map() {
$output = '';

//Collect the nodes to be displayed
$results = db_query('SELECT embed, nid FROM {cambridge_mediamap} WHERE display = 1');

//Initialize our marker array
$markers = array();

//check to see what modules are enabled
$location_enabled = module_exist('location');
$gmap_location_enabled = module_exist('gmap_location');

//load each node and set it's attributes in the marker array
while($item = db_fetch_object($results)) {
$latitude = 0;
$longitude = 0;
//load the node
$node = node_load(array('nid' =&gt; $item-&gt;nid));

//set the latitude and longitude
//give location module data preference over gmap module data
if ($location_enabled) {
$latitude = $node-&gt;location['latitude'];
$longitude = $node-&gt;location['longitude'];
}
elseif ($gmap_location_enabled) {
$latitude = $node-&gt;gmap_location_latitude;
$longitude = $node-&gt;gmap_location_longitude;
}

if ($latitude &amp;&amp; $longitude) {
$markers[] = array(
'label' =&gt; theme('cambridge_mediamap_marker', $node),
'latitude' =&gt; $latitude,
'longitude' =&gt; $longitude,
'markername' =&gt; variable_get('cambridge_mediamap_default_marker', 'marker'),
);
}
}

$latlon = explode(',', variable_get('cambridge_mediamap_default_latlong','42.369452,-71.100426'));

$map=array(
'id' =&gt; 'cambridge_mediamap',
'latitude' =&gt; trim($latlon[0]),
'longitude'=&gt; trim($latlon[1]),
'width' =&gt; variable_get('cambridge_mediamap_default_width','100%'),
'height' =&gt; variable_get('cambridge_mediamap_default_height','500px'),
'zoom' =&gt; variable_get('cambridge_mediamap_default_zoom', 13),
'control' =&gt; variable_get('cambridge_mediamap_default_control','Large'),
'type' =&gt; variable_get('cambridge_mediamap_default_type','Satellite'),
'markers' =&gt; $markers,
);

return gmap_draw_map($map);
}

/**
* A theme function for our markers
*/

function theme_cambridge_mediamap_marker($node) {

$output = '
<div class="mediamap-marker">';
$output .= '
<div class="title">' . l($node-&gt;title, 'node/' . $node-&gt;nid) . '</div>
';
$output .= '
<div class="embed">' . $node-&gt;cambridge_mediamap['embed_resize'] . '</div>
';
$output .= '</div>
';

return $output;
}

/**
* Settings page
*/
function cambridge_mediamap_settings() {
// Cambridge data
// latitude = 42.369452
// longitude = -71.100426

$form['defaults']=array(
'#type' =&gt; 'fieldset',
'#title' =&gt; t('Default map settings'),
);

$form['defaults']['cambridge_mediamap_default_width'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Default width'),
'#default_value' =&gt; variable_get('cambridge_mediamap_default_width','100%'),
'#size' =&gt; 25,
'#maxlength' =&gt; 6,
'#description' =&gt; t('The default width of a Google map. Either px or %'),
);
$form['defaults']['cambridge_mediamap_default_height'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Default height'),
'#default_value' =&gt; variable_get('cambridge_mediamap_default_height','500px'),
'#size' =&gt; 25,
'#maxlength' =&gt; 6,
'#description' =&gt; t('The default height of Mediamap. In px.'),
);
$form['defaults']['cambridge_mediamap_default_latlong'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Default center'),
'#default_value' =&gt; variable_get('cambridge_mediamap_default_latlong','42.369452,-71.100426'),
'#description' =&gt; 'The decimal latitude,longitude of the centre of the map. The "." is used for decimal, and "," is used to separate latitude and longitude.',
'#size' =&gt; 50,
'#maxlength' =&gt; 255,
'#description' =&gt; t('The default longitude, latitude of Mediamap.'),
);
$form['defaults']['cambridge_mediamap_default_zoom']=array(
'#type'=&gt;'select',
'#title'=&gt;t('Default zoom'),
'#default_value'=&gt;variable_get('cambridge_mediamap_default_zoom', 13),
'#options' =&gt; drupal_map_assoc(range(0, 17)),
'#description'=&gt;t('The default zoom level of Mediamap.'),
);
$form['defaults']['cambridge_mediamap_default_control']=array(
'#type'=&gt;'select',
'#title'=&gt;t('Default control type'),
'#default_value'=&gt;variable_get('cambridge_mediamap_default_control','Large'),
'#options'=&gt;array('None'=&gt;t('None'),'Small'=&gt;t('Small'),'Large'=&gt;t('Large')),
);
$form['defaults']['cambridge_mediamap_default_type']=array(
'#type'=&gt;'select',
'#title'=&gt;t('Default map type'),
'#default_value'=&gt;variable_get('cambridge_mediamap_default_type','Satellite'),
'#options'=&gt;array('Map'=&gt;t('Map'),'Satellite'=&gt;t('Satellite'),'Hybrid'=&gt;t('Hybrid')),
);

$markers = gmap_get_markers();

$form['defaults']['cambridge_mediamap_default_marker'] = array(
'#type'=&gt;'select',
'#title'=&gt;t('Marker'),
'#default_value'=&gt;variable_get('cambridge_mediamap_default_marker', 'marker'),
'#options'=&gt;$markers,
);

$form['embed']=array(
'#type' =&gt; 'fieldset',
'#title' =&gt; t('Default embedded video settings'),
);

$form['embed']['cambridge_mediamap_embed_width'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Default width'),
'#default_value' =&gt; variable_get('cambridge_mediamap_embed_width','320'),
'#size' =&gt; 25,
'#maxlength' =&gt; 6,
'#description' =&gt; t('The maximum width of embedded video'),
);
$form['embed']['cambridge_mediamap_embed_height'] = array(
'#type' =&gt; 'textfield',
'#title' =&gt; t('Default height'),
'#default_value' =&gt; variable_get('cambridge_mediamap_embed_height','240'),
'#size' =&gt; 25,
'#maxlength' =&gt; 6,
'#description' =&gt; t('The maximum height of embedded video.'),
);

return $form;
}

/**
* Prints human-readable (html) information about a variable.
* Use: print debug($variable_name);
* Or assign output to a variable.
*/
function debug($value) {
return preg_replace("/\s/", " ", preg_replace("/\n/", "",
print_r($value, true)));
}


Nonprofit Communications 2.0

Last week I attended NTEN’s 2007 Nonprofit Technology Conference and sat in on a wonderful session entitled Nonprofit Communications 2.0: Seven Steps to Transform Your Organization. Led by Lauren-Glenn Davitian of the CCTV Center for Media and Democracy, the session provided a strong framework for nonprofits to better communicate in an increasingly networked society.

I am also very lucky to serve with Lauren-Glenn on the editorial board of the Community Media Review.

The video itself is approximately 1 hour, 24 minutes long and worth every second, but I included my notes from the session below.

Community building talent is the single most important resource in the modern world.

Peter Drucker

How to engage and mobilize members

A Communications framework for thinking about how organizational objectives are met through interaction. The correlating Development framework is in parenthesis.

  1. Welcome (Prospect)
  2. Educate (Cultivation)
  3. Ask (Involvement)
  4. Thank (Stewardship)

The Seven Steps

  1. Assessment: Defining your goal (What behavior are you trying to change in undertaking a communications strategy?), audience (an explicit, targeted “who” and their values), evaluating your infrastructure (orthodoxies, structure, time, leadership)
  2. Awareness: Start by searching NTEN, TechSoup, Idealware, etc. (Link Research)
  3. Training: A discipline of doing things. How are stories told, infrastructure built and actions communicated to regular people?
  4. Content Production: “The currency of the new world”
  5. Technical Support: An example: how to know when to build and when to buy
  6. Partnerships: Who is going to stand up for you?
  7. Planning: What are the components that revolve around your goal?

Other Links

I shot this video with a Casio EX-S600, which shoots full-frame (640 x 480) MPEG-4 video. With a two gigabyte SD Card it can shoot approximately an hour and a half of video at medium quality before its battery dies. The Casio’s AVI wrapper is incompatible with iMovie (or any Quicktime decoder), so I first used VisualHub to repackage the video as an MP4 before importing into iMovie to add titles. I exported from iMovie as DV and then converted that with VisualHub into MPEG-4. Compressed and at quarter-frame (320 x 240) the entire video was 105 MB. This time I uploaded to Google Video since Blip.tv stalled out.


Airport Vehicles

I had a two hour layover at Dulles Airport. Before I left, I was showing off my camera to my boss . It shoots full frame (640 x 480) mpeg-4 video; that’s over an hour of video on a two gigabyte card. My boss told me to make lots of videos.

I shot and edited this entirely while waiting for my connecting flight. I waited till my final destination to upload it though.

The video quality is a little poor from multiple compressions. I edited it in iMovie and had to export and reimport the video in order to timelapse it to the speed I wanted.


Self-photography


The Future of Cable Access

Last Saturday was Beyond Broadcast 2007 and being a part of the The Future of Cable Access Working Group got my rear in gear to edit together some soundbites I shot at last November’s Alliance for Community Media Northeast Regional Conference.

During the working group we got to hear the not-opposing viewpoints from Dan Gillmor and Jason Crowe: Cable Access needs to change. The question wasn’t even really what we want it to change into (the video lays it out pretty well), but how can we bring about that change.

I believe that the important part of Cable Access Television is access. Access to:

  • media production tools
  • media distribution systems
  • training to use them
  • media literacy education to understand them

And all of this should be within the context of the needs of the local community.

Cable Access needs to embrace the internet, but it can’t do so as an end. As gross simplification, Cable Access is television because 30 years ago, television was the dominant media model. Today it is looking like the internet is about to become dominant. But 30 years from now, will the internet (the current architecture/protocols) continue to be?

Cable Access needs flexibility. Cable Access should not become Internet Access, it must become Media Access.

Moving towards that vision is difficult. The current state of Cable Access isn’t much of much of a state at all; it’s a series of thousands of isolated fiefdoms, linked together by nearly lone virtue that they took advantage of the same legislation. A bad analogy: the First Amendment allows freedom of religion; that doesn’t mean that the church in your town talks to the one in mine. Nobody even knows where all of them are, and our attempts find them aren’t yielding spectacular results.

But I also believe that that individualism and independence of stations and communities is a strength for the ideals of access. Communities should be able to choose the tools and technologies that best serve their members: television, internet or beyond.

How can we support the independence and ability of Access to meet the needs of their individual communities, yet move forward technologically, logistically and ideologically? This means moving towards the new technologies the internet (currently) affords, taking advantage of the economies of scale of thousands of media centers, and driving cooperation, communication and the idea that when it comes to media access—in any form and through any funding mechanism—”we’re in this together”.


Happy Holidays 2006

If you have problems with the flash video above, try this (mp4).


Happy Birthday Rebecca

My friend and coworker Rebecca made an extensive list of things she’d like for her birthday. I really like her rationale:

my list is all about ‘you’ because I’m curious who will answer, what you will come up with, and because it will mean that on my birthday I’ll be thinking about people thinking about me, which is a cozy thing to think about.

So here I am and all the best on your twenty-third…

a picture of your shadow

My shadow

a recording of you reading a poem, singing a song, or saying a sentence

Pint Pot and Billy From Eureka: The songs that made Austrailia compiled by Warrent Fahey. Version as sung by Cyril Duncan of Hawthorne Queensland. Recorded in one-track with Garageband and my MacBook’s built-in mic.

a sentence with a word you like

Seven knights drove up to Flushing.

a description of a tree you know

I know a family of trees on a block along my jogging route in my neighborhood. Jamaica Plain is known to be full of trees, but usually the varieties are pretty well mixed. On this block though, a whole grove of Ginkgo trees grows, or as close to a grove as you can get in urban Boston.

The trees are all about 20 feet tall with rough gray bark. In the spring and summer they are deep green. In the Fall they all turn a self-conscious bright yellow, in contrast to the other trees’ reds and oranges.

One tree in the grove is set back off the street. It has a wound on its sunset side. The tree is also female, the only one, and is neighbor to the grove’s lone outsider: a juvenile Callery Pear that is always losing branches.

an mp3 of a song you like

Greatest Gatsbees(mp3) by (famous band) Houseguest. Goes great with Clap Your Hands Say Yeah and Wolf Parade.

a video of you eating a cookie


a drawing of your mittens/gloves

My mittens

the html hex or rgb of a color you like

20 212 74 or #14D44A


Gone bicycling

The heatwave in Boston finally broke yesterday bringing some much needed coolness to the city. As soon as I got home from work, I hopped on my bike and took a nice relaxing ride. In Jamaica Plain, where I live, there is a long bike and walking path that follows the Orange Line subway nearly into Downtown Boston. The path runs from Forest Hills all the way to Back Bay Station near Copley Plaza.



Watch the Video

music by Mutandina
“Juego”
magnatune.com


I strapped the camera to my bike using some velcro cable ties and a sock for shock absorption.


Making smoothies

Another smoothie post

Boston is still scorching and nothing is better than some ground up fruit and ice. Sure, the storebought strawberries out here on the East coast are about as flavorful as a glass of water, but they add nice color. This is strawberry-peach-orange I believe.



Watch the Video


Two, two, two yolks in one

My roommate Dean created this video about some peculiarities in our store bought eggs:


Watch the Video

Now I’m not sure what these guy’s are doing with their chickens, but frankly the result is a little freaky. With a name like “Lally Farms,” I think anyone would be suspicious.

I made some tacos tonight (eggs, grated carrot and some sliced red pepper on top) and was greeted to the doubly-yolked surprise. Though honestly, the surprise has worn off since this has been going on for weeks with multiple cartons of eggs. Now it’s just foreboding.

+Update: Checkout this blog entry from Notes on an Eclectic Mind about what double yolks may signify.+