add more fancy things
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
d332b1264d
commit
3cbcb8b1da
9 changed files with 109 additions and 64 deletions
|
|
@ -76,12 +76,14 @@ int action_seed(int argc, char** argv) {
|
|||
fprintf(f, " </project>\n");
|
||||
fprintf(f, " <nav>\n");
|
||||
fprintf(f, " <group title=\"Example Project\">\n");
|
||||
fprintf(f, " <group title=\"Sitemap\">\n");
|
||||
fprintf(f, " <autogenerate layer=\"2\">\n");
|
||||
fprintf(f, " <exclude>path-you-want-to-exclude/index.xml</exclude>\n");
|
||||
fprintf(f, " <exclude>other-path-you-want-to-exclude</exclude>\n");
|
||||
fprintf(f, " </autogenerate>\n");
|
||||
fprintf(f, " </group>\n");
|
||||
fprintf(f, " <if under=\"/\">\n");
|
||||
fprintf(f, " <group title=\"Sitemap\">\n");
|
||||
fprintf(f, " <autogenerate layer=\"2\" path=\"/\">\n");
|
||||
fprintf(f, " <exclude>path-you-want-to-exclude/index.xml</exclude>\n");
|
||||
fprintf(f, " <exclude>other-path-you-want-to-exclude</exclude>\n");
|
||||
fprintf(f, " </autogenerate>\n");
|
||||
fprintf(f, " </group>\n");
|
||||
fprintf(f, " </if>\n");
|
||||
fprintf(f, " <link name=\"Home\" href=\"/\" />\n");
|
||||
fprintf(f, " <link name=\"Example Co, Ltd.\" href=\"https://example.com\" />\n");
|
||||
fprintf(f, " <group title=\"Example Project\">\n");
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
xemil_t* skinconf;
|
||||
void (*site_stylesheet)(FILE* out, const char* top); /* also create files here if you need one */
|
||||
void (*site_head)(FILE* out, const char* top, xl_node_t* header);
|
||||
void (*site_body)(FILE* out, const char* top, const char* title, xl_node_t* body);
|
||||
void (*site_head)(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
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) {
|
||||
char* in = u_strvacat("site/content/", path, NULL);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ static void accept_attr(const char* top, char* text, int spec, xl_node_t* elemen
|
|||
}
|
||||
}
|
||||
|
||||
void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
||||
void default_head(FILE* out, const char* top, xl_node_t* element, const char* input, int indent) {
|
||||
xl_node_t* child;
|
||||
char tag[2048];
|
||||
char end[128];
|
||||
|
|
@ -73,7 +73,7 @@ void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
child = element->first_child;
|
||||
while(child != NULL) {
|
||||
if(child->type == XL_NODE_NODE && child->name != NULL) {
|
||||
default_head(out, top, child, indent + 1 + add);
|
||||
default_head(out, top, child, input, indent + 1 + add);
|
||||
} else if(child->type == XL_NODE_TEXT && child->text != NULL) {
|
||||
/* most likely junk */
|
||||
#if 0
|
||||
|
|
@ -87,7 +87,7 @@ void default_head(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
if(end[0] != 0) print(out, end, 0, indent);
|
||||
}
|
||||
|
||||
void default_body(FILE* out, const char* top, xl_node_t* element, int spec, int pre, int indent) {
|
||||
void default_body(FILE* out, const char* top, xl_node_t* element, const char* input, int spec, int pre, int indent) {
|
||||
xl_node_t* child;
|
||||
char tag[2048]; /* enough for most cases... :) */
|
||||
char end[128];
|
||||
|
|
@ -240,7 +240,7 @@ void default_body(FILE* out, const char* top, xl_node_t* element, int spec, int
|
|||
child = element->first_child;
|
||||
while(child != NULL) {
|
||||
if(child->type == XL_NODE_NODE && child->name != NULL) {
|
||||
default_body(out, top, child, spec, pre, indent + 1 + add);
|
||||
default_body(out, top, child, input, spec, pre, indent + 1 + add);
|
||||
} else if(child->type == XL_NODE_TEXT && (pre ? (child->text_raw != NULL) : (child->text != NULL))) {
|
||||
print(out, pre ? child->text_raw : child->text, pre, pre ? 0 : (indent + 1 + add));
|
||||
}
|
||||
|
|
@ -312,25 +312,27 @@ static char** scan_xml(const char* path, const char* path2, xl_node_t** excludes
|
|||
char* p3 = u_strvacat(path2, d->d_name, NULL);
|
||||
int i;
|
||||
|
||||
for(i = 0; excludes[i] != NULL; i++) {
|
||||
if(excludes[i]->text == NULL) continue;
|
||||
if(excludes != NULL) {
|
||||
for(i = 0; excludes[i] != NULL; i++) {
|
||||
if(excludes[i]->text == NULL) continue;
|
||||
|
||||
if(strcmp(excludes[i]->text, p3) == 0) break;
|
||||
if(strlen(excludes[i]->text) > 0 && excludes[i]->text[strlen(excludes[i]->text) - 1] == '/' && strstr(p3, excludes[i]->text) == p3) break;
|
||||
if(strlen(excludes[i]->text) > 0) {
|
||||
char* p4 = u_strvacat(excludes[i]->text, "/", NULL);
|
||||
if(strcmp(excludes[i]->text, p3) == 0) break;
|
||||
if(strlen(excludes[i]->text) > 0 && excludes[i]->text[strlen(excludes[i]->text) - 1] == '/' && strstr(p3, excludes[i]->text) == p3) break;
|
||||
if(strlen(excludes[i]->text) > 0) {
|
||||
char* p4 = u_strvacat(excludes[i]->text, "/", NULL);
|
||||
|
||||
if(strstr(p3, p4) == p3) {
|
||||
if(strstr(p3, p4) == p3) {
|
||||
free(p4);
|
||||
break;
|
||||
}
|
||||
free(p4);
|
||||
break;
|
||||
}
|
||||
free(p4);
|
||||
}
|
||||
}
|
||||
|
||||
free(p3);
|
||||
|
||||
if(excludes[i] == NULL) arrput(arr, p);
|
||||
if(excludes == NULL || excludes[i] == NULL) arrput(arr, p);
|
||||
} else {
|
||||
free(p);
|
||||
}
|
||||
|
|
@ -347,12 +349,44 @@ static char** scan_xml(const char* path, const char* path2, xl_node_t** excludes
|
|||
return arr;
|
||||
}
|
||||
|
||||
void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
||||
void default_nav(FILE* out, const char* top, xl_node_t* element, const char* input, int indent) {
|
||||
int i;
|
||||
|
||||
if(element->name == NULL) return;
|
||||
|
||||
if(strcmp(element->name, "link") == 0) {
|
||||
if(strcmp(element->name, "if") == 0) {
|
||||
int cond = 0;
|
||||
xl_attribute_t* attr = element->first_attribute;
|
||||
|
||||
while(attr != NULL) {
|
||||
if(strcmp(attr->key, "under") == 0 && attr->value != NULL) {
|
||||
char* p = u_path_combine("site/content", attr->value);
|
||||
char* p2 = u_strvacat(p, "/", NULL);
|
||||
|
||||
if(strstr(input, p2) == input) {
|
||||
free(p2);
|
||||
free(p);
|
||||
|
||||
cond = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
free(p2);
|
||||
free(p);
|
||||
}
|
||||
|
||||
attr = attr->next;
|
||||
}
|
||||
|
||||
if(cond) {
|
||||
xl_node_t* child = element->first_child;
|
||||
while(child != NULL) {
|
||||
default_nav(out, top, child, input, indent);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
} else if(strcmp(element->name, "link") == 0) {
|
||||
char* link;
|
||||
char* name;
|
||||
|
||||
|
|
@ -381,7 +415,7 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
|
||||
child = element->first_child;
|
||||
while(child != NULL) {
|
||||
default_nav(out, top, child, indent + 1);
|
||||
default_nav(out, top, child, input, indent + 1);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
@ -394,12 +428,24 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, int indent) {
|
|||
char* layer;
|
||||
xl_node_t* child;
|
||||
xl_node_t** excludes;
|
||||
char* p;
|
||||
char* p2;
|
||||
|
||||
if((layer = xl_get_attribute(element, "layer")) == NULL) layer = "*";
|
||||
|
||||
excludes = xl_get_path(element, "exclude");
|
||||
|
||||
xml = scan_xml("site/content/", "", excludes, strcmp(layer, "*") == 0 ? 0xffff : (atoi(layer) - 1));
|
||||
if((p = xl_get_attribute(element, "path")) == NULL) {
|
||||
p = u_path_combine("site/content", "");
|
||||
} else {
|
||||
p = u_path_combine("site/content", p);
|
||||
}
|
||||
|
||||
p2 = u_strvacat(p, "/", NULL);
|
||||
free(p);
|
||||
|
||||
xml = scan_xml(p2, "", excludes, strcmp(layer, "*") == 0 ? 0xffff : (atoi(layer) - 1));
|
||||
free(p2);
|
||||
|
||||
if(excludes != NULL) free(excludes);
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static int parse_file(const char* top, const char* full) {
|
|||
free(nodes);
|
||||
}
|
||||
|
||||
site_head(f, top, header);
|
||||
site_head(f, top, header, full);
|
||||
|
||||
fprintf(f, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\n", top);
|
||||
if(!has_own_icon && (nodes = xl_get_path(skinconf->root, "favicon")) != NULL) {
|
||||
|
|
@ -85,7 +85,7 @@ static int parse_file(const char* top, const char* full) {
|
|||
|
||||
fprintf(f, " </head>\n");
|
||||
fprintf(f, " <body>\n");
|
||||
site_body(f, top, title, body);
|
||||
site_body(f, top, title, body, full);
|
||||
fprintf(f, " <!--[if lte IE 6]>\n");
|
||||
fprintf(f, " <script language=\"javascript\" type=\"text/javascript\">\n");
|
||||
fprintf(f, " for(var i = 0; i < document.images.length; i++){\n");
|
||||
|
|
@ -121,6 +121,9 @@ static int parse_file(const char* top, const char* full) {
|
|||
fprintf(f, " <style>\n");
|
||||
fprintf(f, "pre {\n");
|
||||
fprintf(f, " width: 50px;\n");
|
||||
fprintf(f, " overflow-wrap: break-word;\n");
|
||||
fprintf(f, " word-wrap: break-word;\n");
|
||||
fprintf(f, " white-space: pre-wrap;\n");
|
||||
fprintf(f, "}\n");
|
||||
fprintf(f, " </style>\n");
|
||||
fprintf(f, " <![endif]-->\n");
|
||||
|
|
|
|||
|
|
@ -124,12 +124,6 @@ void classic_stylesheet(FILE* out, const char* top) {
|
|||
fprintf(out, " border-left: 1px solid #cccccc;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "pre {\n");
|
||||
fprintf(out, " overflow-wrap: break-word;\n");
|
||||
fprintf(out, " word-wrap: break-word;\n");
|
||||
fprintf(out, " white-space: pre-wrap;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".message-icon {\n");
|
||||
fprintf(out, " padding-right: 5px;\n");
|
||||
fprintf(out, "}\n");
|
||||
|
|
@ -145,20 +139,18 @@ void classic_stylesheet(FILE* out, const char* top) {
|
|||
}
|
||||
}
|
||||
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header) {
|
||||
void classic_head(FILE* out, const char* top, xl_node_t* header, const char* input) {
|
||||
xl_node_t* child;
|
||||
|
||||
fprintf(out, " <link rel=\"stylesheet\" href=\"%sstyle.css\">\n", top);
|
||||
|
||||
child = header->first_child;
|
||||
while(child != NULL) {
|
||||
default_head(out, top, child, 2);
|
||||
default_head(out, top, child, input, 2);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
}
|
||||
|
||||
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, const char* input) {
|
||||
char year[4 + 1 + 4 + 1]; /* no one would use our software in year 10000... right? :) */
|
||||
char* holder = "Unknown people";
|
||||
char* sitesearch = NULL;
|
||||
|
|
@ -324,7 +316,7 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
|
||||
child = nodes[0]->first_child;
|
||||
while(child != NULL) {
|
||||
default_nav(out, top, child, 6);
|
||||
default_nav(out, top, child, input, 6);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
@ -340,7 +332,7 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
if(body != NULL) {
|
||||
child = body->first_child;
|
||||
while(child != NULL) {
|
||||
default_body(out, top, child, 0, 0, 6);
|
||||
default_body(out, top, child, input, 0, 0, 6);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
@ -352,7 +344,7 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
|
|||
if((nodes = xl_get_path(skinconf->root, "footer")) != NULL) {
|
||||
child = nodes[0]->first_child;
|
||||
while(child != NULL) {
|
||||
default_body(out, top, child, 1, 0, 6);
|
||||
default_body(out, top, child, input, 1, 0, 6);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,12 +172,6 @@ void simple_stylesheet(FILE* out, const char* top) {
|
|||
fprintf(out, " border-bottom: solid 1px #808080;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, "pre {\n");
|
||||
fprintf(out, " overflow-wrap: break-word;\n");
|
||||
fprintf(out, " word-wrap: break-word;\n");
|
||||
fprintf(out, " white-space: pre-wrap;\n");
|
||||
fprintf(out, "}\n");
|
||||
fprintf(out, "\n");
|
||||
fprintf(out, ".box-content ul {\n");
|
||||
fprintf(out, " margin: 0;\n");
|
||||
fprintf(out, " padding-top: 8px;\n");
|
||||
|
|
@ -198,10 +192,18 @@ void simple_stylesheet(FILE* out, const char* top) {
|
|||
}
|
||||
}
|
||||
|
||||
void simple_head(FILE* out, const char* top, xl_node_t* header) {
|
||||
void simple_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 simple_body(FILE* out, const char* top, const char* title, xl_node_t* body) {
|
||||
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";
|
||||
char* project = "Unknown project";
|
||||
|
|
@ -333,7 +335,7 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body)
|
|||
|
||||
child = nodes[0]->first_child;
|
||||
while(child != NULL) {
|
||||
default_nav(out, top, child, 8);
|
||||
default_nav(out, top, child, input, 8);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
@ -348,7 +350,7 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body)
|
|||
if(body != NULL) {
|
||||
child = body->first_child;
|
||||
while(child != NULL) {
|
||||
default_body(out, top, child, 0, 0, 5);
|
||||
default_body(out, top, child, input, 0, 0, 5);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
@ -359,7 +361,7 @@ void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body)
|
|||
if((nodes = xl_get_path(skinconf->root, "footer")) != NULL) {
|
||||
child = nodes[0]->first_child;
|
||||
while(child != NULL) {
|
||||
default_body(out, top, child, 1, 0, 6);
|
||||
default_body(out, top, child, input, 1, 0, 6);
|
||||
|
||||
child = child->next;
|
||||
}
|
||||
|
|
|
|||
18
src/taiga.h
18
src/taiga.h
|
|
@ -52,8 +52,8 @@ 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_head)(FILE* out, const char* top, xl_node_t* header);
|
||||
extern void (*site_body)(FILE* out, const char* top, const char* title, xl_node_t* body);
|
||||
extern void (*site_head)(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
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);
|
||||
|
||||
|
|
@ -86,9 +86,9 @@ unsigned int crc32(void* input, unsigned int len);
|
|||
int process(const char* top, const char* out, const char* full);
|
||||
|
||||
/* default.c */
|
||||
void default_head(FILE* out, const char* top, xl_node_t* element, int indent);
|
||||
void default_body(FILE* out, const char* top, xl_node_t* element, int spec, int pre, int indent); /* pass non-zero to spec if you want links to be relative from top */
|
||||
void default_nav(FILE* out, const char* top, xl_node_t* element, int indent);
|
||||
void default_head(FILE* out, const char* top, xl_node_t* element, const char* input, int indent);
|
||||
void default_body(FILE* out, const char* top, xl_node_t* element, const char* input, int spec, int pre, int indent); /* pass non-zero to spec if you want links to be relative from top */
|
||||
void default_nav(FILE* out, const char* top, xl_node_t* element, const char* input, int indent);
|
||||
|
||||
/*** skins ***/
|
||||
|
||||
|
|
@ -98,12 +98,12 @@ void default_nav(FILE* out, const char* top, xl_node_t* element, int indent);
|
|||
|
||||
/* skin/classic.c */
|
||||
void classic_stylesheet(FILE* out, const char* top);
|
||||
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_head(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
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_head(FILE* out, const char* top, xl_node_t* header);
|
||||
void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body);
|
||||
void simple_head(FILE* out, const char* top, xl_node_t* header, const char* input);
|
||||
void simple_body(FILE* out, const char* top, const char* title, xl_node_t* body, const char* input);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ char* u_path(const char* top, const char* path) {
|
|||
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 */
|
||||
return u_strvacat(top, (top[strlen(top) - 1] == '/' && path[0] == '/') ? (path + 1) : path, NULL); /* otherwise, concat */
|
||||
}
|
||||
|
||||
char* u_http_path(const char* top, const char* path) {
|
||||
|
|
|
|||
|
|
@ -306,7 +306,7 @@ open(OUT, ">", $ARGV[2]);
|
|||
print(OUT "<?xml version=\"1.0\"?>\n");
|
||||
print(OUT "<document>\n");
|
||||
print(OUT " <header>\n");
|
||||
print(OUT " <title>Documentation of $input</title>\n");
|
||||
print(OUT " <title>$input</title>\n");
|
||||
print(OUT " </header>\n");
|
||||
print(OUT " <body>\n");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue