overhaul a lot of stuff

- added lref feature which links to files in the knowledge base without
  having to add ten million "../../../"
- instructions changed so that now you can link to
  "/templates/template.typ" without having to add ten million
  "../../../" to the path
This commit is contained in:
dogeystamp 2023-07-10 13:01:07 -04:00
parent 7853f1e5db
commit 99fd8e3788
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
7 changed files with 54 additions and 9 deletions

View File

@ -15,14 +15,36 @@ docs/
└── ...
```
Personally, I set up templates as a git submodule, and docs as another git repo.
## Installation
Set up `docs/` as a git repo.
mkdir docs
cd docs
git init
Add `templates/` as a submodule.
git submodule add https://github.com/dogeystamp/typst-templates templates
Set the environment variable `TYPST_ROOT` to `docs/` in `.bashrc`, `.profile` or equivalent.
Otherwise, templates won't be able to render due to security policy.
.profile
--------
export TYPST_ROOT="$HOME/docs"
Create a settings file in `docs/`:
templates/gensettings.sh settings.yml
## Example usage
Example usage (this is test.typ in the above tree:)
```typ
#import "../templates/problems.typ": template, source_code, status
#import "/templates/problems.typ": template, source_code, status
#show: template.with(
title: "CCC '22 J1 - Cupcake Party",
problem_url: "https://dmoj.ca/problem/cc22j1",

View File

@ -1,6 +1,6 @@
// templates for compsci notes
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
#import "compsci.typ": source_code
#let template(

View File

@ -1,6 +1,6 @@
// general document
#import "main.typ": gen_title, gen_authors, doc_template
#import "main.typ": gen_title, gen_authors, doc_template, lref
#let template(
title: none,

13
gensettings.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
PROGNAME=$(basename "$0")
if [ -z "$TYPST_ROOT" ]; then
echo "$PROGNAME: "'Please set $TYPST_ROOT.'
exit 1
fi
cat <<EOF > $1
prefix: "$TYPST_ROOT"
me: "$USER"
EOF

View File

@ -6,12 +6,22 @@
#let normal-size = 12pt
#let large-size = 12pt
#let me = "dogeystamp"
#let font = "IBM Plex Sans"
#let heading_font = "IBM Plex Sans"
#let mono_font = "DejaVu Sans Mono"
#let settings = yaml("/settings.yml")
// reference based on TYPST_ROOT
// use paths like "/problems/problem.pdf"
// which will translate to "/home/user/docs/problems/problem.pdf"
#let lref(
url,
text
) = {
return link(settings.prefix + url, text)
}
#let gen_title(
title: none,
) = {
@ -28,7 +38,7 @@
if authors == none {
authors = (
(
name: me,
name: settings.me,
),
)
}

View File

@ -1,6 +1,6 @@
// templates for compsci problem documents outside of contests
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
#import "compsci.typ": source_code, status
#let template(

View File

@ -1,6 +1,6 @@
// templates for online lecture notes
#import "main.typ": gen_title, gen_authors, doc_template, mono_font
#import "main.typ": gen_title, gen_authors, doc_template, mono_font, lref
#let template(
title: none,