content migration

Quiver: crafting a new home for the surfboard shaper community

Quiver Surfboard Chronicles Thumbnail

I'm totally Psyched ! [OpenSourcery] did some really nice work on the site and I've been nothing but happy with the outcome.
- Michael Paler, owner Swaylock's Surf Shop

For ten years the Swaylock's Board Archive served as a forum for surfboard shapers and surfcraft enthusiasts to share photos, trade tips, and swap stories. Swaylock's Surf Shop owner, Michael Paler, wanted to bring “the art and story of surfcraft to a wider audience” by migrating the Swaylock's Board Archive to a new Drupal-based website called Quiver.

Making the move from a traditional discussion forum to an online magazine format required careful consideration, planning, and implementation. With a clear vision for the new website, Michael needed a team of reliable developers to build the social sharing, discussion, and content display features of Quiver and to simplify the migration of existing user accounts with nearly 2000 user submitted surfboards. He called the custom website shapers at OpenSourcery.

Key Features:
  • Migration of photos and user accounts

  • User log-in and sign-up system

  • Users can submit their own surfboard photos and stories

  • Categorical display of submitted boards

  • Custom display of a single user's “quiver” of submitted surfboards

  • Photos and stories can be shared on major social network sites

  • User comments system

  • Site search

The new Quiver Surfboard Chronicles website welcomes a wider audience while enhancing the user-experience for existing members. As Michael Paler explains, “To those who have used or contributed to the Photo Archive, Quiver will seem very familiar and should serve the same function: a place to share and research boards of all shapes, ages and sizes. To those who haven't, Quiver will be an online magazine featuring real boards and real stories written by surfboard shapers, collectors and anyone else obsessed with surfcraft.”

Tagged as: content migration, facebook, site search, social bookmarking, social sharing, user profiles, user submitted content

Parsing HTML, the easy way

One of the toughest aspects of transitioning an existing site to Drupal can be content migration. While there's an entire category of modules available for import/export tasks, sometimes you just need to bite the bullet and parse some HTML.

One of the tools I like to use for this is the PHP Simple HTML DOM Parser. This allows you to use the Document Object Model (DOM). For our purposes, all this means is that the document is modeled as a tree – each element, such as a <div> or a <p>, has parents, children, and siblings, and you can search for them. (I'm sure to many readers this is already familiar, especially if you are using jQuery). Compared to an event-driven parser, I find that using the DOM results in smaller code that's easier to write.

The SourceForge page really has all the examples you need – but I'll provide a small example of how I use it.

include('simple_html_dom.php');
 
$html = file_get_html('old_page.html');
 
# find every <div class=post> in the document
foreach($html->find('.post') as $post) {
 
  # locate the post date, and convert it to ISO 8601 format
  $date_string = $post->prev_sibling()->innertext;
  $date = date_format(date_create($date_string), "Y-m-d");
 
  $title = $post->find('.post-title', 0)->innertext;
 
  # get rid of empty divs
  foreach($post->find('div') as $div) {
    if ($div->innertext == '') {
      $div->outertext = '';
    }
  }
 
  $body = $post->find('.post-body', 0)->innertext;
 
  # this is a wrapper for Drupal's node_save(), but could be anything
  post_save ($title, $date, $body);
}

While this parser advertises the ability to handle errors in the HTML, I prefer to run it through HTML Tidy first. That way I can be sure there aren't any gremlins in the markup.

Tagged as: content migration, Drupal, import, parser

Syndicate content