You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wookie.apache.org by rg...@apache.org on 2011/10/26 16:24:41 UTC

svn commit: r1189232 - in /incubator/wookie/trunk/widgets/templates: ./ browse/ itemDetail/ testWidgets/browseTestWidget/

Author: rgardler
Date: Wed Oct 26 14:24:40 2011
New Revision: 1189232

URL: http://svn.apache.org/viewvc?rev=1189232&view=rev
Log:
Use Twitter in the browse widget test, a little more familiar to most users.

Added:
    incubator/wookie/trunk/widgets/templates/itemDetail/
    incubator/wookie/trunk/widgets/templates/itemDetail/index.html
    incubator/wookie/trunk/widgets/templates/itemDetail/template_build.xml
    incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/detail2html.xsl
    incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/index2html.xsl
Modified:
    incubator/wookie/trunk/widgets/templates/browse/readme.txt
    incubator/wookie/trunk/widgets/templates/readme.txt
    incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/content_primary.html
    incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/widget.properties

Modified: incubator/wookie/trunk/widgets/templates/browse/readme.txt
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/browse/readme.txt?rev=1189232&r1=1189231&r2=1189232&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/browse/readme.txt (original)
+++ incubator/wookie/trunk/widgets/templates/browse/readme.txt Wed Oct 26 14:24:40 2011
@@ -13,7 +13,9 @@ This section describes how the template 
 
 The initial results list is generated by retrieving and XML document from the URL defined by
 "browse.index.url". This document is then transformed into HTML using a stylesheet defined
-in "browse.index.xsl.url" which degaults to "index2html.xsl".
+in "browse.index.xsl.url" which degaults to "index2html.xsl". We recommend copying this 
+stylesheet to your widget definition and editing it to process the data returned by your
+API.
 
 If a search had been performed in the form provided then the results are retrieved from the 
 URL defined by "browse.search.url". Note that the variable "query" defines the search string
@@ -21,6 +23,13 @@ entered by the user.
 
 The results are displayed in an accordion control.
 
+*** Item identifiers
+
+When generating the results list you need to ensure that each item has an attribute "wid" which
+contains the ID of the item in question. This is later used for retrieving the details about that
+item. See the templates example "index2html.xsl" or the "testWidgets/browseTestWidget/index2html.xsl"
+for examples.
+
 ** Result detail
 
 When an item is expanded an ajax request is made to retrieve the details of the item in question.
@@ -29,4 +38,6 @@ identifier for this item.
  
 The XML returned is then transformed using XSLT to provide the HTML content that will be inserted
 into the expanded control. The location of the XSLT file is defined by "browse.detail.xsl.url" and
-defaults to "detail2html.xsl" 
\ No newline at end of file
+defaults to "detail2html.xsl". We recommend copying this 
+stylesheet to your widget definition and editing it to process the data returned by your
+API.
\ No newline at end of file

Added: incubator/wookie/trunk/widgets/templates/itemDetail/index.html
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/itemDetail/index.html?rev=1189232&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/templates/itemDetail/index.html (added)
+++ incubator/wookie/trunk/widgets/templates/itemDetail/index.html Wed Oct 26 14:24:40 2011
@@ -0,0 +1,63 @@
+<!--
+  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.
+-->
+<!DOCTYPE html> 
+<html>
+  <head>
+    <meta http-equiv="pragma" content="no-cache"/>
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1"> 
+
+    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.css" />
+    <script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
+    <script type="text/javascript" src="http://code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>
+
+    <link rel="stylesheet" href="style/all.css" />
+
+    <script type="text/javascript" src="scripts/controller.js"></script>
+			
+    <title>${widget.name}</title>		
+  </head>
+
+  <body>
+    <div data-role="page" class="type-home" id="home"  data-theme="d" >
+      <div data-role="header">
+          ${content.header}
+      </div> <!-- /header -->
+
+      <div data-role="content">
+        <div class="content-primary">
+          ${content.primary}
+        </div>  <!-- /content-primary -->
+      </div> <!-- /content -->
+
+      <div data-role="footer" class="footer">
+		  ${content.footer}
+      </div> <!-- /footer -->
+    </div> <!-- /page -->		
+
+    <div data-role="dialog" id="help">
+      <div data-role="header">
+	<h4>Help: ${widget.name}</h4>
+      </div> <!-- /header -->
+		
+      <div data-role="content" class="ui-content" id="content-help">	
+        ${widget.help}
+      </div><!-- /content -->
+    </div><!-- /page -->
+
+  </body>
+</html>

Added: incubator/wookie/trunk/widgets/templates/itemDetail/template_build.xml
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/itemDetail/template_build.xml?rev=1189232&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/templates/itemDetail/template_build.xml (added)
+++ incubator/wookie/trunk/widgets/templates/itemDetail/template_build.xml Wed Oct 26 14:24:40 2011
@@ -0,0 +1,90 @@
+<?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.
+-->
+<project basedir="." name="itemDetail_template">
+
+  <target name="_init_template"
+          description="Define any template specifc properties">
+    <echo message="+------------------------------------------"/>
+    <echo message="|  Initialising template properties"/>
+    <echo message="+------------------------------------------"/>
+
+	<loadfile property="content.header"
+			  srcFile="content_header.html"
+			  failonerror="false">
+		<filterchain>
+		  <expandproperties/>
+		</filterchain>
+	</loadfile>
+	
+    <loadfile property="content.header"
+              srcFile="${template.dir}/${template.name}/content_header.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
+    <!-- load content from widget definition -->
+    <loadfile property="content.primary"
+              srcFile="content_primary.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
+    <!-- load content from template definition -->
+    <loadfile property="content.primary"
+              srcFile="${template.dir}/${template.name}/content_primary.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+
+    <loadfile property="content.footer"
+              srcFile="content_footer.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+	
+    <loadfile property="content.footer"
+              srcFile="${template.dir}/${template.name}/content_footer.html"
+              failonerror="false">
+        <filterchain>
+          <expandproperties/>
+        </filterchain>
+    </loadfile>
+	
+    <echoproperties destfile="${widget.build.dir}/${widget.shortname}.properties" prefix=""/>
+  </target>
+
+  <target name="_generate_from_parent_templates">
+    <echo message="+------------------------------------------"/>
+    <echo message="|  There are no parent templates for ${template.name}"/>
+    <!-- <echo message="|  Generating from parent templates for ${template.name}"/>  -->
+    <echo message="+------------------------------------------"/>
+
+    <ant antfile="../../build.xml"
+         target="_generate_widget">
+         <property name="template.name" value="base"/>
+    </ant>
+  </target>
+</project>
\ No newline at end of file

Modified: incubator/wookie/trunk/widgets/templates/readme.txt
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/readme.txt?rev=1189232&r1=1189231&r2=1189232&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/readme.txt (original)
+++ incubator/wookie/trunk/widgets/templates/readme.txt Wed Oct 26 14:24:40 2011
@@ -60,7 +60,7 @@ These properties can then be reused in a
 "${property.name}". When the template is used to create a widget these 
 properties will be expanded.
 
-Alternatively properties can values can be provided in files. This is 
+Alternatively properties values can be provided in files. This is 
 useful for properties that are intended to contain lots of information 
 or formatting, such as HTML snippets.
 

Modified: incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/content_primary.html
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/content_primary.html?rev=1189232&r1=1189231&r2=1189232&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/content_primary.html (original)
+++ incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/content_primary.html Wed Oct 26 14:24:40 2011
@@ -16,6 +16,7 @@
 -->
 <h2>Results</h2>
 
-<p>This is the results for ${widget.name} will appear.</p>
+<p>This is the results for ${widget.name} will appear. This content will
+be removed when results have been retrieved.</p>
 
 <p>The description of this widget is "${widget.description}"</p>

Added: incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/detail2html.xsl
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/detail2html.xsl?rev=1189232&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/detail2html.xsl (added)
+++ incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/detail2html.xsl Wed Oct 26 14:24:40 2011
@@ -0,0 +1,70 @@
+<!--
+  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.
+-->
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+	<xsl:template match="/">
+		<xsl:apply-templates />
+	</xsl:template>
+
+	<xsl:template match="status">
+		<div class="tweet">
+			<div class="overview">
+				<div class="thumbnail">
+					<xsl:apply-templates select="user/profile_image_url" />
+				</div>
+				<div class="description"><xsl:value-of select="text"/></div>
+			</div>
+			<div class="meta-data">
+				<div class="clear">
+					<xsl:apply-templates select="user" />
+					<xsl:apply-templates select="created-at" />
+				</div>
+				<div class="clear">
+					<xsl:apply-templates select="hashtags" />
+				</div>
+			</div>
+		</div>
+	</xsl:template>
+
+	<xsl:template match="hashtags">
+		<span class="type">
+			<xslfor-each select="hashtag">
+			  <xsl:value-of select="hashtag" />
+			</xslfor-each>
+		</span>
+	</xsl:template>
+
+	<xsl:template match="user">
+		<span class="uploader">
+			<xsl:value-of select="name"/> (<xsl:value-of select="screen_name" />)
+		</span>
+	</xsl:template>
+
+	<xsl:template match="profile_image_url">
+		<img alt="Avatar for tweet author">
+			<xsl:attribute name="src"><xsl:value-of select="." /></xsl:attribute>
+		</img>
+	</xsl:template>
+
+	<xsl:template match="created-at">
+		<span class="update">
+			<xsl:value-of select="." />
+		</span>
+	</xsl:template>
+
+</xsl:stylesheet>

Added: incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/index2html.xsl
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/index2html.xsl?rev=1189232&view=auto
==============================================================================
--- incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/index2html.xsl (added)
+++ incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/index2html.xsl Wed Oct 26 14:24:40 2011
@@ -0,0 +1,64 @@
+<!--
+  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.
+-->
+<xsl:stylesheet version="1.0"
+	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+	xmlns:atom="http://www.w3.org/2005/Atom">
+
+	<!-- Index requests return a custom XML format -->
+	<xsl:template match="statuses">
+		<div id="results" data-role="collapsible-set">
+			<xsl:apply-templates/>
+		</div>
+	</xsl:template>
+
+	<!-- Search requests return an ATOM feed -->
+	<xsl:template match="atom:feed">
+	  <div id="results" data-role="collapsible-set">
+	  	<xsl:apply-templates/>
+	  </div>
+	</xsl:template>
+
+	<xsl:template match="status">
+      <div class='result' data-role='collapsible'>
+        <xsl:attribute name="wid">
+          <xsl:value-of select="./id"/>
+        </xsl:attribute>
+	  
+	    <h3><xsl:value-of select="./text"/></h3>
+	    <div class="detail">
+	      <p>Loading...</p>
+        </div>
+      </div>
+	</xsl:template>
+
+	<xsl:template match="atom:entry">
+	  <div class='result' data-role='collapsible'>
+        <xsl:attribute name="wid">
+        	<xsl:value-of select="substring-after(substring-after(atom:id, ':'), ':')"/>
+        </xsl:attribute>
+	  
+	    <h3><xsl:value-of select="./atom:title"/></h3>
+	    <div class="detail">
+	      <p>Loading...</p>
+        </div>
+      </div>
+	</xsl:template>
+
+	<xsl:template match="text( )|@*"/>
+
+</xsl:stylesheet>
+

Modified: incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/widget.properties
URL: http://svn.apache.org/viewvc/incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/widget.properties?rev=1189232&r1=1189231&r2=1189232&view=diff
==============================================================================
--- incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/widget.properties (original)
+++ incubator/wookie/trunk/widgets/templates/testWidgets/browseTestWidget/widget.properties Wed Oct 26 14:24:40 2011
@@ -1,7 +1,9 @@
 template.name=browse
 widget.shortname=BrowseTestWidget
-widget.name=Browse Test Widget
-widget.description=This is a demonstration of the browse interface.
-widget.help=<p>The search/results panel will only be visible if there is enough screen space available or if the user clicks on the heading to make it expand.</p>
+widget.name=Browse Test Widget (Browse Twitter)
+widget.description=This is a demonstration of the browse interface. It pulls the latest Tweets from the Twitter public timeline.
+widget.help=<p>Initially this widget displays the most recent tweets in the Twitter timeline.</p> <p>You can expand the search form and enter a search term to search for the most recent tweets containing a given search query.</p>
 
-browse.index.url="http://www.myexperiment.org/users.xml?sort=updated&order=reverse"
\ No newline at end of file
+browse.index.url="http://api.twitter.com/1/statuses/public_timeline.xml"
+browse.search.url="http://search.twitter.com/search.atom?q=" + query + "&rpp=10&include_entities=true&with_twitter_user_id=true&result_type=mixed"
+browse.get.detail.url="http://api.twitter.com/1/statuses/show.xml?id=" + itemId + "&include_entities=true"
\ No newline at end of file