1769203962

This commit is contained in:
2026-01-23 23:32:42 +02:00
parent 17dd7d4549
commit ad58ad90dc
20 changed files with 104 additions and 145 deletions

78
.config/create-work Executable file
View File

@@ -0,0 +1,78 @@
#!/usr/bin/env nu
let template_dir = ".config/template"
let config_dir = ".config"
let out_dir = $"(pwd)"
# let out_dir = $"(pwd)/works"
def main [subject: string, shortcode: string, number?: int] {
let subject_lower = ($subject | str downcase)
let shortcode_lower = ($shortcode | str downcase)
validate-input $subject $shortcode $number
let temp_dir = $"/tmp/nure-work-(random chars -l 8)"
let final_dir = $"($out_dir)/($subject_lower)/($shortcode_lower)($number)"
let subject_dir = $"($out_dir)/($subject_lower)"
# TODO?: replace with git clone
cp -r ($config_dir)/template $temp_dir
# $template | decode base64 | tar zxvf - --strip-components=1 -C $temp_dir o> /dev/null
generate-doc-toml $shortcode_lower $subject_lower $temp_dir $number
check-mkdir $out_dir
if ($final_dir | path exists) {
error make -u {msg: $"Directory ($final_dir) already exists"}
}
check-mkdir $subject_dir; cp -r $temp_dir $final_dir; rm -rf $temp_dir
print $"=> Created new work: ($final_dir)"
}
def check-mkdir [path: string] { if not ($path | path exists) { mkdir $path } }
def validate-input [subject: string, shortcode: string, number?: int] {
if not ($config_dir | path exists) {
error make -u {msg: $"($config_dir) not found"}
}
let defaults_toml = $"($config_dir)/defaults.toml"
let subjects_toml = $"($config_dir)/subjects.toml"
if not ($defaults_toml | path exists) {
error make -u {msg: $"defaults.toml not found in ($config_dir)"}
}
if not ($subjects_toml | path exists) {
error make -u {msg: $"subjects.toml not found in ($config_dir)"}
}
if ($number != nothing and $number < 1 ) {
error make -u {msg: "Work number should be greater than 0"}
}
# Check subject exists (case insensitive)
let subject_lower = ($subject | str downcase)
let subjects = (open $subjects_toml | columns)
if $subject_lower not-in $subjects {
error make -u {
msg: $"Subject '($subject)' not found in configuration"
help: $"Available subjects: ($subjects | str join ', ')"
}
}
}
def generate-doc-toml [shortcode: string, subject: string, target_dir: string, number?: int] {
let defaults = (open $"($config_dir)/defaults.toml")
let subjects = (open $"($config_dir)/subjects.toml")
let subject_data = ($subjects | get $subject)
let work_type = ($defaults | get work_types | try { get $shortcode } catch { $shortcode })
{
university: ($defaults | get university)
subject: ($subject_data | get name), type: $work_type, number: $number
mentors: ($subject_data | get mentors), authors: [($defaults | get default_author)]
} | compact --empty | to toml | save $"($target_dir)/src/doc.toml" --force
}

File diff suppressed because one or more lines are too long

Binary file not shown.

1
.config/template/.envrc Normal file
View File

@@ -0,0 +1 @@
use flake path:$(pwd)

View File

@@ -21,30 +21,18 @@
"local-nure": {
"flake": false,
"locked": {
"lastModified": 1769126611,
"narHash": "sha256-4qmXN7kx87pEpZHFJpyRbLfZ5GanF5Jbi1Bmfx6ZXss=",
"path": "/storage/git/typst_nure_template",
"type": "path"
"lastModified": 1769194824,
"narHash": "sha256-gMPvgSEy5SwmbJQ0yFoNmg1a5f4R+1YGgCj8keuZppY=",
"ref": "multi-pages",
"rev": "3e55bb39a25ca9e0c8adddc0e67de49f5a0be4b1",
"revCount": 122,
"type": "git",
"url": "ssh://gitea@linerds.us/unexplrd/typst_nure_template"
},
"original": {
"path": "/storage/git/typst_nure_template",
"type": "path"
}
},
"local-nure-upstream": {
"flake": false,
"locked": {
"lastModified": 1768301144,
"narHash": "sha256-VHZXALfaAw5f32mClZTS7MeTSaDSQtErAjI+lgpYIZk=",
"ref": "refs/heads/0.1.0",
"rev": "549d7f060f81a6356c43b2c231e6453ddae19fca",
"revCount": 111,
"ref": "multi-pages",
"type": "git",
"url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"
},
"original": {
"type": "git",
"url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"
"url": "ssh://gitea@linerds.us/unexplrd/typst_nure_template"
}
},
"nixpkgs": {
@@ -67,7 +55,6 @@
"inputs": {
"flake-utils": "flake-utils",
"local-nure": "local-nure",
"local-nure-upstream": "local-nure-upstream",
"nixpkgs": "nixpkgs",
"typix": "typix"
}

View File

@@ -9,11 +9,11 @@
flake-utils.url = "github:numtide/flake-utils";
local-nure-upstream.url = "git+ssh://gitea@linerds.us/unexplrd/typst_nure_template?ref=multi-pages";
# local-nure-upstream.url = "git+ssh://gitea@linerds.us/pencelheimer/typst_nure_template";
local-nure-upstream.flake = false;
# local-nure-upstream.url = "git+ssh://gitea@linerds.us/unexplrd/typst_nure_template?ref=multi-pages";
# local-nure-upstream.flake = false;
local-nure.url = "path:/storage/git/typst_nure_template";
# local-nure.url = "git+ssh://gitea@linerds.us/pencelheimer/typst_nure_template";
local-nure.url = "git+ssh://gitea@linerds.us/unexplrd/typst_nure_template?ref=multi-pages";
local-nure.flake = false;
# Example of downloading icons from a non-flake source
@@ -92,17 +92,17 @@
pkgs.linkFarm name linkFarmEntries;
unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [
{
namespace = "unexplrd";
name = "test-multifile";
version = "0.1.0";
input = inputs.local-nure;
}
# {
# namespace = "unexplrd";
# name = "test-multifile";
# version = "0.1.0";
# input = inputs.local-nure;
# }
{
namespace = "local";
name = "nure";
version = "0.1.0";
input = inputs.local-nure-upstream;
input = inputs.local-nure;
}
];

View File

@@ -1,26 +0,0 @@
university = "ХНУРЕ"
subject = "ЕРВ"
type = "ЛБ"
number = 3
[[mentors]]
name = "Шевченко Т. Г."
degree = "Доцент кафедри ПІ"
gender = "m"
[[mentors]]
name = "Франко І. Я."
degree = "Асистент кафедри ПІ"
gender = "m"
[[authors]]
name = "Косач Л. П."
edu_program = "КУІБ"
group = "23-2"
gender = "f"
variant = 8
# For coursework
full_name_gen = "Косач Лариси Петрівни"
course = 2
semester = 4

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

2
.gitignore vendored
View File

@@ -2,9 +2,11 @@
# **/lib/
**/src/lib/
**/config/universities.yaml
**/.direnv/
*.pdf
# nix artifacts
**/result
**/result-*
**/.direnv/

1
erv/lb3/.envrc Normal file
View File

@@ -0,0 +1 @@
use flake path:$(pwd)

View File

@@ -1,7 +1,7 @@
university = "ХНУРЕ"
subject = "ЕРВ"
type = "ЛБ"
number = 2
number = 3
[[mentors]]
name = "Шевченко Т. Г."

View File

@@ -4,4 +4,4 @@ default:
# Create new work from template
new subject shortcode number="":
@./.config/create-work.nu {{subject}} {{shortcode}} {{number}}
@./.config/create-work {{subject}} {{shortcode}} {{number}}