nieuws: drop prompt for article (back)date
authorMischa POSLAWSKY <perl@shiar.org>
Thu, 19 Apr 2018 16:03:33 +0000 (18:03 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Fri, 8 Jun 2018 21:14:53 +0000 (23:14 +0200)
Much easier to use.  In rare cases where custom dates are wanted,
pages can still be created manually.

Requested-by: Arie van Marion
nieuws/edit.js

index 13ca8da917203f42f2bcdb19a8411e44b746e191..64260e9a2cf339be67ca7b711d9d33b4f9df7c1b 100644 (file)
@@ -2,16 +2,12 @@ var editlink = document.createElement('a');
 editlink.className = 'nav';
 editlink.appendChild(document.createTextNode('Nieuw artikel'));
 editlink.onclick = function () {
-       var today = new Date().toJSON().slice(0, 10);
-       var input = prompt('Artikelnaam (plaatsingsdatum en paginatitel)', today + ' ');
+       var today = new Date().toJSON().slice(0, 10).split('-');
+       var input = prompt('Paginatitel', '');
        if (!input) return false;
-       if (!/^\d{4}-\d\d-\d\d[- :]+\S/.test(input)) {
-               alert('Artikelnaam moet beginnen met een datum in de vorm jaar-mm-dd.');
-               return false;
-       }
-       var url = input.toLowerCase().replace(/[^a-z0-9]+/g, ' ').trim()
-                                  .replace(/ /g, '-').replace('-', '/');
-       var title = encodeURIComponent(input.substr(11).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';
        return false;
 };