mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 14:35:04 +00:00
Use xs_html in the static greeting page.
This commit is contained in:
parent
7d7110cb3b
commit
f4633b9356
2 changed files with 21 additions and 15 deletions
4
Makefile
4
Makefile
|
@ -43,8 +43,8 @@ html.o: html.c xs.h xs_io.h xs_json.h xs_regex.h xs_set.h xs_openssl.h \
|
||||||
http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \
|
http.o: http.c xs.h xs_io.h xs_openssl.h xs_curl.h xs_time.h xs_json.h \
|
||||||
snac.h
|
snac.h
|
||||||
httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_httpd.h xs_mime.h \
|
httpd.o: httpd.c xs.h xs_io.h xs_json.h xs_socket.h xs_httpd.h xs_mime.h \
|
||||||
xs_time.h xs_openssl.h xs_fcgi.h snac.h
|
xs_time.h xs_openssl.h xs_fcgi.h xs_html.h snac.h
|
||||||
main.o: main.c xs.h xs_io.h xs_json.h snac.h
|
main.o: main.c xs.h xs_io.h xs_json.h snac.h xs_html.h
|
||||||
mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \
|
mastoapi.o: mastoapi.c xs.h xs_hex.h xs_openssl.h xs_json.h xs_io.h \
|
||||||
xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \
|
xs_time.h xs_glob.h xs_set.h xs_random.h xs_url.h xs_mime.h xs_match.h \
|
||||||
snac.h
|
snac.h
|
||||||
|
|
32
httpd.c
32
httpd.c
|
@ -10,6 +10,7 @@
|
||||||
#include "xs_time.h"
|
#include "xs_time.h"
|
||||||
#include "xs_openssl.h"
|
#include "xs_openssl.h"
|
||||||
#include "xs_fcgi.h"
|
#include "xs_fcgi.h"
|
||||||
|
#include "xs_html.h"
|
||||||
|
|
||||||
#include "snac.h"
|
#include "snac.h"
|
||||||
|
|
||||||
|
@ -98,32 +99,37 @@ static xs_str *greeting_html(void)
|
||||||
|
|
||||||
/* does it have a %userlist% mark? */
|
/* does it have a %userlist% mark? */
|
||||||
if (xs_str_in(s, "%userlist%") != -1) {
|
if (xs_str_in(s, "%userlist%") != -1) {
|
||||||
const char *host = xs_dict_get(srv_config, "host");
|
char *host = xs_dict_get(srv_config, "host");
|
||||||
xs *list = user_list();
|
xs *list = user_list();
|
||||||
xs_list *p;
|
xs_list *p = list;
|
||||||
xs_str *uid;
|
xs_str *uid;
|
||||||
xs *ul = xs_str_new("<ul class=\"snac-user-list\">\n");
|
|
||||||
|
xs_html *ul = xs_html_tag("ul",
|
||||||
|
xs_html_attr("class", "snac-user-list"));
|
||||||
|
|
||||||
p = list;
|
p = list;
|
||||||
while (xs_list_iter(&p, &uid)) {
|
while (xs_list_iter(&p, &uid)) {
|
||||||
snac user;
|
snac user;
|
||||||
|
|
||||||
if (user_open(&user, uid)) {
|
if (user_open(&user, uid)) {
|
||||||
xs *uname = encode_html(xs_dict_get(user.config, "name"));
|
xs_html_add(ul,
|
||||||
|
xs_html_tag("li",
|
||||||
xs *u = xs_fmt(
|
xs_html_tag("a",
|
||||||
"<li><a href=\"%s\">@%s@%s (%s)</a></li>\n",
|
xs_html_attr("href", user.actor),
|
||||||
user.actor, uid, host, uname);
|
xs_html_text("@"),
|
||||||
|
xs_html_text(uid),
|
||||||
ul = xs_str_cat(ul, u);
|
xs_html_text("@"),
|
||||||
|
xs_html_text(host),
|
||||||
|
xs_html_text(" ("),
|
||||||
|
xs_html_text(xs_dict_get(user.config, "name")),
|
||||||
|
xs_html_text(")"))));
|
||||||
|
|
||||||
user_free(&user);
|
user_free(&user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ul = xs_str_cat(ul, "</ul>\n");
|
xs *s1 = xs_html_render(ul);
|
||||||
|
s = xs_replace_i(s, "%userlist%", s1);
|
||||||
s = xs_replace_i(s, "%userlist%", ul);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue