1769203962
This commit is contained in:
Executable
+78
@@ -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.
@@ -0,0 +1 @@
|
|||||||
|
use flake path:$(pwd)
|
||||||
Generated
+9
-22
@@ -21,30 +21,18 @@
|
|||||||
"local-nure": {
|
"local-nure": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1769126611,
|
"lastModified": 1769194824,
|
||||||
"narHash": "sha256-4qmXN7kx87pEpZHFJpyRbLfZ5GanF5Jbi1Bmfx6ZXss=",
|
"narHash": "sha256-gMPvgSEy5SwmbJQ0yFoNmg1a5f4R+1YGgCj8keuZppY=",
|
||||||
"path": "/storage/git/typst_nure_template",
|
"ref": "multi-pages",
|
||||||
"type": "path"
|
"rev": "3e55bb39a25ca9e0c8adddc0e67de49f5a0be4b1",
|
||||||
|
"revCount": 122,
|
||||||
|
"type": "git",
|
||||||
|
"url": "ssh://gitea@linerds.us/unexplrd/typst_nure_template"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"path": "/storage/git/typst_nure_template",
|
"ref": "multi-pages",
|
||||||
"type": "path"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"local-nure-upstream": {
|
|
||||||
"flake": false,
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1768301144,
|
|
||||||
"narHash": "sha256-VHZXALfaAw5f32mClZTS7MeTSaDSQtErAjI+lgpYIZk=",
|
|
||||||
"ref": "refs/heads/0.1.0",
|
|
||||||
"rev": "549d7f060f81a6356c43b2c231e6453ddae19fca",
|
|
||||||
"revCount": 111,
|
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"
|
"url": "ssh://gitea@linerds.us/unexplrd/typst_nure_template"
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "ssh://gitea@gitea.linerds.us/pencelheimer/typst_nure_template"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
@@ -67,7 +55,6 @@
|
|||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-utils": "flake-utils",
|
"flake-utils": "flake-utils",
|
||||||
"local-nure": "local-nure",
|
"local-nure": "local-nure",
|
||||||
"local-nure-upstream": "local-nure-upstream",
|
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
"typix": "typix"
|
"typix": "typix"
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -9,11 +9,11 @@
|
|||||||
|
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
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/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.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;
|
local-nure.flake = false;
|
||||||
|
|
||||||
# Example of downloading icons from a non-flake source
|
# Example of downloading icons from a non-flake source
|
||||||
@@ -92,17 +92,17 @@
|
|||||||
pkgs.linkFarm name linkFarmEntries;
|
pkgs.linkFarm name linkFarmEntries;
|
||||||
|
|
||||||
unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [
|
unpublishedTypstPackages = mkTypstPackagesDrv "unpublished-packages" [
|
||||||
{
|
# {
|
||||||
namespace = "unexplrd";
|
# namespace = "unexplrd";
|
||||||
name = "test-multifile";
|
# name = "test-multifile";
|
||||||
version = "0.1.0";
|
# version = "0.1.0";
|
||||||
input = inputs.local-nure;
|
# input = inputs.local-nure;
|
||||||
}
|
# }
|
||||||
{
|
{
|
||||||
namespace = "local";
|
namespace = "local";
|
||||||
name = "nure";
|
name = "nure";
|
||||||
version = "0.1.0";
|
version = "0.1.0";
|
||||||
input = inputs.local-nure-upstream;
|
input = inputs.local-nure;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -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,9 +2,11 @@
|
|||||||
# **/lib/
|
# **/lib/
|
||||||
**/src/lib/
|
**/src/lib/
|
||||||
**/config/universities.yaml
|
**/config/universities.yaml
|
||||||
|
**/.direnv/
|
||||||
|
|
||||||
*.pdf
|
*.pdf
|
||||||
|
|
||||||
# nix artifacts
|
# nix artifacts
|
||||||
**/result
|
**/result
|
||||||
**/result-*
|
**/result-*
|
||||||
|
**/.direnv/
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
use flake path:$(pwd)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
university = "ХНУРЕ"
|
university = "ХНУРЕ"
|
||||||
subject = "ЕРВ"
|
subject = "ЕРВ"
|
||||||
type = "ЛБ"
|
type = "ЛБ"
|
||||||
number = 2
|
number = 3
|
||||||
|
|
||||||
[[mentors]]
|
[[mentors]]
|
||||||
name = "Шевченко Т. Г."
|
name = "Шевченко Т. Г."
|
||||||
@@ -4,4 +4,4 @@ default:
|
|||||||
|
|
||||||
# Create new work from template
|
# Create new work from template
|
||||||
new subject shortcode number="":
|
new subject shortcode number="":
|
||||||
@./.config/create-work.nu {{subject}} {{shortcode}} {{number}}
|
@./.config/create-work {{subject}} {{shortcode}} {{number}}
|
||||||
|
|||||||
Reference in New Issue
Block a user