You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shindig.apache.org by aw...@apache.org on 2009/04/14 19:47:54 UTC

svn commit: r764899 - in /incubator/shindig/trunk/java: common/conf/ common/src/main/java/org/apache/shindig/expressions/ common/src/test/java/org/apache/shindig/expressions/ gadgets/src/main/java/org/apache/shindig/gadgets/templates/ gadgets/src/test/...

Author: awiner
Date: Tue Apr 14 17:47:53 2009
New Revision: 764899

URL: http://svn.apache.org/viewvc?rev=764899&view=rev
Log:
Per spec discussion, stop using the standard opensocial namespace for template extensions.
Instead, use xmlns:osx="http://ns.opensocial.org/2009/extensions", and rename the tags and functions to remove "x":
  - os:xFlash becomes osx:Flash
  - os:xParseJson() becomes osx:parseJson()
  - os:xDecodeBase64 becomes osx:decodeBase64()
  - os:xUrlEncode() becomes osx:urlEncode()
  - os:xUrlDecode() becomes osx:urlDecode()

Modified:
    incubator/shindig/trunk/java/common/conf/shindig.properties
    incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/expressions/OpensocialFunctions.java
    incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/FunctionsTest.java
    incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/OpensocialFunctionsTest.java
    incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/FlashTagHandler.java
    incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/FlashTagHandlerTest.java

Modified: incubator/shindig/trunk/java/common/conf/shindig.properties
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/conf/shindig.properties?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/conf/shindig.properties (original)
+++ incubator/shindig/trunk/java/common/conf/shindig.properties Tue Apr 14 17:47:53 2009
@@ -34,6 +34,9 @@
 shindig.image-rewrite.jpeg-compression = 0.75
 shindig.image-rewrite.min-threshold-bytes = 200
 
+# Configuration for template rewriter
+shindig.template-rewrite.extension-tag-namespace=http://ns.opensocial.org/2009/extensions
+
 # These values provide default TTLs for HTTP responses that don't use caching headers.
 shindig.cache.http.defaultTtl=3600000
 shindig.cache.http.negativeCacheTtl=60000

Modified: incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/expressions/OpensocialFunctions.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/expressions/OpensocialFunctions.java?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/expressions/OpensocialFunctions.java (original)
+++ incubator/shindig/trunk/java/common/src/main/java/org/apache/shindig/expressions/OpensocialFunctions.java Tue Apr 14 17:47:53 2009
@@ -39,7 +39,7 @@
   /**
    * Convert a string to a JSON Object or JSON Array.
    */
-  @Functions.Expose(prefix = "os", names = {"xParseJson"})
+  @Functions.Expose(prefix = "osx", names = {"parseJson"})
   public static Object parseJson(String text) {
     if ((text == null) || "".equals(text)) {
       return null;
@@ -59,7 +59,7 @@
   /**
    * Decode a base-64 encoded string.
    */
-  @Functions.Expose(prefix = "os", names = {"xDecodeBase64"})
+  @Functions.Expose(prefix = "osx", names = {"decodeBase64"})
   public static String decodeBase64(String text) {
     try {
       // TODO: allow a charset to be passed in?
@@ -74,7 +74,7 @@
   /**
    * Form encode a string
    */
-  @Functions.Expose(prefix = "os", names = {"xUrlEncode"})
+  @Functions.Expose(prefix = "osx", names = {"urlEncode"})
   public static String formEncode(String text) {
     return Utf8UrlCoder.encode(text);
   }
@@ -84,7 +84,7 @@
    * @param text
    * @return
    */
-  @Functions.Expose(prefix = "os", names = {"xUrlDecode"})
+  @Functions.Expose(prefix = "osx", names = {"urlDecode"})
   public static String formDecode(String text) {
     return Utf8UrlCoder.decode(text);
   }

Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/FunctionsTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/FunctionsTest.java?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/FunctionsTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/FunctionsTest.java Tue Apr 14 17:47:53 2009
@@ -57,7 +57,7 @@
     Injector injector = Guice.createInjector();
     functions = injector.getInstance(Functions.class);
     
-    Method toJson = functions.resolveFunction("os", "xParseJson");
+    Method toJson = functions.resolveFunction("osx", "parseJson");
     Object o = toJson.invoke(null, "{a : 1}");
     assertTrue(o instanceof JSONObject);
     assertEquals(1, ((JSONObject) o).getInt("a"));

Modified: incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/OpensocialFunctionsTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/OpensocialFunctionsTest.java?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/OpensocialFunctionsTest.java (original)
+++ incubator/shindig/trunk/java/common/src/test/java/org/apache/shindig/expressions/OpensocialFunctionsTest.java Tue Apr 14 17:47:53 2009
@@ -42,13 +42,13 @@
   
   public void testParseJsonObject() {
     ValueExpression testParseJsonObject =
-      expressions.parse("${os:xParseJson('{a: 1}').a}", Integer.class);
+      expressions.parse("${osx:parseJson('{a: 1}').a}", Integer.class);
     assertEquals(1, testParseJsonObject.getValue(context));
   }
 
   public void testParseJsonArray() {
     ValueExpression testParseJsonArray =
-      expressions.parse("${os:xParseJson('[1, 2, 3]')[1]}", Integer.class);
+      expressions.parse("${osx:parseJson('[1, 2, 3]')[1]}", Integer.class);
     assertEquals(2, testParseJsonArray.getValue(context));
   }
   
@@ -58,7 +58,7 @@
     vars.put("encoded", encoded);
     
     ValueExpression testDecodeBase64 =
-      expressions.parse("${os:xDecodeBase64(encoded)}", String.class);
+      expressions.parse("${osx:decodeBase64(encoded)}", String.class);
     assertEquals("12345", testDecodeBase64.getValue(context));
   }
 
@@ -67,7 +67,7 @@
     vars.put("test", test);
 
     ValueExpression testUrlEncode =
-      expressions.parse("${os:xUrlEncode(test)}", String.class);
+      expressions.parse("${osx:urlEncode(test)}", String.class);
     assertEquals("He+He", testUrlEncode.getValue(context));
   }
 
@@ -76,7 +76,7 @@
     vars.put("encoded", test);
 
     ValueExpression testUrlDecode =
-      expressions.parse("${os:xUrlDecode(encoded)}", String.class);
+      expressions.parse("${osx:urlDecode(encoded)}", String.class);
     assertEquals("He He", testUrlDecode.getValue(context));
   }
 }

Modified: incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/FlashTagHandler.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/FlashTagHandler.java?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/FlashTagHandler.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/templates/FlashTagHandler.java Tue Apr 14 17:47:53 2009
@@ -21,6 +21,7 @@
 import com.google.common.collect.Maps;
 import com.google.common.collect.ImmutableSet;
 import com.google.inject.Inject;
+import com.google.inject.name.Named;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.StringEscapeUtils;
@@ -53,7 +54,7 @@
 
   static final String FLASH_MIN_VER = "9.0.115";
   static final String SWFOBJECT = "swfobject";
-  static final String TAG_NAME = "xFlash";
+  static final String TAG_NAME = "Flash";
 
   private final BeanJsonConverter beanConverter;
   private final GadgetFeatureRegistry featureRegistry;
@@ -65,8 +66,9 @@
   private static final String ALT_CONTENT_PREFIX = "os_xFlash_alt_";
 
   @Inject
-  public FlashTagHandler(BeanJsonConverter beanConverter, GadgetFeatureRegistry featureRegistry) {
-    super(TagHandler.OPENSOCIAL_NAMESPACE, TAG_NAME);
+  public FlashTagHandler(BeanJsonConverter beanConverter, GadgetFeatureRegistry featureRegistry,
+      @Named("shindig.template-rewrite.extension-tag-namespace") String namespace) {
+    super(namespace, TAG_NAME);
     this.beanConverter = beanConverter;
     this.featureRegistry = featureRegistry;
   }

Modified: incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/FlashTagHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/FlashTagHandlerTest.java?rev=764899&r1=764898&r2=764899&view=diff
==============================================================================
--- incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/FlashTagHandlerTest.java (original)
+++ incubator/shindig/trunk/java/gadgets/src/test/java/org/apache/shindig/gadgets/templates/FlashTagHandlerTest.java Tue Apr 14 17:47:53 2009
@@ -76,7 +76,8 @@
     documentProvider = injector.getInstance(DOMImplementation.class);
     parser = injector.getInstance(SocialMarkupHtmlParser.class);
     featureRegistry = mock(GadgetFeatureRegistry.class);
-    handler = new FlashTagHandler(new BeanJsonConverter(injector), featureRegistry);
+    handler = new FlashTagHandler(new BeanJsonConverter(injector), featureRegistry,
+        "http://example.org/ns");
     result = parser.parseDom("");
 
     EasyMock.expect(gadget.getContext()).andReturn(gadgetContext).anyTimes();
@@ -98,10 +99,10 @@
   public void testBasicRender() throws Exception {
     Document document = parser.parseDom(
         "<script type='text/os-template'>"
-            + "<os:xFlash swf='http://www.example.org/test.swf'>"
+            + "<osx:Flash swf='http://www.example.org/test.swf'>"
             + "Click Me"
-          + "</os:xFlash></script>");
-    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("os:xflash"))
+          + "</osx:Flash></script>");
+    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("osx:flash"))
         .get(0);
 
     expectSecurityToken();
@@ -123,10 +124,10 @@
   public void testSanitizedRender() throws Exception {
     Document document = parser.parseDom(
         "<script type='text/os-template'>"
-            + "<os:xFlash swf='http://www.example.org/test.swf'>"
+            + "<osx:Flash swf='http://www.example.org/test.swf'>"
             + "Click Me"
-          + "</os:xFlash></script>");
-    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("os:xflash"))
+          + "</osx:Flash></script>");
+    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("osx:flash"))
         .get(0);
 
     expectSecurityToken();
@@ -149,10 +150,10 @@
   public void testSanitizedRenderClickToPlay() throws Exception {
     Document document = parser.parseDom(
         "<script type='text/os-template'>"
-            + "<os:xFlash swf='http://www.example.org/test.swf' play='onclick'>"
+            + "<osx:flash swf='http://www.example.org/test.swf' play='onclick'>"
             + "Click Me"
-          + "</os:xFlash></script>");
-    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("os:xflash"))
+          + "</osx:flash></script>");
+    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("osx:flash"))
         .get(0);
 
     expectSecurityToken();
@@ -224,10 +225,10 @@
   public void testConfigBindingFailure() throws Exception {
     Document document = parser.parseDom(
         "<script type='text/os-template'>"
-            + "<os:xFlash swf='http://www.example.org/test.swf' play='junk'>"
+            + "<osx:flash swf='http://www.example.org/test.swf' play='junk'>"
             + "Click Me"
-          + "</os:xFlash></script>");
-    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("os:xflash"))
+          + "</osx:flash></script>");
+    Element tag = DomUtil.getElementsByTagNameCaseInsensitive(document, ImmutableSet.of("osx:flash"))
         .get(0);
     handler.process(result.getDocumentElement().getFirstChild().getNextSibling(), tag, processor);
     XPathWrapper wrapper = new XPathWrapper(result);