From 7e8ff76e8290d8ddf89927ca15e278cea105f462 Mon Sep 17 00:00:00 2001 From: NishiOwO Date: Mon, 2 Mar 2026 17:59:05 +0900 Subject: [PATCH] things --- .gitignore | 1 + external/xemil | 2 +- src/classic.c | 78 +++++++++++++++++++- src/classic.c~ | 151 -------------------------------------- src/image/gen.sh | 7 +- src/image/valid-css.h | 4 +- src/image/valid-html401.h | 4 +- src/seed.c | 8 +- 8 files changed, 90 insertions(+), 165 deletions(-) delete mode 100644 src/classic.c~ diff --git a/.gitignore b/.gitignore index 18f9c76..de2f8c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.o *.exe +*.core /taiga /build /site diff --git a/external/xemil b/external/xemil index e8f00f4..e645137 160000 --- a/external/xemil +++ b/external/xemil @@ -1 +1 @@ -Subproject commit e8f00f411100f7e2cc66d935204cd7e1d058ad71 +Subproject commit e645137476ab89b20bf5744cfbce4448b101bac4 diff --git a/src/classic.c b/src/classic.c index d89f033..511ef39 100644 --- a/src/classic.c +++ b/src/classic.c @@ -1,6 +1,8 @@ #include #include "image/fill.h" +#include "image/valid-html401.h" +#include "image/valid-css.h" void classic_stylesheet(FILE* out, const char* top) { FILE* f; @@ -13,6 +15,16 @@ void classic_stylesheet(FILE* out, const char* top) { fwrite(image_fill, 1, image_fill_len, f); fclose(f); + sprintf(path, "%svalid-html401.png", top); + f = fopen(path, "wb"); + fwrite(image_valid_html401, 1, image_valid_html401_len, f); + fclose(f); + + sprintf(path, "%svalid-css.png", top); + f = fopen(path, "wb"); + fwrite(image_valid_css, 1, image_valid_css_len, f); + fclose(f); + if((nodes = xl_get_path(skinconf->root, "breadcrumb")) != NULL) { breadcrumb_bgcolor = xl_get_attribute(nodes[0], "color"); @@ -105,11 +117,51 @@ void classic_head(FILE* out, const char* top, xl_node_t* header) { fprintf(out, " \n", top); } +static void recursive(FILE* out, xl_node_t* element) { + int i; + xl_node_t* child; + char* tag = NULL; + char* end = NULL; + + if(element->name == NULL) return; + + if(strcmp(element->name, "section") == 0) { + char* title = xl_get_attribute(element, "title"); + + if(title != NULL) fprintf(out, "
%s
\n", title); + } else if(strcmp(element->name, "p") == 0) { + tag = "

"; + end = "

"; + } else if(strcmp(element->name, "code") == 0) { + tag = ""; + end = ""; + } + + if(tag != NULL) fprintf(out, " %s\n", tag); + + child = element->first_child; + while(child != NULL) { + if(child->type == XL_NODE_NODE && child->name != NULL) { + recursive(out, child); + } else if(child->type == XL_NODE_TEXT && child->text != NULL) { + if(strcmp(element->name, "title") == 0) { + } else { + fprintf(out, "%s ", child->text); + } + } + + child = child->next; + } + + if(end != NULL) fprintf(out, " %s\n", end); +} + 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; + xl_node_t* child; strcpy(year, "Some year"); @@ -182,13 +234,31 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body fprintf(out, " \n"); fprintf(out, " \n"); fprintf(out, "
\n"); + + child = body->first_child; + while(child != NULL) { + recursive(out, child); + + child = child->next; + } + fprintf(out, "
\n"); fprintf(out, " \n"); fprintf(out, " \n"); fprintf(out, " \n"); - fprintf(out, "
\n"); - fprintf(out, " Copyright © %s %s%s All rights reserved.\n", year, holder, (strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : "."); - fprintf(out, "
\n"); + fprintf(out, " \n"); + fprintf(out, " \n"); + fprintf(out, " \n"); + fprintf(out, " \n"); + fprintf(out, " \n"); + fprintf(out, "
\n"); + fprintf(out, " Copyright © %s %s%s All rights reserved.\n", year, holder, (strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : "."); + fprintf(out, " \n"); + fprintf(out, "
\n"); + fprintf(out, " \"Valid", top); + fprintf(out, " \"Valid", top); + fprintf(out, " \n"); + fprintf(out, "
\n"); fprintf(out, " \n"); -} diff --git a/src/image/gen.sh b/src/image/gen.sh index 9a94d23..fb807f6 100755 --- a/src/image/gen.sh +++ b/src/image/gen.sh @@ -7,7 +7,8 @@ if [ -d image ]; then fi for i in *.gif *.png; do NAME="`echo "$i" | rev | cut -d/ -f1 | rev | cut -d. -f1`" - xxd -i -n image_$NAME $i > $NAME.c - echo "extern unsigned char image_$NAME[];" > $NAME.h - echo "extern unsigned int image_${NAME}_len;" >> $NAME.h + NAME2="`echo "$NAME" | sed 's/-/_/g'`" + xxd -i -n image_$NAME2 $i > $NAME.c + echo "extern unsigned char image_$NAME2[];" > $NAME.h + echo "extern unsigned int image_${NAME2}_len;" >> $NAME.h done diff --git a/src/image/valid-css.h b/src/image/valid-css.h index cd564b2..d170920 100644 --- a/src/image/valid-css.h +++ b/src/image/valid-css.h @@ -1,2 +1,2 @@ -extern unsigned char image_valid - css[]; -extern unsigned int image_valid - css_len; +extern unsigned char image_valid_css[]; +extern unsigned int image_valid_css_len; diff --git a/src/image/valid-html401.h b/src/image/valid-html401.h index 4a07bff..0cbe3c4 100644 --- a/src/image/valid-html401.h +++ b/src/image/valid-html401.h @@ -1,2 +1,2 @@ -extern unsigned char image_valid - html401[]; -extern unsigned int image_valid - html401_len; +extern unsigned char image_valid_html401[]; +extern unsigned int image_valid_html401_len; diff --git a/src/seed.c b/src/seed.c index 322a36b..d89d726 100644 --- a/src/seed.c +++ b/src/seed.c @@ -45,8 +45,12 @@ int action_seed(int argc, char** argv) { fprintf(f, " <![CDATA[Welcome to template]]>\n"); fprintf(f, " \n"); fprintf(f, " \n"); - fprintf(f, "
\n"); - fprintf(f, " Congratulations\n"); + fprintf(f, "
\n"); + fprintf(f, "

\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 site/content/index.xml.\n"); + fprintf(f, " Please edit it and replace this text with content of your own.\n"); + fprintf(f, "

\n"); fprintf(f, "
\n"); fprintf(f, " \n"); fprintf(f, "\n");