Friday, February 24, 2012

Embedding Phone Numbers with HTML5 for iOS

Snippet to embed contact data in a web page so that an iOS device can recognise text as a phone number or as contact data. Use the 'itemprop' attribute, although you can also wrap the div in a 'vcard' class, and setting the class of the phone number span to 'tel' seemed to do funky things too:

<div itemscope>
  <span itemprop="name">Rob Carr</span>
  <a class="nowrap" href="" itemprop="email"></a>
  <span class="nowrap" itemprop="tel">+44 1234 567 890</span>

I added a 'nowrap' class (white-space:nowrap;) purely for styling and usability. When the name or phone number is clicked on, you get the iOS dialogue box:

Contact info recognition doesn't seem to work on HTML5 desktop browsers, and no idea about whether other mobile devices will recognise the 'itemprop' property.

You can wade through the Microdata spec for HTML5 at, or Google for more examples. HTML5 Doctor always a good read.

Thursday, February 09, 2012

Install Drupal Remotely with SSH & Drush

  1. Connect to your server with SSH (using OSX Terminal, or Putty on Windows):
    ssh <username>@<site address>
    See for some background on SSH.
  2. In your server root directory - preferably not the 'Public HTML' directory, WGET the Drush tarball of the latest release of Drush (currently at release 4.5):
  3. Use TAR to extract and de-compress the archive, eg:
    tar xzvf drush-7.x-4.5.tar.gz
  4. Set up an alias to Drush
    alias drush='/myserverroot/home/drush/drush'
  5. Change working directory to Public HTML root of server
  6. Download the Drupal code
    drush dl drupal
  7. Move the download 'up' one level (the .htaccess file won't get copied in the blanket move command):
    mv drupal/* .
    mv drupal/.htaccess . 
  8. Remove the original [now empty] directory: 
    rm –r drupal
  9. Create a MySQL database (you may need to do this via your host's control panel)
    mysqladmin –u <db_user> –p create <db_name>
  10. Install the Drupal site
    drush site-install standard --account-name=admin --account-pass=<useruser_pass> --db-url=mysql://<db_user>:<db_pass>@localhost/<db_name>
  11. Fame and glory await
For more advice and a screencast, go to LevelTen's site, for a great post by Tom McCracken.

Only snag I've had with some hosts is providing enough resources for PHP/Drush to execute commands: 'Out of memory' a common problem, especially on shared hosting which may have relatively low memory. 256MB seems to be the minimum you can get away with to allocate to PHP [for Drupal/Drush] to run, so make sure when you purchase a hosting package, that you can have enough memory to play with.

If you have messed about a bit with Drush, you can check where your version is stored by running which drush on the command line. In this directory you may need to add a php.ini file that has suitable settings (eg memory_limit). Lots of issues on to help you: Google is your friend. If you can't tweak php.ini, you may be able to tweak drushrc.php - see for a bit of helpful advice.