Thursday 26 July 2012

UWA IFrame method [doc] - Netvibes

UWA IFrame method [doc]

Netvibes Developers Network » Universal Widget API » UWA HOWTOs » UWA IFrame method

UWA IFrame method

You can easily display UWA widgets within your own environment, thanks to our IFrame method. This document will show you how to build the correct URL to display a given widget within an IFrame on your platform. Relying on an IFrame has the advantage of both being simple and secure. There can be any number of IFrames on one page, as long as each IFrame has a unique ID (related to the widget's chosen ID).
What this method doesn't provide:
  • drag&dropping for your system

Building the IFrame's target URL

  • The base IFrame URL is:
http://nvmodules.netvibes.com/widget/frame/
Original widget URL:
http://www.netvibes.com/modules/alexa/alexa.html
URL-encoded widget URL:
http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html
Resulting URL:
http://nvmodules.netvibes.com/widget/frame/?uwaUrl=http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html
  • You must indicate a widget identifier, so that the communication script can work properly. It MUST be unique to the page, and generated by your system (or manually). In this example, the chosen id is “123456':
http://nvmodules.netvibes.com/widget/frame/?uwaUrl=http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html&id=123456
  • In order for the widget's height to be correctly resized when its content gets displayed (and other widget communication matters), you must add a reference to a local proxy file. This file must be hosted on the same domain as the page where the IFrame is set.
See further below to get more detail about that proxy file, and get a sample code that you should build upon.
The attribute is called ifproxyUrl (which stands for “IFrame proxy URL”).
For instance, if your widget is displayed here:
http://www.example.com/myWidgets/index.html
…then, the proxy file could reside here:
http://www.example.com/myWidgets/proxy.html
Once that URL is URL-encoded, the string for this example would be like so:
&ifproxyUrl=http%3A%2F%2Fwww.example.com%2FmyWidgets%2Fproxy.html
…which would result in this IFrame URL:
http://nvmodules.netvibes.com/widget/frame/?uwaUrl=http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html&id=123456&ifproxyUrl=http%3A%2F%2Fwww.example.com%2FmyWidgets%2Fproxy.html
  • Finally, just add the URL to an IFrame on your page. The IFrame should have the identifier as its id attribute, in the form of “frame_{ID}”, with {ID} being your widget's unique identifier:
<iframe id="frame_123456" scrolling="no" frameborder="0"
height="200" width="400"
src="http://nvmodules.netvibes.com/widget/frame/
?uwaUrl=http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html
&id=123456
&ifproxyUrl=http%3A%2F%2Fwww.example.com%2FmyWidgets%2Fproxy.html
&alexaSite0=netvibes.com&alexaSite1=nytimes.com">
</iframe>
…and you are done with the IFrame itself!

Retrieving the widget's default title, favicon, meta-values and preferences

We have built a special script to return a simple JSON file containing the widget's informations:
http://nvmodules.netvibes.com/widget/json
Simply specify the needed widget URL with the uwaUrl parameter:
http://nvmodules.netvibes.com/widget/json?uwaUrl=http://www.netvibes.com/modules/digg/digg.html
This should sends back a nice JSON feed, that is yours to parse on your end.

Handling the widget's preferences (the Edit section)

Many UWA widget are not customizable, and just display some data or a Flash application, for instance. But the most useful widget are the ones that can be edit to fit the user's needs. This is done using preferences, which can be set through an 'Edit' section.
By default, the target URL that is built at the start of this tutorial only displays the widget's body - no Edit section is to be found, and thus preferences cannot be changed.
This is done so that you can build your own Edit section, one that would match the look-and-feel of the containing platform.

Displaying the default Edit section within the IFrame

For some reason, you might not want or need to go through the trouble of implement the proprer code to generate a form for the widget's preferences, along with handling the various needed events.
In this case, there is one very quick and painless to let UWA do all the work for you: simply add the &header=1 attribute to the IFrame's target URL. This will request the UWA server to send a fully-formed widget, with botht the body and a working Edit section.
While this might not match your platform's UI, it's a quick and painless way to get widgets fully working in your environment.

Building your own Edit section

For those times when the default Edit section will just not do, you can get all the information you need to build a complete custom form for any UWA widget, using a few tools of ours…

Gathering the widget's preferences names and default values

As indicated in the previous section, preferences are all available, along with metas, favicon and such, through the JSON tool:
http://nvmodules.netvibes.com/widget/json
In the case of the Digg widget, that URL would be:
http://nvmodules.netvibes.com/widget/json?uwaUrl=http://www.netvibes.com/api/uwa/examples/digg.html
…which returns a detailled JSON file. Sample JSON.
This gives you the names of the preferences for the widget, their type, value, and other useful data. Based on these, you are now able to generate a proper form, using which the user will be able to change the any widget's preferences.

Displaying the Edit section

The edit section depends on the displaying platform. Therefore, it is up to you to display the gathered preferences within a form that fits the context's UI, and to store these preferences.

Setting/updating the widget's preferences

In our example at the start of this page, the Alexa widget can take up to 5 sites, with variables names being “alexaSite0” to “alexaSite4” - you would have gathered these names thought the JSON tool above. We'll build an IFrame URL in order to compare two sites: alexaSite0 → netvibes.com & alexaSite1 → nytimes.com
Resulting IFrame URL:
http://nvmodules.netvibes.com/widget/frame/?uwaUrl=http%3A%2F%2Fwww.netvibes.com%2Fmodules%2Falexa%2Falexa.html&id=123456&ifproxyUrl=http%3A%2F%2Fwww.example.com%2FmyWidgets%2Fproxy.html&alexaSite0=netvibes.com&alexaSite1=nytimes.com
In order to properly set-up the widget's preferences, you have to know the preference variables used by the widget, and therefore use the JSON tool above. In its extract, you will find the variable names from the <widget:preference> element.

Handling the widget communications (resizing, preferences, title...)

The IFrame code can be placed anywhere within the body tag of a standard XHTML page. In order for the widget to properly communicate with your system/webpage, you not only need to place a proxy file on your host, as already advised, but you also need to place JavaScript code within the page itself. This code will let you completely handle the various messages sent by and to the widget, one of the most frequent being the resizing message.
Here is the basic code on which to build upon. As-is, it should handle resizing automatically.
<script type="text/javascript"
src="http://www.netvibes.com/js/UWA/Utils/IFrameMessaging.js">
</script>
 
<script type="text/javascript">
msgHandler = function(message) {
var id = message.id;
switch (message.action) {
case 'resizeHeight':
var frame = document.getElementById('frame_' + id);
if (frame) {
frame.setAttribute('height', message.value);
}
break;
default:
console.log(message.action + ': not implemented - ' + message.name + ':' + message.value);
break;
}
};
 
UWA.MessageHandler = new UWA.iFrameMessaging;
UWA.MessageHandler.init({
'eventHandler': msgHandler,
'trustedOrigin' : 'nvmodules.netvibes.com'
});
</script>
This code creates a message-handler for all messages coming from the running widgets. The UWA.MessageHandler() method is called by the widget with a JSON object as a message. This message contains the following properties:
  • id: the widget's ID, as declared in the IFrame URL.
  • action: the name of the action. There are a handful, listed below.
  • value: the action's value.
  • name: if needed, the name of the target to which the value applies. If not used, its value is 'false'.
For instance, in the above sample code, we have built a handler for the resizeHeight action, which is triggered when the widget is first displayed, or when its content is updated. It asks for the container to resize itself according to the displayed content's height, which is given in the action's value. Once the widget's frame has been found (it's ID should be of the form frame_{ID}, as indicated before), the widget's height is reset to the required value.
In this sample code, only the resizeHeight action is fully described, in order for you to get the idea of the way it works. Other actions are redirected to the default behavior, which as you can see is simply to display a message in the console for this minimal example. In our own version of this code, you can make it do whatever is needed by your website to react consistently.
The full set of available actions is as follows:
action description
addStar can be used to indicate that the URL has been correctly sent to Netvibes
resizeHeight can be used to resize the widget's height according to its content's height
setIcon can be used update the widget's favicon
setSearchResultCount can be used indicate the number of results for a search with the widget's content. usually placed beside the title
setTitle can be used to change the widget's title, as displayed by your website
setUnreadCount can be used indicate the number of unread messages. usually place beside the title
setValue can be used to update the widget's preference value
The switch section of the above code can therefore be customized according to your needs and possibilities. For instance, here we set an aditionnal method for the setTitle action:
(...)
switch (message.action) {
case 'resizeHeight':
var frame = document.getElementById('frame_' + id);
if (frame) {
frame.setAttribute('height', message.value);
}
break;
case 'setTitle':
var chrome = document.getElementById('widget-' + id);
var title = chrome.getElementsByClassName("title")[0];
if (title) {
title.innerHTML = message.value;
}
break;
default:
console.log(message.action + ': not implemented - ' + message.name + ':' + message.value);
break;
}
(...)

IFrame proxy

The proxy.html file should be present anywhere in your domain, and passed as a parameter in your IFrame. This file is a very basic HTML file, the purpose of which is to trigger specific JavaScript code. That code can be called from Netvibes' domain, or from within the proxy.html file itself.
Note that the JavaScript code is released by Netvibes under LGPL license.
The following example links Netvibes' own ifproxy.js:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="http://www.netvibes.com/js/UWA/Utils/ifproxy.js"></script>
<title>UWA Container Proxy</title>
</head>
<body>
</body>
</html>
If needed, you can host yourself. Just remember that the Netvibes-hosted version is always the latest. Here's what the current JS code would look like in the proxy file:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
var map = {};
var hash = location.hash.substr(1);
var pairs = hash.split('&');
for (var i = 0; i < pairs.length; i++) {
var pair = pairs[i].split('=');
if (pair.length == 2 && pair[0].length > 0) {
map[pair[0]] = unescape(pair[1]);
}
}
 
if (typeof map.target !== 'undefined' && typeof map.message !== 'undefined' &&
typeof map.origin !== 'undefined' && typeof map.uri !== 'undefined') {
 
if (map.target != 'parent') {
throw new Error('The communication system works with the parent window.');
}
 
if (parent.parent.UWA.MessageHandler) {
var message = null;
if (typeof map.message === 'string' && map.message.length) {
parent.parent.UWA.MessageHandler.dispatch(map.message, map.origin, 'ifproxy');
}
}
}
</script>
<title>UWA Container Proxy</title>
</head>
<body>
</body>
</html>
The location of the JS code is not important, as long as it is triggered from the proxy.html file. What is important is that the proxy.html file MUST be stored on the same domain as the widget.

Quick FAQ

Q: Where should I put the “proxy.html” file you provide us with?
A: It should be uploaded on your own domain.
Q: You mention a unique ID for each widget. Who provides it? The user? Your system? Our system?
A: The widget ID has to be unique to the current page, and handled/generated by your system. All you will need from us is the widget's URL, provided by Ecosystem (or from a list of selected widgets).
Q: How can I implement drag&dropping on UWA widgets?
A: It all depends on your own system. Widgets are hosted in an IFrame, so you will need to build a drag&drop functionality for your system if you don't have one already, and make it work with iframed UWA widgets.

Thursday 5 July 2012

Web Traffic Exchange Giant MGID Grows Global Content

Web Traffic Exchange Giant MGID Grows Global Content

2011-04-21
April 21, 2011, New York, NY. Press Dispensary. MGID (http://www.mgid.com ), the world’s largest traffic exchange service on the web, is upping its stakes with a revamped website that reflects its position as a growing global force, helping bloggers and publishers by generating targeted traffic to their sites, free of charge.

The upgrade of what was already a successful website symbolises a new era for MGID, which has more than 2,200 partners from the US, UK, Canada, Australia and other countries, and uses a patent-pending technology to drive traffic to third party sites. Catering for quality publishers who have decent levels of traffic and content of their own, MGID operates in the areas of traffic exchange, traffic generation from a publisher’s content and targeted services to promote a particular product or service online. Content is king at MGID, and the site has over 1,000,000 visitors daily, making it the world’s largest web traffic exchange.

The service from MGID helps website owners increase their traffic at no cost by placing their content on to a huge network of participating sites. MGID uses a bespoke widget to display content from its partner publishers on each host website. Publishers sign up to MGID because they receive 150-300% targeted traffic back to their own site, making MGID an invaluable tool in the online marketing mix.

The service is a post-crash recession beater. MGID’s activities started officially in 2008. From the summer of 2009 until the last quarter of 2010, the company has shown steady growth, with a constant increase of unique visitors per quarter.

Robert Bardunias, CFO, says: “As part of several growth initiatives, the upgraded MGID website is already helping our partner sites gain more traffic. We listened carefully to the needs of our customers during planning and the resulting upgrade is more in keeping with our company, which has offices worldwide and generates millions of visitors each month. Publishers love the service, as we’re sending visitors who genuinely like their content. The way we see it, the better the content, the more compelling it is for visitors. And the better our underlying website, the more traffic publishers will receive.” 
 - ends -

Notes for editors
Founded in 2003, MGID is a globally ranked news and product portal and the world’s busiest internet traffic exchange. Its monthly reach is more than 11 billion content impressions and it is ranked by Alexa as one of the world’s 500 most visited websites. It has more than 400 employees working in offices in the USA, Eastern Europe and Hong Kong. Its new UK office, from where its European operations will be overseen, is located at Devonshire Square, London.
FOR FURTHER INFORMATION PLEASE CONTACT

MGID Inc, USA
Robert Bardunias
Tel: (800) 351 4940 Ext. 7 / (917) 593 5374
Email: robert@mgid.com
140 Broadway, Ste. 4621 | New York NY 10005

MGID Europe Ltd
Nick Marr
Tel + 44 (0)203 178 4477 / + 44 (0)7801 490 323
Email: nick.marr@mgid.com
9 Devonshire Square, London, EC2M 4YF

Site: http://www.mgid.com

Embed stuff in your pages: Embed google reader in your blog or your homepage

Embed stuff in your pages: Embed google reader in your blog or your homepage

Google Reader is my favorite news reader. You can embed the news in your page either by importing the shared items in your page. Here's how it looks:



and here is the code for it:

<script type="text/javascript" src="http://www.google.com/reader/ui/publisher.js"></script>
<script type="text/javascript" src="http://www.google.com/reader/public/javascript/user/06940223543497213265/state/com.google/broadcast?n=5&callback=GRC_p(%7Bc%3A'green'%2Ct%3A'Shared%20items'%2Cs%3A'false'%7D)%3Bnew%20GRC"></script>


You simply go to the "Shared items" sections in google reader and follow the link in the section "Put a clip on your site or blog".

Note: if you use Blogger, it's even easier to embed.

Cons: you can't change the coloring, which makes the visual integration difficult. The green color they's displaying around the news it's probably one of the least used colors, so if your theme has a black background, you'll end up with a small stain on your beautiful blog.

Embed Google Reader - Google Groups

Embed Google Reader - Google Groups

Embed Google Reader
2 posts by 2 authors in How Do I?
8/15/07
 
Niladmirari Is it possible to embed Google Reader in my web site?  I want to have a group of RSS feeds for my customers to look at, but I don't want them to be able to change anything. Any help would be great.
 
theMezz.com
8/16/07
Use the SHARED ITEMS feature

Final product looks like this
http://www.google.com/reader/shared/13630472463511298754

This is HOW to do it
http://www.google.com/help/reader/sharing.html
- show quoted text -

Creating a public page using Google Reader | The Edublogger

The Complete Educator’s Guide to Using Google Reader | The Edublogger

Creating a public page using Google Reader

A public page is a place for you to collect any of your items in Google Reader that you want to share with other people.

Public pages are handy for educators who want their students to be able to read all posts from the student blogs in one location but don’t want their students to set up their own Google Reader account.

Please note:
  • Previously you could create public pages by making a folder public
  • Now you create a public page using a bundle
  • If you’ve already added a Google Reader blogroll to your blog sidebar then the students can click on the preview link at the bottom of the blogroll to visit your public page and read the latest posts.
  • To add and remove blogs from your Public page you need to edit your Bundle by following the instructions for editing your blogroll.
Here’s how create a public page:
1.  Hover your mouse over the name of a folder you want to create a public page from to display the drop down arrow.
2.  Click on the drop down arrow to display the folder options.
3.  Select Create a bundle.


4.  Click Save.

5.  Click on Add a link.

6.  Copy the URL from the address bar.

7.   Now go to Links > Add New in your blog dashboard
8.  Add a title for your Google Reader public page to the Name

9.  Add your Google Reader public page URL to the Web Address 
10.  Select Blogroll in the Categories and the click Add Link

11. Now go to Appearance > Widgets in your blog dashboard
12.  Add your links widget to your sidebar.
13.  You should now see a link to your Public page and students just need to click on this link to read the latest posts.

Embed Google Reader « Affordable Websites

Embed Google Reader « Affordable Websites


Embed Google Reader

How to embed Google Reader rss feed subscriptions.

Embed Google Reader subscription

  1. Log into your Google Reader account.
  2. Mouse hover over the subscription and a little down arrow will appear. Click on the down arrow.
  3. From the drop down menu select ‘New Folder’.
  4. Name the folder and click the ‘OK’ button.
  5. Now you can see the folder you just created and your feed subscription should automatically be inside the fold. You can drag and drop other feeds into this folder that you want to embed also.
  6. Hover over the fold and click the small arrow that appears.
  7. Click the ‘Create a bundle’ option.
  8. Click the ‘Save’ button to save your bundle.
  9. Click the ‘Create a bundle clip link.
  10. Edit the ‘Title’.
  11. Copy the code snippet.
  12. Paste the code snippet into your Website’s HTML. If you’re using WordPress you can paste the code snippet into any page post or widget.
    Note: If you are pasting this code snippet into a WordPress page or post, make sure you’re in HTML mode.

‘Add to Blogger’

  1. Copy the code snippet then click on the ‘Add to Blogger’ icon.
  2. Select your blog from the ‘Select a blog:’ drop-down menu.
  3. Enter a title for your Bundle.
  4. Click on the ‘Edit Content’ link and paste the code snippet inside it.
  5. Click the ‘Add Widget’ button.