magpiebrain

Sam Newman's site, a Consultant at ThoughtWorks

Archive for ‘April, 2004’

As I “mentioned before(Generate footnotes for printing)”:http://www.magpiebrain.com/archives/000231.html, I recently wrote some Javascript code to produce a more printable version of my pages. Since then I’ve updated the code a little, added a link to each page and refined my printing CSS. The Javascript code handles two tasks – firstly it extracts selected links and creates a footnote for each one. Secondly, it extracts any print stylesheets and displays them in the browser so you can get a better idea of how the printout will work. A couple of niggles still remain – I cannot skip links in blocks which use @id@ rather than @class@, and the markup for the footnotes is horrible. Once I’ve cleaned the code up and fixed the last few remaining issues I’ll post a proper writeup soon.

Now that the code is properly integrated in the new design, I though I’d ask for some feedback.(the ‘Print this page’ link can be found in the top-right hand corner) – you don’t actually have to print, just click the link and see how it looks. I’m especially keen to hear from people with browsers other than Firefox and IE.

I’m using the “MTOutliner(MTOutliner Plugin for Movable Type)”:http://www.cxliv.org/jayseae/movable_type/outliner/ plugin to extract some of my “bloglines”:http://www.bloglines.com/ subscriptions in order to create my blogroll. MTOutliner is capable of loading and parsing an OPML file, and actually provides a special tag to load the OPML file from a named bloglines user:


Today however this seemed to fail – no information was being returned (and no error was generated by the plugin either). I tried referencing the OPML file directly, which seemed to fix the issue:


Which fixed it. I can only theorise that bloglines changed where the OPML files were located. Anyway, everything’s working now.

As you may of noticed, I’ve been having some problems with the “@overflow@(w3c – Overflow and clipping)”:http://www.w3.org/TR/REC-CSS2/visufx.html#overflow-clipping property and IE. Simply put, @overflow@ should define how content outside the displayable area is handled. Using the @auto@ value should display scrollbars when required – and this works perfectly on Mozilla. On IE however I couldn’t get it to work at all.

The problem is seems is that IE isn’t bright enough to work out the width of the on screen element – if I give my @pre@ blocks a width (which I can now do with a fixed-width layout) it correctly displays horizontal scrollbars and stops playing havoc with my layout. Its not all plain sailing however – when it adds the horizontal scrollbar, it doesn’t correctly resize the @pre@, and therefore also displays vertical scrollbars! Oh well, such is life…

OK, I finally got around to the redesign this weekend, and its gone fairly well. I’ve moved from a liquid to a fixed layout, as the site was almost unreadable on high resolution monitors and many of the design changes I wanted to make become overly complex. One downside to moving to a fixed-width layout occurs with preformatted blocks of text. @

I sent some experimental code live today which I’ve been working on a little over the last couple of days. Now visible on the individual entry pages is a ‘Printable Version’ link that can be seen on the bottom left of the post’s content, which when clicked extracts (nearly) all links and creates a series of footnotes with the URL’s displayed. It also extracts any printing stylesheets and displays them so you get a better idea as to how it will print. Hopefully this technique will make printing from sites with many hyperlinks more useful.

The code is completely written in Javascript, and I hope to publish a full writeup on how it works in the next few days. The idea was inspired by an “IE-only bookmarklet”:http://www.kokogiak.com/gedankengang/default.asp#12012200393, although it has been completely rewritten to be supported in more browsers. In the meantime I’d appreciate it if you could let me know of any problems with the technique, especially if there are any problems with Safari or Opera (neither of which I have to hand right now). Known problems include:

* Some links probably shouldn’t be extracted as footnotes – for example the next/last post controls. I am filtering some out already so thats an easy fix.
* No effort has gone into styling the footnote section
* the printing stylesheet is quite primitive – it hides the side menu for example by doesn’t expand the main column to take advantage of the extra space which is available.
* It seems to break the automatic citation links for block quotes, although I have a good idea as to what’s causing that
* The location of the ‘printable version’ is a little out of the way – my aim is that when the code is finished the ‘printable version’ will be available on every page.
* The only way to get back to the non-printable version is using the back button.
* I need to see if there is some proper semantic markup to be used for footnotes

Whilst the technique is being used here for printing, it can easily be applied just to fit in with a site’s editorial style.

_Update_ 1: Oh, and I’ve just noticed the Javascript is stopping the document from validating as (X)HTML Transitional…

_Update_ 2: Also if the text for a link contained other HTML elements, the text is being displayed unformatted – again this is a fairly easy fix.

_Update_ 3: Priting broke when I uploaded the new design, so I’ve taken it off line for the moment until the issues are resolved.

“Jon(Page 23)”:http://www.hicksdesign.co.uk/journal/2004/04/page_23/ told me to:

# Grab the nearest book.
# Open the book to page 23.
# Find the fifth sentence.
# Post the text of the sentence in your journal along with these instructions.

From “Guns, Germs and Steel(Amazon.co.uk – Guns, Germs and Steel – A Short History of Everbody for the Last 13000 Years )”:http://www.amazon.co.uk/exec/obidos/ASIN/0099302780/ref=sr_aps_books_1_1/202-6617646-4629454 by Jared Diamond:

None of the crucial developments preceding political centralization in those same parts of the world were associated with river valleys or with complex irrigation systems

I try and avoid bandwagon jumping (I’m not saying I don’t do it, just that I try and avoid it – I tend to fall off a lot). However, Amazon’s “A9”:http://www.a9.com/ search service has certainly caught my eye. Using Google’s search results, it also adds a few handy features:

* Integrates with their book search (results shown side-by-side with Google results)
* It remembers your past searches
* Supports a Diary feature – add notes associated with a webpage, and when you visit that page again retrieve your notes. Currently this is only supported on the IE toolbar
* Very nice search shortcut – simply type @a9.com/query@ to trigger a search

The Diary feature looks especially nice – its just a shame that there isn’t a Firefox toolbar yet. Steven Garrity has “created a plugin(A9 Search Plugin for Firefox)”:http://www.actsofvolition.com/archives/2004/april/a9searchplugin to allow the use of an A9 search from the Firebox search box though.

“Charles Miller”:http://fishbowl.pastiche.org/ has posted up on the Javablogs confluence wiki some information on “including Javablogs generated statistics graphs”:http://confluence.atlassian.com/display/JAVABLOGS/Including+Javablogs+Statistics+Graphs+on+Your+Blog on your site. The example HTML mixes the semantics of the markup with the presentation logic:

Entries Added

There are several issues with this markup. Firstly, there is a @

@ with no purpose other than to center our image. Secondly it uses a font @@ tag to create a title. Finally it uses the @border@ attribute on the image. All of these aspects are presentation logic, and as such should really be moved into CSS. The benifits of seperating presentation from content using proper semantic markup and CSS are many and varied, and I won’t go into them in depth here, suffice to say that if you’re intersted in the topic, grab a copy of Jeffrey ZeldmanÂ’s “Designing With Web Standards”:http://www.zeldman.com/dwws/, or checkout any of these sites:

* “A List Apart”:http://www.alistapart.com/
* “Mezzoblue”:http://www.mezzoblue.com/
* “The Daily Report”:http://www.zeldman.com/

Not being the one to point out the flaw and offer no better alternatives, I went about producing some nice compliant markup. Firstly, I started with the HTML itself:

Entries to Javablogs over time

Entries to Javablogs over time

Hits from Javablogs this week

Hits from Javablogs this week

Gone are the @@ tags, the @border=@ attribute, the useless @

@ tag. On its own, this looks pretty uninspiring. For a start, by putting the graphs in a @div@ they appear below each other. This is easily fixed with a bit of css:

.graph {
  float: left;
  margin-left: 30px;
}

The @margin-left@ gives a bit of a gap between the two graphs which now sit next to each other. This can introduce another problem however – any @div@ following the @graph@ will also appear on the same line – in my case my related entries @div@ was at fault – this was fixed using @clear@:

.related {
  clear:both;
}

Next, we want our graphs to be centred:

.graph img {
  text-align: center;
}

And finally format our caption:

.graph .caption {
  text-align: right;
  text-style: italic;
  font-size: 90%;
}

Net result? The HTML is smaller, and yet more meaningful – the presentation is entirely within CSS meaning we can easily use the same styles elsewhere, and we can also change styles quickly (and even have different styles for specific users). You can now see the end result on my “Site Statistics”:http://www.magpiebrain.com/archives/000227.html page.

Over at Daring Fireball John Gruber has taken the notion of user specific settings and has “created a preferences page”:http://daringfireball.net/2004/04/preferences for his site. John isn’t using the standard style-switcher approach as outlined in Daniel Ludwin’s “A Backward Compatible Style Switcher” for “A List Apart”:http://www.alistapart.com/, and has instead opted for a an on-the-fly generated style-sheet, but the end result is the same. Daring Fireball allows the user to not only change the font size, but also to toggle the visibility of referrers. “Simple Bits”:http://www.simplebits.com/ uses an approach similar to Daniel Ludwin’s to change the colour scheme of the site, this time using three simple toolbar icons.

I have often worried about all the things I could do with this site, but have wanted to avoid visual bloat. It’s for this reason that I’ve avoiding putting ‘edit’ links next to my posts as a convenience for myself, and why the ‘Related Entries’ only get displayed on the individual entry pages. Now I’ve seen Daring Fireball’s admittedly simple options in action it has inspired me to have a play around with user specific preferences – expect a user configurable magpiebrain soon.