The Mashup-­by-URL-Templating-and-Embedding Pattern

Let’s now apply Flickr’s URL language to make a simple mashup with Flickr. In this section, I’ll show how to create a simple example of what I call the Mashup-­by-URL-Templating-and-Embedding pattern. Specifically, I connect Flickr archives and a WordPress weblog by virtue of translating URLs; an HTML page takes a given year and month and displays my Flickr photos along with the entries from the weblog for this book ( The mashup works because both the Flickr archives and the entries for the weblog are addressable by year and month. For Flickr, recall the following URL template for the archives:{user-id}/archives/{date-taken-or-posted}/{year}/{month}/{archive-view}

For example:

The weblog has URLs for posts by year and month (if posts from those dates exist):{year}/{month}

For example:

The mashup takes the year and month from the user and loads two iframes corresponding to the Flickr photos and entries for the month by constructing the URLs for the year and month:[33]

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
        <title>Raymond Yee's Flickr and mashupguide weblog</title>
        <script type="text/javascript">
            function reloadFrames() {
                // get a handle to the iframes and the year and month in the form
                var dateForm = document.getElementById('date');
                var flickrFrame = document.getElementById('FlickrFrame');
                var wpFrame = document.getElementById('WPFrame');
                year = dateForm.year.value;
                month = dateForm.month.value;
                var year, month, dateForm;
                var flickrURL = "" + year + "/" + month + "/calendar";
                var wpURL = "" + year + "/" + month + "/";
                //reset the URLs for the iframes
                flickrFrame.src = flickrURL;
                wpFrame.src = wpURL;
                return false;
        <form id="date" action="#" onsubmit="return reloadFrames();"
            Year: <input type="text" size="4" name="year"
            Month: <input type="text" size="4"
                name="month" value="06"/>
            <input type="submit" value="Reload Frames"/>
        <iframe id="FlickrFrame"
            name="Flickr" style="width:600px; height:500px; border: 0px"/>
        <iframe id="WPFrame" src=""
            name="WordPress" style="width:600px; height:500px; border: 0px"/>

This example may seem trivial, even accounting for its intentional simplicity as an illustration, but ask yourself, what if you wanted to add a third source, such as the posts I made to posts for a given month? As you will see later in this chapter, there is no URL corresponding to a listing of the bookmarks uploaded in a given year or month (that is, the human UI to is not addressable by the posting date), so I can’t add to my mashup by adding a corresponding iframe and URI template. Addressability of resources is what makes the Mashup-­by-URL-Templating-and-Embedding pattern possible.


You can use to get a list of the number of posts for a date and then use to retrieve them. You can configure to send your daily postings to your blog ({user-id}/blogging/posting).

Granular URI addressability, the ability to refer to resources through a URI in very specific terms, enables simple mashups. This is especially true if the parameters in the URI templates are ones that have the same meaning across many web sites. Such identifiers are often the point of commonality between URIs from different sites. You have seen a number of such identifiers already:

These identifiers contrast with application-­specific identifiers (such as NSIDs of Flickr users and groups). Somewhere between widely used identifiers and those that are confined to one application only are objects such as tags, which may or may not have meaning beyond the originating web site. I’ll return to this issue in Chapter 3.