Conceptric

  1. Capistrano works!

    Deploying even my simplest web applications was a complicated matter:

    1. Log in as a privileged user.
    2. Create the domain deployment directory.
    3. Export the application code from Subversion.
    4. Update the file ownership and privileges.

    For Wordpress I also had to export code for each theme or plug—in to the required locations. So I decided to improve the situation. I’ve changed the way my Wordpress sites are handled in Subversion; haven’t moved to Git yet like the rest of the world, and I am using Capistrano to manage the deployment.

    Capistrano is a Ruby based remote task manager, the most commonly used tasks being for web application deployment. Obviously the original target was Ruby on Rails, but many people use it for PHP. It uses Secure Shell (SSH) as the preferred method for logging into remote servers; all communication is then encrypted.

    What follows isn’t a full set of instructions on deploying PHP with Capistrano, HostingRails.com provide a useful piece and you should look at the Capistrano manual, these are my thoughts. May be something more detailed might come later… but no promises.

    Managing the source code.

    The Subversion repository for each blog project uses a vendor branch of the Wordpress source code and svn:externals properties to import the required themes and plug—ins from their respective repositories.

    Wordpress updates are integrated into the vendor branch and then into any of my projects without disturbing any custom code changes. For merging changes I can strongly recommend using the svn_load_dirs.pl script, it allows you to maintain file history and makes the whole process easier.

    And now deploy.

    I currently have my main Subversion and Web servers on the same machine, leaving me with the option to use the local file:// protocol to retrieve the application files. I wanted to make my deployment script more universal so that I could use it for the production and development platforms.

    The obvious choice was the svn+ssh:// protocol I normally use, but in addition to SSH, I use public key authorisation with passphrases for all of my servers. A frequent problem was that Capistrano didn’t like asking for passphrases for remote machines.

    Since the repository and deployment machines are one in the same, I can use SSH forwarding to provide a recursive tunnel by defining the following in the deploy.rb script.

    set :user, "me" 
    ssh_options[:forward_agent] = true
    

    The variable user tells Capistrano which user has SSH access and the forward_agent option allows the same SSH credentials for the tunnel to the Subversion server. Now , if your svn user is different from the ssh user you’ll need to add another couple of things:

    set :svn_user, username
    set :repository, "--username #{svn_user} svn+ssh://hostname/repository/#{application}/trunk"
    

    These variables enabled me to use the default deployment tasks for my application, there’s no need to override them, just use the before_ and after_ hooks to define additional functionality.

    The result.

    I have two WordPress blogs deployed on my server using Capistrano and Subversion for remote control, including custom themes and third—party plugins. I’ve already redeployed to incorporate changes and everything has worked perfectly.

    Next… Drupal?

    No comments.

    Categorised in:
  2. Claimed in Technorati

    This is just a post to let me claim my blog in Technorati, like there’s any chance I’d give them my username and password. Technorati Profile.

    A blue cornflower macro photograph taken from the flickr photostream of ToppC

    A blue cornflower macro photograph taken from the flickr photostream of ToppC

    OK, I agree that this has very little to do with the general topics in this blog, but it was a test, looks pretty, and it’s blue like the overall colour scheme.

    No comments.

    Categorised in:
  3. Drupal revisited

    OK… as I mentioned in my previous article, I’d had a change of heart on the approach for the Northamptonshire Bird Club website.

    Redefining the Architecture.

    I decided to start again by defining the information architecture for the site based on a proper discussion with the Club committee. The first few meetings on this topic just weren’t as well focused as they should have been; mostly my fault for not knowing what I wanted from them; but this time I tried targeting those features that the membership would really value. Each of the features that emerged seemed to fall into logical sections of the information architecture:

    • About the Club — including notices, events and membership contacts.
    • Content on Birding — after all it’s the main focus of the Club.
    • Social groups within the Club divided by specific interest.

    These overall sections were used as containers for the more specific features, and these formed the basis for implementation.

    I’ve tried an online tool called WriteMaps for developing and sharing the architecture of this site. I haven’t decided whether it’s the best way to approach the job yet, but here’s the link to the detailed sitemap.

    Implementing the Design.

    The original site used custom taxonomy — tagging — to enforce the architecture, with multiple sections of the site sharing the same content types. As I mentioned, this made it very confusing for the Club editors, which was reflected in the site presentation.

    Installing new modules.

    I needed to add several new modules to support the new content. There are several ways of doing this; this alone is a substantial topic; but the simplest is to download the module directory containing the code into the modules directory of your Drupal installation.

    Content types.

    For this redesign I decided that each of the features should have a dedicated content type so that users only need select the right one, there’s help text as you can see, and it’ll end up in the right place on the website. No more messing about with tags!

    The new create content menu

    A great tool for this is the Content Construction Kit (CCK) module. It makes implementing new content types very easy; no PHP required; and there are a wide range of modules that provide additional data fields. I’ve used several to provide dates, images and even GoogleMaps, take a look at the full list of compatible modules on the Drupal website.

    Once the CCK module is installed, all the changes you want to make can be managed from the Content types section of Content Management.

    The content type management menu

    Providing access.

    All these new content types need to have access control set–up before you can go any further. This is done in Access control, under User Management in the administration section of Drupal.

    The user management menu

    You should find both create and edit options to set under node module for the new content types.

    The node access control options

    Once these are set the content types should appear on the appropriate create content menus.

    Setting up the paths.

    But you’ll want to set the URLs to reflect the new architecture before deploying.

    I use Pathauto to provide aliases for my content that better reflect the structure of the website and present friendly URLs. You can do this manually, but if you can’t rely on your users to do this consistently I would recommend using Pathauto.

    The Pathauto settings are under Site Configuration, and it’s the Node paths you want to set–up for your new content.

    Overview of the options for the Pathauto module

    These, combined with the individual content types, provide the structure for the website. For example I wanted the bird guide to appear within the birding section of the site architecture with individual entries beneath this, so I set the pattern to birding/birdguide/[title].htm.

    Examples of node path settings

    Time for a View.

    The Views module provides the ability to present node data in a range of different formats. With the module installed your views can be managed from the Administer views section found under Site building.

    Example of the Views administration options

    Here you can define new views for each of the content types and define a URL from which the specific view can be accessed in the browser. In the image above you can seen that I wanted the bird guide list to appear as the default in the bird guide, and gave it the URL birding/birdguide. These views can generate lists, tables and customised sorting, in addition to the more standard web page presentations.

    …And a menu.

    Finally we’re going to want a menu from which all our good work can be accessed. The menus and blocks in Drupal can all be found in the Site building section.

    The sequence is simple, first create a new menu for the features you’ve implemented, under the Menus section, using the URLs of the views;

    Example of the birding section menu

    and then go to the Blocks section and put the new menu where you want it to appear on the website.

    Placing the menus in left sidebar on the website

    That should be it! Your new functionality has been added.

    Conclusions?

    Having established this workflow, I implemented each of the identified features one at a time, ensuring it was working and acceptable before moving on to the next.

    I believe, and feedback suggests my users agree, that this approach to building a Drupal website is far more successful than a taxonomy based one. I still use taxonomy, but it now provides addition information for particular types of content rather than forming the basis for site architecture.

    As for Drupal itself, it’s relatively easy to use, even without significant PHP knowledge, and the large community provides a huge range of contributed modules and support. This makes it a powerful way to develop feature rich, multi–user websites very quickly.

    On the downside, I’ve found providing users with an easy way to upload and insert images very difficult. There are serious problems with using the popular TinyMCE WYSIWYG editor and IMCE file handling together; individually they work OK, but together… I need to look at this again.

    I would definitely recommend trying Drupal out if you need a CMS, for an image rich website; such as a gallery; I’d try Flickr or, for ultimate control, hand coded XHTML.

    No comments.

    Categorised in:
  4. Anatomy of a semantic blog

    What are the components of a blog post?

    • The title of the post.
    • The name of the author.
    • The date on which the post was published.
    • An excerpt from the content.
    • The post body itself.
    • The tags associated with the post.
    • The categories into which the post has been placed.

    I’m sure that there are more, but this is as far as I got… so the big question is how do I mark this lot up in order to extract even more meaning?

    The two text fields, both being content; the excerpt and post body; don’t necessarily need any container since they’re build from paragraphs. However using <div> would give me a lot more control over the CSS, but is this adding unnecessary mark-up?

    I thought about creating an unordered list out of the post metadata; author, date, tags and categories. It’s all very well describing the whole lot using the ‘metadata’ label, but that’s not very helpful because they don’t belong together.

    I figure that the tags and categories are easy since they’re obviously lists, and unordered ones at that. But the title, author and date are a different matter. Including them to a list is definitely adding extra mark—up, so I haven’t.

    This is definitely an ongoing problem.

    No comments.

    Categorised in:
  5. A remote future for my Mac mini

    I’ve come up with a brilliant idea to reuse my old Mac mini. I’m going to convert it into a server on my local network for development and hosting our personal web projects.

    OK… not very original, but the key point is that I want to be able to use the wireless networking, stick it anywhere, and not have to worry about peripherals. A very mobile server.

    I already work with remote servers over public networks, and rarely use anything but the command line. For this project I wanted to be able to use the Mac desktop. This seemed the perfect excuse to play with VNC. Additionally, I frequently use SSH and PKI for encryption and authentication respectively, but not VNC.

    The Plan.

    It seemed to me that there were several parts to the problem, with only one of which I’m familiar.

    1. Configure a VNC Client on the local machine.
    2. Configure a VNC Server on the remote machine behind a firewall.
    3. Enable SSH communication through the firewall.
    4. Lock it all up using an SSH tunnel through the firewall so the Server and Client could talk.

    Now to work!

    The Client.

    I settled on Chicken of the VNC (COTVNC), a open source project providing a VNC Client for Mac OS-X. Great, that’s just what I want and it gets good reviews, but I guess most other clients out there would work too.

    Once installed COTVNC takes almost no configuration, that all comes later in the SSH and Server.

    Connection set-up dialogue for Chicken of the VNC

    You might be able to see that I set up two connections; one for an unsecured connection, so that I could see if the security measures locked me out later; and this one for the secured connection, that’s why the host is the local machine.

    The Server.

    First I tried Apple Remote Desktop (ARD), but found it a little slow, but more importantly I couldn’t find a way to close the two ports in the firewall that the service automatically opened. While I’m diligently using SSH tunnelling to avoid compromising the security of my machine, these two ports are sitting there waiting for attack!

    Time to try a different approach. I chose to disable the ARD service, closing the firewall again and installed a third party VNC server. The one I selected was Vine Server from Redstone Software. The reason? Nothing better that I’d read good things about it in blogs and on message boards, it’s available for Mac OS-X, and it’s free.

    What is in the box for Vine Server on Mac OS-X

    For Mac OS-X it downloads as a disk image containing the Server and a Viewer. I just wanted the Server as I’m using COTVNC, so a drag toward the Applications folder and a double click later I’m ready to configure things.

    Vine server can be run in two different modes; as a System Server that starts automatically whenever the Mac starts up; or as a Desktop Server that can be run like any other application. Since I want to run my Mac mini as a remote headless — no keyboard, mouse or monitor — server, I only configured the System Server.

    Settings dialogue for Vine System Server

    Not especially difficult, but the eagle‒eyed out there might have spotted that I didn’t enable the “Require Remote Login” option; in fact I did the first time and bang went any connection. I reasoned that I’m using SSH tunnelling, so the Server won’t realise that the connection IS via SSH and block it.

    Set the System Server running, checking that it starts up again after a restart, and that’s the Server done.

    The Secure Protocol.

    Actually, this was pretty easy. Go to System Preferences > Sharing and enable the Remote Login service.

    Settings to enable the Remote Login service on Mac OS-X

    Make sure that the other services are disabled, unless you have a particular use for them; I’ll be enabling the Web Sharing service later. This should ensure that the firewall is closed on all ports except the one used for SSH — port 22.

    The Tunnel.

    The idea of the SSH tunnel was to forward any communications sent between port 5900 — the default VNC port — on the local machine and the remote machine, through an encrypted SSH connection.

    Now there are lots of utilities to help you manage your SSH world, but I tend to use SSH-Agent and the command line. I primarily use SSH-Agent to manage authentication, but it does have the ability to construct tunnels.

    Set-up dialogue for SSH tunnels in SSH-Agent

    If you’ve got PKI set up, you won’t even need to enter any passwords in order to establish the connection.

    The Result.

    Once your tunnel is connected, you can start up COTVNC, or equivalent, and log‒in!

    An image of the desktop on the remote machine

    Everything appears to work and I find Vine Server much more responsive than the Apple free offering.

    By the way, I tried logging in with the unsecured connection and was kicked out.

    No comments.

    Categorised in: