Subversion and Web Design

I’ve started using Subversion for all sites that I’m developing. If I’m lucky, the target host has subversion installed and it makes site deployment and updating really easy. If not I can always grab a clean copy out of the repository to upload via sFTP. Either way I have a versioned back-up of the site on a remote server.

So, first I create a repository. There is an import feature to svn but I usually just create an empty one even if there is an existing site. I do this through my host’s control panel. Then I check out the empty repository to my local working directory:

cd ~Sites/domain.tld
svn co http://mydomain.tld/svn/path/to/repos ./

The “./” tells svn to put it in my current directory. Otherwise it will create a folder with the name of your repos and put the contents inside it, all inside your current directory.

If a site exists I copy the files into the working directory and then add them to the repository:

svn add filename

or

svn add foldername

I use TextMate to write my code and it has a pretty nice svn bundle that lets you add, delete and commit changes to the repository with keyboard shortcuts (⌃-⇧-A brings up svn commands with number keys to execute) right in TM. But sticking with the command line for the moment, I commit files to the repository:

svn ci -m “commit message”

You can delete superseded files from the repository too.

svn del filename

or

svn del foldername —-force

My host makes sub-domains really easy, so I just ssh into the appropriate sub-directory of the domain I’m working on and then check out a copy of the site. From then on I can update it just by ssh-ing to that dir and running and update:

svn up

I deploy to the final site the same way. It makes incremental development and upgrades easy. I just update the development subdirectory for the client to look at and then when they’ve approved it I update the main site. Svn does have an export feature that will deposit just the latest version of the site without all the older versions squirreled away. But unless your site is really old with lots of version or lots of big files, I don’t think it will hurt to do it the update way.

I find that it works well for me even though I’m a one-man-shop. I imagine that it would be even more advantageous in the collaborative environment that svn was designed for.

You can find out more about what svn can do with the free online manual.

Replacing BBCode with Textile on PunBB

I had to set up a forum last year and I chose PunBB to run it. PunBB is both clean and featureful, but it comes with BBcode as it’s default styling mechanism. I followed Mary’s directions to install Textile as posted in the Textpattern forum, but those directions are behind a login and I had a few things to add. So here’s my version:

Before we start, this replaces BBCode!

1. Download Textpattern

2. Grab the classTextile.php file (/textpattern/lib/classTextile.php) and copy it into PunBB’s includes folder (/upload/includes)

3. Open parser.php (/uploads/includes/parser.php) in your favorite text editor and comment out two functions, parse\message_ and parse\signature_. As of version 1.2.14 these start on lines 375 and 445 respectively.

4. Add this code after the two functions you just commented out.

5. Save. Now you can use Textile in PunBB.

6. You’ll notice that the submission textarea still mentions BBCode and not Textile. You can change text surrounding the ‘BBCode’ link on line 496 of post.php (/upload/post.php) and line 213 of edit.php (/upload/edit.php). But to actually change the linktext to read “Textile” you’ll also need to edit the /upload/lang/English/common.php file on line 86, right before the comment text “You probably shouldn’t change this.” I’ve pointed the link to the Textile page, but I plan to edit the help.php file (/upload/help.php) to include some local reference for formatting syntax. If you support multiple languages, you’ll need to edit each language common file.