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,62 +46,96 @@
<script type="text/javascript">
require.config({
baseUrl: "js/",
urlArgs: "_="+new Date().getTime(),
"paths": {
"i18n":"jquery.i18n.properties-1.0.9",
"jquery": "jquery-1.7.2",
"jquery_tmpl": "jquery.tmpl",
"utils": "archiva/utils",
"jquery_ui": "jquery-ui-1.8.16.custom.min",
"jquery_cookie": "jquery.cookie.1.0.0",
"bootstrap": "bootstrap.2.0.2",
"choosen": "chosen.jquery-0.9.7",
"jquery_validate": "jquery.validate-1.9.0",
"jquery_json": "jquery.json-2.3.min",
"knockout.simpleGrid": "knockout.simpleGrid",
"knockout": "knockout-2.0.0.debug",
"knockout.sortable": "knockout-sortable",
"redback": "redback/redback",
"general-admin":"archiva/general-admin",
"redback-templates": "redback/redback-tmpl",
"main-templates": "archiva/main-tmpl",
"repositories": "archiva/repositories",
"network-proxies": "archiva/network-proxies",
"proxy-connectors": "archiva/proxy-connectors",
"repository-groups": "archiva/repository-groups",
"roles": "redback/roles",
"user": "redback/user",
"users": "redback/users",
"archiva/main": "archiva/main"
}
// file upload dependencies
//.script("jquery.iframe-transport-1.4.js").wait()
//.script("jquery.fileupload-5.10.0.js").wait()
//.script("jquery.fileupload-ip-1.0.6.js").wait()
//.script("jquery.fileupload-ui-6.6.3.js" ).wait()
});
require(['order!domReady','order!jquery','order!i18n','order!startup'], function (domReady) {
domReady.withResources(function () {
loadi18n();
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
dataType: 'json',
success:function(data){
window.archivaDevMode=data.devMode;
window.archivaJavascriptLog=data.javascriptLog;
window.archivaRuntimeInfo=data;
require(['order!domReady','archiva/main'],function (domReady) {
domReady.withResources(function () {
startArchivaApplication();
})
})
}}
)
})
});
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({
baseUrl: "js/",
urlArgs: ""+appendTemplateUrl(),
paths: {
"i18n":"jquery.i18n.properties-1.0.9",
"jquery": "jquery-1.7.2",
"jquery_tmpl": "jquery.tmpl",
"utils": "archiva/utils",
"jquery_ui": "jquery-ui-1.8.16.custom.min",
"jquery_cookie": "jquery.cookie.1.0.0",
"bootstrap": "bootstrap.2.0.2",
"choosen": "chosen.jquery-0.9.7",
"jquery_validate": "jquery.validate-1.9.0",
"jquery_json": "jquery.json-2.3.min",
"knockout.simpleGrid": "knockout.simpleGrid",
"knockout": "knockout-2.0.0.debug",
"knockout.sortable": "knockout-sortable",
"redback": "redback/redback",
"general-admin":"archiva/general-admin",
"redback-templates": "redback/redback-tmpl",
"main-templates": "archiva/main-tmpl",
"repositories": "archiva/repositories",
"network-proxies": "archiva/network-proxies",
"proxy-connectors": "archiva/proxy-connectors",
"repository-groups": "archiva/repository-groups",
"roles": "redback/roles",
"user": "redback/user",
"users": "redback/users",
"archiva/main": "archiva/main"
}
// file upload dependencies
//.script("jquery.iframe-transport-1.4.js").wait()
//.script("jquery.fileupload-5.10.0.js").wait()
//.script("jquery.fileupload-ip-1.0.6.js").wait()
//.script("jquery.fileupload-ui-6.6.3.js" ).wait()
});
require(['order!domReady','order!jquery','order!i18n','order!startup'], function (domReady) {
domReady.withResources(function () {
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
dataType: 'json',
success:function(data){
window.archivaDevMode=data.devMode;
window.archivaJavascriptLog=data.javascriptLog;
window.archivaRuntimeInfo=data;
require(['order!domReady','archiva/main'],function (domReady) {
domReady.withResources(function () {
startArchivaApplication();
})
})
}
})
})
});
}
})
</script>

View File

@ -16,16 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
define("main-templates",["text!js/archiva/templates/menu.html"+appendTemplateUrl(),
"text!js/archiva/templates/message.html"+appendTemplateUrl(),
"text!js/archiva/templates/modal.html"+appendTemplateUrl(),
"text!js/archiva/templates/grids-generics.html"+appendTemplateUrl(),
"text!js/archiva/templates/repositories.html"+appendTemplateUrl(),
"text!js/archiva/templates/network-proxies.html"+appendTemplateUrl(),
"text!js/archiva/templates/proxy-connectors.html"+appendTemplateUrl(),
"text!js/archiva/templates/repository-groups.html"+appendTemplateUrl(),
"text!js/archiva/templates/search.html"+appendTemplateUrl(),
"text!js/archiva/templates/general-admin.html"+appendTemplateUrl(),
define("main-templates",["text!archiva/templates/menu.html",
"text!archiva/templates/message.html",
"text!archiva/templates/modal.html",
"text!archiva/templates/grids-generics.html",
"text!archiva/templates/repositories.html",
"text!archiva/templates/network-proxies.html",
"text!archiva/templates/proxy-connectors.html",
"text!archiva/templates/repository-groups.html",
"text!archiva/templates/search.html",
"text!archiva/templates/general-admin.html",
"jquery_tmpl","utils"],
function(menu,message,modal,grids_generics,repositories,network_proxies,proxies_connectors,
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(){
if (!window.archivaDevMode){
return "";
@ -325,9 +333,6 @@ define("utils",["jquery","i18n","jquery_tmpl"], function() {
return "&_="+jQuery.now();
}
appendTemplateUrl=function(){
return "?"+appendArchivaVersion()+timestampNoCache();
}
/**
* mapping for a java Map entry

View File

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

View File

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