New website launched: Fremont.com

Screenshot of Fremont.comI am very excited to announce the launch of a major website redesign: Fremont, the Center of the Universe.

Fremont is a quirky little neighborhood next door to us.  The site is maintained by the Fremont Chamber of Commerce, with the delightful Jessica Vets as executive director.  Their old site looked really nifty, but was totally impossible to navigate and was starting to show its age.  So it was time for a new site, and I thought WordPress would be an ideal solution for them: we could make the site in WordPress for a smaller budget than anything else, and Jessica will be able to maintain the site herself.

I had a lot of fun working on the site: Jessica recruited Michele Savelle, a graphic designer in Fremont, to do the design, and the three of us worked really well together.  Our meetings were not only productive, but lots of fun.

The site is fully responsive: it should look good on any screen of any size.

Most of the site’s functionality is fairly standard, except for the business directory.  This was the most challenging part of the site, mostly because I had trouble finding a plugin that could do what I wanted.  Jessica maintains a business directory in Filemaker Pro, and she needed to be able to import data from that directory into WordPress.  I finally found a plugin that pretty much does what I want, although it does have some bugs: the DigitalQuill Data Import Plugin.  This plugin allows Jessica to export her Filemaker Pro database as a CSV, and then import it into WordPress.  Now all of the businesses in Fremont appear on the website, nicely arranged in categories.

Thanks to Jessica and Michele for being awesome to work with!

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in plugins, responsive, web design, WordPress | Leave a comment

A fully responsive site

Responsive is the big buzzword in web design these days – now that people view websites on so many different sizes of devices, web designs have to be able to respond accordingly and render gracefully in lots of different configurations.  This is one of the things I have always loved about web development: the need to be flexible, to think about how the site is going to look and work on different screens.  Now that responsive web design has arrived, I’m having lots of fun with media queries and percentages and ems.

I have several responsive sites in progress at the moment, but this week marks the official launch of the first fully-responsive design I have coded, and I’m absolutely delighted with how it turned out.  It’s for a new company called Answers in Hand, which facilitates providing information to cell phones via NFC and QR codes.  The fantastic graphic design is by George Guy of Warp Graphics.

So go visit Answers in Hand, and then resize your browser – as it gets bigger and smaller, the hand holding the phone changes orientation so that it always fits on the screen.  Once you get down to mobile phone size, the hand holding the phone disappears (since you’re already looking at it on a phone in your hand).

I’m not usually a fan of one-page websites, but this is a case where I think it works really well.

From now on, I’m making sure that all of my sites are at least a little bit responsive, and you’ll see some more fully responsive sites from me soon.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in responsive, web design | Leave a comment

301 redirects for URL typos for domains that have multiple sub-domains

Anyone who has tried to brand themselves or their company with a domain name knows that they should buy multiple domain names that are similar (e.g. .com, .net, .org) but they should also buy misspelled/mistyped variants of their domain names (e.g. example.com might also consider buying exampe.com and exampl.com).  Just buying the domains means others can’t pretend to be you and catch surfers who perhaps aren’t the best typists, but what if you want to actually have them go to your main web site?

It is fairly easy to just set them up on the same virtual host as your main site, but that (likely) means you will have two sites with duplicate content, which Google really doesn’t like.  So you want to provide a 301 redirect for the mis-typed domain to the correct one.  You could create a whole bunch of 301 redirects for each individual page, but if you’re dealing with dynamically generated content, that really doesn’t work. Luckily, the Apache web server has the RewriteRule, which can be used to redirect everything that comes after the domain name to the new domain name.
Continue reading

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in Uncategorized | Leave a comment

Shane White website: challenging and fun

This week I finished a website that I have been working on for over 2 months.  It was a surprisingly challenging website, but I had lots of fun coding it.  The site is for Shane White, a comic artist here in Seattle.  Shane did all of the graphic design, and then asked me to turn his designs into a WordPress website.

Shane isn’t a programmer, so he didn’t realize that a lot of what he was asking for on his website can get very complicated: e-commerce, ComicPress, different layouts and navigation for different kinds of content, different headers on different pages, and a very different look for the webcomic pages.  Any one or two of these things wouldn’t have been very complicated by themselves, but added all together, it made for a very complex site.

So here are some technical details about the site requirements and what I did to create this site to Shane’s specifications. Continue reading

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in plugins, web design, WordPress | Leave a comment

Writing WordPress themes for usability

One of the biggest reasons I create almost all of my websites in WordPress is that it’s user interface makes it very easy for my clients to update and maintain their sites on their own, without having to rely on me to make changes.  However, as a developer, there are some things I can do to make it easier for my clients to maintain their sites.

When I decide how to code a site, I think constantly about whether someone might want to change what I am coding, and if so, how easy will it be for them to change it?  Continue reading

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in web design, WordPress | Leave a comment

Why I like coding for graphic designers

I collaborate with several graphic designers – most frequently Danny McEnerney of workin’ man creative and George Guy of Warp Graphics – to turn their graphic designs into WordPress websites.  They send me Photoshop files of their designs, and I turn them into functional websites that match their graphics pixel for pixel.  I really love this aspect of my work.

It gives me something fresh and new to work on.  When I code my own designs, I find my own work predictable, since, of course, it comes from my own head.  When I can code someone else’s design, I have something new and interesting to work with, and other designers end up doing things that I never would have thought to do.

It might seem that once the graphic design is done, the creative part of the process is over and writing the code is just busywork.  On the contrary, I actually find that writing code requires a great deal of creativity, especially when it is someone else’s design.  I have to figure out how to write a bunch of text that the computer will translate into the images I see.  Not only that, but I always try to write websites so that they will be easy for the site’s owner to update themselves, so sometimes that requires a little bit of extra creative thinking.  It’s a fun problem-solving exercise, and it often requires thinking outside of the proverbial box or approaching the problem from several directions at once.

Coding for graphic designers has also made me a much better designer myself.  I have to examine the work of several different designers in minutia, and looking at how they put their designs together has taught me a lot about what I need to do when I create websites.

It might seem like writing WordPress themes over and over based on someone else’s designs would get boring, but I really enjoy it. I find it to be creative and stimulating work.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in code, web design, WordPress | Leave a comment

Mac OS X Lion, Terminal and ssh: how to start ssh-agent at login

As a freelance sysadmin, I use Mac OS X’s Terminal.app to connect to a lot of different Unix and Linux servers–I will frequently have a dozen or two (or sometimes three) terminals open to different machines.  This is one of the reasons I hate rebooting–I lose all my connections & pretty much have to start over from scratch.

I recently upgraded to Mac OS X Lion, and things have been mostly positive.  I really love the option to “Reopen windows when logging back in.”  In terminal, that means I get all my windows back! I do still have to reconnect to all the machines, but at least I can see where I was connected, and pretty much what I was doing.  I use screen extensively on  the servers I connect to, so I frequently don’t even lose what I was doing.

The only problem is that when Mac OS X boots back up and starts Terminal.app at login,ssh-agent is not started before Terminal.app starts, meaning I can’t log into servers using my SSH public keys.  Further, if you quit Terminal.app, and re-open it, it won’t reliably open ssh-agent (I’ve had it happen a couple times out of the many times I’ve tested).  The only surefire way to get ssh-agent to start is to close all your windows and then quit & restart Terminal.app with a completely blank slate.

That is a problem as it undoes all the good that saving all my windows did.  I wanted to find a way to get ssh-agent started before Terminal.app opened.  I added it to my Login Items without any success, and even adding a LoginHook to /etc/ttys did not make it start before Terminal loaded.

But, there is a workaround  in that if I have ssh-agent start at login, I can quit & restart Terminal.app and it always connects, so that is what I have done.  The probably more correct place to do is to add it to my Login Items.  To do that, I opened a Terminal window & created a symbolic link from ssh-agent to my home directory.

ln -s /usr/bin/ssh-agent .

Then I added it to my Login Items by pressing the + button and selecting it from my home dir.  I can then remove the symbolic link I created, as Login Items is smart enough to link to the actual ssh-agent program.

So now after bootup and login, if I quit Terminal.app and restart it, it always connects to the ssh-agent and I can go about my passwordless logging in to all my servers.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in OSX, Secure Shell | 7 Comments

Different layouts on different pages in ComicPress

I’m currently writing a theme for a website using ComicPress, a WordPress plugin/theme designed for publishing comics.  ComicPress is powerful, complex, and impressive.  It makes life a lot easier for writers and readers of webcomics.  I’ve been poking through the code a lot, and I have been impressed with what I see.

However, I did run into a weakness of ComicPress pretty quickly.  The comic artist for whom I am writing this theme wants different pages to have different layouts.  This is a pretty standard feature of WordPress sites: sometimes you want one page to have sidebars and another none, or some pages with sidebars on the left and some with sidebars on the right.  In ComicPress, on the other hand, you can’t do this.  ComicPress comes with several choices of layout, but once you make your choice in the ComicPress admin area, you’re stuck with that layout on every page.

Fortunately, I found that it is actually pretty easy to make different layouts for different pages with ComicPress, if you don’t mind tinkering with the code.  I’ll show you how I did it.

First of all, make sure that you are working with a ComicPress child theme, and do not edit the ComicPress files themselves: if you do, all your changes will be lost when you upgrade ComicPress.

The files that control the layout of the site are called layout-head.php and layout-foot.php.  Copy those two files into your child theme directory: now you can update them and they will override the original files.

Here is the original layout-head.php that comes with ComicPress:

<?php if (comicpress_themeinfo('enable_caps')) { ?><div id="content-wrapper-head"></div><?php } ?>
<div id="content-wrapper">
        <?php if (is_cp_theme_layout('2cr,2cl,3c,3c2l,3c2r')) do_action('comic-area'); ?>
        <?php if (comicpress_themeinfo('enable_caps')) { ?><div id="subcontent-wrapper-head"></div><?php } ?>
        <div id="subcontent-wrapper">
                <?php if (is_cp_theme_layout('2cl,2cvl,3c,3c2l,v3c,v3cl,lgn') && !comicpress_disable_sidebars()) get_sidebar('left'); ?>
                <?php if (is_cp_theme_layout('3c2l,v3cl') && !comicpress_disable_sidebars()) get_sidebar('right'); ?>
                <?php if (is_cp_theme_layout('2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn')) { ?>
                        <div id="section-wrap">
                        <?php do_action('comic-area');?>
                <?php } ?>
                <?php if (is_cp_theme_layout('rgn') && !comicpress_disable_sidebars()) get_sidebar('left'); ?>
                <div id="content" class="narrowcolumn">
                        <?php if (is_active_sidebar('over-blog')) get_sidebar('overblog'); ?>

The section of code that interests us is after <div id="subcontent-wrapper">. You can see that there are short names for each layout option, and the code is full of conditional clauses for each layout. So the code says that all layouts show the left sidebar, unless the sidebars have been disabled. The three-column layouts also show the right sidebar. All layouts show the comic area.

I rewrote the conditional logic, as you can see here:

<?php if (comicpress_themeinfo('enable_caps')) { ?><div id="content-wrapper-head"></div><?php } ?>
<div id="content-wrapper">
        <?php if (is_cp_theme_layout('2cr,2cl,3c,3c2l,3c2r')) do_action('comic-area'); ?>
        <?php if (comicpress_themeinfo('enable_caps')) { ?><div id="subcontent-wrapper-head"></div><?php } ?>
        <div id="subcontent-wrapper">

        <?php
                if (is_page()) { ?>
                        <div id="content" class="narrowcolumn"> <?php ;
                }
                elseif (is_home()) { ?>
                                <div id="content" class="narrowcolumn"> <?php ;
                }
                elseif (is_single()) { ?>
                        <div id="content" class="narrowcolumn"> <?php ;
                }
                else { ?>
                        <div id="content" class="widecolumn"> <?php ;
                }
        ?>
        <?php if (is_cp_theme_layout('2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn')) { ?>
                <?php do_action('comic-area');?>
        <?php } ?>

                <?php if (is_active_sidebar('over-blog')) get_sidebar('overblog'); ?>

Instead of my conditions being based on what layout was chosen in the ComicPress admin options, I wrote conditions based on what kind of page is being rendered, using WordPress’s conditional tags. For pages where I don’t want sidebars, I made a div with class “widecolumn”; for pages where I do want sidebars, the div’s class is “narrowcolumn.”  I moved all references to the sidebars to the footer.

I made very similar changes to layout-foot.php. Here is ComicPress’s code:

                </div>
                <?php if (is_cp_theme_layout('2cvr,2cvl,v3c,v3cr,v3cl,lgn,rgn')) { ?>
                        <?php if (is_cp_theme_layout('lgn') && !comicpress_disable_sidebars()) get_sidebar('right');  ?>
                                <div class="clear"></div>
                        </div>
                        <?php } ?>
                <?php if (is_cp_theme_layout('3c2r,v3cr') && !comicpress_disable_sidebars()) get_sidebar('left'); ?>
                <?php if (is_cp_theme_layout('2cr,2cvr,3c,3c2r,v3c,v3cr,rgn') && !comicpress_disable_sidebars()) get_sidebar('right');  ?>
                <?php if (comicpress_themeinfo('enable_caps')) { ?><div id="subcontent-wrapper-foot"></div><?php } ?>
                <div class="clear"></div>
        </div>
        <div class="clear"></div>
</div>
<?php if (comicpress_themeinfo('enable_caps')) { ?><div id="content-wrapper-foot"></div><?php } ?>

And here is my version:

                </div>

                <?php if (is_page()) get_sidebar('right'); ?>
                <?php if (is_home()) get_sidebar('right'); ?>
                <?php if (is_single()) get_sidebar('right'); ?>

                <?php if (comicpress_themeinfo('enable_caps')) { ?><div id="subcontent-wrapper-foot"></div><?php } ?>
                <div class="clear"></div>
        </div>
        <div class="clear"></div>
</div>
<?php if (comicpress_themeinfo('enable_caps')) { ?><div id="content-wrapper-foot"></div><?php } ?>

Just like in the header layout, I use conditional tags to render the sidebars only on pages where I want sidebars.

This is a simple hack, and enables you to have different layouts on different pages. Conditional tags can work for just about any conditions you can think of, so this is a great way to make your ComicPress theme more flexible.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in code, web design, WordPress | 1 Comment

shell scripting pitfall: string/number conversions

I create quite a few WordPress installs for my partner, Morgan, to develop from, and we have a non-trivial number of changes we implement for each new WordPress install.  I wrote a simple install script that does everything so that Morgan can easily create a new WP install whenever she needs one.

One of the things I do in the script is add a new DNS record to a zone file in BIND and update the named server.  (Tiny bit of a background: DNS updating works by having serial numbers be larger that the previous update’s serial–these serials are typically a 10-digit numeric form of date+version (eg, the serial 2011072602 is July 26th, 2011 (20110726) & the (02) 2nd revision for today).) If my shell script needed to update the serial number which was already changed today, it would need to increment the version, which gets read in as a string.  That isn’t a big deal, as you can easily cast a string to be a number by doing $((variable)).  But it needs to be replaced by a 2-digit version again, so I used awk to make sure it was

ver="02"
echo $ver+1
02+1
echo $((ver+1))
03

That works fine, but what if you’re on the 08th revision for the day?
ver="08"
echo $ver+1
08+1
echo $((ver+1))
08: value too great for base (error token is "08")

Why is that happening?

Well, the shell is trying to be clever: it knows that numbers that start with 0x are going to be in hex, and numbers that start with 1-9 are going to be decimals, and it thinks that numbers that start with 0 are octal (that is, base 8, or 01234567) so it doesn’t know what the heck an ’8′ is (its like trying to add 3+a in decimal–it just doesn’t compute).  To get around this, I need to force my variable “ver” to be numeric without the leading 0.

I use awk’s printf to do this as it seemed like the easiest thing (I really like awk).

ver="08"
ver2=`echo $ver | awk '{printf( "%d", $1 )}'`
echo $((ver2+1))
9

I then have to ensure that I have a 2-digit number to put back together with today’s date to ensure that my serial number is complete.  I again use awk’s printf:
ver3=`echo $((ver2+1)) | awk '{printf( "%02d", $1 )}'`
echo ver3
09

While converting from 08 to 8 to 9 and back to the 2-digit 09 is a little convoluted, being able to do different common base (eg hex, octal) in the shell is handy (after all, Real Men code in the shell, right?).

Feel free to contact me if you’d like a copy of the script.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in awk, linux, shell scripting | 3 Comments

Alchemy: What Medieval Geeks did

I recently ran across a Margaret Atwood quote that epitomizes why we chose to name our company “Alchemy Computer Solutions.”  Several months ago, one of my favorite bloggers, Geoffrey Chaucer (or at least a hilariously temporally vague manifestation of him) interviewed one of my favorite authors, Margaret Atwood.  If you’re feeling up to the diversion of Middle English, the interview is wonderful (as is the rest of the blog).  But what especially caught my attention was a question towards the end of the interview: Chaucer asked Atwood what comes to mind when she hears the word “Alchemy.”  She answered (in Middle English, of course),

1) My recipe for Calla Lilies, a swetemete of great delicacye. 2) What geekes did in late mediaeval tymes.

I love that definition of alchemy: what geeks did in late medieval times.  It resonates particularly well with me, since by day I am a web developer and own a company called Alchemy, and by night I am a medieval historian (in an alternate universe, I’m a medieval history professor; in this universe, I’m very happy as a web developer). Naturally, our interest in history was part of the reason that Jonathan and I chose to name our company “Alchemy Computer Solutions.”

Margaret Atwood is spot-on when she says alchemy is what geeks did.  Of course, defining “geek” is tricky, but here I’m thinking of “geeks” as people who immerse themselves in a topic that others find arcane or tedious, and who devote themselves passionately to learning all they can about that topic.  Alchemists were, of course, seeking a way to turn lead into gold using the famous Philosopher’s Stone, but in the process, what they were really doing was trying to understand how the world works.  They were trying to get to the very roots of what is knowable.  In the eras before computers and comic books, alchemy was a good outlet for the kind of people who feel compelled to learn all that they can about a topic.

One of the reasons we chose the name “Alchemy” for our company is that a lot of what we do seems like magic to those who don’t share our knowledge of computers.  When Jonathan fixes a server or I make a website do something nifty, it seems to our clients like we just worked some magic.  But of course, like alchemy, what we’re doing is really a science.  It might look like hocus-pocus to non-geeks, but we geeks understand the underlying code and processes.

Share:
  • Twitter
  • Facebook
  • StumbleUpon
  • Google Bookmarks
Posted in education, history | Leave a comment
This website uses a Hackadelic PlugIn, Hackadelic Sliding Notes 1.6.5.