Acumen Development

  • Acumen Development
  • Acumen Systems
  • Acumen Third Sector
  • About Us
  • Websites
  • Web Applications
  • Branding
  • Support
  • Contact Us

Wordpress and Subversion

recent news

  • Wordpress and Subversion
    Leo Brown, 1st June

  • Working with Corrupt Subversion Repositories
    Leo Brown, 20th January

  • Integrating with Web1.0 Service Providers
    Leo Brown, 4th June

  • WordPress Text Replacement Plugin
    Leo Brown, 14th February

  • Direct Email Reception
    Leo Brown, 2nd January

Project Request Form

Download a project request form here

Wordpress and Subversion

June 1, 2010
categories: Open Source, Subversion, Wordpress

If there’s two bits of software I love, Wordpress and Subversion would be right up there in terms of making my life simpler, and making publishing easier. While it’s tempting to counter statements like these with a long list of problems, I’ll leave that as it is – today I want to convey a few things that helped me use the two pieces of software together.

First, the context of using Wordpress and Subversion jointly is typically in making sure that customer websites are fully versioned so that we can be accountable and transparent, and equally importantly so that we can roll back in a disaster scenario.

Second, some background on our approach. We believe that when using Open Source software for customers, it’s important to strike a balance between cutting edge features and stability. We typically accomplish this by starting the project at the head revision of the software we’re using – in this case, Wordpress.

svn co http://core.svn.wordpress.org/trunk www

Now we have a freshly checked out copy of Wordpress, and we’ll want to keep it this way. If you don’t feel comfortable with leaving a repository in a certain state there are a few options here – the most obvious would be for you to maintain your own copy of the Wordpress source tree (which can be useful in other ways too, for instance if WP’s subversion servers were to go down.) This can be accomplished easily using `svnsync`.

Assuming that you’re happy with your checked-out Wordpress, we now want to move all the User data to one place, so that we can version it separately to the Wordpress trunk. Typically, this is just the `wp-content` folder, but you may also want to version wp-config.php, .htaccess, and any other special files you’re using in the project webroot.

Your final decision on the path structure really depends on the scenario- you may want to separate out the theme directory from other ‘user content’ directories if you’re planning to open source your theme or host it elsewhere. In this case, you’d have a subversion repository containing the folders within wp-content, with a `themes` folder which will load your versioned theme(s) as an svn:externals entry.

Now, a couple of tricks – first, your uploads folder may want to be versioned. If not, you’ll want to svn:ignore it. If you do version it, you’ll probably want to svn:ignore some of it. For instance, WP2.5 onwards supports image resizing, and it uses the uploads directory also as a cache store for these thumbnails. We can ignore these thumbnails by setting the svn:ignore property on the uploads directory as follows:

[root@www uploads]# svn -R  propset svn:ignore "*[0-9]x[1-9]*"; .
property 'svn:ignore' set (recursively) on '.'

Note that if your uploads folder is structured by date, these ignore settings will not persist in new directories, so I’d recommend you do not use a structured uploads folder if you are versioning it (the option titled ” Organize my uploads into month- and year-based folders”).

Basic Scraping

November 22, 2008
categories: Development Processes, Open Source
tags: mashups, php, scraping
A short introduction to Web Page Scraping

While in production applications we all favour use of an API, there are a lot of situations, such as in ‘Mashups’ (I love how that term has been reappropriated from Jungle music) where you need to do some page scraping.

It’s occurred to me how these very easy techniques seem inaccessible to many people, so I thought I’d post a few bits and bobs about some basic scraping methods.

Here’s a bit of code I wrote to use PHP’s DOMDocument class to treat a HTML page as XML and fetch, in this case, the incredibly useful current world population… fantastic!

<?php
 // where to find population data...
 $location['url']='http://www.census.gov/ipc/www/popclockworld.html';
 $location['id']='worldnumber';

 // initialise a new document and prepare the data
 $d=new DOMDocument();
 $file = file_get_contents($location['url']);

 // get and print current world population
 $d->loadHTML($file);
 $e=$d->getElementById($location['id']);
 print $e->nodeValue;
?>

Sample output: 6,738,610,278

PHP StopWatch Class

April 16, 2008
categories: Open Source
tags: debugging, performance, stopwatch

Just a simple little class to play around with. I quickly threw it together because I got fed up of writing performance debugging code into perfectly clean classes, and then having to strip it out again later. The stop watch allows you to set callback methods to receive any calls to the stopwatches mark method, which as it’s a singleton can be called just about anywhere. Additionally it uses sprintf() strings to format the message and time.

Additionally this shows how in two lines you can be notified of the scripts entire execution time using StopWatch.

<?php
include('StopWatch.class.php');
$stopWatch=StopWatch::getInstance();
$stopWatch-&amp;amp;gt;setFinishMessage('script executed in %01.2f seconds');
sleep(2);
?>

And here’s the source stopwatch.zip.

Vector for php, surely not?

February 21, 2008
categories: Open Source
tags: performance, php, vector
Ok before you try to hit me let me explain. This is not just a boring Object Orientated wrapper for storing PHP object in an array. It’s a multi-indexed, self sufficient class.

Ok before you try to hit me let me explain. This is not just a boring Object Orientated wrapper for storing PHP object in an array. It’s a multi-indexed, self sufficient class.

(more…)