add dark theme, wip
All checks were successful
pyrite-dev/taiga/pipeline/head This commit looks good
All checks were successful
pyrite-dev/taiga/pipeline/head This commit looks good
This commit is contained in:
parent
3cac2281a3
commit
6ec477a9b5
10 changed files with 203 additions and 17 deletions
3
objs.mk
3
objs.mk
|
|
@ -80,6 +80,9 @@ src/src_process.o: src/process.c
|
|||
OBJS += src/src_skin_classic.o
|
||||
src/src_skin_classic.o: src/skin/classic.c
|
||||
$(CC) $(CFLAGS) -c -o $@ src/skin/classic.c
|
||||
OBJS += src/src_skin_dark.o
|
||||
src/src_skin_dark.o: src/skin/dark.c
|
||||
$(CC) $(CFLAGS) -c -o $@ src/skin/dark.c
|
||||
OBJS += src/src_skin_simple.o
|
||||
src/src_skin_simple.o: src/skin/simple.c
|
||||
$(CC) $(CFLAGS) -c -o $@ src/skin/simple.c
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ static char* title = NULL;
|
|||
static int in_title = 0;
|
||||
static int in_section = 0;
|
||||
static int in_message = 0;
|
||||
static int in_pre = 0;
|
||||
static int in_pre = 0;
|
||||
static char** mapping;
|
||||
static int mapping_len;
|
||||
static char* argin = NULL;
|
||||
|
|
@ -501,7 +501,7 @@ int action_markdown(int argc, char** argv) {
|
|||
in_title = 0;
|
||||
in_section = 0;
|
||||
in_message = 0;
|
||||
in_pre = 0;
|
||||
in_pre = 0;
|
||||
mode = 0;
|
||||
if(md_parse(buffer, size, &parser, NULL)) {
|
||||
free(buffer);
|
||||
|
|
@ -523,7 +523,7 @@ int action_markdown(int argc, char** argv) {
|
|||
in_title = 0;
|
||||
in_section = 0;
|
||||
in_message = 0;
|
||||
in_pre = 0;
|
||||
in_pre = 0;
|
||||
mode = 1;
|
||||
if(md_parse(buffer, size, &parser, NULL)) {
|
||||
free(buffer);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ int action_seed(int argc, char** argv) {
|
|||
fprintf(f, " </nav>\n");
|
||||
fprintf(f, " <favicon></favicon>\n");
|
||||
fprintf(f, " <extra-css></extra-css>\n");
|
||||
fprintf(f, " <skin>classic</skin> <!-- classic or simple -->\n");
|
||||
fprintf(f, " <skin>classic</skin> <!-- classic or simple or dark -->\n");
|
||||
fprintf(f, " <copyright>\n");
|
||||
fprintf(f, " <holder>Example Co, Ltd</holder>\n");
|
||||
fprintf(f, " <year>%d</year> <!-- Year when you started this project/whatever copyright holder -->\n", 1900 + tm->tm_year);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
xemil_t* skinconf;
|
||||
void (*site_stylesheet)(FILE* out, const char* top); /* also create files here if you need one */
|
||||
void (*site_htmlattr)(FILE* out, const char* top);
|
||||
void (*site_head)(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
void (*site_bodyattr)(FILE* out, const char* top);
|
||||
void (*site_body)(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
static int scan(const char* top, int mode, const char* path) {
|
||||
|
|
@ -80,7 +82,9 @@ static int scan(const char* top, int mode, const char* path) {
|
|||
|
||||
#define USE_THEME(x) \
|
||||
site_stylesheet = x##_stylesheet; \
|
||||
site_htmlattr = x##_htmlattr; \
|
||||
site_head = x##_head; \
|
||||
site_bodyattr = x##_bodyattr; \
|
||||
site_body = x##_body;
|
||||
|
||||
int action_site(int argc, char** argv) {
|
||||
|
|
@ -103,6 +107,8 @@ int action_site(int argc, char** argv) {
|
|||
USE_THEME(classic);
|
||||
} else if(strcmp(nodes[0]->text, "simple") == 0) {
|
||||
USE_THEME(simple);
|
||||
} else if(strcmp(nodes[0]->text, "dark") == 0) {
|
||||
USE_THEME(dark);
|
||||
} else {
|
||||
fprintf(stderr, "Unknown skin: %s\n", nodes[0]->text);
|
||||
st = 1;
|
||||
|
|
|
|||
|
|
@ -102,7 +102,11 @@ void default_body(FILE* out, const char* top, xl_node_t* element, const char* in
|
|||
char* title = xl_get_attribute(element, "title");
|
||||
char* id = u_section_id(element);
|
||||
|
||||
if(id != NULL) sprintf(tag, "<div class=\"section\" id=\"%s\">%s</div>", id, title);
|
||||
if(id != NULL) {
|
||||
sprintf(tag, "<div class=\"section\" id=\"%s\">%s</div>", id, title);
|
||||
|
||||
sprintf(tag + strlen(tag), "<table border=\"0\" width=\"100%%\" cellspacing=\"0\" cellpadding=\"0\"><tr><td class=\"sectionsep\"></td></tr></table>");
|
||||
}
|
||||
} else if(strcmp(element->name, "fixme") == 0 || /**/
|
||||
strcmp(element->name, "warning") == 0 || /**/
|
||||
strcmp(element->name, "note") == 0) {
|
||||
|
|
|
|||
|
|
@ -48,8 +48,12 @@ static int parse_file(const char* top, const char* full) {
|
|||
|
||||
if(title == NULL) title = u_strdup("Untitled");
|
||||
|
||||
fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
|
||||
fprintf(f, "<html>\n");
|
||||
if(site_htmlattr != dark_htmlattr) {
|
||||
fprintf(f, "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
|
||||
}
|
||||
fprintf(f, "<html");
|
||||
site_htmlattr(f, top);
|
||||
fprintf(f, ">\n");
|
||||
fprintf(f, " <head>\n");
|
||||
fprintf(f, " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n");
|
||||
fprintf(f, " <meta name=\"generator\" content=\"Taiga\">\n");
|
||||
|
|
@ -84,7 +88,9 @@ static int parse_file(const char* top, const char* full) {
|
|||
}
|
||||
|
||||
fprintf(f, " </head>\n");
|
||||
fprintf(f, " <body>\n");
|
||||
fprintf(f, " <body");
|
||||
site_bodyattr(f, top);
|
||||
fprintf(f, ">\n");
|
||||
site_body(f, top, title, body, full);
|
||||
fprintf(f, " <!--[if lte IE 6]>\n");
|
||||
fprintf(f, " <script language=\"javascript\" type=\"text/javascript\">\n");
|
||||
|
|
@ -117,7 +123,6 @@ static int parse_file(const char* top, const char* full) {
|
|||
fprintf(f, " fixTags(\"p\");\n");
|
||||
fprintf(f, " document.documentElement.style.width = document.documentElement.clientWidth + \"px\";\n");
|
||||
fprintf(f, " </script>\n");
|
||||
fprintf(f, " </script>\n");
|
||||
fprintf(f, " <style>\n");
|
||||
fprintf(f, "pre {\n");
|
||||
fprintf(f, " width: 50px;\n");
|
||||
|
|
|
|||
|
|
@ -139,6 +139,9 @@ void classic_stylesheet(FILE* out, const char* top) {
|
|||
}
|
||||
}
|
||||
|
||||
void classic_htmlattr(FILE* out, const char* top) {
|
||||
}
|
||||
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header, const char* input) {
|
||||
xl_node_t* child;
|
||||
|
||||
|
|
@ -150,6 +153,9 @@ void classic_head(FILE* out, const char* top, xl_node_t* header, const char* inp
|
|||
}
|
||||
}
|
||||
|
||||
void classic_bodyattr(FILE* out, const char* top) {
|
||||
}
|
||||
|
||||
void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input) {
|
||||
char year[4 + 1 + 4 + 1]; /* no one would use our software in year 10000... right? :) */
|
||||
char* holder = "Unknown people";
|
||||
|
|
|
|||
139
src/skin/dark.c
Normal file
139
src/skin/dark.c
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
#include <taiga.h>
|
||||
|
||||
void dark_stylesheet(FILE* out, const char* top) {
|
||||
fprintf(out, "body, td, th, div, p, .smalltext {\n");
|
||||
fprintf(out, " color: #666666;\n");
|
||||
fprintf(out, " font-family: \"Verdana\";\n");
|
||||
fprintf(out, " font-size: 9pt;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".smalltext {\n");
|
||||
fprintf(out, " font-size: 8pt;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".section {\n");
|
||||
fprintf(out, " color: #999999;\n");
|
||||
fprintf(out, " font-family: \"Verdana\";\n");
|
||||
fprintf(out, " font-size: 11pt;\n");
|
||||
fprintf(out, " padding-top: 8px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".sectionsep {\n");
|
||||
fprintf(out, " background: #666666;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "a {\n");
|
||||
fprintf(out, " text-decoration: none;\n");
|
||||
fprintf(out, " color: #cccccc;\n");
|
||||
fprintf(out, " font-family: \"Verdana\";\n");
|
||||
fprintf(out, " font-weight: bold;\n");
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
||||
void dark_htmlattr(FILE* out, const char* top) {
|
||||
fprintf(out, " style=\"height: 100%%;\"");
|
||||
}
|
||||
|
||||
void dark_head(FILE* out, const char* top, xl_node_t* header, const char* input) {
|
||||
xl_node_t* child;
|
||||
|
||||
child = header->first_child;
|
||||
while(child != NULL) {
|
||||
default_head(out, top, child, input, 2);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
void dark_bodyattr(FILE* out, const char* top) {
|
||||
fprintf(out, " marginwidth=\"0\"");
|
||||
fprintf(out, " marginheight=\"0\"");
|
||||
fprintf(out, " bgcolor=\"black\"");
|
||||
fprintf(out, " style=\"height: 100%%;\"");
|
||||
}
|
||||
|
||||
void dark_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input) {
|
||||
char* holder = "Unknown people";
|
||||
char* project_desc = "Unknown project description";
|
||||
char* link;
|
||||
char* image;
|
||||
char size[256];
|
||||
int ws, hs;
|
||||
xl_node_t* child;
|
||||
xl_node_t** nodes;
|
||||
|
||||
size[0] = 0;
|
||||
|
||||
if((nodes = xl_get_path(skinconf->root, "copyright.holder")) != NULL) {
|
||||
holder = nodes[0]->text;
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
link = NULL;
|
||||
if((nodes = xl_get_path(skinconf->root, "project.link")) != NULL) {
|
||||
link = xl_get_attribute(nodes[0], "href");
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
if(link == NULL) link = "https://invalid.link";
|
||||
link = u_path(top, link);
|
||||
|
||||
image = NULL;
|
||||
if((nodes = xl_get_path(skinconf->root, "project.image")) != NULL) {
|
||||
image = xl_get_attribute(nodes[0], "src");
|
||||
if(image != NULL) image = u_path(top, image);
|
||||
|
||||
if(u_image_size(top, image, u_http_path, &ws, &hs)) {
|
||||
sprintf(size, " width=\"%d\" height=\"%d\"", ws, hs);
|
||||
}
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
if((nodes = xl_get_path(skinconf->root, "project.description")) != NULL) {
|
||||
project_desc = nodes[0]->text;
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
fprintf(out, " <table width=\"100%%\" height=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td valign=\"middle\" align=\"center\">\n");
|
||||
fprintf(out, " <table width=\"600\" height=\"400\" border=\"0\" cellspacing=\"10\" cellpadding=\"0\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td>\n");
|
||||
fprintf(out, " <table width=\"1\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td align=\"center\" valign=\"middle\">\n");
|
||||
if(image != NULL) {
|
||||
fprintf(out, " <a href=\"%s\"><img src=\"%s\" alt=\"Project logo\" border=\"0\"%s></a>\n", link, image, size);
|
||||
}
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td align=\"right\">\n");
|
||||
fprintf(out, " %s<br>\n", project_desc);
|
||||
fprintf(out, " <br>\n");
|
||||
fprintf(out, " <div class=\"smalltext\">© %s</div>\n", holder);
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " <td width=\"1\" bgcolor=\"#666666\"></td>\n");
|
||||
fprintf(out, " <td width=\"450\" valign=\"top\" id=\"content\">\n");
|
||||
if(body != NULL) {
|
||||
child = body->first_child;
|
||||
while(child != NULL) {
|
||||
default_body(out, top, child, input, 0, 0, 5);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
}
|
||||
|
|
@ -192,6 +192,9 @@ void simple_stylesheet(FILE* out, const char* top) {
|
|||
}
|
||||
}
|
||||
|
||||
void simple_htmlattr(FILE* out, const char* top) {
|
||||
}
|
||||
|
||||
void simple_head(FILE* out, const char* top, xl_node_t* header, const char* input) {
|
||||
xl_node_t* child;
|
||||
|
||||
|
|
@ -203,6 +206,9 @@ void simple_head(FILE* out, const char* top, xl_node_t* header, const char* inpu
|
|||
}
|
||||
}
|
||||
|
||||
void simple_bodyattr(FILE* out, const char* top) {
|
||||
}
|
||||
|
||||
void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input) {
|
||||
char year[4 + 1 + 4 + 1]; /* no one would use our software in year 10000... right? :) */
|
||||
char* holder = "Unknown people";
|
||||
|
|
@ -210,7 +216,7 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body,
|
|||
char* project_desc = "Unknown project description";
|
||||
xl_node_t** nodes;
|
||||
xl_node_t* child;
|
||||
char* text;
|
||||
char* image;
|
||||
char* link;
|
||||
char size[256];
|
||||
|
||||
|
|
@ -271,25 +277,29 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body,
|
|||
link = NULL;
|
||||
if((nodes = xl_get_path(skinconf->root, "project.link")) != NULL) {
|
||||
link = xl_get_attribute(nodes[0], "href");
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
if(link == NULL) link = "https://invalid.link";
|
||||
link = u_path(top, link);
|
||||
|
||||
text = NULL;
|
||||
image = NULL;
|
||||
if((nodes = xl_get_path(skinconf->root, "project.image")) != NULL) {
|
||||
text = xl_get_attribute(nodes[0], "src");
|
||||
if(text != NULL) text = u_path(top, text);
|
||||
image = xl_get_attribute(nodes[0], "src");
|
||||
if(image != NULL) image = u_path(top, image);
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
if(text != NULL) {
|
||||
if(image != NULL) {
|
||||
int ws, hs;
|
||||
|
||||
if(u_image_size(top, text, u_http_path, &ws, &hs)) {
|
||||
if(u_image_size(top, image, u_http_path, &ws, &hs)) {
|
||||
sprintf(size, " width=\"%d\" height=\"%d\"", ws, hs);
|
||||
}
|
||||
|
||||
fprintf(out, " <a href=\"%s\"><img src=\"%s\" alt=\"Project logo\" border=\"0\"%s></a>\n", link, text, size);
|
||||
free(text);
|
||||
fprintf(out, " <a href=\"%s\"><img src=\"%s\" alt=\"Project logo\" border=\"0\"%s></a>\n", link, image, size);
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
free(link);
|
||||
|
|
|
|||
13
src/taiga.h
13
src/taiga.h
|
|
@ -52,7 +52,9 @@ void io_closedir(IO_DIR* dir);
|
|||
/* action/site.c */
|
||||
extern xemil_t* skinconf;
|
||||
extern void (*site_stylesheet)(FILE* out, const char* top); /* also create files here if you need one */
|
||||
extern void (*site_htmlattr)(FILE* out, const char* top);
|
||||
extern void (*site_head)(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
extern void (*site_bodyattr)(FILE* out, const char* top);
|
||||
extern void (*site_body)(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
int action_site(int argc, char** argv);
|
||||
|
|
@ -98,12 +100,23 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, const char* inp
|
|||
|
||||
/* skin/classic.c */
|
||||
void classic_stylesheet(FILE* out, const char* top);
|
||||
void classic_htmlattr(FILE* out, const char* top);
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
void classic_bodyattr(FILE* out, const char* top);
|
||||
void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
/* skin/simple.c */
|
||||
void simple_stylesheet(FILE* out, const char* top);
|
||||
void simple_htmlattr(FILE* out, const char* top);
|
||||
void simple_head(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
void simple_bodyattr(FILE* out, const char* top);
|
||||
void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
/* skin/dark.c */
|
||||
void dark_stylesheet(FILE* out, const char* top);
|
||||
void dark_htmlattr(FILE* out, const char* top);
|
||||
void dark_head(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
void dark_bodyattr(FILE* out, const char* top);
|
||||
void dark_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue