diff options
Diffstat (limited to 'src/sdp/meta/conf_make_meta_sdlang.d')
-rw-r--r-- | src/sdp/meta/conf_make_meta_sdlang.d | 213 |
1 files changed, 144 insertions, 69 deletions
diff --git a/src/sdp/meta/conf_make_meta_sdlang.d b/src/sdp/meta/conf_make_meta_sdlang.d index 480a8fe..2bded69 100644 --- a/src/sdp/meta/conf_make_meta_sdlang.d +++ b/src/sdp/meta/conf_make_meta_sdlang.d @@ -3,7 +3,7 @@ extract sdlang header return sdlang +/ module sdp.meta.conf_make_meta_sdlang; -template SiSUextractSDLang() { +static template SiSUextractSDLang() { import std.exception, std.regex, @@ -69,87 +69,162 @@ template SiSUextractSDLang() { } return sdl_root_header; // sdlang.ast.Tag } - private auto sdlangToAA(C,Tag)(C conf, Tag conf_sdlang) { - debug(asserts){ - static assert(is(typeof(conf) == string[string][string])); - } - foreach (maintag, subtags; conf) { - /+ writeln(__LINE__, ": ", maintag, ":- ", subtags); +/ - foreach (subtag, content; subtags) { - if (maintag in conf_sdlang.maybe.tags) { - Tag _maintag = conf_sdlang.getTag(maintag); - if ((subtag in _maintag.maybe.tags) - && (_maintag.getTagValues(subtag).length > 0)) { - debug(headersdlang) { - writeln(__LINE__, ": ", maintag, ":", subtag, ": ", _maintag.getTagValues(subtag)[0]); - } - if (_maintag.getTagValues(subtag).length == 1) { - conf[maintag][subtag] = - (_maintag.getTagValues(subtag)[0]).to!string; - } else if (_maintag.getTagValues(subtag).length > 1) { - foreach (st; _maintag.getTagValues(subtag)) { - conf[maintag][subtag] ~= - st.to!string ~ ";"; - } - } - } else if ((subtag in _maintag.maybe.attributes) - && (_maintag.maybe.attributes[subtag][0].value.length > 0)) { - debug(headersdlang) { - writeln(__LINE__, ": ", maintag, ":", subtag, ": ", conf_sdlang.tags[maintag][0].attributes[subtag][0].value); - } - conf[maintag][subtag] = - (conf_sdlang.tags[maintag][0].attributes[subtag][0].value).to!string; - } - } - } + private auto docSDLtoStruct(C,Tag)(C _conf_composite, Tag header_sdlang) { + mixin SiSUregisters; + /+ make +/ + if ("make" in header_sdlang.maybe.tags) { + _conf_composite.make_str.bold = _conf_composite.make.bold = extractSDLangTabOrAttrib(header_sdlang, "make", "bold"); + _conf_composite.make_str.breaks = _conf_composite.make.breaks = extractSDLangTabOrAttrib(header_sdlang, "make", "breaks"); + _conf_composite.make_str.cover_image = _conf_composite.make.cover_image = extractSDLangTabOrAttrib(header_sdlang, "make", "cover_image"); + _conf_composite.make_str.css = _conf_composite.make.css = extractSDLangTabOrAttrib(header_sdlang, "make", "css"); + _conf_composite.make_str.emphasis = _conf_composite.make.emphasis = extractSDLangTabOrAttrib(header_sdlang, "make", "emphasis"); + _conf_composite.make_str.footer = _conf_composite.make.footer = extractSDLangTabOrAttrib(header_sdlang, "make", "footer"); + _conf_composite.make_str.headings = _conf_composite.make.headings = extractSDLangTabOrAttrib(header_sdlang, "make", "headings"); + _conf_composite.make_str.home_button_image = _conf_composite.make.home_button_image = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_image"); + _conf_composite.make_str.home_button_text = _conf_composite.make.home_button_text = extractSDLangTabOrAttrib(header_sdlang, "make", "home_button_text"); + _conf_composite.make_str.italics = _conf_composite.make.italics = extractSDLangTabOrAttrib(header_sdlang, "make", "italics"); + _conf_composite.make_str.num_top = _conf_composite.make.num_top = extractSDLangTabOrAttrib(header_sdlang, "make", "num_top"); + _conf_composite.make_str.num_depth = _conf_composite.make.num_depth = extractSDLangTabOrAttrib(header_sdlang, "make", "num_depth"); + _conf_composite.make_str.substitute = _conf_composite.make.substitute = extractSDLangTabOrAttrib(header_sdlang, "make", "substitute"); + _conf_composite.make_str.texpdf_font = _conf_composite.make.texpdf_font = extractSDLangTabOrAttrib(header_sdlang, "make", "texpdf_font"); } - return conf; - } - private auto docHeaderSDLtoAA(Ma, Tag)(Ma dochead_make, Tag header_sdlang) { - debug(asserts){ - static assert(is(typeof(dochead_make) == string[string][string])); + /+ conf +/ + if ("webserv" in header_sdlang.maybe.tags) { + _conf_composite.conf.webserv_url_root = extractSDLangTabOrAttrib(header_sdlang, "webserv", "url_root"); + _conf_composite.conf.webserv_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "path"); + _conf_composite.conf.webserv_images = extractSDLangTabOrAttrib(header_sdlang, "webserv", "images"); + _conf_composite.conf.webserv_cgi = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi"); + _conf_composite.conf.webserv_cgi_host = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host"); + _conf_composite.conf.webserv_cgi_host_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_host_path"); + _conf_composite.conf.webserv_cgi_port = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_port"); + _conf_composite.conf.webserv_cgi_user = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_user"); + _conf_composite.conf.webserv_cgi_file_links = extractSDLangTabOrAttrib(header_sdlang, "webserv", "cgi_file_links"); + } + if ("processing" in header_sdlang.maybe.tags) { + _conf_composite.conf.processing_path = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_path"); + _conf_composite.conf.processing_dir = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_dir"); + _conf_composite.conf.processing_concord_max = extractSDLangTabOrAttrib(header_sdlang, "webserv", "processing_concord_max"); + } + if("flag" in header_sdlang.maybe.tags) { + _conf_composite.conf.flag_act0 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act0"); + _conf_composite.conf.flag_act1 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act1"); + _conf_composite.conf.flag_act2 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act2"); + _conf_composite.conf.flag_act3 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act3"); + _conf_composite.conf.flag_act4 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act4"); + _conf_composite.conf.flag_act5 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act5"); + _conf_composite.conf.flag_act6 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act6"); + _conf_composite.conf.flag_act7 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act7"); + _conf_composite.conf.flag_act8 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act8"); + _conf_composite.conf.flag_act9 = extractSDLangTabOrAttrib(header_sdlang, "flag", "act9"); + } + if ("default" in header_sdlang.maybe.tags) { + _conf_composite.conf.default_papersize = extractSDLangTabOrAttrib(header_sdlang, "default", "papersize"); + _conf_composite.conf.default_text_wrap = extractSDLangTabOrAttrib(header_sdlang, "default", "text_wrap"); + _conf_composite.conf.default_emphasis = extractSDLangTabOrAttrib(header_sdlang, "default", "emphasis"); + _conf_composite.conf.default_language = extractSDLangTabOrAttrib(header_sdlang, "default", "language"); + _conf_composite.conf.default_digest = extractSDLangTabOrAttrib(header_sdlang, "default", "digest"); + } + if ("search" in header_sdlang.maybe.tags) { + _conf_composite.conf.search_flag = extractSDLangTabOrAttrib(header_sdlang, "search", "flag"); + _conf_composite.conf.search_action = extractSDLangTabOrAttrib(header_sdlang, "search", "action"); + _conf_composite.conf.search_db = extractSDLangTabOrAttrib(header_sdlang, "search", "db"); + _conf_composite.conf.search_title = extractSDLangTabOrAttrib(header_sdlang, "search", "title"); + } + /+ meta +/ + if ("classify" in header_sdlang.maybe.tags) { + _conf_composite.meta.classify_dewey = extractSDLangTabOrAttrib(header_sdlang, "classify", "dewey"); + _conf_composite.meta.classify_keywords = extractSDLangTabOrAttrib(header_sdlang, "classify", "keywords"); + _conf_composite.meta.classify_loc = extractSDLangTabOrAttrib(header_sdlang, "classify", "loc"); + _conf_composite.meta.classify_subject = extractSDLangTabOrAttrib(header_sdlang, "classify", "subject"); + _conf_composite.meta.classify_topic_register = extractSDLangTabOrAttrib(header_sdlang, "classify", "topic_register"); + } + if ("date" in header_sdlang.maybe.tags) { + _conf_composite.meta.date_added_to_site = extractSDLangTabOrAttrib(header_sdlang, "date", "added_to_site"); + _conf_composite.meta.date_available = extractSDLangTabOrAttrib(header_sdlang, "date", "available"); + _conf_composite.meta.date_created = extractSDLangTabOrAttrib(header_sdlang, "date", "created"); + _conf_composite.meta.date_issued = extractSDLangTabOrAttrib(header_sdlang, "date", "issued"); + _conf_composite.meta.date_modified = extractSDLangTabOrAttrib(header_sdlang, "date", "modified"); + _conf_composite.meta.date_published = extractSDLangTabOrAttrib(header_sdlang, "date", "published"); + _conf_composite.meta.date_valid = extractSDLangTabOrAttrib(header_sdlang, "date", "valid"); + } + if("identifier" in header_sdlang.maybe.tags) { + _conf_composite.meta.identifier_isbn = extractSDLangTabOrAttrib(header_sdlang, "identifier", "isbn"); + _conf_composite.meta.identifier_oclc = extractSDLangTabOrAttrib(header_sdlang, "identifier", "oclc"); + _conf_composite.meta.identifier_pg = extractSDLangTabOrAttrib(header_sdlang, "identifier", "pg"); + } + if ("links" in header_sdlang.maybe.tags) { + // _conf_composite.meta.links = extractSDLangTabOrAttrib(header_sdlang, "links", ""); } - dochead_make = sdlangToAA(dochead_make, header_sdlang); - auto dochead_meta = sdlangToAA(meta_aa_empty, header_sdlang); - if (dochead_meta["title"]["main"].empty) { - { + if ("notes" in header_sdlang.maybe.tags) { + _conf_composite.meta.notes_abstract = extractSDLangTabOrAttrib(header_sdlang, "notes", "abstract"); + _conf_composite.meta.notes_description = extractSDLangTabOrAttrib(header_sdlang, "notes", "description"); + } + if ("original" in header_sdlang.maybe.tags) { + _conf_composite.meta.original_language = extractSDLangTabOrAttrib(header_sdlang, "original", "language"); + _conf_composite.meta.original_source = extractSDLangTabOrAttrib(header_sdlang, "original", "source"); + _conf_composite.meta.original_title = extractSDLangTabOrAttrib(header_sdlang, "original", "title"); + } + if ("publisher" in header_sdlang.maybe.tags) { + // _conf_composite.meta.publisher = extractSDLangTabOrAttrib(header_sdlang, "publisher", ""); + } + if ("rights" in header_sdlang.maybe.tags) { + _conf_composite.meta.rights_copyright = extractSDLangTabOrAttrib(header_sdlang, "rights", "copyright"); + _conf_composite.meta.rights_cover = extractSDLangTabOrAttrib(header_sdlang, "rights", "cover"); + _conf_composite.meta.rights_illustrations = extractSDLangTabOrAttrib(header_sdlang, "rights", "illustrations"); + _conf_composite.meta.rights_license = extractSDLangTabOrAttrib(header_sdlang, "rights", "license"); + } + if (_conf_composite.meta.creator_author.empty) { + if ("creator" in header_sdlang.maybe.tags) { + _conf_composite.meta.creator_author = extractSDLangTabOrAttrib(header_sdlang, "creator", "author"); + _conf_composite.meta.creator_author_email = extractSDLangTabOrAttrib(header_sdlang, "creator", "author_email"); + _conf_composite.meta.creator_illustrator = extractSDLangTabOrAttrib(header_sdlang, "creator", "illustrator"); + _conf_composite.meta.creator_translator = extractSDLangTabOrAttrib(header_sdlang, "creator", "translator"); + } + // dochead_meta["creator"]["author_raw"] = dochead_meta["creator"]["author"]; + string[] authors_arr; + auto authors_raw_arr = _conf_composite.meta.creator_author.split(rgx.arr_delimiter); + foreach (author_raw; authors_raw_arr) { + authors_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); + } + _conf_composite.meta.creator_author = join(authors_arr, ", ").chomp.chomp; + } + if (_conf_composite.meta.title_main.empty) { + if ("title" in header_sdlang.maybe.tags) { + _conf_composite.meta.title_edition = extractSDLangTabOrAttrib(header_sdlang, "title", "edition"); + _conf_composite.meta.title_language = extractSDLangTabOrAttrib(header_sdlang, "title", "language"); + _conf_composite.meta.title_main = extractSDLangTabOrAttrib(header_sdlang, "title", "main"); + _conf_composite.meta.title_note = extractSDLangTabOrAttrib(header_sdlang, "title", "note"); + _conf_composite.meta.title_sub = extractSDLangTabOrAttrib(header_sdlang, "title", "sub"); + _conf_composite.meta.title_subtitle = extractSDLangTabOrAttrib(header_sdlang, "title", "subtitle"); + } + if (_conf_composite.meta.title_main.empty) { Tag _maintag = header_sdlang.getTag("title"); if (_maintag !is null) { if ("main" in _maintag.maybe.tags) { - dochead_meta["title"]["main"] = + _conf_composite.meta.title_main = to!string(_maintag.getTagValues("main")); } else if ("main" !in _maintag.maybe.attributes) { writeln(__LINE__, ": ", _maintag.values[0]); - dochead_meta["title"]["main"] = + _conf_composite.meta.title_main = (_maintag.values[0]).to!string; // test that this exists } } } + if ((!(_conf_composite.meta.title_subtitle.empty)) + && (_conf_composite.meta.title_sub.empty)) { + _conf_composite.meta.title_sub = _conf_composite.meta.title_subtitle; + } + if (_conf_composite.meta.title_sub.empty) { + _conf_composite.meta.title_full = _conf_composite.meta.title_main; + } else { + _conf_composite.meta.title_full = format( + "%s - %s", + _conf_composite.meta.title_main, + _conf_composite.meta.title_sub, + ); + } } - if (!(dochead_meta["title"]["subtitle"].empty) - && (dochead_meta["title"]["sub"].empty)) { - dochead_meta["title"]["sub"] ~= dochead_meta["title"]["subtitle"]; - } - dochead_meta["title"].remove("subtitle"); - if (dochead_meta["title"]["sub"].empty) { - dochead_meta["title"]["full"] ~= dochead_meta["title"]["main"]; - } else { - dochead_meta["title"]["full"] ~= format( - "%s - %s", - dochead_meta["title"]["main"], - dochead_meta["title"]["sub"], - ); - } - dochead_meta["creator"]["author_raw"] = dochead_meta["creator"]["author"]; - string[] authors_arr; - auto authors_raw_arr = dochead_meta["creator"]["author"].split(rgx.arr_delimiter); - foreach (author_raw; authors_raw_arr) { - authors_arr ~= author_raw.replace(rgx.raw_author_munge, "$2 $1"); - } - dochead_meta["creator"]["author"] = join(authors_arr, ", ").chomp.chomp; - auto t = tuple(dochead_make, dochead_meta); - static assert(t.length==2); - return t; + return _conf_composite; } } } |