initial commit

This commit is contained in:
davidovski 2021-08-26 04:15:22 +01:00
commit daaf7d4350
24 changed files with 555 additions and 0 deletions

107
build.py Normal file
View File

@ -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()

7
const.py Normal file
View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

39
html/blog/index.html Normal file
View File

@ -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>

3
html/blog/src/blarg.md Normal file
View File

@ -0,0 +1,3 @@
# blarg
blarg blarg test haha

View File

@ -0,0 +1,5 @@
# test my blog
this is an entry woooooooooooow

3
html/blog/src/test.md Normal file
View File

@ -0,0 +1,3 @@
# test
test testing lol

11
html/entries/test.html Normal file
View File

@ -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>

46
html/entries/welcome.html Normal file
View File

@ -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>

53
html/index.html Normal file
View File

@ -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>

BIN
html/mononoki.woff Normal file

Binary file not shown.

19
html/rss.xml Normal file
View File

@ -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>

7
html/src/welcome.md Normal file
View File

@ -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

83
html/style.css Normal file
View File

@ -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);
}

13
new.sh Executable file
View File

@ -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

7
src/welcome.md Normal file
View File

@ -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

7
sync.sh Executable file
View File

@ -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

46
templates/index.html Normal file
View File

@ -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>

6
templates/item.xml Normal file
View File

@ -0,0 +1,6 @@
<item>
<title>%name%</title>
<link>https://davidovski.xyz/%url%</link>
<pubDate>%date%</pubDate>
<description><![CDATA[%content%]]></description>
</item>

46
templates/page.html Normal file
View File

@ -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>

10
templates/rss.xml Normal file
View File

@ -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>

4
templates/summary.html Normal file
View File

@ -0,0 +1,4 @@
<div class="entry">
<div class="small">%date% <a href="%url%">🔗</a></div>
%content%
</div>