Drupal Module for CKAN Integration

Here's a basic Drupal Module that pulls CKAN data into Drupal.

It provides a simple search interface - when the user views a CKAN package for the first time a corresponding node is created.

When this node is then viewed Drupal loads the package details - I'm only displaying notes and title here as I've run out of time tonight - but the rest of the data is there.

You can then have user comments, voting, etc on these pages.

Read more

Accessing CKAN data from PHP

I've been working on a couple of open data projects recently - which has been very rewarding.

A couple of people have asked for some code so I've knocked up a quick version of the sort of thing I've been working on.

This code requires PHP 5.1 for the JSON functions but doesn't need any extra libraries (pecl_http can give better error messages but is a bit of a pain to install).

The Notes field in packages returns output in Markdown format - you can convert this to HTMl with a parser available at http://michelf.com/projects/php-markdown

Read more

Drupal - the missing API

I was just reading this presentation on deploying Drupal

http://www.slideshare.net/eaton/drupal-deployment-presentation

and noticed

http://drupal.org/project/install_profile_api

Which seems to have a collection of API functions needed at install/upgrade time that are missing from Drupal (and contrib modules)

And even better this is great motivation to write more such functions myself instead of just using SQL hacks.

Read more

Drupal as URL shortener

Drupal has a couple of modules which allow you to produce your own tinyurl.com type website - complete with your own tracking etc.

This has been extended for use by the US government at http://go.usa.com/ and the code re-released to the community.

This mainly adds statistics gathering and reporting

Unfortunately the module maintainer has chosen not to integrate these changes back into the module at drupal.org - issue here : http://drupal.org/node/520588

So now the patch doesn't apply cleanly unless you checkout an old version of the module from CVS like this

Read more

ssh port forwarding

Every now and again I find I have ssh access to one server - which has access to somewhere I need to get to - but I want direct access (eg to forward an X session)

ssh -L 2222:otherserver:22 server

ssh -X -p 2222 localhost

an now I'm logged into othersever with forwarded X

Read more

Drush "tput: No value for $TERM and no -T specified"

The drush script which provides comman line acceess to drupal functionality emits an error message when run as a cron job

tput: No value for $TERM and no -T specified

# If it is not exported determine and export the number of columns.
if [ -z $COLUMNS ]; then
  export COLUMNS=$(tput cols)
fi

I presume drush uses this information to calculate layout of output.

However when running as a cron job COLUMNS is not set and tput gives the above error.

Read more

Drupal Cron getting stuck

I've just run into the drupal cron problem again  

Cron fails and the error log says

"Attempting
to re-run cron while it is already running."

 

  • delete from variable where name='cron_semaphore';
  • clear caches
  • run cron from the web page

That seems to do the trick.

Now cron runs OK fom drush or web.

Read more

Programatic Block Creation in Drupal

To remove static blocks and replace with as custom block.

Implement hook_block specifying the default visibility and so on

<?php
$blocks
['random'] = array(
     
'info' => t('Random'),
     
'weight' => 0,
     
'status' => 1,
     
'region' => 'sidebar',
     
'pages'  => 'offers',
     
'visibility' => 0, // all pages except
     
'cache' => BLOCK_CACHE_PER_PAGE,
    );
?>

Create an update hook that deletes the old blocks and boxes (I've specified the ID as I know they won't change on my site).

Read more

Bug in Trac on Ubuntu Jaunty

There is a bug in Ubunty Jaunty which cause Trac to have errors.

 Attachments do not work, the admin interface for milestones doesn't work properly - and there may be other issues.

The bug report is at https://bugs.launchpad.net/ubuntu/+source/trac/+bug/369792

And the solution is 

"go to http://packages.ubuntu.com/karmic/trac
and scroll all the way down. There you'll find a download link for the
karmic package which you can download and install via

Read more

Moving an svn repository to integrate with trac

I just started on a project that was using trac and subversion but they weren't integrated. I love the cross referncing trac provides. It can really help explain changesets and show how an issue was resolved.

The steps to add subversion to trac are

Read more