Author: doll
Date: Thu Mar 13 09:17:49 2008
New Revision: 636794

URL: http://svn.apache.org/viewvc?rev=636794&view=rev
Log:
Added an activities demo gadget and put some activities in the state file. 
These don't work right now. 

Also cleaned up bad tab characters in SocialHelloWorld and fixed css styles in 
the sample container.


Added:
    
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialActivitiesWorld.xml
Modified:
    
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialHelloWorld.xml
    incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html
    incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml

Added: 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialActivitiesWorld.xml
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/examples/SocialActivitiesWorld.xml?rev=636794&view=auto
==============================================================================
--- 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialActivitiesWorld.xml
 (added)
+++ 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialActivitiesWorld.xml
 Thu Mar 13 09:17:49 2008
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Module>
+ <ModulePrefs title="Social Activities World">
+   <Require feature="opensocial-0.7"></Require>
+   <Require feature="dynamic-height"></Require>
+ </ModulePrefs>
+ <Content type="html">
+   <![CDATA[
+<style type="text/css">
+  .streamtitle,
+  .socialHeading {
+    font-family:arial,helvetica,sans-serif;
+    font-size:13pt;
+    font-weight:bold;
+  }
+
+  .streamtitle {
+    background-color: #E0ECFF;
+    border-top 1px solid: blue;
+    padding: .25em;
+  }
+
+  .socialDescription a {
+    color:#999999;
+  }
+
+  .streamdescription,
+  .streamdescription a,
+  .streamdescription a:visited {
+    color:#408BFE;
+    font-size:12pt;
+    font-weight:bold;
+    text-decoration:underline;
+    font-family:arial,helvetica,sans-serif;
+  }
+
+  .streamurl a {
+    color:#008000;
+    font-size:10pt;
+    font-family:arial,helvetica,sans-serif;
+    text-decoration:underline;
+  }
+
+  .streamrow {
+    clear: both;
+  }
+
+  .streamrowline {
+    border-bottom:1px solid #DDE9F5;
+    clear:both;
+    height:0px;
+    margin:5px;
+  }
+
+  .streamcontents {
+    padding: .5em;
+  }
+
+  .streamhtmlcontents {
+    color:#333333;
+    font-size:10pt;
+    line-height:130%;
+    padding:2px 0pt 3px 10px;
+    font-family:arial,helvetica,sans-serif;
+  }
+
+  .mediaitems {
+    padding-left: 5em;
+  }
+
+  .addActivityDiv {
+    clear:both;
+    padding-bottom:15px;
+  }
+
+  #addActivityText {
+    color:#999999;
+    font-size:10pt;
+    font-weight:normal;
+    font-family:arial,helvetica,sans-serif;
+  }
+
+  .leftcolumn {
+    float: left;
+    width: 47%;
+  }
+
+  .rightcolumn {
+    float: right;
+    width: 47%;
+  }
+</style>
+
+<script type="text/javascript">
+
+gadgets.util.registerOnLoadHandler(refreshActivities);
+
+function refreshActivities() {
+  var req = opensocial.newDataRequest();
+  if (!viewer) {
+    req.add(req.newFetchPersonRequest('VIEWER'), 'viewer');
+  }
+  req.add(req.newFetchActivitiesRequest('VIEWER'), 'viewerActivities');
+  req.add(req.newFetchActivitiesRequest('VIEWER_FRIENDS'), 'activities');
+  req.send(handleActivities);
+}
+
+function postNewActivity() {
+  var activityElement = document.getElementById('newActivity');
+  var mediaItem = [opensocial.newActivityMediaItem("image", 
viewer.getField('thumbnailUrl'), {'type' : 'IMAGE'})];
+  var activity = opensocial.newActivity({ 'title' : viewer.getDisplayName() + 
' wrote: ' + activityElement.value,
+    'body' : 'write back!', 'mediaItems' : mediaItem});
+
+  activityElement.value = '';
+  opensocial.requestCreateActivity(activity, "HIGH", refreshActivities);
+}
+
+var viewer;
+var activities;
+function handleActivities(dataResponse) {
+  if (!viewer) {
+    viewer = dataResponse.get('viewer').getData();
+  }
+  activities = 
dataResponse.get('viewerActivities').getData()['activities'].asArray();
+  activities = 
activities.concat(dataResponse.get('activities').getData()['activities'].asArray());
+  document.getElementById('stream').style.display = 'block';
+
+  var html = '';
+  if (!activities || activities.length == 0) {
+    document.getElementById('stream').innerHTML = 'You do not have any 
activities yet';
+    return;
+  }
+
+  for (var i = 0; i < activities.length; i++) {
+    html += '<div class="streamrow">';
+
+    html += '<div class="streamdescription"><a href="' + activities[i].url + 
'">' + activities[i].getField('title') + '</a></div>';
+
+    html += '<div class="streamcontents">';
+    html += '<img 
src="http://www.google.com/s2/sharing/resources/static/images/quot.png?hl=en_US"/>'
+
+    var body = activities[i].getField('body') || '';
+    html += '<span class="streamhtmlcontents">' + body + '</span>';
+    html += '</div>';
+
+    html += '<div class="mediaitems">';
+    var mediaItems = activities[i].getField('mediaItems');
+    if (mediaItems) {
+      for (var j = 0; j < mediaItems.length; j++) {
+        if (mediaItems[j].getField('type') == 'IMAGE') {
+          html += '<img height="150px" style="padding-right:.5em;" src="' + 
mediaItems[j].getField('url') + '"/>';
+        }
+      }
+    }
+    html += '</div>';
+
+    var shortUrl = activities[i].getField('url');
+    if (shortUrl) {
+      if (shortUrl.indexOf('http://') == 0) {
+        shortUrl = shortUrl.substring(7);
+      }
+      html += '<div class="streamurl"><a href="' + 
activities[i].getField('url') + '">' + shortUrl + '</a></div>';
+    }
+
+    html += '</div>';
+    html += '<div class="streamrowline"></div>';
+  }
+  document.getElementById('stream').innerHTML = html;
+  gadgets.window.adjustHeight();
+}
+
+function hideShowDiv(divToShow, divToHide) {
+  document.getElementById(divToShow).style.display = 'block';
+  document.getElementById(divToHide).style.display = 'none';
+}
+</script>
+
+<div class="streamtitle">Activities from your friends</div>
+<div class="addActivityDiv">
+  <a id="addActivityText" href="#" 
onclick="hideShowDiv('addActivity','addActivityText'); return false;"> Add your 
own activity </a>
+  <span id="addActivity" style="display:none; border: 2px solid steelblue; 
padding: .5em;">
+    <input id="newActivity" type="text"></input>
+    <input type="button" onclick="postNewActivity(); return false;" 
value="add"></input>
+    <input type="button" 
onclick="hideShowDiv('addActivityText','addActivity'); return false;" 
value="cancel"></input>
+  </span>
+</div>
+<div id="stream" style="display:none"></div>
+
+]]>
+</Content>
+</Module>
\ No newline at end of file

Modified: 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialHelloWorld.xml
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/examples/SocialHelloWorld.xml?rev=636794&r1=636793&r2=636794&view=diff
==============================================================================
--- 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialHelloWorld.xml
 (original)
+++ 
incubator/shindig/trunk/javascript/samplecontainer/examples/SocialHelloWorld.xml
 Thu Mar 13 09:17:49 2008
@@ -8,43 +8,43 @@
    <![CDATA[
    <style type="text/css">
      #helloworlds {
-       margin: 20px;
-       font-family: arial, sans-serif;
-       width: 310px;
+       margin: 20px;
+       font-family: arial, sans-serif;
+       width: 310px;
      }
 
      div.person img {
-       margin-bottom: 10px;
+       margin-bottom: 10px;
      }
 
      div.bubble {
-       background-image: 
url(/gadgets/files/samplecontainer/examples/bubble.gif);
-       background-repeat: no-repeat;
-       width: 202px;
-       height: 66px;
-       padding: 12px 0px 0px 12px;
-       font-weight: bold;
-       font-size: 18px;
-       float: right;
-    }
+       background-image: 
url(/gadgets/files/samplecontainer/examples/bubble.gif);
+       background-repeat: no-repeat;
+       width: 202px;
+       height: 66px;
+       padding: 12px 0px 0px 12px;
+       font-weight: bold;
+       font-size: 18px;
+       float: right;
+     }
 
-    .c0 { color: #008000; }
-    .c1 { color: #FF8A00; }
-    .c2 { color: #7777CC; }
-    .c3 { color: #008000; }
-    .c4 { color: #CC0000; }
-    .c5 { color: #73A6FF; }
+     .c0 { color: #008000; }
+     .c1 { color: #FF8A00; }
+     .c2 { color: #7777CC; }
+     .c3 { color: #008000; }
+     .c4 { color: #CC0000; }
+     .c5 { color: #73A6FF; }
 
-    div.name {
-       width: 150px;
-       text-align: right;
-       font-weight: normal;
-       font-size: 12px;
-       color: #999;
-       position:relative;
-       top: 10px;
-       right: -35px;
-    }
+     div.name {
+       width: 150px;
+       text-align: right;
+       font-weight: normal;
+       font-size: 12px;
+       color: #999;
+       position:relative;
+       top: 10px;
+       right: -35px;
+     }
    </style>
 
    <script type="text/javascript">

Modified: 
incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html?rev=636794&r1=636793&r2=636794&view=diff
==============================================================================
--- incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html 
(original)
+++ incubator/shindig/trunk/javascript/samplecontainer/samplecontainer.html Thu 
Mar 13 09:17:49 2008
@@ -21,6 +21,16 @@
     float: right;
   }
 
+  .gadgets-gadget-chrome {
+    width: 60%;
+    float: none;
+    margin: auto;
+  }
+
+  .gadgets-gadget {
+    width: 100%;
+  }
+
 </style>
 <script type="text/javascript" src="../../js/rpc.js?c=1&debug=1"></script>
 <script type="text/javascript" src="../container/cookies.js"></script>
@@ -253,6 +263,6 @@
   </div>
 
   <div id="gadgetState" style="font-size:smaller"></div>
-  <div id="gadget-chrome" class="gadgets-gadget-chrome" 
style="width:80%;"></div>
+  <div id="gadget-chrome" class="gadgets-gadget-chrome"></div>
 </body>
 </html>

Modified: 
incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml?rev=636794&r1=636793&r2=636794&view=diff
==============================================================================
--- 
incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml 
(original)
+++ 
incubator/shindig/trunk/javascript/samplecontainer/state-basicfriendlist.xml 
Thu Mar 13 09:17:49 2008
@@ -13,4 +13,18 @@
     <data person="jane.doe" field="count">7</data>
   </personAppData>
 
+  <activities>
+    <stream title="jane's photos" userId="jane.doe">
+      <activity title="Jane just posted a photo of a monkey" id="1"
+          body="and she thinks you look like him!">
+        <mediaItem type="IMAGE" mimeType="image/jpeg" 
url="http://animals.nationalgeographic.com/staticfiles/NGS/Shared/StaticFiles/animals/images/primary/black-spider-monkey.jpg";></mediaItem>
+        <mediaItem type="IMAGE" mimeType="image/jpeg" 
url="http://image.guardian.co.uk/sys-images/Guardian/Pix/gallery/2002/01/03/monkey300.jpg";></mediaItem>
+      </activity>
+      <activity title="Jane says George likes yoda!" id="1"
+          body="or is it you?">
+        <mediaItem type="IMAGE" mimeType="image/jpeg" 
url="http://www.funnyphotos.net.au/images/fancy-dress-dog-yoda-from-star-wars1.jpg";></mediaItem>
+      </activity>
+    </stream>
+  </activities>
+
 </container>


Reply via email to