shindig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mherma...@apache.org
Subject svn commit: r1101304 - in /shindig/trunk/features/src: main/javascript/features/ main/javascript/features/core.util.dom/ main/javascript/features/core.util.string/ main/javascript/features/core.util.urlparams/ main/javascript/features/core.util/ test/j...
Date Tue, 10 May 2011 03:52:01 GMT
Author: mhermanto
Date: Tue May 10 03:52:01 2011
New Revision: 1101304

URL: http://svn.apache.org/viewvc?rev=1101304&view=rev
Log:
(Start of) breaking up core.util into core.util.dom and core.util.string.
http://codereview.appspot.com/4538045/

Added:
    shindig/trunk/features/src/main/javascript/features/core.util.string/
    shindig/trunk/features/src/main/javascript/features/core.util.string/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util.string/string.js
    shindig/trunk/features/src/main/javascript/features/core.util.string/taming.js
    shindig/trunk/features/src/main/javascript/features/core.util.urlparams/taming.js
Modified:
    shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js
    shindig/trunk/features/src/main/javascript/features/core.util.urlparams/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util/taming.js
    shindig/trunk/features/src/main/javascript/features/core.util/util.js
    shindig/trunk/features/src/main/javascript/features/features.txt
    shindig/trunk/features/src/test/javascript/features/alltests.js

Modified: shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js Tue May 10 03:52:01
2011
@@ -29,7 +29,7 @@
 gadgets.util = gadgets.util || {};
 
 (function() {  
-  
+
   var XHTML_SPEC = 'http://www.w3.org/1999/xhtml';
 
   /**
@@ -47,8 +47,7 @@ gadgets.util = gadgets.util || {};
     }
     return element || document.createElement(tagName);
   };
-  
-  
+
   /**
    * Gets the HTML or XHTML body element.
    * @return {Element} The DOM node representing body.

Added: shindig/trunk/features/src/main/javascript/features/core.util.string/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.string/feature.xml?rev=1101304&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.string/feature.xml (added)
+++ shindig/trunk/features/src/main/javascript/features/core.util.string/feature.xml Tue May
10 03:52:01 2011
@@ -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>core.util.string</name>
+  <dependency>globals</dependency>
+  <all>
+    <script src="string.js"/>
+    <script src="taming.js" caja="1"/>
+    <api>
+      <exports type="js">gadgets.util.unescapeString</exports>
+    </api>
+  </all>
+</feature>

Added: shindig/trunk/features/src/main/javascript/features/core.util.string/string.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.string/string.js?rev=1101304&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.string/string.js (added)
+++ shindig/trunk/features/src/main/javascript/features/core.util.string/string.js Tue May
10 03:52:01 2011
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+
+/**
+ * @fileoverview General purpose utilities that gadgets can use.
+ */
+
+/**
+ * @static
+ * @class Provides a thin method for parsing url parameters.
+ * @name gadgets.util
+ */
+gadgets.util = gadgets.util || {};
+
+(function() {
+
+  /**
+   * Regular expression callback that returns strings from unicode code points.
+   *
+   * @param {Array} match Ignored.
+   * @param {number} value The codepoint value to convert.
+   * @return {string} The character corresponding to value.
+   */
+  function unescapeEntity(match, value) {
+    // TODO: b0rked for UTF-16 and can easily be convinced to generate
+    // truncating NULs or completely invalid non-Unicode characters. Here's a
+    // fixed version (it handles entities for valid codepoints from U+0001 ...
+    // U+10FFFD, except for the non-character codepoints U+...FFFE and
+    // U+...FFFF; isolated UTF-16 surrogate pairs are supported for
+    // compatibility with previous versions of escapeString, 0 generates the
+    // empty string rather than a possibly-truncating '\0', and all other inputs
+    // generate U+FFFD (the replacement character, standard practice for
+    // non-signalling Unicode codecs like this one)
+    //     return (
+    //         (value > 0) &&
+    //         (value <= 0x10fffd) &&
+    //         ((value & 0xffff) < 0xfffe)) ?
+    //       ((value <= 0xffff) ?
+    //         String.fromCharCode(value) :
+    //         String.fromCharCode(
+    //           ((value - 0x10000) >> 10) | 0xd800,
+    //           ((value - 0x10000) & 0x3ff) | 0xdc00)) :
+    //       ((value === 0) ? '' : '\ufffd');
+    return String.fromCharCode(value);
+  }
+  
+  /**
+   * Reverses escapeString
+   *
+   * @param {string} str The string to unescape.
+   * @return {string}
+   */
+  gadgets.util.unescapeString = function(str) {
+    if (!str) return str;
+    return str.replace(/&#([0-9]+);/g, unescapeEntity);
+  };
+
+})();

Added: shindig/trunk/features/src/main/javascript/features/core.util.string/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.string/taming.js?rev=1101304&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.string/taming.js (added)
+++ shindig/trunk/features/src/main/javascript/features/core.util.string/taming.js Tue May
10 03:52:01 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * @class
+ * Tame and expose core gadgets.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+  caja___.whitelistFuncs([
+    [gadgets.util, 'unescapeString']
+  ]);
+});

Modified: shindig/trunk/features/src/main/javascript/features/core.util.urlparams/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.urlparams/feature.xml?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.urlparams/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util.urlparams/feature.xml Tue
May 10 03:52:01 2011
@@ -21,6 +21,7 @@
   <dependency>globals</dependency>
   <all>
     <script src="urlparams.js"/>
+    <script src="taming.js" caja="1"/>
     <api>
       <exports type="js">gadgets.util.getUrlParameters</exports>
     </api>

Added: shindig/trunk/features/src/main/javascript/features/core.util.urlparams/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.urlparams/taming.js?rev=1101304&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.urlparams/taming.js (added)
+++ shindig/trunk/features/src/main/javascript/features/core.util.urlparams/taming.js Tue
May 10 03:52:01 2011
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+/**
+ * @class
+ * Tame and expose core gadgets.* API to cajoled gadgets
+ */
+tamings___.push(function(imports) {
+  caja___.whitelistFuncs([
+    [gadgets.util, 'getUrlParameters']
+  ]);
+});

Modified: shindig/trunk/features/src/main/javascript/features/core.util/feature.xml
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/feature.xml?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/feature.xml (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/feature.xml Tue May 10 03:52:01
2011
@@ -22,6 +22,7 @@
   <dependency>taming</dependency>
   <dependency>core.config</dependency>
   <dependency>core.util.dom</dependency>
+  <dependency>core.util.string</dependency>
   <dependency>core.util.urlparams</dependency>
   <all>
     <script src="util.js"/>
@@ -34,11 +35,12 @@
       <exports type="js">gadgets.util.getServices</exports>
       <exports type="js">gadgets.util.registerOnLoadHandler</exports>
       <exports type="js">gadgets.util.runOnLoadHandlers</exports>
-      <exports type="js">gadgets.util.escape</exports>
-      <exports type="js">gadgets.util.escapeString</exports>
-      <exports type="js">gadgets.util.unescapeString</exports>
       <exports type="js">gadgets.util.attachBrowserEvent</exports>
       <exports type="js">gadgets.util.removeBrowserEvent</exports>
+      <!-- TODO: move to core.util.string -->
+      <exports type="js">gadgets.util.escape</exports>
+      <exports type="js">gadgets.util.escapeString</exports>
+      <!-- TODO: move to core.util.dom -->
       <exports type="js">gadgets.util.createIframeElement</exports>
     </api>
   </all>

Modified: shindig/trunk/features/src/main/javascript/features/core.util/taming.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/taming.js?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/taming.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/taming.js Tue May 10 03:52:01
2011
@@ -23,11 +23,10 @@
  */
 tamings___.push(function(imports) {
   caja___.whitelistFuncs([
+    [gadgets.util, 'escape'],
     [gadgets.util, 'escapeString'],
     [gadgets.util, 'getFeatureParameters'],
-    [gadgets.util, 'getUrlParameters'],
     [gadgets.util, 'hasFeature'],
-    [gadgets.util, 'registerOnLoadHandler'],
-    [gadgets.util, 'unescapeString']
+    [gadgets.util, 'registerOnLoadHandler']
   ]);
 });

Modified: shindig/trunk/features/src/main/javascript/features/core.util/util.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/util.js?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/util.js (original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/util.js Tue May 10 03:52:01
2011
@@ -98,36 +98,6 @@ gadgets.util = gadgets.util || {};
     65340 : true
   };
 
-  /**
-   * Regular expression callback that returns strings from unicode code points.
-   *
-   * @param {Array} match Ignored.
-   * @param {number} value The codepoint value to convert.
-   * @return {string} The character corresponding to value.
-   */
-  function unescapeEntity(match, value) {
-    // TODO: b0rked for UTF-16 and can easily be convinced to generate
-    // truncating NULs or completely invalid non-Unicode characters. Here's a
-    // fixed version (it handles entities for valid codepoints from U+0001 ...
-    // U+10FFFD, except for the non-character codepoints U+...FFFE and
-    // U+...FFFF; isolated UTF-16 surrogate pairs are supported for
-    // compatibility with previous versions of escapeString, 0 generates the
-    // empty string rather than a possibly-truncating '\0', and all other inputs
-    // generate U+FFFD (the replacement character, standard practice for
-    // non-signalling Unicode codecs like this one)
-    //     return (
-    //         (value > 0) &&
-    //         (value <= 0x10fffd) &&
-    //         ((value & 0xffff) < 0xfffe)) ?
-    //       ((value <= 0xffff) ?
-    //         String.fromCharCode(value) :
-    //         String.fromCharCode(
-    //           ((value - 0x10000) >> 10) | 0xd800,
-    //           ((value - 0x10000) & 0x3ff) | 0xdc00)) :
-    //       ((value === 0) ? '' : '\ufffd');
-    return String.fromCharCode(value);
-  }
-
   function escapeString(str) {
     if (!str) return str;
     var out = [], ch, shouldEscape;
@@ -276,6 +246,7 @@ gadgets.util = gadgets.util || {};
    * @private Only to be used by the container, not gadgets.
    */
   gadgets.util.escape = function(input, opt_escapeObjects) {
+    // TODO: move to core.util.string.
     if (!input) {
       return input;
     } else if (typeof input === 'string') {
@@ -305,20 +276,10 @@ gadgets.util = gadgets.util || {};
    * @param {string} str The string to escape.
    * @return {string} The escaped string.
    */
+  // TODO: move to core.util.string.
   gadgets.util.escapeString = escapeString;
 
   /**
-   * Reverses escapeString
-   *
-   * @param {string} str The string to unescape.
-   * @return {string}
-   */
-  gadgets.util.unescapeString = function(str) {
-    if (!str) return str;
-    return str.replace(/&#([0-9]+);/g, unescapeEntity);
-  };
-
-  /**
    * Attach an event listener to given DOM element (Not a gadget standard)
    *
    * @param {Object} elem  DOM element on which to attach event.
@@ -365,7 +326,7 @@ gadgets.util = gadgets.util || {};
    * @return {Element} The DOM node representing body.
    */
   gadgets.util.createIframeElement = function(opt_attribs) {
-    // TODO: factor this out to core.util.dom.
+    // TODO: move to core.util.dom.
     var frame = gadgets.util.createElement('iframe');
     try {
       // TODO: provide automatic mapping to only set the needed

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=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Tue May 10 03:52:01 2011
@@ -37,6 +37,7 @@ features/core.none/feature.xml
 features/core.prefs/feature.xml
 features/core.util/feature.xml
 features/core.util.dom/feature.xml
+features/core.util.string/feature.xml
 features/core.util.urlparams/feature.xml
 features/core/feature.xml
 features/dynamic-height.height/feature.xml

Modified: shindig/trunk/features/src/test/javascript/features/alltests.js
URL: http://svn.apache.org/viewvc/shindig/trunk/features/src/test/javascript/features/alltests.js?rev=1101304&r1=1101303&r2=1101304&view=diff
==============================================================================
--- shindig/trunk/features/src/test/javascript/features/alltests.js (original)
+++ shindig/trunk/features/src/test/javascript/features/alltests.js Tue May 10 03:52:01 2011
@@ -35,15 +35,16 @@ if (!this.JsUtil) {
 
   eval(JsUtil.prototype.include(testSrcDir + '/mocks/env.js'));
   eval(JsUtil.prototype.include(testSrcDir + '/mocks/xhr.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/config.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/json-native.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/json-jsimpl.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/json-flatten.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/auth.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.config.base/config.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.json/json-native.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.json/json-jsimpl.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.json/json-flatten.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.util.string/string.js'));
   eval(JsUtil.prototype.include(srcDir + '/core.util.dom/dom.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.util.urlparams/urlparams.js'));
   eval(JsUtil.prototype.include(srcDir + '/core.util/util.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/prefs.js'));
-  eval(JsUtil.prototype.include(srcDir + '/core/log.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.prefs/prefs.js'));
+  eval(JsUtil.prototype.include(srcDir + '/core.log/log.js'));
   eval(JsUtil.prototype.include(srcDir + '/core.io/io.js'));
   eval(JsUtil.prototype.include(srcDir + '/views/views.js'));
   eval(JsUtil.prototype.include(srcDir + '/xhrwrapper/xhrwrapper.js'));
@@ -79,6 +80,7 @@ if (!this.JsUtil) {
   eval(JsUtil.prototype.include(srcDir + '/osapi/jsonrpctransport.js'));
   eval(JsUtil.prototype.include(srcDir + '/osapi/gadgetsrpctransport.js'));
   eval(JsUtil.prototype.include(srcDir + '/osapi/peoplehelpers.js'));
+  eval(JsUtil.prototype.include(srcDir + '/shindig.auth/auth.js'));
   eval(JsUtil.prototype.include(srcDir + '/shindig.uri/uri.js'));
   eval(JsUtil.prototype.include(srcDir + '/container/constant.js'));
   eval(JsUtil.prototype.include(srcDir + '/container/util.js'));



Mime
View raw message