Was this page helpful?

Ajax RSS

  • You do not have permissions to view this page - please try logging in.
Vendor
MindTouch
Type Script
Categories Rss
Requires MindTouch Core 1.8.3 or later
Status Stable
License Free/Open Source
Manifest http://scripts.mindtouch.com/ajaxrss.xml

 

Install Script
To add  this script to your site, enter the address of your MindTouch installation (ex: http://www.mindtouch.com) and click the Add Script button.  This will open your control panel and prepopulate the necessary values.  You will still need to manually add configuration settings if required.  Note that no changes are made to your site until you confirm the action in your control panel.
Your site address:     


Table of Contents

Description

This extension contains an easily customizable function for displaying RSS feeds.

See also How to add a script, Using the Extension Dialog, Learn about DekiScript, Extensions Directory.


Configuration

The following configuration settings are required to run this script (unless shown as optional).

NameTypeDescription
api-keystrGoogle API key for feed web-service.
securestr(optional) Always use https:// to load scripts from Google servers.


Functions

ajaxrss(feed : uri, max : num) : xml

Display an rss feed

Parameters:

NameTypeDescription
feedurifeed uri (Atom or RSS)
maxnum(optional) max items to display (default: nil)


Script Source

<extension>
  <title>MindTouch RSS Extension (customizable)</title> 
  <label>ajaxrss</label> 
  <copyright>Copyright (c) 2006-2010 MindTouch Inc.</copyright> 
  <description>This extension contains an easily customizable function for displaying RSS feeds.</description>

  <config>
    <param name="api-key" type="str">Google API key for feed web-service.</param>
    <param name="secure" type="str" optional="true">Always use https:// to load scripts from Google servers.</param>
  </config>
  
  <function>
    <name>ajaxrss</name>
    <description>Display an rss feed</description>
    <param name="feed" type="uri">feed uri (Atom or RSS)</param>
    <param name="max" type="num" optional="true">max items to display (default: nil)</param>
    <return>
      <html xmlns:eval="http://mindtouch.com/2007/dekiscript">
        <head>
          <script eval:src="(((string.compare(config.secure ?? '', 'true', true) == 0) || string.startswith(__env.site.uri ?? '', 'https:', true)) ? 'https' : 'http') .. '://www.google.com/jsapi' .. (config['api-key'] ? '?key='..config['api-key'] : (config['maps-api-key'] ? '?key='..config['maps-api-key'] : ''))" type="text/javascript" />
          <script type="text/javascript">google.load('feeds', '1');</script>
        </head>
        <body>
          <div eval:id="@id" />
        </body>
        <tail>
          <script type="text/javascript">
            var feed = new google.feeds.Feed(<eval:js>args.feed</eval:js>);
            <eval:if test="args.max">feed.setNumEntries(<eval:js>args.max</eval:js>);</eval:if>
            feed.load(function(result) {
              var container = document.getElementById(<eval:js>@id</eval:js>);
              if (!result.error) {
                var header = container.appendChild(document.createElement("h3"));
                var headerLink = header.appendChild(document.createElement("a"));
                headerLink.href = result.feed.link;
                headerLink.innerHTML = result.feed.title; 
                headerLink.setAttribute("class", "external");
                var entryList = container.appendChild(document.createElement("ul"));
                for (var i = 0; i &lt; result.feed.entries.length; i++) {
                  entryListItem = entryList.appendChild(document.createElement("li"));
                  var entryLink = entryListItem.appendChild(document.createElement("a"));
                  entryLink.href = result.feed.entries[i].link;
                  entryLink.innerHTML = result.feed.entries[i].title;
                  entryLink.setAttribute("class", "external");
                }
              } else {
                container.innerHTML = result.error.message;
              }
            });
          </script>
        </tail>
      </html>
    </return>
  </function>
</extension>

Was this page helpful?
Tag page
You must login to post a comment.

Copyright © 2011 MindTouch, Inc. Powered by