wip
Some checks are pending
pyrite-dev/taiga/pipeline/head Build queued...

This commit is contained in:
Nishi 2026-03-01 23:36:33 +09:00
commit 930fa5dbad
Signed by: nishi
GPG key ID: 27EF69B208EB9343
5 changed files with 100 additions and 0 deletions

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
*.o
*.exe
/taiga
/build
/site

View file

@ -26,3 +26,6 @@ src/src_seed.o: src/seed.c
OBJS += src/src_site.o
src/src_site.o: src/site.c
$(CC) $(CFLAGS) -c -o $@ src/site.c
OBJS += src/src_util.o
src/src_util.o: src/util.c
$(CC) $(CFLAGS) -c -o $@ src/util.c

View file

@ -1,5 +1,38 @@
#include <taiga.h>
static void describe(const char* path, const char* what){
char space[64];
int i;
memset(space, 0, sizeof(space));
for(i = 0; i < (32 - strlen(path)); i++) space[i] = ' ';
printf("%s%s# %s\n", path, space, what);
}
int action_seed(int argc, char** argv){
FILE* f;
io_mkdir("site", 0755);
io_mkdir("site/content", 0755);
if((f = fopen("site/skinconf.xml", "w")) == NULL){
fprintf(stderr, "Failed to open site/skinconf.xml\n");
return 1;
}
fprintf(f, "<?xml version=\"1.0\"?>\n");
fprintf(f, "<skinconfig>\n");
fprintf(f, " <search domain=\"example.com\" />\n");
fprintf(f, " <vendor>Example Co, Ltd.</vendor>\n");
fprintf(f, " <year>2026</vendor>\n");
fprintf(f, " <copyright-link>https://example.com</copyright-link>\n");
fprintf(f, "</skinconfig>\n");
fclose(f);
printf("Template project created!\n");
printf("\n");
printf("Here is an outline of the generated files:\n");
describe("site/skinconf.xml", "Skin configuration");
return 0;
}

View file

@ -1,5 +1,39 @@
#include <taiga.h>
static void scan(const char* path){
char* in = u_strvacat("site/content/", path, NULL);
char* out = u_strvacat("build/", path, NULL);
IO_DIR* dir;
if((dir = io_opendir(in)) != NULL){
struct io_dirent* d;
while((d = io_readdir(dir)) != NULL){
char* p;
struct io_stat s;
if(strcmp(d->d_name, ".") == 0 || strcmp(d->d_name, "..") == 0) continue;
p = u_strvacat(in, d->d_name, "/", NULL);
if(io_stat(p, &s) == 0){
if(IO_S_ISDIR(s.st_mode)){
scan(p);
}
}
free(p);
}
io_closedir(dir);
}
free(out);
free(in);
}
int action_site(int argc, char** argv){
io_mkdir("build", 0755);
scan("");
return 0;
}

View file

@ -4,10 +4,35 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <direct.h>
#include <io.h>
#else
#include <unistd.h>
#include <dirent.h>
#endif
#ifdef _WIN32
#define io_mkdir(x,y) _mkdir(x)
#define io_chdir(x) _chdir(x)
#define io_stat _stat
#define IO_S_ISDIR(m) ((m) & _S_IFDIR)
#else
#define io_mkdir mkdir
#define io_chdir chdir
#define io_stat stat
#define IO_S_ISDIR(m) ((m) & S_IFDIR)
#define IO_DIR DIR
#define io_dirent dirent
#define io_opendir opendir
#define io_readdir readdir
#define io_closedir closedir
#endif
/* site.c */
@ -19,4 +44,7 @@ int action_help(int argc, char** argv);
/* seed.c */
int action_seed(int argc, char** argv);
/* util.c */
char* u_strvacat(const char* str, ...);
#endif