summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorthing1 <thing1@seacrossedlovers.xyz>2025-02-01 14:42:35 +0000
committerthing1 <thing1@seacrossedlovers.xyz>2025-02-01 14:42:35 +0000
commitba4f74e2613d9e8228ab82ccb65dd4f66e35af17 (patch)
tree214697d102fbf3ad16f04f53763a93152b02ee19
init commit
-rw-r--r--.gitignore2
-rw-r--r--Makefile2
-rwxr-xr-xblogger.sh37
-rw-r--r--blogs/first---1.2.25.blog11
-rw-r--r--blogs/output/style.css29
-rw-r--r--blogtohtml.c44
6 files changed, 125 insertions, 0 deletions
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 """
+<h1 id=blogtitle>Thing1's blogs!</h1>
+<link rel=\"stylesheet\" href=\"style.css\">
+<br>
+<br>
+<br>
+<br>
+""" > $index
+
+blogs=$(ls $blogfile/*.blog)
+for i in $blogs; do
+ out=$(echo $i | rev | cut -d '/' -f 1 | cut -d '.' -f 2- | rev)
+
+ echo """
+<title>${out}</title>
+<body>
+<h1 id=blogtitle>$out</h1>
+ """ > $outfile/$out.html
+
+ cat $i | ./blogtohtml >> $outfile/$out.html
+
+ echo """
+</body>
+ """ >> $outfile/$out.html
+
+ echo "<a id=bloglink href=${out}.html>${out}</a>" >> $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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#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("<link rel=\"stylesheet\" href=\""stylesheet"\">\n");
+
+ int headingcount = 0;
+ for (int i = 0; i < len - 1; i++) {
+ if (memcmp(&buffer[i], "\n*", 2) == 0){
+ i += 3;
+ (headingcount != 0) ? printf("</p>\n<h1 id=blogheading>") : printf("<h1 id=blogheading>");
+ headingcount++;
+ while (buffer[i] != '\n' && buffer[i] != 0) {
+ printf("%c", buffer[i]);
+ i++;
+ }
+ printf("</h1>\n<p id=blogcontent>\n");
+ } else if (buffer[i] == '\n') {
+ printf("\n<br>\n");
+ } else printf("%c", buffer[i]);
+ }
+ printf("</p>\n");
+}