aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/doc_reform/meta/conf_make_meta_structs.d
blob: ef3994496e8cdedf66cbc9db975a0111528bbc1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/+
- Name: Spine, Doc Reform [a part of]
  - Description: documents, structuring, processing, publishing, search
    - static content generator

  - Author: Ralph Amissah
    [ralph.amissah@gmail.com]

  - Copyright: (C) 2015 - 2024 Ralph Amissah, All Rights Reserved.

  - License: AGPL 3 or later:

    Spine (SiSU), a framework for document structuring, publishing and
    search

    Copyright (C) Ralph Amissah

    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU AFERO General Public License as published by the
    Free Software Foundation, either version 3 of the License, or (at your
    option) any later version.

    This program is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
    more details.

    You should have received a copy of the GNU General Public License along with
    this program. If not, see [https://www.gnu.org/licenses/].

    If you have Internet connection, the latest version of the AGPL should be
    available at these locations:
    [https://www.fsf.org/licensing/licenses/agpl.html]
    [https://www.gnu.org/licenses/agpl.html]

  - Spine (by Doc Reform, related to SiSU) uses standard:
    - docReform markup syntax
      - standard SiSU markup syntax with modified headers and minor modifications
    - docReform object numbering
      - standard SiSU object citation numbering & system

  - Homepages:
    [https://www.doc_reform.org]
    [https://www.sisudoc.org]

  - Git
    [https://git.sisudoc.org/projects/?p=software/spine.git;a=summary]

+/
module doc_reform.meta.conf_make_meta_structs;
@safe:
import
  std.exception,
  std.json,
  std.path,
  std.regex,
  std.stdio,
  std.string,
  std.typecons,
  std.utf,
  std.conv : to;
import
  doc_reform.meta.defaults,
  doc_reform.meta.rgx_yaml,
  doc_reform.meta.rgx;
mixin spineRgxIn;
static auto rgx = RgxI();
mixin spineRgxYamlTags;
static auto rgx_y = RgxYaml();
mixin InternalMarkup;
static auto mkup = InlineMarkup();
string url_markup(string line) {
  string line_ = line
    .replaceAll(
      rgx.smid_inline_link_markup_regular,
      ("$1"
        ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c
        ~ mkup.url_o ~ "$3" ~ mkup.url_c
      ) // ("$1{ $2 }$3$4")
    )
    .replaceAll(
        rgx.smid_inline_link_naked_url,
        ("$1"
          ~ mkup.lnk_o ~ "$2" ~ mkup.lnk_c
          ~ mkup.url_o ~ "$2" ~ mkup.url_c
        ) // ("$1{ $2 }$2$3")
    )
    .replaceAll(
       rgx.arr_delimiter,
       mkup.br_line
    );
  return line_;
}
struct ConfCompositeMakeStr {
  string     doc_type = "book"; // book, article
  string     breaks;
  string     bold;
  string     cover_image;
  string     css;
  string     emphasis;
  string[]   footer;
  string[]   headings;
  string[]   home_button_image;
  string     home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├"
    ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├"
    ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├";
  string     italics;
  string     auto_num_top_at_level;
  int        auto_num_top_lv           = 9;
  int        auto_num_depth            = 2;
  string[][] substitute;
  string     texpdf_font;
}
@trusted struct confCompositeMakeBuild {
  string[] bold(string _mk) {
    string[] _out;
    if (_mk) {
      _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "*{$1}*", "<b>$1</b>"];
    }
    return _out;
  }
  string doc_type(string _mk) {
    return _mk;
  }
  string breaks(string _mk) {
    return _mk;
  }
  string cover_image(string _mk) {
    return _mk;
  }
  string css(string _mk) {
    return _mk;
  }
  string[] emphasis(string _mk) {
    string[] _out;
    if (_mk) {
      _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "!{$1}!", "<em>$1</em>" ];
    }
    return _out;
  }
  string[] footer(string[] _mk) {
    string line_;
    string[] _mk2;
    foreach (line; _mk) {
      _mk2 ~= url_markup(line);
    }
    return _mk2;
  }
  string[] headings(string[] _mk) {
    return _mk;
  }
  string[] home_button_image(string[] _mk) {
    return _mk;
  }
  string home_button_text(string _mk) {
    return url_markup(_mk);
  }
  string[] italics(string _mk) {
    string[] _out;
    if (_mk) {
      _out = [ (cast(string) (`(` ~ _mk.dup ~ `)`)), "/{$1}/", "<i>$1</i>" ];
    }
    return _out;
  }
  string auto_num_top_at_level(string _mk) {
    return _mk;
  }
  int auto_num_top_lv(int _mk) {
    return _mk;
  }
  int auto_num_depth(int _mk) {
    return _mk;
  }
  string[][] substitute(string[][] _mk) {
    return _mk;
  }
  string texpdf_font(string _mk) {
    return _mk;
  }
}
struct ConfCompositeMakeInit {
  string     doc_type;
  string     breaks;
  string     cover_image;
  string     css;
  string[]   bold;
  string[]   emphasis;
  string[]   footer;
  string[]   headings;
  string[]   home_button_image;
  string     home_button_text = "┥Spine, Doc Reform┝┤https://www.doc-reform.org├"
    ~ " ┥www.doc-reform.org┝┤https://www.doc-reform.org├"
    ~ " ┥sources / git┝┤https://git.doc-reform.org/software/spine├";
  string[] italics;
  string     auto_num_top_at_level;
  int        auto_num_top_lv               = 9;
  int        auto_num_depth                = 2;
  string[][] substitute;
  string     texpdf_font;
}
struct ConfCompositeSiteLocal {
  string   w_srv_http;
  string   w_srv_host;
  string   w_srv_data_http;            // if not set same as webserv_http
  string   w_srv_data_host;            // if not set same as webserv_host
  string   w_srv_data_root_part;
  string   w_srv_data_root_url;
  string   w_srv_data_root_url_html;
  string   w_srv_data_root_path;
  string   w_srv_images_root_part;
  // string   w_srv_url_doc_path;
  string   w_srv_cgi_search_form_title;
  string   w_srv_cgi_http;             // if not set same as webserv_http
  string   w_srv_cgi_host;             // if not set same as webserv_host
  string   w_srv_cgi_bin_subpath;
  string   w_srv_cgi_bin_path;
  string   w_srv_cgi_search_script;
  string   w_srv_cgi_search_script_raw_fn_d;
  string   w_srv_cgi_port;
  string   w_srv_cgi_user;
  string   w_srv_cgi_action;
  string   w_srv_cgi_bin_url;
  string   w_srv_db_sqlite_filename;
  string   w_srv_db_sqlite_path;
  // string   w_srv_db_pg;
  string   w_srv_db_pg_table;
  string   w_srv_db_pg_user;
  // string   webserv_cgi_file_links;
  string   output_path;
  string   processing_path;
  string   processing_dir;
  string   processing_concord_max;
  string   flag_act0;
  string   flag_act1;
  string   flag_act2;
  string   flag_act3;
  string   flag_act4;
  string   flag_act5;
  string   flag_act6;
  string   flag_act7;
  string   flag_act8;
  string   flag_act9;
  string[] set_papersize;
  string   set_text_wrap;
  string   set_emphasis;
  string   set_language;
  string   set_digest;
  string   permission_share_source;
  string   search_flag;
  string   search_action;
  string   search_db;
  string   search_title;
}
struct MetaComposite {
  string   classify_dewey;
  string   classify_keywords;
  string   classify_loc;
  string   classify_subject;
  string   classify_topic_register;
  string[] classify_topic_register_arr;
  string[] classify_topic_register_expanded_arr; // experimental use in sqlite topics table
  string[] creator_author_arr;
  string   creator_author;
  string   creator_author_surname_fn;
  string   creator_author_surname;
  string   creator_author_email;
  string   creator_illustrator;
  string   creator_translator;
  string   date_added_to_site;
  string   date_available;
  string   date_created;
  string   date_issued;
  string   date_modified;
  string   date_published;
  string   date_valid;
  string   identifier_isbn;
  string   identifier_oclc;
  string   identifier_pg;
  string   language_document;
  string   language_document_char;
  string   links;
  string   notes_abstract;
  string   notes_description;
  string   notes_summary;
  string   original_language;
  string   original_language_char;
  string   original_publisher;
  string   original_source;
  string   original_title;
  string   publisher;
  string   rights_copyright;
  string   rights_copyright_audio;
  string   rights_copyright_cover;
  string   rights_copyright_illustrations;
  string   rights_copyright_photographs;
  string   rights_copyright_text;
  string   rights_copyright_translation;
  string   rights_copyright_video;
  string   rights_license;
  string   title_edition;
  string   title_full;
  string   title_language;
  string   title_main;
  string   title_note;
  string   title_short;
  string   title_sub;
  string   title_subtitle;
}
struct ConfComposite {
  MetaComposite               meta;
  ConfCompositeMakeInit       make;
  ConfCompositeMakeStr        make_str;
  ConfCompositeSiteLocal      conf;
}
JSONValue config_jsonstr = `{
}`;