summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile6
-rw-r--r--activitypub.c31
-rw-r--r--html.c19
3 files changed, 43 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index ae3b231..01dab0d 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,12 @@ install:
mkdir -p -m 755 $(PREFIX_MAN)/man8
install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8
+uninstall:
+ rm $(PREFIX)/bin/snac
+ rm $(PREFIX_MAN)/man1/snac.1
+ rm $(PREFIX_MAN)/man5/snac.5
+ rm $(PREFIX_MAN)/man8/snac.8
+
activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \
xs_openssl.h xs_regex.h xs_time.h xs_set.h snac.h
data.o: data.c xs.h xs_io.h xs_json.h xs_openssl.h xs_glob.h xs_set.h \
diff --git a/activitypub.c b/activitypub.c
index dddeb20..4919a61 100644
--- a/activitypub.c
+++ b/activitypub.c
@@ -1057,6 +1057,7 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
xs *ntid = tid(0);
xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0);
int max = 8;
+ xs_set seen;
msg = xs_dict_set(msg, "type", "Question");
@@ -1068,20 +1069,30 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
xs_str *v;
xs *replies = xs_json_loads("{\"type\":\"Collection\",\"totalItems\":0}");
- while (max-- && xs_list_iter(&p, &v)) {
- xs *v2 = xs_dup(v);
- xs *d = xs_dict_new();
+ xs_set_init(&seen);
- if (strlen(v2) > 60) {
- v2[60] = '\0';
- v2 = xs_str_cat(v2, "...");
- }
+ while (max && xs_list_iter(&p, &v)) {
+ if (*v) {
+ xs *v2 = xs_dup(v);
+ xs *d = xs_dict_new();
+
+ if (strlen(v2) > 60) {
+ v2[60] = '\0';
+ v2 = xs_str_cat(v2, "...");
+ }
+
+ if (xs_set_add(&seen, v2) == 1) {
+ d = xs_dict_append(d, "name", v2);
+ d = xs_dict_append(d, "replies", replies);
+ o = xs_list_append(o, d);
- d = xs_dict_append(d, "name", v2);
- d = xs_dict_append(d, "replies", replies);
- o = xs_list_append(o, d);
+ max--;
+ }
+ }
}
+ xs_set_free(&seen);
+
msg = xs_dict_append(msg, multiple ? "anyOf" : "oneOf", o);
/* set the end time */
diff --git a/html.c b/html.c
index bf71710..37a884f 100644
--- a/html.c
+++ b/html.c
@@ -815,6 +815,12 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
/* add the ballot box emoji */
xs *f = xs_fmt("<span title=\"%s\"> &#128499; </span>", L("Poll"));
s = xs_str_cat(s, f);
+
+ if (was_question_voted(snac, id)) {
+ /* add a check to show this poll was voted */
+ xs *f2 = xs_fmt("<span title=\"%s\"> &#10003; </span>", L("Voted"));
+ s = xs_str_cat(s, f2);
+ }
}
/* if this is our post, add the score */
@@ -1049,6 +1055,10 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
if ((attach = xs_dict_get(msg, "attachment")) != NULL) { /** **/
char *v;
+
+ /* make custom css for attachments easier */
+ s = xs_str_cat(s, "<p class=\"snac-content-attachments\">\n");
+
while (xs_list_iter(&attach, &v)) {
char *t = xs_dict_get(v, "mediaType");
@@ -1060,8 +1070,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
char *name = xs_dict_get(v, "name");
if (url != NULL) {
- xs *s1 = xs_fmt("<p><img src=\"%s\" alt=\"%s\" loading=\"lazy\"/></p>\n",
- url, xs_is_null(name) ? "" : name);
+ xs *s1 = xs_fmt(
+ "<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" loading=\"lazy\"/></a>\n",
+ url, url, xs_is_null(name) ? "" : name);
s = xs_str_cat(s, s1);
}
@@ -1071,12 +1082,14 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
char *url = xs_dict_get(v, "url");
if (url != NULL) {
- xs *s1 = xs_fmt("<p><object data=\"%s\"></object></p>\n", url);
+ xs *s1 = xs_fmt("<object data=\"%s\"></object>\n", url);
s = xs_str_cat(s, s1);
}
}
}
+
+ s = xs_str_cat(s, "</p>\n");
}
if (sensitive)