Author: thomas.heute(a)jboss.com
Date: 2010-10-05 04:44:26 -0400 (Tue, 05 Oct 2010)
New Revision: 4496
Modified:
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
Log:
GTNPORTAL-1470: Allow to add an external javascript in gatein-resource
Modified:
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java 2010-10-05
08:41:26 UTC (rev 4495)
+++
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/Javascript.java 2010-10-05
08:44:26 UTC (rev 4496)
@@ -47,6 +47,10 @@
}
public String getPath() {
+ if(key.isExternalScript())
+ {
+ return key.getScriptPath();
+ }
return key.getContextPath() + key.getScriptPath();
}
Modified:
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-10-05
08:41:26 UTC (rev 4495)
+++
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptConfigService.java 2010-10-05
08:44:26 UTC (rev 4496)
@@ -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:
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java 2010-10-05
08:41:26 UTC (rev 4495)
+++
epp/portal/branches/EPP_5_1_Branch/component/web/resources/src/main/java/org/exoplatform/web/application/javascript/JavascriptKey.java 2010-10-05
08:44:26 UTC (rev 4496)
@@ -75,4 +75,9 @@
{
return contextPath;
}
+
+ public boolean isExternalScript()
+ {
+ return (scriptPath.startsWith("http") ||
scriptPath.startsWith("https")) ? true : false;
+ }
}
Modified:
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl
===================================================================
---
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-10-05
08:41:26 UTC (rev 4495)
+++
epp/portal/branches/EPP_5_1_Branch/web/portal/src/main/webapp/groovy/portal/webui/workspace/UIPortalApplication.gtmpl 2010-10-05
08:44:26 UTC (rev 4496)
@@ -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" ;<%}
Show replies by date