Thursday, May 13, 2010

Adding GreetBox to Blogger

Wordpress blogs have enjoyed for quite a while the GreetBox, a plugin that greets visitors based on their traffic source (referrer). In 2009 ClassicTutorials released an adaptation of that plugin for the Blogger platform hosted on GoogleCode. In this article, we'll be looking at implementing that script with customized messages.

The author, Kaushik, might be looking into adding customized greeting messages, but as he has stated, this could potentially make the script unmanageably large. He is suggesting we download it, host it and edit it ourselves:

Kaushik suggests we edit GreetBox licensing

The original WP version is licensed with GPL v3, while Kaushik released his under Apache 2.0. This is fine, because, according to GNU’s guide:

In addition to clarifying the rules about licenses that are already GPL-compatible, GPLv3 is also newly compatible with a few other licenses. The Apache License 2.0 is a prime example.

The main difference between Apache 2 and GPL 3 is that Apache 2 license is more permissive. One could take an Apache 2 licensed code, modify and then release it as GPL 3, but the reverse should not be possible. Everything is fine as long as Kaushik has innovated from scratch, as opposed to adapting Thaya’s code. If I ever make enough improvements to consider it “new & significantly different”, I will probably keep this under an Apache 2 license, unless I could switch to a Creative Commons license, which I prefer because Prof Lessig is so cool.

referrers

The WP version currently supports the following referrers, while the Blogger version supports fewer (though since the article has been released, Kaushik may have updated the script without updating the article).


Blogger referrers WP referrers (extras)

  • delicious
  • digg
  • facebook
  • flickr
  • friendfeed
  • friendster
  • furl
  • general
  • google
  • lastfm
  • linkedin
  • livejournal
  • magnolia
  • mixx
  • myspace
  • netvibes
  • newsvine
  • picasa
  • pownce
  • reddit
  • stumbleupon
  • technorati
  • twitter
  • vimeo
  • webshots
  • wordpress
  • yahoo
  • yelp
  • youtube

  • bing.com
  • blinklist.com
  • blogmarks.com
  • del.icio.us
  • delicious.com
  • designrfix.com
  • digg.com
  • diigo.com
  • facebook.com
  • flickr.com
  • friendfeed.com
  • furl.com
  • google.*
  • linkedin.com
  • ma.gnolia.com
  • mister-wong.com
  • myspace.com
  • netvibes.com
  • newsvine.com
  • plurk.com
  • reddit.com
  • scoopeo.com
  • search.live.com
  • search.msn.com
  • search.yahoo.com
  • simpy.com
  • stumbleupon.com
  • technorati.com
  • twitter.com
  • webdesign-ne.ws
  • wikio.com
  • youtube.com
  • It is one of my goals to modify the script to include all the referrers supported by WP but not by Blogger.

    install

    The installation is very simple. Just copy and paste this code into an HTML / JavaScript widget:

    <script src="http://blogidol-greetbox.googlecode.com/files/bi-TextToBeDisplayedDiv-minv3.1.js" type="text/javascript"></script>
    <div id="mainDisplayDiv" style="background:#F8F8FF;border:1px solid #B6AFA9;display:none">
    <div style="float: right; margin-right: 5px; margin-top: 5px;">
    <href a="#" onclick="closeGreetBox('7')"><img border="0" alt="x" src="http://img214.imageshack.us/img214/9837/closebutton.gif" />
    </href></div>
    <div id="dynamicContentDisplayed">
    </div>
    <script type="text/javascript">
    // Give your feed url here
    var feedURL = "http://3w.blogidol.ro";var dynamicHTMLText = displayRequiredText(feedURL);
    document.getElementById("dynamicContentDisplayed").innerHTML = dynamicHTMLText;
    </script>
    </div>
    <script src="http://blogidol-greetbox.googlecode.com/files/HideShowDivV3.0.js" type="text/javascript">
    </script>
    <script type="text/javascript">
    showHideDiv();
    </script>

    If you would like to use it yourself, feel free to copy and paste the above into your own widget, which you should place somewhere at the top. If you do so, make sure you replace the feedURL with your own feed. Note however that I plan to modify this script and as such, you might want to experiment with newer versions from the repository. For the Romanian version, replace above with



    http://blogidol-greetbox.googlecode.com/files/bi-TextToBeDisplayedDiv-minv3.2.0.1.1.js


    first mods


    I have already modified the footer so that it is smaller and points to this site, though in the future I might get rid of it altogheter.


    One of the first things I’ll be playing with is getting rid of the “HideShowDiv” script:



    <script src="https://blogidol-greetbox.googlecode.com/files/HideShowDivV3.0.js"
    type="text/javascript">
    </script>


    It is very short and I see no reason to keep it as separate file, wasting time with an additional external call:



    function showHideDiv(myRestrictedDomainList){
        var arrayOfRestrictedDomains = new Array();
        document.getElementById("mainDisplayDiv").style.display = 'block';
    }


    The above would be the “SCRIPT_CONTENT”. In general, to embed an external .js into a site / template you should use the following tricks:


    a) When the script is in the template body, you can use a straight replacement:



    <script type='text/javascript'>
    //<![CDATA[
    SCRIPT_CONTENT
    //]]>
    </script>


    b) In a gadget, simply use


    <script type='text/javascript'>
    SCRIPT_CONTENT
    </script>


    There are sometimes problems with such scripts when < or > are employed. If you encounter such an issue, add a space before and after, so that i<a becomes i < a.

    ciao!


    AFAIC, this is work in progress and you install it at your own risk. If you want a more stable version, please install Kaushik’s. I will try to keep this article updated with the sites that have installed my version; if you install a later version (when it works well) and you are not listed here, consider writing a message to let me and everyone else know.


    Sources / More info: v3, v2, gcode, zamo-backup, js-hosting, gpl3, apache2, wp-greetbox by Thaya Kareeson


    [K @ GoogleDocs (gc)] [My own version]


    1 comment:

    1. closebutton.gif seems to have been deleted - see it here: https://www.google.ca/search?q=closebutton.gif

      ReplyDelete

    Thank you for commenting and rest assured that any and all comments are welcome, whether positive or negative, constructive or distructive. Unfortunately, if you comment in this view I might not know about - please use the regular (Desktop) view.
    I am using Disqus for commenting, but Blogger is not showing it so your comments may end up not being displayed - tell Google about it!