From 372a868876d970cc1772bc2cbd9ff06646c90a2f Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 24 Jan 2012 18:22:58 +0000 Subject: [PATCH] add a timestamp on template loading to prevent browser cache when developping. mode desactivated by default git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1235393 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-webapp-js/src/main/webapp/index.html | 3 ++- .../src/main/webapp/js/archiva/main-tmpl.js | 6 ++++-- .../src/main/webapp/js/archiva/main.js | 10 +++++++--- .../src/main/webapp/js/archiva/utils.js | 7 +++++++ .../src/main/webapp/js/redback/redback-tmpl.js | 8 +++++--- .../main/webapp/js/redback/templates/roles-tmpl.html | 6 ++++-- 6 files changed, 29 insertions(+), 11 deletions(-) diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html index 3f179e425..14d602c7e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/index.html @@ -44,6 +44,7 @@ $.ajax( { url: "restServices/archivaServices/commonServices/devMode", success:function(data){ + window.archivaDevMode=data=='true'; require.config({ baseUrl: "js/" }); @@ -52,7 +53,7 @@ $.ajax( AlwaysPreserveOrder:true, BasePath:"js/", explicit_preloading:false, - CacheBust:data=='true' + CacheBust:window.archivaDevMode }; $LAB.setGlobalDefaults(options); $LAB diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main-tmpl.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main-tmpl.js index 73d313e21..8acd644a6 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main-tmpl.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main-tmpl.js @@ -16,8 +16,10 @@ * specific language governing permissions and limitations * under the License. */ -require(["text!archiva/templates/menu.html","text!archiva/templates/topbar.html","text!archiva/templates/message.html", - "text!archiva/templates/modal.html","text!archiva/templates/grids-generics.html","text!archiva/templates/repositories.html"], +require(["text!archiva/templates/menu.html?"+timestampNoCache(),"text!archiva/templates/topbar.html?"+timestampNoCache(), + "text!archiva/templates/message.html?"+timestampNoCache(),"text!archiva/templates/modal.html?"+timestampNoCache(), + "text!archiva/templates/grids-generics.html?"+timestampNoCache(), + "text!archiva/templates/repositories.html?"+timestampNoCache()], function(menu,topbar,message,modal,grids_generics,repositories) { // template loading diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index c52b5bf31..dced221f6 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -21,13 +21,17 @@ function($) { $(function() { + // define a container object with various datas + window.archivaModel = {}; + + $.log("devMode:"+window.archivaDevMode); + // no cache for ajax queries jQuery.ajaxSetup( { - cache: false + cache: !window.archivaDevMode } ); - // define a container object with various datas - window.archivaModel = {}; + /** * reccord a cookie for session with the logged user diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index 179b07313..15f15a295 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -295,4 +295,11 @@ customShowError=function(validator, errorMap, errorList) { field.parents( "div.clearfix" ).addClass( "error" ); field.parent().append( "" + error.message + "" ); } +} + +timestampNoCache=function(){ + if (!window.archivaDevMode){ + return ""; + } + return "_="+jQuery.now(); } \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback-tmpl.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback-tmpl.js index d9b537a14..e61cf04ec 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback-tmpl.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/redback-tmpl.js @@ -16,9 +16,11 @@ * specific language governing permissions and limitations * under the License. */ -require(["text!redback/templates/user-edit.html", "text!redback/templates/user-grids.html", "text!redback/templates/login.html" - , "text!redback/templates/register-form.html","text!redback/templates/password-change-form.html" - ,"text!redback/templates/user-edit-form.html","text!redback/templates/roles-tmpl.html"], +require(["text!redback/templates/user-edit.html?"+timestampNoCache(), "text!redback/templates/user-grids.html?"+timestampNoCache(), + "text!redback/templates/login.html?"+timestampNoCache(), "text!redback/templates/register-form.html?"+timestampNoCache(), + "text!redback/templates/password-change-form.html?"+timestampNoCache(), + "text!redback/templates/user-edit-form.html?"+timestampNoCache(), + "text!redback/templates/roles-tmpl.html?"+timestampNoCache()], function(useredit, usergrids, login,register,passwordchange,usereditform,roles) { diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html index 1c7e919b7..6f03d6351 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/templates/roles-tmpl.html @@ -190,14 +190,16 @@ ${ columnDefinition.headerText } {{/each}} ${$.i18n.prop('edit')} - {{each(i, row) itemsOnCurrentPage()}} {{each(j, columnDefinition) columns}} - ${ typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText] } + {{var val = (typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText])}} + + ${val} + {{/each}} Edit -- 2.39.5