From 2e4002e5ad2f495088da627bd7ee8a216eb4e7b1 Mon Sep 17 00:00:00 2001 From: davidovski Date: Thu, 26 Aug 2021 04:15:22 +0100 Subject: initial commit --- build.py | 107 ++++++++++++++++++++++++++++++++++++ const.py | 7 +++ html/blog/entries/blarg.html | 11 ++++ html/blog/entries/test my blog.html | 11 ++++ html/blog/entries/test.html | 11 ++++ html/blog/index.html | 39 +++++++++++++ html/blog/src/blarg.md | 3 + html/blog/src/test my blog.md | 5 ++ html/blog/src/test.md | 3 + html/entries/test.html | 11 ++++ html/entries/welcome.html | 46 ++++++++++++++++ html/index.html | 53 ++++++++++++++++++ html/mononoki.woff | Bin 0 -> 42208 bytes html/rss.xml | 19 +++++++ html/src/welcome.md | 7 +++ html/style.css | 83 ++++++++++++++++++++++++++++ new.sh | 13 +++++ src/welcome.md | 7 +++ sync.sh | 7 +++ templates/index.html | 46 ++++++++++++++++ templates/item.xml | 6 ++ templates/page.html | 46 ++++++++++++++++ templates/rss.xml | 10 ++++ templates/summary.html | 4 ++ 24 files changed, 555 insertions(+) create mode 100644 build.py create mode 100644 const.py create mode 100644 html/blog/entries/blarg.html create mode 100644 html/blog/entries/test my blog.html create mode 100644 html/blog/entries/test.html create mode 100644 html/blog/index.html create mode 100644 html/blog/src/blarg.md create mode 100644 html/blog/src/test my blog.md create mode 100644 html/blog/src/test.md create mode 100644 html/entries/test.html create mode 100644 html/entries/welcome.html create mode 100644 html/index.html create mode 100644 html/mononoki.woff create mode 100644 html/rss.xml create mode 100644 html/src/welcome.md create mode 100644 html/style.css create mode 100755 new.sh create mode 100644 src/welcome.md create mode 100755 sync.sh create mode 100644 templates/index.html create mode 100644 templates/item.xml create mode 100644 templates/page.html create mode 100644 templates/rss.xml create mode 100644 templates/summary.html diff --git a/build.py b/build.py new file mode 100644 index 0000000..5e9a0c3 --- /dev/null +++ b/build.py @@ -0,0 +1,107 @@ +import markdown +import os +import time +import shutil + +from const import * + +def getTemplateHTML(name): + html = "" + with open(os.path.join(templates, name), "r") as file: + html = file.read(); + return html + +def listPages(): + return [ + (lambda path: + (lambda content: + (lambda timestamp: + (lambda name: { + "source_file" : path, + "source_content" : content, + "html" : markdown.markdown(content), + "timestamp" : timestamp, + "date": time.strftime(date_format, time.localtime(timestamp)), + "name" : name, + "url" : f"entries/{name}.html" + })(".".join(p.split(".")[:-1])) + )(os.stat(path).st_ctime) + )(open(path, "r").read()) + )(os.path.join(source, p)) for p in os.listdir(source) + ] + +def formatEntry(content, page): + return content.replace("%date%", page["date"])\ + .replace("%name%", page["name"])\ + .replace("%time%", str(page["timestamp"]))\ + .replace("%source%", site_index + page["source_file"])\ + .replace("%url%", site_index + page["url"]) + +def make(): + + try: + os.makedirs(os.path.join(dist, "entries")) + except: + print("Already have content") + shutil.rmtree(os.path.join(dist, "src")) + shutil.rmtree(os.path.join(dist, "images")) + shutil.copytree(source, os.path.join(dist, "src")) + shutil.copytree(images, os.path.join(dist, "images")) + + pages = listPages() + + summary_templ = getTemplateHTML("summary.html") + + summariesHTML = "\n".join( + [ + formatEntry(summary_templ, page) + .replace( + "%content%", + "\n".join(page["html"].split("\n")[:summary_max]) + ) + + for page in pages + ] + ) + + entry_templ = getTemplateHTML("page.html") + + for page in pages: + with open(os.path.join(dist, page["url"]), "w") as entry: + entry.write( + formatEntry( + entry_templ, + page + ) + .replace("%content%", page["html"]) + ) + + + + index_templ = getTemplateHTML("index.html") + + with open(os.path.join(dist, "index.html"), "w") as index: + index.write( + index_templ.replace("%entries%", summariesHTML) + ) + + + item_templ = getTemplateHTML("item.xml") + rss_templ = getTemplateHTML("rss.xml") + itemsXML = "\n".join( + [ + formatEntry(item_templ, page).replace("%content%", page["html"]) + for page in pages + ] + ) + + with open(os.path.join(dist, "rss.xml"), "w") as index: + index.write( + rss_templ.replace("%items%", itemsXML) + ) + + print(f"built in {len(pages)} pages") +make() + + + diff --git a/const.py b/const.py new file mode 100644 index 0000000..07eeef6 --- /dev/null +++ b/const.py @@ -0,0 +1,7 @@ +site_index = "https://davidovski.xyz/" +images = "images" +date_format = "%a, %d %b %Y %H:%M:%S" +source = "src" +templates = "templates" +dist = "html" +summary_max = 10 diff --git a/html/blog/entries/blarg.html b/html/blog/entries/blarg.html new file mode 100644 index 0000000..2b8b489 --- /dev/null +++ b/html/blog/entries/blarg.html @@ -0,0 +1,11 @@ + + + + + blarg + + +

blarg

+

blarg blarg test haha

+ + diff --git a/html/blog/entries/test my blog.html b/html/blog/entries/test my blog.html new file mode 100644 index 0000000..6af39a4 --- /dev/null +++ b/html/blog/entries/test my blog.html @@ -0,0 +1,11 @@ + + + + + test my blog + + +

test my blog

+

this is an entry woooooooooooow

+ + diff --git a/html/blog/entries/test.html b/html/blog/entries/test.html new file mode 100644 index 0000000..94642ad --- /dev/null +++ b/html/blog/entries/test.html @@ -0,0 +1,11 @@ + + + + + test + + +

test

+

test testing lol

+ + diff --git a/html/blog/index.html b/html/blog/index.html new file mode 100644 index 0000000..1c92525 --- /dev/null +++ b/html/blog/index.html @@ -0,0 +1,39 @@ + + + + + + + +

blog test

+
+
+

test

+

test testing lol

+ + ... + more +

Date: Sun, 08 Aug 2021

+
+ +
+

blarg

+

blarg blarg test haha

+ + ... + more +

Date: Sun, 08 Aug 2021

+
+ +
+

test my blog

+

this is an entry woooooooooooow

+ + ... + more +

Date: Sun, 08 Aug 2021

+
+ +
+ + diff --git a/html/blog/src/blarg.md b/html/blog/src/blarg.md new file mode 100644 index 0000000..8ba38dd --- /dev/null +++ b/html/blog/src/blarg.md @@ -0,0 +1,3 @@ +# blarg + +blarg blarg test haha diff --git a/html/blog/src/test my blog.md b/html/blog/src/test my blog.md new file mode 100644 index 0000000..d4b4bb8 --- /dev/null +++ b/html/blog/src/test my blog.md @@ -0,0 +1,5 @@ +# test my blog + + +this is an entry woooooooooooow + diff --git a/html/blog/src/test.md b/html/blog/src/test.md new file mode 100644 index 0000000..cef0e58 --- /dev/null +++ b/html/blog/src/test.md @@ -0,0 +1,3 @@ +# test + +test testing lol diff --git a/html/entries/test.html b/html/entries/test.html new file mode 100644 index 0000000..cf4cbac --- /dev/null +++ b/html/entries/test.html @@ -0,0 +1,11 @@ + + + + + test + + +

test

+

hi test haha

+ + diff --git a/html/entries/welcome.html b/html/entries/welcome.html new file mode 100644 index 0000000..666cc01 --- /dev/null +++ b/html/entries/welcome.html @@ -0,0 +1,46 @@ + + + + + + + davidovski.xyz + + +
+
+ davidovski.xyz +
+ +
+ +
+

welcome to my site

+
+
+ %entries% +
+
+ + + diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..4421c62 --- /dev/null +++ b/html/index.html @@ -0,0 +1,53 @@ + + + + + + + davidovski.xyz + + +
+
+ davidovski.xyz +
+ +
+ +
+

welcome to my site

+
+
+
+
Sun, 08 Aug 2021 04:23:07 🔗
+

welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things.

+

originally i was going to make this blog on b.davidovski.xyz using nanoblogger (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: kblg. Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?)

+

anyway thats all for now, cya

+

~davidovski

+
+ +
+
+ + + diff --git a/html/mononoki.woff b/html/mononoki.woff new file mode 100644 index 0000000..939ec2a Binary files /dev/null and b/html/mononoki.woff differ diff --git a/html/rss.xml b/html/rss.xml new file mode 100644 index 0000000..42c251f --- /dev/null +++ b/html/rss.xml @@ -0,0 +1,19 @@ + + + + + davidovski + https://davidovski.xyz + davidovski's site + + welcome + https://davidovski.xyz/https://davidovski.xyz/entries/welcome.html + Sun, 08 Aug 2021 04:23:07 + welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things.

+

originally i was going to make this blog on b.davidovski.xyz using nanoblogger (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: kblg. Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?)

+

anyway thats all for now, cya

+

~davidovski

]]>
+
+ +
+
diff --git a/html/src/welcome.md b/html/src/welcome.md new file mode 100644 index 0000000..5c8500c --- /dev/null +++ b/html/src/welcome.md @@ -0,0 +1,7 @@ +welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things. + +originally i was going to make this blog on [b.davidovski.xyz](https://b.davidovski.xyz) using [nanoblogger](http://nanoblogger.sourceforge.net/) (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: [kblg](https://github.com/davidovski/kblg/). Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?) + +anyway thats all for now, cya + +~davidovski diff --git a/html/style.css b/html/style.css new file mode 100644 index 0000000..4221417 --- /dev/null +++ b/html/style.css @@ -0,0 +1,83 @@ +:root { + --fg: #f58F44; + --black: #707880; + --red: #cc6666; + --green: #b5bd68; + --yellow: #f0c674; + --blue: #5f819d; + --magenta: #b294bb; + --cyan: #b4d6d1; + --white: #c5c8c6; + --bg: #191919; + --line: 2px; +} + + +@font-face { + font-family: mononoki; + src: url(mononoki.woff); +} + +body { + background-color: var(--bg); + color: var(--fg); + font-family: mononoki; + font-size: 16px +} + +a { + color: var(--blue); + text-decoration: none; +} + +.main { + margin-top: 0; + margin-bottom: 0; + margin-left: 20%; + margin-right: 20%; + + padding: 2%; + height: 100%; + + border-left: var(--line) solid var(--fg); + border-right: var(--line) solid var(--fg); + border-bottom: var(--line) solid var(--fg); +} + +.header { + text-align: center; +} + +.links { + text-align: center justify; + text-justify: inter-word; + #white-space: nowrap; +} + +hr { + width: 100%; + border: 0; + border-bottom: var(--line) solid var(--fg); +} +.title { + font-size: 40px; + color: var(--fg); +} +.small { + font-size: 9px; + padding: 0; + color: var(--black); +} + +a.red { + color: --var(red); +} + +a.green { + color: --var(green); +} + +a.blue { + color: --var(blue); +} + diff --git a/new.sh b/new.sh new file mode 100755 index 0000000..9fce8a3 --- /dev/null +++ b/new.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +EDITOR=nvim +TEMPFILE=/tmp/blog_entry.md + +$EDITOR $TEMPFILE + +NAME=src/$(head -1 $TEMPFILE | cut -d" " -f2-).md + +cp $TEMPFILE "$NAME" +rm $TEMPFILE + +./sync.sh diff --git a/src/welcome.md b/src/welcome.md new file mode 100644 index 0000000..5c8500c --- /dev/null +++ b/src/welcome.md @@ -0,0 +1,7 @@ +welcome. i decided to turn this wepage into blog-style site... i havent got a topic or anything, so expect either: quality tutorials and very interesting techy things; or just random shitposts or rambles about things. + +originally i was going to make this blog on [b.davidovski.xyz](https://b.davidovski.xyz) using [nanoblogger](http://nanoblogger.sourceforge.net/) (you might be able to still see the start of that) but nb itself seemed quite dead, and i couldn't really be asked to customise it all myself. So i made my own script to generate this static site: [kblg](https://github.com/davidovski/kblg/). Right now its probably just the bare minimum needed for this, but I am planning to add more things to it as I go along (including rss, if anyone would be interested?) + +anyway thats all for now, cya + +~davidovski diff --git a/sync.sh b/sync.sh new file mode 100755 index 0000000..a161596 --- /dev/null +++ b/sync.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +cp templates/index.html templates/page.html + +python build.py +rsync -Lta --no-perms --no-owner --no-group --delete --exclude=sync.sh -vz -e ssh ./html/ oracle:/srv/davidovski/html + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..666cc01 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,46 @@ + + + + + + + davidovski.xyz + + +
+
+ davidovski.xyz +
+ +
+ +
+

welcome to my site

+
+
+ %entries% +
+
+ + + diff --git a/templates/item.xml b/templates/item.xml new file mode 100644 index 0000000..031cd35 --- /dev/null +++ b/templates/item.xml @@ -0,0 +1,6 @@ + + %name% + https://davidovski.xyz/%url% + %date% + + diff --git a/templates/page.html b/templates/page.html new file mode 100644 index 0000000..666cc01 --- /dev/null +++ b/templates/page.html @@ -0,0 +1,46 @@ + + + + + + + davidovski.xyz + + +
+
+ davidovski.xyz +
+ +
+ +
+

welcome to my site

+
+
+ %entries% +
+
+ + + diff --git a/templates/rss.xml b/templates/rss.xml new file mode 100644 index 0000000..58e206d --- /dev/null +++ b/templates/rss.xml @@ -0,0 +1,10 @@ + + + + + davidovski + https://davidovski.xyz + davidovski's site + %items% + + diff --git a/templates/summary.html b/templates/summary.html new file mode 100644 index 0000000..9f226af --- /dev/null +++ b/templates/summary.html @@ -0,0 +1,4 @@ +
+
%date% 🔗
+ %content% +
-- cgit v1.2.1