aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc/util/d/tools/spine_scaffold.d
diff options
context:
space:
mode:
Diffstat (limited to 'misc/util/d/tools/spine_scaffold.d')
-rwxr-xr-xmisc/util/d/tools/spine_scaffold.d134
1 files changed, 134 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" );
+ }
+}