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/05/18 18:57:10 UTC

svn commit: r945746 - in /shindig/trunk: content/container/ features/src/main/javascript/features/ features/src/main/javascript/features/shindig.connect/

Author: lindner
Date: Tue May 18 16:57:10 2010
New Revision: 945746

URL: http://svn.apache.org/viewvc?rev=945746&view=rev
Log:
shindig-connect first pass

Added:
    shindig/trunk/content/container/sample-connect.html
    shindig/trunk/features/src/main/javascript/features/shindig.connect/
    shindig/trunk/features/src/main/javascript/features/shindig.connect/connect.js
    shindig/trunk/features/src/main/javascript/features/shindig.connect/feature.xml
Modified:
    shindig/trunk/features/src/main/javascript/features/features.txt

Added: shindig/trunk/content/container/sample-connect.html
URL: http://svn.apache.org/viewvc/shindig/trunk/content/container/sample-connect.html?rev=945746&view=auto
==============================================================================
--- shindig/trunk/content/container/sample-connect.html (added)
+++ shindig/trunk/content/container/sample-connect.html Tue May 18 16:57:10 2010
@@ -0,0 +1,121 @@
+<!--
+ * 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>
+<head>
+<title>Metadata Demo</title>
+<style>
+  .gadget {
+    border: solid 1px #000;
+    margin: 10px;
+    float: left;
+    text-align: center;
+  }
+  .gadget h2 {
+    background: #ccf;
+    border-bottom: solid 1px #000;
+    margin: 0;
+    padding: 5px;
+  }
+  .gadget iframe {
+    margin: 5px;
+    border: none;
+    height: 300px;
+    width: 300px;
+  }
+</style>
+<script src="/gadgets/js/shindig-connect.js?c=1&container=default"></script>
+</head>
+<body>
+Hello <os:viewer/>
+<os:config country="de"/>
+<os:gadget moduleId="1" url="http://www.google.com/ig/modules/horoscope.xml"></os:gadget>
+<os:gadget moduleId="2" url="http://www.labpixies.com/campaigns/todo/todo.xml"></os:gadget>
+
+<script type="text/javascript">
+  function renderGadgets(obj) {
+    var gadgetList = obj.gadgets;
+    var features = {};
+    for (var i = 0, gadget; gadget = gadgetList[i]; ++i) {
+      var feats = gadget.features || [];
+      for (var j = 0, feature; feature = feats[j]; ++j) {
+        features[feature] = true;
+      }
+    }
+    var libs = [];
+    for (var lib in features) {libs.push(lib);}
+    libs.sort();
+    libs = libs.join(":");
+
+    // TODO race condition exists here..
+    libs = "core:rpc";
+
+    for (var i = 0, gadget; gadget = gadgetList[i]; ++i) {
+      var newGadget = document.createElement("div");
+      newGadget.className = "gadget";
+
+      if (gadget.errors && gadget.errors.length > 0) {
+        newGadget.innerHTML = ["Unable to process gadget: ", gadget.url, ". Errors: <pre>", gadget.errors.join("\n"), "</pre>"].join("");
+        document.body.appendChild(newGadget);
+      } else {
+        newGadget.innerHTML = ['<h2>', gadget.title, '</h2>',
+          '<iframe src="', gadget.iframeUrl, '&debug=1&libs=', libs ,'#parent=http://localhost:8080/&rpcToken=1111" id="remote_iframe_', gadget.moduleId, '" name="remote_iframe_', gadget.moduleId, '" style="height: ', gadget.height,  'px"></iframe>'
+        ].join("");
+        $("#gadget_id_" + gadget.moduleId).html(newGadget);
+        gadgets.rpc.setupReceiver("remote_iframe_" + gadget.moduleId);
+      }
+    }
+  }
+
+  var request = {};
+  var gadgetlist = [];
+  $("os\\:gadget").each(function() {
+    var tag = $(this);
+    var mid = tag.attr('moduleId');
+    tag.attr("id", "gadget_id_" + mid);
+    tag.html("Loading...");
+    gadgetlist.push({url: tag.attr('url'), moduleId: mid});
+  });
+  // defaults
+  var context = {
+      country: "US",
+      language: "en",
+      view: "default",
+      container: "default",
+      debug: true
+  };
+
+  var os_config =   $("os\\:config");
+  if (os_config) {
+    context.country = os_config.attr('country') || context.country;
+    context.language = os_config.attr('language') || context.language;
+  }
+  var request = {
+    context: context,
+    gadgets: gadgetlist
+   };
+
+  var req = gadgets.json.stringify(request);
+
+  var script = document.createElement('script');
+  script.setAttribute('src', "/gadgets/metadata?callback=renderGadgets&req=" + req);
+  document.getElementsByTagName('head')[0].appendChild(script); 
+
+</script>
+</body>
+</html>

Modified: shindig/trunk/features/src/main/javascript/features/features.txt
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/features.txt?rev=945746&r1=945745&r2=945746&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Tue May 18 16:57:10 2010
@@ -59,6 +59,7 @@ features/rpc/feature.xml
 features/security-token/feature.xml
 features/setprefs/feature.xml
 features/settitle/feature.xml
+features/shindig.connect/feature.xml
 features/shindig.container/feature.xml
 features/skins/feature.xml
 features/swfobject/feature.xml

Added: shindig/trunk/features/src/main/javascript/features/shindig.connect/connect.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.connect/connect.js?rev=945746&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/shindig.connect/connect.js (added)
+++ shindig/trunk/features/src/main/javascript/features/shindig.connect/connect.js Tue May 18 16:57:10 2010
@@ -0,0 +1,7 @@
+
+gadgets.rpc.register('resize_iframe', function(height) {
+  var element = document.getElementById(this.f);
+  if (element) {
+    element.style.height = height + 'px';
+  }
+});

Added: shindig/trunk/features/src/main/javascript/features/shindig.connect/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/shindig.connect/feature.xml?rev=945746&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/shindig.connect/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/shindig.connect/feature.xml Tue May 18 16:57:10 2010
@@ -0,0 +1,29 @@
+<?xml version="1.0"?>
+<!--
+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.
+-->
+<feature>
+  <name>shindig-connect</name>
+  <dependency>globals</dependency>
+  <dependency>rpc</dependency>
+  <dependency>osapi</dependency>
+  <dependency>core</dependency>
+  <dependency>org.jquery.core-1.4.2</dependency>
+  <container>
+    <script src="connect.js"/>
+  </container>
+</feature>