aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRalph Amissah <ralph.amissah@gmail.com>2021-02-04 11:41:06 -0500
committerRalph Amissah <ralph.amissah@gmail.com>2021-02-04 14:52:41 -0500
commit264013035076a2f51c59e642bb39710b95fdf6bb (patch)
treec694ee18ca47a784fdb62e8846ef66fb6394edff
parentnix, use pkgs.lib instead of stdenv.lib (diff)
spine scaffold generator, sample pod structure .sst document
- build pod structure, and - minimal requirement for a document - at the requested path - uses rund (as D script compiler)
-rwxr-xr-xmisc/util/d/tools/spine_scaffold.d134
-rw-r--r--nix/pkglst/shell-pkgs.nix1
-rw-r--r--org/spine_build_scaffold.org1
-rwxr-xr-xproject.nix1
-rwxr-xr-xspine.nix1
5 files changed, 138 insertions, 0 deletions
diff --git a/misc/util/d/tools/spine_scaffold.d b/misc/util/d/tools/spine_scaffold.d
new file mode 100755
index 0000000..dbcc857
--- /dev/null
+++ b/misc/util/d/tools/spine_scaffold.d
@@ -0,0 +1,134 @@
+#!/usr/bin/env rund
+void main( string[] args ) {
+ import std;
+ if (args.length > 1) {
+ string base_fn_path = args[1].expandTilde;
+ string base_fn = base_fn_path.baseName;
+ string sst_fn = base_fn ~ ".sst";
+ string txt_for_pod_manifest = format(q"┃doc:
+ filename: %s
+ language: en
+┃",
+ sst_fn
+ );
+ string txt_for_sisu_document_make = format(q"┃
+┃",
+ );
+ string txt_for_document_scaffold = format(q"┃# SiSU 8.0
+
+title: "As Yet Unnamed"
+
+creator:
+ author: "Annon, Unnamed"
+
+:A~ @title @author
+
+1~ Summary
+
+To get you started, the first paragraph following a section or chapter heading.
+
+Spine / SiSU documents minimum requirements:
+
+_* a header containing document metadata that must at least contain the fields Title and Creator Author.
+
+_* text body, identified as starting by the A~ marker at the start of a line, followed by at least one level 1~ section heading with the text that follows it.~{ the document provided here would be a valid Spine document, and this text contained within the tilde and curly braces delimiters would be the first footnote/endnote }~
+
+To generate this document to have html and epub output for example you would run:
+
+``` code
+spine --html --epub --output=/tmp/spine-sample-output %s
+```
+
+1~ Conclusion
+
+This sample pod is provided to get you started.
+
+Good luck and good speed.
+┃",
+ base_fn_path
+ );
+ if (!exists(base_fn_path)) {
+ try {
+ base_fn_path.mkdirRecurse;
+ } catch (ErrnoException ex) {
+ writeln(ex);
+ }
+ if (exists(args[1].expandTilde)) {
+ try {
+ base_fn_path.buildPath("conf").mkdirRecurse;
+ } catch (ErrnoException ex) {
+ writeln(ex);
+ }
+ try {
+ base_fn_path.buildPath("media/text/en").mkdirRecurse;
+ } catch (ErrnoException ex) {
+ writeln(ex);
+ }
+ {
+ // 1 // create/write pod.manifest
+ string fn = base_fn_path.buildPath("pod.manifest");
+ File(fn, "w").writeln(txt_for_pod_manifest);
+ string tell = format(q"┃OK - pod.manifest (yaml file containing filename and languages)
+ %s
+%s
+┃",
+ fn,
+ txt_for_pod_manifest.strip
+ );
+ writeln(tell);
+ }
+ if (exists(base_fn_path.buildPath("conf"))) {
+ // 2 // create/write conf/sisu_document_make
+ string fn = base_fn_path.buildPath("conf/sisu_document_make");
+ File(fn, "w").writeln(txt_for_sisu_document_make);
+ // auto f = File(fn, "w");
+ // foreach (line; content_array) {
+ // f.writeln(line);
+ // }
+ string tell = format(q"┃OK - sisu_document_make
+ %s
+┃",
+ fn
+ );
+ writeln(tell);
+ }
+ if (exists(base_fn_path.buildPath("media/text/en"))) {
+ // 3 // create/write media/text/[lang code]/[filename].sst
+ string fn = base_fn_path.buildPath("media/text/en/" ~ sst_fn);
+ File(fn, "w").writeln(txt_for_document_scaffold);
+ // auto f = File(fn, "w");
+ // foreach (line; content_array) {
+ // f.writeln(line);
+ // }
+ string tell = format(q"┃OK - .sst [document text content]
+ %s
+ - To start editing document (spine pod content):
+ ${EDITOR} %s
+ - To generate this document to have html and epub output for example you would run:
+ spine --html --epub --output=/tmp/spine-sample-output %s
+┃",
+ fn,
+ fn,
+ base_fn_path
+ );
+ writeln(tell);
+ }
+ }
+ /+
+ pod/[filename]
+ │
+ ├── conf
+ │   └── sisu_document_make
+ ├── media
+ │   └── text
+ │   └── en
+ │   └── [filename].charles_stross.sst
+ └── pod.manifest
+ +/
+ } else {
+ writeln("requested output pod name with path already exists:\n ", args[1].expandTilde);
+ }
+ } else {
+ writeln( "please provide directory path to operate on, e.g.\n spine_scaffold.d ./pod/filetest" );
+ }
+}
diff --git a/nix/pkglst/shell-pkgs.nix b/nix/pkglst/shell-pkgs.nix
index 7587c02..2b8f03e 100644
--- a/nix/pkglst/shell-pkgs.nix
+++ b/nix/pkglst/shell-pkgs.nix
@@ -7,6 +7,7 @@ let
in
with pkgs; [
nixFlakes
+ rund
dub
ldc
sqlite
diff --git a/org/spine_build_scaffold.org b/org/spine_build_scaffold.org
index 3b56420..d92c753 100644
--- a/org/spine_build_scaffold.org
+++ b/org/spine_build_scaffold.org
@@ -2330,6 +2330,7 @@ dub2nix = (import dub2nix-src) { inherit pkgs; };
#+NAME: nix_shell_with_pkgs_list
#+BEGIN_SRC nix
nixFlakes
+rund
dub
ldc
sqlite
diff --git a/project.nix b/project.nix
index 4594999..fddd77b 100755
--- a/project.nix
+++ b/project.nix
@@ -16,6 +16,7 @@ mkDubDerivation rec {
in
with pkgs; [
nixFlakes
+ rund
dub
ldc
sqlite
diff --git a/spine.nix b/spine.nix
index 185e17e..0c0cf88 100755
--- a/spine.nix
+++ b/spine.nix
@@ -125,6 +125,7 @@ mkDubDerivation rec {
in
with pkgs; [
nixFlakes
+ rund
dub
ldc
sqlite