[gatein-commits] gatein SVN: r4396 - in portal/branches/branch-GTNPORTAL-1493: web/portal/src/main/webapp/groovy/portal/webui/workspace and 1 other directory.
do-not-reply at jboss.org
do-not-reply at jboss.org
Mon Sep 27 05:07:11 EDT 2010
Author: kien_nguyen
Date: 2010-09-27 05:07:10 -0400 (Mon, 27 Sep 2010)
New Revision: 4396
Modified:
portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
portal/branches/branch-GTNPORTAL-1493/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
Log:
GTNPORTAL-1470 Allow to add an external javascript in gatein-resource
Modified: portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java 2010-09-27 08:57:03 UTC (rev 4395)
+++ portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java 2010-09-27 09:07:10 UTC (rev 4396)
@@ -47,6 +47,10 @@
}
public String getPath() {
+ if(key.isExternalScript())
+ {
+ return key.getScriptPath();
+ }
return key.getContextPath() + key.getScriptPath();
}
Modified: portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-09-27 08:57:03 UTC (rev 4395)
+++ portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-09-27 09:07:10 UTC (rev 4396)
@@ -178,37 +178,40 @@
object_view_of_merged_JS.put(javascript.getKey().getContextPath(), mergedJS_list);
}
- StringBuffer sB = new StringBuffer();
- String line = "";
- try
- {
- BufferedReader reader = javascript.getReader();
+ //Merge internal javascripts
+ if(!javascript.getKey().isExternalScript()) {
+ StringBuffer sB = new StringBuffer();
+ String line = "";
try
{
- while ((line = reader.readLine()) != null)
+ BufferedReader reader = javascript.getReader();
+ try
{
- line = line + "\n";
- sB.append(line);
- mergedJS_list.add(line);
+ while ((line = reader.readLine()) != null)
+ {
+ line = line + "\n";
+ sB.append(line);
+ mergedJS_list.add(line);
+ }
}
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ Safe.close(reader);
+ }
}
- catch (Exception ex)
+ catch (Exception e)
{
- ex.printStackTrace();
+ e.printStackTrace();
}
- finally
- {
- Safe.close(reader);
- }
+ sB.append("\n");
+ mergedJS_list.add("\n");
+
+ mergedJavascript = mergedJavascript.concat(sB.toString());
}
- catch (Exception e)
- {
- e.printStackTrace();
- }
- sB.append("\n");
- mergedJS_list.add("\n");
-
- mergedJavascript = mergedJavascript.concat(sB.toString());
}
/**
Modified: portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
===================================================================
--- portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java 2010-09-27 08:57:03 UTC (rev 4395)
+++ portal/branches/branch-GTNPORTAL-1493/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java 2010-09-27 09:07:10 UTC (rev 4396)
@@ -75,4 +75,9 @@
{
return contextPath;
}
+
+ public boolean isExternalScript()
+ {
+ return (scriptPath.startsWith("http") || scriptPath.startsWith("https")) ? true : false;
+ }
}
Modified: portal/branches/branch-GTNPORTAL-1493/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
--- portal/branches/branch-GTNPORTAL-1493/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-09-27 08:57:03 UTC (rev 4395)
+++ portal/branches/branch-GTNPORTAL-1493/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-09-27 09:07:10 UTC (rev 4396)
@@ -63,7 +63,13 @@
<%} else {%>
<script type="text/javascript" src="<%=docBase%>/javascript/merged.js"></script>
- <%}%>
+ <%
+ for(path in scriptsPaths) {
+ if(path.startsWith("http") || path.startsWith("https")) {%>
+ <script type="text/javascript" src="<%=path%>"></script>
+ <%}
+ }
+ }%>
<script type="text/javascript">
eXo.env.portal.context = "<%=docBase%>" ;
<%if(rcontext.getAccessPath() == 0) {%>eXo.env.portal.accessMode = "public" ;<%}
More information about the gatein-commits
mailing list