simplify template url loading

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1305652 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-26 22:51:03 +00:00
parent 5643f67fac
commit 680767ee7d
5 changed files with 116 additions and 87 deletions

View File

@ -46,10 +46,35 @@
<script type="text/javascript"> <script type="text/javascript">
appendArchivaVersion=function(){
return "_archivaVersion="+window.archivaRuntimeInfo.version;
}
timestampNoCache=function(){
if (!window.archivaDevMode){
return "";
}
return "&_="+jQuery.now();
}
appendTemplateUrl=function(){
return appendArchivaVersion()+timestampNoCache();
}
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/en",
dataType: 'json',
success:function(data){
window.archivaDevMode=data.devMode;
window.archivaJavascriptLog=data.javascriptLog;
window.archivaRuntimeInfo=data;
require.config({ require.config({
baseUrl: "js/", baseUrl: "js/",
urlArgs: "_="+new Date().getTime(), urlArgs: ""+appendTemplateUrl(),
"paths": { paths: {
"i18n":"jquery.i18n.properties-1.0.9", "i18n":"jquery.i18n.properties-1.0.9",
"jquery": "jquery-1.7.2", "jquery": "jquery-1.7.2",
"jquery_tmpl": "jquery.tmpl", "jquery_tmpl": "jquery.tmpl",
@ -82,9 +107,12 @@
//.script("jquery.fileupload-ip-1.0.6.js").wait() //.script("jquery.fileupload-ip-1.0.6.js").wait()
//.script("jquery.fileupload-ui-6.6.3.js" ).wait() //.script("jquery.fileupload-ui-6.6.3.js" ).wait()
}); });
require(['order!domReady','order!jquery','order!i18n','order!startup'], function (domReady) { require(['order!domReady','order!jquery','order!i18n','order!startup'], function (domReady) {
domReady.withResources(function () { domReady.withResources(function () {
loadi18n();
$.ajax({ $.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(), url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
dataType: 'json', dataType: 'json',
@ -92,16 +120,22 @@
window.archivaDevMode=data.devMode; window.archivaDevMode=data.devMode;
window.archivaJavascriptLog=data.javascriptLog; window.archivaJavascriptLog=data.javascriptLog;
window.archivaRuntimeInfo=data; window.archivaRuntimeInfo=data;
require(['order!domReady','archiva/main'],function (domReady) { require(['order!domReady','archiva/main'],function (domReady) {
domReady.withResources(function () { domReady.withResources(function () {
startArchivaApplication(); startArchivaApplication();
}) })
}) })
}}
)
}
})
}) })
}); });
}
})
</script> </script>

View File

@ -16,16 +16,16 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
define("main-templates",["text!js/archiva/templates/menu.html"+appendTemplateUrl(), define("main-templates",["text!archiva/templates/menu.html",
"text!js/archiva/templates/message.html"+appendTemplateUrl(), "text!archiva/templates/message.html",
"text!js/archiva/templates/modal.html"+appendTemplateUrl(), "text!archiva/templates/modal.html",
"text!js/archiva/templates/grids-generics.html"+appendTemplateUrl(), "text!archiva/templates/grids-generics.html",
"text!js/archiva/templates/repositories.html"+appendTemplateUrl(), "text!archiva/templates/repositories.html",
"text!js/archiva/templates/network-proxies.html"+appendTemplateUrl(), "text!archiva/templates/network-proxies.html",
"text!js/archiva/templates/proxy-connectors.html"+appendTemplateUrl(), "text!archiva/templates/proxy-connectors.html",
"text!js/archiva/templates/repository-groups.html"+appendTemplateUrl(), "text!archiva/templates/repository-groups.html",
"text!js/archiva/templates/search.html"+appendTemplateUrl(), "text!archiva/templates/search.html",
"text!js/archiva/templates/general-admin.html"+appendTemplateUrl(), "text!archiva/templates/general-admin.html",
"jquery_tmpl","utils"], "jquery_tmpl","utils"],
function(menu,message,modal,grids_generics,repositories,network_proxies,proxies_connectors, function(menu,message,modal,grids_generics,repositories,network_proxies,proxies_connectors,
repository_groups,search,general_admin) { repository_groups,search,general_admin) {

View File

@ -318,6 +318,14 @@ define("utils",["jquery","i18n","jquery_tmpl"], function() {
} }
} }
appendArchivaVersion=function(){
return "_archivaVersion="+window.archivaRuntimeInfo.version;
}
buildLoadJsUrl=function(srcScript){
return srcScript+"?"+appendArchivaVersion()+"&_"+jQuery.now();
}
timestampNoCache=function(){ timestampNoCache=function(){
if (!window.archivaDevMode){ if (!window.archivaDevMode){
return ""; return "";
@ -325,9 +333,6 @@ define("utils",["jquery","i18n","jquery_tmpl"], function() {
return "&_="+jQuery.now(); return "&_="+jQuery.now();
} }
appendTemplateUrl=function(){
return "?"+appendArchivaVersion()+timestampNoCache();
}
/** /**
* mapping for a java Map entry * mapping for a java Map entry

View File

@ -16,13 +16,13 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
define("redback-templates",["text!js/redback/templates/user-edit.html"+appendTemplateUrl(), define("redback-templates",["text!redback/templates/user-edit.html",
"text!js/redback/templates/user-grids.html"+appendTemplateUrl(), "text!redback/templates/user-grids.html",
"text!js/redback/templates/login.html"+appendTemplateUrl(), "text!redback/templates/login.html",
"text!js/redback/templates/register-form.html"+appendTemplateUrl(), "text!redback/templates/register-form.html",
"text!js/redback/templates/password-change-form.html"+appendTemplateUrl(), "text!redback/templates/password-change-form.html",
"text!js/redback/templates/user-edit-form.html"+appendTemplateUrl(), "text!redback/templates/user-edit-form.html",
"text!js/redback/templates/roles-tmpl.html"+appendTemplateUrl(), "text!redback/templates/roles-tmpl.html",
"jquery_tmpl","utils"], "jquery_tmpl","utils"],
function(useredit, usergrids, login,register,passwordchange,usereditform,roles) { function(useredit, usergrids, login,register,passwordchange,usereditform,roles) {

View File

@ -20,16 +20,6 @@
define("startup",["jquery","utils"], define("startup",["jquery","utils"],
function() { function() {
appendArchivaVersion=function(){
return "_archivaVersion="+window.archivaRuntimeInfo.version;
}
buildLoadJsUrl=function(srcScript){
return srcScript+"?"+appendArchivaVersion()+"&_"+jQuery.now();
}
// define a container object with various datas // define a container object with various datas
window.archivaModel = {}; window.archivaModel = {};
@ -40,5 +30,5 @@ function() {
cache: false,//!window.archivaDevMode cache: false,//!window.archivaDevMode
dataType: 'json' dataType: 'json'
}); });
loadi18n();
}); });