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
This commit is contained in:
Olivier Lamy 2012-01-24 18:22:58 +00:00
parent 87101453e3
commit 372a868876
6 changed files with 31 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -21,14 +21,18 @@ function($) {
$(function() {
// no cache for ajax queries
jQuery.ajaxSetup( {
cache: false
} );
// define a container object with various datas
window.archivaModel = {};
$.log("devMode:"+window.archivaDevMode);
// no cache for ajax queries
jQuery.ajaxSetup( {
cache: !window.archivaDevMode
} );
/**
* reccord a cookie for session with the logged user
* @param user see user.js

View File

@ -295,4 +295,11 @@ customShowError=function(validator, errorMap, errorList) {
field.parents( "div.clearfix" ).addClass( "error" );
field.parent().append( "<span class=\"help-inline\">" + error.message + "</span>" );
}
}
timestampNoCache=function(){
if (!window.archivaDevMode){
return "";
}
return "_="+jQuery.now();
}

View File

@ -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) {

View File

@ -190,14 +190,16 @@
<th>${ columnDefinition.headerText }</th>
{{/each}}
<th>${$.i18n.prop('edit')}</th>
</tr>
</thead>
<tbody>
{{each(i, row) itemsOnCurrentPage()}}
<tr>
{{each(j, columnDefinition) columns}}
<td>${ typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText] }</td>
{{var val = (typeof columnDefinition.rowText == 'function' ? columnDefinition.rowText(row) : row[columnDefinition.rowText])}}
<td id="role-description-${val}">
${val}
</td>
{{/each}}
<td><a href="#" data-bind="click: function(){ window.redbackModel.rolesViewModel.editRole(row) }">Edit</a></td>
</tr>