mcardle 2006/01/04 04:22:25 CET
Modified files:
src/view/jsp/include header.inc
Log:
* adds option to invalidate the current page and all its fragments in ESI mode
Revision Changes Path
1.14 +62 -2
corporate_portal_templates/src/view/jsp/include/header.inc
http://jahia.mine.nu:8080/cgi-bin/cvsweb.cgi/corporate_portal_templates/src/view/jsp/include/header.inc.diff?r1=1.13&r2=1.14&f=h
Index: header.inc
===================================================================
RCS file:
/home/cvs/repository/corporate_portal_templates/src/view/jsp/include/header.inc,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- header.inc 23 Dec 2005 11:26:32 -0000 1.13
+++ header.inc 4 Jan 2006 03:22:25 -0000 1.14
@@ -117,6 +117,7 @@
window.location.href = theUrl;
}
}
+
function resizeme(i) {
if (i.width > 500) i.width=500;
}
@@ -132,6 +133,45 @@
theForm.freeSearch.value=theForm.search.value;
}
+function esiGeneratePageInvalidationUrl(){
+ var theUrl = window.location.href;
+
+ var invEsiMarker = "esi=invalidateNow";
+
+ var posInv = theUrl.indexOf(invEsiMarker);
+ //add invalidation marker
+ if (posInv == -1) {
+ var posParam = theUrl.indexOf("?");
+ if (posParam == -1) {
+ theUrl += "?"+invEsiMarker;
+ } else {
+ theUrl += "&"+invEsiMarker;
+ }
+ document.write("Invalidating cache for this page...");
+ }
+ window.location.href = theUrl;
+}
+
+function esiForwardToOrginalUrl(){
+ var theUrl = window.location.href;
+
+ var invEsiMarker = new String("esi=invalidateNow");
+ var posInv = theUrl.indexOf(invEsiMarker);
+
+ //remove invalidation marker
+ if (posInv != -1) {
+ document.write(theUrl);
+ theUrl = theUrl.replace(/\?esi=invalidateNow/gi,"");
+ theUrl = theUrl.replace(/&esi=invalidateNow/gi,"");
+ theUrl = theUrl.replace(/esi=invalidateNow/gi,"");
+ //theUrl.replace("\\?"+invEsiMarker,"");
+ //theUrl.replace("&"+invEsiMarker,"");
+ //theUrl.replace(invEsiMarker,"");
+ window.location.href = theUrl;
+ }
+}
+
+
-->
</script>
<%@ include file="splash.inc"%>
@@ -140,9 +180,29 @@
<body>
<%@ page import="org.jahia.settings.SettingsBean"%>
- <% if
(jData.getProcessingContext().settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED))
{ %>
+<%@ page import="org.jahia.services.esi.EsiSOAPInvalidation"%>
+ <%
+ //Display special info when ESI is enabled
+ if
(jData.getProcessingContext().settings().lookupBoolean(SettingsBean.ESI_CACHE_ACTIVATED))
{ %>
<esi:remove><p><b>REQUEST NOT PASSED THROUGH ESI
SERVER</b></p></esi:remove>
- <% } %>
+ <%
+ String esiInvParam = request.getParameter("esi");
+ String isFragmentRequested = request.getParameter("__esi_fragment");
+ if (esiInvParam!=null &&
esiInvParam.equalsIgnoreCase("invalidateNow")
+ && isFragmentRequested==null) {
+ //invalidate page and all its fragments
+ System.err.println("------ invalidting now");
+
EsiSOAPInvalidation.SOAPInvalidatePageAndAllFrags(jData.params(),
jData.params().getPageID() );
+ %><script>
+ <!--
+ esiForwardToOrginalUrl();
+ //-->
+ </script>
+ <% } %>
+ <a
href="javascript:esiGeneratePageInvalidationUrl()">Invalidate Current Page</a>
+ <br>
+
+<% } %>
<% if (thePrint) { %> class="maintable"<% } %>
<%