Author: chirag
Date: Sat Sep 11 00:08:53 2010
New Revision: 996019
URL: http://svn.apache.org/viewvc?rev=996019&view=rev
Log:
Load cajita-debugmode.js if debug=1
Code Review: http://codereview.appspot.com/2175042/
Added:
shindig/trunk/features/src/main/javascript/features/caja-debug/
shindig/trunk/features/src/main/javascript/features/caja-debug/feature.xml
Modified:
shindig/trunk/features/src/main/javascript/features/features.txt
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java
Added:
shindig/trunk/features/src/main/javascript/features/caja-debug/feature.xml
URL:
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja-debug/feature.xml?rev=996019&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja-debug/feature.xml
(added)
+++ shindig/trunk/features/src/main/javascript/features/caja-debug/feature.xml
Sat Sep 11 00:08:53 2010
@@ -0,0 +1,27 @@
+<?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.
+
+The javascript referenced here should be found in the caja jar.
+-->
+<feature>
+ <name>caja-debug</name>
+ <dependency>caja</dependency>
+ <gadget>
+ <script src="res://com/google/caja/cajita-debugmode.js"/>
+ </gadget>
+</feature>
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=996019&r1=996018&r2=996019&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Sat Sep 11
00:08:53 2010
@@ -22,6 +22,7 @@ features/globals/feature.xml
features/analytics/feature.xml
features/auth-refresh/feature.xml
features/caja/feature.xml
+features/caja-debug/feature.xml
features/container/feature.xml
features/content-rewrite/feature.xml
features/core.config/feature.xml
Modified:
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java
URL:
http://svn.apache.org/viewvc/shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java?rev=996019&r1=996018&r2=996019&view=diff
==============================================================================
---
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java
(original)
+++
shindig/trunk/java/gadgets/src/main/java/org/apache/shindig/gadgets/servlet/CajaContentRewriter.java
Sat Sep 11 00:08:53 2010
@@ -27,6 +27,7 @@ import com.google.caja.opensocial.Gadget
import com.google.caja.parser.html.Dom;
import com.google.caja.parser.html.Namespaces;
import com.google.caja.parser.js.CajoledModule;
+import com.google.caja.plugin.PipelineMaker;
import com.google.caja.plugin.PluginCompiler;
import com.google.caja.plugin.PluginMeta;
import com.google.caja.plugin.UriFetcher;
@@ -124,17 +125,13 @@ public class CajaContentRewriter impleme
compiler.setMessageContext(context);
- /**
- * TODO(jasvir): This can provide support for debugging with
- * cajita-debugmode.js but cajita-debugmode.js should be loaded
- * iff url param debug=1
- *
- * if (debug) {
- * compiler.setGoals(compiler.getGoals()
- * .without(PipelineMaker.ONE_CAJOLED_MODULE)
- * .with(PipelineMaker.ONE_CAJOLED_MODULE_DEBUG));
- * }
- */
+ if (debug) {
+ // This will load cajita-debugmode.js
+ gadget.addFeature("caja-debug");
+ compiler.setGoals(compiler.getGoals()
+ .without(PipelineMaker.ONE_CAJOLED_MODULE)
+ .with(PipelineMaker.ONE_CAJOLED_MODULE_DEBUG));
+ }
InputSource is = new InputSource(javaGadgetUri);
boolean safe = false;
@@ -155,7 +152,7 @@ public class CajaContentRewriter impleme
.withEmbeddable(true));
tc.noMoreTokens();
-
+
Node html = compiler.getStaticHtml();
Element script = doc.createElementNS(
@@ -180,7 +177,7 @@ public class CajaContentRewriter impleme
if (cajoledCache != null && !debug) {
cajoledCache.addElement(cacheKey, cajoledOutput);
}
- safe = true;
+
cajoledData = cajoledOutput;
createContainerFor(doc, cajoledData);
mc.documentChanged();
@@ -203,7 +200,7 @@ public class CajaContentRewriter impleme
}
}
- private boolean cajaEnabled(Gadget gadget) {
+ protected boolean cajaEnabled(Gadget gadget) {
return (gadget.getAllFeatures().contains("caja") ||
"1".equals(gadget.getContext().getParameter("caja")));
}