mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-22 13:25:04 +00:00
Some work towards an instance timeline.
This commit is contained in:
parent
8970df96ea
commit
64111f85bd
1 changed files with 48 additions and 18 deletions
66
html.c
66
html.c
|
@ -218,10 +218,10 @@ xs_str *html_msg_icon(xs_str *os, const xs_dict *msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
xs_str *html_base_header(xs_str *s)
|
||||||
/* creates the HTML header */
|
|
||||||
{
|
{
|
||||||
char *p, *v;
|
xs_list *p;
|
||||||
|
xs_str *v;
|
||||||
|
|
||||||
s = xs_str_cat(s, "<!DOCTYPE html>\n<html>\n<head>\n");
|
s = xs_str_cat(s, "<!DOCTYPE html>\n<html>\n<head>\n");
|
||||||
s = xs_str_cat(s, "<meta name=\"viewport\" "
|
s = xs_str_cat(s, "<meta name=\"viewport\" "
|
||||||
|
@ -236,6 +236,25 @@ xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xs_str *html_instance_header(xs_str *s)
|
||||||
|
{
|
||||||
|
s = html_base_header(s);
|
||||||
|
|
||||||
|
s = xs_str_cat(s, "</head>\n<body>\n");
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
xs_str *html_user_header(snac *snac, xs_str *s, int local)
|
||||||
|
/* creates the HTML header */
|
||||||
|
{
|
||||||
|
s = html_base_header(s);
|
||||||
|
|
||||||
/* add the user CSS */
|
/* add the user CSS */
|
||||||
{
|
{
|
||||||
xs *css = NULL;
|
xs *css = NULL;
|
||||||
|
@ -1345,7 +1364,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_user_footer(xs_str *s)
|
xs_str *html_footer(xs_str *s)
|
||||||
{
|
{
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<div class=\"snac-footer\">\n"
|
"<div class=\"snac-footer\">\n"
|
||||||
|
@ -1361,7 +1380,7 @@ xs_str *html_user_footer(xs_str *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int show, int show_more)
|
xs_str *html_timeline(snac *user, const xs_list *list, int local, int skip, int show, int show_more)
|
||||||
/* returns the HTML for the timeline */
|
/* returns the HTML for the timeline */
|
||||||
{
|
{
|
||||||
xs_str *s = xs_str_new(NULL);
|
xs_str *s = xs_str_new(NULL);
|
||||||
|
@ -1369,26 +1388,35 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
|
||||||
char *v;
|
char *v;
|
||||||
double t = ftime();
|
double t = ftime();
|
||||||
|
|
||||||
s = html_user_header(snac, s, local);
|
if (user)
|
||||||
|
s = html_user_header(user, s, local);
|
||||||
|
else
|
||||||
|
s = html_instance_header(s);
|
||||||
|
|
||||||
if (!local)
|
if (user && !local)
|
||||||
s = html_top_controls(snac, s);
|
s = html_top_controls(user, s);
|
||||||
|
|
||||||
s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n");
|
s = xs_str_cat(s, "<a name=\"snac-posts\"></a>\n");
|
||||||
s = xs_str_cat(s, "<div class=\"snac-posts\">\n");
|
s = xs_str_cat(s, "<div class=\"snac-posts\">\n");
|
||||||
|
|
||||||
while (xs_list_iter(&p, &v)) {
|
while (xs_list_iter(&p, &v)) {
|
||||||
xs *msg = NULL;
|
xs *msg = NULL;
|
||||||
|
int status;
|
||||||
|
|
||||||
if (!valid_status(timeline_get_by_md5(snac, v, &msg)))
|
if (user)
|
||||||
|
status = timeline_get_by_md5(user, v, &msg);
|
||||||
|
else
|
||||||
|
status = object_get_by_md5(v, &msg);
|
||||||
|
|
||||||
|
if (!valid_status(status))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
s = html_entry(snac, s, msg, local, 0, v, 0);
|
s = html_entry(user, s, msg, local, 0, v, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = xs_str_cat(s, "</div>\n");
|
s = xs_str_cat(s, "</div>\n");
|
||||||
|
|
||||||
if (local) {
|
if (user && local) {
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<div class=\"snac-history\">\n"
|
"<div class=\"snac-history\">\n"
|
||||||
"<p class=\"snac-history-title\">%s</p><ul>\n",
|
"<p class=\"snac-history-title\">%s</p><ul>\n",
|
||||||
|
@ -1397,7 +1425,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
|
|
||||||
xs *list = history_list(snac);
|
xs *list = history_list(user);
|
||||||
char *p, *v;
|
char *p, *v;
|
||||||
|
|
||||||
p = list;
|
p = list;
|
||||||
|
@ -1405,7 +1433,7 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
|
||||||
xs *fn = xs_replace(v, ".html", "");
|
xs *fn = xs_replace(v, ".html", "");
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<li><a href=\"%s/h/%s\">%s</a></li>\n",
|
"<li><a href=\"%s/h/%s\">%s</a></li>\n",
|
||||||
snac->actor, v, fn);
|
user->actor, v, fn);
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
@ -1419,19 +1447,21 @@ xs_str *html_timeline(snac *snac, const xs_list *list, int local, int skip, int
|
||||||
}
|
}
|
||||||
|
|
||||||
if (show_more) {
|
if (show_more) {
|
||||||
|
const char *base_url = user ? user->actor : srv_baseurl;
|
||||||
|
|
||||||
xs *s1 = xs_fmt(
|
xs *s1 = xs_fmt(
|
||||||
"<p>"
|
"<p>"
|
||||||
"<a href=\"%s%s\" name=\"snac-more\">%s</a> - "
|
"<a href=\"%s%s\" name=\"snac-more\">%s</a> - "
|
||||||
"<a href=\"%s%s?skip=%d&show=%d\" name=\"snac-more\">%s</a>"
|
"<a href=\"%s%s?skip=%d&show=%d\" name=\"snac-more\">%s</a>"
|
||||||
"</p>\n",
|
"</p>\n",
|
||||||
snac->actor, local ? "" : "/admin", L("Back to top"),
|
base_url, local ? "" : "/admin", L("Back to top"),
|
||||||
snac->actor, local ? "" : "/admin", skip + show, show, L("Older entries...")
|
base_url, local ? "" : "/admin", skip + show, show, L("Older entries...")
|
||||||
);
|
);
|
||||||
|
|
||||||
s = xs_str_cat(s, s1);
|
s = xs_str_cat(s, s1);
|
||||||
}
|
}
|
||||||
|
|
||||||
s = html_user_footer(s);
|
s = html_footer(s);
|
||||||
|
|
||||||
s = xs_str_cat(s, "</body>\n</html>\n");
|
s = xs_str_cat(s, "</body>\n</html>\n");
|
||||||
|
|
||||||
|
@ -1567,7 +1597,7 @@ xs_str *html_people(snac *snac)
|
||||||
|
|
||||||
s = html_people_list(snac, s, wers, L("People that follow you"), "e");
|
s = html_people_list(snac, s, wers, L("People that follow you"), "e");
|
||||||
|
|
||||||
s = html_user_footer(s);
|
s = html_footer(s);
|
||||||
|
|
||||||
s = xs_str_cat(s, "</body>\n</html>\n");
|
s = xs_str_cat(s, "</body>\n</html>\n");
|
||||||
|
|
||||||
|
@ -1684,7 +1714,7 @@ xs_str *html_notifications(snac *snac)
|
||||||
else
|
else
|
||||||
s = xs_str_cat(s, "</div>\n");
|
s = xs_str_cat(s, "</div>\n");
|
||||||
|
|
||||||
s = html_user_footer(s);
|
s = html_footer(s);
|
||||||
|
|
||||||
s = xs_str_cat(s, "</body>\n</html>\n");
|
s = xs_str_cat(s, "</body>\n</html>\n");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue