add note template

main
Jean-Marie 'Histausse' Mineau 2024-03-23 02:05:35 +01:00
parent cd3c5dac83
commit 061cbb6a49
Signed by: histausse
GPG Key ID: B66AEEDA9B645AD2
5 changed files with 74 additions and 5 deletions

View File

@ -106,6 +106,12 @@ Parameters can be passed to the template depending on the usage. The `doc_type`
#show: notes-template.with(doc_type: "research_journal", keywords: ("ipsum",))
```
## LICENSE
This template is licensed under AGPLv3 or later, except for the content of the `img` directory, which is proprietary en protected by copyright laws.
If you find the need to use this code under a more permissive license, contact `histausse <at> protonmail.com` and explain your use-case, we may grant you part of the code under another license. (Request for commercial use outside of what is allowed by the AGPL will most likely not be granted: the price to use this code is to keep it free).
## TODO:
- biblio

BIN
img/pains-perdus.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
img/pirat.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 KiB

57
lib.typ
View File

@ -23,8 +23,36 @@
}
}
#let note_header(title: "Notes", ..args) = {
[ = #title ]
#let logos = (
"pirat": image("img/pirat.png", width: 30mm),
"pains-perdus": image("img/pains-perdus.png", width: 25mm),
)
#let note_header(title: [ Notes ], authors: (), date: datetime.today(), logo: none, ..args) = {
align(center, text(size: 20pt, title))
if logo != none {
context {
place(
top+left,
dy: -page.margin*0.8,
dx: -page.margin*0.8,
logos.at(logo)
)
}
}
place(top+right, date.display())
if authors != () {
align(center)[
//By:
#v(16pt, weak: true)
#for author in authors {
author
v(16pt, weak: true)
}
]
}
outline(indent: 2em, fill: none)
}
#let research_journal_header(title: "Research Journal", ..args) = {
@ -45,7 +73,15 @@
v(2em)
}
#let notes-template(title: none, doc_type: none, keywords: (), doc) = {
#let notes-template(
title: none,
doc_type: none,
keywords: (),
authors: none,
date: none,
logo: none,
doc) = {
set document(title: title)
show raw.where(lang: "dot-render"): it => gviz.render-image(it.text)
show raw.where(lang: "digraphLR"): it => gviz.render-image("digraph mygraph { rankdir=\"LR\";" + it.text + "}")
show raw.where(lang: "digraphTB"): it => gviz.render-image("digraph mygraph { rankdir=\"TB\";" + it.text + "}")
@ -65,12 +101,25 @@
}
let args = (:)
for (arg, val) in ("title": title, "keywords": keywords) {
for (arg, val) in (
"title": title,
"keywords": keywords,
"authors": authors,
"date": date,
"logo": logo,
) {
if val != none {
args.insert(arg, val)
}
}
set page(
height: auto,
margin: 25mm,
) if doc_type == "notes"
if doc_type == "notes" {
// TODO: import from file instead?
note_header(..args)
} else if doc_type == "research_journal" {
research_journal_header(..args)

View File

@ -1,5 +1,19 @@
#import "@local/notes:0.0.1": *
#show: notes-template.with(doc_type: "research_journal", keywords: ("ipsum",))
#show: notes-template.with(
doc_type: "notes",
title: [ On the Usefullness of Notetaking ],
authors: (
[ Jane Doe ],
[ Jack Dow ]
),
logo: "pains-perdus",
date: datetime(
year: 2024,
month: 1,
day: 1,
),
keywords: ()
)
```dot-render
digraph mygraph {