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:
27 mkdir -p -m 755 $(PREFIX_MAN)/man8 27 mkdir -p -m 755 $(PREFIX_MAN)/man8
28 install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8 28 install -m 644 doc/snac.8 $(PREFIX_MAN)/man8/snac.8
29 29
30uninstall:
31 rm $(PREFIX)/bin/snac
32 rm $(PREFIX_MAN)/man1/snac.1
33 rm $(PREFIX_MAN)/man5/snac.5
34 rm $(PREFIX_MAN)/man8/snac.8
35
30activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \ 36activitypub.o: activitypub.c xs.h xs_json.h xs_curl.h xs_mime.h \
31 xs_openssl.h xs_regex.h xs_time.h xs_set.h snac.h 37 xs_openssl.h xs_regex.h xs_time.h xs_set.h snac.h
32data.o: data.c xs.h xs_io.h xs_json.h xs_openssl.h xs_glob.h xs_set.h \ 38data.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,
1057 xs *ntid = tid(0); 1057 xs *ntid = tid(0);
1058 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0); 1058 xs_dict *msg = msg_note(user, content, NULL, NULL, attach, 0);
1059 int max = 8; 1059 int max = 8;
1060 xs_set seen;
1060 1061
1061 msg = xs_dict_set(msg, "type", "Question"); 1062 msg = xs_dict_set(msg, "type", "Question");
1062 1063
@@ -1068,20 +1069,30 @@ xs_dict *msg_question(snac *user, const char *content, xs_list *attach,
1068 xs_str *v; 1069 xs_str *v;
1069 xs *replies = xs_json_loads("{\"type\":\"Collection\",\"totalItems\":0}"); 1070 xs *replies = xs_json_loads("{\"type\":\"Collection\",\"totalItems\":0}");
1070 1071
1071 while (max-- && xs_list_iter(&p, &v)) { 1072 xs_set_init(&seen);
1072 xs *v2 = xs_dup(v);
1073 xs *d = xs_dict_new();
1074 1073
1075 if (strlen(v2) > 60) { 1074 while (max && xs_list_iter(&p, &v)) {
1076 v2[60] = '\0'; 1075 if (*v) {
1077 v2 = xs_str_cat(v2, "..."); 1076 xs *v2 = xs_dup(v);
1078 } 1077 xs *d = xs_dict_new();
1078
1079 if (strlen(v2) > 60) {
1080 v2[60] = '\0';
1081 v2 = xs_str_cat(v2, "...");
1082 }
1083
1084 if (xs_set_add(&seen, v2) == 1) {
1085 d = xs_dict_append(d, "name", v2);
1086 d = xs_dict_append(d, "replies", replies);
1087 o = xs_list_append(o, d);
1079 1088
1080 d = xs_dict_append(d, "name", v2); 1089 max--;
1081 d = xs_dict_append(d, "replies", replies); 1090 }
1082 o = xs_list_append(o, d); 1091 }
1083 } 1092 }
1084 1093
1094 xs_set_free(&seen);
1095
1085 msg = xs_dict_append(msg, multiple ? "anyOf" : "oneOf", o); 1096 msg = xs_dict_append(msg, multiple ? "anyOf" : "oneOf", o);
1086 1097
1087 /* set the end time */ 1098 /* 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,
815 /* add the ballot box emoji */ 815 /* add the ballot box emoji */
816 xs *f = xs_fmt("<span title=\"%s\"> &#128499; </span>", L("Poll")); 816 xs *f = xs_fmt("<span title=\"%s\"> &#128499; </span>", L("Poll"));
817 s = xs_str_cat(s, f); 817 s = xs_str_cat(s, f);
818
819 if (was_question_voted(snac, id)) {
820 /* add a check to show this poll was voted */
821 xs *f2 = xs_fmt("<span title=\"%s\"> &#10003; </span>", L("Voted"));
822 s = xs_str_cat(s, f2);
823 }
818 } 824 }
819 825
820 /* if this is our post, add the score */ 826 /* 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,
1049 1055
1050 if ((attach = xs_dict_get(msg, "attachment")) != NULL) { /** **/ 1056 if ((attach = xs_dict_get(msg, "attachment")) != NULL) { /** **/
1051 char *v; 1057 char *v;
1058
1059 /* make custom css for attachments easier */
1060 s = xs_str_cat(s, "<p class=\"snac-content-attachments\">\n");
1061
1052 while (xs_list_iter(&attach, &v)) { 1062 while (xs_list_iter(&attach, &v)) {
1053 char *t = xs_dict_get(v, "mediaType"); 1063 char *t = xs_dict_get(v, "mediaType");
1054 1064
@@ -1060,8 +1070,9 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
1060 char *name = xs_dict_get(v, "name"); 1070 char *name = xs_dict_get(v, "name");
1061 1071
1062 if (url != NULL) { 1072 if (url != NULL) {
1063 xs *s1 = xs_fmt("<p><img src=\"%s\" alt=\"%s\" loading=\"lazy\"/></p>\n", 1073 xs *s1 = xs_fmt(
1064 url, xs_is_null(name) ? "" : name); 1074 "<a href=\"%s\" target=\"_blank\"><img src=\"%s\" alt=\"%s\" loading=\"lazy\"/></a>\n",
1075 url, url, xs_is_null(name) ? "" : name);
1065 1076
1066 s = xs_str_cat(s, s1); 1077 s = xs_str_cat(s, s1);
1067 } 1078 }
@@ -1071,12 +1082,14 @@ xs_str *html_entry(snac *snac, xs_str *os, const xs_dict *msg, int local,
1071 char *url = xs_dict_get(v, "url"); 1082 char *url = xs_dict_get(v, "url");
1072 1083
1073 if (url != NULL) { 1084 if (url != NULL) {
1074 xs *s1 = xs_fmt("<p><object data=\"%s\"></object></p>\n", url); 1085 xs *s1 = xs_fmt("<object data=\"%s\"></object>\n", url);
1075 1086
1076 s = xs_str_cat(s, s1); 1087 s = xs_str_cat(s, s1);
1077 } 1088 }
1078 } 1089 }
1079 } 1090 }
1091
1092 s = xs_str_cat(s, "</p>\n");
1080 } 1093 }
1081 1094
1082 if (sensitive) 1095 if (sensitive)