diary of an indie game developer

 

Archive for the 'Web Dev' Category

The Perfect Popup

Tuesday, April 10th, 2007

As a web developer, sometimes (rarely!) you just can’t get around creating a popup. Maybe you want to be able to define some terms, and can’t use a floating div because of Internet Explorer z-order bugs. Perhaps your client just really, really wants one.

This simple request– make a popup– is actually much more difficult than it seems. Window size and positioning requirements frequently preclude the use of target=”_blank”. Once you move to Javascript, though, you run into browsers running sans Javascript, popup blockers, and search engine unfriendliness.

To anyone who’s been in web development for a while, this isn’t a surprise: almost any seemingly small task becomes a maze of browser incompatibilities, security settings, search engine optimization, user experience, accessibility for the blind, and on and on. You need a toolkit you can return to, or you’ll end up spending hours or days on every “minor” feature.

Accessify provides some great scripts and tips to augment your bag of tricks. Returning to the subject at hand, they have this extensive walk-through of their perfect popup script. Web developers: it’s probably better than whatever you’re currently using for popups, on those rare occasions you have to use them. Everyone else: it’s a frightening demonstration of how much thought goes into what, on first glance, looks like one line of code.

Multiple stylesheets with TinyMCE

Tuesday, March 6th, 2007

It looks like the TinyMCE editor (the default editor for Wordpress) doesn’t support specifying multiple stylesheets for edited content. This is particularly common, since you’ll generally want to use your site’s CSS, plus a CSS full of overrides for the editor.

There are some helpful tips on the TinyMCE forums, but I’ll sum up the simplest hack here: simply write a PHP file that includes all the stylesheets you want.  My file here (copied from forum user “unfold”):

Filename: editor-styles.css.php
$includeme = $_SERVER['DOCUMENT_ROOT'].”/sitesubdir/site-style.css”; if (file_exists($includeme)) {include($includeme);}
$includeme = $_SERVER['DOCUMENT_ROOT'].”/sitesubdir/editor-overrides.css”; if (file_exists($includeme)) {include($includeme);}
?>

I still feel like TinyMCE should offer the option by default, since it’s so common, but I won’t argue with such a quick solution!

Creating a .htaccess file in Windows

Friday, February 16th, 2007

How many times has this happened to you?

  • File->New->Text Document.
  • Change from “New Text Document.txt” to “.htaccess”.
  • Windows: “You must type a file name.”
  • Hit F2 to rename.
  • Change from “New Text Document.txt” to “.htaccess”.
  • Windows: “You must type a file name.”

That’s right– Windows won’t let you create a file starting with a period.  Fret no more!

  • Open Notepad, Vim, or whatever you like.  Create a new document.
  • Save as .htaccess.
  • Hooray!  Other programs are not subject to explorer’s restrictions.

Forum Software Showdown

Thursday, November 30th, 2006

I just set up a message board for a client. There are at least 20 usable products out there: the awesome Forum Matrix solves that in a hurry. View a list of options pared down by your requirements, then view a list of the most important criteria to you (from a list of something like 50).

In this case, vBulletin was the winner. vBulletin is a very nice product, but the competition wasn’t nearly as strong as I’d anticipated after first viewing the size of the field. One similarly-priced solution has their demo offline until some time next year, with their site claiming it’s coming in October. phpBB has a lot of theoretical power from user-created mods, but they’re hit and miss (the file attachment mod is gold, but calendar options are lacking).

vBulletin was easy to install, has a great calendar, supports archiving, and is just extremely full-featured. It costs $160, which it quickly justifies when I compare its setup time with the work I spent on other solutions. People with different requirements might like phpBB or some other free option fine, though, so hit up that aforementioned matrix.

Blog setup: how WordPress, SEO, and .htaccess can all be friends.

Tuesday, October 10th, 2006

There are a lot of questions about making Wordpress play nice with other functionality on your site, so here’s the solution that works for me.
One of the first things to do after installing Wordpress is to configure it for “pretty permalinks”, in the options tab. That gives you links like this rather than some “index.php?a=144″ gibberish. Unfortunately, it modifies your .htaccess file to do this, and in a way that isn’t terribly friendly with other functionality you might want.

Fortunately, there’s an easy fix: enable Wordpress’s “verbose” rewrite rules by setting “use_verbose_rules” to true in your wp-includes/classes.php file.

Now that you’re good and friendly with your .htaccess file, let’s do a bit of search engine optimization (SEO) to your site. If your site displays the same at “mydomainname.com”, “www.mydomainname.com”, and “www.mydomainname.com/index.html”, you can easily confuse search engines. Unless you explicitly tell Google otherwise, for example, it will treat “mydomainname.com” and “www.mydomainname.com” as two different sites. If people start linking to both, it can hurt your PageRank.

There’s an easy solution to this, too: a 301 redirect. Several sites explain the ins and outs of 301 redirects and .htaccess syntax, so I’m just going to give you the code that works for me. Put this near the end of your .htaccess file, but before the “#BEGIN WordPress” section:

RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\.independentcreator\.com$
RewriteRule ^(.*)$ http://www.independentcreator.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(([^/]+/)*)index\.html\ HTTP/
RewriteRule index\.html$ http://www.independentcreator.com/%1 [R=301,L]

Finally, I had a problem with this rule breaking WordPress comments: I had accidentally configured WordPress to use my site’s URL as “independentcreator.com” instead of “www.independentcreator.com” in the Options tab.

Importing old e-mail into GMail.

Monday, August 14th, 2006

Recently, a client decided to consolidate all of his e-mail into one GMail account. I’ve done the same thing: I enjoy labels and searchability far more than even corporate Outlook.

As long as you’re switching over to GMail for all the benefits, why not convert your old e-mails as well? This particular client needed his old e-mail moved for other reasons, but it was so easy, I decided to go and do it for my old mail as well.

In most cases, all you need is Mark Lyon’s GMail Loader. It’s super simple. You plug in a working GMail SMTP server from this list (or your ISP’s, if it blocks outgoing SMTP traffic), point it at your existing e-mail file or files, give it a target GMail address, and tell it to go to work. It then merrily chugs away, sending one at a time to your GMail account, leaving the old from/to intact (only the date gets clobbered). Beautiful!

In this case, the e-mail was already in a giant Outlook Express file, which isn’t supported by GMail Loader. No problem: just pop it into DbxConv and you’re good to go.