diff --git a/objs.mk b/objs.mk
index d6602ae..2617508 100644
--- a/objs.mk
+++ b/objs.mk
@@ -17,6 +17,9 @@ src/external_xemil_src_util.o: external/xemil/src/util.c
OBJS += src/src_classic.o
src/src_classic.o: src/classic.c
$(CC) $(CFLAGS) -c -o $@ src/classic.c
+OBJS += src/src_crc.o
+src/src_crc.o: src/crc.c
+ $(CC) $(CFLAGS) -c -o $@ src/crc.c
OBJS += src/src_default.o
src/src_default.o: src/default.c
$(CC) $(CFLAGS) -c -o $@ src/default.c
diff --git a/src/classic.c b/src/classic.c
index 2826c8a..aa69778 100644
--- a/src/classic.c
+++ b/src/classic.c
@@ -53,6 +53,10 @@ void classic_stylesheet(FILE* out, const char* top) {
fprintf(out, " padding: 8px;\n");
fprintf(out, "}\n");
fprintf(out, "\n");
+ fprintf(out, "#footer {\n");
+ fprintf(out, " padding-top: 0;\n");
+ fprintf(out, "}\n");
+ fprintf(out, "\n");
fprintf(out, ".section {\n");
fprintf(out, " background-color: #eeeeee;\n");
fprintf(out, " padding-left: 8px;\n");
@@ -278,6 +282,27 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
fprintf(out, "
\n");
fprintf(out, " \n");
+ if((nodes = xl_get_path(body, "section")) != NULL) {
+ int i;
+
+ fprintf(out, " - Contents \n");
+ fprintf(out, " \n");
+
+ for(i = 0; nodes[i] != NULL; i++) {
+ char* name = NULL;
+ char* id;
+
+ if((name = xl_get_attribute(nodes[i], "title")) == NULL) continue;
+
+ id = u_section_id(nodes[i]);
+
+ fprintf(out, " - %s\n", id, name);
+ }
+
+ fprintf(out, " \n");
+ fprintf(out, " \n");
+ }
+
if((nodes = xl_get_path(skinconf->root, "nav")) != NULL) {
int i;
diff --git a/src/crc.c b/src/crc.c
new file mode 100644
index 0000000..3d8a05b
--- /dev/null
+++ b/src/crc.c
@@ -0,0 +1,25 @@
+/* crc32.c -- compute the CRC-32 of a data stream
+ * Copyright (C) 1995-1998 Mark Adler
+ * For conditions of distribution and use, see copyright notice in zlib.h
+ */
+
+#include
+
+unsigned int crc32(void* input, unsigned int len) {
+ int i, j;
+ unsigned int byte, crc, mask;
+ unsigned char* message = input;
+
+ i = 0;
+ crc = 0xFFFFFFFF;
+ while(i < len) {
+ byte = message[i]; // Get next byte.
+ crc = crc ^ byte;
+ for(j = 7; j >= 0; j--) { // Do eight times.
+ mask = -(crc & 1);
+ crc = (crc >> 1) ^ (0xEDB88320 & mask);
+ }
+ i = i + 1;
+ }
+ return ~crc;
+}
diff --git a/src/default.c b/src/default.c
index 70a0e38..6cb13ae 100644
--- a/src/default.c
+++ b/src/default.c
@@ -103,8 +103,9 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int spec, int
if(strcmp(element->name, "section") == 0) {
char* title = xl_get_attribute(element, "title");
+ char* id = u_section_id(element);
- sprintf(tag, "%s ", title);
+ if(id != NULL) sprintf(tag, "%s ", id, title);
} else if(strcmp(element->name, "fixme") == 0 || /**/
strcmp(element->name, "warning") == 0 || /**/
strcmp(element->name, "note") == 0) {
diff --git a/src/seed.c b/src/seed.c
index da5752c..9cad87b 100644
--- a/src/seed.c
+++ b/src/seed.c
@@ -127,7 +127,7 @@ int action_seed(int argc, char** argv) {
fprintf(f, " Test | \n");
fprintf(f, " \n");
fprintf(f, " \n");
- fprintf(f, " \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");
diff --git a/src/simple.c b/src/simple.c
index 05bb4df..9ef283d 100644
--- a/src/simple.c
+++ b/src/simple.c
@@ -156,7 +156,6 @@ void simple_stylesheet(FILE* out, const char* top) {
fprintf(out, "\n");
fprintf(out, ".message-icon {\n");
fprintf(out, " padding-right: 5px;\n");
- ;
fprintf(out, "}\n");
fprintf(out, "\n");
fprintf(out, ".message-title {\n");
@@ -168,6 +167,14 @@ void simple_stylesheet(FILE* out, const char* top) {
fprintf(out, " border-bottom: solid 1px #808080;\n");
fprintf(out, "}\n");
fprintf(out, "\n");
+ fprintf(out, ".box-content ul {\n");
+ fprintf(out, " margin: 0;\n");
+ fprintf(out, " padding-top: 8px;\n");
+ fprintf(out, " padding-bottom: 8px;\n");
+ fprintf(out, " padding-left: 28px;\n");
+ fprintf(out, " padding-right: 18px;\n");
+ fprintf(out, "}\n");
+ fprintf(out, "\n");
for(i = 0; i < sizeof(messages) / sizeof(messages[0]); i++) {
fprintf(out, ".%s-message {\n", messages[i]);
@@ -281,6 +288,32 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body)
fprintf(out, " \n");
fprintf(out, " \n");
fprintf(out, " \n");
+
+ if((nodes = xl_get_path(body, "section")) != NULL) {
+ int i;
+
+ fprintf(out, " \n");
+ fprintf(out, " CONTENTS\n");
+ fprintf(out, " \n");
+ fprintf(out, " \n");
+
+ for(i = 0; nodes[i] != NULL; i++) {
+ char* name = NULL;
+ char* id;
+
+ if((name = xl_get_attribute(nodes[i], "title")) == NULL) continue;
+
+ id = u_section_id(nodes[i]);
+
+ fprintf(out, " - %s
\n", id, name);
+ }
+
+ fprintf(out, " \n");
+ fprintf(out, " \n");
+ fprintf(out, " \n");
+ free(nodes);
+ }
+
fprintf(out, " \n");
fprintf(out, " LINKS\n");
fprintf(out, " \n");
diff --git a/src/taiga.h b/src/taiga.h
index e678179..8d815e2 100644
--- a/src/taiga.h
+++ b/src/taiga.h
@@ -67,6 +67,10 @@ char* u_strdup(const char* str);
char* u_path(const char* top, const char* path);
char* u_http_path(const char* top, const char* path);
int u_image_size(const char* top, const char* path, char* (*path_func)(const char* top, const char* path), int* w, int* h);
+char* u_section_id(xl_node_t* node);
+
+/* crc.c */
+unsigned int crc32(void* input, unsigned int len);
/* process.c */
int process(const char* top, const char* out, const char* full);
diff --git a/src/util.c b/src/util.c
index 04570c8..84c555f 100644
--- a/src/util.c
+++ b/src/util.c
@@ -110,3 +110,29 @@ int u_image_size(const char* top, const char* path, char* (*path_func)(const cha
return st;
}
+
+char* u_section_id(xl_node_t* node) {
+ char* name;
+ char* id;
+
+ if((name = xl_get_attribute(node, "title")) == NULL) return NULL;
+
+ if((id = xl_get_attribute(node, "id")) != NULL) id = u_strdup(id);
+ if(id == NULL) {
+ int unique = 0;
+ xl_node_t* child = node->parent->first_child;
+
+ while(child != NULL) {
+ if(child == node) break;
+
+ unique++;
+ child = child->next;
+ }
+
+ id = malloc(64);
+
+ sprintf(id, "%d-%d", unique, crc32(name, strlen(name)));
+ }
+
+ return id;
+}
| |