Blogging Archives, page 12

Blogging about blogging, how meta.

Importing Haloscan comments into WordPress from Blogger

Update, please read this first!
The instructions below only worked for WordPress 1.5, 2.0, 2.1, and 2.2 before Google released a new version of Blogger—which broke the WordPress importer. Since that time, these instructions have ceased to be useful. However, if you’ve recently imported your Blogger blog into WordPress 2.3 (or are planning to) and need to import your Haloscan comments, check out my new post created specifically for you: Importing Haloscan comments into WordPress 2.3 from Blogger. I’m leaving this post here for posterity, but since it’s no longer doing anybody any good, I’ve closed the comments.

Background

WordPress logoJudging by the response to my original moving from blogger to wordpress post, this is a popular topic. However, I only meant for that post to be useful to the next hacker down the line and not so much for the faint of heart. This post seeks to remedy that oversight with an improved script for importing Haloscan comments into WordPress.

This was made possible after Haloscan fixed their comment export feature so that html is no longer stripped from the comment text. The other night I looked back at some code I had pieced together based on Phil Ringnalda’s code from his post, Importing YACCS comments in Movable Type, and I was able to finish the Haloscan importer the way I had originally intended: without screen scraping! If you have any problems or suggestions, feel free to leave a comment. Enjoy.

Step 1: Upgrade Haloscan

Only “premium” customers have access to Haloscan’s export comments feature. Bah! The only way to get around this limitation and get access to your comments for export is by donating $12 to Haloscan. If you do make the donation, the instructions and code below (for versions 1.5.x and 2.x of WordPress) should work for you.

Step 2: Import Blogger posts into WordPress 2.x

If you’ve already imported your Blogger posts using WordPress 2’s importer without the modification below, you will need to delete the posts you’ve imported, make the modification described in step 2, and rerun the importer. Luckily I’ve created a plugin to make deleting all of your blog posts a snap.

  1. Open /path/to/wordpress/wp-admin/import/blogger.php in a text editor
  2. Find the following line (line 404 in v2.0.2)
    $post_content = $postinfo[2];

    and change it to this:

    $post_content = "<!--" . $postinfo[3] . "-->" . $postinfo[2];

    Explanation: This stores each blogger post id as an html comment at the beginning of the post, which is used later to associate the post with the appropriate Haloscan comments.

  3. Save the file and then return to a web broswer
  4. Log in to the WordPress administrative interface and select the “Import” option from the top menu, and then select “Blogger” and follow the instuctions for importing your posts
  5. Continue with Step 3: Importing your Haloscan comments below

Update: If you’re interested in maintaining the permalinks to your posts, I’ve written a post called Maintain permalinks moving from Blogger to WordPress that requires three additional changes to the blogger.php script, which need to be made before you run the import. (17-Oct-2006)

Step 2B: Import Blogger posts into WordPress 1.5.x

Note: This step is left here for historical purposes. WordPress 2 comes with a significantly more advanced importer for Blogger which should be used instead of the instructions below. If you’re importing into WordPress 2.x, skip to Step 3.

The instructions marked with an asterisk (*) below are slightly different from the instructions that come with the import-blogger.php script provided by WordPress. In particular, step 7 is crucial in order to import comments from Haloscan.

If you’ve already imported your Blogger posts into WordPress using the provided import-blogger.php script and you can’t or don’t want to delete the posts that you’ve already imported, I’ve written a script to insert the Blogger post IDs into your WordPress posts so that you’ll be able to successfully import your Haloscan comments.

Just download insert-blogger-post-ids.zip, unzip it, and upload insert-blogger-post-ids.php to your wp-admin directory. Then run it in your browser like you did import-blogger.php. Now you can skip down to the section entitled “Importing your Haloscan comments”.

  1. log in to Blogger
  2. go to Settings > Publishing and set FTP Path to your WordPress install e. g. /path/to/wordpress/
  3. *change Blog Filename to wordpress.html
    explanation: prevents creating an index.html file in wordpress directory—this file can be deleted later
  4. go to Settings > Formatting and change Timestamp Format to mm/dd/yyy hh:mm:ss tt (the first option) and set Enable float alignment to “No”
    explanation: the second change prevents Blogger from inserting unnecessary formatting markup at the beginning and end of each post
  5. go to Settings > Archiving and set Archive Frequency to “Monthly”, set Archive File name to wordpress.php, and set Archive Path to your WordPress install e. g. /path/to/wordpress/ (should be the same as above)
  6. *set Enable Post Pages to “No”
    explanation: prevents creating post pages filed under directories named 2004, 2005, etc in your WordPress directory which would eventually collide with permalink rewrites
  7. *go to Template > Edit Current and replace your template with the following line of code
    <Blogger><wordpresspost><$BlogItemDateTime$>|||<$BlogItemAuthorNickname$>|||<!--<$BlogItemNumber$>--><$BlogItemBody$>|||<$BlogItemNumber$>|||<$BlogItemSubject$></Blogger>

    explanation: includes the unique blogger post id within an HTML comment in the body of each post

  8. Click “Save Template Changes” and then click “Republish” to republish your blog
  9. goto http://example.com/wordpress/wp-admin/import-blogger.php where example.com/wordpress is replaced with the domain name and path to your WordPress install
  10. click OK at the bottom of the page to import your Blogger posts

Step 3: Importing your Haloscan comments

import-haloscan.php has be revised for WordPress 2.x so that comment counts are now automatically incremented.

  1. Download and unzip import-haloscan-2.0.zip (v2.0)
  2. Upload import-haloscan.php to your wp-admin directory
    /path/to/wordpress/wp-admin/
  3. log in to Haloscan
  4. go to Manage Comments > Export
    Note: only “premium members” have access to export their comments, but if you’re really serious about leaving Haloscan, you might be willing to donate the $12 necessary to gain access to your comments for exporting.
  5. There will be an export link for every thousand comments you have. Clicking one of the export links will prompt you to save the file as “export.xml”. If there is more than one link (i.e. if you have more than 1000 comments), rename the first file to export1.xml, the second file to export2.xml, and so on. Save the files to your desktop and upload them to your WordPress directory
    /path/to/wordpress/
  6. Go to http://example.com/wordpress/wp-admin/import-haloscan.php where example.com/wordpress is replaced with the domain name and path to your WordPress install
  7. Click OK at the bottom of the page to import your Haloscan comments

monthchunks for blogger

unfortunately this took me a long time to get around to. i got the following request in response to my monthchunks for wordpress post:

So is there any way that someone still on Blogger (waves hand in the air with earnest and pleading look on face) could wangle the original javascript to turn the ‘standard archive link into something a little more compact’? I assume this would be code that goes into my custom template in place of the month-by-month links I’ve got there now? Short of a real calendar, the less vertical space used up by my archive links list, the happier a camper I am. Many thanks, I hope! —Leeeny

i developed the monthchunks archive format originally in javascript to modify the display of the links to my blogger archive pages. but since i moved my blog over to wordpress and replaced the javascript with a plugin written in php, i thought the javascript was gone.

of course it completely skipped my mind that my neatlinks sidebar blog is blogger driven, and the monthchunks-style archive links at the bottom of the column are indeed generated by javascript on the client. here’s how to do it.

  1. get the javascript monthchunks-1.0.js into your blog in one of two ways:
    1. if you have the ability to upload files to your web host, grab the the monthchunks javascript above and upload it to your web directory (i put my javascript files in a folder called “scripts”), then add the following line of code before the </head> tag at the top of your current blogger template
      <script type="text/javascript" src="/scripts/monthchunks-1.0.js"></script>

      note: the src attribute assumes the script lives inside a folder called “scripts”—if this is not the case, change it appropriately

    2. if you cannot upload the javascript file to your web host (for instance if you’re using blogspot), add the following lines of code before the </head> tag at the top of your current blogger template
      <script type="text/javascript">
      // paste function here
      </script>

      then left-click the “monthchunks” link above, copy the javascript, then paste it where it says // paste function here

  2. update your current template’s archive links output. it may look something like this:
    <BloggerArchives>
      <a href='<$BlogArchiveURL$>'><$BlogArchiveName$></a>
    </BloggerArchives>
    

    replace it with this:

    <script type="text/javascript">
    var archives = new Array();
    <BloggerArchives>archives[archives.length] = new Array('<$BlogArchiveURL$>', '<$BlogArchiveName$>');</BloggerArchives>
    monthchunks(archives);
    </script>
    <noscript><BloggerArchives><a href='<$BlogArchiveURL$>'><$BlogArchiveName$></a> </BloggerArchives></noscript>
    
  3. finally change your archive date settings in blogger (under settings > formatting > archive index date format to the mm/dd setting

and of course, if you run into any problems or have questions, please leave a comment. enjoy.

Adsense for Feeds, Counterpoint

Matt Haughey makes a case against Adsense for Feeds:

You can be fairly sure that every single person subscribed to your feed is a daily reader and it’s not likely random searchers would add your feed. The people reading your feed are using a feed because they don’t want to miss a single word you’re saying. They’re not just fans reading your site, they’re more die-hard than that.

Who would you subject to advertising, if you had a say in the matter: random visitors or your biggest fans?

This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.

Full Text Feeds, Yey!

With the help of Simple RSS Customizations, I’ve now updated Beasts to have fulltext RSS 1.0, RSS 2.0, and Atom 0.3 feeds, with HTML. Though honestly I’d like to settle on one feed eventually, preferably Atom 1.0. I’ve just got to get through the book first.

I’ve also turned on comments for unregistered, non-TypeKey users.

This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.

Google Adsense for Feeds

This could be big:

AdSense for feeds is a program that enables publishers to place relevant ads in the feeds they syndicate. Google technology understands the nuances of language, and places ads that are closely matched (or “targeted”) to the content next to which they appear.

This post first appeared on From the Belly of the Beasts, a weblog from some of the people who build O’Reilly websites.