Author: tchemit Date: 2012-08-31 12:08:01 +0200 (Fri, 31 Aug 2012) New Revision: 1327 Url: http://nuiton.org/repositories/revision/mavenpom/1327 Log: refs #2241: improve common js Modified: trunk/src/static-site/resources/js/mavenpom-site.js Modified: trunk/src/static-site/resources/js/mavenpom-site.js =================================================================== --- trunk/src/static-site/resources/js/mavenpom-site.js 2012-08-30 14:43:38 UTC (rev 1326) +++ trunk/src/static-site/resources/js/mavenpom-site.js 2012-08-31 10:08:01 UTC (rev 1327) @@ -39,19 +39,38 @@ var scmwebeditorenabled = metas.attr('scmwebeditorenabled'); var scm = metas.attr('scm'); if (scmwebeditorenabled && - scm.indexOf("/trunk") > -1 && - scm.indexOf("/branches") > -1) { + (scm.indexOf("/trunk") > -1 || + scm.indexOf("/branches") > -1)) { // allow scmwebeditor is enabled and on trunk // remove scm prefix (scm:svn:) scm = scm.replace('scm:svn:', ''); + scm = scm.replace('/SNAPSHOT', ''); + var scmurl = metas.attr('scmwebeditorurl'); var projectId = metas.attr('projectId'); var siteSourcesType = metas.attr('siteSourcesType'); + var locale = metas.attr('locale'); var path; var pathname = document.location.pathname; + + // remove /SNAPSHOT from path + pathname = pathname.replace('/SNAPSHOT', ''); + + var localeInPath; + if (pathname.indexOf('/' + locale) > -1) { + + // locale detected in path (means not default locale) + // remove locale from path + pathname = pathname.replace('/' + locale, ''); + localeInPath = locale + '/'; + } else { + + // means default locale, no need to set it in svn url + localeInPath = ""; + } if (pathname.indexOf('target/site') > 0) { path = pathname.substr(pathname.indexOf('/site')). replace('/site/', ''); @@ -65,7 +84,7 @@ } } path = path.replace('.html', '.' + siteSourcesType); - var url = scmurl + "?address=" + scm + "/src/site/" + siteSourcesType + "/" + path; + var url = scmurl + "?address=" + scm + "/src/site/" + localeInPath + siteSourcesType + "/" + path; console.log("Add scmwebeditor with url = " + url); var html = "<li class='pull-right'><a href='" + url + "'>Éditer la page</a></li>" +
participants (1)
-
tchemit@users.nuiton.org