add a knowledgebase feature

This commit is contained in:
stupidcomputer 2024-06-29 15:48:06 -05:00
parent 24bf60f245
commit 9a63464300
9 changed files with 72 additions and 5 deletions

View File

@ -1,10 +1,19 @@
prod: # execute this target on the production server in the nix-shell
rm -fr franklincce/staticfiles
cd franklincce; python3 manage.py collectstatic
sed "s/change_me/$(shell shuf -i1-1000000 -n1)/g" .env.prod.orig > .env.prod
sh gen_kb.sh
sed "s|change_me|$(shell dd if=/dev/urandom bs=1024 count=1|base64)|g" .env.prod.orig > .env.prod
docker-compose -f docker-compose.prod.yml up -d --build
permissions:
permissions: db.sqlite3
chmod -f 660 db.sqlite3
echo "make sure that db.sqlite3 is owned by group users"
echo "make sure that db.sqlite3 is owned by group users"
db.sqlite3:
touch db.sqlite3
make_kb:
sh gen_kb.sh
clean:
rm -fr franklincce/staticfiles
docker-compose -f docker-compose.prod.yml down -v

View File

@ -14,6 +14,7 @@
<nav id="navbar" class="boxed">
<div id="leftnav">
<a href="/explorer">explorer</a>
<a href="/kb">knowledge</a>
</div>
<div id="rightnav">
<a href="/explorer/all">all</a>

10
gen_kb.sh Executable file
View File

@ -0,0 +1,10 @@
files=$(find kb -type f | awk -F'/' '{print $NF}')
IFS='
'
mkdir -p franklincce/staticfiles/kb
for file in $files; do
without_extension=${file%.*}
echo $file, $without_extension
pandoc -s --template=./template.html -f markdown -t html -o "franklincce/staticfiles/kb/$without_extension.html" "kb/$without_extension.md" --lua-filter=links-to-html.lua
done

7
kb/index.md Normal file
View File

@ -0,0 +1,7 @@
---
title: "Franklin CCE Knowledgebase"
---
## Model UN
- [Writing a resolution](./writing-resolution.md)

5
kb/writing-resolution.md Normal file
View File

@ -0,0 +1,5 @@
---
title: "Writing a Resolution"
---
This is a test

4
links-to-html.lua Normal file
View File

@ -0,0 +1,4 @@
function Link(el)
el.target = string.gsub(el.target, "%.md", ".html")
return el
end

View File

@ -16,4 +16,8 @@ server {
location /static/ {
alias /home/app/web/staticfiles/;
}
location /kb {
alias /home/app/web/staticfiles/kb;
}
}

View File

@ -1,4 +1,4 @@
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf ] ++ [pkgs.docker-compose pkgs.gnumake] ;
nativeBuildInputs = with pkgs.python311Packages; [ django pymupdf ] ++ [ pkgs.docker-compose pkgs.gnumake pkgs.pandoc ] ;
}

27
template.html Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="generator" content="pandoc" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
<title>$title$</title>
<link rel="stylesheet" href="/static/style.css">
<link rel="stylesheet" href="/static/tn.css">
</head>
<body>
<nav id="navbar" class="boxed">
<div id="leftnav">
<a href="/explorer">explorer</a>
<a href="/kb">knowledge</a>
</div>
</nav>
<div class="boxed">
<h1>$title$</h1>
$body$
</div>
</body>
</html>