Moving from Blogger to Wordpress
September 14, 2009 by Ed Spencer · Leave a Comment
Over the weekend I migrated from Blogger (hosted by Google) to Wordpress (hosted by me). Overall, Wordpress feels far superior, but the migration was not without problems. Here’s a short guide to what I had to do:
Get Wordpress
First, grab the latest version of Wordpress. Being a PHP application, it just drops into a directory and works
Create a database, set config
Wordpress has a setup script but being a bit of a noob I couldn’t give it write permission to my filesystem. If you are also afflicted by such inadequacies the following steps may help you. For clarity I’ll call my DB ‘wordpress’. First, set up your database:
- mysql -u root
- CREATE DATABASE wordpress;
- GRANT ALL on wordpress.* TO ‘wordpress’@'localhost’ identified by ‘wordpress’;
You’ll need a wp-config.php file – Wordpress comes with a default one which you can copy thusly (in the root directory of your wordpress directory):
cp wp-config-sample.php wp-config.php
Now edit wp-config.php, and fill in the details to make it look a little like this:
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
define(’DB_NAME’, ‘wordpress’);
/** MySQL database username */
define(’DB_USER’, ‘wordpress’);
/** MySQL database password */
define(’DB_PASSWORD’, ‘wordpress’);
/** MySQL hostname */
define(’DB_HOST’, ‘localhost’);
Hitting the site now should show a default Wordpress installation with some dummy content. Whoop.
Import from Blogger
Importing from Blogger is pleasingly simple – just use the Tools -> Import option on the menu. It’ll ask you to verify access and then pull down all your posts and comments.
It’s not perfect though – for me the post Tags were imported as Categories. To get them to be Tags again, go to the Posts -> Categories menu and use the handy Categories to Tags converter.
I found that the imported Post markup was pretty mangled (I think this is Blogger’s fault, not Wordpress’) – <br />s everywhere and no line breaks. To resolve this I cracked open mysql again and ran the following:
- use wordpress;
- UPDATE wp_posts SET post_content = REPLACE(post_content, “<br />”, “\n”);
That sorted me out alright. Next we need to set up how our permalinks work. Set this in the Settings -> Permalinks menu, and use the following format to mimic the Blogger urls:
/%year%/%monthnum%/%postname%.html
Wordpress will either write a .htaccess file for you at this point, or tell you it can’t write to the filesystem and give you a short text config which you must manually copy into a file called .htaccess.
One final thing to note is that Wordpress constructs its slug urls differently to Blogger (Wordpress would use ‘the-trouble-with-new’ vs Blogger’s ‘trouble-with-new’, for example). If you’re importing blog posts this means your urls won’t always match, so any incoming links will be broken. I couldn’t find an easier way to correct them than just copy/paste by hand – doesn’t take long though.
Syntax Highlighting
This whole step is entirely optional.
Because I’m a geek I post code fairly often. I used the SyntaxHighlighter library back in the Blogger days and wanted to keep using it. You can install the Wordpress plugin version from http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/. The old syntax didn’t seem to work, so I needed to go back into mysql and run the following:
UPDATE wp_posts SET post_content = REPLACE(post_content, "<pre name=\"code\" class=\"js\">", "[c0de language=\"js\"]"); UPDATE wp_posts SET post_content = REPLACE(post_content, "</pre>", "[/c0de]");
NOTE: So that Wordpress doesn’t interpret those tags above I’ve changed the ‘o’ in code to a ‘0′. You need to change it back
This just swaps all your old <pre name="code" class="js"> and </pre> tags for [c0de language="js"]and [/c0de] respectively. Repeat the first line for any other languages you have used (for me this was xml, css, html and ruby).
Fixing feeds
Wordpress doesn’t like the world to see your content via RSS. Odd, isn’t it? There’s an option in Settings -> Reading which claims to output the full text of each article into your feed, but it doesn’t seem to work. Instead, what you need to do is hack your theme a little. You’ll need to edit the wp-includes/feed-rss2.php file and change line 47 from <?php the_excerpt_rss() ?> to <?php the_content() ?>.
If you’re using Feedburner or similar, don’t forget to give it your new feed url too. In this case you should also update wp-content/themes/yourTheme/header.php and swap out the occurrences with your Feedburner url.
Upload and update DNS
At this point everything should be working nicely, so upload your blog folder and update your DNS settings. I’m guessing if you’re hosting Wordpress yourself you don’t need help with this. I’ve made my own blog into a git repository up on Github, allowing me to deploy any changes I make using Capistrano. It’s a nice solution – for more information see this lovely post by the gentlemen at imedo.
Read my BDD article in this month’s JS Magazine
June 10, 2009 by Ed Spencer · 7 Comments
I have an article on Behaviour Driven Development for JavaScript in June’s edition of the excellent JavaScript Magazine.
If you haven’t seen or read the magazine before (it’s quite new), it’s well worth the few dollars charged. The magazine format allows for in-depth articles that require more space, time and effort to write than a typical blog post, and which therefore often go unwritten.
The thrust of my article is that too much of our JavaScript goes untested, but that nowadays it’s easy to fix that. I go through an example of a client side shopping cart, using the JSpec BDD library. Even if you don’t buy/read the magazine, I highly recommend checking out JSpec and other libraries like it. As JavaScript powered applications become the norm, BDD will only become more important in ensuring our applications work properly, so now is a good time to start.
Also in this month’s issue is a guide to using the Canvas tag, tips on how to use build scripts to optimise your JavaScript for each environment, AJAX security pointers and a roundup of community news.
Darwin, Humanism and Science
June 7, 2009 by Ed Spencer · 2 Comments
On Saturday I had the good fortune to be able to attend a conference entitled “Darwin, Humanism and Science“, held at London’s Conway Hall. For those not able to attend here is a short roundup of what happened:
Richard Dawkins starts us off
The conference kicked off with a quick introduction from BHA President Polly Toynbee, after which Professor Dawkins took to the stage. His lecture revolved around the concluding paragraph of Darwin’s On the Origin of Species, which can be read online for free here (the relevant passage starts “Thus, from the war of nature …”). Dawkins analysed each segment of the text in turn, giving us his insights into its meaning and slipping in some fascinating information about our modern-day understanding of evolution, such as how we know that all species in the world today must be descended from a single progenitor.
The professor left some time for questions at the end of his lecture. He had commented on the lamentable state of the public’s understanding of science, proffering the alarming statistic that some 18% of the British population believes that the Earth orbits the Sun once a month (presumably we go around faster in February), which lead me to ask him what we can do to combat this. His answer was to “get out more”.
Referring to the role scientists have to play in the public’s awareness and understanding of science, rather than (I hope) to my social life, he made the point that scientists and educators must make greater efforts to reach out to the public and disseminate not only the knowledge that modern science has obtained, but the joy that this knowledge can bring. It was a point that was returned to time and again throughout the day.
Insidious Creationism in Education
Following Professor Dawkins were two quick talks about the teaching of evolution in schools – first from a European perspective from Professor Charles Susanne, and then from a British one from James Williams. Though both highlighted the growing influence Creationist organisations are having on educational materials, Mr Williams’ speech was for me the more alarming:
Quickly firing through a series of ridiculous materials showing how children and dinosaurs once lived and played together, and even an endearing image of Jesus cuddling a small Velociraptor, Williams showed how creationist books, comics and literature represent an “intellectual abuse of children”. Entitled “Insidious Creationism”, his talk opened our eyes to the battle being waged over children’s education, in this country and around the world. I for one am very pleased that we have people like Williams fighting in our corner, and for his troubles he was presented with the rather dubious prize of an Atlas of Creation.
Human understanding of Evolution
After lunch we were treated to talks from Johan De Smedt and Dr Michael Schmidt-Salomon. Johan’s talk revolved around the three themes of essentialism, teleology and the design stance. Tackling these in turn he described the biases inherent within us that give these ideas more prominence in our mental model of the world than they deserve, especially when we are young.
Dr Schmidt-Salomon rebutted the idea that evolution can be objected to on moral grounds. Though it may seem obvious that a moral objection to a natural phenomenon does not make it any less real, he reminds us that there are those who disagree. His most impressive moment though was in revealing his efforts to turn Ascension Day into Evolution Day, aided by a spectacularly bizarre music video featuring Charles Darwin as an unlikely rock star:
Brilliant.
Hinduism and The Two Cultures
For me an unexpected highlight of the day came in the form of Babu Gogineni’s description of the devastating effect that some interpretations of Hinduism are having on science in India. He described how many Hindus believe that modern science backs up Hinduism’s central tenets, and can therefore turn their backs on further progress made by the scientific community. It was a startling and eye-opening description, and one could feel his frustration at how quackery and superstition are considered more important (or at least more profitable) than science and understanding in India today.
The conference was rounded off by what seemed a short talk from Professor A C Grayling. This was the first time I had heard Grayling speak, and the calm lucidity with which he spoke made his 45 minutes seem more like 5. Speaking on the ‘two cultures’ – that of science and that of the humanities – he referred to a lecture given by C P Snow some 50 years ago decrying the divergence of these two cultures, and the widening communication gap between them. Snow’s original point was that this divergence was getting in the way of solving the world’s problems – 50 years later Grayling points out that we still have some way to go in closing that gap.
The ‘Special’ Dinner
In the evening a special dinner was laid on for the speakers and delegates attending the conference (today was just one day in a week of Humanism conferences). For some reason they let some of the unwashed masses in too, and so it was that I sat down with a delightful group of fellow conference-goers to enjoy a good meal punctuated by good conversation.
After we had eaten Professor Grayling presented Professor Dawkins with an award in recognition of his efforts in spreading rationality and clear thinking around the world, and in return Dawkins read out a modern day episode of Jeeves and Wooster, albeit with a rather Atheistic stance. I’m not sure whether or not he penned the parable himself but it was extremely well written and its British humour well received.
All too soon the coffee came round and it was time to leave. Overall the day was very well run and extremely enjoyable. A wise gentleman on my table was moved to remark that “it was the best 8 quid I’ve ever spent”. Amen.
ExtJS Textmate bundle
January 10, 2009 by Ed Spencer · 3 Comments
** Update: Added extra instructions when downloading the bundle instead of git cloning it. Thanks to TopKatz for his help**
I develop on both OSX and Windows machines, and my editors of choice are Textmate and the excellent Windows clone E. One of the great things about Textmate is its bundle support, which allows you to create reusable code snippets (among other things).
I’ve got a good collection of these built up so thought I’d make them available on Github. You can install it like this:
Mac OSX:
cd ~/Library/Application Support/TextMate/Bundles
git clone git://github.com/edspencer/extjs-tmbundle.git ExtJS.tmbundle
Windows:
cd C:\Documents and Settings\{YOUR USERNAME}\Application Data\e\Bundles
git clone git://github.com/edspencer/extjs-tmbundle.git ExtJS.tmbundle
If you don’t have git installed you can simply download the bundle as a zip file, and extract it into the directory as above. You need to rename the extracted directory to something like extjs.tmbundle or it won’t show up. If you do go the git route you can of course cd into that git directory at any point and use git pull to update to the latest bundle version.
I’ll give one example of the usefulness of snippets like these; here’s the Ext.extend snippet from the bundle:
/**
* @class ${1:ClassName}
* @extends ${2:extendsClass}
* ${5:Description}
*/
${1:ClassName} = function(config) {
var config = config || {};
Ext.applyIf(config, {
$0
});
${1:ClassName}.superclass.constructor.call(this, config);
};
Ext.extend(${1:ClassName}, ${2:extendsClass});
${3:Ext.reg('${4:xtype}', ${1:ClassName});}
To use this you can just type ‘extend’ into a JS file in TextMate/E and press tab. The snippet takes you through a few editable areas such as the name of your new class, the name of the class you’re extending, xtype definition and description, then dumps the cursor inside the Ext.applyIf block. The actual characters typed are these:
extend [tab] MyWindow [tab] Ext.Window [tab] [tab] mywindow [tab] Special window class [tab]
Which produces this:
/**
* @class MyWindow
* @extends Ext.Window
* Special window class
*/
MyWindow = function(config) {
var config = config || {};
Ext.applyIf(config, {
});
MyWindow.superclass.constructor.call(this, config);
};
Ext.extend(MyWindow, Ext.Window);
Ext.reg('mywindow', MyWindow);
Hopefully it’s obvious how much time things like this can save when generating repetitive, boilerplate code. The extend snippet is one of the larger ones but even the small ones are very useful (pressing c then tab is much nicer than typing console.log(”); each time).
Any suggestions/contributions are welcome. Thanks go to rdougan for his contributions and organisation also.
There is also another ExtJS textmate bundle available at http://hakore.com/extjs.tmbundle/, written by krzak from the Ext forums.
Don’t forget the wurst
August 23, 2008 by Ed Spencer · Leave a Comment
So it came to be realised during Rails Camp 08 that the world was sadly lacking in William Shatner based list apps. Thankfully, the Railslove guys (plus Rany) have come to the rescue with don’t forget the wurst. If you’re looking for something delightfully random in your life, you may have just found it.
Check out my Shatner’s greatest hits list and Ask William about a few of the items – he will furnish you with compelling and thoughtful answers.