projects
/
blerg.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix reload between permalink and user page
[blerg.git]
/
common
/
json.c
diff --git
a/common/json.c
b/common/json.c
index
6b793ab
..
eebea2c
100644
(file)
--- a/
common/json.c
+++ b/
common/json.c
@@
-1,3
+1,6
@@
+/* Blerg is (C) 2011 The Dominion of Awesome, and is distributed under a
+ * BSD-style license. Please see the COPYING file for details.
+ */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@
-5,7
+8,7
@@
#include "database.h"
#include "json.h"
#include "database.h"
#include "json.h"
-void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record) {
+void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, uint64_t record
, int brief
) {
char *data;
char number[21];
int len;
char *data;
char number[21];
int len;
@@
-15,6
+18,16
@@
void json_generate_one_record(yajl_gen g, const char *author, struct blerg *b, u
return;
}
return;
}
+ if (brief && len > 150) {
+ len = 150;
+ /* This is a bit of a hackish way to add an ellipsis, and will
+ * probably cause weird results if we overwrite part of a UTF-8
+ * char */
+ data[149] = '.';
+ data[148] = '.';
+ data[147] = '.';
+ }
+
yajl_gen_map_open(g);
if (author != NULL) {
yajl_gen_string(g, "author", 6);
yajl_gen_map_open(g);
if (author != NULL) {
yajl_gen_string(g, "author", 6);