back to the 90s

This commit is contained in:
relt-1
2023-09-23 13:47:00 +02:00
parent 7e322971dd
commit bcb3d037d9
7 changed files with 160 additions and 51 deletions

View File

@@ -1,51 +0,0 @@
# Sample workflow for building and deploying a Jekyll site to GitHub Pages
name: Deploy Jekyll with GitHub Pages dependencies preinstalled
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Build with Jekyll
uses: actions/jekyll-build-pages@v1
with:
source: ./
destination: ./_site
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

37
__main__.py Normal file
View File

@@ -0,0 +1,37 @@
import markdown2
import sys
import os
import re
mark = markdown2.Markdown()
src = os.path.dirname(os.path.realpath(__file__))+"/src/"
dst = os.path.dirname(os.path.realpath(__file__))+"/dst/"
with open("template.html","r") as f:
template = f.read()
documentlist = []
namelist = []
for root, subdirs, files in os.walk(src):
for file in files:
fpath = os.path.join(root, file)
with open(fpath,"r") as f:
rawmarkdown = f.read()
if(rawmarkdown[0:2] != "# "):
raise SyntaxError(".md file must begin with a # marked title!")
documentlist.append(fpath[len(src):].replace(".md",".html").replace("\\","/"))
namelist.append(rawmarkdown[2:].split("\n",1)[0])
template = template.replace("@DOCUMENTLIST",str(documentlist)).replace("@NAMELIST",str(namelist))
for root, subdirs, files in os.walk(src):
if(not os.path.exists(dst+root[len(src):])):
os.mkdir(dst+root[len(src):])
for file in files:
fpath = os.path.join(root, file)
with open(fpath,"r") as f:
with open(dst+fpath[len(src):].replace(".md",".html"), "w") as r:
converted = mark.convert(f.read())
links = re.findall(r'\[\[.+\]\]', converted)
for link in links:
converted = converted.replace(link, "<a href=\""+link[2:-2]+".html\">"+link[2:-2].split("/")[-1]+"</a>")
r.write(template.replace("@CONTENT",converted))

40
dst/folder/other.html Normal file
View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<script>
const documentlist = ['index.html', 'folder/other.html']
const namelist = ['test', 'Other']
function updateSearch() {
searchtext = document.getElementById("searchbox").value.toLowerCase();
var res = [];
var searchresults = document.getElementById("searchresults")
searchresults.innerHTML = ""
if(searchtext === "")
return;
for (var i = 0; i < namelist.length; i++)
{
if(!namelist[i].toLowerCase().includes(searchtext)) continue;
var searchelement = document.createElement("li");
var link = document.createElement("a");
searchelement.appendChild(link);
link.setAttribute("href", documentlist[i]);
link.innerHTML = namelist[i];
searchresults.appendChild(searchelement);
}
}
</script>
<div style="position:fixed; display:block; top: 0px; left: 0px; height:100%; width:200px;border-color: black; border-width: 1px; border-style:solid;">
<input type="text" placeholder="search..." autocomplete="off" id="searchbox" oninput="updateSearch();" style="width:192px;">
<nav>
<ul id="searchresults">
</ul>
</nav>
</div>
<div style="margin-left:200px;">
<h1>Other</h1>
<h2>hi</h2>
</div>

40
dst/index.html Normal file
View File

@@ -0,0 +1,40 @@
<!DOCTYPE html>
<script>
const documentlist = ['index.html', 'folder/other.html']
const namelist = ['test', 'Other']
function updateSearch() {
searchtext = document.getElementById("searchbox").value.toLowerCase();
var res = [];
var searchresults = document.getElementById("searchresults")
searchresults.innerHTML = ""
if(searchtext === "")
return;
for (var i = 0; i < namelist.length; i++)
{
if(!namelist[i].toLowerCase().includes(searchtext)) continue;
var searchelement = document.createElement("li");
var link = document.createElement("a");
searchelement.appendChild(link);
link.setAttribute("href", documentlist[i]);
link.innerHTML = namelist[i];
searchresults.appendChild(searchelement);
}
}
</script>
<div style="position:fixed; display:block; top: 0px; left: 0px; height:100%; width:200px;border-color: black; border-width: 1px; border-style:solid;">
<input type="text" placeholder="search..." autocomplete="off" id="searchbox" oninput="updateSearch();" style="width:192px;">
<nav>
<ul id="searchresults">
</ul>
</nav>
</div>
<div style="margin-left:200px;">
<h1>test</h1>
<p>this is the <a href="folder/other.html">other</a> link</p>
</div>

3
src/folder/other.md Normal file
View File

@@ -0,0 +1,3 @@
# Other
## hi

3
src/index.md Normal file
View File

@@ -0,0 +1,3 @@
# test
this is the [[folder/other]] link

37
template.html Normal file
View File

@@ -0,0 +1,37 @@
<!DOCTYPE html>
<script>
const documentlist = @DOCUMENTLIST
const namelist = @NAMELIST
function updateSearch() {
searchtext = document.getElementById("searchbox").value.toLowerCase();
var res = [];
var searchresults = document.getElementById("searchresults")
searchresults.innerHTML = ""
if(searchtext === "")
return;
for (var i = 0; i < namelist.length; i++)
{
if(!namelist[i].toLowerCase().includes(searchtext)) continue;
var searchelement = document.createElement("li");
var link = document.createElement("a");
searchelement.appendChild(link);
link.setAttribute("href", documentlist[i]);
link.innerHTML = namelist[i];
searchresults.appendChild(searchelement);
}
}
</script>
<div style="position:fixed; display:block; top: 0px; left: 0px; height:100%; width:200px;border-color: black; border-width: 1px; border-style:solid;">
<input type="text" placeholder="search..." autocomplete="off" id="searchbox" oninput="updateSearch();" style="width:192px;">
<nav>
<ul id="searchresults">
</ul>
</nav>
</div>
<div style="margin-left:200px;">
@CONTENT
</div>