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("
", "

")\ - .replace("

", "

")\ - .replace("
", "
")\ - .replace("
", "")\ - .replace("

", "

")\ - .replace("
", "")\ - .replace("

", "

")\ - .replace("

", "")\ - .replace("

", "

")\ - .replace("

", "")\ - .replace("

", "

")\ - .replace("

", "")\ - -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") - - 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"{s}") - 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"

This repo has been compiled for web view on {date} and may not be the latest version

" - - for root, dirs, files in os.walk(path): - filename = "/".join(root.split("/")[1:]) - index_content = "
" - - 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 += "
" - - 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 old mode 100644 new mode 100755 similarity index 99% rename from src/git_compile.md rename to entries/git_compile.html index 05176c0..48619f6 --- 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 old mode 100644 new mode 100755 similarity index 98% rename from src/librex.md rename to entries/librex.html index aec86a2..c78c2cd --- 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 old mode 100644 new mode 100755 similarity index 99% rename from src/pci_passthrough.md rename to entries/pci_passthrough.html index 75f169e..942c2b4 --- 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 old mode 100644 new mode 100755 similarity index 99% rename from src/ssh_forwarding.md rename to entries/ssh_forwarding.html index 863c97f..d068f54 --- 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 old mode 100644 new mode 100755 similarity index 98% rename from src/welcome.md rename to entries/welcome.html index c9bf751..5d34602 --- 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 old mode 100644 new mode 100755 similarity index 74% rename from gif.py rename to images/gif.py index 827f150..26e8408 --- 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) - -make("dist/images/bg.gif", colors) -make("dist/images/remotecontrol.gif", colors2, inp="images/remotecontrol-small.png") + frames[0].save(sys.stdout, mode="P", format="GIF", append_images=frames[1:], save_all=True, duration=100, loop=0) + + +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 +
+
+ +

Hi, I'm david and this is my website.

+ +

if you want to contact me, you can message me on matrix @ix:davidovski.xyz.

+
+ +
+ +
+
+ +EOF + +cat << EOF +
+

blog posts

+ + +
+EOF diff --git a/resources/mononoki.woff b/mononoki.woff similarity index 100% rename from resources/mononoki.woff rename to mononoki.woff diff --git a/new.sh b/new.sh index 9fce8a3..3a05034 100755 --- a/new.sh +++ b/new.sh @@ -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 old mode 100644 new mode 100755 similarity index 89% rename from templates/page.html rename to page.sh index a8a3e97..69db1fb --- 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 @@ -13,8 +17,6 @@

- %content% +EOF + +[ -z "$1" ] || /bin/sh $* + +cat << EOF +EOF diff --git a/rss.xml b/rss.xml new file mode 100755 index 0000000..d2ec426 --- /dev/null +++ b/rss.xml @@ -0,0 +1,33 @@ +#!/bin/sh + +cat << EOF + + + + + davidovski + https://davidovski.xyz + davidovski's site +EOF + +for entry in entries/*.html; do + title="$(grep '^# ' $entry)" + title=${title#\# } + + printf "\n" + printf "%s\n" "${title}" + printf "%s\n" "http://davidovski.xyz/$entry" + printf "%s\n" "$(stat -c %z "$entry")" + + + printf "\n" + + done + + +cat << EOF + + +EOF diff --git a/resources/style.css b/style.css similarity index 100% rename from resources/style.css rename to 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 @@ - -
-
- -

Hi, I'm david and this is my website.

-

This site is still under construction... permanently. So expect it to look better (or worse) in the future.

- -

if you want to contact me, you can message me on matrix @iksv:monero.social.

-
- -
- -
-
- -
-

blog posts

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

%filename%

- -

%commit%

- -%content% - -

Clone this repo: git clone %url%

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 @@ - - %name% - %url% - %date% - - 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 @@ - - - - - davidovski - https://davidovski.xyz - davidovski's site - %items% - - 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 @@ -

  • - -
    %date%
    - %title% -
    -