Wednesday, June 26, 2013

Notes on the Bluebird Template, Part 2

Welcome back to our discussion of the Blogger.com Bluebird classic template. The Bluebird template very prominently displays the blog title at the top of the page, and that title is as good a place as any to begin our template deconstruction. The blog title is held by an id="Title" div, whose full coding is given below:

#Title { font-size: 43px; padding-left: 0px; padding-top: 10px; text-transform: none; }
#Title a { text-decoration: inherit; color: inherit; }
a:hover { background-color: #c3cfe5; }
...
<div id="Title">
<ItemPage><a href="<$BlogURL$>"></ItemPage>
<$BlogTitle$>
<ItemPage></a></ItemPage>
</div>


The Title div is the fifth-in-source-order div in the template; it is the second child of the main div that frames all of the non-background content. (We will discuss the Title div's previousSibling, the menu div that contains the sidebar on the right side of the template, at a later point.)

The blog title (reptile7's JavaScript blog in my case) is the 'replacement text' for the <$BlogTitle$> reference. The title's font size is set to 43px, which is about 33% larger than that for h1 element text and which gives the title a bolded appearance. A padding-top:10px; style pushes the title down a bit from the top edge of the main div. BTW, the CSS text-transform property's initial value is none and therefore the text-transform:none; declaration can be thrown out.

If the Title div's containing document is for the blog's main page (http://reptile7.blogspot.com/) or for one of the blog's archive pages (e.g., http://reptile7.blogspot.com/2010_01_01_archive.html), then the div's only content will be the blog title. However, if the div's containing document is for one of the blog's individual post pages (e.g., http://reptile7.blogspot.com/2013/05/subtract-other-items-update.html), then the <ItemPage></ItemPage> conditional tags will wrap the blog title in an anchor element with a href attribute set to <$BlogURL$>, whose replacement text is the URL for the blog's main page. Long story short: At an individual post page, the blog title will link to the main page.

Style-wise, our new <a href="<$BlogURL$>"> ... </a> link
(a) inherits the text-decoration of its Title div parent, i.e., it won't be underlined (the initial value of the CSS text-decoration property is also none),
(b) inherits the color of its Title div parent, i.e., it'll be black for almost all users, and
(c) is given a #c3cfe5 background-color if we mouseover it.
I myself like blue and underlined links, and consequently would throw out the #Title a { text-decoration: inherit; color: inherit; } style rule.

A non-database ItemPage

We can easily duplicate the ItemPage functionality with a bit of JavaScript/DOM programming.

var mainpage = location.pathname == "/";
var archivepage = location.pathname.indexOf("archive") != -1;
var itempage = !mainpage && !archivepage;

window.onload = function ( ) {
    var titleDiv = document.getElementById("Title");
    if (itempage) {
        var titleLink = document.createElement("a");
        titleLink.setAttribute("href", "http://myblog.blogspot.com/");
        titleLink.textContent = "Title of My Blog";
        titleDiv.appendChild(titleLink); }
    else titleDiv.textContent = "Title of My Blog"; }


At the blog's main page the location.pathname return is / and at an archive page location.pathname contains archive; by process of elimination, we are at an individual post page if location.pathname is not / and does not contain archive.

If we are at an individual post page, then we
(1) create an empty anchor element,
(2) equip the anchor element with a href attribute that points to the main page's URL,
(3) load the blog title into the anchor element, and finally
(4) load the completed anchor element into the Title div.
If we are at the main page or an archive page, then we simply load the blog title into the Title div.

Of course, you might prefer to ditch the ItemPage/anchor markup and just go with a
<div id="Title">Title of My Blog</div> title, and that would be fair enough.

Blogger tags, take two

In the previous post I stated that the <tagName> ... </tagName> construct is an XML element, but I'm not so sure about that now. On the one hand, the browser sees it as an element node, it serves a descriptive purpose to an extent, and the tagName name is case-sensitive. However, it is clear from this post that <ItemPage></ItemPage> at least is as much a subroutine call - an onIndividualPostPage event handler, if you will - as it is a structural unit. Perhaps we should refer to <tagName> ... </tagName> as a function or operation - these terms are not wholly satisfactory but they're better than "tags", which implies a static structure.

We'll discuss the template's date header in our next installment.

Monday, June 17, 2013

Notes on the Bluebird Template, Part 1

From time to time I get comments on the 'skin' of my technical blog:
I sегiouslу lοvе your website. Eхcellent colоrs & theme. Dіd уou creаte thіs website yοurself? Рlease reply back aѕ I'm trying to create my own personal site and would like to find out where you got this from or exactly what the theme is called. Thank you! Feel free to visit my weblog: nagelpilz
reptile7's JavaScript blog makes use of Blogger.com's "Bluebird" classic template, which was created by Evhead and Glish. I thought it would be worthwhile to take a look at the Bluebird template given that it is no longer available from Blogger.com - as you may know, resurrecting outdated code is a 'theme' of what I do.

Basic structure

The Bluebird template has a simple structure that is based on a set of ten div elements. These divs have id or class names that (for the most part) straightforwardly describe what they contain: a main div frames all non-background content, a Title div holds the blog title, each post sits in a Post div, etc.

The template look

The Bluebird template

The Bluebird template's head element holds a style block that styles the template's body element, the aforementioned div elements, and other body element descendants. The template's characteristic look - its blue-stripe frame - results from the body's background-color:#c3cfe5; and the main div's margin:20px;.

<style type="text/css">
body { margin: 0px 0px 0px 0px; font-family: arial, helvetica; background-color: #c3cfe5; }
#main { margin: 20px; border: 1px solid #000; background-color: #fff; padding: 0px 0px 15px 15px; }
...
</style>


As shades of blue go, #c3cfe5 is a bit dull, but if we pushed the body background to pure blue, then it wouldn't be quite so bluebird-y, would it?

Template tags

Like all of the Blogger.com classic templates, the Bluebird template is littered with what are called "Blogger tags" or "template tags", of which there are two main types:

(1) <tagName> ... </tagName>

Although the author of the aforelinked "Template Tags: defined" article can't be bothered to say so, these "tags" are in fact XML elements. Some of these elements serve as containers for repeating units of content.

(2) <$tagName$>

I don't know what exactly these things are, but I can tell you some things about them. These "tags" are some sort of database-related construct, and they function just like SGML entity references, more specifically, they are replaced by text or markup from a database when a template page is rendered by the browser. (And given their resemblance to SGML entity references, I think it was a bad call on Blogger's part to give them a markup-like appearance - a &tagName; formulation would have been much more appropriate.) Their Node.nodeName return is #text, meaning they are objects that implement the Core DOM's Text interface.

My primary goal in writing about the Bluebird template is to set out the template's HTML and CSS so that a 'Weekend Silicon Warrior' can apply the template to the creation of normal Web pages, and consequently I will keep discussion of the template tags to a minimum (we won't be able to avoid them completely). We'll take up the other highlights of the template in the following post.

Friday, June 7, 2013

What You Are Is Lonely

About three weeks ago I checked out Tegan and Sara's Heartthrob album from my local library. For some reason I had it in my head that Tegan and Sara make 'jangle pop' à la early R.E.M.; corroboratingly, upon downloading the CD track names from the Web, the responding database assigned "Indie Rock" to the iTunes Genre header. Boy, was I in for a surprise! Heartthrob is a modern pop record with a new-wave sensibility; sound-wise, Tegan and Sara have more in common with the Go-Go's or even ᗅᗺᗷᗅ than with the Indigo Girls.

Although somewhat derivative in places, Heartthrob is overall an enjoyable listen. My favorite cut on the album is "Drove Me Wild", and "Goodbye, Goodbye" is almost as good - these songs definitely belong on the radio. I also appreciate the Radiohead-ish artsiness that adorns some of the album's later tracks; it would be great to hear an entire record in the vein of "Now I'm All Messed Up".

Checking the credits, I see that most of Heartthrob was produced by Greg Kurstin. Hope springs eternal that someday Geggy Tah will reunite - Sacred Cow is my favorite record from the 1990s - but I'm not holding my breath on that.

Bronski Beat's The Age of Consent will be our next musical selection.