thing
All checks were successful
pyrite-dev/taiga/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-03-02 21:51:27 +09:00
commit feb64d3270
Signed by: nishi
GPG key ID: 27EF69B208EB9343
5 changed files with 77 additions and 8 deletions

View file

@ -12,12 +12,12 @@ void classic_stylesheet(FILE* out, const char* top) {
char path[128];
char* breadcrumb_bgcolor = NULL;
xl_node_t** nodes;
int i;
char* messages[] = {
"fixme", "#cc6600", /**/
"warning", "#990000", /**/
"note", "#006699" /**/
};
int i;
sprintf(path, "%sfill.gif", top);
f = fopen(path, "wb");
@ -157,6 +157,11 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
char* sitesearch = NULL;
xl_node_t** nodes;
xl_node_t* child;
int i;
char* images[] = {
"group", "Group", /**/
"project", "Project" /**/
};
strcpy(year, "Some year");
@ -191,6 +196,36 @@ void classic_body(FILE* out, const char* top, const char* title, xl_node_t* body
}
if(sitesearch == NULL) sitesearch = "https://invalid.link";
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++) {
char path[64];
char* description = "";
sprintf(path, "%s.name", images[i]);
if((nodes = xl_get_path(skinconf->root, path)) != NULL) {
description = nodes[i]->text;
free(nodes);
}
if(description == NULL) description = "Logo";
sprintf(path, "%s.image", images[i]);
if((nodes = xl_get_path(skinconf->root, path)) != NULL) {
char* text = xl_get_attribute(nodes[0], "src");
if(text != NULL) {
text = u_path(top, text);
fprintf(out, " <img src=\"%s\" alt=\"%s\">\n", text, images[i + 1], description);
free(text);
}
free(nodes);
}
}
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, " <tr width=\"100%%\">\n");
fprintf(out, " <td>\n");

View file

@ -8,7 +8,7 @@ static void describe(const char* path, const char* what) {
int i;
memset(space, 0, sizeof(space));
for(i = 0; i < (32 - strlen(path)); i++) space[i] = ' ';
for(i = 0; i < (48 - strlen(path)); i++) space[i] = ' ';
printf("%s%s# %s\n", path, space, what);
}
@ -18,17 +18,17 @@ int action_seed(int argc, char** argv) {
io_mkdir("site", 0755);
io_mkdir("site/content", 0755);
io_mkdir("site/image", 0755);
io_mkdir("site/content/image", 0755);
if((f = fopen("site/image/group-logo.png", "w")) == NULL) {
fprintf(stderr, "Failed to open site/image/group-logo.png\n");
if((f = fopen("site/content/image/group-logo.png", "w")) == NULL) {
fprintf(stderr, "Failed to open site/content/image/group-logo.png\n");
return 1;
}
fwrite(image_logo1, image_logo1_len, 1, f);
fclose(f);
if((f = fopen("site/image/project-logo.png", "w")) == NULL) {
fprintf(stderr, "Failed to open site/image/project-logo.png\n");
if((f = fopen("site/content/image/project-logo.png", "w")) == NULL) {
fprintf(stderr, "Failed to open site/content/image/project-logo.png\n");
return 1;
}
fwrite(image_logo2, image_logo2_len, 1, f);
@ -45,11 +45,17 @@ int action_seed(int argc, char** argv) {
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, " <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, " <link href=\"https://example.com\" />\n");
fprintf(f, " <image src=\"\" />\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");
@ -104,6 +110,8 @@ int action_seed(int argc, char** argv) {
printf("Here is an outline of the generated files:\n");
describe("site/skinconf.xml", "Skin configuration");
describe("site/content/index.xml", "Example index file");
describe("site/content/image/group-logo.png", "Group logo");
describe("site/content/image/project-logo.png", "Project logo");
return 0;
}

View file

@ -22,6 +22,10 @@ static int scan(const char* top, const char* path) {
if(IO_S_ISDIR(s.st_mode)) {
char* p2 = u_strvacat(d->d_name, "/", NULL);
char* t = u_strvacat(top, "../", NULL);
char* o = u_strvacat(out, d->d_name, NULL);
io_mkdir(o, 0755);
free(o);
if(!scan(t, p2)) {
free(t);
free(p2);
@ -44,6 +48,19 @@ static int scan(const char* top, const char* path) {
return 0;
}
} else {
char* po = u_strvacat(out, d->d_name, NULL);
FILE* fin = fopen(p, "rb");
FILE* fout = fopen(po, "wb");
char buffer[4096];
int s;
while((s = fread(buffer, 1, sizeof(buffer), fin)) != 0) {
fwrite(buffer, 1, s, fout);
}
fclose(fout);
fclose(fin);
}
}
free(p);

View file

@ -52,6 +52,7 @@ int action_seed(int argc, char** argv);
/* util.c */
char* u_strvacat(const char* str, ...);
char* u_strdup(const char* str);
char* u_path(const char* top, const char* path);
/* process.c */
int process(const char* top, const char* out, const char* full);

View file

@ -28,3 +28,11 @@ char* u_strdup(const char* str) {
return s;
}
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 */
return u_strvacat(top, path, NULL); /* otherwise, concat */
}