From 3434b91d73562686f35796ccfa7553df7b4307b5 Mon Sep 17 00:00:00 2001
From: Ralph Amissah <ralph.amissah@gmail.com>
Date: Sat, 24 Jun 2023 19:51:00 -0400
Subject: html, bespoke homepage, symlink toc.html index.html

- html, bespoke homepage option
- html, symlinks toc.html index.html
---
 org/out_xmls.org             |  3 +++
 org/output_hub.org           | 16 +++++++++++++++-
 src/doc_reform/io_out/html.d |  3 +++
 src/doc_reform/io_out/hub.d  | 16 +++++++++++++++-
 views/configuration.txt      |  3 +++
 5 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/org/out_xmls.org b/org/out_xmls.org
index 4a2626b..d9c4800 100644
--- a/org/out_xmls.org
+++ b/org/out_xmls.org
@@ -2350,6 +2350,9 @@ default:
       }
       f.writeln(xhtml_format.tail(doc_matters));
     }
+    if (!exists(pth_html.fn_seg(doc_matters.src.filename, "index"))) {
+      symlink("./toc.html", (pth_html.fn_seg(doc_matters.src.filename, "index")));
+    }
   } catch (ErrnoException ex) {
     // handle error
   }
diff --git a/org/output_hub.org b/org/output_hub.org
index a7bb536..179a008 100644
--- a/org/output_hub.org
+++ b/org/output_hub.org
@@ -67,13 +67,27 @@ template outputHub() {
   }
 }
 template outputHubInitialize() {
+  import std.file;
   import doc_reform.io_out,
     doc_reform.io_out.metadata,
     doc_reform.io_out.paths_output;
+  string _bespoke_homepage = "./spine-bespoke-output/html/homepage.index.html";
   @system void outputHubInitialize(O,I)(
     O opt_action,
     I program_info
   ) {
+    if ((opt_action.html || opt_action.html_seg || opt_action.html_scroll)
+        && opt_action.output_dir_set.length > 0
+        && !(opt_action.output_dir_set ~ "/index.html").exists
+    ) {
+      writeln(_bespoke_homepage);
+      if (("./spine-bespoke-output/html/homepage.index.html").exists) {
+        writeln("copy bespoke html homepage\n./spine-bespoke-output/html/homepage.index.html -> ", opt_action.output_dir_set, "/index.html");
+        "./spine-bespoke-output/html/homepage.index.html".copy(opt_action.output_dir_set ~ "/index.html");
+      } else {
+        writeln("place bespoke homepage in ./spine-bespoke-output/html/homepage.index.html");
+      }
+    }
     if (
       opt_action.latex_document_header_sty
       || (
@@ -88,8 +102,8 @@ template outputHubInitialize() {
         program_info.name_version_and_compiler,
         program_info.time_output_generated,
       );
+      writeln(opt_action.latex);
     }
-    writeln(opt_action.latex);
   }
 }
 template outputHubOp() {
diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d
index 0cbf61e..29f7f4e 100644
--- a/src/doc_reform/io_out/html.d
+++ b/src/doc_reform/io_out/html.d
@@ -533,6 +533,9 @@ template outputHTML() {
         }
         f.writeln(xhtml_format.tail(doc_matters));
       }
+      if (!exists(pth_html.fn_seg(doc_matters.src.filename, "index"))) {
+        symlink("./toc.html", (pth_html.fn_seg(doc_matters.src.filename, "index")));
+      }
     } catch (ErrnoException ex) {
       // handle error
     }
diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d
index 92fea80..06c684e 100644
--- a/src/doc_reform/io_out/hub.d
+++ b/src/doc_reform/io_out/hub.d
@@ -166,13 +166,27 @@ template outputHub() {
   }
 }
 template outputHubInitialize() {
+  import std.file;
   import doc_reform.io_out,
     doc_reform.io_out.metadata,
     doc_reform.io_out.paths_output;
+  string _bespoke_homepage = "./spine-bespoke-output/html/homepage.index.html";
   @system void outputHubInitialize(O,I)(
     O opt_action,
     I program_info
   ) {
+    if ((opt_action.html || opt_action.html_seg || opt_action.html_scroll)
+        && opt_action.output_dir_set.length > 0
+        && !(opt_action.output_dir_set ~ "/index.html").exists
+    ) {
+      writeln(_bespoke_homepage);
+      if (("./spine-bespoke-output/html/homepage.index.html").exists) {
+        writeln("copy bespoke html homepage\n./spine-bespoke-output/html/homepage.index.html -> ", opt_action.output_dir_set, "/index.html");
+        "./spine-bespoke-output/html/homepage.index.html".copy(opt_action.output_dir_set ~ "/index.html");
+      } else {
+        writeln("place bespoke homepage in ./spine-bespoke-output/html/homepage.index.html");
+      }
+    }
     if (
       opt_action.latex_document_header_sty
       || (
@@ -187,8 +201,8 @@ template outputHubInitialize() {
         program_info.name_version_and_compiler,
         program_info.time_output_generated,
       );
+      writeln(opt_action.latex);
     }
-    writeln(opt_action.latex);
   }
 }
 template outputHubOp() {
diff --git a/views/configuration.txt b/views/configuration.txt
index 5f49a1a..7728c94 100644
--- a/views/configuration.txt
+++ b/views/configuration.txt
@@ -4,6 +4,9 @@ struct Cfg {
   string www_url_doc_root         = "http://localhost";
   string www_url_doc_subroot      = "/spine";
   string processing_path_doc_root = "/srv/www/spine";
+  // string processing_path_doc_root = "/srv/www/spine";
+  // string processing_path_doc_root = "/srv/www";
+  // string processing_path_doc_subroot = "/spine";
   string cgi_bin_root             = "/var/www/cgi/cgi-bin";
   string cgi_bin_subpath          = "/cgi-bin";
   string cgi_filename             = "spine_search";
-- 
cgit v1.2.3