This commit is contained in:
parent
de036d46aa
commit
36d7eb30cb
10 changed files with 246 additions and 115 deletions
130
src/classic.c
130
src/classic.c
|
|
@ -17,7 +17,8 @@ void classic_stylesheet(FILE* out, const char* top) {
|
|||
|
||||
free(nodes);
|
||||
}
|
||||
if(breadcrumb_bgcolor == NULL) breadcrumb_bgcolor = "#003366";
|
||||
if(breadcrumb_bgcolor == NULL)
|
||||
breadcrumb_bgcolor = "#003366";
|
||||
|
||||
fprintf(out, "body {\n");
|
||||
fprintf(out, " padding: 0;\n");
|
||||
|
|
@ -129,7 +130,8 @@ void classic_stylesheet(FILE* out, const char* top) {
|
|||
void classic_head(FILE* out, const char* top, xl_node_t* header) {
|
||||
xl_node_t* child;
|
||||
|
||||
fprintf(out, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\n", top);
|
||||
fprintf(out, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\n",
|
||||
top);
|
||||
|
||||
child = header->first_child;
|
||||
while(child != NULL) {
|
||||
|
|
@ -139,8 +141,10 @@ void classic_head(FILE* out, const char* top, xl_node_t* header) {
|
|||
}
|
||||
}
|
||||
|
||||
void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body) {
|
||||
char year[4 + 1 + 4 + 1]; /* no one would use our software in year 10000... right? :) */
|
||||
void classic_body(FILE* out, const char* top, const char* title,
|
||||
xl_node_t* body) {
|
||||
char year[4 + 1 + 4 +
|
||||
1]; /* no one would use our software in year 10000... right? :) */
|
||||
char* holder = "Unknown people";
|
||||
char* sitesearch = NULL;
|
||||
xl_node_t** nodes;
|
||||
|
|
@ -182,9 +186,11 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
|
||||
free(nodes);
|
||||
}
|
||||
if(sitesearch == NULL) sitesearch = "https://invalid.link";
|
||||
if(sitesearch == NULL)
|
||||
sitesearch = "https://invalid.link";
|
||||
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" "
|
||||
"cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <tr width=\"100%%\">\n");
|
||||
fprintf(out, " <td>\n");
|
||||
for(i = 0; i < sizeof(images) / sizeof(images[0]); i++) {
|
||||
|
|
@ -197,14 +203,16 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
name = nodes[0]->text;
|
||||
free(nodes);
|
||||
}
|
||||
if(name == NULL) name = "Logo";
|
||||
if(name == NULL)
|
||||
name = "Logo";
|
||||
|
||||
sprintf(path, "%s.link", images[i]);
|
||||
if((nodes = xl_get_path(skinconf->root, path)) != NULL) {
|
||||
link = xl_get_attribute(nodes[0], "href");
|
||||
free(nodes);
|
||||
}
|
||||
if(link == NULL) link = "https://invalid.link";
|
||||
if(link == NULL)
|
||||
link = "https://invalid.link";
|
||||
|
||||
link = u_path(top, link);
|
||||
|
||||
|
|
@ -214,7 +222,10 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
|
||||
if(text != NULL) {
|
||||
text = u_path(top, text);
|
||||
fprintf(out, " <a href=\"%s\"><img src=\"%s\" alt=\"%s\" border=\"0\"></a>\n", link, text, images[i + 1], name);
|
||||
fprintf(out,
|
||||
" <a href=\"%s\"><img "
|
||||
"src=\"%s\" alt=\"%s\" border=\"0\"></a>\n",
|
||||
link, text, images[i + 1], name);
|
||||
free(text);
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +237,8 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\" id=\"breadcrumb\">\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" "
|
||||
"cellspacing=\"0\" width=\"100%%\" id=\"breadcrumb\">\n");
|
||||
fprintf(out, " <tr width=\"100%%\">\n");
|
||||
fprintf(out, " <td>\n");
|
||||
if((nodes = xl_get_path(skinconf->root, "breadcrumb.link")) != NULL) {
|
||||
|
|
@ -236,14 +248,18 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
char* link = xl_get_attribute(nodes[i], "href");
|
||||
char* name = xl_get_attribute(nodes[i], "name");
|
||||
|
||||
if(link == NULL) link = "https://invalid.link";
|
||||
if(link == NULL)
|
||||
link = "https://invalid.link";
|
||||
|
||||
link = u_path(top, link);
|
||||
|
||||
if(title == NULL) title = link;
|
||||
if(title == NULL)
|
||||
title = link;
|
||||
|
||||
if(i > 0) fprintf(out, " |\n");
|
||||
fprintf(out, " <a href=\"%s\">%s</a>\n", link, name);
|
||||
if(i > 0)
|
||||
fprintf(out, " |\n");
|
||||
fprintf(out, " <a href=\"%s\">%s</a>\n",
|
||||
link, name);
|
||||
|
||||
free(link);
|
||||
}
|
||||
|
|
@ -251,19 +267,28 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
free(nodes);
|
||||
}
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " <td nowrap=\"1\" align=\"right\">\n");
|
||||
fprintf(out, " <form action=\"https://www.google.com/search\" method=\"GET\">\n");
|
||||
fprintf(out, " <td nowrap=\"1\" "
|
||||
"align=\"right\">\n");
|
||||
fprintf(out, " <form "
|
||||
"action=\"https://www.google.com/search\" method=\"GET\">\n");
|
||||
fprintf(out, " Search\n");
|
||||
fprintf(out, " <input type=\"hidden\" name=\"sitesearch\" value=\"%s\">\n", sitesearch);
|
||||
fprintf(out, " <input name=\"q\" size=\"10\">\n");
|
||||
fprintf(out, " <input type=\"submit\" value=\"Go\">\n");
|
||||
fprintf(out,
|
||||
" <input type=\"hidden\" "
|
||||
"name=\"sitesearch\" value=\"%s\">\n",
|
||||
sitesearch);
|
||||
fprintf(out, " <input "
|
||||
"name=\"q\" size=\"10\">\n");
|
||||
fprintf(out, " <input "
|
||||
"type=\"submit\" value=\"Go\">\n");
|
||||
fprintf(out, " </form>\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" "
|
||||
"cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td width=\"150\" valign=\"top\">\n");
|
||||
fprintf(out, " <td width=\"150\" "
|
||||
"valign=\"top\">\n");
|
||||
fprintf(out, " <div id=\"nav\">\n");
|
||||
|
||||
if((nodes = xl_get_path(skinconf->root, "nav")) != NULL) {
|
||||
|
|
@ -282,7 +307,8 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
fprintf(out, " </div>\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " <td valign=\"top\">\n");
|
||||
fprintf(out, " <div id=\"content\">\n");
|
||||
fprintf(out, " <div "
|
||||
"id=\"content\">\n");
|
||||
|
||||
child = body->first_child;
|
||||
while(child != NULL) {
|
||||
|
|
@ -295,30 +321,62 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" "
|
||||
"cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td id=\"copyright\" align=\"center\">\n");
|
||||
fprintf(out, " Copyright © %s %s%s All rights reserved.\n", year, holder, (strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : ".");
|
||||
fprintf(
|
||||
out,
|
||||
" <td id=\"copyright\" align=\"center\">\n");
|
||||
fprintf(out,
|
||||
" Copyright © %s %s%s All "
|
||||
"rights reserved.\n",
|
||||
year, holder,
|
||||
(strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : ".");
|
||||
fprintf(out, " <td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td align=\"right\">\n");
|
||||
fprintf(out, " <a href=\"https://validator.w3.org/check/referer\"><img src=\"%simage/valid-html401.png\" alt=\"Valid HTML 4.01\" border=\"0\"></a>\n", top);
|
||||
fprintf(out, " <a href=\"https://jigsaw.w3.org/css-validator/\"><img src=\"%simage/valid-css.png\" alt=\"Valid CSS\" border=\"0\"></a>\n", top);
|
||||
fprintf(out,
|
||||
" <a "
|
||||
"href=\"https://validator.w3.org/check/referer\"><img "
|
||||
"src=\"%simage/valid-html401.png\" alt=\"Valid HTML 4.01\" "
|
||||
"border=\"0\"></a>\n",
|
||||
top);
|
||||
fprintf(out,
|
||||
" <a "
|
||||
"href=\"https://jigsaw.w3.org/css-validator/\"><img "
|
||||
"src=\"%simage/valid-css.png\" alt=\"Valid CSS\" border=\"0\"></a>\n",
|
||||
top);
|
||||
fprintf(out, " <td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <!--[if lte IE 6]>\n");
|
||||
fprintf(out, " <script language=\"javascript\" type=\"text/javascript\">\n");
|
||||
fprintf(out, " for(var i = 0; i < document.images.length; i++){\n");
|
||||
fprintf(out, " var s = document.images[i].src;\n");
|
||||
fprintf(
|
||||
out,
|
||||
" <script language=\"javascript\" type=\"text/javascript\">\n");
|
||||
fprintf(
|
||||
out,
|
||||
" for(var i = 0; i < document.images.length; i++){\n");
|
||||
fprintf(out, " var s = "
|
||||
"document.images[i].src;\n");
|
||||
fprintf(out, " if(s.indexOf('.png') > 0){\n");
|
||||
fprintf(out, " var oldw = document.images[i].clientWidth;\n");
|
||||
fprintf(out, " var oldh = document.images[i].clientHeight;\n");
|
||||
fprintf(out, " document.images[i].src = '%simage/fill.gif';\n", top);
|
||||
fprintf(out, " document.images[i].style.filter = \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" + s + \"', sizingMethod='scale')\";\n");
|
||||
fprintf(out, " document.images[i].style.width = oldw + \"px\";\n");
|
||||
fprintf(out, " document.images[i].style.height = oldh + \"px\";\n");
|
||||
fprintf(out, " var oldw = "
|
||||
"document.images[i].clientWidth;\n");
|
||||
fprintf(out, " var oldh = "
|
||||
"document.images[i].clientHeight;\n");
|
||||
fprintf(out,
|
||||
" document.images[i].src = "
|
||||
"'%simage/fill.gif';\n",
|
||||
top);
|
||||
fprintf(
|
||||
out,
|
||||
" document.images[i].style.filter = "
|
||||
"\"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='\" + s + \"', "
|
||||
"sizingMethod='scale')\";\n");
|
||||
fprintf(out, " "
|
||||
"document.images[i].style.width = oldw + \"px\";\n");
|
||||
fprintf(out, " "
|
||||
"document.images[i].style.height = oldh + \"px\";\n");
|
||||
fprintf(out, " }\n");
|
||||
fprintf(out, " }\n");
|
||||
fprintf(out, " </script>\n");
|
||||
|
|
|
|||
|
|
@ -6,12 +6,16 @@ static void print(FILE* out, const char* txt, int indent) {
|
|||
for(i = 0;; i++) {
|
||||
if(i == 0 || txt[i] == '\n' || txt[i] == 0) {
|
||||
int j;
|
||||
if(i > 0) fprintf(out, "\n");
|
||||
if(txt[i] == 0) break;
|
||||
for(j = 0; j < indent; j++) fprintf(out, "\t");
|
||||
if(i > 0)
|
||||
fprintf(out, "\n");
|
||||
if(txt[i] == 0)
|
||||
break;
|
||||
for(j = 0; j < indent; j++)
|
||||
fprintf(out, "\t");
|
||||
}
|
||||
|
||||
if(txt[i] != '\n') fprintf(out, "%c", txt[i]);
|
||||
if(txt[i] != '\n')
|
||||
fprintf(out, "%c", txt[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -25,7 +29,8 @@ static void accept_attr(char* text, xl_node_t* element, ...) {
|
|||
|
||||
va_start(va, element);
|
||||
while((s = va_arg(va, const char*)) != NULL) {
|
||||
if(strcmp(attr->key, s) != 0) continue;
|
||||
if(strcmp(attr->key, s) != 0)
|
||||
continue;
|
||||
if(attr->value == NULL) {
|
||||
sprintf(text + strlen(text), " %s", attr->key);
|
||||
} else {
|
||||
|
|
@ -46,7 +51,8 @@ void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
|
||||
tag[0] = end[0] = 0;
|
||||
|
||||
if(element->name == NULL) return;
|
||||
if(element->name == NULL)
|
||||
return;
|
||||
|
||||
if(strcmp(element->name, "link") == 0) {
|
||||
char text[2048];
|
||||
|
|
@ -56,7 +62,8 @@ void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
sprintf(tag, "<%s%s>", element->name, text);
|
||||
}
|
||||
|
||||
if(tag[0] != 0) print(out, tag, indent);
|
||||
if(tag[0] != 0)
|
||||
print(out, tag, indent);
|
||||
|
||||
child = element->first_child;
|
||||
while(child != NULL) {
|
||||
|
|
@ -72,7 +79,8 @@ void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
child = child->next;
|
||||
}
|
||||
|
||||
if(end[0] != 0) print(out, end, indent);
|
||||
if(end[0] != 0)
|
||||
print(out, end, indent);
|
||||
}
|
||||
|
||||
void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
||||
|
|
@ -84,7 +92,8 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
|
||||
tag[0] = end[0] = 0;
|
||||
|
||||
if(element->name == NULL) return;
|
||||
if(element->name == NULL)
|
||||
return;
|
||||
|
||||
if(strcmp(element->name, "section") == 0) {
|
||||
char* title = xl_get_attribute(element, "title");
|
||||
|
|
@ -105,21 +114,28 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
say = "Fixme";
|
||||
|
||||
strcpy(author, " ()");
|
||||
if((attr = xl_get_attribute(element, "author")) != NULL) sprintf(author, " (%s)", attr);
|
||||
if((attr = xl_get_attribute(element, "author")) != NULL)
|
||||
sprintf(author, " (%s)", attr);
|
||||
} else if(strcmp(element->name, "warning") == 0) {
|
||||
say = "Warning";
|
||||
} else if(strcmp(element->name, "note") == 0) {
|
||||
say = "Note";
|
||||
}
|
||||
|
||||
sprintf(tag + strlen(tag), "<div class=\"%s-message\"%s>\n", element->name, text);
|
||||
sprintf(tag + strlen(tag), " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">\n");
|
||||
sprintf(tag + strlen(tag), "<div class=\"%s-message\"%s>\n", element->name,
|
||||
text);
|
||||
sprintf(tag + strlen(tag), " <table border=\"0\" cellpadding=\"0\" "
|
||||
"cellspacing=\"0\" width=\"100%%\">\n");
|
||||
sprintf(tag + strlen(tag), " <tr>\n");
|
||||
sprintf(tag + strlen(tag), " <td rowspan=\"2\" class=\"message-icon\">\n");
|
||||
sprintf(tag + strlen(tag), " <img src=\"%simage/%s.png\">\n", top, element->name);
|
||||
sprintf(tag + strlen(tag),
|
||||
" <td rowspan=\"2\" class=\"message-icon\">\n");
|
||||
sprintf(tag + strlen(tag),
|
||||
" <img src=\"%simage/%s.png\">\n", top,
|
||||
element->name);
|
||||
sprintf(tag + strlen(tag), " </td>\n");
|
||||
sprintf(tag + strlen(tag), " <td>\n");
|
||||
sprintf(tag + strlen(tag), " <b>%s%s</b>\n", say, author);
|
||||
sprintf(tag + strlen(tag), " <b>%s%s</b>\n", say,
|
||||
author);
|
||||
sprintf(tag + strlen(tag), " </td>\n");
|
||||
sprintf(tag + strlen(tag), " </tr>\n");
|
||||
sprintf(tag + strlen(tag), " <tr>\n");
|
||||
|
|
@ -168,7 +184,8 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
|
||||
sprintf(end, "</%s>", element->name);
|
||||
} else if(strcmp(element->name, "img") == 0) {
|
||||
accept_attr(text, element, "src", "alt", "title", "height", "width", "id", "class", NULL);
|
||||
accept_attr(text, element, "src", "alt", "title", "height", "width", "id",
|
||||
"class", NULL);
|
||||
|
||||
sprintf(tag, "<%s%s>", element->name, text);
|
||||
|
||||
|
|
@ -182,7 +199,10 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
} else if(strcmp(element->name, "table") == 0) {
|
||||
accept_attr(text, element, "id", "class", NULL);
|
||||
|
||||
sprintf(tag, "<%s%s class=\"grid\" width=\"100%%\" cellpadding=\"3\" cellspacing=\"2\" border=\"1\">", element->name, text);
|
||||
sprintf(tag,
|
||||
"<%s%s class=\"grid\" width=\"100%%\" cellpadding=\"3\" "
|
||||
"cellspacing=\"2\" border=\"1\">",
|
||||
element->name, text);
|
||||
|
||||
sprintf(end, "</%s>", element->name);
|
||||
} else if(strcmp(element->name, "hr") == 0 || /**/
|
||||
|
|
@ -192,7 +212,8 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
sprintf(tag, "<%s%text>", element->name, text);
|
||||
}
|
||||
|
||||
if(tag[0] != 0) print(out, tag, indent);
|
||||
if(tag[0] != 0)
|
||||
print(out, tag, indent);
|
||||
|
||||
child = element->first_child;
|
||||
while(child != NULL) {
|
||||
|
|
@ -205,24 +226,29 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
child = child->next;
|
||||
}
|
||||
|
||||
if(end[0] != 0) print(out, end, indent);
|
||||
if(end[0] != 0)
|
||||
print(out, end, indent);
|
||||
}
|
||||
|
||||
void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
||||
int i;
|
||||
|
||||
if(element->name == NULL) return;
|
||||
if(element->name == NULL)
|
||||
return;
|
||||
|
||||
if(strcmp(element->name, "link") == 0) {
|
||||
char* link;
|
||||
char* name;
|
||||
|
||||
if((link = xl_get_attribute(element, "href")) == NULL) link = "https://invalid.link";
|
||||
if((name = xl_get_attribute(element, "name")) == NULL) name = "";
|
||||
if((link = xl_get_attribute(element, "href")) == NULL)
|
||||
link = "https://invalid.link";
|
||||
if((name = xl_get_attribute(element, "name")) == NULL)
|
||||
name = "";
|
||||
|
||||
link = u_path(top, link);
|
||||
|
||||
for(i = 0; i < indent; i++) fprintf(out, "\t");
|
||||
for(i = 0; i < indent; i++)
|
||||
fprintf(out, "\t");
|
||||
fprintf(out, " - <a href=\"%s\">%s</a><br>\n", link, name);
|
||||
|
||||
free(link);
|
||||
|
|
@ -230,14 +256,17 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
char* title;
|
||||
xl_node_t* child;
|
||||
|
||||
if((title = xl_get_attribute(element, "title")) == NULL) title = "";
|
||||
if((title = xl_get_attribute(element, "title")) == NULL)
|
||||
title = "";
|
||||
|
||||
if(title != NULL) {
|
||||
for(i = 0; i < indent; i++) fprintf(out, "\t");
|
||||
for(i = 0; i < indent; i++)
|
||||
fprintf(out, "\t");
|
||||
fprintf(out, "<div class=\"linkgrouptitle\"> - %s</div>\n", title);
|
||||
}
|
||||
|
||||
for(i = 0; i < indent; i++) fprintf(out, "\t");
|
||||
for(i = 0; i < indent; i++)
|
||||
fprintf(out, "\t");
|
||||
fprintf(out, "<div class=\"linkgroup\">\n");
|
||||
|
||||
child = element->first_child;
|
||||
|
|
@ -247,7 +276,8 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
child = child->next;
|
||||
}
|
||||
|
||||
for(i = 0; i < indent; i++) fprintf(out, "\t");
|
||||
for(i = 0; i < indent; i++)
|
||||
fprintf(out, "\t");
|
||||
fprintf(out, "</div>\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
#include <taiga.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
/* reason why this is included here, is because it makes compilation REALLY slow */
|
||||
/* reason why this is included here, is because it makes compilation REALLY slow
|
||||
*/
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct io_dir {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
unsigned char image_fill[] = {
|
||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0xf0, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00,
|
||||
0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b};
|
||||
0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00, 0xf0,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x21, 0xf9, 0x04,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x00, 0x01,
|
||||
0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44, 0x01, 0x00, 0x3b};
|
||||
unsigned int image_fill_len = 43;
|
||||
|
|
|
|||
12
src/main.c
12
src/main.c
|
|
@ -7,13 +7,16 @@ int main(int argc, char** argv) {
|
|||
char** target_argv = malloc(sizeof(*target_argv));
|
||||
target_argv[0] = NULL;
|
||||
|
||||
printf("Taiga, static website generator - run `%s help' for help\n\n", argv[0]);
|
||||
printf("Taiga, static website generator - run `%s help' for help\n\n",
|
||||
argv[0]);
|
||||
|
||||
for(i = 1; i < argc; i++) {
|
||||
if(argv[i][0] == '-') {
|
||||
if(action != NULL) continue;
|
||||
if(action != NULL)
|
||||
continue;
|
||||
} else {
|
||||
if(action != NULL) continue;
|
||||
if(action != NULL)
|
||||
continue;
|
||||
action = argv[i];
|
||||
|
||||
free(target_argv);
|
||||
|
|
@ -22,7 +25,8 @@ int main(int argc, char** argv) {
|
|||
}
|
||||
}
|
||||
|
||||
if(action == NULL) action = "site";
|
||||
if(action == NULL)
|
||||
action = "site";
|
||||
|
||||
if(strcmp(action, "site") == 0) {
|
||||
return action_site(target_argc, target_argv);
|
||||
|
|
|
|||
|
|
@ -23,33 +23,40 @@ static int parse_file(const char* top, const char* full) {
|
|||
xl_node_t** nodes2;
|
||||
int has_own_icon = 0;
|
||||
|
||||
if(handle->root != NULL) node = handle->root->first_child;
|
||||
if(handle->root != NULL)
|
||||
node = handle->root->first_child;
|
||||
while(node != NULL) {
|
||||
if(node->type == XL_NODE_NODE && strcmp(node->name, "header") == 0) {
|
||||
xl_node_t* n = node->first_child;
|
||||
|
||||
while(n != NULL) {
|
||||
if(n->type == XL_NODE_NODE && strcmp(n->name, "title") == 0) {
|
||||
if(title != NULL) free(title);
|
||||
if(title != NULL)
|
||||
free(title);
|
||||
title = u_strdup(n->text);
|
||||
}
|
||||
n = n->next;
|
||||
}
|
||||
|
||||
header = node;
|
||||
} else if(node->type == XL_NODE_NODE && strcmp(node->name, "body") == 0) {
|
||||
} else if(node->type == XL_NODE_NODE &&
|
||||
strcmp(node->name, "body") == 0) {
|
||||
body = node;
|
||||
}
|
||||
|
||||
node = node->next;
|
||||
}
|
||||
|
||||
if(title == NULL) title = u_strdup("Untitled");
|
||||
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,
|
||||
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 "
|
||||
"Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">\n");
|
||||
fprintf(f, "<html>\n");
|
||||
fprintf(f, " <head>\n");
|
||||
fprintf(f, " <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\">\n");
|
||||
fprintf(f, " <meta http-equiv=\"Content-Type\" "
|
||||
"content=\"text/html;charset=UTF-8\">\n");
|
||||
fprintf(f, " <title>%s</title>\n", title);
|
||||
|
||||
if((nodes = xl_get_path(header, "link")) != NULL) {
|
||||
|
|
@ -69,7 +76,8 @@ static int parse_file(const char* top, const char* full) {
|
|||
|
||||
classic_head(f, top, header);
|
||||
|
||||
if(!has_own_icon && (nodes = xl_get_path(skinconf->root, "favicon")) != NULL) {
|
||||
if(!has_own_icon &&
|
||||
(nodes = xl_get_path(skinconf->root, "favicon")) != NULL) {
|
||||
if(nodes[0]->text != NULL) {
|
||||
char* p = u_path(top, nodes[0]->text);
|
||||
fprintf(f, " <link rel=\"icon\" href=\"%s\">\n", p);
|
||||
|
|
@ -92,7 +100,8 @@ static int parse_file(const char* top, const char* full) {
|
|||
st = 0;
|
||||
}
|
||||
|
||||
if(handle != NULL) xl_close(handle);
|
||||
if(handle != NULL)
|
||||
xl_close(handle);
|
||||
|
||||
return st;
|
||||
}
|
||||
|
|
@ -100,14 +109,16 @@ static int parse_file(const char* top, const char* full) {
|
|||
int process(const char* top, const char* out, const char* full) {
|
||||
char* fn = strrchr(full, '/');
|
||||
|
||||
if(fn != NULL) fn = fn + 1;
|
||||
if(fn != NULL)
|
||||
fn = fn + 1;
|
||||
|
||||
if(fn != NULL) {
|
||||
char* n;
|
||||
char* p;
|
||||
|
||||
fn = u_strdup(fn);
|
||||
if((n = strrchr(fn, '.')) != NULL) n[0] = 0;
|
||||
if((n = strrchr(fn, '.')) != NULL)
|
||||
n[0] = 0;
|
||||
|
||||
p = u_strvacat(out, fn, ".html", NULL);
|
||||
if((f = fopen(p, "w")) != NULL) {
|
||||
|
|
|
|||
53
src/seed.c
53
src/seed.c
|
|
@ -1,20 +1,21 @@
|
|||
#include <taiga.h>
|
||||
|
||||
#include "image/fill.h"
|
||||
#include "image/valid-html401.h"
|
||||
#include "image/valid-css.h"
|
||||
#include "image/fixme.h"
|
||||
#include "image/warning.h"
|
||||
#include "image/note.h"
|
||||
#include "image/logo1.h"
|
||||
#include "image/logo2.h"
|
||||
#include "image/note.h"
|
||||
#include "image/valid-css.h"
|
||||
#include "image/valid-html401.h"
|
||||
#include "image/warning.h"
|
||||
|
||||
static void describe(const char* path, const char* what) {
|
||||
char space[64];
|
||||
int i;
|
||||
|
||||
memset(space, 0, sizeof(space));
|
||||
for(i = 0; i < (48 - strlen(path)); i++) space[i] = ' ';
|
||||
for(i = 0; i < (48 - strlen(path)); i++)
|
||||
space[i] = ' ';
|
||||
|
||||
printf("%s%s# %s\n", path, space, what);
|
||||
}
|
||||
|
|
@ -28,7 +29,9 @@ static void describe(const char* path, const char* what) {
|
|||
fclose(f);
|
||||
|
||||
int action_seed(int argc, char** argv) {
|
||||
FILE* f;
|
||||
FILE* f;
|
||||
time_t t = time(NULL);
|
||||
struct tm* tm = localtime(&t);
|
||||
|
||||
io_mkdir("site", 0755);
|
||||
io_mkdir("site/content", 0755);
|
||||
|
|
@ -50,41 +53,52 @@ int action_seed(int argc, char** argv) {
|
|||
fprintf(f, "<?xml version=\"1.0\"?>\n");
|
||||
fprintf(f, "<!--\n");
|
||||
fprintf(f, " NOTE!\n");
|
||||
fprintf(f, " - Relative path in this config is relative to site/content\n");
|
||||
fprintf(f, " - If relative path starts from ./ or ../, it's relative to URL when accessed\n");
|
||||
fprintf(
|
||||
f,
|
||||
" - Relative path in this config is relative to site/content\n");
|
||||
fprintf(f, " - If relative path starts from ./ or ../, it's relative to "
|
||||
"URL when accessed\n");
|
||||
fprintf(f, "-->\n");
|
||||
fprintf(f, "<skinconfig>\n");
|
||||
fprintf(f, " <search domain=\"example.com\" />\n");
|
||||
fprintf(f, " <breadcrumb>\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd\" href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <link name=\"Example Project\" href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd\" "
|
||||
"href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <link name=\"Example Project\" "
|
||||
"href=\"https://example.com\" />\n");
|
||||
fprintf(f, " </breadcrumb>\n");
|
||||
fprintf(f, " <group>\n");
|
||||
fprintf(f, " <name>Example Co, Ltd</name>\n");
|
||||
fprintf(f, " <description>Example Co, Ltd Description</description>\n");
|
||||
fprintf(
|
||||
f,
|
||||
" <description>Example Co, Ltd Description</description>\n");
|
||||
fprintf(f, " <link href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <image src=\"image/group-logo.png\" />\n");
|
||||
fprintf(f, " </group>\n");
|
||||
fprintf(f, " <project>\n");
|
||||
fprintf(f, " <name>Example Project</name>\n");
|
||||
fprintf(f, " <description>Example Project Description</description>\n");
|
||||
fprintf(
|
||||
f,
|
||||
" <description>Example Project Description</description>\n");
|
||||
fprintf(f, " <link href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <image src=\"image/project-logo.png\" />\n");
|
||||
fprintf(f, " </project>\n");
|
||||
fprintf(f, " <nav>\n");
|
||||
fprintf(f, " <group title=\"Example Project\">\n");
|
||||
fprintf(f, " <link name=\"Home\" href=\"/\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd.\" href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd.\" "
|
||||
"href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <group title=\"Example Project\">\n");
|
||||
fprintf(f, " <link name=\"Home\" href=\"/\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd.\" href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd.\" "
|
||||
"href=\"https://example.com\" />\n");
|
||||
fprintf(f, " </group>\n");
|
||||
fprintf(f, " </group>\n");
|
||||
fprintf(f, " </nav>\n");
|
||||
fprintf(f, " <favicon></favicon>\n");
|
||||
fprintf(f, " <copyright>\n");
|
||||
fprintf(f, " <holder>Example Co, Ltd</holder>\n");
|
||||
fprintf(f, " <year>2026</year>\n");
|
||||
fprintf(f, " <year>%d</year>\n", 1900 + tm->tm_year);
|
||||
fprintf(f, " <link href=\"https://example.com\" />\n");
|
||||
fprintf(f, " </copyright>\n");
|
||||
fprintf(f, "</skinconfig>\n");
|
||||
|
|
@ -115,9 +129,12 @@ int action_seed(int argc, char** argv) {
|
|||
fprintf(f, " </table>\n");
|
||||
fprintf(f, " <section title=\"Congratulations\">\n");
|
||||
fprintf(f, " <p>\n");
|
||||
fprintf(f, " You have successfully generated and rendered a website using Taiga - static website generator.\n");
|
||||
fprintf(f, " This page is from the site template. It is found in <code>site/content/index.xml</code>.\n");
|
||||
fprintf(f, " Please edit it and replace this text with content of your own.\n");
|
||||
fprintf(f, " You have successfully generated and "
|
||||
"rendered a website using Taiga - static website generator.\n");
|
||||
fprintf(f, " This page is from the site template. "
|
||||
"It is found in <code>site/content/index.xml</code>.\n");
|
||||
fprintf(f, " Please edit it and replace this text "
|
||||
"with content of your own.\n");
|
||||
fprintf(f, " </p>\n");
|
||||
fprintf(f, " </section>\n");
|
||||
fprintf(f, " </body>\n");
|
||||
|
|
|
|||
|
|
@ -15,7 +15,8 @@ static int scan(const char* top, const char* path) {
|
|||
char* p;
|
||||
struct io_stat s;
|
||||
|
||||
if(strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) continue;
|
||||
if(strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
p = u_strvacat(in, d->d_name, NULL);
|
||||
if(io_stat(p, &s) == 0) {
|
||||
|
|
@ -81,7 +82,8 @@ int action_site(int argc, char** argv) {
|
|||
|
||||
io_mkdir("build", 0755);
|
||||
|
||||
if((skinconf = xl_open_file("site/skinconf.xml")) == NULL || !xl_parse(skinconf)) {
|
||||
if((skinconf = xl_open_file("site/skinconf.xml")) == NULL ||
|
||||
!xl_parse(skinconf)) {
|
||||
fprintf(stderr, "Failed to parse site/skinconf.xml!\n");
|
||||
st = 1;
|
||||
goto cleanup;
|
||||
|
|
@ -100,7 +102,8 @@ int action_site(int argc, char** argv) {
|
|||
}
|
||||
|
||||
cleanup:;
|
||||
if(skinconf != NULL) xl_close(skinconf);
|
||||
if(skinconf != NULL)
|
||||
xl_close(skinconf);
|
||||
|
||||
if(st == 0) {
|
||||
fprintf(stderr, "\nBuild successful\n");
|
||||
|
|
|
|||
18
src/taiga.h
18
src/taiga.h
|
|
@ -1,19 +1,19 @@
|
|||
#ifndef __TAIGA_H__
|
||||
#define __TAIGA_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <time.h>
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <time.h>
|
||||
#ifdef _WIN32
|
||||
#include <direct.h>
|
||||
#include <io.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <xemil.h>
|
||||
|
|
@ -67,9 +67,11 @@ char* u_path(const char* top, const char* path);
|
|||
int process(const char* top, const char* out, const char* full);
|
||||
|
||||
/* classic.c */
|
||||
void classic_stylesheet(FILE* out, const char* top); /* also create files here if you need one */
|
||||
void classic_stylesheet(
|
||||
FILE* out, const char* top); /* also create files here if you need one */
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header);
|
||||
void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body);
|
||||
void classic_body(FILE* out, const char* top, const char* title,
|
||||
xl_node_t* body);
|
||||
|
||||
/* default.c */
|
||||
void default_head(FILE* out, const char* top, xl_node_t* element, int indent);
|
||||
|
|
|
|||
15
src/util.c
15
src/util.c
|
|
@ -8,14 +8,16 @@ char* u_strvacat(const char* str, ...) {
|
|||
|
||||
len += strlen(str);
|
||||
va_start(va, str);
|
||||
while((s = va_arg(va, const char*)) != NULL) len += strlen(s);
|
||||
while((s = va_arg(va, const char*)) != NULL)
|
||||
len += strlen(s);
|
||||
va_end(va);
|
||||
|
||||
r = malloc(len + 1);
|
||||
|
||||
strcpy(r, str);
|
||||
va_start(va, str);
|
||||
while((s = va_arg(va, const char*)) != NULL) strcat(r, s);
|
||||
while((s = va_arg(va, const char*)) != NULL)
|
||||
strcat(r, s);
|
||||
va_end(va);
|
||||
|
||||
return r;
|
||||
|
|
@ -30,9 +32,12 @@ char* u_strdup(const char* str) {
|
|||
}
|
||||
|
||||
char* u_path(const char* top, const char* path) {
|
||||
if(strlen(path) > 3 && strstr(path, "://") != NULL) return u_strdup(path); /* link - return as is */
|
||||
if(strlen(path) > 2 && memcmp(path, "./", 2) == 0) return u_strdup(path); /* current directory - probably intended */
|
||||
if(strlen(path) > 3 && memcmp(path, "../", 2) == 0) return u_strdup(path); /* parent directory - also probably intended */
|
||||
if(strlen(path) > 3 && strstr(path, "://") != NULL)
|
||||
return u_strdup(path); /* link - return as is */
|
||||
if(strlen(path) > 2 && memcmp(path, "./", 2) == 0)
|
||||
return u_strdup(path); /* current directory - probably intended */
|
||||
if(strlen(path) > 3 && memcmp(path, "../", 2) == 0)
|
||||
return u_strdup(path); /* parent directory - also probably intended */
|
||||
|
||||
return u_strvacat(top, path, NULL); /* otherwise, concat */
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue