Author: tchemit Date: 2012-08-31 12:15:22 +0200 (Fri, 31 Aug 2012) New Revision: 1329 Url: http://nuiton.org/repositories/revision/mavenpom/1329 Log: refs #2241: add logs + push back old js script (for the moment...) Added: trunk/src/static-site/resources/js/maven-site-nuiton.org.js Added: trunk/src/static-site/resources/js/maven-site-nuiton.org.js =================================================================== --- trunk/src/static-site/resources/js/maven-site-nuiton.org.js (rev 0) +++ trunk/src/static-site/resources/js/maven-site-nuiton.org.js 2012-08-31 10:15:22 UTC (rev 1329) @@ -0,0 +1,85 @@ +/* + * #%L + * EchoBase + * + * $Id: maven-site-chorem.org.js 3267 2012-04-13 17:27:48Z tchemit $ + * $HeadURL: http://svn.chorem.org/svn/pollen/trunk/src/site/resources/maven-site-chorem.... $ + * %% + * Copyright (C) 2011 - 2012 Ifremer, Codelutin + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * #L% + */ +$(document).ready(function () { + + var metas = $('#projectMetas'); + var piwikEnabled = metas.attr('piwikEnabled'); + if (piwikEnabled) { + //Piwik Tracking Code + var piwikId = metas.attr('piwikId'); + if (!piwikId) { + + // default piwikId for nuiton.org + piwikId = 2; + } + + console.log("use Piwik with id = " + piwikId); + var pkBaseURL = "https:" == document.location.protocol ? + "https://piwik.codelutin.com/" : + "http://piwik.codelutin.com/"; + $.getScript(pkBaseURL + "piwik.js", function (data, textStatus, jqxhr) { + var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", piwikId); + piwikTracker.trackPageView(); + piwikTracker.enableLinkTracking(); + console.log("piwikTracker loaded = " + piwikTracker); + }); + //Piwik Tracking Code + } + var scmwebeditorenabled = metas.attr('scmwebeditorenabled'); + var scm = metas.attr('scm'); + if (scmwebeditorenabled && scm.indexOf("/trunk") > -1) { + + // allow scmwebeditor is enabled and on trunk + + // remove scm prefix (scm:svn:) + scm = scm.replace('scm:svn:', ''); + + var scmurl = metas.attr('scmwebeditorurl'); + var projectId = metas.attr('projectId'); + var siteSourcesType = metas.attr('siteSourcesType'); + var path; + var pathname = document.location.pathname; + if (pathname.indexOf('target/site') > 0) { + path = pathname.substr(pathname.indexOf('/site')). + replace('/site/', ''); + } else { + if (pathname == '/' + projectId + '/') { + // on / page + path = 'index.html'; + } else { + path = pathname.substr(pathname.indexOf('/' + projectId)). + replace('/' + projectId + '/', ''); + } + } + path = path.replace('.html', '.' + siteSourcesType); + var url = scmurl + "?address=" + scm + "/src/site/" + siteSourcesType + "/" + path; + console.log("Add scmwebeditor with url = " + url); + var html = "<li class='pull-right'><a href='" + url + + "'>Éditer la page</a></li>" + + "<li class='divider pull-right'>|</li>"; + var ul = $('#publishDate'); + ul.prepend(html); + + } +}); \ No newline at end of file