Rubénerd Blog :)

Tuesday 01st September 2009

WordPress summaries on some posts

Every time I try to pry myself away from WordPress which I’ve been moved over to in 2005 after thinking for far too long, another feature comes along that makes the decision harder. I’ll give you the attention you deserve one day Django!

In this case, it’s the ability to show a summary of a post with a link to read more, but only posts you elect it to happen to. Given I merged all my blogs into this one recently I’ve decided to use this on anime reviews which tend to have a ton more graphics and are much longer. It also means I can append a mild NSFW warning on some posts above the read more link when Her Senjougaharaness insists on spending half an episode in the shower.

To pull it off, make sure you have this code within the the_content() method, NOT the_summary() as you may assume. Finally, wherever you want the more link to be inserted, add <!--more-->.

Spiffyness.

Thursday 23rd July 2009

[Anime] Restarting my deleted blog here

Proofreading blog posts
Kallen proofreading my nonsensical drivel…

For the longest time I was thinking whether or not to take the Zombie Plan approach and import my anime blog into it’s own subdomain WordPress install here, or import the posts into rubenerd.com with their own seperated category.

Seems the decision was made for me, my university wiped my database and the SQL backups I had made in my home folder. All my screenshots from three years of blogging are still there as well as the original theme files, but the posts themselves are gone. Like a Pythonesque dead parrot, they have ceased to exist. It’s entirely my own baka baka baka fault of course, I should have put my backups in a separate location. Lesson learned!

Never fear though (I can hear you fearing… wait what?) I’ve decided to pick myself up and start again, only this time I’ll be posting my anime reviews and senseless Japanese culture discussion here on Rubenerd.com in the sparsely populated anime category which ironically happens to be one of my most visited pages!

And here I was thinking Haruhi’s Endless 8 would be the thing irritating me most about anime currently. I blame Kyoto Animation. Yeah, that works. Could Mikuru go back in time for me and rescue my old posts? Or perhaps with her bizarre and endless amount energy Minori could rewrite them all one afternoon. Or Negi and Louise could just use their magic wands to recreate them. After Britannia that doesn’t control Britain has been defeated, Mio has got over her stage shyness, those wooden starfish for Fuko have been carved and Mai has moved to her new school with that huge smouldering crater in the front garden. Yes I’m a hopeless closet anime watching geek who’s not cool enough to be an otaku, shaddup!

Haruhi and the gang

I haven’t decided whether or not I’ll use the WordPress magic I learned to theme the anime category differently and prevent posts from appearing on the home page and master RSS feed to still make it appear as a separate site. Might be a bit jarring seeing all this new and unrelated stuff start appearing here.

I over-think things too much. Or do I over-think things too much after all? Or do I just over-think to the extent that it impedes my abilities to make decisions? Is that the definition of over-think?

Perhaps a moment with Kyou in the gym supply closet would calm my nerves about this loss and subsequent indecision about where to go from here. Nah, Mizuno Ami is still the best ^_^.

Now do you see why I kept my anime blog posts separate?

Tuesday 14th July 2009

Seperate templates for WordPress categories

Here’s something interesting. If you use WordPress you can assign separate templates for different categories; presumably I’m assuming (what a redundant few words) this also means you could give different categories different CSS styles too.

The WordPress Codex says you can define different templates in your current theme based on the ID of the category you want to customise. If it doesn’t find a specific template for the category, it reverts back to the theme default.

For example, the Rubenerd Show category here has an ID of 277 (the unfortunate legacy of using categories as tags before WordPress has native tag support) which means if I wanted to create a custom theme template for it, I’d create a category-227.php file. Other categories don’t have that ID, so they’d continue to use the basic category.php template.

My plan of merging all my blogs into this one while giving the appearance of separate sites seems to be a neverending story, but all the pieces seem to be falling into place. So far I’ve learned:

I’m starting to think it may have been less work to just move my blog here to my Django system after all, but I guess I have the advantage in this case that someone else is maintaining the code. I’ve gone this far though I guess, so no point stopping now!

Wednesday 08th July 2009

Getting priorities right with WordPress 2.9

Now that version 2.8 is out the electronic door whatsit, The Twitterverse is all abuzz over features people want to see in WordPress 2.9. I’m surprised the vast majority of these requested features have to do with hosting and organising media instead of dealing with some of the shortfalls of the platform itself.

My particular gripe has been the WordPress limit of one blog per installation without resorting to installing multiple copies or using WordPress mu, both of which are overkill. The stop gap workaround for this has been to use categories with separate styles for each section, but even this is more difficult because (by default) categories have to contain the term category in their URIs and separate themes cannot be assigned to different categories.

Honestly, with the amount of discussion I see around the net about this, I reckon there’s more pent up demand for more basic blog functionality than fancy media hosting and organising; as far as I’m concerned the lunch of that idea has already been eaten by the likes of Flickr and YouTube any way. The phrasing of this paragraph is terrible.

My 10 cents. Adjusted for inflation. Or perhaps with the current economic climate maybe I should deflate it to 1 cent. Plus GST of course.

Saturday 27th June 2009

Removing Categories from Wordpress URIs

A few months ago I lampooned Wordpress for it’s need to have the term "category" appear within every category URL. It appears I’m not the only one who found this irritating.

For me I wanted to merge all my disparate nonsense blogs into one meta nonsense blog (Rubenerd.com) which would be easier to maintain, then use categories with their own CSS to make them still appear separate. A shrewd, devilish cunning plan worthy of Baldric himself, but alas having the term "category" in all the URis spoilt the illusion.

Original blogs Ideal new sub-URI Wordpress illusion screwup
Rubenerd Show rubenerd.com/show/ rubenerd.com/category/show/
Fun Facts rubenerd.com/nonsense/ rubenerd.com/category/nonsense/
Intranet rubenerd.com/anime/ rubenerd.com/category/anime/
Studies rubenerd.com/studies/ rubenerd.com/category/studies/

Fortunately having played with and been disappointed by so many plugins in the past, I’ve finally found one that works so beautifully I’m thinking of sending the writer a grilled cheese sandwich: the adeptly-titled WP No Category Base. Not only does it work right out of the box, but it also redirects your previous category permalinks which means you don’t need to mess with .htaccess files. A beautiful, elegant solution!

As the name suggests this plugin will completely remove the mandatory "Category Base" from your category permalinks ( e.g. "myblog.com/category/my-category/" to "myblog.com/my-category/".

The plugin requires no setup or modifying core wordpress files and will not break any links.

Now I can finally start to import all my other posts. Apparently the anime category gets the most hits here anyway despite it having nothing of value in it! Crazy, grilled cheese sandwich stuff.

I’ve already figured out how to exclude certain categories from certain places so they act like separate sites with their own styles and whatnot, now I just need to work out the feeds. I know Wordpress allows you to generate separate RSS and Atom feeds for different categories, but how do I customise them? For example, add iTunes information to the Rubenerd Show category feed, but not any others.

If I spent as much time blogging and talking about interesting topics on my blog and podcast as I did blogging and talking about blogging and talking, I’d get much more blogging and talking done on my blog and podcast. Wait, what?

Monday 08th June 2009

Excluding WordPress categories

I can confirm adding the following code to the functions.php in my current theme prevents posts from certain categories appearing on the home page, and the main site RSS feed. In this case we’re filtering category ID 5:

function myFilter($query) {
  if ($query->is_feed || $query->is_home) {
    $query->set('cat','-5');
  }
  return $query;
}
add_filter('pre_get_posts','myFilter');

If you only want to filter categories from the home page, simply remove the $query->is_feed || condition, and vica versa.

This little change really allows WordPress to be used as a simple CMS by allowing you to separate material and provide category feeds for different types of posts. I’ll be using this so regular readers subscribed to my main RSS feed don’t get any of my anime posts from my blog that I’ll be importing from my university intranet.

Thanks to Scott Jangro for this great tip.

Friday 22nd May 2009

WordPress category URI conundrum

ANOTHER UPDATE: This post has been superseded by a new one with updated information. This should now be considered hysterical. I mean, historical.

UPDATE: Both these plugins messed up a whole pile of my permalinks. I’ve decided to deactivate them and live with the problem until a solution is created upstream in WordPress.

When I merged the Rubenerd Show and some other material into this blog to reduce overhead and the number of concurrent installations of WordPress I had to keep up to date, my plan was to give the illusion of separate sites by using categories that would have their own themes and RSS feeds.

I figured URIs like these would also make much more sense than the hodgepodge of addresses I had before:

Old address New address
rubenerdshow.com/blog/ rubenerd.com/
rubenerdshow.com/ rubenerd.com/show/
rubenerdshow.com/blog/about/ rubenerd.com/me/
[intranet anime site] rubenerd.com/anime/
rubenerdshow.com/blog/category/software/ rubenerd.com/software/
[...] [...]

The problem I quickly ran across though was one that any serious WordPress user has already realised, in it’s default state it’s impossible to remove the “category” identifier from URIs. While the above URIs are clean and make sense, having the show appear as http://rubenerd.com/category/show/ just looked… well, stupid.

I was about ready to launch into some mod_rewrite hacking, but fortunately I came across te beautifully elegant Decategorizer plugin by Bruno "Aesqe" Babic that did the trick. Once you’ve installed and activated the Redirection plugin by John Godley then installed and activated Decategorizer, it not only removes category from URIs for the categories, but also just as importantly from RSS and Atom feeds.

Rubenerd dot com slash show rolls off the tongue much more easily than Rubenerd dot com slash cateogry slash show. Why do I all of a sudden have a Fatboy Slim song stuck in my head?

Wednesday 06th May 2009

SimpleTags for WordPress

Michael Franks
My post about Michael Franks was the last to use the SimpleTags plugin. Couldn’t think of any other picture to put here!

When I started using it for this blog back in 2005, WordPress didn’t have native tagging abilities. The Ultimate Tag Warrior was the most popular third party plugin to provide them at the time as evidenced by the importer available for it in more recent WordPress versions. I chose not to use it because I’ve never been comfortable with plugins altering my blog’s database.

The solution I found at the time was Broobles’ SimpleTags which allowed tags to be defined within the text of a blog post either inline or in a block. When the post was rendered the plugin would generate a nice list of Technorati tag links with the rel="tag" attribute so they’d be recognised as such. No muss, no fuss.

ASIDE: All posts here that used SimpleTags have since been mass tagged with the simpletagged tag using WordPress’s tagging system. That’s right, I have an internal tag for posts that have been tagged in another system. I also had a grilled chicken sandwich for lunch, and I don’t hear anyone complaining.

When WordPress implemented tagging support I stopped using SimpleTags, meaning most of my posts from 2006 (and very early 2007) still have them. Fortunately SimpleTags still works even with the latest versions of WordPress so I can keep it installed to generate those links. For example, I can define a few right here:

That was fun, I haven’t done inline tags in a long time!

Even though I’ve moved over, I can see situations where SimpleTags would still be preferable to using WordPress’s tagging abilities. Unfortunately (in my opinion) WordPress handles tags very much like categories in your blog database, meaning if you don’t want your tables to get ridiculously huge and therefore take longer to backup, you have to be more restrictive in your tagging. With SimpleTags you can tag a post with as many as you want; I remember on many posts I would include several different spellings of the same word, and with posts about software I’d include a generic name tag along with a more specific name and product version tag.

So I did end up reviewing SimpleTags, it just took 4 years to do it ^_^.

Monday 04th May 2009

Why do spammers spam?


Spam, spam, spam, spam, spam…

In 2007, Raj over on BlogHash asked Why do spammers spam blogs?

Spammers should know that over 99% of the time their comments are taken care by anti-spam plugins like Akismet, 0.5% times manual intervention of a blog owner marks their comments as spam, and the rest of the time they succeed. When the success rate is below 1%, why spam? Why not spend that valuable time of yours to do something worth?

Even though it’s two years later, I still know the not very PC answer: Because they’re dumb! Thank you.

Saturday 18th April 2009

Restoring posts since February finally done!

My workspace from this evening. Now all I have open is this browser window :)
My workspace from this evening. Now all I have open is this browser window :)

Well after several long hours of debugging, cursing and several tall cups of coffee, my Perl script to import static pages from Google’s cache, convert them to a WordPress WXR/RSS file and import here worked! This means all the blog posts from February 2009 to April 2009 that weren’t part of my last good backup are now available again.

Had it not been for Google’s cache, over 120 posts would have been lost.

I’ve started a cron job to make automatic backups every evening in both WXR/RSS and SQL formats and send them to a secret email address so this mess never happens again. I’ll also be looking into checksumming/hashing said files before and after their transfer so I don’t end up with the same invalid, messed up export files I had to deal with and piece back together this time around.

Aside from the changed webhost and URI, everything is now back to the way it was before. The only things missing are comments; if you left a comment on a post over the last two months feel free to write another if you could be bothered.

Next step is to finally implement my new theme I’ve been kicking around for a few months. As I said in the last post I’ve tried my best to set up correct redirects for search engines and people subscribed, as well as changing the URIs on all the posts here to speed things up. If you see something amiss, feel free to leave a comment.

UPDATE: If you see repeated posts in Google Reader, Bloglines or other blog readers, I’m sorry for bombarding you! I attempted to maintain the permalinks so this wouldn’t happen, but clearly Google Reader and Bloglines still thought they were new posts.

UPDATE: It seems a couple of posts are still missing because they were uploaded too recently to have been put into Google’s cache. Tomorrow morning I’ll go to trusty Google Reader and copy them back here. Google has been a real pal over these last few days!

< Older posts
Dedicated to my groovy late mum Debra Schade.