More work on www tree stuff
This commit is contained in:
parent
f0fa63cc5a
commit
0d26b5b06c
219
src/www_msgs.c
219
src/www_msgs.c
@ -96,7 +96,6 @@ char *www_msgs_arealist(struct user_record *user) {
|
|||||||
|
|
||||||
char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip) {
|
char *www_msgs_messagelist(struct user_record *user, int conference, int area, int skip) {
|
||||||
struct msg_headers *mhrs;
|
struct msg_headers *mhrs;
|
||||||
stralloc page = EMPTY_STRALLOC;
|
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
int i;
|
int i;
|
||||||
struct tm msg_date;
|
struct tm msg_date;
|
||||||
@ -108,6 +107,16 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
char *to;
|
char *to;
|
||||||
char *from;
|
char *from;
|
||||||
char *subject;
|
char *subject;
|
||||||
|
char datebuf[32];
|
||||||
|
|
||||||
|
stralloc url;
|
||||||
|
|
||||||
|
struct www_tag *page;
|
||||||
|
struct www_tag *cur_tag;
|
||||||
|
struct www_tag *child_tag;
|
||||||
|
struct www_tag *child_child_tag;
|
||||||
|
struct www_tag *child_child_child_tag;
|
||||||
|
struct www_tag *child_child_child_child_tag;
|
||||||
|
|
||||||
if (conference < 0 || conference >= ptr_vector_len(&conf.mail_conferences))
|
if (conference < 0 || conference >= ptr_vector_len(&conf.mail_conferences))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -116,32 +125,62 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
return NULL;
|
return NULL;
|
||||||
struct mail_area *ma = get_area(conference, area);
|
struct mail_area *ma = get_area(conference, area);
|
||||||
|
|
||||||
stralloc_copys(&page, "<div class=\"content-header\"><h2>");
|
page = www_tag_new(NULL, "");
|
||||||
stralloc_cats(&page, mc->name);
|
cur_tag = www_tag_new("div", NULL);
|
||||||
stralloc_cats(&page, " - ");
|
www_tag_add_attrib(cur_tag, "class", "content-header");
|
||||||
stralloc_cats(&page, ma->name);
|
www_tag_add_child(page, cur_tag);
|
||||||
stralloc_cats(&page, "</h2></div>\n");
|
|
||||||
|
child_tag = www_tag_new("h2", NULL);
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new(NULL, mc->name);
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new(NULL, " - ");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new(NULL, ma->name);
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
if (ma->type != TYPE_NETMAIL_AREA) {
|
if (ma->type != TYPE_NETMAIL_AREA) {
|
||||||
stralloc_cats(&page, "<div class=\"button\"><a href=\"");
|
cur_tag = www_tag_new("div", NULL);
|
||||||
stralloc_cats(&page, conf.www_url);
|
www_tag_add_attrib(cur_tag, "class", "button");
|
||||||
stralloc_cats(&page, "msgs/new/");
|
www_tag_add_child(page, cur_tag);
|
||||||
stralloc_cat_long(&page, conference);
|
|
||||||
stralloc_append1(&page, '/');
|
child_tag = www_tag_new("a", NULL);
|
||||||
stralloc_cat_long(&page, area);
|
|
||||||
stralloc_cats(&page, "\">New Message</a></div>\n");
|
url = EMPTY_STRALLOC;
|
||||||
|
stralloc_cats(&url, conf.www_url);
|
||||||
|
stralloc_cats(&url, "msgs/new/");
|
||||||
|
stralloc_cat_long(&url, conference);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, area);
|
||||||
|
stralloc_0(&url);
|
||||||
|
|
||||||
|
www_tag_add_attrib(child_tag, "href", url.s);
|
||||||
|
free(url.s);
|
||||||
|
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new(NULL, "New Message");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
}
|
}
|
||||||
mhrs = read_message_headers(conference, area, user, 0);
|
mhrs = read_message_headers(conference, area, user, 0);
|
||||||
|
|
||||||
if (mhrs == NULL) {
|
if (mhrs == NULL) {
|
||||||
stralloc_cats(&page, "<h3>No Messages</h3>\n");
|
cur_tag = www_tag_new("h3", NULL);
|
||||||
} else {
|
www_tag_add_child(page, cur_tag);
|
||||||
|
|
||||||
stralloc_cats(&page, "<div class=\"div-table\">\n");
|
child_tag = www_tag_new(NULL, "No Messages");
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
} else {
|
||||||
|
cur_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(cur_tag, "class", "div-table");
|
||||||
|
www_tag_add_child(page, cur_tag);
|
||||||
|
|
||||||
jb = open_jam_base(ma->path);
|
jb = open_jam_base(ma->path);
|
||||||
if (!jb) {
|
if (!jb) {
|
||||||
free(page.s);
|
www_tag_destroy(page);
|
||||||
free_message_headers(mhrs);
|
free_message_headers(mhrs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -163,53 +202,143 @@ char *www_msgs_messagelist(struct user_record *user, int conference, int area, i
|
|||||||
to = www_sanitize(mhrs->msgs[i]->to);
|
to = www_sanitize(mhrs->msgs[i]->to);
|
||||||
from = www_sanitize(mhrs->msgs[i]->from);
|
from = www_sanitize(mhrs->msgs[i]->from);
|
||||||
subject = www_sanitize(mhrs->msgs[i]->subject);
|
subject = www_sanitize(mhrs->msgs[i]->subject);
|
||||||
|
|
||||||
|
child_tag = www_tag_new("div", NULL);
|
||||||
|
|
||||||
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
if (msgbase_is_flagged(user, conference, area, mhrs->msgs[i]->msg_h->MsgNum)) {
|
||||||
if (conf.date_style == 1) {
|
www_tag_add_attrib(child_tag, "class", "msg-summary-flag");
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-flag\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
} else if (mhrs->msgs[i]->msg_h->MsgNum > jlr.HighReadMsg) {
|
||||||
if (conf.date_style == 1) {
|
www_tag_add_attrib(child_tag, "class", "msg-summary");
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
} else {
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
www_tag_add_attrib(child_tag, "class", "msg-summary-seen");
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (conf.date_style == 1) {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mon + 1, msg_date.tm_mday, msg_date.tm_year - 100);
|
|
||||||
} else {
|
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-seen\"><div class=\"msg-summary-id\">%d</div><div class=\"msg-summary-subject\"><a href=\"%smsgs/%d/%d/%d\">%s</a></div><div class=\"msg-summary-from\">%s</div><div class=\"msg-summary-to\">%s</div><div class=\"msg-summary-date\">%.2d:%.2d %.2d-%.2d-%.2d</div></div>\n", mhrs->msgs[i]->msg_no + 1, conf.www_url, conference, area, mhrs->msgs[i]->msg_h->MsgNum, subject, from, to, msg_date.tm_hour, msg_date.tm_min, msg_date.tm_mday, msg_date.tm_mon + 1, msg_date.tm_year - 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(child_child_tag, "class", "msg-summary-id");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
url = EMPTY_STRALLOC;
|
||||||
|
stralloc_cat_long(&url, mhrs->msgs[i]->msg_no + 1);
|
||||||
|
stralloc_0(&url);
|
||||||
|
|
||||||
|
child_child_child_tag = www_tag_new(NULL, url.s);
|
||||||
|
free(url.s);
|
||||||
|
www_tag_add_child(child_child_tag, child_child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(child_child_tag, "class", "msg-summary-subject");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
url = EMPTY_STRALLOC;
|
||||||
|
stralloc_cats(&url, conf.www_url);
|
||||||
|
stralloc_cats(&url, "msgs/");
|
||||||
|
stralloc_cat_long(&url, conference);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, area);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, mhrs->msgs[i]->msg_h->MsgNum);
|
||||||
|
stralloc_0(&url);
|
||||||
|
|
||||||
|
child_child_child_tag = www_tag_new("a", NULL);
|
||||||
|
www_tag_add_attrib(child_child_child_tag, "href", url.s);
|
||||||
|
free(url.s);
|
||||||
|
www_tag_add_child(child_child_tag, child_child_child_tag);
|
||||||
|
|
||||||
|
child_child_child_child_tag = www_tag_new(NULL, subject);
|
||||||
|
www_tag_add_child(child_child_child_tag, child_child_child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(child_child_tag, "class", "msg-summary-from");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
child_child_child_tag = www_tag_new(NULL, from);
|
||||||
|
www_tag_add_child(child_child_tag, child_child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(child_child_tag, "class", "msg-summary-to");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
child_child_child_tag = www_tag_new(NULL, to);
|
||||||
|
www_tag_add_child(child_child_tag, child_child_child_tag);
|
||||||
|
|
||||||
|
child_child_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(child_child_tag, "class", "msg-summary-date");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
|
|
||||||
|
if (conf.date_style == 1)
|
||||||
|
strftime(datebuf, sizeof datebuf, "%H:%M %m-%d-%y", &msg_date);
|
||||||
|
else
|
||||||
|
strftime(datebuf, sizeof datebuf, "%H:%M %d-%m-%y", &msg_date);
|
||||||
|
|
||||||
|
child_child_child_tag = www_tag_new(NULL, datebuf);
|
||||||
|
www_tag_add_child(child_child_tag, child_child_child_tag);
|
||||||
|
|
||||||
free(to);
|
free(to);
|
||||||
free(from);
|
free(from);
|
||||||
free(subject);
|
free(subject);
|
||||||
|
|
||||||
stralloc_cats(&page, buffer);
|
|
||||||
}
|
}
|
||||||
stralloc_cats(&page, "</div>\n");
|
|
||||||
if (skip + 50 <= mhrs->msg_count) {
|
if (skip + 50 <= mhrs->msg_count) {
|
||||||
snprintf(buffer, sizeof buffer,
|
cur_tag = www_tag_new("div", NULL);
|
||||||
"<div class=\"msg-summary-next\"><a href=\"%smsgs/%d/%d/?skip=%d\">Next</a></div>\n",
|
www_tag_add_attrib(cur_tag, "class", "msg-summary-next");
|
||||||
conf.www_url, conference, area, skip + 50);
|
www_tag_add_child(page, cur_tag);
|
||||||
stralloc_cats(&page, buffer);
|
|
||||||
|
child_tag = www_tag_new("a", NULL);
|
||||||
|
|
||||||
|
url = EMPTY_STRALLOC;
|
||||||
|
|
||||||
|
stralloc_cats(&url, conf.www_url);
|
||||||
|
stralloc_cats(&url, "msgs/");
|
||||||
|
stralloc_cat_long(&url, conference);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, area);
|
||||||
|
stralloc_cats(&url, "/?skip=");
|
||||||
|
stralloc_cat_long(&url, skip + 50);
|
||||||
|
stralloc_0(&url);
|
||||||
|
|
||||||
|
www_tag_add_attrib(child_tag, "href", url.s);
|
||||||
|
free(url.s);
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
child_child_tag = www_tag_new(NULL, "Next");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (skip > 0) {
|
if (skip > 0) {
|
||||||
|
cur_tag = www_tag_new("div", NULL);
|
||||||
|
www_tag_add_attrib(cur_tag, "class", "msg-summary-prev");
|
||||||
|
www_tag_add_child(page, cur_tag);
|
||||||
|
child_tag = www_tag_new("a", NULL);
|
||||||
|
url = EMPTY_STRALLOC;
|
||||||
if (skip - 50 < 0) {
|
if (skip - 50 < 0) {
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/\">Prev</a></div>\n", conf.www_url, conference, area);
|
stralloc_cats(&url, conf.www_url);
|
||||||
|
stralloc_cats(&url, "msgs/");
|
||||||
|
stralloc_cat_long(&url, conference);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, area);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
} else {
|
} else {
|
||||||
snprintf(buffer, sizeof buffer, "<div class=\"msg-summary-prev\"><a href=\"%smsgs/%d/%d/?skip=%d\">Prev</a></div>\n", conf.www_url, conference, area, skip - 50);
|
stralloc_cats(&url, conf.www_url);
|
||||||
|
stralloc_cats(&url, "msgs/");
|
||||||
|
stralloc_cat_long(&url, conference);
|
||||||
|
stralloc_append1(&url, '/');
|
||||||
|
stralloc_cat_long(&url, area);
|
||||||
|
stralloc_cats(&url, "/?skip=");
|
||||||
|
stralloc_cat_long(&url, skip - 50);
|
||||||
}
|
}
|
||||||
stralloc_cats(&page, buffer);
|
stralloc_0(&url);
|
||||||
|
www_tag_add_attrib(child_tag, "href", url.s);
|
||||||
|
free(url.s);
|
||||||
|
|
||||||
|
www_tag_add_child(cur_tag, child_tag);
|
||||||
|
child_child_tag = www_tag_new(NULL, "Prev");
|
||||||
|
www_tag_add_child(child_tag, child_child_tag);
|
||||||
}
|
}
|
||||||
free_message_headers(mhrs);
|
free_message_headers(mhrs);
|
||||||
}
|
}
|
||||||
stralloc_0(&page);
|
|
||||||
|
|
||||||
return page.s;
|
return www_tag_unwravel(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg) {
|
char *www_msgs_messageview(struct user_record *user, int conference, int area, int msg) {
|
||||||
@ -244,7 +373,7 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
char *nodename;
|
char *nodename;
|
||||||
struct fido_addr *nodeno;
|
struct fido_addr *nodeno;
|
||||||
|
|
||||||
struct www_tag *page = www_tag_new(NULL, "");
|
struct www_tag *page;
|
||||||
struct www_tag *cur_tag;
|
struct www_tag *cur_tag;
|
||||||
struct www_tag *child_tag;
|
struct www_tag *child_tag;
|
||||||
struct www_tag *child_child_tag;
|
struct www_tag *child_child_tag;
|
||||||
@ -345,6 +474,8 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
|
|||||||
JAM_CloseMB(jb);
|
JAM_CloseMB(jb);
|
||||||
free(jb);
|
free(jb);
|
||||||
|
|
||||||
|
page = www_tag_new(NULL, "");
|
||||||
|
|
||||||
cur_tag = www_tag_new("div", NULL);
|
cur_tag = www_tag_new("div", NULL);
|
||||||
www_tag_add_attrib(cur_tag, "class", "content-header");
|
www_tag_add_attrib(cur_tag, "class", "content-header");
|
||||||
www_tag_add_child(page, cur_tag);
|
www_tag_add_child(page, cur_tag);
|
||||||
|
Reference in New Issue
Block a user