Posts Tagged ‘xml’

How to add custom external links to your Tonido

Tonido not only allows seamless access to your files and media, it truly is your personal hub.

With the latest Tonido 2.10.x release, there is a new feature to customize the apps that are shown in the navigation tree. You are no longer limited by the apps Tonido provides, but you can add your own custom app that is a simple link to another website .

This allows you to get quick access to that website from within Tonido.  For example, if you have other web servers or services running in your home, you can point to those too making Tonido a single place to access your stuff.



Here’s how you do it:

1) Download the following zip file (for a link)


2) Unzip the folder inside

3) Copy the folder to your Tonido install directory, into the directory called “plugins”

4) (Optional) Edit the manifest.xml and change the “AppURL” value to whatever you want

5) Restart Tonido

6) Your new app should show up in the Apps Navigation Tree

7) Enjoy!

You can customize the icons shown by replacing the two icons that are in that directory, icon.gif and iconbg.gif. You can also disable them from appearing by “suspending” these apps like normal Tonido apps. You can also delete them in one click.

We have started a Tonido Forums thread here, that will have user-created zips for various things in the future. For now, it has a and external links.
Feel free to create your own and contribute.

JavaScript Mashups using Tonido HTTP API

You can write app mashups purely using Javascript in Tonido. For example, say you wanted to combine data from two Tonido apps together and present them in a single view, you can do that quite easily. Or if you want to present information in a different way, you can do that too.

In this post, let me walkthrough a simple JS script that grabs data from Tonido Thots applications and displays them.

For this JS to work, you need to make sure the JS code is being served up by Tonido itself, otherwise, due to the cross-domain scripting rules, the script won’t run. To make Tonido serve these files up, you can add these files to a folder and share it via Webshare and then load the .html page by clicking on it in Webshare file listing.

Doing AJAX via JS can be a chore unless you let a library do all the dirty work for you. In this case, I am using jQuery. It is especially excellent for parsing the XML that is returned by Tonido’s HTTP calls.

First, in the code below, we set an event handler so that when the link is clicked, we make a call to the ‘getauthenticationinfo’ HTTP API. This returns the status of the currently logged in user etc via XML.

<br />
 $(document).ready(function(){<br />
       $("a").click(function(event){<br />
         $.get('', function(data) {<br />
 		 var $entry = $(data).find('info');<br />
		 var $profile = $entry.find('profile').text();<br />
		 if ($profile == "")<br />
		 {<br />
		     alert("Profile Not Logged IN");<br />
		 }<br />
		 else<br />
		 {<br />
			if ($entry.find('authenticated').text() == "1")<br />
			{<br />
				getThots();<br />
			}<br />
			else<br />
			{<br />
                             alert("Profile logged in, but needs to be authenticated");<br />
			}<br />
		}<br />
		});<br />
          event.preventDefault();<br />
         return false;<br />
       });<br />
     });<br />

This XML response below contains several pieces of information. The primary being the authenticated element. Each value of that element represents something as you can see from the JS. If it is “1″ we are ready to make our next call. That is of course to get the actual thots data.

<br />
<authenticationinfo><br />
             <authenticated>>1< /span></authenticated><br />
             <isremote>>0< /span></isremote><br />
             <reasoncode>>0< /span></reasoncode><br />
          </info><br />
</authenticationinfo><br />

Getting the Thots data is a simple HTTP call again passed in with a bunch of GET parameters. The return naturally is XML again.

<br />
function getThots()<br />
{<br />
	$.get(';max=10&amp;datefilter=&amp;categoryfilter=&amp;searchfilter=',<br />
                             function (data) {<br />
				var $meta = $(data).find('totalrecords').text();<br />
				var $thots = $(data).find('thot').each(function ()<br />
                                 {<br />
				     var $entry = $(this);<br />
				     var $content = $entry.find('displaycontent').text();<br />
				     var $displaycontent = jQuery("
<p>");<br />
				    $displaycontent.appendTo(document.body);<br />
				});<br />
		}, "xml");<br />
 }<br />

Which looks like the below:

    <meta><br />
    <totalrecords>>60</totalrecords><br />
        <id>>75</id><br />
        <title/><br />
        <displaycontent>Interesting Thot</displaycontent><br />
        <content>Interesting Thot</content><br />
        <status/><br />
        <date>>2009-07-20 13:08:09< /span></date></p>
<pageobjectindex>>1< /span></pageobjectindex>
        <totalobjects>>60</totalobjects><br />
        <totalcategories>>1< /span></totalcategories><br />
        <categoryid_0>>1< /span></categoryid_0><br />
        <categorytext_0>Bookmarks</categorytext_0><br />
       <categoryparentid_0>-1< /span></categoryparentid_0><br />
       <category_texts>Bookmarks</category_texts><br />
       <displaycategory_texts>Bookmarks</displaycategory_texts><br />

We parse the XML and append it to the document in the loop. So the effect is when you click the link you see list of thots entries.

This is for sake of example and is trivial to write. Imagine you could do the same thing, but create a page which showed your Tasks/Calendars/Thots/Webshare Upload History all in one shot. Maybe even a text box to quickly add a torrent in one shot. That would be fun.

You can even write a mini Tonido application with a different UI just by running Webshare JS and HTML files. The possibilities are endless.

Tonido’s implements almost all of the app functionality using HTTP APIs. You can study these APIs and responses easily using FireBug. If you want more documentation, you can read the official documentation for the HTTP APIs in the reference documentation.

Download the full source for this sample.