diff options
-rw-r--r-- | build.py | 290 | ||||
-rwxr-xr-x | build.sh | 4 | ||||
-rw-r--r-- | const.py | 8 | ||||
-rwxr-xr-x | entries/entries.sh | 5 | ||||
-rwxr-xr-x[-rw-r--r--] | entries/git_compile.html (renamed from src/git_compile.md) | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | entries/librex.html (renamed from src/librex.md) | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | entries/pci_passthrough.html (renamed from src/pci_passthrough.md) | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | entries/ssh_forwarding.html (renamed from src/ssh_forwarding.md) | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | entries/welcome.html (renamed from src/welcome.md) | 2 | ||||
-rw-r--r-- | git_repos.txt | 10 | ||||
-rwxr-xr-x | images/bg.gif | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | images/gif.py (renamed from gif.py) | 24 | ||||
-rwxr-xr-x | images/remotecontrol.gif | 2 | ||||
-rwxr-xr-x | index.html | 43 | ||||
-rw-r--r-- | mononoki.woff (renamed from resources/mononoki.woff) | bin | 42208 -> 42208 bytes | |||
-rwxr-xr-x | new.sh | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | page.sh (renamed from templates/page.html) | 13 | ||||
-rwxr-xr-x | rss.xml | 33 | ||||
-rw-r--r-- | style.css (renamed from resources/style.css) | 0 | ||||
-rwxr-xr-x | sync.sh | 5 | ||||
-rw-r--r-- | templates/about.html | 20 | ||||
-rw-r--r-- | templates/file.html | 7 | ||||
-rw-r--r-- | templates/item.xml | 6 | ||||
-rw-r--r-- | templates/rss.xml | 10 | ||||
-rw-r--r-- | templates/summary.html | 6 |
25 files changed, 121 insertions, 387 deletions
diff --git a/build.py b/build.py deleted file mode 100644 index bed1ac7..0000000 --- a/build.py +++ /dev/null @@ -1,290 +0,0 @@ -import markdown -import os -import time -import shutil -import subprocess -from html import escape - - -from const import * - -def getTemplateHTML(name): - html = "" - with open(os.path.join(templates, name), "r") as file: - html = file.read(); - return html - -def lowerHeadings(html): - # This is a dumb lol - return html.replace("<h6>", "<p>")\ - .replace("</h6>", "</p>")\ - .replace("<h5>", "<h6>")\ - .replace("</h5>", "</h6>")\ - .replace("<h4>", "<h5>")\ - .replace("</h4>", "</h5>")\ - .replace("<h3>", "<h4>")\ - .replace("</h3>", "</h4>")\ - .replace("<h2>", "<h3>")\ - .replace("</h2>", "</h3>")\ - .replace("<h1>", "<h2>")\ - .replace("</h1>", "</h2>")\ - -def listPages(): - return [ - (lambda path: - (lambda content: - (lambda timestamp: - (lambda name: { - "source_file" : path, - "source_content" : content, - "html" : markdown.markdown("\n".join(content.split("\n...\n"))), - "title" : content.split("\n")[0].replace("# ", ""), - "summary" : lowerHeadings(markdown.markdown(content.split("\n...\n")[0])), - "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_mtime) - )(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") - try: - shutil.rmtree(os.path.join(dist, "src")) - except: - pass - try: - shutil.rmtree(os.path.join(dist, "images")) - except: - pass - try: - shutil.copytree(source, os.path.join(dist, "src")) - except: - pass - try: - shutil.copytree(images, os.path.join(dist, "images")) - except: - pass - - pages = listPages() - - pages = sorted(pages, key=lambda p: p["timestamp"]) - - summary_templ = getTemplateHTML("summary.html") - - summariesHTML = getTemplateHTML("about.html").replace("%posts%", "\n<ul>\n"+ "\n".join( - [ - formatEntry(summary_templ, page) - .replace( - "%content%", - page["summary"] + (f"<a href={page['url']}>read more...</a>" if len(page["source_content"].split("\n...\n")) > 1 else "") - ).replace("%title%", page["title"]) - - for page in pages - ][: : -1] - ) + "</ul>") - - 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("page.html") - - with open(os.path.join(dist, "index.html"), "w") as index: - index.write( - index_templ.replace("%content%", 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 - ][: : -1] - ) - - with open(os.path.join(dist, "rss.xml"), "w") as index: - index.write( - rss_templ.replace("%items%", itemsXML) - ) - - for f in os.listdir(resources): - shutil.copy(os.path.join(resources, f), dist) - - print(f"built in {len(pages)} pages") - - -def get_repos(): - repos = [] - if os.path.exists("git_repos.txt"): - with open("git_repos.txt", "r") as file: - repos = [l for l in file.readlines() if l.startswith("http")] - return repos - -def list_files(path): - files = [] - dirlist = [path] - - while len(dirlist) > 0: - for (dirpath, dirnames, filenames) in os.walk(dirlist.pop()): - dirlist.extend(dirnames) - files.extend(map(lambda n: os.path.join(*n), zip([dirpath] * len(filenames), filenames))) - print(len(files)) - - return files - -def linkify_path(path): - output = [] - full = "/" - for s in path.split("/"): - full += s + "/" - output.append(f"<a href='{full}'>{s}</a>") - return "/" + "/".join(output) - - - -def format_file(page_templ, content, v): - return page_templ.replace("%title%", v["name"])\ - .replace("%up%", v["above"])\ - .replace("%filename%", linkify_path(v["filename"]))\ - .replace("%commit%", str(v["commit"]))\ - .replace("%url%", str(v["url"]))\ - .replace("%content%", content) - - -def traverse_repo(path, name, commit, url): - page_templ = getTemplateHTML("page.html") - page_templ = page_templ.replace("%content%", getTemplateHTML("file.html")) - - date = time.strftime(date_format, time.localtime()) - footer = f"<p class='small'>This repo has been compiled for web view on <b>{date}</b> and may not be the latest version</p>" - - for root, dirs, files in os.walk(path): - filename = "/".join(root.split("/")[1:]) - index_content = "<ul>" - - index_content += f"<a href='../'><li>../</li></a>" - for d in dirs: - if d.startswith("."): - shutil.rmtree(os.path.join(root, d)) - else: - index_content += f"<a href='{d}'><li>{d}/</li></a>" - - for file_name in files: - if file_name.startswith("."): - os.remove(f) - else: - f = os.path.join(root, file_name) - - try: - with open(f, "r") as file: - content = file.read() - - if f.endswith(".md"): - content = markdown.markdown(content) - content = content.replace("\"/", "\"/" + filename + "/") - else: - content = "<p><pre><code>" + escape(content) + "</code></p></pre>" - - content += footer - content = format_file(page_templ, content, { - "name": name, - "commit": commit, - "url": url, - "filename": "/".join(f.split("/")[1:]), - "above": "/".join(f.split("/")[1:-1]), - }) - - with open(f + ".html", "w") as file: - file.write(content) - - if file_name != "README.md": - os.remove(f) - - index_content += f"<a href='{file_name}.html'><li>{file_name}</li></a>" - except UnicodeDecodeError: - index_content += f"<a href='{file_name}'><li>{file_name}</li></a>" - - index_content += "</ul><hr>" - - readme = os.path.join(root, "README.md") - if os.path.exists(readme): - with open(readme) as file: - readme_content = markdown.markdown(file.read()) - #massive hack - readme_content = readme_content.replace("\"/", "\"/" + filename + "/") - - index_content += readme_content - - index_content += "<hr>" - - index_content += footer - index_content = format_file(page_templ, index_content, { - "name": name, - "commit": commit, - "url": url, - "filename": filename, - "above": "/".join(root.split("/")[1:-1]), - }) - - with open(os.path.join(root,"index.html"), "w") as file: - file.write(index_content) - -def create_repos(): - try: - shutil.rmtree(os.path.join(dist, "git")) - except: - pass - - git_path = os.path.join(dist, "git") - try: - os.makedirs(git_path) - except: - print("Already have git path") - - for repo in get_repos(): - repo = repo.strip() - print(repo) - name = ".".join(repo.split("/")[-1].split(".")[:-1]) - os.system(f"mkdir -p /tmp/repos/{name} ;\ - cd /tmp/repos/{name} ;\ - git pull || git clone {repo} /tmp/repos/{name}") - - os.system(f"cp -r /tmp/repos/{name} {dist}/git") - - command = subprocess.run(f"cd /tmp/repos/{name} && git log --pretty=format:'%h%x09%an%x09%ad%x09%s' --no-decorate -1", stdout=subprocess.PIPE, shell=True) - - commit = command.stdout.decode() - - traverse_repo(os.path.join(git_path, name), name, commit, repo) - -make() -create_repos() diff --git a/build.sh b/build.sh deleted file mode 100755 index 4abdef5..0000000 --- a/build.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -python build.py -python gif.py - diff --git a/const.py b/const.py deleted file mode 100644 index 6903e96..0000000 --- a/const.py +++ /dev/null @@ -1,8 +0,0 @@ -site_index = "https://davidovski.xyz/" -images = "images" -date_format = "%a, %d %b %Y %H:%M:%S" -source = "src" -templates = "templates" -resources = "resources" -dist = "dist" -summary_max = 10 diff --git a/entries/entries.sh b/entries/entries.sh new file mode 100755 index 0000000..e85c454 --- /dev/null +++ b/entries/entries.sh @@ -0,0 +1,5 @@ +#!../page.sh + +[ -z "$1" ] || { + md2html $1 +} diff --git a/src/git_compile.md b/entries/git_compile.html index 05176c0..48619f6 100644..100755 --- a/src/git_compile.md +++ b/entries/git_compile.html @@ -1,9 +1,9 @@ +#!./entries.sh + # Compiling files in a git repo So I decided to improve the way that that you can access some of the repos that I am hosting on this server, including the code that I use to compile the site itself. I quickly hacked together a bit of code in my existing [build.py](https://davidovski.xyz/git/davidovski/build.py.html) to clone a list of repos and go through and generate a html pages for each of the files in the repo. -... - Although this means that this is only a static view of the repo at any time (needing me to rebuild the site for it to update) I can easily add any git repo to be built into my site, so as you may see, I have added a few repos from my github as well. I tried using cgit, but it just didn't provide exactly what I wanted and I wasn't in the mood to try configuring it to my liking, so I opted for this approach instead. diff --git a/src/librex.md b/entries/librex.html index aec86a2..c78c2cd 100644..100755 --- a/src/librex.md +++ b/entries/librex.html @@ -1,3 +1,5 @@ +#!./entries.sh + # LibreX - a metasearch engine My instance: [search.davidovski.xyz](https://search.davidovski.xyz/) diff --git a/src/pci_passthrough.md b/entries/pci_passthrough.html index 75f169e..942c2b4 100644..100755 --- a/src/pci_passthrough.md +++ b/entries/pci_passthrough.html @@ -1,9 +1,9 @@ +#!./entries.sh + # PCI passthrough with qemu QEMU is a powerful free and open source emulator which when paired with kvm can be used to create almost bare-metal performance virtual machines. In this guide I will be detailing some tips and tricks to configuring a setup on your linux system to allow a PCI device (typically a graphics card) to be passed through to a virtual machine. -... - Countless guides already exist on this topic but they all rely on using virt-manager and other Redhat software, which, depending on your use case, may be completely overkill. This guide assumes that you will not be using the target GPU as a video output on your host machine from boot, so will only work in configurations where you are able to remote connect or where you have **multiple graphics cards**. However the process is mostly similar for single GPU passthrough, with extra steps if you want to bind and unbind display drivers from the host. This is a generic guide written to support any semi-standard Linux distributions, so adapt any instructions as you see fit to your current system. diff --git a/src/ssh_forwarding.md b/entries/ssh_forwarding.html index 863c97f..d068f54 100644..100755 --- a/src/ssh_forwarding.md +++ b/entries/ssh_forwarding.html @@ -1,11 +1,11 @@ +#!./entries.sh + # Permanent SSH Forwarding (Tutorial) Take this situation: you have a cheap (or even free), low-powered remote server and a considerably better homeserver with more storage and power. For certain services that require more power, you'd obviously want to run them on that homeserver. However, what if you don't want to, *or can't*, directly open ports onto your home network, or you if you simply want to keep all of your site to one IP? This is where SSH port forwarding comes in handy: using ssh to forward the open port from a service from your local server to the remote one, where it can be exposed to the rest of the internet. -... - ## SSH Remote Port Forwarding SSH remote port forwarding is built right into ssh itself, and is quite simple: diff --git a/src/welcome.md b/entries/welcome.html index c9bf751..5d34602 100644..100755 --- a/src/welcome.md +++ b/entries/welcome.html @@ -1,3 +1,5 @@ +#!./entries.sh + # welcome welcome. i decided to turn this webpage 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. diff --git a/git_repos.txt b/git_repos.txt deleted file mode 100644 index fcfa3fb..0000000 --- a/git_repos.txt +++ /dev/null @@ -1,10 +0,0 @@ -#https://git.davidovski.xyz/davidovski.git -#https://git.davidovski.xyz/xilinux/xibuild.git -#https://git.davidovski.xyz/xilinux/xipkg.git -#https://git.davidovski.xyz/dot.git -#https://github.com/davidovski/glsl-mandelbrot.git -#https://github.com/davidovski/dungeon-generator.git -#https://github.com/davidovski/chatroom.git -#https://github.com/davidovski/kblg.git -#https://github.com/davidovski/asteriods.git -#https://github.com/davidovski/anyscroll.git diff --git a/images/bg.gif b/images/bg.gif new file mode 100755 index 0000000..044324f --- /dev/null +++ b/images/bg.gif @@ -0,0 +1,2 @@ +#!/bin/sh +./gif.py diff --git a/gif.py b/images/gif.py index 827f150..26e8408 100644..100755 --- a/gif.py +++ b/images/gif.py @@ -1,4 +1,7 @@ +#!/usr/bin/env python import glob +import sys +import os import math import random from PIL import Image @@ -21,14 +24,8 @@ colors = [ color("#191919"), color("#373b41"), ] -colors2 = colors + [ - color("#f58f44") -] -sorted(colors, key=rgb_to_v) -sorted(colors2, key=rgb_to_v) - -def make(filename, colors, inp=None): +def make(colors, inp=None): p = len(colors) w = int(128 / p) * p h = int(128 / p) * p @@ -58,9 +55,16 @@ def make(filename, colors, inp=None): frames.append(image.convert("P")) - frames[0].save(filename, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) + frames[0].save(sys.stdout, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) + -make("dist/images/bg.gif", colors) -make("dist/images/remotecontrol.gif", colors2, inp="images/remotecontrol-small.png") +template = None +if len(sys.argv) > 1 and os.path.exists(sys.argv[1]): + template = sys.argv[1] + colors = colors + [ color("#f58f44") ] + +sorted(colors, key=rgb_to_v) +make(colors, inp=template) +#make("dist/images/remotecontrol.gif", colors2, inp="images/remotecontrol-small.png") diff --git a/images/remotecontrol.gif b/images/remotecontrol.gif new file mode 100755 index 0000000..5e73b92 --- /dev/null +++ b/images/remotecontrol.gif @@ -0,0 +1,2 @@ +#!/bin/sh +./gif.py remotecontrol-small.png diff --git a/index.html b/index.html new file mode 100755 index 0000000..080a484 --- /dev/null +++ b/index.html @@ -0,0 +1,43 @@ +#!./page.sh + +cat << EOF +<div class="grid"> + <div class="about"> + + <p>Hi, I'm david and this is my website.</p> + + <p>if you want to contact me, you can message me on matrix <code>@ix:davidovski.xyz</code>.</p> + </div> + + <div class="image"> + <img src="/images/remotecontrol.gif"> + </div> +</div> + +EOF + +cat << EOF + <div> + <h2>blog posts</h2> + + <ul> +EOF +# list all the files in the directory +for file in entries/*.html; do + title="$(grep '^# ' $file)" + title=${title#\# } + + printf " +<li class=\"entry\"> +<a href=\"%s\"> + <div class=\"small\">%s</div> + <span>%s</span> +</a> +</li> +" "${file%.*}.html" "$(stat -c %z "$file")" "$title" + done + +cat << EOF + </ul> + </div> +EOF diff --git a/resources/mononoki.woff b/mononoki.woff Binary files differindex 939ec2a..939ec2a 100644 --- a/resources/mononoki.woff +++ b/mononoki.woff @@ -5,9 +5,9 @@ TEMPFILE=/tmp/blog_entry.md $EDITOR $TEMPFILE -NAME=src/$(head -1 $TEMPFILE | cut -d" " -f2-).md +NAME=entries/$(head -1 $TEMPFILE | cut -d" " -f2-).html cp $TEMPFILE "$NAME" rm $TEMPFILE -./sync.sh +chmod +x $NAME diff --git a/templates/page.html b/page.sh index a8a3e97..69db1fb 100644..100755 --- a/templates/page.html +++ b/page.sh @@ -1,3 +1,7 @@ +#!/bin/sh +# set a variable to avoid this template being repeated indefinitely + +cat << EOF <!DOCTYPE html> <html lang="en"> <head> @@ -13,8 +17,6 @@ <hr> <div class="links"> <a href="https://davidovski.xyz/git">git</a> - | - <a href="https://orangepeel.pw/">op</a> || <a color="#cc6666" style="color: var(--red);" href="https://davidovski.xyz/m">m</a> | @@ -31,8 +33,13 @@ </div> <hr> - %content% +EOF + +[ -z "$1" ] || /bin/sh $* + +cat << EOF </div> </body> </html> +EOF @@ -0,0 +1,33 @@ +#!/bin/sh + +cat << EOF +<?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> +EOF + +for entry in entries/*.html; do + title="$(grep '^# ' $entry)" + title=${title#\# } + + printf "<item>\n" + printf "<title>%s</title>\n" "${title}" + printf "<link>%s</link>\n" "http://davidovski.xyz/$entry" + printf "<pubDate>%s</pubDate>\n" "$(stat -c %z "$entry")" + + + printf "<description><![CDATA[" + md2html $entry + printf "]]></description>\n</item>" + + done + + +cat << EOF +</channel> +</rss> +EOF diff --git a/resources/style.css b/style.css index 47b7d40..47b7d40 100644 --- a/resources/style.css +++ b/style.css diff --git a/sync.sh b/sync.sh deleted file mode 100755 index 86adc3f..0000000 --- a/sync.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -rsync -Lta --no-perms --no-owner --no-group --delete --exclude=sync.sh -z -e ssh ./dist/ cheetah.remote:/srv/www/davidovski/html -ssh -t cheetah.remote "ln -s /srv/shared/site/* /srv/www/davidovski/html/" -# git push # push after everything to keep it all backed up diff --git a/templates/about.html b/templates/about.html deleted file mode 100644 index e0bc58c..0000000 --- a/templates/about.html +++ /dev/null @@ -1,20 +0,0 @@ - -<div class="grid"> - <div class="about"> - - <p>Hi, I'm david and this is my website.</p> - <p>This site is still under construction... permanently. So expect it to look better (or worse) in the future.</p> - - <p>if you want to contact me, you can message me on matrix <code>@iksv:monero.social</code>.</p> - </div> - - <div class="image"> - <img src="/images/remotecontrol.gif"> - </div> -</div> - -<div> - <h2>blog posts</h2> - %posts% -</div> - diff --git a/templates/file.html b/templates/file.html deleted file mode 100644 index 19048c3..0000000 --- a/templates/file.html +++ /dev/null @@ -1,7 +0,0 @@ -<h1>%filename%</h1> - -<p><code>%commit%</code></p> - -%content% - -<p>Clone this repo: <code>git clone %url%</code><p> diff --git a/templates/item.xml b/templates/item.xml deleted file mode 100644 index 5864b7f..0000000 --- a/templates/item.xml +++ /dev/null @@ -1,6 +0,0 @@ -<item> - <title>%name%</title> - <link>%url%</link> - <pubDate>%date%</pubDate> - <description><![CDATA[%content%]]></description> -</item> diff --git a/templates/rss.xml b/templates/rss.xml deleted file mode 100644 index 58e206d..0000000 --- a/templates/rss.xml +++ /dev/null @@ -1,10 +0,0 @@ -<?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 deleted file mode 100644 index 483763f..0000000 --- a/templates/summary.html +++ /dev/null @@ -1,6 +0,0 @@ -<li class="entry"> -<a href="%url%"> - <div class="small">%date%</div> - <span>%title%</span> -</a> -</li> |