diff options
author | davidovski <david@davidovski.xyz> | 2021-08-26 04:15:22 +0100 |
---|---|---|
committer | davidovski <david@sendula.com> | 2021-08-26 04:15:22 +0100 |
commit | 2e4002e5ad2f495088da627bd7ee8a216eb4e7b1 (patch) | |
tree | d5fb9fe514eb04277eeb25bc000c311fef156bc4 |
initial commit
-rw-r--r-- | build.py | 107 | ||||
-rw-r--r-- | const.py | 7 | ||||
-rw-r--r-- | html/blog/entries/blarg.html | 11 | ||||
-rw-r--r-- | html/blog/entries/test my blog.html | 11 | ||||
-rw-r--r-- | html/blog/entries/test.html | 11 | ||||
-rw-r--r-- | html/blog/index.html | 39 | ||||
-rw-r--r-- | html/blog/src/blarg.md | 3 | ||||
-rw-r--r-- | html/blog/src/test my blog.md | 5 | ||||
-rw-r--r-- | html/blog/src/test.md | 3 | ||||
-rw-r--r-- | html/entries/test.html | 11 | ||||
-rw-r--r-- | html/entries/welcome.html | 46 | ||||
-rw-r--r-- | html/index.html | 53 | ||||
-rw-r--r-- | html/mononoki.woff | bin | 0 -> 42208 bytes | |||
-rw-r--r-- | html/rss.xml | 19 | ||||
-rw-r--r-- | html/src/welcome.md | 7 | ||||
-rw-r--r-- | html/style.css | 83 | ||||
-rwxr-xr-x | new.sh | 13 | ||||
-rw-r--r-- | src/welcome.md | 7 | ||||
-rwxr-xr-x | sync.sh | 7 | ||||
-rw-r--r-- | templates/index.html | 46 | ||||
-rw-r--r-- | templates/item.xml | 6 | ||||
-rw-r--r-- | templates/page.html | 46 | ||||
-rw-r--r-- | templates/rss.xml | 10 | ||||
-rw-r--r-- | templates/summary.html | 4 |
24 files changed, 555 insertions, 0 deletions
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 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>blarg</title> +</head> +<body> + <h1>blarg</h1> +<p>blarg blarg test haha</p> +</body> +</html> 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 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>test my blog</title> +</head> +<body> + <h1>test my blog</h1> +<p>this is an entry woooooooooooow</p> +</body> +</html> 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 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>test</title> +</head> +<body> + <h1>test</h1> +<p>test testing lol</p> +</body> +</html> 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 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title></title> +</head> +<body> + <h1>blog test</h1> + <div class="entries"> + <div> + <h1>test</h1> +<p>test testing lol</p> + + ... + <a href="www.example.com/entries/test.html">more</a> + <p>Date: Sun, 08 Aug 2021</p> +</div> + +<div> + <h1>blarg</h1> +<p>blarg blarg test haha</p> + + ... + <a href="www.example.com/entries/blarg.html">more</a> + <p>Date: Sun, 08 Aug 2021</p> +</div> + +<div> + <h1>test my blog</h1> +<p>this is an entry woooooooooooow</p> + + ... + <a href="www.example.com/entries/test my blog.html">more</a> + <p>Date: Sun, 08 Aug 2021</p> +</div> + + </div> +</body> +</html> 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 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="UTF-8"> + <title>test</title> +</head> +<body> + <h1>test</h1> +<p>hi test haha</p> +</body> +</html> 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 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + + <link rel="stylesheet" href="/style.css"> + <title>davidovski.xyz</title> + </head> + <body> + <div class="main"> + <div class="header"> + <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a> + <hr> + <div class="links"> + <a href="https://github.com/davidovski">git</a> + | + <a href="https://osu.ppy.sh/users/11140827">osu</a> + | + <a href="https://myanimelist.net/animelist/davidovski">mal</a> + | + <a href="https://orangepeel.pw/">op</a> + || + <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a> + || + <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a> + | + <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a> + | + <a style="color: var(--green)" href="/rss.xml">rss</a> + </div> + </div> + + <hr> + <p>welcome to my site</p> + <hr> + <div class="entries"> + %entries% + </div> + </div> + + </body> +</html> 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 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + + <link rel="stylesheet" href="/style.css"> + <title>davidovski.xyz</title> + </head> + <body> + <div class="main"> + <div class="header"> + <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a> + <hr> + <div class="links"> + <a href="https://github.com/davidovski">git</a> + | + <a href="https://osu.ppy.sh/users/11140827">osu</a> + | + <a href="https://myanimelist.net/animelist/davidovski">mal</a> + | + <a href="https://orangepeel.pw/">op</a> + || + <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a> + || + <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a> + | + <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a> + | + <a style="color: var(--green)" href="/rss.xml">rss</a> + </div> + </div> + + <hr> + <p>welcome to my site</p> + <hr> + <div class="entries"> + <div class="entry"> + <div class="small">Sun, 08 Aug 2021 04:23:07 <a href="https://davidovski.xyz/entries/welcome.html">🔗</a></div> + <p>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.</p> +<p>originally i was going to make this blog on <a href="https://b.davidovski.xyz">b.davidovski.xyz</a> using <a href="http://nanoblogger.sourceforge.net/">nanoblogger</a> (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: <a href="https://github.com/davidovski/kblg/">kblg</a>. 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?)</p> +<p>anyway thats all for now, cya</p> +<p>~davidovski</p> +</div> + + </div> + </div> + + </body> +</html> diff --git a/html/mononoki.woff b/html/mononoki.woff Binary files differnew file mode 100644 index 0000000..939ec2a --- /dev/null +++ b/html/mononoki.woff 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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<rss version="2.0"> + +<channel> + <title>davidovski</title> + <link>https://davidovski.xyz</link> + <description>davidovski's site</description> + <item> + <title>welcome</title> + <link>https://davidovski.xyz/https://davidovski.xyz/entries/welcome.html</link> + <pubDate>Sun, 08 Aug 2021 04:23:07</pubDate> + <description><![CDATA[<p>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.</p> +<p>originally i was going to make this blog on <a href="https://b.davidovski.xyz">b.davidovski.xyz</a> using <a href="http://nanoblogger.sourceforge.net/">nanoblogger</a> (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: <a href="https://github.com/davidovski/kblg/">kblg</a>. 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?)</p> +<p>anyway thats all for now, cya</p> +<p>~davidovski</p>]]></description> +</item> + +</channel> +</rss> 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); +} + @@ -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 @@ -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 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + + <link rel="stylesheet" href="/style.css"> + <title>davidovski.xyz</title> + </head> + <body> + <div class="main"> + <div class="header"> + <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a> + <hr> + <div class="links"> + <a href="https://github.com/davidovski">git</a> + | + <a href="https://osu.ppy.sh/users/11140827">osu</a> + | + <a href="https://myanimelist.net/animelist/davidovski">mal</a> + | + <a href="https://orangepeel.pw/">op</a> + || + <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a> + || + <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a> + | + <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a> + | + <a style="color: var(--green)" href="/rss.xml">rss</a> + </div> + </div> + + <hr> + <p>welcome to my site</p> + <hr> + <div class="entries"> + %entries% + </div> + </div> + + </body> +</html> 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 @@ +<item> + <title>%name%</title> + <link>https://davidovski.xyz/%url%</link> + <pubDate>%date%</pubDate> + <description><![CDATA[%content%]]></description> +</item> 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 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> + + <link rel="stylesheet" href="/style.css"> + <title>davidovski.xyz</title> + </head> + <body> + <div class="main"> + <div class="header"> + <a href="https://davidovski.xyz/"<h1 class="title">davidovski.xyz</h1></a> + <hr> + <div class="links"> + <a href="https://github.com/davidovski">git</a> + | + <a href="https://osu.ppy.sh/users/11140827">osu</a> + | + <a href="https://myanimelist.net/animelist/davidovski">mal</a> + | + <a href="https://orangepeel.pw/">op</a> + || + <a style="color: var(--red);" href="https://davidovski.xyz/m">m</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/f">f</a> + | + <a style="color: var(--red);" href="https://davidovski.xyz/s">s</a> + || + <a style="color: var(--green)" href="http://chat.davidovski.xyz/">chat</a> + | + <a style="color: var(--green)" href="mailto:david@davidovski.xyz">mail</a> + | + <a style="color: var(--green)" href="/rss.xml">rss</a> + </div> + </div> + + <hr> + <p>welcome to my site</p> + <hr> + <div class="entries"> + %entries% + </div> + </div> + + </body> +</html> 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 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<rss version="2.0"> + +<channel> + <title>davidovski</title> + <link>https://davidovski.xyz</link> + <description>davidovski's site</description> + %items% +</channel> +</rss> 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 @@ +<div class="entry"> + <div class="small">%date% <a href="%url%">🔗</a></div> + %content% +</div> |