From 2e1831f6091dd5b64b35c8a44ee04f39586fbfbe Mon Sep 17 00:00:00 2001 From: posativ Date: Sun, 28 Oct 2012 00:38:55 +0200 Subject: [PATCH] show pending status, add some css --- isso/comment.py | 2 +- isso/js/isso.js | 72 ++++++++++++++++++++++++++++--------------- isso/static/style.css | 19 ++++++++++++ 3 files changed, 68 insertions(+), 25 deletions(-) diff --git a/isso/comment.py b/isso/comment.py index 060ffc9..0feb230 100644 --- a/isso/comment.py +++ b/isso/comment.py @@ -39,7 +39,7 @@ def create(app, environ, request, path): md5 = rv.md5 rv.text = app.markup.convert(rv.text) - response = Response(json.dumps(rv), 201, content_type='application/json') + response = Response(json.dumps(rv), 202 if rv.pending else 201, content_type='application/json') response.set_cookie('session-%s-%s' % (urllib.quote(path, ''), rv.id), app.signer.dumps([path, rv.id, md5]), max_age=app.MAX_AGE) return response diff --git a/isso/js/isso.js b/isso/js/isso.js index 0eec7bb..def054f 100644 --- a/isso/js/isso.js +++ b/isso/js/isso.js @@ -91,7 +91,7 @@ function form(id, appendfunc, eventfunc) { var formid = 'issoform' + (id ? ('_' + id) : ''), form = '
' + '
' + - ' ' + + ' ' + '
' + '
' + ' ' + @@ -100,7 +100,7 @@ function form(id, appendfunc, eventfunc) { '' + '
' + '
' + - ' ' + + ' ' + '
' + '
' + '' + @@ -127,12 +127,6 @@ function insert(post) { */ var path = encodeURIComponent(window.location.pathname); - var author = post['author'] || 'Anonymous'; - - if (post['website']) { - author = '' + author + ''; - } - var date = new Date(parseInt(post['created']) * 1000); // create
    for parent, if used @@ -140,19 +134,48 @@ function insert(post) { $('#isso_' + post['parent']).append('
      '); } - $(post['parent'] ? '#isso_' + post['parent'] + ' > ul:last-child' : '#isso_thread > ul').append( + $(post['parent'] ? '#isso_' + post['parent'] + ' > ul:last-child' : '#isso_thread > ul') + .append( '
      ' + - '
      ' + author + '' + - '
      ' + - '
      ' + post['text'] + - '
      ' + - ' ' + - '
      '); + '
      ' + + '
      ' + + '
      ' + + '' + ); + + var node = $('#isso_' + post['id']), + author = post['author'] || 'Anonymous'; + + if (post['website']) + author = '' + author + ''; + + // deleted + if (post['mode'] == 4) { + node.addClass('deleted'); + $('header', node).append('Kommentar entfernt') + $('div', node).append('

       

      ') + return; + } + + $('header', node).append('' + author + ''); + if (post['mode'] == 2 ) + $('helpers', node).append('Kommentar muss noch freigeschaltet werden'); + + $('div', node).append(post['text']); + + $('footer', node).append( + 'Antworten' + + '#' + post['id'] + '' + + '' + ) + + // pending notification + if (post['mode'] == 2 ) { + $('#isso_' + post['id'] + ' header') + .append('Kommentar muss noch freigeschaltet werden'); + } if (read('session-' + path + '-' + post['id'])) { $('#isso_' + post['id'] + '> footer > a:first-child') @@ -225,10 +248,11 @@ function insert(post) { parent: post['id'] }, function(status, rv) { $('#issoform_' + post['id']).remove(); - - if (status == 201) { + if (status == 201 || status == 202) { insert(JSON.parse(rv)); - } // XXX else ... + } else { + alert("Mööp."); + }; }); }); } else { @@ -260,7 +284,7 @@ function initialize(thread) { website: $('input[id="website"]').val() || null, parent: null }, function(status, rv) { - if (status == 201) { + if (status == 201 || status == 202) { insert(JSON.parse(rv)); } }); diff --git a/isso/static/style.css b/isso/static/style.css index 7b648eb..5db7228 100644 --- a/isso/static/style.css +++ b/isso/static/style.css @@ -8,18 +8,37 @@ margin-top: 18px; } +.isso footer a, .isso header a { + color: #111111; + font-family: Palatino, "times new roman", serif; + font-weight: bold; + font-size: 0.95em; + text-decoration: none; +} + +.isso footer a:hover, .isso header a:hover { + color: #111111; + text-shadow: #aaaaaa 0px 0px 1px; +} + .isso .author { font-weight: bold; } .isso time { color: lightgray; + float: right; } .isso > header { border-bottom: solid 1px lightgray; } +.isso > header .note { + float: right; + color: gray; +} + .isso > footer > a { padding: 0 10px 10px 0; }