From 9125357297e005a555586c354be18ea03701d342 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 25 Jun 2023 18:18:51 -0400 Subject: replace directory listing, blank index.html --- src/doc_reform/io_out/epub3.d | 4 ++ src/doc_reform/io_out/html.d | 30 +++++++++---- src/doc_reform/io_out/hub.d | 8 ++-- src/doc_reform/io_out/latex.d | 34 ++++++++++----- src/doc_reform/io_out/metadata.d | 27 ++++++++---- src/doc_reform/io_out/odt.d | 86 +++++++++++++++++++++----------------- src/doc_reform/io_out/source_pod.d | 4 ++ src/doc_reform/io_out/xmls.d | 7 ++-- 8 files changed, 129 insertions(+), 71 deletions(-) (limited to 'src/doc_reform/io_out') diff --git a/src/doc_reform/io_out/epub3.d b/src/doc_reform/io_out/epub3.d index 7a646fb..c94863b 100644 --- a/src/doc_reform/io_out/epub3.d +++ b/src/doc_reform/io_out/epub3.d @@ -638,6 +638,10 @@ template outputEPub3() { if (!exists(pth_epub3.base)) { pth_epub3.base.mkdirRecurse; } + if (!exists(pth_epub3.base ~ "/index.html")) { + auto f = File(pth_epub3.base ~"/index.html", "w"); + f.writeln(""); + } { /+ debug +/ if (doc_matters.opt.action.debug_do_epub) { if (!exists(pth_epub3.dbg_doc_meta_inf(doc_matters.src.filename))) { diff --git a/src/doc_reform/io_out/html.d b/src/doc_reform/io_out/html.d index 29f7f4e..9e108c6 100644 --- a/src/doc_reform/io_out/html.d +++ b/src/doc_reform/io_out/html.d @@ -245,9 +245,15 @@ template outputHTML() { if (!exists(pth_html.base)) { pth_html.base.mkdirRecurse; } - auto f = File(pth_html.fn_scroll(doc_matters.src.filename), "w"); - foreach (o; doc) { - f.writeln(o); + { + auto f = File(pth_html.fn_scroll(doc_matters.src.filename), "w"); + foreach (o; doc) { + f.writeln(o); + } + } + if (!exists(pth_html.base ~ "/index.html")) { + auto f = File(pth_html.base ~"/index.html", "w"); + f.writeln(""); } } catch (ErrnoException ex) { // Handle error @@ -550,10 +556,16 @@ template outputHTML() { if (!exists(pth_html.css)) { (pth_html.css).mkdirRecurse; } - auto f = File(pth_html.fn_seg_css, "w"); - f.writeln(css.html_seg); - f = File(pth_html.fn_scroll_css, "w"); - f.writeln(css.html_scroll); + { + auto f = File(pth_html.fn_seg_css, "w"); + f.writeln(css.html_seg); + f = File(pth_html.fn_scroll_css, "w"); + f.writeln(css.html_scroll); + } + if (!exists(pth_html.css ~ "/index.html")) { + auto f = File(pth_html.css ~"/index.html", "w"); + f.writeln(""); + } } catch (ErrnoException ex) { // Handle error } @@ -580,6 +592,10 @@ template outputHTML() { } } } + if (!exists(pth_html.image ~ "/index.html")) { + auto f = File(pth_html.image ~"/index.html", "w"); + f.writeln(""); + } } } } diff --git a/src/doc_reform/io_out/hub.d b/src/doc_reform/io_out/hub.d index 06c684e..308d05a 100644 --- a/src/doc_reform/io_out/hub.d +++ b/src/doc_reform/io_out/hub.d @@ -180,11 +180,11 @@ template outputHubInitialize() { && !(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"); + if ((_bespoke_homepage).exists) { + writeln("copy bespoke html homepage\n", _bespoke_homepage, " -> ", opt_action.output_dir_set, "/index.html"); + _bespoke_homepage.copy(opt_action.output_dir_set ~ "/index.html"); } else { - writeln("place bespoke homepage in ./spine-bespoke-output/html/homepage.index.html"); + writeln("place bespoke homepage in ", _bespoke_homepage); } } if ( diff --git a/src/doc_reform/io_out/latex.d b/src/doc_reform/io_out/latex.d index 56ae9fe..231d0c5 100644 --- a/src/doc_reform/io_out/latex.d +++ b/src/doc_reform/io_out/latex.d @@ -1349,17 +1349,23 @@ template outputLaTeX() { if (doc_matters.opt.action.vox_gt0) { writeln(" ", pth_latex.latex_file_with_path(paper_size_orientation)); } - auto f = File(pth_latex.latex_file_with_path(paper_size_orientation), "w"); - f.writeln(latex_content.head); - f.writeln(latex_content.content); - f.writeln(latex_content.tail); - foreach (image; doc_matters.srcs.image_list) { - string fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; - string fn_src_out_file = pth_latex.latex_path_stuff ~ "/" ~ image; - if (exists(fn_src_in)) { - fn_src_in.copy(fn_src_out_file); + { + auto f = File(pth_latex.latex_file_with_path(paper_size_orientation), "w"); + f.writeln(latex_content.head); + f.writeln(latex_content.content); + f.writeln(latex_content.tail); + foreach (image; doc_matters.srcs.image_list) { + string fn_src_in = doc_matters.src.image_dir_path ~ "/" ~ image; + string fn_src_out_file = pth_latex.latex_path_stuff ~ "/" ~ image; + if (exists(fn_src_in)) { + fn_src_in.copy(fn_src_out_file); + } } } + if (!exists(pth_latex.latex_path_stuff ~ "/index.html")) { + auto f = File(pth_latex.latex_path_stuff ~"/index.html", "w"); + f.writeln(""); + } } catch (ErrnoException ex) { // handle error } @@ -1399,8 +1405,14 @@ template outputLaTeXstyInit() { if (!exists(pth_latex.base_sty)) { (pth_latex.base_sty).mkdirRecurse; } - auto f = File(pth_latex.latex_document_header_sty(filename), "w"); - f.writeln(latex_sty); + { + auto f = File(pth_latex.latex_document_header_sty(filename), "w"); + f.writeln(latex_sty); + } + if (!exists(pth_latex.base_sty ~ "/index.html")) { + auto f = File(pth_latex.base_sty ~"/index.html", "w"); + f.writeln(""); + } } catch (ErrnoException ex) { // handle error } diff --git a/src/doc_reform/io_out/metadata.d b/src/doc_reform/io_out/metadata.d index 3fab452..2686d15 100644 --- a/src/doc_reform/io_out/metadata.d +++ b/src/doc_reform/io_out/metadata.d @@ -331,9 +331,15 @@ string theme_light_1 = format(q"┃ if (!exists(pth_html.base)) { pth_html.base.mkdirRecurse; } - auto f = File(pth_html.fn_scroll("metadata." ~ doc_matters.src.filename), "w"); - foreach (o; metadata_) { - f.writeln(o); + { + auto f = File(pth_html.fn_scroll("metadata." ~ doc_matters.src.filename), "w"); + foreach (o; metadata_) { + f.writeln(o); + } + } + if (!exists(pth_html.base ~ "/index.html")) { + auto f = File(pth_html.base ~"/index.html", "w"); + f.writeln(""); } } catch (ErrnoException ex) { // Handle error @@ -372,12 +378,17 @@ string theme_light_1 = format(q"┃ ┃"); metadata_ ~= "
"; if (doc_matters.opt.action.html_link_curate) { - metadata_ ~= format(q"┃

[  ≅ HOME ] ⌘ Curated metadata: - [ Authors ] - [ Topics ]

- ┃"); + metadata_ ~= format(q"┃

[  HOME  |  ≅ Collection ]  [ +  🖋 Authors  | +  ⌘ Topics ]

+ ┃", + (doc_matters.opt.action.webserver_url_doc_root.length > 0) + ? doc_matters.opt.action.webserver_url_doc_root + : doc_matters.conf_make_meta.conf.w_srv_data_root_url + , // HOME index.html equivalent _cfg.www_url_doc_root, + ); } else { - metadata_ ~= format(q"┃

[ ≅ HOME ] + metadata_ ~= format(q"┃

[ ≅ HOME   ≅ Collection ] ┃"); } metadata_ ~= "

" ~ inline_search_form(doc_matters) ~ "

"; diff --git a/src/doc_reform/io_out/odt.d b/src/doc_reform/io_out/odt.d index 8604684..df52149 100644 --- a/src/doc_reform/io_out/odt.d +++ b/src/doc_reform/io_out/odt.d @@ -999,6 +999,10 @@ template outputODT() { if (!exists(pth_odt.base_pth)) { pth_odt.base_pth.mkdirRecurse; } + if (!exists(pth_odt.base_pth ~ "/index.html")) { + auto f = File(pth_odt.base_pth ~"/index.html", "w"); + f.writeln(""); + } // return 0; } @safe string mimetype() { @@ -2049,48 +2053,54 @@ template outputODT() { if (!exists(pth_odt.base_pth)) { // check pth_odt.base_pth.mkdirRecurse; } - string fn; - File f; - { fn = pth_odt.mimetype("zip"); - ODTzip(odt_content.mimetype, fn); - } - { fn = pth_odt.manifest_rdf("zip"); - ODTzip(odt_content.manifest_rdf, fn); - } - { fn = pth_odt.settings_xml("zip"); - ODTzip(odt_content.settings_xml, fn); - } - { fn = pth_odt.styles_xml("zip"); - ODTzip(odt_content.styles_xml, fn); - } - { fn = pth_odt.content_xml("zip"); - ODTzip(odt_content.content_xml, fn); - } - { fn = pth_odt.manifest_xml("zip"); - ODTzip(odt_content.manifest_xml, fn); - } - { fn = pth_odt.meta_xml("zip"); - ODTzip(odt_content.meta_xml, fn); - } - { /+ (images) +/ - foreach (image; doc_matters.srcs.image_list) { - auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; - auto fn_out = pth_odt.image_dir("zip") ~ "/" ~ image; - if (exists(fn_src)) { - { - auto zip_arc_member_file = new ArchiveMember(); - zip_arc_member_file.name = fn_out; - auto zip_data = new OutBuffer(); - zip_data.write(cast(char[]) ((fn_src).read)); - zip_arc_member_file.expandedData = zip_data.toBytes(); - zip.addMember(zip_arc_member_file); - createZipFile!()(fn_odt, zip.build()); + { + string fn; + File f; + { fn = pth_odt.mimetype("zip"); + ODTzip(odt_content.mimetype, fn); + } + { fn = pth_odt.manifest_rdf("zip"); + ODTzip(odt_content.manifest_rdf, fn); + } + { fn = pth_odt.settings_xml("zip"); + ODTzip(odt_content.settings_xml, fn); + } + { fn = pth_odt.styles_xml("zip"); + ODTzip(odt_content.styles_xml, fn); + } + { fn = pth_odt.content_xml("zip"); + ODTzip(odt_content.content_xml, fn); + } + { fn = pth_odt.manifest_xml("zip"); + ODTzip(odt_content.manifest_xml, fn); + } + { fn = pth_odt.meta_xml("zip"); + ODTzip(odt_content.meta_xml, fn); + } + { /+ (images) +/ + foreach (image; doc_matters.srcs.image_list) { + auto fn_src = doc_matters.src.image_dir_path ~ "/" ~ image; + auto fn_out = pth_odt.image_dir("zip") ~ "/" ~ image; + if (exists(fn_src)) { + { + auto zip_arc_member_file = new ArchiveMember(); + zip_arc_member_file.name = fn_out; + auto zip_data = new OutBuffer(); + zip_data.write(cast(char[]) ((fn_src).read)); + zip_arc_member_file.expandedData = zip_data.toBytes(); + zip.addMember(zip_arc_member_file); + createZipFile!()(fn_odt, zip.build()); + } } } } + if (doc_matters.opt.action.vox_gt0) { + writeln(" ", pth_odt.odt_file); + } } - if (doc_matters.opt.action.vox_gt0) { - writeln(" ", pth_odt.odt_file); + if (!exists(pth_odt.base_pth ~ "/index.html")) { + auto f = File(pth_odt.base_pth ~"/index.html", "w"); + f.writeln(""); } } catch (ErrnoException ex) { // Handle error diff --git a/src/doc_reform/io_out/source_pod.d b/src/doc_reform/io_out/source_pod.d index 7c08a89..f61721c 100644 --- a/src/doc_reform/io_out/source_pod.d +++ b/src/doc_reform/io_out/source_pod.d @@ -128,6 +128,10 @@ template spinePod() { pths_pod.doc_lng(doc_matters.src.filename, doc_matters.src.language).filesystem_open_zpod.mkdirRecurse; } } + if (!exists(pths_pod.pod_dir_() ~ "/index.html")) { + auto f = File(pths_pod.pod_dir_() ~"/index.html", "w"); + f.writeln(""); + } if (doc_matters.opt.action.debug_do_pod && doc_matters.opt.action.vox_gt1) { writeln(__LINE__, ": ", diff --git a/src/doc_reform/io_out/xmls.d b/src/doc_reform/io_out/xmls.d index 048b614..c38844c 100644 --- a/src/doc_reform/io_out/xmls.d +++ b/src/doc_reform/io_out/xmls.d @@ -320,7 +320,7 @@ template outputXHTMLs() { ) { string o; string metadata_links = ((doc_matters.opt.action.html_link_curate) - ? format(q"┃

[ ≅ | %s | ◆ |%s%s ⌘• | ⌘A | ⌘T ]

┃", + ? format(q"┃

⟰  [ %s  ◆ %s%s ⌘• ]   ≅ | 🖋 | ⌘ |

┃", (doc_matters.opt.action.webserver_url_doc_root.length > 0) ? doc_matters.opt.action.webserver_url_doc_root : doc_matters.conf_make_meta.conf.w_srv_data_root_url @@ -339,7 +339,7 @@ template outputXHTMLs() { ~ doc_matters.src.filename_base ~ "." ~ doc_matters.src.lng - ~ ".a4.portrait.pdf\"> □ |") + ~ ".a4.portrait.pdf\"> □ ") : "", (doc_matters.opt.action.html_link_pdf || doc_matters.opt.action.html_link_pdf_letter) ? (" □ |") + ~ ".letter.portrait.pdf\"> □ ") : "", (type == "seg") ? "../" : "", doc_matters.src.filename_base, (type == "seg") ? "../" : "", (type == "seg") ? "../" : "", + (type == "seg") ? "../" : "", ) : ""); o = format(q"┃ -- cgit v1.2.3