ShoZu Module for Drupal (Beta)

Overview

The ShoZu module for Drupal(Beta) is a Drupal plug-in that has been designed to allow uploads from ShoZu to generate entries with embedded photos or videos into a Drupal blog.

Some History
I originally started this project so that I could gain a better technical understanding of module writing for Drupal using a subject that I was already familiar with (remote API architectures), but then continued to use it to upload my cellphone images to my blog. This gave me the idea that perhaps others may want to use it to upload as well, hence this article, the availability of my code and now the release of the ShoZuDrupal destination on our production servers.

The module is very similar in functionality to the features available in Drupal using the standard XML-RPC calls such as MetaWeblog - which ShoZu already supports. The problem (from my point of view) is that most metaweblog implementations either do not support file upload or upload is supported but to create a blog entry with an embedded photo requires 2 stages, one to upload the media and the second to create the blog entry and embed the uploaded media. The code I created allows this to be done in one call, uploading the media and creating the blog entry as well.

Current Features

Module Download
The file attached here contains the module installation files that can be used with Drupal 5.x (I do not currently have a Drupal 6 install and so have not tested it). You are welcome to download this but please be aware that currently (March 2008) the ShoZu destination is not yet available on the ShoZu production servers so you will not be able to use this code with ShoZu, I can upload with my cellphone as I have my mobile connected through one of our test servers( managing the integrations does have its advantages).

22 Apr update
ShoZu is now looking at releasing this integration so that the destination (and this module) can be used on the ShoZu production servers. It has been scheduled to go into formal testing and I will update this article as soon as we have a production release date.

26 Apr update
The ShoZu production servers should have the "ShoZuDrupal" site on them within the next week, we are just testing on our staging servers now.

Plugin Overview

Introduction
This is an overview of how the images and videos are processed and stored when they are received.

Uploaded files
All files that are uploaded (photos or videos) are stored in the default Drupal files directory in a sub-directory that is specific to the user account doing the upload. This is done by creating a sub-directory using the account userid.

For example:

If the user id for an account was 324 then all Share-It uploaded files would be stored in /files/324

photos
When a photo is uploaded the original file (keeping the original filename) is stored along with a smaller image that is prefixed with "preview_". The dimensions of this "preview" image can be defined by an administrator in the Drupal set up menu. This is done so that the image size that is displayed in a blog entry can be set up to suit the site. This "preview" image is the one used when embedding a photo into a blog entry.

NB: The resize only takes place if the original uploaded image is bigger in dimension that the values set up by the administrator.

videos
When a video is uploaded it is stored in the same place as the photos and displayed in a blog entry by embedding it as a quicktime object. There is also an admin menu for video options that can be set up:

ShoZu Supported Featureset

Introduction
ShoZu has a wide feature set that is constantly updated to match new features that it's destinations offer. Here you will find the features that the Drupal plug-in module supports.

Authentication
The plug-in allows ShoZu to check that a username and password exists on the destination Drupal site. This is used by ShoZu to ensure that a valid account exists when a user selects the destination as an upload site.

List blogs
Currently this will only return 1 entry as Drupal supports one blog per user.

Upload
This allows ShoZu to upload media (currently a photo or video) along with the actual blog entry (title and content) and keyword (tags/categories).

Blog Entry Formatting

Introduction
This section describes how the plug-in module formats the actual blog entry when an upload of a photo or video has been detected.

Formatting
A Share-It upload has the following components:

Title
This is used as the title of the blog entry.

Keywords
These are added to the entries taxonomy - I have this set to free form so that all keywords that are uploaded will be created if they do not exist already.

Payload and Content
These are dealt with together as they both make up the blog entry for a Share-It upload. The payload file is stored and processed as described elsewhere in this book and is then either turned into an HTML image tag (for photos) or an embedded object tag (for videos). This is then used as the first part of the content of the blog entry, an HTML line break is then added followed by the Content text as uploaded.

Example Photo entry:

<img src="/files/999/preview_sky.jpg"><br/> This is my picture of the sky as it turned red at sunset looking over Crane beach in Barbados.<br/>- Taken at 18:48 PM on Feb 18, 2006 - cameraphone upload by ShoZu