aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/output/paths_output.d
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc_reform/output/paths_output.d')
-rw-r--r--src/doc_reform/output/paths_output.d272
1 files changed, 272 insertions, 0 deletions
diff --git a/src/doc_reform/output/paths_output.d b/src/doc_reform/output/paths_output.d
new file mode 100644
index 0000000..abd21b6
--- /dev/null
+++ b/src/doc_reform/output/paths_output.d
@@ -0,0 +1,272 @@
+/++
+ default settings
++/
+module doc_reform.output.paths_output;
+import std.array,
+ std.path,
+ std.regex,
+ std.stdio;
+import doc_reform.meta.rgx;
+template SiSUoutPaths() {
+ auto SiSUoutPaths(Po,Lng)(
+ Po output_pth_root,
+ Lng lng,
+ ) {
+ struct _PathsStruct {
+ string output_root() {
+ return (output_pth_root.length > 0)
+ ? output_pth_root
+ : "sisugen";
+ }
+ string output_base() {
+ return asNormalizedPath(output_root.chainPath(lng)).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUoutPathSQLite() {
+ auto SiSUoutPathSQLite(Po)(
+ Po output_pth_root,
+ ) {
+ struct _PathsStruct {
+ string output_root() {
+ return (output_pth_root.length > 0)
+ ? output_pth_root
+ : "sisugen";
+ }
+ string output_base() {
+ return asNormalizedPath(output_root).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUoutPathsFnPd() {
+ /+ TODO stuff to work out here +/
+ auto SiSUoutPathsFnPd(Fn,Pn)(
+ Fn fn_src_pth,
+ Pn pod_name
+ ) {
+ struct _PathsStruct {
+ string base_filename() {
+ return fn_src_pth.baseName.stripExtension;
+ }
+ string base_pod_and_filename() { // TODO
+ /+
+ - if pod,
+ - pod_name
+ - file_name
+ - if pod_name == file_name
+ - file_name
+ - else if pod_name != file_name
+ - pod_name.file_name
+ +/
+ string _fn_src = fn_src_pth.baseName.stripExtension;
+ string _output_base_name;
+ if (!(pod_name.empty)) {
+ if (pod_name == _fn_src) {
+ _output_base_name = _fn_src;
+ } else {
+ _output_base_name = pod_name ~ "." ~ _fn_src;
+ }
+ } else {
+ _output_base_name = _fn_src;
+ }
+ return _output_base_name;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsHTML() {
+ mixin SiSUrgxInit;
+ static auto rgx = Rgx();
+ auto SiSUpathsHTML(Po,Lng)(
+ Po output_pth_root,
+ Lng lng,
+ ) {
+ auto out_pth = SiSUoutPaths!()(output_pth_root, lng);
+ string base_dir = "html";
+ string suffix = ".html";
+ struct _PathsStruct {
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string base() {
+ return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array;
+ }
+ string image() {
+ return asNormalizedPath((out_pth.output_root).chainPath("image")).array;
+ }
+ string css() {
+ return asNormalizedPath((out_pth.output_root).chainPath("css")).array;
+ }
+ string fn_seg_css() {
+ return asNormalizedPath(css.chainPath("html_seg.css")).array;
+ }
+ string fn_scroll_css() {
+ return asNormalizedPath(css.chainPath("html_scroll.css")).array;
+ }
+ string seg(string fn_src) {
+ return asNormalizedPath(base.chainPath(base_filename(fn_src))).array;
+ }
+ string fn_scroll(string fn_src) {
+ return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ suffix)).array;
+ }
+ string fn_seg(string fn_src, string seg_filename) {
+ return asNormalizedPath(seg(fn_src).chainPath(seg_filename ~ suffix)).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsEPUB() {
+ mixin SiSUrgxInit;
+ static auto rgx = Rgx();
+ auto SiSUpathsEPUB(Po,Lng)(
+ Po output_pth_root,
+ Lng lng,
+ ) {
+ auto out_pth = SiSUoutPaths!()( output_pth_root, lng);
+ string base_dir = "epub";
+ struct _PathsStruct {
+ string base() {
+ return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array;
+ }
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string epub_file(string fn_src) {
+ return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ ".epub")).array;
+ }
+ string dirtop() {
+ return "".chainPath("").array;
+ }
+ string doc_meta_inf(string fn_src) {
+ return asNormalizedPath(dirtop.chainPath("META-INF")).array;
+ }
+ string doc_oebps(string fn_src) {
+ return asNormalizedPath(dirtop.chainPath("OEBPS")).array;
+ }
+ string doc_oebps_css(string fn_src) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath("css")).array;
+ }
+ string doc_oebps_image(string fn_src) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath("image")).array;
+ }
+ string fn_mimetypes(string fn_src) {
+ return asNormalizedPath(dirtop.chainPath("mimetypes")).array;
+ }
+ string fn_dmi_container_xml(string fn_src) {
+ return asNormalizedPath(doc_meta_inf(fn_src).chainPath("container.xml")).array;
+ }
+ string fn_oebps_toc_nav_xhtml(string fn_src) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath("toc_nav.xhtml")).array;
+ }
+ string fn_oebps_toc_ncx(string fn_src) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath("toc.ncx")).array;
+ }
+ string fn_oebps_content_opf(string fn_src) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath("content.opf")).array;
+ }
+ string fn_oebps_content_xhtml(string fn_src, string seg_filename) {
+ return asNormalizedPath(doc_oebps(fn_src).chainPath(seg_filename ~ ".xhtml")).array;
+ }
+ string fn_oebps_css(string fn_src) {
+ return asNormalizedPath(doc_oebps_css(fn_src).chainPath("epub.css")).array;
+ }
+ debug(epub_output) {
+ string dbg_docdir(string fn_src) {
+ return base.chainPath(base_filename(fn_src)).array;
+ }
+ string dbg_docdir_oebps(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("OEBPS").array;
+ }
+ string dbg_doc_meta_inf(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("META-INF").array;
+ }
+ string dbg_doc_oebps(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("OEBPS").array;
+ }
+ string dbg_doc_oebps_css(string fn_src) {
+ return dbg_doc_oebps(fn_src).chainPath("css").array;
+ }
+ string dbg_doc_oebps_image(string fn_src) {
+ return dbg_doc_oebps(fn_src).chainPath("image").array;
+ }
+ string dbg_fn_mimetypes(string fn_src) {
+ return dbg_docdir(fn_src).chainPath("mimetypes").array;
+ }
+ string dbg_fn_dmi_container_xml(string fn_src) {
+ return dbg_doc_meta_inf(fn_src).chainPath("container.xml").array;
+ }
+ string dbg_fn_oebps_toc_nav_xhtml(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("toc_nav.xhtml").array;
+ }
+ string dbg_fn_oebps_toc_ncx(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("toc.ncx").array;
+ }
+ string dbg_fn_oebps_content_opf(string fn_src) {
+ return dbg_docdir_oebps(fn_src).chainPath("content.opf").array;
+ }
+ string dbg_fn_oebps_content_xhtml(string fn_src, string seg_filename) {
+ return dbg_docdir_oebps(fn_src).chainPath(seg_filename ~ ".xhtml").array;
+ }
+ string dbg_fn_oebps_css(string fn_src) {
+ return dbg_doc_oebps_css(fn_src).chainPath("epub.css").array;
+ }
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsSQLiteDiscrete() {
+ mixin SiSUrgxInit;
+ static auto rgx = Rgx();
+ auto SiSUpathsSQLiteDiscrete(Po,Lng)(
+ Po output_pth_root,
+ Lng lng,
+ ) {
+ struct _PathsStruct {
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string base() {
+ auto out_pth = SiSUoutPaths!()(output_pth_root, lng);
+ string base_dir = "sqlite";
+ return asNormalizedPath((out_pth.output_base).chainPath(base_dir)).array;
+ }
+ string seg(string fn_src) {
+ return asNormalizedPath(base.chainPath(base_filename(fn_src))).array;
+ }
+ string sqlite_file(string fn_src) {
+ return asNormalizedPath(base.chainPath(base_filename(fn_src) ~ ".sql.db")).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}
+template SiSUpathsSQLite() {
+ mixin SiSUrgxInit;
+ static auto rgx = Rgx();
+ auto SiSUpathsSQLite(DbN, Po)(
+ DbN db_name,
+ Po output_pth_root,
+ ) {
+ struct _PathsStruct {
+ string base_filename(string fn_src) {
+ return fn_src.baseName.stripExtension;
+ }
+ string base() {
+ auto out_pth = SiSUoutPathSQLite!()(output_pth_root); // decide whether to have separate files for each language
+ string base_dir = "sqlite";
+ return asNormalizedPath((out_pth.output_root).chainPath(base_dir)).array;
+ }
+ string sqlite_file() {
+ return asNormalizedPath(base.chainPath(base_filename(db_name) ~ ".sql.db")).array;
+ }
+ }
+ return _PathsStruct();
+ }
+}