Martin Ström
my-domain.se

100% height CSS for IE7 and more

I needed an element with a background to be 100% height and the usual solutions didn’t seem to work for this project. The problem with the other solutions around the web is that they either work when the page is short and without scrollbars, or they just work for longer page (with scrollbar).

A friend reminded me to set the element to display: table;, but said it might now work for IE7. He was right and here’s how to make it work for everyone.

The element I want full height for is .document and the base structure for the html is:

The CSS which works is:


Prototypish Style Sheet Switcher

This is a Prototypish rewrite of Paul Sowdens Style Sheet Switcher. The original version has a lot of global functions so I put everything into a class instead and made the code a bit more elegant. It should work as the normal one except for some methods have been renamed.

A cookie library is included as well since the switcher needs to read and create cookies to save the users preferred style sheet.

Update

I fixed a bug for pages without any alternate style sheets and updated the script to version 0.2.

Download


Colhour WordPress plugin

Colhour Plugin This is a plugin for WordPress. The Plugin makes it easy to have elements on your site in colors generated by the Colhour system. Basically it will let you input CSS rules from a option page in the WordPress Admin, and when the site is viewed later it will have the colors replaced by an ever updating Colhour-color.

There are a couple of input fields on the options page; one for each “length” of the spectrum (for it to start over again). I.e., if you want a div element with the id “header” to get its background colorized from Colhour and its Colhour cycle starting over every day (after 24 hours), you just enter the CSS rules in the “day” input field. The actual color-value should be replaced with `%colhour%´ so the plugin can insert the current color in its place. 

colhour-plugin2.png

I suggest not having any other CSS rules in the Colhour admin than the ones dealing with the colors you want replaced. I.e., strip out the fonts, border sizes etc and keep all that in your .css file where they belong (and can be cached).

Bad:

#myDiv {
    font: 1.1em Courier; 
    padding: 2em;
    background: #DDD url(my-background.png) no-repeat top left;
    border: 2px dotted %colhour%;
}

Good: 

#myDiv {border-color: %colhour%;}

Download here, put it in your wp-themes/plugins/colhour.php (note the .php extension) folder and activate it as usual in WordPress admin » Plugins. The options can be found under Options » Colhour.

Update May 4, 2006 I’ve updated the plugin with some minor tweaks and UI enhancement. Also, this site is now using the plugin to style the links.

WordPress theme

Finally this site looks like something other than the default WordPress theme. Peter and I wanted to connect our work sites to each other and decided to use his simple but easy-to-use WordPress theme as a base.

The problem was that his theme never was cross browser compatible and worked more or less only in Safari. My first task was to re-code the theme from scratch to make it work in all modern browsers using valid XHTML and CSS with as clean and simple code as possible.

I also set all font sizes using em:s (instead of px or pt) to make the text resizable. It wasn’t too hard making it work (even in Microsoft Internet Explorer) thanks to some great resources. Sooner or later I’ll convert the positions, margins etc to em:s as well, but font sizes should be enough for now.

I also added AJAX comments and used effects from script.aculo.us. I’m using Prototype to add CSS classes to some elements and to wrap i.e. all <h3>‘s content in a <span> to achieve the look I wanted without any unnecessary markup. Since <input type="search" /> only is supported by Safari and I wanted to use it, I used a script (thanks Wolfgang Bartelme) that replaces the regular text input field with a search field for Safari only. This way the document will stay valid XHTML 1.1.

Next task was to make the theme more personal for my site. I’ve tried some different looks but couldn’t really decide how I wanted it and choose (for now at least) a slightly darker version of Peter’s theme. I think it looks good and is easy to use without making too much noise.

When I implanted the tagging I first looked at Ultimate Tag Warrior 3 but it seemed too advanced for my needs, so I decided to use the native category system in WordPress 2.0, that lets one add tags (categories) by just entering them in separated by comma in a text field (WP 1.x didn’t have this feature). The tag cloud is a modified and simplified version of Tag Cloud Plugin.

Download

Update April 20, 2006 The theme is now released in a beta version. Some notes: * You’ll need the [Post Updated Plugin](http://guff.szub.net/2005/02/22/post-updated) to get a page’s last modified date. * My “lite” version of the [TagCloud plugin][tagcloud] can be [downloaded here][tagcloudlite]. * You’ll problably want to change the `autosave` attributes value in `javascripts/global.js` (line #24) to your own unique id. [Read more on the attribute](http://weblogs.mozillazine.org/hyatt/archives/2004_07.html#005890). I also found this great plugin for the admin area, [Cat2Tag](http://www.agkamai.org/cat2tag) The link seems to be broken, get it download it here for now for easier tagging of your content without using a separete database like [Ultimate Tag Warrior 3][utw] does. Cat2Tag just use WordPress’ own categories instead. [Download](http://my-domain.se/wordpress/wp-content/uploads/burnfield-dark.zip).
Update May 4, 2006 The [TagCloud plugin][tagcloudlite] is updated to use the [rel-tag](http://microformats.org/wiki/rel-tag) [microformat](http://microformats.org/about).
Update August 18, 2007 Since a lot of people ask me how to get the thumbnails to work, here is the instructions I usually email them:

— ✄ ——————

First, download a newer version of `posts-thumbnail.php` replace the current one (from the downloaded .zip file) with this one attached in this message. Create the thumbnail image and name it “thumb-POST_SLUG.png”. The post slug is shown on the “edit post” screen in the admin (i.e my latest post with title “Rails’ time extensions ported to JavaScript” has post slug “rails-time-extensions-ported-to-javascript” and the thumbnail should therefore be named “thumb-rails-time-extensions-ported-to-javascript.png”). Then just upload the image from the same screen using WordPress’ built-in uploader (you dont have to give it any description or title). Then the theme should automatically find the image for you and show it in the list view.

———— ✄ ——

Btw is a new version of this theme under development and will make the thumbnail handling easier.
Update October 31, 2007 The link to the plugin “Cat2Tag” seems to be down (thanks Kris Aubuchon) so, for now at least, you can download it here. I haven’t really looked into the new tagging system in WP 2.3 so perhaps this plugin isn’t necessary any more.

Pluxemburg

pluxemburg-site.png

Pluxemburg is a record label I’m co-running with some friends. The site in its current form is almost two years old, but a lot of things have changed since it was first released. Since I just released some updates, I thought I’d write something about them and show how the CMS/administrative interface works.

Recent site updates

I won’t go through the whole site and tell you everything about it. Instead, go browse it by yourself. The shop has been improved with a smarter cart that doesn’t forget your items if you by accident reload your browser or hit the back button. Validation is more clear and better looking in the same style as the improved (and AJAX powered) guestbook and newsletter subscription.

Browser support

When the site launched almost two years ago, it fully supported Internet Explorer 5 (Mac), IE 5, 5.5 and 6 on PC and of course, old and new Firefox versions, Mozilla, Safari etc etc. It was a pain to fix the CSS especially for IE Mac and IE5, IE5.5 on Windows. Currently, I’ve dropped support for MacIE (it’is not even supported by Microsoft any more), IE5 and IE5.5 for Windows. I think the site should work more or less using outdated browsers, but it might not look exacly as intended.

CMS and site admin

The site is powered by an advanced CMS that helps us adding and editing news, products in the shop, guestbook spam and a lot of other things. When I first wrote it for this site, I had in mind to keep it so general I could, so it could be extended and used in other projects. Of course the administrative interface is password protected, but I’ve recorded two movies showing some parts of it. I’ll convert the movies to H.264 right after this is posted, so for now, the movies are pretty large in size. The movies are now in H.264 format and are 75% smaller (before: total 44.8 MB, now: 11.6 MB)

The first movie, shows a basic task such as adding some news items to specific part of the site and then view it. Pretty basic.

Watch the first movie (QuickTime 7, 20.9 3.1 MB)

The second show how easy it is to manage products in the shop, as well as track orders.

Watch the second movie (QuickTime 7, 23.9 8.5 MB)

To download them, hold the ⌥ (alt) key down and click the link or right click and choose “Download Linked File”

You’ll need QuickTime 7 to watch them.


Marie Frans

Website and CMS for swedish photographer’s agency I made together with Peter. We also did their graphic identity.

The frontend is optimized to be a fast, simple but effective way of browsing the photographers and their photos, check it out. The CMS makes it easy for the photographers to upload, edit and organize their photos and for the site editors to write news and edit information on the site. It’s a customized version of the administrative interface I coded for pluxemburg.com with added functionality such as image uploading and photo organization. I wanted to let the server handle the image resizing and creation of thumbnails as well, but found out that PHP’s image functions didn’t do as good work as expected. I tried all kind of different techniques but we ended up using Photoshop and manually make the thumbnails. Photoshop does a way better job and with this kind of client (working with photographs) we wanted as good quality as possible.

I’ve made a movie (QuickTime, 4.9 MB) showing how the admin interface works when uploading and reordering the photos, since it’s password protected. You’ll need QuickTime 7 to watch it.

Update 2006-03-13

Since the agency and the site was shut down some weeks ago, I’ve put up some screen shots to show how it was done. I might record a movie and/or a mirrored version for reference.

Index

mf-index.png

Photographers

mf-photographers.png

Photos

mf-photos.png

Loading a photo

mf-loading.png

Showing a photo

mf-show.png

Information

mf-info.png


Konst & Teknik site

Konst & Teknik website

My friends over at Konst & Teknik asked me to code their web site. It’s only one page, that should show the results from Google Image searches for the word in their name, “konst” and “teknik” (“art” and “technology” in swedish). I liked the idea and also got the opportunity to do some ruby scripting and try the Prototype JavaScript library.

Server side

Since Google currently doesn’t offer any API to do other searches than pure web searches and we wanted to use Google Image Search, I had to do my own image fetching script. The script is a ruby script that will pull the images and info from Google Images and store them in a local index file. First, I used Net::HTTP but I found out that it had problem dealing with the swedish characters (used in swedish, ie åäö) so I changed the URL-fetching to use curl instead, witch also was slightly faster. The index is written from ruby using Marshal. It is scheduled to run twice a week using cron.

Client side

My first approach was to make one class that downloads and shows the image for the given keyword. Then create one instance for each word (konst and teknik), controlling the preloading and image-switching every 4th second (meaning; updating one of the images every second second). But I found out it was hard to make the updates smooth and exacly on time.

Instead I split the client side script into of two main classes, the Preloader class and the Switcher class. The Preloader triggers a request using AJAX to a server side ruby script that will return a new random image from the image index and then stores the info received from the server in a local array. After some delay the script will start over again with a new request for another image. When the Preloader is done indexing some images then the Switcher will kick in and start showing them and switch every other second between the images for each word as long as there are images preloaded and ready to be shown. If the Preloader is out of preloaded images then the Switcher will pause and show a loader while the Preloader’s buffering. We wanted the images to be vertical aligned by bottom but I couldn’t make it work with CSS only (nor with vertical-align, float or position). Instead, the script is switching between two <div>s (for each word, totally four divs) and when the “not active” div got a new image loaded into it, it will find its dimensions and set its margins automatically. The next time it’s time to switch image (for this word) this div will be shown instead, the other one becomes invisible and get the next image loaded.

The script should work fine in Safari, Firefox, Camino etc (even WinIE6). It needs some code cleaning (mostly OO-issues; currently I’m referencing the instances from the class, which I think is a bit ugly) but I’m releasing it anyway.

Check it out http://www.konst-teknik.se


CSS is in progress