Sorry, website is down for a bit. -Sha

Posts Tagged ‘wordpress’

Website notes

Wednesday, May 20th, 2009

The website updating has been coming along, and I thought I’d just give some information on hacks/modifications I’ve done to WordPress, as well as some other website-related news.

  1. When I imported my old entries from Movable Type, I noticed that not all of the line breaks were preserved, which left all of my entries looking squished. I found this support forum post which detailed some changes you could make to the Movable Type import code to insert line breaks on empty lines, which will preserve breaks between paragraphs. I made these changes and re-imported the entries, and it all seemed to work great, until I noticed that my auto-generated excerpts (which are the first 55 words of an entry) stopped working. I started poking around in the function that displays these breaks, and realized that the change to the import code must have inserted an ‘\n’ character into the empty excerpt field. Since the excerpt was now technically non-empty, WordPress would show that instead of auto-generating one. In order to fix this, I edited wp-includes/formatting.php, line 1483 (in function wp_trim_excerpt) and changed:

    if ( '' == $text) {

    to

    if ( '' == trim($text)) {

    So now WordPress considers the ‘\n’ as empty, and auto-generates the excerpt.

  2. I installed the Configurable Tag Cloud which is similar to the built-in Tag Cloud widget, but is more…configurable. I did notice one weird behavior, which was that my long tags were breaking out of their containing div:

    tag-cloud-unwrapped

    I looked through the widget code, and noticed that for some reason, all spaces in tags were being converted to non-broken spaces (tag-cloud.php, line 202):

    $tag = str_replace(' ', ' ', wp_specialchars( $tag ));

    So I just commented that line out, and everything was happy:

    tag-cloud-wrapped

  3. I was looking for all my entries related to my marathon training, and couldn’t find them, and then I remembered that I had made them in a separate running blog. So I went ahead and exported them from Movable Type and imported them to WordPress. You can find most of them by clicking on the national AIDS marathon training program tag, or by browsing the Fitness catagory.
  4. Finally, I changed the favicon to match the new look of the site: favicon. You will probably need to clear your browser cache to see it.
Tags: , , ,

Facebook sharing from WordPress

Sunday, May 17th, 2009

I just added a “Share on Facebook” link to each entry on my site. It’s more so I can easily post my entries to Facebook from my iPhone (no copy/paste…yet), but if you feel so inclined, you (my gentle readers) are free to use it as well.

When I was adding them, I discovered that the examples on the Facebook site don’t work quite right on WordPress index pages, because they rely on location.href and document.title, so any time you had a share link from an index page, it would link back to that index page rather than the individual entry you wanted. I fixed this by having the Javascript function take in the URL and title parameters, rather than grab them from the current page:

function fbs_click1(url, title)
{
    window.open('http://www.facebook.com/sharer.php?u='+url+'&t='+title,'sharer','toolbar=0,status=0,width=626,height=436');
    return false;
}

The link then becomes this in your index page or individual entry template:

<a title="Share this post on Facebook" onclick="return fbs_click1('<?php the_permalink();?>','<?php the_title();?>');" href="http://www.facebook.com/share.php?u=<?php the_permalink();?>" target="_blank">[link text or image]</a>

As I understand it, the reason why it’s better to put the popup code in the onclick attribute (rather than in the href attribute, e.g. <a href=”javascript:fbs_click1(…)”>) is so that browsers that do not have Javascript enabled can still use the link; it will just not be in a nice popup window.

This is all very simple, but was frustrating to do because I made a couple typos, and had to just stare at the code until I saw the problem (missing closing quote…boo). Is it even possible to debug Javascript?

Tags: , ,

Great success

Friday, May 15th, 2009

I finished importing all of my old entries, and thanks to some clever URL redirecting, there shouldn’t be too many broken links. I know there is a bit of weirdness with all of the photos posted from Flickr, and unfortunately I think I might need to edit those by hand. But otherwise, I’m pretty impressed by how easy it was to import all the entries, including the infamous Tom Delonge post, with all 504 of its glorious comments.

Edit: Amazing; my site has been up for less than one day, and I just got my first comment spam.

Tags:

Hooray!

Thursday, May 14th, 2009

If you’re reading this, WordPress installed correctly. Woo! Soon I’ll be importing all the old entries (and picking a better theme), but for now, I decided to just get this up and running now.

Please join me in welcoming sha v 4.0! I was rather fond of The Green Machine, but I was getting a little tired of Movable Type, and I installed WordPress on my photography site (no, still not finished, stop looking) and really liked it, so I decided to switch my main site to it, too.

I’ll probably be messing with themes and layouts for a little while, so please excuse any visual weirdness you might see. Any weirdness in content, though, is all on me.

Tags: