• Yesterday I posted a request for help with designing a Google Gadget for my WP feed. It led to some debate as to what should or shouldn’t be included here in the miscellaneous category.

    Before going any further, I should mention the advantage of making a gadget over just having an ‘Add to Google’ button:
    You can submit a gadget to Google’s gadget directory. If it is accepted for inclusion in the directory, it can open up a large pool of potential new readers who have personalized homepages in Google.

    Google’s own example refers to an atom feed, and doesn’t work out of the box on rss 2.0. I’m pleased to say that I got the gadget working, and so I’m posting the code here for anyone who wants to use it as a starting point for a Google Gadget for their own WordPress feed.

    An acknowledgement: I used some code from https://www.semanticbible.com/blogos/gems/dailyverse.xml
    in my Google Gadget. (This unusual gadget displays a new biblical verse daily. However, the rss 2.0 feed file being read has only one item in it at any one time.)

    I’ve used the feed from the WordPress blog as an example in my gadget.

    Unfortunately, try as I might, I couldn’t get the gadget to display the <description> for each item. I’ll have another go at this sometime and if it works out I’ll post the amended code.

    Sample code for Google Gadget to read RSS 2.0 headlines:

    **************************************************

    <?xml version=”1.0″ encoding=”UTF-8″ ?>
    <Module>

    <ModulePrefs title=”Wordpress Blog” scrolling=”true” render_inline=”optional” />

    <Content type=”html”>
    <![CDATA[
    <!– load the NXSL library –>
    <script src=”https://www.google.com/js/nxsl.1.js&#8221; type=”text/javascript”></script>
    <div id=”content___MODULE_ID__”></div>

    <script type=”text/javascript”>
    _IG_RegisterOnloadHandler(function () {
    var url = ‘https://www.ads-software.com/development/feed/&#8217;;
    _IG_FetchContent(url, function (response) {
    var prefs = new _IG_Prefs(__MODULE_ID__);
    var nxsl = xmlParse(”
    + ‘<div select=”/rss/channel/item”>’
    + ‘ <div style=”text-align:right;”><span h3 select=”title” content=”.”></h3></span></div>’
    + ‘</div>’);
    nxslProcess(xmlParse(response), nxsl);
    var content = xmlText(nxsl);
    content = content.replace(/</g, ‘<‘)
    .replace(/>/g, ‘>’)
    .replace(/&/g, ‘&’)
    ;
    _gel(‘content___MODULE_ID__’).innerHTML = content;
    });
    });
    </script>

    ]]>
    </Content>
    </Module>

    *******************************************************
    To try this code, do the following:

    1. Copy and save it to a .xml file.

    2. Upload it to a hosting account.

    3. Log in to your Google Personalized homepage.

    4. Go to https://www.google.com/apis/homepage/guide.html#DevModStart
    and add the developer module to your Google Personalized homepage.

    5. Add your gadget to your personalized homepage by inputting its url in the developer module.

    You should now have a gadget displaying headlines from the WP blog feed (or your chosen RSS2.0 blog feed).

    For more info on developing gadgets, go to https://www.google.com/apis/homepage/guide.html

    Hopefully this will be of use to someone and it will put the controversy to bed as well!

  • The topic ‘Got my Google Gadget for WP feed working’ is closed to new replies.