nieuws: create article urls with dash separators v3.1
authorMischa POSLAWSKY <perl@shiar.org>
Sat, 16 Jun 2018 03:43:12 +0000 (05:43 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Sat, 16 Jun 2018 03:43:12 +0000 (05:43 +0200)
Prompt for "link" to clarify purpose, and replace spaces (as most sites do).

nieuws/edit.js

index 86b0b4ce6e58029965efaa532a4a32444805e03a..3155ac0afc1ccbf344d71679c85b6b366c5462b7 100644 (file)
@@ -3,10 +3,10 @@ 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();
+               input.toLowerCase().replace(/[^a-z0-9]+/g, '-').trim();
        var title = encodeURIComponent(input.trim());
        window.location = '/nieuws/'+url+'?edit='+title+'#edit';
        return false;