You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by li...@apache.org on 2010/11/09 08:21:03 UTC

svn commit: r1032875 - in /shindig/trunk/content/samplecontainer/examples/commoncontainer: ./ gadgetCollections.json index.html layout.js testContainer.js testGadgets.js

Author: lindner
Date: Tue Nov  9 07:21:03 2010
New Revision: 1032875

URL: http://svn.apache.org/viewvc?rev=1032875&view=rev
Log:
SHINDIG-1463 | Patch from Andy Smith | Create a new test page that builds on the container Js to make it easier for interoperability testing

Added:
    shindig/trunk/content/samplecontainer/examples/commoncontainer/
    shindig/trunk/content/samplecontainer/examples/commoncontainer/gadgetCollections.json
    shindig/trunk/content/samplecontainer/examples/commoncontainer/index.html
    shindig/trunk/content/samplecontainer/examples/commoncontainer/layout.js
    shindig/trunk/content/samplecontainer/examples/commoncontainer/testContainer.js
    shindig/trunk/content/samplecontainer/examples/commoncontainer/testGadgets.js

Added: shindig/trunk/content/samplecontainer/examples/commoncontainer/gadgetCollections.json
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/gadgetCollections.json?rev=1032875&view=auto
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/gadgetCollections.json (added)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/gadgetCollections.json Tue Nov  9 07:21:03 2010
@@ -0,0 +1,34 @@
+{ "collections":
+        [
+            {
+            "name": "Publish Subscribe Demo",
+            "Description": "This is a sample pub/sub demo showcasing the pubsub-2 feature",
+            "apps" : [
+                     {"name": "publisher", "url": "http://localhost:8080/container/sample-pubsub-2-publisher.xml"},
+                     {"name": "subscriber", "url": "http://localhost:8080/container/sample-pubsub-2-subscriber.xml"}
+                     ]
+             },
+             {
+            "name": "Activity Streams Sample",
+            "Description": "Simple gadget to test base ActivityStreams implementation in features",
+            "apps" : [
+                     {"name": "ActivityStreams Sample", "url": "http://localhost:8080/samplecontainer/examples/ActivityStreams/ActivityStreamGadget.xml"}
+                     ]
+             },
+                         {
+            "name": "Sample Media Items Gadget",
+            "Description": "This is a sample pub/sub demo showcasing the pubsub-2 feature",
+            "apps" : [
+                     {"name": "publisher", "url": "http://localhost:8080/samplecontainer/examples/media/Media.xml"}
+                     ]
+             },
+             {
+             "name": "ToDo & Horoscope",
+             "Description": "Sample gadgets used in the simple sample (sample1.html)",
+             "apps" : [
+                      {"name": "Horoscope", "url": "http://www.google.com/ig/modules/horoscope.xml"},
+                      {"name": "TODO", "url": "http://www.labpixies.com/campaigns/todo/todo.xml"}
+                      ]
+             }
+         ]
+}
\ No newline at end of file

Added: shindig/trunk/content/samplecontainer/examples/commoncontainer/index.html
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/index.html?rev=1032875&view=auto
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/index.html (added)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/index.html Tue Nov  9 07:21:03 2010
@@ -0,0 +1,130 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!--
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
+<head>
+
+<!-- My OpenSocial Beginnings -->
+<link rel="stylesheet" href="/container/gadgets.css">
+<script type="text/javascript"
+	src="/gadgets/js/container:rpc:pubsub-2.js?c=1&debug=1&container=default""></script>
+<script
+	src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
+<script
+	src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script>
+<link rel="stylesheet"
+	href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/cupertino/jquery-ui.css"
+	type="text/css" media="all" />
+<script type="text/javascript" src="./testContainer.js"></script>
+<script type="text/javascript" src="./testGadgets.js"></script>
+<script type="text/javascript" src="./layout.js"></script>
+
+<style>
+#content {
+	display: table;
+	width: 100%;
+}
+
+#testArea {
+	display: table-cell;
+	width: 75%;
+	padding-left:22px;
+}
+
+#controlPanel {
+	display: table-cell;
+	width: 25%;
+}
+
+</style>
+</head>
+
+
+<body onLoad="CommonContainer.init();">
+<!--  Need to add in an improved header with links to specification -->
+<a href="http://www.opensocial.org/"><img alt="OpenSocial" src="http://api.ning.com/files/chwE7fbkJ5D1q8NSzNCYJzzCqOiuo3xYyToZCsYuY0SViOKQ7EG-3UUv4KFSxOMACbIzs3oWtD076*cbEL-*ABd9hCO0p7Al/opensocialsitelogo1.png?width=288&amp;height=70&amp;xn_auth=no&amp;type=png"></a><div id="content">
+
+<div id="controlPanel">
+
+<div id="accordionResizerControls"
+	style="padding: 10px; width: 100%; height: 100%;"
+	class="ui-widget-content">
+
+<div id="accordionGadgetControls">
+<h3><a href="#">Manage Gadgets</a></h3>
+<div>
+
+Enter the gadget url (ex.  http://localhost:8080/samplecontainer/SocialHelloWorld.xml)  and select 'Add' to render the gadget
+<br/>
+<input type="text"name="gadgetUrl" id="gadgetUrl" class="text ui-widget-content ui-corner-all" /> 
+
+<button id="addGadget">Add</button>
+<br/>
+<br/>
+-OR-
+<br/>
+<br/>
+
+Pick from one of the collections and select Add Gadgets to render the associated gadgets 
+<br/>
+<select id="gadgetCollection"> </select>   <button id="addGadgets">Add Gadgets</button>
+   
+</div>
+</div>
+<span class="ui-icon ui-icon-grip-dotted-horizontal"
+	style="margin: 2px auto;"></span>
+<div id="accordionContainerControls">
+<h3><a href="#">Manage Container</a></h3>
+<div>More to come here with common container....</div>
+</div>
+</div>
+</div>
+
+<div id="testArea">
+<div id="accordionResizer"
+	style="padding: 10px; width: 100%; height: 650px;"
+	class="ui-widget-content">
+
+<div id="accordion">
+<h3><a href="#">Test Area</a></h3>
+<div>
+<div id="gadgetArea" class="column"> 
+</div>
+</div>
+</div>
+<span class="ui-icon ui-icon-grip-dotted-horizontal"
+	style="margin: 2px auto;"></span></div>
+
+<div id="accordionResizerEvents"
+	style="padding: 10px; width: 100%; height: 350px;"
+	class="ui-widget-content">
+
+<div id="accordionEvents">
+<h3><a href="#">events</a></h3>
+<div>
+<div id="output" class="column"></div>
+</div>
+
+</div>
+<span class="ui-icon ui-icon-grip-dotted-horizontal"
+	style="margin: 2px auto;"></span></div>
+</div>
+
+</body>
+</html>

Added: shindig/trunk/content/samplecontainer/examples/commoncontainer/layout.js
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/layout.js?rev=1032875&view=auto
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/layout.js (added)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/layout.js Tue Nov  9 07:21:03 2010
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+ //  Setup the base container objects for managing layout, gadget, and container configuration
+$(function() {
+	
+		//TODO:  enable drag and drop with the portlet at some point
+		$(".column").sortable({
+			connectWith: '.column',
+			update:  function(event, ui) {
+					//TODO:  There is an issue with drag & drop 
+		}
+		});
+
+		$(".portlet").addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
+			.find(".portlet-header")
+				.addClass("ui-widget-header ui-corner-all")
+				.prepend('<span class="ui-icon ui-icon-minusthick"></span>')
+				.end()
+			.find(".portlet-content");
+
+		$(".portlet-header .ui-icon").click(function() {
+			$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
+			$(this).parents(".portlet:first").find(".portlet-content").toggle();
+		});
+
+		$(".column").disableSelection();
+	});
+		
+	$(function() {
+		$( "#accordion" ).accordion({
+			fillSpace: true,
+			collapsible: true
+			
+		});
+	});
+	$(function() {
+		$( "#accordionResizer" ).resizable({
+			minHeight: 140,
+			resize: function() {
+				$( "#accordion" ).accordion( "resize" );
+			}
+		});
+	});
+	$(function() {
+		$( "#accordionEvents" ).accordion({
+			fillSpace: true,
+			collapsible: true
+			
+		});
+	});
+	$(function() {
+		$( "#accordionResizerEvents" ).resizable({
+			minHeight: 140,
+			resize: function() {
+				$( "#accordionEvents" ).accordion( "resize" );
+			}
+		});
+	});
+	$(function() {
+		$( "#accordionGadgetControls" ).accordion({
+			fillSpace: true,
+			collapsible: true
+			
+		});
+	});
+	$(function() {
+		$( "#accordionContainerControls" ).accordion({
+			fillSpace: true,
+			collapsible: true
+			
+		});
+	});
+	$(function() {
+		$( "#accordionResizerControls" ).resizable({
+			minHeight: 140,
+			resize: function() {
+				$( "#accordionGadgetControls" ).accordion( "resize" );
+			}
+		});
+	});

Added: shindig/trunk/content/samplecontainer/examples/commoncontainer/testContainer.js
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/testContainer.js?rev=1032875&view=auto
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/testContainer.js (added)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/testContainer.js Tue Nov  9 07:21:03 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+var testConfig =  testConfig || {};
+testConfig[shindig.container.ServiceConfig.API_PATH] = '/rpc';	
+testConfig[shindig.container.ContainerConfig.RENDER_DEBUG] = "1";
+
+//Default the security token for testing.
+shindig.auth.updateSecurityToken('john.doe:john.doe:appid:cont:url:0:default');
+
+
+//  Create the new CommonContainer 
+var CommonContainer = new shindig.container.Container(testConfig);
+
+// Need to pull these from values supplied in the dialog
+CommonContainer.init = function() {
+	//  Override base funcitons to log OAH events
+	gadgets.pubsub2router.init(
+		    {
+		      onSubscribe: function(topic, container) {
+		        log(container.getClientID() + " subscribes to topic '" + topic + "'");
+		        return true;
+		        // return false to reject the request.
+		      },
+		      onUnsubscribe: function(topic, container) {
+		        log(container.getClientID() + " unsubscribes from topic '" + topic + "'");
+		        return true;
+		      },
+		      onPublish: function(topic, data, pcont, scont) {
+		        log(pcont.getClientID() + " publishes '" + data + "' to topic '" + topic + "' subscribed by " + scont.getClientID());
+		        return true;
+		        // return false to reject the request.
+		      }
+		    });
+};
+
+//Wrapper function to set the gadget site/id and default width.  Currently have some inconsistency with width actually being set. This 
+//seems to be related to the pubsub2 feature.
+CommonContainer.renderGadget = function(newGadgetSpec, gadgetId) {
+	//going to hardcode these values for width.  
+    var el = document.getElementById("gadget-site-" + gadgetId);
+    var parms ={};
+    parms[shindig.container.RenderParam.WIDTH]="700px";
+	var gadgetSite = CommonContainer.newGadgetSite(el);
+	CommonContainer.navigateGadget(gadgetSite, newGadgetSpec, {}, parms);
+  
+};
+//TODO:  To be implemented. Identify where to hook this into the page (in the gadget title bar/gadget management, etc)
+CommonContainer.navigateView = function(newGadgetSpec, gadgetId, view) {
+	
+};
+//TODO:  Add in UI controls in portlet header to remove gadget from the canvas
+CommonContainer.removeGadget = function(gadgetId) {
+  
+};
+
+//display the pubsub 2 event details
+function log(message) {
+
+  document.getElementById("output").innerHTML = gadgets.util.escapeString(message) + "<br/>" + document.getElementById("output").innerHTML;
+};
+

Added: shindig/trunk/content/samplecontainer/examples/commoncontainer/testGadgets.js
URL: http://svn.apache.org/viewvc/shindig/trunk/content/samplecontainer/examples/commoncontainer/testGadgets.js?rev=1032875&view=auto
==============================================================================
--- shindig/trunk/content/samplecontainer/examples/commoncontainer/testGadgets.js (added)
+++ shindig/trunk/content/samplecontainer/examples/commoncontainer/testGadgets.js Tue Nov  9 07:21:03 2010
@@ -0,0 +1,100 @@
+$(function() {
+
+// Input field that contains gadget urls added by the user manually
+var newGadgetUrl= $( "#gadgetUrl" );
+
+// Base html template that is used for the gadget wrapper and site
+var gadgetTemplate ='<div class="portlet">' +
+			                '<div class="portlet-header">sample to replace</div>'+
+			                '<div id="gadget-site" class="portlet-content"></div>' +
+                            '</div>';
+// ID used to associate gadget site
+curId = 0;
+
+//  Load the defaultl collections stored and update the options with the collection name
+$.ajax({
+		url: './gadgetCollections.json',
+		dataType: 'json',
+		success: function(data) {
+		$.each(data.collections, function(i,data)
+			{
+			 var optionVal = [];
+			 $.each(data.apps, function(i,data)
+			 	 {
+			      optionVal.push(data.url);
+			 	 }
+			 	);
+			 $('#gadgetCollection').append('<option value="'+ optionVal.toString() + '">' + data.name +'</option>');
+					}
+					);
+			  }
+			});	
+	 
+//  Load single gadgets entered by user
+$( "#addGadget" ).click(function() {
+	
+	CommonContainer.preloadGadget(newGadgetUrl.val(), function(result){
+		
+		  for (var id in result) {
+			  var newGadgetSite = gadgetTemplate;
+				 newGadgetSite = newGadgetSite.replace(/(gadget-site)/g,'$1-'+ curId);
+				 $(newGadgetSite).appendTo($( '#gadgetArea' )).addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
+					.find(".portlet-header")
+					.addClass("ui-widget-header ui-corner-all")
+					.prepend('<span class="ui-icon ui-icon-minusthick"></span>')
+					.text(result[id]['modulePrefs'].title)
+					.end()
+				.find(".portlet-content");
+		
+				 
+				 $(".portlet-header .ui-icon").click(function() {
+						$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
+						$(this).parents(".portlet:first").find(".portlet-content").toggle();
+					});
+
+				    //Call gadget render
+				  
+				   CommonContainer.renderGadget(id, curId);
+				   curId++;
+		  }
+
+	    //Clear Values
+	    newGadgetUrl.val( "" ); });
+	    return true; 
+});
+
+//  Load the select collection of gadgets and render them the gadget test area
+$( "#addGadgets" ).click(function() {
+	
+	//TODO:  This just provides and example to load configurations
+	//var testGadgets=["http://localhost:8080/container/sample-pubsub-2-publisher.xml","http://localhost:8080/container/sample-pubsub-2-subscriber.xml"];
+	var testGadgets = $('#gadgetCollection').val().split(",");
+	CommonContainer.preloadGadgets(testGadgets, function(result){
+		
+		  for (var id in result) {
+			  var newGadgetSite = gadgetTemplate;
+				 newGadgetSite = newGadgetSite.replace(/(gadget-site)/g,'$1-'+ curId);
+				 $(newGadgetSite).appendTo($( '#gadgetArea' )).addClass("ui-widget ui-widget-content ui-helper-clearfix ui-corner-all")
+					.find(".portlet-header")
+					.addClass("ui-widget-header ui-corner-all")
+					.prepend('<span class="ui-icon ui-icon-minusthick"></span>')
+					.text(result[id]['modulePrefs'].title)
+					.end()
+				.find(".portlet-content");
+		
+				 
+				 $(".portlet-header .ui-icon").click(function() {
+						$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick");
+						$(this).parents(".portlet:first").find(".portlet-content").toggle();
+					});
+
+				    //Call gadget render
+				  
+				   CommonContainer.renderGadget(id, curId);
+				   curId++;
+		  }
+	});
+	    return true; 
+	    
+});
+});
\ No newline at end of file