nieuws: create new articles relative to page root
[minimedit.git] / nieuws / edit.js
index 64260e9a2cf339be67ca7b711d9d33b4f9df7c1b..6f3f54fa7856e7dc3a93072bd4c8208da0f45621 100644 (file)
@@ -3,12 +3,12 @@ editlink.className = 'nav';
 editlink.appendChild(document.createTextNode('Nieuw artikel'));
 editlink.onclick = function () {
        var today = new Date().toJSON().slice(0, 10).split('-');
-       var input = prompt('Paginatitel', '');
+       var input = prompt('Paginalink (beknopte titel)', '');
        if (!input) return false;
-       var url = today[0] + '/' + today[1] + '/' + today[2] + '-' +
-               input.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim();
+       var url = today[0] + '/' + today[1] + '-' + today[2] + '-' +
+               input.toLowerCase().replace(/[^a-z0-9]+/g, '-').trim();
        var title = encodeURIComponent(input.trim());
-       window.location = '/nieuws/'+url+'?edit='+title+'#edit';
+       window.location = window.location.pathname+'/'+url+'?edit='+title+'#edit';
        return false;
 };
 document.getElementById('news').appendChild(editlink);