Wednesday, November 30, 2011

Social Media : Dojo Widgets ( e.g: checkbox ) into a OpenSocial Gadget.


Article written here is my own opinion and does not reflect my employer's point of view.

Social Media gadgets are slowly becoming popular amongst the community who are developing content in digital influence and intelligence. These gadgets provide the ability to create/connect/exchange information between friends/colleagues and others who are part of a group.

Here I am experimenting with this Apache Shindig - which is an Apache module allowing developers to create Open Social apps to create gadgets. These gadgets have the ability to handle REST and RPC requests.

The advantages of this Open Social is that the developer don't have to start from scratch as the Apache Module ( Shindig) provides it as a built in feature.

Before I go into some details:  Here are my definitions of terms being used in this article.
Container : The Interface ( the web page in other words ) where the gadgets can be loaded.
Gadgets : This is xml file which has the definition of how the front end should look like. The xml file consists of paragraphs like

<Module>
<ModulePrefs >   ...........  </ModulePrefs>
..html code encompassed in [[ CDATA ....  ]]








To get this dojo widget into the open social container - do the following.

1. In the webapps/ROOT/container folder,

Create this file and name it dojo_checkbox.html
Note : the specURL0 would point to the right/appropriate location depending on your configuration.

<!--
-->
<!DOCTYPE html>
<html>
<head>
<title>Sample: Simple Container</title>
<!-- default container look and feel -->
<link rel="stylesheet" href="gadgets.css">
<script type="text/javascript"
src="../gadgets/js/shindig-container:rpc.js?c=1&debug=1&nocache=1"></script>
<script type="text/javascript">
var specUrl0 =
'http://localhost:8080/productserver/widgets/dojo_checkbox.xml';

// This container lays out and renders gadgets itself.
function renderGadgets() {
var gadget0 = shindig.container.createGadget({specUrl: specUrl0});
shindig.container.addGadget(gadget0);
shindig.container.layoutManager.setGadgetChromeIds(
['gadget-chrome-x']);
shindig.container.renderGadget(gadget0);
};
</script>
</head>
<body onLoad="renderGadgets();">
<h2>Sample: Simple Dojo Check Box Container</h2>
<div id="gadget-chrome-x" class="gadgets-gadget-chrome"></div>
</body>
</html>
------------X-----------Done -----------X-------

Next, create the file, productserver/widgets/dojo_checkbox.xml as shown.


---------X-------- Cut and Paste -------------X------------
<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs title="Hello OpenSocial Gadgets!" height="200"
author="Shashi Kiran" author_email="kiranshashiny@gmail.com"
screenshot="" thumbnail="" >
<Require feature="opensocial-0.8" />
</ModulePrefs>
<Content type="html">
<![CDATA[
<link rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="path/to/local/dojo.js"></script>
<script>
function loader () {
dojo.require ("dijo.parser");
dojo.require ("dijit.form.CheckBox");
dojo.addOnLoad(callback);
function callback () {
new dijit.form.CheckBox ({}, dojo.byId("cb"));
}
dojo.config.parseOnLoad = true;
dojo.config.dojoBlankHtmlUrl = '/blank.html';
dojo.addOnLoad(loader);
</script>

<input id="cb" dojotype="dijit.form.CheckBox" name="developer"
checked="checked" value="on" type="checkbox" />
<label for="cb"> Are you a Developer </label>
]]>

</Content>
</Module>
--------------X-------------- Done ---------------------X-----------------
Now go to the browser and type in
http://localhost:8080/container/dojo_checkbox.html and it will render the
checkbox widget.

Open Social Examples - on Apache Web Server

Open Social war file comes with some other examples - these were brought up
as shown.....


(Embedded image moved to file: pic17602.gif)


This is how it renders.

(Embedded image moved to file: pic01080.gif)

(Embedded image moved to file: pic08673.gif)

Fw: Apache OpenSocial - Configuration - Tutorial



This tutorial is to install the OpenSocial Container on  Apache.

Open Social Gadget helps in ( similar to Facebook and other social media
outlets ) connect with friends/colleagues and share information.
Blogging my experiences here.
1.
I used the Apache 6.0 on my Windows XP.
2. First I downloaded the Apache Shindig - war file from this location.
http://shindig.apache.org/
3. Click on Download



 
5. Copied the shindig-server-2.0.0.war file to the webapps folder.
6. Moved the ROOT folder to ROOT.old
7. Moved the shindig-server-2.0.0.war to ROOT.war

8. Started Tomcat
9. Open FireFox
10.
http://localhost:8080/samplecontainer/samplecontainer.html
This is the final outcome - the page that shows the sample Open Social Demo.