mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-12 19:33:03 +00:00
Embed CSS in email
This commit is contained in:
parent
3b3b199302
commit
5165daf35c
59
src/elogd.c
59
src/elogd.c
@ -2361,7 +2361,7 @@ int sendmail(LOGBOOK * lbs, char *smtp_host, char *from, char *to, char *text, c
|
|||||||
|
|
||||||
/* replace "." at beginning of line by ".." */
|
/* replace "." at beginning of line by ".." */
|
||||||
strlcpy(str, text, strsize);
|
strlcpy(str, text, strsize);
|
||||||
strsubst(str, strsize, "\r\n.\r\n", "\r\n..\r\n");
|
strsubst(str, strsize, "\n.", "\n..");
|
||||||
|
|
||||||
/* add ".<CR>" to signal end of message */
|
/* add ".<CR>" to signal end of message */
|
||||||
strlcat(str, ".\r\n", strsize);
|
strlcat(str, ".\r\n", strsize);
|
||||||
@ -7624,10 +7624,10 @@ void show_plain_header(int size, char *file_name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void show_html_header(LOGBOOK * lbs, BOOL expires, char *title, BOOL close_head, BOOL rss_feed, char *cookie,
|
void show_html_header(LOGBOOK * lbs, BOOL expires, char *title, BOOL close_head, BOOL rss_feed, char *cookie,
|
||||||
int absolute_link, int refresh)
|
int embed_css, int refresh)
|
||||||
{
|
{
|
||||||
int i, n;
|
int i, n;
|
||||||
char css[1000], css_base[1000], str[1000], media[1000];
|
char css[1000], css_base[1000], str[1000], media[1000], file_name[256];
|
||||||
char css_list[MAX_N_LIST][NAME_LENGTH];
|
char css_list[MAX_N_LIST][NAME_LENGTH];
|
||||||
|
|
||||||
show_http_header(lbs, expires, cookie);
|
show_http_header(lbs, expires, cookie);
|
||||||
@ -7648,17 +7648,40 @@ void show_html_header(LOGBOOK * lbs, BOOL expires, char *title, BOOL close_head,
|
|||||||
rsprintf("<title>%s</title>\n", title);
|
rsprintf("<title>%s</title>\n", title);
|
||||||
|
|
||||||
/* Cascading Style Sheet */
|
/* Cascading Style Sheet */
|
||||||
if (absolute_link) {
|
if (embed_css) {
|
||||||
if (lbs != NULL && getcfg(lbs->name, "Email CSS URL", str, sizeof(str)))
|
strlcpy(css, "elog.css", sizeof(css));
|
||||||
strlcpy(css_base, str, sizeof(css_base));
|
if (lbs != NULL && getcfg(lbs->name, "CSS", str, sizeof(str)))
|
||||||
else if (lbs == NULL && getcfg("global", "Email CSS URL", str, sizeof(str)))
|
strlcpy(css, str, sizeof(css));
|
||||||
strlcpy(css_base, str, sizeof(css_base));
|
else if (lbs == NULL && getcfg("global", "CSS", str, sizeof(str)))
|
||||||
if (css_base[0] == 0)
|
strlcpy(css, str, sizeof(css));
|
||||||
compose_base_url(lbs, css_base, sizeof(css_base), FALSE);
|
|
||||||
} else
|
|
||||||
css_base[0] = 0;
|
|
||||||
|
|
||||||
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%selog.css\">\n", css_base);
|
strlcpy(file_name, resource_dir, sizeof(str));
|
||||||
|
strlcat(file_name, "themes", sizeof(str));
|
||||||
|
strlcat(file_name, DIR_SEPARATOR_STR, sizeof(str));
|
||||||
|
strlcat(file_name, theme_name, sizeof(str));
|
||||||
|
strlcat(file_name, DIR_SEPARATOR_STR, sizeof(str));
|
||||||
|
strlcat(file_name, css, sizeof(str));
|
||||||
|
|
||||||
|
FILE *f = fopen(file_name, "rb");
|
||||||
|
if (f != NULL) {
|
||||||
|
fseek(f, 0, SEEK_END);
|
||||||
|
int size = TELL(fileno(f));
|
||||||
|
fseek(f, 0, SEEK_SET);
|
||||||
|
|
||||||
|
char *buf = xmalloc(size + 100);
|
||||||
|
fread(buf, 1, size, f);
|
||||||
|
buf[size] = 0;
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
rsprintf("<style>\n");
|
||||||
|
rsputs(buf);
|
||||||
|
rsprintf("</style>\n");
|
||||||
|
|
||||||
|
xfree(buf);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"elog.css\">\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (lbs != NULL && getcfg(lbs->name, "CSS", str, sizeof(str)))
|
if (lbs != NULL && getcfg(lbs->name, "CSS", str, sizeof(str)))
|
||||||
strlcpy(css, str, sizeof(css));
|
strlcpy(css, str, sizeof(css));
|
||||||
@ -7682,10 +7705,12 @@ void show_html_header(LOGBOOK * lbs, BOOL expires, char *title, BOOL close_head,
|
|||||||
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%s%s\">\n", css_base, css);
|
rsprintf("<link rel=\"stylesheet\" type=\"text/css\" href=\"%s%s\">\n", css_base, css);
|
||||||
}
|
}
|
||||||
|
|
||||||
rsprintf("<link rel=\"shortcut icon\" href=\"favicon.ico\" />\n");
|
if (!embed_css) {
|
||||||
rsprintf("<link rel=\"icon\" href=\"favicon.png\" type=\"image/png\" />\n");
|
rsprintf("<link rel=\"shortcut icon\" href=\"favicon.ico\" />\n");
|
||||||
|
rsprintf("<link rel=\"icon\" href=\"favicon.png\" type=\"image/png\" />\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (rss_feed) {
|
if (rss_feed && !embed_css) {
|
||||||
rsprintf("<link rel=\"alternate\" type=\"application/rss+xml\" ");
|
rsprintf("<link rel=\"alternate\" type=\"application/rss+xml\" ");
|
||||||
rsprintf("title=\"ELOG %s\" ", lbs->name);
|
rsprintf("title=\"ELOG %s\" ", lbs->name);
|
||||||
rsprintf("href=\"elog.rdf\" />\n");
|
rsprintf("href=\"elog.rdf\" />\n");
|
||||||
@ -24639,7 +24664,7 @@ void show_elog_entry(LOGBOOK * lbs, char *dec_path, char *command)
|
|||||||
strcpy(str, "ELOG");
|
strcpy(str, "ELOG");
|
||||||
|
|
||||||
if (email) {
|
if (email) {
|
||||||
/* show absolute link for CSS */
|
/* embed CSS */
|
||||||
show_html_header(lbs, FALSE, str, TRUE, FALSE, NULL, TRUE, 0);
|
show_html_header(lbs, FALSE, str, TRUE, FALSE, NULL, TRUE, 0);
|
||||||
rsprintf("<body>\n");
|
rsprintf("<body>\n");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user