This commit is contained in:
parent
9b69a269f7
commit
7e8ff76e82
8 changed files with 90 additions and 165 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1,5 +1,6 @@
|
|||
*.o
|
||||
*.exe
|
||||
*.core
|
||||
/taiga
|
||||
/build
|
||||
/site
|
||||
|
|
|
|||
2
external/xemil
vendored
2
external/xemil
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit e8f00f411100f7e2cc66d935204cd7e1d058ad71
|
||||
Subproject commit e645137476ab89b20bf5744cfbce4448b101bac4
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#include <taiga.h>
|
||||
|
||||
#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, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\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, " <div class=\"section\">%s</div>\n", title);
|
||||
} else if(strcmp(element->name, "p") == 0) {
|
||||
tag = "<p>";
|
||||
end = "</p>";
|
||||
} else if(strcmp(element->name, "code") == 0) {
|
||||
tag = "<code>";
|
||||
end = "</code>";
|
||||
}
|
||||
|
||||
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, " </td>\n");
|
||||
fprintf(out, " <td valign=\"top\">\n");
|
||||
fprintf(out, " <div id=\"content\">\n");
|
||||
|
||||
child = body->first_child;
|
||||
while(child != NULL) {
|
||||
recursive(out, child);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
fprintf(out, " </div>\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <center id=\"copyright\">\n");
|
||||
fprintf(out, " Copyright © %s %s%s All rights reserved.\n", year, holder, (strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : ".");
|
||||
fprintf(out, " </center>\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>\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=\"%svalid-html401.png\" alt=\"Valid HTML 4.01\" border=\"0\"></a>", top);
|
||||
fprintf(out, " <a href=\"https://jigsaw.w3.org/css-validator/\"><img src=\"%svalid-css.png\" alt=\"Valid CSS\" border=\"0\"></a>", 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");
|
||||
|
|
@ -196,7 +266,7 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
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 = '/static/fill.gif';\n");
|
||||
fprintf(out, " document.images[i].src = '%sfill.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");
|
||||
|
|
|
|||
151
src/classic.c~
151
src/classic.c~
|
|
@ -1,151 +0,0 @@
|
|||
#include <taiga.h>
|
||||
|
||||
#include "image/fill.h"
|
||||
|
||||
void classic_stylesheet(FILE* out, const char* top) {
|
||||
FILE* f;
|
||||
char path[128];
|
||||
|
||||
sprintf(path, "%sfill.gif", top);
|
||||
f = fopen(path, "wb");
|
||||
fwrite(image_fill, 1, image_fill_len, f);
|
||||
fclose(f);
|
||||
|
||||
fprintf(out, "body {\n");
|
||||
fprintf(out, " padding: 0;\n");
|
||||
fprintf(out, " margin: 0;\n");
|
||||
fprintf(out, " font-family: Arial, sans-serif;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "#breadcrumb {\n");
|
||||
fprintf(out, " background-color: #600000;\n");
|
||||
fprintf(out, " font-weight: bold;\n");
|
||||
fprintf(out, " color: #fff;\n");
|
||||
fprintf(out, " padding-left: 8px;\n");
|
||||
fprintf(out, " padding-top: 2px;\n");
|
||||
fprintf(out, " padding-bottom: 2px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "#nav {\n");
|
||||
fprintf(out, " background-color: #eeeeee;\n");
|
||||
fprintf(out, " border-right: solid 1px #aaaaaa;\n");
|
||||
fprintf(out, " border-bottom: solid 1px #aaaaaa;\n");
|
||||
fprintf(out, " padding: 8px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "#content {\n");
|
||||
fprintf(out, " padding: 8px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".section {\n");
|
||||
fprintf(out, " background-color: #eeeeee;\n");
|
||||
fprintf(out, " padding-left: 8px;\n");
|
||||
fprintf(out, " font-weight: bold;\n");
|
||||
fprintf(out, " color: #000088;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "a {\n");
|
||||
fprintf(out, " text-decoration: none;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "#breadcrumb a {\n");
|
||||
fprintf(out, " color: #ffff44;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "a:link {\n");
|
||||
fprintf(out, " color: #003366;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "a:visited {\n");
|
||||
fprintf(out, " color: blue;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "a:hover, #breadcrumb a:hover {\n");
|
||||
fprintf(out, " color: #ff3300;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".linkgroup {\n");
|
||||
fprintf(out, " padding-left: 16px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".linkgrouptitle {\n");
|
||||
fprintf(out, " font-weight: bold;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "#content p {\n");
|
||||
fprintf(out, " padding-left: 8px;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "tr.even {\n");
|
||||
fprintf(out, " background-color: #eeeeee;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "tr.odd {\n");
|
||||
fprintf(out, " background-color: #dddddd;\n");
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header) {
|
||||
fprintf(out, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\n", top);
|
||||
}
|
||||
|
||||
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";
|
||||
xl_node_t** nodes;
|
||||
|
||||
strcpy(year, "Some year");
|
||||
|
||||
if((nodes = xl_get_path(skinconf->root, "copyright.holder")) != NULL) {
|
||||
holder = nodes[0]->text;
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
if((nodes = xl_get_path(skinconf->root, "copyright.year")) != NULL) {
|
||||
time_t t = time(NULL);
|
||||
struct tm* tm = localtime(&t);
|
||||
int cyear = tm->tm_year + 1900;
|
||||
int xyear = atoi(nodes[0]->text);
|
||||
|
||||
if(cyear == xyear){
|
||||
sprintf(year, "%d", cyear);
|
||||
}else{
|
||||
int low = cyear < xyear ? cyear : xyear;
|
||||
int high = cyear > xyear ? cyear : xyear;
|
||||
|
||||
sprintf(year, "%d-%d", low, high);
|
||||
}
|
||||
|
||||
free(nodes);
|
||||
}
|
||||
|
||||
fprintf(out, " <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td colspan=\"2\" id=\"breadcrumb\">\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " <tr>\n");
|
||||
fprintf(out, " <td width=\"150\" valign=\"top\">\n");
|
||||
fprintf(out, " </td>\n");
|
||||
fprintf(out, " </tr>\n");
|
||||
fprintf(out, " </table>\n");
|
||||
fprintf(out, " <center>\n");
|
||||
fprintf(out, " <small>Copyright © %s %s%s All rights reserved.</small>\n", year, holder, (strlen(holder) > 0 && holder[strlen(holder) - 1] == '.') ? "" : ".");
|
||||
fprintf(out, " </center>\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, " 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 = '/static/fill.gif';\n");
|
||||
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");
|
||||
fprintf(out, " <![endif]-->\n");
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -45,8 +45,12 @@ int action_seed(int argc, char** argv) {
|
|||
fprintf(f, " <title><![CDATA[Welcome to template]]></title>\n");
|
||||
fprintf(f, " </header>\n");
|
||||
fprintf(f, " <body>\n");
|
||||
fprintf(f, " <section id=\"status\">\n");
|
||||
fprintf(f, " <title>Congratulations</title>\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, " </p>\n");
|
||||
fprintf(f, " </section>\n");
|
||||
fprintf(f, " </body>\n");
|
||||
fprintf(f, "</document>\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue