updating comment format to match defined JSON-LD API context

This commit is contained in:
El RIDO 2015-10-18 11:38:48 +02:00
parent f21567133c
commit 22d0b1ec22
5 changed files with 16 additions and 10 deletions

View File

@ -2,9 +2,16 @@
"@context": { "@context": {
"status": "http://schema.org/Integer", "status": "http://schema.org/Integer",
"id": "http://schema.org/name", "id": "http://schema.org/name",
"parentid": "http://schema.org/name",
"url: { "url: {
"@id": "http://schema.org/url", "@id": "http://schema.org/url",
"@type": "@id" "@type": "@id"
},
"data": "http://schema.org/Text",
"meta": {
"postdate": "http://schema.org/Integer",
"nickname": "http://schema.org/Text",
"vizhash": "http://schema.org/Text"
} }
} }
} }

View File

@ -709,18 +709,18 @@ $(function() {
catch(err) catch(err)
{} {}
// If parent comment exists, display below (CSS will automatically shift it right.) // If parent comment exists, display below (CSS will automatically shift it right.)
var cname = '#comment_' + comment.meta.parentid; var cname = '#comment_' + comment.parentid;
// If the element exists in page // If the element exists in page
if ($(cname).length) if ($(cname).length)
{ {
place = $(cname); place = $(cname);
} }
var divComment = $('<article><div class="comment" id="comment_' + comment.meta.commentid+'">' var divComment = $('<article><div class="comment" id="comment_' + comment.id + '">'
+ '<div class="commentmeta"><span class="nickname"></span><span class="commentdate"></span></div><div class="commentdata"></div>' + '<div class="commentmeta"><span class="nickname"></span><span class="commentdate"></span></div><div class="commentdata"></div>'
+ '<button class="btn btn-default btn-sm">' + i18n._('Reply') + '</button>' + '<button class="btn btn-default btn-sm">' + i18n._('Reply') + '</button>'
+ '</div></article>'); + '</div></article>');
divComment.find('button').click({commentid: comment.meta.commentid}, $.proxy(this.openReply, this)); divComment.find('button').click({commentid: comment.id}, $.proxy(this.openReply, this));
helper.setElementText(divComment.find('div.commentdata'), cleartext); helper.setElementText(divComment.find('div.commentdata'), cleartext);
// Convert URLs to clickable links in comment. // Convert URLs to clickable links in comment.
helper.urls2links(divComment.find('div.commentdata')); helper.urls2links(divComment.find('div.commentdata'));
@ -737,7 +737,7 @@ $(function() {
} }
divComment.find('span.commentdate') divComment.find('span.commentdate')
.text(' (' + (new Date(comment.meta.postdate * 1000).toLocaleString()) + ')') .text(' (' + (new Date(comment.meta.postdate * 1000).toLocaleString()) + ')')
.attr('title', 'CommentID: ' + comment.meta.commentid); .attr('title', 'CommentID: ' + comment.id);
// If an avatar is available, display it. // If an avatar is available, display it.
if (comment.meta.vizhash) if (comment.meta.vizhash)

View File

@ -444,7 +444,6 @@ class zerobin
$result['url'] = ( $result['url'] = (
array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : '/' array_key_exists('REQUEST_URI', $_SERVER) ? $_SERVER['REQUEST_URI'] : '/'
) . '?' . $message; ) . '?' . $message;
$result['@context'] = 'js/paste.jsonld';
} }
$result += $other; $result += $other;
$this->_json = json_encode($result); $this->_json = json_encode($result);

View File

@ -177,8 +177,8 @@ class zerobin_data extends zerobin_abstract
$comment = json_decode(file_get_contents($discdir . $filename)); $comment = json_decode(file_get_contents($discdir . $filename));
$items = explode('.', $filename); $items = explode('.', $filename);
// Add some meta information not contained in file. // Add some meta information not contained in file.
$comment->meta->commentid = $items[1]; $comment->id = $items[1];
$comment->meta->parentid = $items[2]; $comment->parentid = $items[2];
// Store in array // Store in array
$key = $this->getOpenSlot($comments, (int) $comment->meta->postdate); $key = $this->getOpenSlot($comments, (int) $comment->meta->postdate);

View File

@ -378,15 +378,15 @@ class zerobin_db extends zerobin_abstract
{ {
$i = $this->getOpenSlot($comments, (int) $row['postdate']); $i = $this->getOpenSlot($comments, (int) $row['postdate']);
$comments[$i] = new stdClass; $comments[$i] = new stdClass;
$comments[$i]->id = $row['dataid'];
$comments[$i]->parentid = $row['parentid'];
$comments[$i]->data = $row['data']; $comments[$i]->data = $row['data'];
$comments[$i]->meta = new stdClass; $comments[$i]->meta = new stdClass;
$comments[$i]->meta->postdate = (int) $row['postdate'];
if (array_key_exists('nickname', $row)) if (array_key_exists('nickname', $row))
$comments[$i]->meta->nickname = $row['nickname']; $comments[$i]->meta->nickname = $row['nickname'];
if (array_key_exists('vizhash', $row)) if (array_key_exists('vizhash', $row))
$comments[$i]->meta->vizhash = $row['vizhash']; $comments[$i]->meta->vizhash = $row['vizhash'];
$comments[$i]->meta->postdate = (int) $row['postdate'];
$comments[$i]->meta->commentid = $row['dataid'];
$comments[$i]->meta->parentid = $row['parentid'];
} }
ksort($comments); ksort($comments);
} }