diff --git a/Makefile b/Makefile index aee731e..60b072d 100644 --- a/Makefile +++ b/Makefile @@ -7,13 +7,29 @@ EXE=bin/GenBlog all: install $(CC) $(FLAGS) src/GenBlog.c -o $(EXE) +debug: install + $(CC) $(FLAGS) -DDEBUG src/GenBlog.c -o $(EXE) + install: mkdir -p bin mkdir -p obj + mkdir -p blogs clean: rm -rf obj rm -rf bin blog: all + @# Reset all blogs to start build. + -rm -rf blogs/*.html + @# Setup boilerplate html files for blog files + -@for blog in ./blogs/RawBlogs/*.blog ; do \ + blog=$$(echo $$blog | cut -c 17- | cut -d "." -f 1); \ + cp ./blogs/preamble/start.html ./blogs/$$blog.html; \ + done ./bin/GenBlog + @# Append the end of the file once done + -@for blog in ./blogs/RawBlogs/*.blog ; do \ + blog=$$(echo $$blog | cut -c 17- | cut -d "." -f 1); \ + cat ./blogs/preamble/end.html >> ./blogs/$$blog.html; \ + done diff --git a/blogs/RawBlogs/test.blog b/blogs/RawBlogs/test.blog new file mode 100644 index 0000000..b65a6e7 --- /dev/null +++ b/blogs/RawBlogs/test.blog @@ -0,0 +1,10 @@ +Title +[ +No Box +] +- +Text in a box +_ +- +Another box +- diff --git a/blogs/preamble/end.html b/blogs/preamble/end.html new file mode 100644 index 0000000..fcaaf94 --- /dev/null +++ b/blogs/preamble/end.html @@ -0,0 +1,4 @@ +View page source + + + diff --git a/blogs/preamble/start.html b/blogs/preamble/start.html new file mode 100644 index 0000000..01dd1d0 --- /dev/null +++ b/blogs/preamble/start.html @@ -0,0 +1,42 @@ + + + + +
+
+ 🅱️ HOME 🅱️
+
+
+
+View page source
+
+
+
diff --git a/blogs/test.html b/blogs/test.html new file mode 100644 index 0000000..dade83d --- /dev/null +++ b/blogs/test.html @@ -0,0 +1,46 @@ + + + + +
+
+ 🅱️ HOME 🅱️
+
+
+
+View page source
+
+
+
+View page source + + + diff --git a/src/GenBlog.c b/src/GenBlog.c index edcd0ba..558e866 100644 --- a/src/GenBlog.c +++ b/src/GenBlog.c @@ -1,6 +1,76 @@ #include #include +#include +#include + +void parseBox(void); +void parseNoBox(void); +void genBP(char *file); +void echoFile(FILE *fp); +int ch; int main() { + DIR *dir; + struct dirent *ent; + char buff[256]; + + if ((dir = opendir("./blogs/RawBlogs")) != NULL) { + while ((ent = readdir(dir)) != NULL) { + if (strcmp(ent->d_name, ".") && strcmp(ent->d_name, "..")) { + printf("file = %s\n", ent->d_name); + sprintf(buff, "./blogs/RawBlogs/"); + strcat(buff, ent->d_name); + printf("opening, %s\n", buff); + genBP(buff); + } + } + } return EXIT_SUCCESS; } + +void genBP(char *file) { + FILE *fp = fopen(file, "r"); + char buff[256]; + echoFile(fopen(file, "r")); + + //Begin parsing the file. + ch = getc(fp); + while (ch != EOF) { + switch (ch) { + case '-': + ch = getc(fp); + parseBox(); + break; + case '[': + ch = getc(fp); + parseNoBox(); + break; + } + ch = getc(fp); + } +} + +void echoFile(FILE *fp) { + char line[256] = ""; + ch = getc(fp); + + printf("Echo file\n"); + while (ch != EOF) { + if (ch != '\n') { + strcat(line, &ch); + } else { + printf("%s\n", line); + sprintf(line, ""); + } + ch = getc(fp); + } + fclose(fp); +} + +void parseBox() { + +} + +void parseNoBox() { + +}