From ba4f74e2613d9e8228ab82ccb65dd4f66e35af17 Mon Sep 17 00:00:00 2001 From: thing1 Date: Sat, 1 Feb 2025 14:42:35 +0000 Subject: init commit --- .gitignore | 2 ++ Makefile | 2 ++ blogger.sh | 37 +++++++++++++++++++++++++++++++++++++ blogs/first---1.2.25.blog | 11 +++++++++++ blogs/output/style.css | 29 +++++++++++++++++++++++++++++ blogtohtml.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 125 insertions(+) create mode 100644 .gitignore create mode 100644 Makefile create mode 100755 blogger.sh create mode 100644 blogs/first---1.2.25.blog create mode 100644 blogs/output/style.css create mode 100644 blogtohtml.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e5da97b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.html +blogtohtml diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3a5b40a --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +blogtohtml: blogtohtml.c + cc blogtohtml.c -o blogtohtml diff --git a/blogger.sh b/blogger.sh new file mode 100755 index 0000000..4a50e3f --- /dev/null +++ b/blogger.sh @@ -0,0 +1,37 @@ +#!/bin/sh + +blogfile="./blogs" +outfile="./blogs/output" +index="./blogs/output/index.html" + + +mkdir -p $outfile +rm -rf outfile/*.html + +echo """ +

Thing1's blogs!

+ +
+
+
+
+""" > $index + +blogs=$(ls $blogfile/*.blog) +for i in $blogs; do + out=$(echo $i | rev | cut -d '/' -f 1 | cut -d '.' -f 2- | rev) + + echo """ +${out} + +

$out

+ """ > $outfile/$out.html + + cat $i | ./blogtohtml >> $outfile/$out.html + + echo """ + + """ >> $outfile/$out.html + + echo "${out}" >> $index +done diff --git a/blogs/first---1.2.25.blog b/blogs/first---1.2.25.blog new file mode 100644 index 0000000..ba641af --- /dev/null +++ b/blogs/first---1.2.25.blog @@ -0,0 +1,11 @@ + +* Wow! look at this blog +Isn't it amazing, I know it is right, some content finally came onto this site, it's as if someone is running it. I want to use these blogs as a pseudo dirary sorta thing. I dont really expect them to be read but if someone does then I suppose thats a win. + +I suppose a good place to start with is who am I. Well im a lot of things, notably a nerd, so thats why you can read this page at all, I like righting clean code in C, with no nonsense librarys or anything like that (looking at you CMake), I like small command line editors like vim, but as of writing I'm using kakoune, it's a new years resolution of sort but I dont really believe in them, oh well :). (If you read this far the best thing to take away is to try kakoune). + +On other things obvously I'm a linux guy but I doubt that needed to be said, you probably are too if your reading this drivel. + +If your somehow intressed in the stuff I'm using to make this blog (Shokingly its not hand writen html), its a small tool I just through together called blogger, which consists of about ~50 of shell and C code combind, none of it is very good but it doesn't need to be, it's working so far. + +Anyway I think that calls it for the blog today, on other news the world is ending but thats nothing new! diff --git a/blogs/output/style.css b/blogs/output/style.css new file mode 100644 index 0000000..c39429b --- /dev/null +++ b/blogs/output/style.css @@ -0,0 +1,29 @@ +body { + background: black; +} + +#blogtitle { + text-align: center; + color: white; + scale: 2; + padding: 30px +} + +#blogheading { + text-align: center; + color: white; +} + +#blogcontent { + text-align: center; + color: white; + margin-left: 20%; + margin-right: 20%; +} + +#bloglink { + margin-left: auto; + margin-right: auto; + text-align: center; + display: block; +} diff --git a/blogtohtml.c b/blogtohtml.c new file mode 100644 index 0000000..b6576d7 --- /dev/null +++ b/blogtohtml.c @@ -0,0 +1,44 @@ +#include +#include +#include + +#define stylesheet "style.css" + +int main() { + char c; + size_t len = 0; + + size_t size = 100; + char *buffer = malloc(size); + + while ((c = getchar()) != EOF){ + if (len >= size) { + size += 100; + buffer = realloc(buffer, size); + } + buffer[len] = c; + len++; + } + len++; + buffer = realloc(buffer, len); + buffer[len] = 0; + + printf("\n"); + + int headingcount = 0; + for (int i = 0; i < len - 1; i++) { + if (memcmp(&buffer[i], "\n*", 2) == 0){ + i += 3; + (headingcount != 0) ? printf("

\n

") : printf("

"); + headingcount++; + while (buffer[i] != '\n' && buffer[i] != 0) { + printf("%c", buffer[i]); + i++; + } + printf("

\n

\n"); + } else if (buffer[i] == '\n') { + printf("\n
\n"); + } else printf("%c", buffer[i]); + } + printf("

\n"); +} -- cgit v1.2.3