Cast for two

Sunday, July 29, 2007

How to include a HTML page into blogger posts ? (final)

I already undertook three attemps (attempt 1, attempt 2 and attempt 3) to include a Google Sheet into a blogger post without much succes. I almost surrendered but I got a new idea. I started from the proposal I found in "Insert HTML page into another HTML page" that basically proposed the following code:

<!--[if IE]>
   <object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="some.html">
      <p>backup content</p>
   </object>
<![endif]-->
<!--[if !IE]> <-->
   <object type="text/html" data="some.html">
      <p>backup content</p>
   </object>
<!--> <![endif]-->

The above code is very good for direct inclusion into a HTML page, but Blogger filters out the conditionals for selecting the code based upon the user agent. So it's not the solution we're seeking for. But then I got another idea. Maybe I could insert the above code using Javascript that IS allowed to be inserted in Bloggers HTML. In that way, it's possible to circumvent the restriction in Blogger HTML. I pasted the code into a HTMl-to-Javascript convertor. This gave me:

<script language="JavaScript" type="text/javascript">
<!--
function writeJS(){
var url = 'http://spreadsheets.google.com/pub?key=pzcvT0aLrnhuxklkh_C8AVA&output=html&gid=0&single=true&widget=true';

var str='';
str+='<!--[if IE]>';
str+='<object classid="clsid:25336920-03F9-11CF-8FD0-00AA00686F13" data="'+url+'">';
str+='<p>backup content<\/p>';
str+='<\/object>';
str+='<![endif]-->';
str+=' <!--[if !IE]> <-->';
str+='<object type="text\/html" data="'+url+'">';
str+='<p>backup content<\/p>';
str+='<\/object>';
str+='<!--> <![endif]-->';
document.write(str);
}
writeJS();
//-->
</script>


that renders as:

Above code reders nicely in Firefox and Safari but not in Interet Explorer 6.
Therefore I changed the code such that in IE an iframe is displayed and otherwise an object. The code was put into javascript:

<script language="javaScript" type="text/javascript"    src="http://lode.nachtergaele.googlepages.com/includeHTML3.js">
</script>


and on IE6 it renders to:


So finally, we start to view some light:


  1. First, include into blogger a Javascript:

    <script language="JavaScript" src="http://lode.nachtergaele.googlepages.com/includeHTML3.js" type="text/javascript" ></script>

  2. Put in the Javascript file the following Javascript code:

    <!--
    function writeJS(){
    var str='';
    str+='<!--[if IE]>';
    str+=' <iframe src="http://spreadsheets.google.com/pub?key=pzcvT0aLrnhuxklkh_C8AVA&output=html&gid=0&single=true&widget=true" width='550' height='370' frameborder='0'>';
    str+='<p>backup content</p>';
    str+='</iframe>';
    str+='<![endif]-->';
    str+='<!--[if !IE]> <-->';
    str+=' <object type="text/html" data="http://spreadsheets.google.com/pub?key=pzcvT0aLrnhuxklkh_C8AVA&output=html&gid=0&single=true&widget=true" width='550' height='370' frameborder='0'>';
    str+=' <p>backup content</p>';
    str+=' </object>';
    str+='<!--> <![endif]-->';
    document.write(str);
    }
    writeJS();
    //-->
  3. Alternatively, Javascript can detect the user agent as well. This leads to the following code:

    <!--
    function writeJS(){
    var str='';
    if (navigator.appName.indexOf("Microsoft") != -1) {
       str+=" <iframe       src='http://spreadsheets.google.com/pub?key=pzcvT0aLrnhuxklkh_C8AVA&output=html&gid=0&single=true&widget=true'       width='550' height='370' frameborder='0'>";
       str+='<p>backup content</p>';
       str+='</iframe>';
    } else {
       str+=" <object type='text/html'       data='http://spreadsheets.google.com/pub?key=pzcvT0aLrnhuxklkh_C8AVA&output=html&gid=0&single=true&widget=true'       width='550' height='370' frameborder='0'>";
       str+=' <p>backup content</p>';
       str+=' </object>';
    }
    document.write(str);
    }
    writeJS();
    //-->

  4. And that wil do the trick. The Javascript code generates HTML code that includes an Iframe if viewed by Internet Explorer and an object for other browsers. I agree that this is maybe a big detour just to able to include an object. And hopefully it shows up in the feed readers....


In 50 ways to include HTML into a Blogger post an overview is given of all kinds of techniques and can be used for testing.

How to (not?) include a HTML page into blogger posts ? (continued 2)

Much to my despair, I noticed the Google Spreadsheet included in a blog post of this blog does not render nicely (even after some digging into the issue, see post1 and post2) in Microsoft Internet Explorer 6 and 7:
While reading Make Magazine in Google Reader, I noticed that the Youtube movie of post "Thomas Edsison hates cats" was coming trough nicely. I looked up the HTML code in the RSS feed and adapted the code I found for displaying inline HTML code. It boils down to something like this:

<![CDATA[<p>
<object data="URL to HTML page" type="text/html" width="520" height="350">
<embed src="URL to HTML page" type="text/html" width="520" height="350"></embed>
</object></p>
<p>Title of HTML Page <a href="URL to HTML page">Link</a></p>]]>

Unfortunatly, Blogger does not accept the <![CDATA[. It reports "tag is broken". I removed the CDATA:

<p>
<object data="URL to HTML page" type="text/html" width="520" height="350">
<embed src="URL to HTML page" type="text/html" width="520" height="350"></embed>
</object></p>
<p>Title of HTML Page <a href="URL to HTML page">Link</a></p>


which renders to (with URL of the Google Spreadsheet):





Blog of colleagues Juli 2007 Link


which renders on Microsoft Internet Exporer 6 as:

Bummer. The object does not display nicely. Ok, lets see what Google Reader makes from it:

Archhh. This is even worse. It must have been the CDATA. Why is Blogger not accepting that I put CDATA into a blogpost. Give me full control of the HTML in the feed please !
Or maybe, as a last resort conflicting with my open standards first DNA, I could try this (as a kind of revance ;-)): export the Google Sheet to Microsoft Excel and include the Excel sheet with MIME type : application/vnd.ms-excel
The code would be like this:

<p>
<object data="URL to HTML page" type="application/vnd.ms-excel" width="520" height="350">
<embed src="URL to HTML page" type="application/vnd.ms-excel" width="520" height="350"></embed>
</object></p>
<p>Title of HTML Page <a href="URL to HTML page">Link</a></p>

which causes Firefox 2.0.5 on OSX to pop up this dialogue:

Ok, I surrender. Maybe the Iframe code Google Sheets proposes it not that bad at all. If any body has a better idea, please let me know.

Saturday, July 28, 2007

Iphone not in Belgium ?


The Register reports "Only 'major' EU countries to be in second iPhone rollout". Since our small Belgian country is anything but major (at least in terms op potential revenues from Apple products), I guess we will have to have some extra patience. Damn.

Pingo : a disguised cheater ?


Our sysadmin mascotte Pingo was moved to the list of cheaters. Some people probably got a bit to enthousiastic. You can still vote for it:

Friday, July 27, 2007

How to include a HTML page into blogger posts ? (continued)

In How to include a HTML page into blogger posts ? I explored using the more general object tag to include an external page of HTML into a blogger post. You would for example want to do this when discussing a published Google Document Sheet. When checking the appearence of the post in the RSS reader Google Reader, I noticed that the alternate text showed up:

This brought me to an idea for an improvement. I took a screenshot of the Google Sheet as displayed in my browser and loaded up the picture to the blog post. Next I moved the blurb of code for the picture:

<a onblur="try {parent.deselectBloggerImageGracefully();}catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6fFWgw_EHUdXJ9ez9cL69nHhZWKtx-fGWF_glB7NmFob_7n_2G5KcUPFtB8iBBv1v30grM3GWevFiTlQo7jTnNgS1YUm2upPmP14c6fq3WHpLm8BSwIRsFl5fEZhR_BBqSGXpw/s1600-h/Screenshot_5.png">
<img style="display:block; margin:0px auto 10px;
text-align:center;cursor:pointer; cursor:hand;"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6fFWgw_EHUdXJ9ez9cL69nHhZWKtx-fGWF_glB7NmFob_7n_2G5KcUPFtB8iBBv1v30grM3GWevFiTlQo7jTnNgS1YUm2upPmP14c6fq3WHpLm8BSwIRsFl5fEZhR_BBqSGXpw/s400/Screenshot_5.png"
border="0" alt=""id="BLOGGER_PHOTO_ID_5091774679559246658" /></a>

into to object tag enclosure:

<object data="URL to HTML page" type="text/html" width="520" height="350">

<a onblur="try {parent.deselectBloggerImageGracefully();}
catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6fFWgw_EHUdXJ9ez9cL69nHhZWKtx-fGWF_glB7NmFob_7n_2G5KcUPFtB8iBBv1v30grM3GWevFiTlQo7jTnNgS1YUm2upPmP14c6fq3WHpLm8BSwIRsFl5fEZhR_BBqSGXpw/s1600-h/Screenshot_5.png">
<img style="display:block; margin:0px auto 10px;
text-align:center;cursor:pointer; cursor:hand;"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6fFWgw_EHUdXJ9ez9cL69nHhZWKtx-fGWF_glB7NmFob_7n_2G5KcUPFtB8iBBv1v30grM3GWevFiTlQo7jTnNgS1YUm2upPmP14c6fq3WHpLm8BSwIRsFl5fEZhR_BBqSGXpw/s400/Screenshot_5.png"
border="0" alt=""id="BLOGGER_PHOTO_ID_5091774679559246658" /></a>

</object>

The result is that in Google Reader a picure of the Google sheet shows up:

If you want that the browser is directed to the published HTML page of the Google Sheet when clicking on the picture of the sheet, you can change the URL of the href of the pciture:

<object data="URL to HTML page" type="text/html" width="520" height="350">

<a onblur="try {parent.deselectBloggerImageGracefully();}
catch(e) {}" href="URL to HTML page">
<img style="display:block; margin:0px auto 10px;
text-align:center;cursor:pointer; cursor:hand;"
src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEis6fFWgw_EHUdXJ9ez9cL69nHhZWKtx-fGWF_glB7NmFob_7n_2G5KcUPFtB8iBBv1v30grM3GWevFiTlQo7jTnNgS1YUm2upPmP14c6fq3WHpLm8BSwIRsFl5fEZhR_BBqSGXpw/s400/Screenshot_5.png"
border="0" alt=""id="BLOGGER_PHOTO_ID_5091774679559246658" /></a>

</object>


Of cource, you can also copy and past the HTML code directly into the blog post. Then you get this:
URLEst. ValuePage RankWebsite GraderTechnorati AuthorityTechnorati Rank

http://peterdecroubele.be205945237167,118

http://www.koenfillet.be$1910477--

http://www.werner.be94944928226,753

http://koenfillet.blogspot.com/44547756103,461

http://www.braincubes.be/23421241,367,488

http://castfortwo.blogspot.com/823668779,588

http://www.patdonnez.be/log/index.php80313--

http://detender.wordpress.com/5046310638,771

http://joro.wordpress.com/4224122,505,981

http://217.19.231.156/apps/blog_david/40259--

http://mertenswouter.com/blog/11050--

http://stielo.blogspot.com/206213,900,217

http://hetruimesop.blogspot.com/0043-7,931,033

http://jeroenvanaert.blogspot.com/0043-7,931,033

http://myjumps.blogspot.com/0042-7,931,033


which is not that bad. Only something with the first row went wrong.
A bit fiddling with the HTML code allows to obtain this:

URLEst. ValuePage RankWebsite GraderTechnorati AuthorityTechnorati Rank
http://peterdecroubele.be205945237167,118
http://www.koenfillet.be$1910477--
http://www.werner.be94944928226,753
http://koenfillet.blogspot.com/44547756103,461
http://www.braincubes.be/23421241,367,488
http://castfortwo.blogspot.com/823668779,588
http://www.patdonnez.be/log/index.php80313--
http://detender.wordpress.com/5046310638,771
http://joro.wordpress.com/4224122,505,981
http://217.19.231.156/apps/blog_david/40259--
http://mertenswouter.com/blog/11050 - -
http://stielo.blogspot.com/206213,900,217
http://hetruimesop.blogspot.com/0043-7,931,033
http://jeroenvanaert.blogspot.com/0043-7,931,033
http://myjumps.blogspot.com/0042-7,931,033


Every table row contained a bogus
<td class="rAll"> </td>
that I just deleted.

Show some love for Pingo today

Today is Sys admin day. If you want to vote for VRT's sysadmin, go to http://www.sysadmindag.nl/
and vote for our pingo:

Thursday, July 26, 2007

How to include a HTML page into blogger posts ?

In the previous post, I included HTML code generated from a published Google Sheet. To do so, I first used the code proposed when publishing a Google Document and selecting Blogger as target.

This is basically the HTML code Google proposes to post into the HTML code of post on Blogger:


<iframe src="URL to HTML page" frameborder="0" height="350" width="520">
</iframe>

This works when viewing the blog post in a browser, but when reading the post with a feed reader, the HTML iframe is sometimes ommitted. Recently, I read an interesting article "The object tag - embed content in valid strict HTML -" arguing for the use of the HTML object tag as follows:

<object data="URL to HTML page" type="text/html" width="520" height="350">
alt : <a href="URL to HTML page">alternate text</a>
</object>

The advantage of using the object tag is that the HTML object (the Googele sheet) appears when reading the blog post inline with netvibes:

In Google Reader, the alternate text appears (in this case the URL to the HTML of the document):

In iGoogle, it is even worse. There even the alternate text does not appear:

The above picture displays the Atom feed from Google (http://castfortwo.blogspot.com/feeds/posts/default) and the feed from feedburner (http://feeds.feedburner.com/cast42).

Conclusion is that even using the object tag is no ideal solution to include an exteral HTML page into a blog post. But if you opt to do it, the use of the object tag may be preferred instead of using an Iframe. In case you would know a better solution, do not hesitate to add a comment.

Tuesday, July 24, 2007

How are the blogs of the colleagues doing ?





In the above Google spreadsheet, I compared how the blog's of my colleques at the VRT are doing. At least those are the blogs I'm aware of. Of course its comparing apples with oranges because several blogs have different aims. The point of this post is more about the method. The first column list the URL's. The second column lists the estimated value of the blogs calculated by SmartPageRank (Remarkt that the performance of this webservice is flaky. Sometimes it returns errors or incorrect results). I also tried DNScoop but the service values my blog at $1,320,066 , probably only a small measurement error ;). The third column lists the Google Pagerank obtainted by the Pagerank Checker of Peter Forret ( a number between 0 and 10, higher is better). The fourth column reports the website grade calculated by the website grader (a number between 0 and 100, the higher the better). The last two columns list the Technorati rank (lower is better) and authority (higher is better) I checked with Xinu Returns.

Friday, July 20, 2007

New Youtube features allows for custom player

Using a new feature by Youtube, you can customize the player. Here is what I get from youtube.com/custom_player:

Hover your mouse in the bottom of the video playing field while the video is playing and all video's stored in my favourites show up in cover flow style. Cool ! I don't get what the button with three dots next to the play button is supposed to do. Weird.

Thursday, July 19, 2007

Calculating the length of Google Maps line segments

A few days ago, I decided to bike home from work (from Brussels to Leuven). Inspired by the "gefietst" blog en based upon the route here I made my adapted route to get to my home. The bike trip went well. Of course, I was wandering how long the bike trip was. Since I have a basic bike with no equipement to measure this I had to resort to the Google Maps info. I was almost sure that a webservice would exist that calculated the length of linesegments of Google Maps or from a KML file but after some searching I found no easy way to do this via the web. (If somebody would be aware of such a service, please drop me a line in the comments) Therefore, I decided to write a small Python script to calculate the lenght of all lines drawn on a Google Map. Just go to your map, click on "Link to this page", copy the URL and fill the URL in the Python script. Run the Python script and, bingo, you have the length in kilometers for every continuous linesegment. Here's the code:

alt : http://lode.nachtergaele.googlepages.com/distance_print.html

The output of the above script is:


distance of fietsweg is 36.35 kilometer

Of course, this calculation is only an approximation since the trajectory is only an approximation (albeit a pretty good one) of the real route I followed and no heigth information is taken into account. Still I guess that its accurate upto a few kilometers. If somebody has a spare Bluetooth GPS receiver, you can always send me one ;-).

The calculation of the distance in kilometer between two points is based on the code in Ruby and the examples from the zips project a sourceforge. The coordinates of the linesegments are obtained from the KML file that Google Maps generates when appending &output=kml to the URL from 'link to this page'. The KML file is parsed using the Python minidom module. I hope that in the future Google will provide a "&output=jsonp&callback=calcfunc" so that a simple webpage with some Javascript can calculate the length. But that's for another programming project.

Unboxing a Google Search Appliance

Today a Google Search appliance arrived at the office:



The box contains a cool black T-shirt with the Google logo (the real reason for obtaining a SA ;-)) . We decided to dress up the corporate mascotte. Isn't she cute ?

Wednesday, July 04, 2007

Twitter tweets on Goople maps mashup



I figured out a simple way to make a mashup that displays tweets from twitter on a Google Map. Click on the pin and a window pops up containing the last tweet that was updated. It is easy to change the location of the pin or the twitter feed that is addressed to obtain the latest tweet. For your reference, here's a pretty print of the code using Google Code Javascript code prettifier:

alt : test.html

Here is how it works:
Twitter API rocks with a JSON feed for every user. Adding a callback function makes it very convient to read the data. Just call a JSON object http://www.twitter.com/statuses/user_timeline/user.json and add a callbackfunction. In our case, the function is called "twitterCallback". The full URL becomes:

http://www.twitter.com/statuses/user_timeline/user.json?callback=twitterCallback&count=1
Replace user with your Twitter nickname. In my case, it's cast42.
The count parameter is set to 1 such that only the most recent tweet is obtained. In the callback function it's easy to obtain the text from the latest tweet:
   var tweet = new Object;
function twitterCallback(obj) {
tweet
.text = obj[0].text;
}
The full source code can be downloaded from the example. Don't forget to fill in your own Google Maps key and replace cast42 with your own twitter name.