From 960c3088bc88f2db879154053280b06c160d4d70 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 21 Apr 2015 14:45:52 -0400 Subject: lib/sisu/*, single libs directory (c&d gone) (7) * removed lib/sisu/{current,develop} dir branches v7 (v5 & v6 retired) * simplify dir structure, offer single version per snapshot * have enjoyed carrying stable and development versions v5 & v6 in a single tarball, may return to this structure --- bin/sisu | 203 +- bin/sisu5 | 1 - bin/sisu6 | 1 - conf/sisu/sisurc.yml | 163 + conf/sisu/v5/sisurc.yml | 1 - conf/sisu/v6/sisurc.yml | 1 - data/doc/sisu/CHANGELOG_v5 | 18 +- data/doc/sisu/CHANGELOG_v6 | 9 +- .../markup-samples/manual/_sisu/sisu_document_make | 2 +- .../sisu/markup-samples/manual/_sisu/sisurc.yml | 148 + .../sisu/markup-samples/manual/_sisu/v5/sisurc.yml | 1 - .../sisu/markup-samples/manual/_sisu/v6/sisurc.yml | 1 - lib/sisu.rb | 94 + lib/sisu/air.rb | 80 + lib/sisu/ao.rb | 590 ++++ lib/sisu/ao_character_check.rb | 102 + lib/sisu/ao_composite.rb | 286 ++ lib/sisu/ao_doc_objects.rb | 565 ++++ lib/sisu/ao_doc_str.rb | 2269 +++++++++++++ lib/sisu/ao_endnotes.rb | 136 + lib/sisu/ao_expand_insertions.rb | 514 +++ lib/sisu/ao_hash_digest.rb | 174 + lib/sisu/ao_idx.rb | 422 +++ lib/sisu/ao_images.rb | 187 ++ lib/sisu/ao_metadata.rb | 86 + lib/sisu/ao_misc_arrange.rb | 207 ++ lib/sisu/ao_numbering.rb | 720 ++++ lib/sisu/ao_persist.rb | 194 ++ lib/sisu/ao_references.rb | 502 +++ lib/sisu/ao_syntax.rb | 640 ++++ lib/sisu/cgi.rb | 84 + lib/sisu/cgi_pgsql.rb | 270 ++ lib/sisu/cgi_sql_common.rb | 986 ++++++ lib/sisu/cgi_sqlite.rb | 244 ++ lib/sisu/conf.rb | 287 ++ lib/sisu/constants.rb | 388 +++ lib/sisu/css.rb | 3484 ++++++++++++++++++++ lib/sisu/current/air.rb | 80 - lib/sisu/current/ao.rb | 590 ---- lib/sisu/current/ao_character_check.rb | 102 - lib/sisu/current/ao_composite.rb | 286 -- lib/sisu/current/ao_doc_objects.rb | 565 ---- lib/sisu/current/ao_doc_str.rb | 2269 ------------- lib/sisu/current/ao_endnotes.rb | 136 - lib/sisu/current/ao_expand_insertions.rb | 514 --- lib/sisu/current/ao_hash_digest.rb | 174 - lib/sisu/current/ao_idx.rb | 422 --- lib/sisu/current/ao_images.rb | 187 -- lib/sisu/current/ao_metadata.rb | 86 - lib/sisu/current/ao_misc_arrange.rb | 207 -- lib/sisu/current/ao_numbering.rb | 720 ---- lib/sisu/current/ao_persist.rb | 194 -- lib/sisu/current/ao_references.rb | 502 --- lib/sisu/current/ao_syntax.rb | 640 ---- lib/sisu/current/cgi.rb | 84 - lib/sisu/current/cgi_pgsql.rb | 270 -- lib/sisu/current/cgi_sql_common.rb | 986 ------ lib/sisu/current/cgi_sqlite.rb | 244 -- lib/sisu/current/conf.rb | 287 -- lib/sisu/current/constants.rb | 388 --- lib/sisu/current/css.rb | 3484 -------------------- lib/sisu/current/db_columns.rb | 1997 ----------- lib/sisu/current/db_create.rb | 689 ---- lib/sisu/current/db_dbi.rb | 90 - lib/sisu/current/db_drop.rb | 207 -- lib/sisu/current/db_import.rb | 877 ----- lib/sisu/current/db_indexes.rb | 146 - lib/sisu/current/db_load_tuple.rb | 323 -- lib/sisu/current/db_remove.rb | 182 - lib/sisu/current/db_select.rb | 230 -- lib/sisu/current/db_sqltxt.rb | 173 - lib/sisu/current/db_tests.rb | 114 - lib/sisu/current/dbi.rb | 166 - lib/sisu/current/dbi_discrete.rb | 206 -- lib/sisu/current/digests.rb | 306 -- lib/sisu/current/dp.rb | 1606 --------- lib/sisu/current/dp_identify_markup.rb | 161 - lib/sisu/current/dp_make.rb | 668 ---- lib/sisu/current/embedded.rb | 149 - lib/sisu/current/errors.rb | 84 - lib/sisu/current/generic_parts.rb | 131 - lib/sisu/current/git.rb | 277 -- lib/sisu/current/html.rb | 775 ----- lib/sisu/current/html_concordance.rb | 391 --- lib/sisu/current/html_format.rb | 1348 -------- lib/sisu/current/html_harvest.rb | 109 - lib/sisu/current/html_harvest_author_format.rb | 111 - lib/sisu/current/html_harvest_authors.rb | 466 --- lib/sisu/current/html_harvest_topics.rb | 893 ----- lib/sisu/current/html_lite_shared.rb | 324 -- lib/sisu/current/html_manifest.rb | 1032 ------ lib/sisu/current/html_minitoc.rb | 230 -- lib/sisu/current/html_parts.rb | 437 --- lib/sisu/current/html_persist.rb | 237 -- lib/sisu/current/html_promo.rb | 440 --- lib/sisu/current/html_scroll.rb | 235 -- lib/sisu/current/html_segments.rb | 716 ---- lib/sisu/current/html_shared.rb | 62 - lib/sisu/current/html_table.rb | 64 - lib/sisu/current/html_tune.rb | 301 -- lib/sisu/current/hub.rb | 277 -- lib/sisu/current/hub_actions.rb | 1122 ------- lib/sisu/current/hub_loop_markup_files.rb | 170 - lib/sisu/current/hub_options.rb | 1695 ---------- lib/sisu/current/i18n.rb | 702 ---- lib/sisu/current/manpage.rb | 377 --- lib/sisu/current/manpage_format.rb | 85 - lib/sisu/current/object_munge.rb | 307 -- lib/sisu/current/prog_text_translation.rb | 1702 ---------- lib/sisu/current/qrcode.rb | 754 ----- lib/sisu/current/relaxng.rb | 1153 ------- lib/sisu/current/remote.rb | 246 -- lib/sisu/current/rexml.rb | 148 - lib/sisu/current/se.rb | 158 - lib/sisu/current/se_cleanoutput.rb | 145 - lib/sisu/current/se_clear.rb | 105 - lib/sisu/current/se_createsite.rb | 273 -- lib/sisu/current/se_css.rb | 221 -- lib/sisu/current/se_date.rb | 92 - lib/sisu/current/se_db.rb | 214 -- lib/sisu/current/se_envcall.rb | 326 -- lib/sisu/current/se_file_op.rb | 2758 ---------------- lib/sisu/current/se_filemap.rb | 247 -- lib/sisu/current/se_get_init.rb | 258 -- lib/sisu/current/se_hub_particulars.rb | 234 -- lib/sisu/current/se_info_env.rb | 2179 ------------ lib/sisu/current/se_info_port.rb | 70 - lib/sisu/current/se_info_system.rb | 202 -- lib/sisu/current/se_load.rb | 108 - lib/sisu/current/se_processing.rb | 659 ---- lib/sisu/current/se_programs.rb | 394 --- lib/sisu/current/se_remotes.rb | 553 ---- lib/sisu/current/se_standardise_lang.rb | 176 - lib/sisu/current/se_version.rb | 183 - lib/sisu/current/shared_images.rb | 137 - lib/sisu/current/shared_markup_alt.rb | 336 -- lib/sisu/current/shared_metadata.rb | 1361 -------- lib/sisu/current/shared_sem.rb | 156 - lib/sisu/current/sisu_thor_lib.rb | 407 --- lib/sisu/current/sitemaps.rb | 224 -- lib/sisu/current/src_kdissert_share.rb | 102 - lib/sisu/current/src_po4a_share.rb | 309 -- lib/sisu/current/src_po4a_shelf.rb | 1217 ------- lib/sisu/current/src_po4a_shelf_set.rb | 297 -- lib/sisu/current/src_po4a_sst_ao_sst.rb | 893 ----- lib/sisu/current/src_po4a_sst_ao_sst_set.rb | 284 -- lib/sisu/current/src_po4a_sstm.rb | 135 - lib/sisu/current/src_shared.rb | 347 -- lib/sisu/current/src_sisupod_make.rb | 171 - lib/sisu/current/src_sisupod_sstm.rb | 109 - lib/sisu/current/sst_convert_markup.rb | 323 -- lib/sisu/current/sst_do_inline_footnotes.rb | 440 --- lib/sisu/current/sst_from_xml.rb | 178 - lib/sisu/current/sst_identify_markup.rb | 482 --- lib/sisu/current/sst_to_s_xml_sax.rb | 471 --- lib/sisu/current/termsheet.rb | 163 - lib/sisu/current/texinfo.rb | 430 --- lib/sisu/current/texinfo_format.rb | 541 --- lib/sisu/current/texpdf.rb | 1162 ------- lib/sisu/current/texpdf_format.rb | 1689 ---------- lib/sisu/current/texpdf_parts.rb | 235 -- lib/sisu/current/txt_asciidoc.rb | 354 -- lib/sisu/current/txt_asciidoc_decorate.rb | 207 -- lib/sisu/current/txt_markdown.rb | 389 --- lib/sisu/current/txt_markdown_decorate.rb | 207 -- lib/sisu/current/txt_orgmode.rb | 376 --- lib/sisu/current/txt_orgmode_decorate.rb | 186 -- lib/sisu/current/txt_output.rb | 86 - lib/sisu/current/txt_plain.rb | 410 --- lib/sisu/current/txt_plain_decorate.rb | 189 -- lib/sisu/current/txt_read.rb | 109 - lib/sisu/current/txt_rst.rb | 371 --- lib/sisu/current/txt_rst_decorate.rb | 186 -- lib/sisu/current/txt_shared.rb | 241 -- lib/sisu/current/txt_textile.rb | 367 --- lib/sisu/current/txt_textile_decorate.rb | 186 -- lib/sisu/current/update.rb | 141 - lib/sisu/current/urls.rb | 696 ---- lib/sisu/current/utils.rb | 232 -- lib/sisu/current/utils_composite.rb | 115 - lib/sisu/current/utils_response.rb | 114 - lib/sisu/current/utils_screen_text_color.rb | 472 --- lib/sisu/current/utils_spell.rb | 99 - lib/sisu/current/webrick.rb | 191 -- lib/sisu/current/wikispeak.rb | 375 --- lib/sisu/current/xhtml.rb | 472 --- lib/sisu/current/xhtml_epub2.rb | 890 ----- lib/sisu/current/xhtml_epub2_concordance.rb | 322 -- lib/sisu/current/xhtml_epub2_format.rb | 2272 ------------- lib/sisu/current/xhtml_epub2_persist.rb | 278 -- lib/sisu/current/xhtml_epub2_segments.rb | 599 ---- lib/sisu/current/xhtml_epub2_tune.rb | 330 -- lib/sisu/current/xhtml_parts.rb | 183 - lib/sisu/current/xhtml_shared.rb | 62 - lib/sisu/current/xhtml_table.rb | 97 - lib/sisu/current/xml_docbook5.rb | 376 --- lib/sisu/current/xml_dom.rb | 624 ---- lib/sisu/current/xml_fictionbook2.rb | 389 --- lib/sisu/current/xml_format.rb | 865 ----- lib/sisu/current/xml_md_oai_pmh_dc.rb | 229 -- lib/sisu/current/xml_odf_odt.rb | 885 ----- lib/sisu/current/xml_odf_odt_format.rb | 674 ---- lib/sisu/current/xml_parts.rb | 191 -- lib/sisu/current/xml_persist.rb | 126 - lib/sisu/current/xml_sax.rb | 521 --- .../current/xml_scaffold_structure_collapsed.rb | 198 -- lib/sisu/current/xml_scaffold_structure_sisu.rb | 201 -- lib/sisu/current/xml_shared.rb | 665 ---- lib/sisu/current/xml_tables.rb | 261 -- lib/sisu/current/zap.rb | 90 - lib/sisu/db_columns.rb | 1997 +++++++++++ lib/sisu/db_create.rb | 689 ++++ lib/sisu/db_dbi.rb | 90 + lib/sisu/db_drop.rb | 207 ++ lib/sisu/db_import.rb | 877 +++++ lib/sisu/db_indexes.rb | 146 + lib/sisu/db_load_tuple.rb | 323 ++ lib/sisu/db_remove.rb | 182 + lib/sisu/db_select.rb | 230 ++ lib/sisu/db_sqltxt.rb | 173 + lib/sisu/db_tests.rb | 114 + lib/sisu/dbi.rb | 166 + lib/sisu/dbi_discrete.rb | 206 ++ lib/sisu/develop/air.rb | 80 - lib/sisu/develop/ao.rb | 590 ---- lib/sisu/develop/ao_character_check.rb | 102 - lib/sisu/develop/ao_composite.rb | 286 -- lib/sisu/develop/ao_doc_objects.rb | 565 ---- lib/sisu/develop/ao_doc_str.rb | 2269 ------------- lib/sisu/develop/ao_endnotes.rb | 136 - lib/sisu/develop/ao_expand_insertions.rb | 514 --- lib/sisu/develop/ao_hash_digest.rb | 174 - lib/sisu/develop/ao_idx.rb | 422 --- lib/sisu/develop/ao_images.rb | 187 -- lib/sisu/develop/ao_metadata.rb | 86 - lib/sisu/develop/ao_misc_arrange.rb | 207 -- lib/sisu/develop/ao_numbering.rb | 720 ---- lib/sisu/develop/ao_persist.rb | 194 -- lib/sisu/develop/ao_references.rb | 502 --- lib/sisu/develop/ao_syntax.rb | 640 ---- lib/sisu/develop/cgi.rb | 84 - lib/sisu/develop/cgi_pgsql.rb | 270 -- lib/sisu/develop/cgi_sql_common.rb | 986 ------ lib/sisu/develop/cgi_sqlite.rb | 244 -- lib/sisu/develop/conf.rb | 287 -- lib/sisu/develop/constants.rb | 388 --- lib/sisu/develop/css.rb | 3484 -------------------- lib/sisu/develop/db_columns.rb | 1997 ----------- lib/sisu/develop/db_create.rb | 689 ---- lib/sisu/develop/db_dbi.rb | 90 - lib/sisu/develop/db_drop.rb | 207 -- lib/sisu/develop/db_import.rb | 877 ----- lib/sisu/develop/db_indexes.rb | 146 - lib/sisu/develop/db_load_tuple.rb | 323 -- lib/sisu/develop/db_remove.rb | 182 - lib/sisu/develop/db_select.rb | 230 -- lib/sisu/develop/db_sqltxt.rb | 173 - lib/sisu/develop/db_tests.rb | 114 - lib/sisu/develop/dbi.rb | 166 - lib/sisu/develop/dbi_discrete.rb | 206 -- lib/sisu/develop/digests.rb | 306 -- lib/sisu/develop/dp.rb | 1606 --------- lib/sisu/develop/dp_identify_markup.rb | 161 - lib/sisu/develop/dp_make.rb | 668 ---- lib/sisu/develop/embedded.rb | 149 - lib/sisu/develop/errors.rb | 84 - lib/sisu/develop/generic_parts.rb | 131 - lib/sisu/develop/git.rb | 277 -- lib/sisu/develop/html.rb | 775 ----- lib/sisu/develop/html_concordance.rb | 391 --- lib/sisu/develop/html_format.rb | 1348 -------- lib/sisu/develop/html_harvest.rb | 109 - lib/sisu/develop/html_harvest_author_format.rb | 111 - lib/sisu/develop/html_harvest_authors.rb | 466 --- lib/sisu/develop/html_harvest_topics.rb | 893 ----- lib/sisu/develop/html_lite_shared.rb | 324 -- lib/sisu/develop/html_manifest.rb | 1032 ------ lib/sisu/develop/html_minitoc.rb | 230 -- lib/sisu/develop/html_parts.rb | 437 --- lib/sisu/develop/html_persist.rb | 237 -- lib/sisu/develop/html_promo.rb | 440 --- lib/sisu/develop/html_scroll.rb | 235 -- lib/sisu/develop/html_segments.rb | 716 ---- lib/sisu/develop/html_shared.rb | 62 - lib/sisu/develop/html_table.rb | 64 - lib/sisu/develop/html_tune.rb | 301 -- lib/sisu/develop/hub.rb | 277 -- lib/sisu/develop/hub_actions.rb | 1122 ------- lib/sisu/develop/hub_loop_markup_files.rb | 170 - lib/sisu/develop/hub_options.rb | 1695 ---------- lib/sisu/develop/i18n.rb | 702 ---- lib/sisu/develop/manpage.rb | 377 --- lib/sisu/develop/manpage_format.rb | 85 - lib/sisu/develop/object_munge.rb | 307 -- lib/sisu/develop/prog_text_translation.rb | 1702 ---------- lib/sisu/develop/qrcode.rb | 754 ----- lib/sisu/develop/relaxng.rb | 1153 ------- lib/sisu/develop/remote.rb | 246 -- lib/sisu/develop/rexml.rb | 148 - lib/sisu/develop/se.rb | 158 - lib/sisu/develop/se_cleanoutput.rb | 145 - lib/sisu/develop/se_clear.rb | 105 - lib/sisu/develop/se_createsite.rb | 273 -- lib/sisu/develop/se_css.rb | 221 -- lib/sisu/develop/se_date.rb | 92 - lib/sisu/develop/se_db.rb | 214 -- lib/sisu/develop/se_envcall.rb | 326 -- lib/sisu/develop/se_file_op.rb | 2758 ---------------- lib/sisu/develop/se_filemap.rb | 247 -- lib/sisu/develop/se_get_init.rb | 258 -- lib/sisu/develop/se_hub_particulars.rb | 234 -- lib/sisu/develop/se_info_env.rb | 2179 ------------ lib/sisu/develop/se_info_port.rb | 70 - lib/sisu/develop/se_info_system.rb | 202 -- lib/sisu/develop/se_load.rb | 108 - lib/sisu/develop/se_processing.rb | 659 ---- lib/sisu/develop/se_programs.rb | 394 --- lib/sisu/develop/se_remotes.rb | 553 ---- lib/sisu/develop/se_standardise_lang.rb | 176 - lib/sisu/develop/se_version.rb | 183 - lib/sisu/develop/shared_images.rb | 137 - lib/sisu/develop/shared_markup_alt.rb | 336 -- lib/sisu/develop/shared_metadata.rb | 1361 -------- lib/sisu/develop/shared_sem.rb | 156 - lib/sisu/develop/sisu_thor_lib.rb | 407 --- lib/sisu/develop/sitemaps.rb | 224 -- lib/sisu/develop/src_kdissert_share.rb | 102 - lib/sisu/develop/src_po4a_share.rb | 309 -- lib/sisu/develop/src_po4a_shelf.rb | 1217 ------- lib/sisu/develop/src_po4a_shelf_set.rb | 297 -- lib/sisu/develop/src_po4a_sst_ao_sst.rb | 893 ----- lib/sisu/develop/src_po4a_sst_ao_sst_set.rb | 284 -- lib/sisu/develop/src_po4a_sstm.rb | 135 - lib/sisu/develop/src_shared.rb | 347 -- lib/sisu/develop/src_sisupod_make.rb | 171 - lib/sisu/develop/src_sisupod_sstm.rb | 109 - lib/sisu/develop/sst_convert_markup.rb | 323 -- lib/sisu/develop/sst_do_inline_footnotes.rb | 440 --- lib/sisu/develop/sst_from_xml.rb | 178 - lib/sisu/develop/sst_identify_markup.rb | 482 --- lib/sisu/develop/sst_to_s_xml_sax.rb | 471 --- lib/sisu/develop/termsheet.rb | 163 - lib/sisu/develop/texinfo.rb | 430 --- lib/sisu/develop/texinfo_format.rb | 541 --- lib/sisu/develop/texpdf.rb | 1162 ------- lib/sisu/develop/texpdf_format.rb | 1689 ---------- lib/sisu/develop/texpdf_parts.rb | 235 -- lib/sisu/develop/txt_asciidoc.rb | 354 -- lib/sisu/develop/txt_asciidoc_decorate.rb | 207 -- lib/sisu/develop/txt_markdown.rb | 389 --- lib/sisu/develop/txt_markdown_decorate.rb | 207 -- lib/sisu/develop/txt_orgmode.rb | 376 --- lib/sisu/develop/txt_orgmode_decorate.rb | 186 -- lib/sisu/develop/txt_output.rb | 86 - lib/sisu/develop/txt_plain.rb | 410 --- lib/sisu/develop/txt_plain_decorate.rb | 189 -- lib/sisu/develop/txt_read.rb | 109 - lib/sisu/develop/txt_rst.rb | 371 --- lib/sisu/develop/txt_rst_decorate.rb | 186 -- lib/sisu/develop/txt_shared.rb | 241 -- lib/sisu/develop/txt_textile.rb | 367 --- lib/sisu/develop/txt_textile_decorate.rb | 186 -- lib/sisu/develop/update.rb | 141 - lib/sisu/develop/urls.rb | 696 ---- lib/sisu/develop/utils.rb | 232 -- lib/sisu/develop/utils_composite.rb | 115 - lib/sisu/develop/utils_response.rb | 114 - lib/sisu/develop/utils_screen_text_color.rb | 472 --- lib/sisu/develop/utils_spell.rb | 99 - lib/sisu/develop/webrick.rb | 191 -- lib/sisu/develop/wikispeak.rb | 375 --- lib/sisu/develop/xhtml.rb | 472 --- lib/sisu/develop/xhtml_epub2.rb | 890 ----- lib/sisu/develop/xhtml_epub2_concordance.rb | 322 -- lib/sisu/develop/xhtml_epub2_format.rb | 2272 ------------- lib/sisu/develop/xhtml_epub2_persist.rb | 278 -- lib/sisu/develop/xhtml_epub2_segments.rb | 599 ---- lib/sisu/develop/xhtml_epub2_tune.rb | 330 -- lib/sisu/develop/xhtml_parts.rb | 183 - lib/sisu/develop/xhtml_shared.rb | 62 - lib/sisu/develop/xhtml_table.rb | 97 - lib/sisu/develop/xml_docbook5.rb | 376 --- lib/sisu/develop/xml_dom.rb | 624 ---- lib/sisu/develop/xml_fictionbook2.rb | 389 --- lib/sisu/develop/xml_format.rb | 865 ----- lib/sisu/develop/xml_md_oai_pmh_dc.rb | 229 -- lib/sisu/develop/xml_odf_odt.rb | 885 ----- lib/sisu/develop/xml_odf_odt_format.rb | 674 ---- lib/sisu/develop/xml_parts.rb | 191 -- lib/sisu/develop/xml_persist.rb | 126 - lib/sisu/develop/xml_sax.rb | 521 --- .../develop/xml_scaffold_structure_collapsed.rb | 198 -- lib/sisu/develop/xml_scaffold_structure_sisu.rb | 201 -- lib/sisu/develop/xml_shared.rb | 665 ---- lib/sisu/develop/xml_tables.rb | 261 -- lib/sisu/develop/zap.rb | 90 - lib/sisu/digests.rb | 306 ++ lib/sisu/dp.rb | 1606 +++++++++ lib/sisu/dp_identify_markup.rb | 161 + lib/sisu/dp_make.rb | 668 ++++ lib/sisu/embedded.rb | 149 + lib/sisu/errors.rb | 84 + lib/sisu/generic_parts.rb | 131 + lib/sisu/git.rb | 277 ++ lib/sisu/html.rb | 775 +++++ lib/sisu/html_concordance.rb | 391 +++ lib/sisu/html_format.rb | 1348 ++++++++ lib/sisu/html_harvest.rb | 109 + lib/sisu/html_harvest_author_format.rb | 111 + lib/sisu/html_harvest_authors.rb | 466 +++ lib/sisu/html_harvest_topics.rb | 893 +++++ lib/sisu/html_lite_shared.rb | 324 ++ lib/sisu/html_manifest.rb | 1032 ++++++ lib/sisu/html_minitoc.rb | 230 ++ lib/sisu/html_parts.rb | 437 +++ lib/sisu/html_persist.rb | 237 ++ lib/sisu/html_promo.rb | 440 +++ lib/sisu/html_scroll.rb | 235 ++ lib/sisu/html_segments.rb | 716 ++++ lib/sisu/html_shared.rb | 62 + lib/sisu/html_table.rb | 64 + lib/sisu/html_tune.rb | 301 ++ lib/sisu/hub.rb | 277 ++ lib/sisu/hub_actions.rb | 1122 +++++++ lib/sisu/hub_loop_markup_files.rb | 170 + lib/sisu/hub_options.rb | 1695 ++++++++++ lib/sisu/i18n.rb | 702 ++++ lib/sisu/manpage.rb | 377 +++ lib/sisu/manpage_format.rb | 85 + lib/sisu/object_munge.rb | 307 ++ lib/sisu/prog_text_translation.rb | 1702 ++++++++++ lib/sisu/qrcode.rb | 754 +++++ lib/sisu/relaxng.rb | 1153 +++++++ lib/sisu/remote.rb | 246 ++ lib/sisu/rexml.rb | 148 + lib/sisu/se.rb | 158 + lib/sisu/se_cleanoutput.rb | 145 + lib/sisu/se_clear.rb | 105 + lib/sisu/se_createsite.rb | 273 ++ lib/sisu/se_css.rb | 221 ++ lib/sisu/se_date.rb | 92 + lib/sisu/se_db.rb | 214 ++ lib/sisu/se_envcall.rb | 326 ++ lib/sisu/se_file_op.rb | 2758 ++++++++++++++++ lib/sisu/se_filemap.rb | 247 ++ lib/sisu/se_get_init.rb | 238 ++ lib/sisu/se_hub_particulars.rb | 234 ++ lib/sisu/se_info_env.rb | 2179 ++++++++++++ lib/sisu/se_info_port.rb | 70 + lib/sisu/se_info_system.rb | 202 ++ lib/sisu/se_load.rb | 108 + lib/sisu/se_processing.rb | 659 ++++ lib/sisu/se_programs.rb | 394 +++ lib/sisu/se_remotes.rb | 553 ++++ lib/sisu/se_standardise_lang.rb | 176 + lib/sisu/se_version.rb | 174 + lib/sisu/shared_images.rb | 137 + lib/sisu/shared_markup_alt.rb | 336 ++ lib/sisu/shared_metadata.rb | 1361 ++++++++ lib/sisu/shared_sem.rb | 156 + lib/sisu/sisu_thor_lib.rb | 407 +++ lib/sisu/sitemaps.rb | 224 ++ lib/sisu/src_kdissert_share.rb | 102 + lib/sisu/src_po4a_share.rb | 309 ++ lib/sisu/src_po4a_shelf.rb | 1217 +++++++ lib/sisu/src_po4a_shelf_set.rb | 297 ++ lib/sisu/src_po4a_sst_ao_sst.rb | 893 +++++ lib/sisu/src_po4a_sst_ao_sst_set.rb | 284 ++ lib/sisu/src_po4a_sstm.rb | 135 + lib/sisu/src_shared.rb | 347 ++ lib/sisu/src_sisupod_make.rb | 171 + lib/sisu/src_sisupod_sstm.rb | 109 + lib/sisu/sst_convert_markup.rb | 323 ++ lib/sisu/sst_do_inline_footnotes.rb | 440 +++ lib/sisu/sst_from_xml.rb | 178 + lib/sisu/sst_identify_markup.rb | 482 +++ lib/sisu/sst_to_s_xml_sax.rb | 471 +++ lib/sisu/termsheet.rb | 163 + lib/sisu/texinfo.rb | 430 +++ lib/sisu/texinfo_format.rb | 541 +++ lib/sisu/texpdf.rb | 1162 +++++++ lib/sisu/texpdf_format.rb | 1689 ++++++++++ lib/sisu/texpdf_parts.rb | 235 ++ lib/sisu/txt_asciidoc.rb | 354 ++ lib/sisu/txt_asciidoc_decorate.rb | 207 ++ lib/sisu/txt_markdown.rb | 389 +++ lib/sisu/txt_markdown_decorate.rb | 207 ++ lib/sisu/txt_orgmode.rb | 376 +++ lib/sisu/txt_orgmode_decorate.rb | 186 ++ lib/sisu/txt_output.rb | 86 + lib/sisu/txt_plain.rb | 410 +++ lib/sisu/txt_plain_decorate.rb | 189 ++ lib/sisu/txt_read.rb | 109 + lib/sisu/txt_rst.rb | 371 +++ lib/sisu/txt_rst_decorate.rb | 186 ++ lib/sisu/txt_shared.rb | 241 ++ lib/sisu/txt_textile.rb | 367 +++ lib/sisu/txt_textile_decorate.rb | 186 ++ lib/sisu/update.rb | 141 + lib/sisu/urls.rb | 696 ++++ lib/sisu/utils.rb | 232 ++ lib/sisu/utils_composite.rb | 115 + lib/sisu/utils_response.rb | 114 + lib/sisu/utils_screen_text_color.rb | 472 +++ lib/sisu/utils_spell.rb | 99 + lib/sisu/webrick.rb | 191 ++ lib/sisu/wikispeak.rb | 375 +++ lib/sisu/xhtml.rb | 472 +++ lib/sisu/xhtml_epub2.rb | 890 +++++ lib/sisu/xhtml_epub2_concordance.rb | 322 ++ lib/sisu/xhtml_epub2_format.rb | 2272 +++++++++++++ lib/sisu/xhtml_epub2_persist.rb | 278 ++ lib/sisu/xhtml_epub2_segments.rb | 599 ++++ lib/sisu/xhtml_epub2_tune.rb | 330 ++ lib/sisu/xhtml_parts.rb | 183 + lib/sisu/xhtml_shared.rb | 62 + lib/sisu/xhtml_table.rb | 97 + lib/sisu/xml_docbook5.rb | 376 +++ lib/sisu/xml_dom.rb | 624 ++++ lib/sisu/xml_fictionbook2.rb | 389 +++ lib/sisu/xml_format.rb | 865 +++++ lib/sisu/xml_md_oai_pmh_dc.rb | 229 ++ lib/sisu/xml_odf_odt.rb | 887 +++++ lib/sisu/xml_odf_odt_format.rb | 674 ++++ lib/sisu/xml_parts.rb | 191 ++ lib/sisu/xml_persist.rb | 126 + lib/sisu/xml_sax.rb | 521 +++ lib/sisu/xml_scaffold_structure_collapsed.rb | 198 ++ lib/sisu/xml_scaffold_structure_sisu.rb | 201 ++ lib/sisu/xml_shared.rb | 665 ++++ lib/sisu/xml_tables.rb | 261 ++ lib/sisu/zap.rb | 90 + man/man1/sisu5.1 | 1 - man/man1/sisu6.1 | 1 - qi | 81 +- setup/qi_libs.rb | 243 +- setup/qi_libs_base.rb | 31 +- setup/rbuild | 80 +- setup/rbuild_libs.rb | 145 +- 539 files changed, 79985 insertions(+), 159296 deletions(-) delete mode 120000 bin/sisu5 delete mode 120000 bin/sisu6 create mode 100644 conf/sisu/sisurc.yml delete mode 120000 conf/sisu/v5/sisurc.yml delete mode 120000 conf/sisu/v6/sisurc.yml create mode 100644 data/doc/sisu/markup-samples/manual/_sisu/sisurc.yml delete mode 120000 data/doc/sisu/markup-samples/manual/_sisu/v5/sisurc.yml delete mode 120000 data/doc/sisu/markup-samples/manual/_sisu/v6/sisurc.yml create mode 100644 lib/sisu.rb create mode 100644 lib/sisu/air.rb create mode 100644 lib/sisu/ao.rb create mode 100644 lib/sisu/ao_character_check.rb create mode 100644 lib/sisu/ao_composite.rb create mode 100644 lib/sisu/ao_doc_objects.rb create mode 100644 lib/sisu/ao_doc_str.rb create mode 100644 lib/sisu/ao_endnotes.rb create mode 100644 lib/sisu/ao_expand_insertions.rb create mode 100644 lib/sisu/ao_hash_digest.rb create mode 100644 lib/sisu/ao_idx.rb create mode 100644 lib/sisu/ao_images.rb create mode 100644 lib/sisu/ao_metadata.rb create mode 100644 lib/sisu/ao_misc_arrange.rb create mode 100644 lib/sisu/ao_numbering.rb create mode 100644 lib/sisu/ao_persist.rb create mode 100644 lib/sisu/ao_references.rb create mode 100644 lib/sisu/ao_syntax.rb create mode 100644 lib/sisu/cgi.rb create mode 100644 lib/sisu/cgi_pgsql.rb create mode 100644 lib/sisu/cgi_sql_common.rb create mode 100644 lib/sisu/cgi_sqlite.rb create mode 100644 lib/sisu/conf.rb create mode 100644 lib/sisu/constants.rb create mode 100644 lib/sisu/css.rb delete mode 100644 lib/sisu/current/air.rb delete mode 100644 lib/sisu/current/ao.rb delete mode 100644 lib/sisu/current/ao_character_check.rb delete mode 100644 lib/sisu/current/ao_composite.rb delete mode 100644 lib/sisu/current/ao_doc_objects.rb delete mode 100644 lib/sisu/current/ao_doc_str.rb delete mode 100644 lib/sisu/current/ao_endnotes.rb delete mode 100644 lib/sisu/current/ao_expand_insertions.rb delete mode 100644 lib/sisu/current/ao_hash_digest.rb delete mode 100644 lib/sisu/current/ao_idx.rb delete mode 100644 lib/sisu/current/ao_images.rb delete mode 100644 lib/sisu/current/ao_metadata.rb delete mode 100644 lib/sisu/current/ao_misc_arrange.rb delete mode 100644 lib/sisu/current/ao_numbering.rb delete mode 100644 lib/sisu/current/ao_persist.rb delete mode 100644 lib/sisu/current/ao_references.rb delete mode 100644 lib/sisu/current/ao_syntax.rb delete mode 100644 lib/sisu/current/cgi.rb delete mode 100644 lib/sisu/current/cgi_pgsql.rb delete mode 100644 lib/sisu/current/cgi_sql_common.rb delete mode 100644 lib/sisu/current/cgi_sqlite.rb delete mode 100644 lib/sisu/current/conf.rb delete mode 100644 lib/sisu/current/constants.rb delete mode 100644 lib/sisu/current/css.rb delete mode 100644 lib/sisu/current/db_columns.rb delete mode 100644 lib/sisu/current/db_create.rb delete mode 100644 lib/sisu/current/db_dbi.rb delete mode 100644 lib/sisu/current/db_drop.rb delete mode 100644 lib/sisu/current/db_import.rb delete mode 100644 lib/sisu/current/db_indexes.rb delete mode 100644 lib/sisu/current/db_load_tuple.rb delete mode 100644 lib/sisu/current/db_remove.rb delete mode 100644 lib/sisu/current/db_select.rb delete mode 100644 lib/sisu/current/db_sqltxt.rb delete mode 100644 lib/sisu/current/db_tests.rb delete mode 100644 lib/sisu/current/dbi.rb delete mode 100644 lib/sisu/current/dbi_discrete.rb delete mode 100644 lib/sisu/current/digests.rb delete mode 100644 lib/sisu/current/dp.rb delete mode 100644 lib/sisu/current/dp_identify_markup.rb delete mode 100644 lib/sisu/current/dp_make.rb delete mode 100644 lib/sisu/current/embedded.rb delete mode 100644 lib/sisu/current/errors.rb delete mode 100644 lib/sisu/current/generic_parts.rb delete mode 100644 lib/sisu/current/git.rb delete mode 100644 lib/sisu/current/html.rb delete mode 100644 lib/sisu/current/html_concordance.rb delete mode 100644 lib/sisu/current/html_format.rb delete mode 100644 lib/sisu/current/html_harvest.rb delete mode 100644 lib/sisu/current/html_harvest_author_format.rb delete mode 100644 lib/sisu/current/html_harvest_authors.rb delete mode 100644 lib/sisu/current/html_harvest_topics.rb delete mode 100644 lib/sisu/current/html_lite_shared.rb delete mode 100644 lib/sisu/current/html_manifest.rb delete mode 100644 lib/sisu/current/html_minitoc.rb delete mode 100644 lib/sisu/current/html_parts.rb delete mode 100644 lib/sisu/current/html_persist.rb delete mode 100644 lib/sisu/current/html_promo.rb delete mode 100644 lib/sisu/current/html_scroll.rb delete mode 100644 lib/sisu/current/html_segments.rb delete mode 100644 lib/sisu/current/html_shared.rb delete mode 100644 lib/sisu/current/html_table.rb delete mode 100644 lib/sisu/current/html_tune.rb delete mode 100644 lib/sisu/current/hub.rb delete mode 100644 lib/sisu/current/hub_actions.rb delete mode 100644 lib/sisu/current/hub_loop_markup_files.rb delete mode 100644 lib/sisu/current/hub_options.rb delete mode 100644 lib/sisu/current/i18n.rb delete mode 100644 lib/sisu/current/manpage.rb delete mode 100644 lib/sisu/current/manpage_format.rb delete mode 100644 lib/sisu/current/object_munge.rb delete mode 100644 lib/sisu/current/prog_text_translation.rb delete mode 100644 lib/sisu/current/qrcode.rb delete mode 100644 lib/sisu/current/relaxng.rb delete mode 100644 lib/sisu/current/remote.rb delete mode 100644 lib/sisu/current/rexml.rb delete mode 100644 lib/sisu/current/se.rb delete mode 100644 lib/sisu/current/se_cleanoutput.rb delete mode 100644 lib/sisu/current/se_clear.rb delete mode 100644 lib/sisu/current/se_createsite.rb delete mode 100644 lib/sisu/current/se_css.rb delete mode 100644 lib/sisu/current/se_date.rb delete mode 100644 lib/sisu/current/se_db.rb delete mode 100644 lib/sisu/current/se_envcall.rb delete mode 100644 lib/sisu/current/se_file_op.rb delete mode 100644 lib/sisu/current/se_filemap.rb delete mode 100644 lib/sisu/current/se_get_init.rb delete mode 100644 lib/sisu/current/se_hub_particulars.rb delete mode 100644 lib/sisu/current/se_info_env.rb delete mode 100644 lib/sisu/current/se_info_port.rb delete mode 100644 lib/sisu/current/se_info_system.rb delete mode 100644 lib/sisu/current/se_load.rb delete mode 100644 lib/sisu/current/se_processing.rb delete mode 100644 lib/sisu/current/se_programs.rb delete mode 100644 lib/sisu/current/se_remotes.rb delete mode 100644 lib/sisu/current/se_standardise_lang.rb delete mode 100644 lib/sisu/current/se_version.rb delete mode 100644 lib/sisu/current/shared_images.rb delete mode 100644 lib/sisu/current/shared_markup_alt.rb delete mode 100644 lib/sisu/current/shared_metadata.rb delete mode 100644 lib/sisu/current/shared_sem.rb delete mode 100644 lib/sisu/current/sisu_thor_lib.rb delete mode 100644 lib/sisu/current/sitemaps.rb delete mode 100644 lib/sisu/current/src_kdissert_share.rb delete mode 100644 lib/sisu/current/src_po4a_share.rb delete mode 100644 lib/sisu/current/src_po4a_shelf.rb delete mode 100644 lib/sisu/current/src_po4a_shelf_set.rb delete mode 100644 lib/sisu/current/src_po4a_sst_ao_sst.rb delete mode 100644 lib/sisu/current/src_po4a_sst_ao_sst_set.rb delete mode 100644 lib/sisu/current/src_po4a_sstm.rb delete mode 100644 lib/sisu/current/src_shared.rb delete mode 100644 lib/sisu/current/src_sisupod_make.rb delete mode 100644 lib/sisu/current/src_sisupod_sstm.rb delete mode 100644 lib/sisu/current/sst_convert_markup.rb delete mode 100644 lib/sisu/current/sst_do_inline_footnotes.rb delete mode 100644 lib/sisu/current/sst_from_xml.rb delete mode 100644 lib/sisu/current/sst_identify_markup.rb delete mode 100644 lib/sisu/current/sst_to_s_xml_sax.rb delete mode 100644 lib/sisu/current/termsheet.rb delete mode 100644 lib/sisu/current/texinfo.rb delete mode 100644 lib/sisu/current/texinfo_format.rb delete mode 100644 lib/sisu/current/texpdf.rb delete mode 100644 lib/sisu/current/texpdf_format.rb delete mode 100644 lib/sisu/current/texpdf_parts.rb delete mode 100644 lib/sisu/current/txt_asciidoc.rb delete mode 100644 lib/sisu/current/txt_asciidoc_decorate.rb delete mode 100644 lib/sisu/current/txt_markdown.rb delete mode 100644 lib/sisu/current/txt_markdown_decorate.rb delete mode 100644 lib/sisu/current/txt_orgmode.rb delete mode 100644 lib/sisu/current/txt_orgmode_decorate.rb delete mode 100644 lib/sisu/current/txt_output.rb delete mode 100644 lib/sisu/current/txt_plain.rb delete mode 100644 lib/sisu/current/txt_plain_decorate.rb delete mode 100644 lib/sisu/current/txt_read.rb delete mode 100644 lib/sisu/current/txt_rst.rb delete mode 100644 lib/sisu/current/txt_rst_decorate.rb delete mode 100644 lib/sisu/current/txt_shared.rb delete mode 100644 lib/sisu/current/txt_textile.rb delete mode 100644 lib/sisu/current/txt_textile_decorate.rb delete mode 100644 lib/sisu/current/update.rb delete mode 100644 lib/sisu/current/urls.rb delete mode 100644 lib/sisu/current/utils.rb delete mode 100644 lib/sisu/current/utils_composite.rb delete mode 100644 lib/sisu/current/utils_response.rb delete mode 100644 lib/sisu/current/utils_screen_text_color.rb delete mode 100644 lib/sisu/current/utils_spell.rb delete mode 100644 lib/sisu/current/webrick.rb delete mode 100644 lib/sisu/current/wikispeak.rb delete mode 100644 lib/sisu/current/xhtml.rb delete mode 100644 lib/sisu/current/xhtml_epub2.rb delete mode 100644 lib/sisu/current/xhtml_epub2_concordance.rb delete mode 100644 lib/sisu/current/xhtml_epub2_format.rb delete mode 100644 lib/sisu/current/xhtml_epub2_persist.rb delete mode 100644 lib/sisu/current/xhtml_epub2_segments.rb delete mode 100644 lib/sisu/current/xhtml_epub2_tune.rb delete mode 100644 lib/sisu/current/xhtml_parts.rb delete mode 100644 lib/sisu/current/xhtml_shared.rb delete mode 100644 lib/sisu/current/xhtml_table.rb delete mode 100644 lib/sisu/current/xml_docbook5.rb delete mode 100644 lib/sisu/current/xml_dom.rb delete mode 100644 lib/sisu/current/xml_fictionbook2.rb delete mode 100644 lib/sisu/current/xml_format.rb delete mode 100644 lib/sisu/current/xml_md_oai_pmh_dc.rb delete mode 100644 lib/sisu/current/xml_odf_odt.rb delete mode 100644 lib/sisu/current/xml_odf_odt_format.rb delete mode 100644 lib/sisu/current/xml_parts.rb delete mode 100644 lib/sisu/current/xml_persist.rb delete mode 100644 lib/sisu/current/xml_sax.rb delete mode 100644 lib/sisu/current/xml_scaffold_structure_collapsed.rb delete mode 100644 lib/sisu/current/xml_scaffold_structure_sisu.rb delete mode 100644 lib/sisu/current/xml_shared.rb delete mode 100644 lib/sisu/current/xml_tables.rb delete mode 100644 lib/sisu/current/zap.rb create mode 100644 lib/sisu/db_columns.rb create mode 100644 lib/sisu/db_create.rb create mode 100644 lib/sisu/db_dbi.rb create mode 100644 lib/sisu/db_drop.rb create mode 100644 lib/sisu/db_import.rb create mode 100644 lib/sisu/db_indexes.rb create mode 100644 lib/sisu/db_load_tuple.rb create mode 100644 lib/sisu/db_remove.rb create mode 100644 lib/sisu/db_select.rb create mode 100644 lib/sisu/db_sqltxt.rb create mode 100644 lib/sisu/db_tests.rb create mode 100644 lib/sisu/dbi.rb create mode 100644 lib/sisu/dbi_discrete.rb delete mode 100644 lib/sisu/develop/air.rb delete mode 100644 lib/sisu/develop/ao.rb delete mode 100644 lib/sisu/develop/ao_character_check.rb delete mode 100644 lib/sisu/develop/ao_composite.rb delete mode 100644 lib/sisu/develop/ao_doc_objects.rb delete mode 100644 lib/sisu/develop/ao_doc_str.rb delete mode 100644 lib/sisu/develop/ao_endnotes.rb delete mode 100644 lib/sisu/develop/ao_expand_insertions.rb delete mode 100644 lib/sisu/develop/ao_hash_digest.rb delete mode 100644 lib/sisu/develop/ao_idx.rb delete mode 100644 lib/sisu/develop/ao_images.rb delete mode 100644 lib/sisu/develop/ao_metadata.rb delete mode 100644 lib/sisu/develop/ao_misc_arrange.rb delete mode 100644 lib/sisu/develop/ao_numbering.rb delete mode 100644 lib/sisu/develop/ao_persist.rb delete mode 100644 lib/sisu/develop/ao_references.rb delete mode 100644 lib/sisu/develop/ao_syntax.rb delete mode 100644 lib/sisu/develop/cgi.rb delete mode 100644 lib/sisu/develop/cgi_pgsql.rb delete mode 100644 lib/sisu/develop/cgi_sql_common.rb delete mode 100644 lib/sisu/develop/cgi_sqlite.rb delete mode 100644 lib/sisu/develop/conf.rb delete mode 100644 lib/sisu/develop/constants.rb delete mode 100644 lib/sisu/develop/css.rb delete mode 100644 lib/sisu/develop/db_columns.rb delete mode 100644 lib/sisu/develop/db_create.rb delete mode 100644 lib/sisu/develop/db_dbi.rb delete mode 100644 lib/sisu/develop/db_drop.rb delete mode 100644 lib/sisu/develop/db_import.rb delete mode 100644 lib/sisu/develop/db_indexes.rb delete mode 100644 lib/sisu/develop/db_load_tuple.rb delete mode 100644 lib/sisu/develop/db_remove.rb delete mode 100644 lib/sisu/develop/db_select.rb delete mode 100644 lib/sisu/develop/db_sqltxt.rb delete mode 100644 lib/sisu/develop/db_tests.rb delete mode 100644 lib/sisu/develop/dbi.rb delete mode 100644 lib/sisu/develop/dbi_discrete.rb delete mode 100644 lib/sisu/develop/digests.rb delete mode 100644 lib/sisu/develop/dp.rb delete mode 100644 lib/sisu/develop/dp_identify_markup.rb delete mode 100644 lib/sisu/develop/dp_make.rb delete mode 100644 lib/sisu/develop/embedded.rb delete mode 100644 lib/sisu/develop/errors.rb delete mode 100644 lib/sisu/develop/generic_parts.rb delete mode 100644 lib/sisu/develop/git.rb delete mode 100644 lib/sisu/develop/html.rb delete mode 100644 lib/sisu/develop/html_concordance.rb delete mode 100644 lib/sisu/develop/html_format.rb delete mode 100644 lib/sisu/develop/html_harvest.rb delete mode 100644 lib/sisu/develop/html_harvest_author_format.rb delete mode 100644 lib/sisu/develop/html_harvest_authors.rb delete mode 100644 lib/sisu/develop/html_harvest_topics.rb delete mode 100644 lib/sisu/develop/html_lite_shared.rb delete mode 100644 lib/sisu/develop/html_manifest.rb delete mode 100644 lib/sisu/develop/html_minitoc.rb delete mode 100644 lib/sisu/develop/html_parts.rb delete mode 100644 lib/sisu/develop/html_persist.rb delete mode 100644 lib/sisu/develop/html_promo.rb delete mode 100644 lib/sisu/develop/html_scroll.rb delete mode 100644 lib/sisu/develop/html_segments.rb delete mode 100644 lib/sisu/develop/html_shared.rb delete mode 100644 lib/sisu/develop/html_table.rb delete mode 100644 lib/sisu/develop/html_tune.rb delete mode 100644 lib/sisu/develop/hub.rb delete mode 100644 lib/sisu/develop/hub_actions.rb delete mode 100644 lib/sisu/develop/hub_loop_markup_files.rb delete mode 100644 lib/sisu/develop/hub_options.rb delete mode 100644 lib/sisu/develop/i18n.rb delete mode 100644 lib/sisu/develop/manpage.rb delete mode 100644 lib/sisu/develop/manpage_format.rb delete mode 100644 lib/sisu/develop/object_munge.rb delete mode 100644 lib/sisu/develop/prog_text_translation.rb delete mode 100644 lib/sisu/develop/qrcode.rb delete mode 100644 lib/sisu/develop/relaxng.rb delete mode 100644 lib/sisu/develop/remote.rb delete mode 100644 lib/sisu/develop/rexml.rb delete mode 100644 lib/sisu/develop/se.rb delete mode 100644 lib/sisu/develop/se_cleanoutput.rb delete mode 100644 lib/sisu/develop/se_clear.rb delete mode 100644 lib/sisu/develop/se_createsite.rb delete mode 100644 lib/sisu/develop/se_css.rb delete mode 100644 lib/sisu/develop/se_date.rb delete mode 100644 lib/sisu/develop/se_db.rb delete mode 100644 lib/sisu/develop/se_envcall.rb delete mode 100644 lib/sisu/develop/se_file_op.rb delete mode 100644 lib/sisu/develop/se_filemap.rb delete mode 100644 lib/sisu/develop/se_get_init.rb delete mode 100644 lib/sisu/develop/se_hub_particulars.rb delete mode 100644 lib/sisu/develop/se_info_env.rb delete mode 100644 lib/sisu/develop/se_info_port.rb delete mode 100644 lib/sisu/develop/se_info_system.rb delete mode 100644 lib/sisu/develop/se_load.rb delete mode 100644 lib/sisu/develop/se_processing.rb delete mode 100644 lib/sisu/develop/se_programs.rb delete mode 100644 lib/sisu/develop/se_remotes.rb delete mode 100644 lib/sisu/develop/se_standardise_lang.rb delete mode 100644 lib/sisu/develop/se_version.rb delete mode 100644 lib/sisu/develop/shared_images.rb delete mode 100644 lib/sisu/develop/shared_markup_alt.rb delete mode 100644 lib/sisu/develop/shared_metadata.rb delete mode 100644 lib/sisu/develop/shared_sem.rb delete mode 100644 lib/sisu/develop/sisu_thor_lib.rb delete mode 100644 lib/sisu/develop/sitemaps.rb delete mode 100644 lib/sisu/develop/src_kdissert_share.rb delete mode 100644 lib/sisu/develop/src_po4a_share.rb delete mode 100644 lib/sisu/develop/src_po4a_shelf.rb delete mode 100644 lib/sisu/develop/src_po4a_shelf_set.rb delete mode 100644 lib/sisu/develop/src_po4a_sst_ao_sst.rb delete mode 100644 lib/sisu/develop/src_po4a_sst_ao_sst_set.rb delete mode 100644 lib/sisu/develop/src_po4a_sstm.rb delete mode 100644 lib/sisu/develop/src_shared.rb delete mode 100644 lib/sisu/develop/src_sisupod_make.rb delete mode 100644 lib/sisu/develop/src_sisupod_sstm.rb delete mode 100644 lib/sisu/develop/sst_convert_markup.rb delete mode 100644 lib/sisu/develop/sst_do_inline_footnotes.rb delete mode 100644 lib/sisu/develop/sst_from_xml.rb delete mode 100644 lib/sisu/develop/sst_identify_markup.rb delete mode 100644 lib/sisu/develop/sst_to_s_xml_sax.rb delete mode 100644 lib/sisu/develop/termsheet.rb delete mode 100644 lib/sisu/develop/texinfo.rb delete mode 100644 lib/sisu/develop/texinfo_format.rb delete mode 100644 lib/sisu/develop/texpdf.rb delete mode 100644 lib/sisu/develop/texpdf_format.rb delete mode 100644 lib/sisu/develop/texpdf_parts.rb delete mode 100644 lib/sisu/develop/txt_asciidoc.rb delete mode 100644 lib/sisu/develop/txt_asciidoc_decorate.rb delete mode 100644 lib/sisu/develop/txt_markdown.rb delete mode 100644 lib/sisu/develop/txt_markdown_decorate.rb delete mode 100644 lib/sisu/develop/txt_orgmode.rb delete mode 100644 lib/sisu/develop/txt_orgmode_decorate.rb delete mode 100644 lib/sisu/develop/txt_output.rb delete mode 100644 lib/sisu/develop/txt_plain.rb delete mode 100644 lib/sisu/develop/txt_plain_decorate.rb delete mode 100644 lib/sisu/develop/txt_read.rb delete mode 100644 lib/sisu/develop/txt_rst.rb delete mode 100644 lib/sisu/develop/txt_rst_decorate.rb delete mode 100644 lib/sisu/develop/txt_shared.rb delete mode 100644 lib/sisu/develop/txt_textile.rb delete mode 100644 lib/sisu/develop/txt_textile_decorate.rb delete mode 100644 lib/sisu/develop/update.rb delete mode 100644 lib/sisu/develop/urls.rb delete mode 100644 lib/sisu/develop/utils.rb delete mode 100644 lib/sisu/develop/utils_composite.rb delete mode 100644 lib/sisu/develop/utils_response.rb delete mode 100644 lib/sisu/develop/utils_screen_text_color.rb delete mode 100644 lib/sisu/develop/utils_spell.rb delete mode 100644 lib/sisu/develop/webrick.rb delete mode 100644 lib/sisu/develop/wikispeak.rb delete mode 100644 lib/sisu/develop/xhtml.rb delete mode 100644 lib/sisu/develop/xhtml_epub2.rb delete mode 100644 lib/sisu/develop/xhtml_epub2_concordance.rb delete mode 100644 lib/sisu/develop/xhtml_epub2_format.rb delete mode 100644 lib/sisu/develop/xhtml_epub2_persist.rb delete mode 100644 lib/sisu/develop/xhtml_epub2_segments.rb delete mode 100644 lib/sisu/develop/xhtml_epub2_tune.rb delete mode 100644 lib/sisu/develop/xhtml_parts.rb delete mode 100644 lib/sisu/develop/xhtml_shared.rb delete mode 100644 lib/sisu/develop/xhtml_table.rb delete mode 100644 lib/sisu/develop/xml_docbook5.rb delete mode 100644 lib/sisu/develop/xml_dom.rb delete mode 100644 lib/sisu/develop/xml_fictionbook2.rb delete mode 100644 lib/sisu/develop/xml_format.rb delete mode 100644 lib/sisu/develop/xml_md_oai_pmh_dc.rb delete mode 100644 lib/sisu/develop/xml_odf_odt.rb delete mode 100644 lib/sisu/develop/xml_odf_odt_format.rb delete mode 100644 lib/sisu/develop/xml_parts.rb delete mode 100644 lib/sisu/develop/xml_persist.rb delete mode 100644 lib/sisu/develop/xml_sax.rb delete mode 100644 lib/sisu/develop/xml_scaffold_structure_collapsed.rb delete mode 100644 lib/sisu/develop/xml_scaffold_structure_sisu.rb delete mode 100644 lib/sisu/develop/xml_shared.rb delete mode 100644 lib/sisu/develop/xml_tables.rb delete mode 100644 lib/sisu/develop/zap.rb create mode 100644 lib/sisu/digests.rb create mode 100644 lib/sisu/dp.rb create mode 100644 lib/sisu/dp_identify_markup.rb create mode 100644 lib/sisu/dp_make.rb create mode 100644 lib/sisu/embedded.rb create mode 100644 lib/sisu/errors.rb create mode 100644 lib/sisu/generic_parts.rb create mode 100644 lib/sisu/git.rb create mode 100644 lib/sisu/html.rb create mode 100644 lib/sisu/html_concordance.rb create mode 100644 lib/sisu/html_format.rb create mode 100644 lib/sisu/html_harvest.rb create mode 100644 lib/sisu/html_harvest_author_format.rb create mode 100644 lib/sisu/html_harvest_authors.rb create mode 100644 lib/sisu/html_harvest_topics.rb create mode 100644 lib/sisu/html_lite_shared.rb create mode 100644 lib/sisu/html_manifest.rb create mode 100644 lib/sisu/html_minitoc.rb create mode 100644 lib/sisu/html_parts.rb create mode 100644 lib/sisu/html_persist.rb create mode 100644 lib/sisu/html_promo.rb create mode 100644 lib/sisu/html_scroll.rb create mode 100644 lib/sisu/html_segments.rb create mode 100644 lib/sisu/html_shared.rb create mode 100644 lib/sisu/html_table.rb create mode 100644 lib/sisu/html_tune.rb create mode 100644 lib/sisu/hub.rb create mode 100644 lib/sisu/hub_actions.rb create mode 100644 lib/sisu/hub_loop_markup_files.rb create mode 100644 lib/sisu/hub_options.rb create mode 100644 lib/sisu/i18n.rb create mode 100644 lib/sisu/manpage.rb create mode 100644 lib/sisu/manpage_format.rb create mode 100644 lib/sisu/object_munge.rb create mode 100644 lib/sisu/prog_text_translation.rb create mode 100644 lib/sisu/qrcode.rb create mode 100644 lib/sisu/relaxng.rb create mode 100644 lib/sisu/remote.rb create mode 100644 lib/sisu/rexml.rb create mode 100644 lib/sisu/se.rb create mode 100644 lib/sisu/se_cleanoutput.rb create mode 100644 lib/sisu/se_clear.rb create mode 100644 lib/sisu/se_createsite.rb create mode 100644 lib/sisu/se_css.rb create mode 100644 lib/sisu/se_date.rb create mode 100644 lib/sisu/se_db.rb create mode 100644 lib/sisu/se_envcall.rb create mode 100644 lib/sisu/se_file_op.rb create mode 100644 lib/sisu/se_filemap.rb create mode 100644 lib/sisu/se_get_init.rb create mode 100644 lib/sisu/se_hub_particulars.rb create mode 100644 lib/sisu/se_info_env.rb create mode 100644 lib/sisu/se_info_port.rb create mode 100644 lib/sisu/se_info_system.rb create mode 100644 lib/sisu/se_load.rb create mode 100644 lib/sisu/se_processing.rb create mode 100644 lib/sisu/se_programs.rb create mode 100644 lib/sisu/se_remotes.rb create mode 100644 lib/sisu/se_standardise_lang.rb create mode 100644 lib/sisu/se_version.rb create mode 100644 lib/sisu/shared_images.rb create mode 100644 lib/sisu/shared_markup_alt.rb create mode 100644 lib/sisu/shared_metadata.rb create mode 100644 lib/sisu/shared_sem.rb create mode 100644 lib/sisu/sisu_thor_lib.rb create mode 100644 lib/sisu/sitemaps.rb create mode 100644 lib/sisu/src_kdissert_share.rb create mode 100644 lib/sisu/src_po4a_share.rb create mode 100644 lib/sisu/src_po4a_shelf.rb create mode 100644 lib/sisu/src_po4a_shelf_set.rb create mode 100644 lib/sisu/src_po4a_sst_ao_sst.rb create mode 100644 lib/sisu/src_po4a_sst_ao_sst_set.rb create mode 100644 lib/sisu/src_po4a_sstm.rb create mode 100644 lib/sisu/src_shared.rb create mode 100644 lib/sisu/src_sisupod_make.rb create mode 100644 lib/sisu/src_sisupod_sstm.rb create mode 100644 lib/sisu/sst_convert_markup.rb create mode 100644 lib/sisu/sst_do_inline_footnotes.rb create mode 100644 lib/sisu/sst_from_xml.rb create mode 100644 lib/sisu/sst_identify_markup.rb create mode 100644 lib/sisu/sst_to_s_xml_sax.rb create mode 100644 lib/sisu/termsheet.rb create mode 100644 lib/sisu/texinfo.rb create mode 100644 lib/sisu/texinfo_format.rb create mode 100644 lib/sisu/texpdf.rb create mode 100644 lib/sisu/texpdf_format.rb create mode 100644 lib/sisu/texpdf_parts.rb create mode 100644 lib/sisu/txt_asciidoc.rb create mode 100644 lib/sisu/txt_asciidoc_decorate.rb create mode 100644 lib/sisu/txt_markdown.rb create mode 100644 lib/sisu/txt_markdown_decorate.rb create mode 100644 lib/sisu/txt_orgmode.rb create mode 100644 lib/sisu/txt_orgmode_decorate.rb create mode 100644 lib/sisu/txt_output.rb create mode 100644 lib/sisu/txt_plain.rb create mode 100644 lib/sisu/txt_plain_decorate.rb create mode 100644 lib/sisu/txt_read.rb create mode 100644 lib/sisu/txt_rst.rb create mode 100644 lib/sisu/txt_rst_decorate.rb create mode 100644 lib/sisu/txt_shared.rb create mode 100644 lib/sisu/txt_textile.rb create mode 100644 lib/sisu/txt_textile_decorate.rb create mode 100644 lib/sisu/update.rb create mode 100644 lib/sisu/urls.rb create mode 100644 lib/sisu/utils.rb create mode 100644 lib/sisu/utils_composite.rb create mode 100644 lib/sisu/utils_response.rb create mode 100644 lib/sisu/utils_screen_text_color.rb create mode 100644 lib/sisu/utils_spell.rb create mode 100644 lib/sisu/webrick.rb create mode 100644 lib/sisu/wikispeak.rb create mode 100644 lib/sisu/xhtml.rb create mode 100644 lib/sisu/xhtml_epub2.rb create mode 100644 lib/sisu/xhtml_epub2_concordance.rb create mode 100644 lib/sisu/xhtml_epub2_format.rb create mode 100644 lib/sisu/xhtml_epub2_persist.rb create mode 100644 lib/sisu/xhtml_epub2_segments.rb create mode 100644 lib/sisu/xhtml_epub2_tune.rb create mode 100644 lib/sisu/xhtml_parts.rb create mode 100644 lib/sisu/xhtml_shared.rb create mode 100644 lib/sisu/xhtml_table.rb create mode 100644 lib/sisu/xml_docbook5.rb create mode 100644 lib/sisu/xml_dom.rb create mode 100644 lib/sisu/xml_fictionbook2.rb create mode 100644 lib/sisu/xml_format.rb create mode 100644 lib/sisu/xml_md_oai_pmh_dc.rb create mode 100644 lib/sisu/xml_odf_odt.rb create mode 100644 lib/sisu/xml_odf_odt_format.rb create mode 100644 lib/sisu/xml_parts.rb create mode 100644 lib/sisu/xml_persist.rb create mode 100644 lib/sisu/xml_sax.rb create mode 100644 lib/sisu/xml_scaffold_structure_collapsed.rb create mode 100644 lib/sisu/xml_scaffold_structure_sisu.rb create mode 100644 lib/sisu/xml_shared.rb create mode 100644 lib/sisu/xml_tables.rb create mode 100644 lib/sisu/zap.rb delete mode 120000 man/man1/sisu5.1 delete mode 120000 man/man1/sisu6.1 diff --git a/bin/sisu b/bin/sisu index f7c36bb3..6b18e592 100755 --- a/bin/sisu +++ b/bin/sisu @@ -8,23 +8,8 @@ class Orient super() @called_as,@argv=$0,$* end - def version - def stable - '5' - end - def unstable - '6' - end - def default - unstable - end - def current - 'current' - end - def next - 'next' - end - self + def version_major + '7' end def sisu_called_from_directory @@sisu_called_from_directory ||= Dir.pwd @@ -35,7 +20,7 @@ class Orient :full_path_to_sisu_bin_in_sisu_dir_tree elsif processing.sisu_runtime_path =~/\/gems\// \ and processing.sisu_runtime_path \ - =~ /\/sisu-[#{version.stable}#{version.unstable}]\.(?:\d+|[a-z])\.(?:\d+|[a-z])\// + =~ /\/sisu-(?:\d+|[a-z])\.(?:\d+|[a-z])\.(?:\d+|[a-z])\// :gem_install else :system_install @@ -54,112 +39,34 @@ class Orient def sisu_runtime_path __FILE__ end - def stable - 'v' + version.stable - end - def unstable - 'v' + version.unstable - end - def default - 'v' + version.default - end - def current - 'current' - end - def next - 'develop' - end - def stable_bin_file_regex - %r{\bsisu#{version.stable}$} + def bin_file_regex + %r{\bsisu$} end - def unstable_bin_file_regex - %r{\bsisu#{version.unstable}$} - end - def stable_gem_regex - %r{\/sisu-#{version.stable}\.(?:\d+|[a-z])\.(?:\d+|[a-z])\/} - end - def unstable_gem_regex - %r{\/sisu-#{version.unstable}\.(?:\d+|[a-z])\.(?:\d+|[a-z])\/} - end - def stable_modifier_regex - %r{"(?:--v#{version.stable}|--current|--stable|--release)"} - end - def unstable_modifier_regex - %r{"(?:--v#{version.unstable}|--next|--unstable|--dev)"} + def gem_regex + %r{\/sisu-(?:\d+|[a-z])\.(?:\d+|[a-z])\.(?:\d+|[a-z])\/} end self end def sisu_lib - "sisu/#{branch_name_}" - end - def sisu_path_lib - if sisu_path_specified_lib \ - && FileTest.file?("#{sisu_path_specified_lib}/#{sisu_lib}/hub.rb") - "#{sisu_path_specified_lib}/#{sisu_lib}" - else sisu_lib - end + 'sisu' end def sisu_version_info_path - "#{sisu_path_base_system_data}/version/#{branch_name?}.yml" - end - def branch_name_ - if sisu_run_from? == :full_path_to_sisu_bin_in_sisu_dir_tree \ - or sisu_run_from? == :system_install - case processing.called_as - when processing.stable_bin_file_regex then processing.current - when processing.unstable_bin_file_regex then processing.next - else - case processing.argv_str - when processing.stable_modifier_regex then processing.current - when processing.unstable_modifier_regex then processing.next - else processing.current - end - end - elsif sisu_run_from? == :gem_install - case processing.sisu_runtime_path - when processing.stable_gem_regex then processing.current - when processing.unstable_gem_regex then processing.next - else processing.current - end - else processing.current - end - end - def branch_version_ - if sisu_run_from? == :full_path_to_sisu_bin_in_sisu_dir_tree \ - or sisu_run_from? == :system_install - case processing.called_as - when processing.stable_bin_file_regex then processing.stable - when processing.unstable_bin_file_regex then processing.unstable - else - case processing.argv_str - when processing.stable_modifier_regex then processing.stable - when processing.unstable_modifier_regex then processing.unstable - else processing.stable - end - end - elsif sisu_run_from? == :gem_install - case processing.sisu_runtime_path - when processing.stable_gem_regex then processing.stable - when processing.unstable_gem_regex then processing.unstable - else processing.stable - end - else processing.stable - end + "#{sisu_path_base_system_data}/version.yml" end def paths_set if sisu_run_from? == :system_install \ and processing.called_as \ - =~ /^#{RbConfig::CONFIG['bindir']}\/sisu[#{version.stable}#{version.unstable}]?$/ + =~ /^#{RbConfig::CONFIG['bindir']}\/sisu$/ :set_path_system elsif sisu_run_from? == :full_path_to_sisu_bin_in_sisu_dir_tree \ and processing.called_as \ - !~ /^#{RbConfig::CONFIG['bindir']}\/sisu[#{version.stable}#{version.unstable}]?$/ \ + !~ /^#{RbConfig::CONFIG['bindir']}\/sisu$/ \ && File.expand_path(processing.called_as) \ - =~ /bin\/sisu[#{version.stable}#{version.unstable}]?$/ \ + =~ /bin\/sisu$/ \ && FileTest.file?(processing.called_as) :set_dir_tree_full_path elsif sisu_run_from? ==:gem_install - :set_gem_path + :set_path_gem else nil end end @@ -188,8 +95,8 @@ class Orient RbConfig::CONFIG['datadir'] + '/sisu' when :set_dir_tree_full_path File.expand_path(processing.called_as). - sub(/\/bin\/sisu[#{version.stable}#{version.unstable}]?$/,'') - when :set_gem_path + sub(/\/bin\/sisu$/,'') + when :set_path_gem Gem::Specification.find_by_name("sisu").gem_dir else nil end @@ -200,18 +107,44 @@ class Orient RbConfig::CONFIG['datadir'] + '/sisu' when :set_dir_tree_full_path File.expand_path(processing.called_as). - sub(/\/bin\/sisu[#{version.stable}#{version.unstable}]?$/,'/data/sisu') - when :set_gem_path + sub(/\/bin\/sisu$/,'/data/sisu') + when :set_path_gem Gem::Specification.find_by_name("sisu").gem_dir + '/data/sisu' else nil end end - def sisu_path_specified_lib + def sisu_this_lib + if processing.sisu_runtime_path =~/\/gems\// \ + and processing.sisu_runtime_path \ + =~ /\/sisu-(?:\d+|[a-z])\.(?:\d+|[a-z])\.(?:\d+|[a-z])\// + # gem sought + processing.sisu_runtime_path. + gsub(/\/bin\/sisu[a-z0-7_-]*$/,'/lib/sisu') + elsif (processing.called_as \ + !~ /^#{RbConfig::CONFIG['bindir']}\/sisu$/) + # called off file system, project directory tree + File.expand_path(processing.called_as). + sub(/bin\/sisu\S*/,'lib/sisu') + else + # distro installation + sisulib={ + vendorlib: RbConfig::CONFIG['vendordir'] + '/sisu', + sitelib: RbConfig::CONFIG['sitelibdir'] + '/sisu', + } + if FileTest.directory?(sisulib[:sitelib]) # Arch Linux; Debian local + sisulib[:sitelib] + elsif FileTest.directory?(sisulib[:vendorlib]) # Debian GNU Linux system + sisulib[:vendorlib] + else 'sisu' # assume lib paths work + end + end + end + def sisu_this_lib_ if (processing.called_as \ - !~ /^#{RbConfig::CONFIG['bindir']}\/sisu[#{version.stable}#{version.unstable}]?$/) + !~ /^#{RbConfig::CONFIG['bindir']}\/sisu$/) File.expand_path(processing.called_as). - sub(/bin\/sisu[#{version.stable}#{version.unstable}]?$/,'lib') - else nil + sub(/bin\/sisu\S*/,'lib/sisu') + else 'sisu' end end def language_list @@ -224,8 +157,11 @@ class Orient self end def sisu_is + def version_major? + version_major + end def runtime_path? - sisu_runtime_path + processing.sisu_runtime_path end def runtime_type? sisu_run_from? @@ -233,21 +169,12 @@ class Orient def called_from? sisu_called_from_directory end - def branch_name? - branch_name_ - end - def branch_version? - branch_version_ - end def path_base? sisu_path_base end def path_base_system_data? sisu_path_base_system_data end - def path_lib? - sisu_path_lib - end def version_info_path? sisu_version_info_path end @@ -309,7 +236,7 @@ class Orient self end def control - require "#{sisu_is.path_lib?}/hub" + require sisu_this_lib sisu_called_from_directory begin if get_processing_info.processing_files.length > 0 @@ -322,7 +249,7 @@ class Orient Dir.chdir(markup_dir) $sisu_document_markup_directory_base_fixed_path= Dir.pwd.gsub(/\/(?:#{language_list.regex})$/,'') - SiSU::HubMaster.new(argv_sub,sisu_is.runtime?) + SiSU_libs::CallHubMaster.new(argv_sub,sisu_is.runtime?) elsif markup_dir =~/https?:/ markup_file.each do |mf| (FileTest.file?(mf)) \ @@ -333,7 +260,7 @@ class Orient $sisu_document_markup_directory_base_fixed_path= Dir.pwd.gsub(/\/(?:#{language_list.regex})$/,'') argv_sub=command_line_modifiers + markup_file - SiSU::HubMaster.new(argv_sub,sisu_is.runtime?) + SiSU_libs::CallHubMaster.new(argv_sub,sisu_is.runtime?) else p "Error directory specified #{markup_dir} not found" end ensure @@ -345,11 +272,11 @@ class Orient $sisu_document_markup_directory=Dir.pwd.gsub(/\/$/,'') $sisu_document_markup_directory_base_fixed_path= Dir.pwd.gsub(/(^|\/)(?:#{language_list.regex})$/,'') - SiSU::HubMaster.new(processing.argv,sisu_is.runtime?) + SiSU_libs::CallHubMaster.new(processing.argv,sisu_is.runtime?) end rescue ensure - SiSU::HubClose.new(sisu_called_from_directory,@argv) + SiSU_libs::HubClose.new(@argv,sisu_called_from_directory) Dir.chdir(sisu_called_from_directory) system("cd #{sisu_called_from_directory}") end @@ -358,7 +285,6 @@ end #% sisu select source & branch, begin $VERBOSE=nil require 'rbconfig' -require 'rubygems' begin require 'singleton' s=Orient.instance @@ -369,14 +295,15 @@ rescue #% - STDERR.puts $! STDERR.puts $@ puts %{ - #{%x{ruby -v}.strip.to_s} - #{RUBY_VERSION} - ruby version: #{RbConfig::CONFIG['RUBY_PROGRAM_VERSION']}p#{RbConfig::CONFIG['PATCHLEVEL']} - ruby named: #{RbConfig::CONFIG['ruby_version']} - rubylib: #{RbConfig::CONFIG['rubylibdir']} - rubylib local: #{RbConfig::CONFIG['sitelibdir']} - gem dir: #{Gem.dir} - gem path: #{Gem.path} + #{%x{ruby -v}.strip.to_s} + #{RUBY_VERSION} + ruby version: #{RbConfig::CONFIG['RUBY_PROGRAM_VERSION']}p#{RbConfig::CONFIG['PATCHLEVEL']} + ruby named: #{RbConfig::CONFIG['ruby_version']} + rubylib: #{RbConfig::CONFIG['rubylibdir']} + vendor lib #{RbConfig::CONFIG['vendordir']} + site lib local: #{RbConfig::CONFIG['sitelibdir']} + gem dir: #{Gem.dir} + gem path: #{Gem.path} } system(%{echo " system RUBYPATH: ${RUBYPATH} diff --git a/bin/sisu5 b/bin/sisu5 deleted file mode 120000 index b4999d51..00000000 --- a/bin/sisu5 +++ /dev/null @@ -1 +0,0 @@ -sisu \ No newline at end of file diff --git a/bin/sisu6 b/bin/sisu6 deleted file mode 120000 index b4999d51..00000000 --- a/bin/sisu6 +++ /dev/null @@ -1 +0,0 @@ -sisu \ No newline at end of file diff --git a/conf/sisu/sisurc.yml b/conf/sisu/sisurc.yml new file mode 100644 index 00000000..790eb315 --- /dev/null +++ b/conf/sisu/sisurc.yml @@ -0,0 +1,163 @@ +# Name: SiSU +# Author: ralph@amissah.com +# Description: Site wide environment defaults set here +# system environment info / resource configuration file, for sisu +# License: GPL v3 or later +# site environment configuration file +# this file should be configured and live in +# /etc/sisu #per environment settings, overridden by: +# ~/.sisu #per user settings, overridden by: +# ./_sisu #per local markup directory settings +#% #image source directory, main path and subdirectories +#image: +# path: 'sisu_working' +# public: '_sisu/image' +# #all: 'image' +#% presentation/web directory, main path and subdirectories (most subdirectories are created automatically based on markup directory name) +#webserv: +# url_root: 'http://www.your.url' #without dir stub +# path: '/var/www' #either (i) / [full path from root] or (ii) ~/ [home] or (iii) ./ [pwd] or (iv) will be made from home +# images: '_sisu/image' +# man: 'man' +# cgi: '/usr/lib/cgi-bin' +# feed: 'feed' +# sqlite: 'sisu/sqlite' +# webrick_url: true +#show_output_on: 'filesystem' #for -v and -u url information, alternatives: 'filesystem','webserver','remote_webserver','local:8111','localhost','localhost:8080','webrick','path' +#show_output_on: 'local:8111' +#webserv_cgi: +# host: localhost +# base_path: ~ +# port: '8081' +# user: ~ + +show_output_on: 'filesystem_url' +#texinfo display output +#texinfo: +# stub: 'texinfo' + +#% output_dir_structure_by: +# language (language and filetype directories); +# filetype (filetype directories, language code added to filename includes language code); +# filetype_mono or monolingual (filetype drectories, no language codes in filenames) +# filename (directory output similar to original v1 v2, filename includes language code); +# filename_mono (directory output similar to original v1 v2, filename without language code); +output_dir_structure_by: language # language filetype filetype_mono filename filename_mono + +##% processing directories, main path and subdirectories (appended to $HOME), using defaults set in sysenv +#processing: +# path: '~' +# dir: '.sisu_processing~' +# metaverse: 'metaverse' +# tune: 'tune' +# latex: 'tex' +# texinfo: 'texinfo' +# concord_max: 400000 + +#% flag - set (non-default) processing flag shortcuts -1, -2 etc. (here adding colour and verbosity as default) +flag: + color: true # making colour default -c is toggle, and will now toggle colour off +# act0: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --verbose' +# act1: '--manifest --text --html' +# act2: '--manifest --text --html --epub --pdf' +# act3: '--manifest --qrcode --text --html --epub --concordance --pdf' +# act4: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook' +# act5: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --sqlite' +# act6: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite' +# act7: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod' +# act8: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update' +# act9: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod' +## default: '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest --verbose' +## i: '--digest --qrcode --text --html --epub --concordance --pdf --manifest' +## ii: '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --manifest' +## iii: '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --manifest' +## iv: '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --manifest' +## v: '--digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod --manifest' + +#% papersize, (LaTeX/pdf) available values: A4, US_letter, book_b5, book_a5, US_legal +default: + papersize: 'a4,letter' #'a4,letter,b5,a5,legal' + #language: 'en' + #texpdf_font: 'Liberation Sans' # 'Liberation Sans' 'Liberation Serif' + #texpdf_font_mono: 'Liberation Mono' #'Inconsolata' + #text_wrap: 78 + #emphasis: 'bold' #make *{emphasis}* 'bold', 'italics' or 'underscore', default if not configured is 'bold' + #digest: 'sha' #sha is sha256, default is md5 + #multilingual: false + #language_file: 2 +#% markup, make *{emphasis}* 'bold' or 'italics', default if not configured is 'bold' + +#% settings used by ssh scp +#remote: +# - +# user: '[usrname]' +# host: '[remote.hostname]' +# path: '.' #no trailing slash eg 'sisu/www' +# - +# user: '[usrname]' +# host: '[remote.hostname]' +# path: '.' #no trailing slash eg 'sisu/www' + +#% webrick information +#webrick: +# port: '8081' + +#% sql database info, postgresql and sqlite +#db: +# share_source: false # boolean, default is false +# postgresql: +# port: # '[port (default is 5432)]' +# host: # '[if not localhost, provide host tcp/ip address or domain name]'' +# user: # '[(if different from user) provide username]' +# password: # '[password if required]' +# sqlite: +# path: ~ # './sisu_sqlite.db' +# port: "**" + +#html: +# quick_ref: true #default false +# seg_title_banner: true #default false +#odt: +# ocn: true +#plaintext: +# ocn: true + +permission_set: + zap: true + css_modify: true +# remote_base_site: true + +program_set: + rmagick: false +# wc: true +# editor: true +# postgresql: true +# sqlite: true +# tidy: true +# rexml: true +# pdflatex: true + +#program_select: +# editor: 'vim' #'gvim -c :R' +# pdf_viewer: 'evince' +# web_browser: 'iceweasel' +# console_web_browser: 'w3m' #'links2' #'elinks' #'w3m' #'lynx' #'links' +# odf_viewer: 'lowriter' #'oowriter' #'abiword' +# xml_viewer: 'xml-viewer' +# epub_viewer: 'ebook-viewer' #'calibre' #'fbreader' #'okular' +# info_viewer: 'pinfo -f' +# man: 'man' #'groff -man -Tascii' # 'nroff -man' + +#search: +# sisu: +# flag: true +# action: http://www.sisudoc.org/cgi-bin/sisu_v6c_sqlite.cgi +# action: http://localhost:8081/cgi-bin/sisu_pgsql.cgi +# action: http://192.168.1.108/cgi-bin/sisu_pgsql.cgi +# action: http://search.sisudoc.org +# db: sisu +# title: sample search form + +#promo: sisu_search_libre, sisu_icon, sisu, open_society, fsf, ruby + +#omit: minitoc diff --git a/conf/sisu/v5/sisurc.yml b/conf/sisu/v5/sisurc.yml deleted file mode 120000 index 53d85905..00000000 --- a/conf/sisu/v5/sisurc.yml +++ /dev/null @@ -1 +0,0 @@ -../rc/sisurc_default.yml \ No newline at end of file diff --git a/conf/sisu/v6/sisurc.yml b/conf/sisu/v6/sisurc.yml deleted file mode 120000 index 53d85905..00000000 --- a/conf/sisu/v6/sisurc.yml +++ /dev/null @@ -1 +0,0 @@ -../rc/sisurc_default.yml \ No newline at end of file diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index af735e3f..a6d552b9 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -5,20 +5,8 @@ SiSU CHANGELOG -*- mode: org; -*- * debian/changelog -v5 stable branch (v6 development branch) - markup rule change, document structure rule introduced: - [v5 branch to become stable shortly, posted with 5.2.3, 2014-01-20] - * single document root == document title == heading level A~ - * adds possible level D~ - (from 5.2 on (earlier v5 development branch insulated from v4)) -v4 stable branch supersedes & replaces v3 branch - [v4 branch closure imminent, v5 to become stable, posted with 4.2.20, - 2014-01-20] - initial goals: - * remove/retire "skins"; replace some functionality with headers and/or yml - file (consider header like syntax for document and site appearance info) - * bin/sisu $0 make possible to run sisu command on/within project dir tree - * bin/sisu $*, hub, make possible to specify dir path for markup files +v5 branch is removed; it is available in sisu < 5.9.0 +v4 branch is removed; it is available in sisu < 5.3.0 v3 branch is removed; it is available in sisu < 4.1.0 v2 branch is removed; it is available in sisu =< 3.3.2 @@ -32,7 +20,7 @@ v2 branch is removed; it is available in sisu =< 3.3.2 * Reverse Chronological: ---- HEAD --- +--- HEAD --- [closed] ** 5.9.0.orig.tar.xz (2015-04-21:16/2) http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_5.9.0 diff --git a/data/doc/sisu/CHANGELOG_v6 b/data/doc/sisu/CHANGELOG_v6 index e260b312..3b167c79 100644 --- a/data/doc/sisu/CHANGELOG_v6 +++ b/data/doc/sisu/CHANGELOG_v6 @@ -5,10 +5,9 @@ SiSU CHANGELOG -*- mode: org; -*- * debian/changelog -v6 branch for development and testing prior to roll-into v5, to provide v5 with - some insulation -v5 stable branch -v4 branch is removed; it is available in sisu < 4.2.20 +v6 branch is removed; it is available in sisu =< 6.5.0 +v5 branch is removed; it is available in sisu < 5.9.0 +v4 branch is removed; it is available in sisu < 5.3.0 v3 branch is removed; it is available in sisu < 4.1.0 v2 branch is removed; it is available in sisu =< 3.3.2 @@ -22,7 +21,7 @@ v2 branch is removed; it is available in sisu =< 3.3.2 * Reverse Chronological: ---- HEAD --- +--- HEAD --- [closed] ** 6.5.0.orig.tar.xz (2015-04-21:16/2) http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=log;h=refs/tags/sisu_6.4.1 diff --git a/data/doc/sisu/markup-samples/manual/_sisu/sisu_document_make b/data/doc/sisu/markup-samples/manual/_sisu/sisu_document_make index 5ffd7d14..080786e2 100644 --- a/data/doc/sisu/markup-samples/manual/_sisu/sisu_document_make +++ b/data/doc/sisu/markup-samples/manual/_sisu/sisu_document_make @@ -3,7 +3,7 @@ :breaks: new=C; break=1 :bold: /Debian|Ruby|SiSU/ :italics: /Linux|GPL|GPLv3|LaTeX|PostgreSQL|SQLite|SQL|Vim|ascii|plaintext|UTF-?8|HTML|XHTML|XML|EPUB|OpenDocument|ODF|ODT|PDF|pgSQL|TeXinfo|YAML|YML|OCN|object citation system|object citation numbering|granular search|Dublin Core/ - :substitute: /${sisu_stable}/,'5.6.2' /${sisu_dev}/,'6.2.3' /${debian_stable}/,'*{Wheezy}*' /${debian_testing}/,'*{Jessie}*' + :substitute: /${sisu_stable}/,'7.0.0' /${sisu_dev}/,'7.0.0' /${debian_stable}/,'*{Jessie}*' /${debian_testing}/,'*{Stretch}*' :home_button_text: {SiSU}http://sisudoc.org; {git}http://git.sisudoc.org :footer: {SiSU}http://sisudoc.org; {git}http://git.sisudoc.org diff --git a/data/doc/sisu/markup-samples/manual/_sisu/sisurc.yml b/data/doc/sisu/markup-samples/manual/_sisu/sisurc.yml new file mode 100644 index 00000000..3cb49894 --- /dev/null +++ b/data/doc/sisu/markup-samples/manual/_sisu/sisurc.yml @@ -0,0 +1,148 @@ +# Name: SiSU - Simple information Structuring Universe +# Author: ralph@amissah.com +# Description: Site wide environment defaults set here +# system environment info / resource configuration file, for sisu +# License: GPL v3 or later +# site environment configuration file +# this file should be configured and live in +# /etc/sisu #per environment settings, overridden by: +# ~/.sisu #per user settings, overridden by: +# ./_sisu #per local markup directory settings +#% #image source directory, main path and subdirectories +#image: +# path: 'sisu_working' +# public: '_sisu/image' +# #all: 'image' +#% presentation/web directory, main path and subdirectories (most subdirectories are created automatically based on markup directory name) +#webserv: +# url_root: 'http://www.your.url' #url to document root, without dir stub +# path: '/srv/www' #'/var/www' '/srv/www.sisudoc.org/web' #either (i) / [full path from root] or (ii) ~/ [home] or (iii) ./ [pwd] or (iv) will be made from home +# url_root: 'http://www.sisudoc.org' #without dir stub, e.g. this dir would map to http://www.sisudoc.org/samples +# images: '_sisu/image' +# man: 'man' +# cgi: '/usr/local/lib/sisu-cgi' +# feed: 'feed' +# sqlite: 'sisu/sqlite' +# webrick_url: true +#show_output_on: 'filesystem' #for -v and -u url information, alternatives: 'filesystem','webserver','remote_webserver','local:8111','localhost','localhost:8080','webrick','path' +#show_output_on: 'local:8111' +#webserv_cgi: +# host: localhost +# base_path: ~ +# port: '8081' +# user: ~ +# file_links: www.sisudoc.org + +#show_output_on: 'filesystem_url' +#texinfo display output +#texinfo: +# stub: 'texinfo' + +#% output_dir_structure_by: +# language (language and filetype directories); +# filetype (filetype directories, language code added to filename includes language code); +# filetype_mono or monolingual (filetype drectories, no language codes in filenames) +# filename (directory output similar to original v1 v2, filename includes language code); +# filename_mono (directory output similar to original v1 v2, filename without language code); +output_dir_structure_by: language # language filetype filetype_mono filename filename_mono +#% language_default: lng_lst: %w[am bg bn br ca cs cy da de el en eo es et eu fi fr ga gl he hi hr hy ia is it ja ko la lo lt lv ml mr nl nn no oc pl pt pt_BR ro ru sa se sk sl sq sr sv ta te th tk tr uk ur us vi zh] ('en' default) +#language_default: 'en' + +##% processing directories, main path and subdirectories (appended to $HOME), using defaults set in sysenv +#processing: +# path: 'sisu_processing' +# metaverse: 'metaverse' +# tune: 'tune' +# latex: 'tex' +# texinfo: 'texinfo' +# concord_max: 400000 + +#% flag - set (non-default) processing flag shortcuts -1, -2 etc. (here adding colour and verbosity as default) +flag: + color: true # making colour default -c is toggle, and will now toggle colour off +# act0: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --verbose' +# act1: '--manifest --text --html' +# act2: '--manifest --text --html --epub --pdf' +# act3: '--manifest --qrcode --text --html --epub --concordance --pdf' +# act4: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook' +# act5: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --sqlite' +# act6: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite' +# act7: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --sqlite --source --sisupod' +# act8: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update' +# act9: '--manifest --digest --qrcode --text --html --epub --concordance --pdf --odf --docbook --xhtml --xml-sax --xml-dom --pg --update --source --sisupod' + +#% papersize, (LaTeX/pdf) available values: A4, US_letter, book_b5, book_a5, US_legal +default: + papersize: 'a4,letter' #'a4,letter,b5,a5,legal' + #language: 'en' + #texpdf_font: 'Liberation Sans' # 'Liberation Sans' 'Liberation Serif' + #texpdf_font_mono: 'Liberation Mono' #'Inconsolata' + #text_wrap: 78 + #emphasis: 'bold' #make *{emphasis}* 'bold', 'italics' or 'underscore', default if not configured is 'bold' + #digest: 'sha' #sha is sha256, default is md5 + #language: 'English' + #emphasis: 'italics' + +#% settings used by ssh scp +#remote: +# - +# user: '[usrname]' +# host: '[remote.hostname]' +# path: '.' #no trailing slash eg 'sisu/www' +# - +# user: '[usrname]' +# host: '[remote.hostname]' +# path: '.' #no trailing slash eg 'sisu/www' + +#% webrick information +#webrick: +# port: '8081' + +#sql database info, postgresql and sqlite +db: + postgresql: + port: '5432' # '5432' + #host: # '[if not localhost, provide host tcp/ip address or domain name]'' + #user: # '[(if different from user) provide username]' + #password: # '[password if required]' +# sqlite: +# path: ~ # './sisu_sqlite.db' +# port: "**" + +permission_set: + zap: true + css_modify: true + remote_base_site: true + +program_set: + rmagick: true +# wc: true +# editor: true +# postgresql: true +# sqlite: true +# tidy: true +# rexml: true +# pdflatex: true + +#program_select: +# editor: 'vim' #'gvim -c :R' +# pdf_viewer: 'evince' +# web_browser: 'iceweasel' +# console_web_browser: 'w3m' #'links2' #'elinks' #'w3m' #'lynx' #'links' +# odf_viewer: 'lowriter' #'oowriter' #'abiword' +# xml_viewer: 'xml-viewer' +# epub_viewer: 'ebook-viewer' #'calibre' #'fbreader' #'okular' +# info_viewer: 'pinfo -f' +# man: 'man' #'groff -man -Tascii' # 'nroff -man' + +#search: +# sisu: +# flag: true +# action: http://www.sisudoc.org/cgi-bin/sisu_v6c_sqlite.cgi +# action: http://search.sisudoc.org +# db: manual +# title: 'SiSU search form (sample)' + +#promo: sisu_search_libre, sisu_icon, sisu, open_society, fsf, ruby + +#omit: minitoc diff --git a/data/doc/sisu/markup-samples/manual/_sisu/v5/sisurc.yml b/data/doc/sisu/markup-samples/manual/_sisu/v5/sisurc.yml deleted file mode 120000 index 53d85905..00000000 --- a/data/doc/sisu/markup-samples/manual/_sisu/v5/sisurc.yml +++ /dev/null @@ -1 +0,0 @@ -../rc/sisurc_default.yml \ No newline at end of file diff --git a/data/doc/sisu/markup-samples/manual/_sisu/v6/sisurc.yml b/data/doc/sisu/markup-samples/manual/_sisu/v6/sisurc.yml deleted file mode 120000 index 53d85905..00000000 --- a/data/doc/sisu/markup-samples/manual/_sisu/v6/sisurc.yml +++ /dev/null @@ -1 +0,0 @@ -../rc/sisurc_default.yml \ No newline at end of file diff --git a/lib/sisu.rb b/lib/sisu.rb new file mode 100644 index 00000000..b4dee16b --- /dev/null +++ b/lib/sisu.rb @@ -0,0 +1,94 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** hub + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_libs + require_relative 'sisu/hub' # sisu/hub.rb + require_relative 'sisu/se' # sisu/se.rb + require_relative 'sisu/utils' # sisu/utils.rb + class CallHubMaster + def initialize(argv,sisu_runtime) + begin + SiSU::HubMaster.new(argv,sisu_runtime) + rescue + SiSU_Screen::Ansi.new(argv).rescue do + __LINE__.to_s + ':' + __FILE__ + end + ensure + Dir.chdir(sisu_runtime[:call_path]) + end + end + end + class HubClose + def initialize(argv,call_path) + begin + env=SiSU_Env::InfoEnv.new + rescue + ensure + if FileTest.directory?(env.processing_path.processing) \ + and FileTest.directory?(env.processing_path.processing_base_tmp) \ + and env.processing_path.processing_base_tmp =~/#{env.processing_path.processing}/ \ + and env.processing_path.processing_base_tmp =~/^\/tmp\/\S+/ \ + and not argv.inspect =~/"--maintenance"|"-M"/ + FileUtils::cd(env.processing_path.processing_base_tmp) do + FileUtils::rm_rf('.') + end + end + Dir.chdir(call_path) + end + end + end +end +__END__ diff --git a/lib/sisu/air.rb b/lib/sisu/air.rb new file mode 100644 index 00000000..ad1d3a47 --- /dev/null +++ b/lib/sisu/air.rb @@ -0,0 +1,80 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_Air + require_relative 'se_hub_particulars' # se_hub_particulars.rb + class Source + @@ao_array=[] + @@fns=nil + def initialize(opt) + @opt=opt + @@fns||@opt.fns + @particulars=SiSU_Particulars::Combined.new(opt) + #@env=@particulars.env + #@md=@particulars.md + #@ao_array=@particulars.ao_array + end + def read + end + protected + def print + puts @particulars.md.inspect + puts @particulars.env.inspect + puts @particulars.ao_array + end + end +end +__END__ diff --git a/lib/sisu/ao.rb b/lib/sisu/ao.rb new file mode 100644 index 00000000..3e5f506e --- /dev/null +++ b/lib/sisu/ao.rb @@ -0,0 +1,590 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** preprocessing, (document abstraction), data abstraction used in subsequent + processing + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO + require_relative 'se' # se.rb + include SiSU_Env + require_relative 'dp' # dp.rb + include SiSU_Param + require_relative 'ao_doc_objects' # ao_doc_objects.rb + require_relative 'ao_syntax' # ao_syntax.rb + include SiSU_AO_Syntax + require_relative 'ao_doc_str' # ao_doc_str.rb + require_relative 'ao_references' # ao_references.rb + require_relative 'ao_idx' # ao_idx.rb + require_relative 'ao_numbering' # ao_numbering.rb + require_relative 'ao_hash_digest' # ao_hash_digest.rb + require_relative 'ao_endnotes' # ao_endnotes.rb + require_relative 'ao_images' # ao_images.rb + require_relative 'ao_metadata' # ao_metadata.rb + require_relative 'ao_character_check' # ao_character_check.rb + require_relative 'ao_misc_arrange' # ao_misc_arrange.rb + require_relative 'ao_expand_insertions' # ao_expand_insertions.rb + require_relative 'ao_persist' # ao_persist.rb + require_relative 'prog_text_translation' # prog_text_translation.rb + require_relative 'shared_sem' # shared_sem.rb + class Instantiate < SiSU_Param::Parameters::Instructions + def initialize + @@flag_vocab=0 + @@line_mode='' + end + end + class Source #{cf.meta}" + ).txt_grey + end + end + ao.each {|s| ao_array << s} + if @opt.act[:maintenance][:set]==:on + ao_array.each do |obj| + if defined? obj.parent + if defined? obj.ln + if defined? obj.node + puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}} + else + puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent}} + end + else + if defined? obj.node + puts %{ #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}} + else + puts %{ #{obj.ocn} : #{obj.parent}} + end + end + end + end + end + ao_array + end + def read_fnm + ao=[] + ao=(FileTest.file?(@fnm)) \ + ? (File.open(@fnm,'r:utf-8'){ |f| ao=Marshal.load(f)}) + : SiSU_AO::Source.new(@opt).create_ao + end + def read_fnc + ao=[] + ao=(FileTest.file?(@fnc)) \ + ? (File.open(@fnc,'r:utf-8'){ |f| ao=Marshal.load(f)}) + : SiSU_AO::Source.new(@opt,@fnx,@process).create_ao + end + def read_idx_sst + m=[] + m=(FileTest.file?(@idx_sst)) \ + ? (File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + def read_idx_raw + m=[] + m=(FileTest.file?(@idx_raw)) \ + ? (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + def read_idx_html + m=[] + m=(FileTest.file?(@idx_html)) \ + ? (File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + def read_idx_xhtml + m=[] + m=(FileTest.file?(@idx_xhtml)) \ + ? (File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + def read_map_nametags + m=[] + m=(FileTest.file?(@map_nametags)) \ + ? (File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + def read_map_ocn_htmlseg + m=[] + m=(FileTest.file?(@map_ocn_htmlseg)) \ + ? (File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)}) + : nil + end + end + class Output + def initialize(fn,md,data) + @fn,@md,@data=fn,md,data + @cf=SiSU_Env::CreateFile.new(@fn) + @make=SiSU_Env::InfoFile.new(@fn) + @dir=SiSU_Env::InfoEnv.new(@fn) + end + def screen_dump(o) + if defined? o.of + print %{OF: #{o.of}; } + end + if defined? o.is + print %{IS: #{o.is.to_s}; } + end + if defined? o.ocn + print %{OCN: #{o.ocn}; } + end + if defined? o.node + print %{NODE: #{o.node}; } + end + if defined? o.parent + print %{Parent: #{o.parent}; } + end + if defined? o.obj and not o.obj.empty? + puts %{\n#{o.obj}; } + else "\n" + end + end + def screen_print(t_o) + if defined? t_o + print ' ' + t_o.to_s + end + end + def screen_output(data) + data.each do |o| + print o.class + screen_print(o.ocn) + screen_print(o.obj) + puts "\n" + end + end + def hard_output + if @md.opt.act[:maintenance][:set]==:on + filename_meta=@cf.metaverse.file_meta + @data.each {|o| filename_meta.puts o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ')} #to make diffing easier + filename_txt=@cf.metaverse.file_txt + @data.each do |o| + if defined? o.ocn + filename_txt.puts case o.is + when :heading + "[#{o.is.to_s} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" + else "[#{o.is.to_s} [#{o.ocn}]] #{o.obj}" + end + else + filename_txt.puts case o.is + when :meta + "[m~#{o.tag}] #{o.obj}" + else "[#{o.is.to_s}] #{o.obj}" + end + end + end + filename_debug=@cf.file_debug + @data.each do |o| + if defined? o.ocn + case o.is + when :heading + filename_debug.puts + "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" + end + end + end + else + hard="#{@dir.processing_path.ao}/#{@md.fns}.meta" + File.unlink(hard) if FileTest.file?(hard) + hard="#{@dir.processing_path.ao}/#{@md.fns}.txt" + File.unlink(hard) if FileTest.file?(hard) + hard="#{@dir.processing_path.ao}/#{@md.fns}.debug.txt" + File.unlink(hard) if FileTest.file?(hard) + end + end + def make_marshal_content + marshal_ao=@make.marshal.ao_content + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + end + def make_marshal_metadata + marshal_ao=@make.marshal.ao_metadata + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) + end + def idx_html_hard_output + if @md.book_idx \ + and @md.opt.act[:maintenance][:set]==:on + filename_meta=@cf.file_meta_idx_html + if @data.is_a?(Array) + @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)} + @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} + end + else + hard_idx_html="#{@dir.processing_path.ao}/#{@md.fns}.idx.html" + File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html) + end + end + def make_marshal_idx_sst_html_seg + marshal_ao=@make.marshal.ao_idx_sst_rel_html_seg + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Array) + end + def make_marshal_idx_sst_rel + marshal_ao=@make.marshal.ao_idx_sst_rel + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Array) + end + def make_marshal_idx_html + marshal_ao=@make.marshal.ao_idx_html + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Array) + end + def make_marshal_idx_xhtml + marshal_ao=@make.marshal.ao_idx_xhtml + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Array) + end + def make_marshal_map_nametags + marshal_ao=@make.marshal.ao_map_nametags + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Hash) + end + def make_marshal_map_name_ocn_htmlseg + marshal_ao=@make.marshal.ao_map_ocn_htmlseg + File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ + if @data.is_a?(Hash) + end + end + class Make + def initialize(fn,md,data,fnx,process) + @fn,@md,@data,@fnx,@process=fn,md,data,fnx,process + @env=SiSU_Env::InfoEnv.new(@md.fns) + end + def reset + @@flag_vocab=0 + @@line_mode='' + end + def song + reset + data_txt=@data + data_txt= + SiSU_AO_Insertions::Insertions.new(@md,data_txt). # ao_expand_insertions.rb + expand_insertions? + data_txt= + SiSU_AO_MiscArrangeText::SI.new(@md,data_txt). # ao_misc_arrange.rb + prepare_text + data_obj, + metadata, + bibliography= + SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt). # ao_doc_str.rb + identify_parts + data_obj= + SiSU_AO_Syntax::Markup.new(@md,data_obj,bibliography).songsheet # ao_syntax.rb + data_obj, + endnote_array= + SiSU_AO_CharacterCheck::Check.new(data_obj). # ao_character_check.rb + character_check_and_oldstyle_endnote_array + data_obj= + SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb + data_obj, + tags_map, + ocn_html_seg_map= + SiSU_AO_Numbering::Numbering.new(@md,data_obj,@fnx,@process). # ao_numbering.rb + numbering_song + data_obj, + book_index_rel, + book_index_rel_html_seg, + html_idx, + xhtml_idx= + SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env). # ao_idx.rb + indexing_song if @md.book_idx + data_obj= + SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array). # ao_endnotes.rb + endnotes + outputdata=data_obj + if (@md.opt.act[:ao][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_AO::Output.new(@fn,@md,outputdata).hard_output + SiSU_AO::Output.new(@fn,@md,outputdata).make_marshal_content + SiSU_AO::Output.new(@fn,@md,metadata).make_marshal_metadata + SiSU_AO::Output.new(@fn,@md,html_idx).idx_html_hard_output + SiSU_AO::Output.new(@fn,@md,book_index_rel_html_seg).make_marshal_idx_sst_html_seg + SiSU_AO::Output.new(@fn,@md,book_index_rel).make_marshal_idx_sst_rel + SiSU_AO::Output.new(@fn,@md,html_idx).make_marshal_idx_html + SiSU_AO::Output.new(@fn,@md,xhtml_idx).make_marshal_idx_xhtml + SiSU_AO::Output.new(@fn,@md,tags_map).make_marshal_map_nametags + SiSU_AO::Output.new(@fn,@md,ocn_html_seg_map).make_marshal_map_name_ocn_htmlseg + end + reset + outputdata + end + protected + end +end +__END__ diff --git a/lib/sisu/ao_character_check.rb b/lib/sisu/ao_character_check.rb new file mode 100644 index 00000000..7cd8f171 --- /dev/null +++ b/lib/sisu/ao_character_check.rb @@ -0,0 +1,102 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_CharacterCheck + class Check + def initialize(data) + @data=data + @comment='%' + @endnote_array=[] + end + def character_check_and_oldstyle_endnote_array + data=@data + @endnote_array=[] + endnote_no=1 + @tuned_file=data.select do |dob| + unless dob.is ==:table + dob.obj=dob.obj.strip. + gsub(/^[{~}]\s*$/,''). + gsub(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}"). + gsub(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}"). + gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). + gsub(/(~\{\s*)\s+/,'\1 '). + gsub(/ \/\//,"#{Mx[:br_line]}"). + gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. + gsub(/\t/,' '). + gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” + gsub(/\\copy(?:right)?\b/,'©'). + gsub(/\\trademark\b|\\tm\b/,'®') + dob.obj=dob.obj + "\n" + unless dob.is ==:code + case dob.obj + when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ + sub_dob=dob.obj.dup + @endnote_array << sub_dob.gsub(/\n/,''). + gsub(/\^~\s+(.+)\s*/, + %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). + strip + endnote_no+=1 + dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion + end + end + end + dob if dob.is_a?(Object) + end.flatten.compact + [@tuned_file,@endnote_array] + end + end +end +__END__ diff --git a/lib/sisu/ao_composite.rb b/lib/sisu/ao_composite.rb new file mode 100644 index 00000000..d110e52b --- /dev/null +++ b/lib/sisu/ao_composite.rb @@ -0,0 +1,286 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** composite documents, assemble/build documents from other documents + or parts of marked up text + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_Assemble + require_relative 'se' # se.rb + require_relative 'utils_composite' # utils_composite.rb + class RemoteImage + def initialize + @env=SiSU_Env::InfoEnv.new + end + def image(dir) + images=[] + images[0]=dir + images + end + def download_images(images_info) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) \ + unless FileTest.directory?(path) + download_from=images_info.shift + images_info.each do |i| + image="#{path}/#{i}" + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + output_path="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_external" + FileUtils::mkdir_p(output_path) \ + unless FileTest.directory?(output_path) + SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync + end + end + class Composite + include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + pwd=Dir.pwd + Dir.chdir(@opt.f_pth[:pth]) + if @opt.fno =~/\S+?\.ssm$/ + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", + ).grey_title_hi unless @opt.act[:quiet][:set]==:on + composite_and_imported_filenames_array(@opt.fno) # composite doc, .ssm, extract all related insert files, array of filenames test + assembled=loadfile(@opt.fno) + write(assembled) + end + Dir.chdir(pwd) + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns). + location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def insert?(para) + if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + url($1.strip) + elsif para =~/^<<\s+(\S+?\.ss[it])$/ + loadfilename=$1.strip + insert_array=loadfile(loadfilename) + file=insertion(loadfilename,insert_array) + file[:prepared] + else para + end + end + def loadfile(loadfilename) + begin + if FileTest.file?(loadfilename) + insert_array=IO.readlines(loadfilename,'') + if loadfilename =~/\S+?\.ss[itm]$/ + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfilename, + ).txt_grey + end + tuned_file=if loadfilename =~/\S+?\.ss[im]$/ + insert_array.each.map do |para| + insert?(para) + end + elsif loadfilename =~/\S+?\.sst$/ + insert_array.each.map do |para| + para + end + end.flatten.compact + end + end + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def url(loadfilename) + if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest + loadfilename=$1 + begin + require 'uri' + require 'open-uri' + require 'pp' + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error('uri, open-uri or pp NOT FOUND (LoadError)') + end + insert=open(loadfilename) + insert_array=insert.dup + insert.close + file=insertion(loadfilename,insert_array) + file[:prepared] + end + end + def write(assembled) + assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') + assembled.each {|a| assembled_file << a } + assembled_file.close + end + def download_images(download_from,images_array) + path="#{@env.processing_path.processing}/external_document/image" + FileUtils::mkdir_p(path) unless FileTest.directory?(path) + images_array.each do |i| + image="#{path}/#{i}" + unless FileTest.exists?(image) + imagefile=File.new(image,'w+') + open("#{download_from}/#{i}") do |g| + imagefile << g.read + end + imagefile.close + end + end + end + def insertion(fni,insert_array) + file={ prepared: [], images: [] } + rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ + file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" + @code_flag=false + insert_array.each do |i| + @code_flag=if i =~/^code\{/ then true + elsif i =~/^\}code/ then false + else @code_flag + end + if not @code_flag \ + and i !~/^%+\s/ + i=i. + gsub(/^([123]|:?[ABCD])~\? /, + '% [conditional heading:] \1~ ') #off conditional heading (consider syntax) + if i =~/^@\S+?:/ + i=i.gsub(/\n/m,"\n% "). + gsub(/\n%\s+$/m,''). + gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers + end + end + file[:prepared] << i + if i !~/^%+\s/ \ + and i =~rgx_image + file[:images] << i.scan(rgx_image).uniq + end + end + file[:prepared] << "\n% end import" << "\n\n" + if file[:images].length > 0 + file[:images]=file[:images].flatten.uniq + file[:images].delete_if {|x| x =~/https?:\/\// } + end + file + end + end + class CompositeFileList + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new + end + def read + begin + @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub + fns_array=IO.readlines(@opt.fns,'') + insertions?(fns_array) + rescue + SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do + __LINE__.to_s + ':' + __FILE__ + end + ensure + end + end + def insertions?(fns_array) + tuned_file=[] + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'Composite Document', + @opt.fno + ).grey_title_hi unless @opt.act[:quiet][:set]==:on + @ssm=[@opt.fns] + fns_array.each do |para| + if para =~/^<<\s+(\S+?\.ss[it])$/ + loadfilename=$1.strip + if (@opt.act[:verbose][:set]==:on \ + || @opt.act[:verbose_plus][:set]==:on \ + || @opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'loading:', + loadfilename, + ).txt_grey + end + tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ + @ssm << loadfilename + elsif loadfilename =~ /\.ss[it]$/ \ + and FileTest.file?(loadfilename) + @ssm << loadfilename + else + STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} + $process_document = :skip; break #remove this line to continue processing documents that have missing include files + para + end + end + end + @ssm + end + end +end +__END__ diff --git a/lib/sisu/ao_doc_objects.rb b/lib/sisu/ao_doc_objects.rb new file mode 100644 index 00000000..6cb824e2 --- /dev/null +++ b/lib/sisu/ao_doc_objects.rb @@ -0,0 +1,565 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** document abstraction + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_DocumentStructure + class Extract + def extract(h,o) + h ? h : o + end + end + class ObjectMetadata + attr_accessor :is,:of,:tags,:obj,:digest + def initialize + @tags={} + @is=@tmp=@digest=nil + @of=:meta + end + def metadata(tags) + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + tags = tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag + obj = nil + @of,@is,@tags,@obj=of,is,tags,obj + self + end + end + class ObjectMeta + attr_accessor :obj,:is,:of,:tag,:digest,:tmp + def initialize + @is=@obj=@tag=@digest=@digest=@tmp=nil + @of=:meta + end + def metadata(h,o=nil) + of = @of #Symbol, classification - group + is = :meta #Symbol, classification - specific type + tag = h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp + self + end + end + class ObjectHeading + attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:use_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp + def initialize + @of=:para + @is=@obj=@lv=@ln=@lc=@use_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil + @tags=[] + end + def heading_ln(lv) + case lv + when /A/ then 0 + when /B/ then 1 + when /C/ then 2 + when /D/ then 3 + when /1/ then 4 + when /2/ then 5 + when /3/ then 6 + when /4/ then 7 + when /5/ then 8 + when /6/ then 9 + end + end + def heading_lv(ln) + case ln.to_s + when /0/ then 'A' + when /1/ then 'B' + when /2/ then 'C' + when /3/ then 'D' + when /4/ then '1' + when /5/ then '2' + when /6/ then '3' + when /7/ then '4' + when /8/ then '5' + when /9/ then '6' + end + end + def heading(h,o=nil) + if not h[:ln] \ + and (h[:lv] and h[:lv]=~/[1-6A-D]/) + h[:ln]=heading_ln(h[:lv]) + elsif not h[:lv] \ + and (h[:ln] and h[:ln].to_s=~/[0-9]/) + h[:lv]=heading_lv(h[:ln]) + end + of = @of #Symbol, classification - group + is = :heading #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + node = h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + lv = h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 + ln = h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 + lc = h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) + use_ = if lv \ + and lv == '1' + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + elsif not lv.empty? \ + and lv =~ /[A-D2-3]/ + :ok + else + h[:use_] || ((defined? o.use_) ? o.use_ : :ok) + end + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + autonum_ = if h[:autonum_].nil? + ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses + else h[:autonum_] + end + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@use_,@ocn_,@note_,@autonum_,@digest,@tmp= + of, is, lv, ln, lc, name, tags, obj, idx, ocn, odv, osp, node, parent, use_, ocn_, note_, autonum_, digest, tmp + self + end + def heading_insert(h,o=nil) + heading(h,o=nil) + @is = :heading_insert #String, classification - specific type + self + end + end + class ObjectPara + attr_accessor :obj,:is,:tags,:of,:name,:idx,:quote_,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp + def initialize + @of=:para + @is=@obj=@name=@idx=@quote_=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil + @tags=[] + end + def paragraph(h,o=nil) + of = @of #Symbol, classification - group + is = :para #Symbol, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level + hang = h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level + bullet_ = h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? + quote_ = h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= + of, is, name, tags, obj, indent, hang, bullet_, quote_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp + self + end + def docinfo(h,o=nil) + of = @of #String, classification - group + is = :docinfo #String, classification - specific type + name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? + tags = h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = nil #String, book index provided? + ocn = nil #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + indent = nil #Integer, indent level + hang = nil #Integer, indent level + bullet_ = false #Bool, bulleted? + note_ = false #Bool, endnotes/footnotes? (processing optimization) + image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= + of, is, name, tags, obj, indent, hang, bullet_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp + self + end + end + class ObjectBlockTxt + attr_accessor :obj,:is,:of,:tags,:lngsyn,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp + def initialize + @of=:block + @is=@obj=@lngsyn=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil + @tags=[] + end + def code(h,o=nil) + of = @of #Symbol, classification - group #alt 'code' + is = :code #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + lngsyn = h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + number_ = h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, lngsyn, idx, ocn, odv, osp, parent, number_, note_, ocn_, num, digest, tmp + self + end + def box(h,o=nil) + of = @of #Symbol, classification - group + is = :box #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp + self + end + def block(h,o=nil) + of = @of #Symbol, classification - group + is = :block #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp + self + end + def group(h,o=nil) + of = @of #Symbol, classification - group + is = :group #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp + self + end + def alt(h,o=nil) #see block + of = @of #Symbol, classification - group + is = :alt #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp + self + end + def verse(h,o=nil) #part of poem decide how you deal with this + of = @of #Symbol, classification - group + is = :verse #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp + @h=nil + self + end + end + class ObjectTable + attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:num,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp + def initialize + @of=:block + @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@num,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil + @tags=[] + end + def table(h,o=nil) + of = @of #Symbol, classification - group + is = :table #Symbol, classification - specific type + tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + cols = h[:cols] || ((defined? o.cols) ? o.cols : nil) + widths = h[:widths] || ((defined? o.widths) ? o.widths : nil) + obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + head_ = h[:head_] || ((defined? o.head_) ? o.head_ : false) + note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_ = if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + num = h[:num] || ((defined? o.num) ? o.num : nil) + digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@num,@digest,@tmp= + of, is, tags, cols, widths, obj, idx, ocn, odv, osp, parent, head_, note_, ocn_, num, digest, tmp + self + end + end + class ObjectImage + attr_accessor :obj,:is,:of,:lv,:idx,:size,:ocn,:parent,:note_,:ocn_,:digest,:tmp + def initialize + @of=:image + @is=@obj=@lv=@idx=@size=@ocn=@parent=@note_=@ocn_=@tmp=@digest=nil + @tags=[] + end + def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider + of= @of #Symbol, classification - group + is= :image #Symbol, classification - specific type + tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + size= h[:size] || ((defined? o.size) ? o.size : nil) + idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? + ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects + odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) + osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) + parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] + note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) + ocn_=if h[:ocn_].nil? + ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider + else h[:ocn_] + end + digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@tags,@obj,@size,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,size,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp + self + end + end + class ObjectStructure + attr_accessor :obj,:tag,:node,:lv,:ln,:lc,:status,:is,:of,:tmp + def initialize + @of=:structure + @is=@obj=@node=@lv=@ln=@lc=@status=@tmp=nil + end + def xml_dom(h,o=nil) + of= @of #Symbol, classification - group + is= :xml_dom #Symbol, classification - specific type + obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content + lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 + ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 + lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) + node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] + status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status Symbol :open or :close + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@obj,@status,@node,@lv,@ln,@lc,@tmp=of,is,obj,status,node,lv,ln,lc,tmp + self + end + end + class ObjectFlag + attr_accessor :obj,:is,:of,:flag,:act,:selections,:tmp + def initialize + @of=:flag + @is=@obj=@flag=@act=@selections=@tmp=nil + end + def flag(h,o=nil) + of= @of #Symbol, classification - group + is= :flag #Symbol, classification - specific type + obj= nil #String, text content + flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content + act= h[:act] || ((defined? o.act) ? o.act : nil) #String, text content + selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content + tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of, @is,@obj,@flag,@act,@selections,@tmp= + of,is, obj, flag, act, selections, tmp + self + end + def flag_ocn(h,o=nil) + of= @of #Symbol, classification - group + is= :flag_ocn #Symbol, classification - specific type + obj= nil #String, text content + flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content + act= h[:act] || ((defined? o.act) ? o.act : nil) #String, text content + selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content + tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of, @is,@obj,@flag,@act,@selections,@tmp= + of,is, obj, flag, act, selections,tmp + self + end + def flag_lng(h,o=nil) + of= @of #Symbol, classification - group + is= :flag_lng + obj= nil #String, text content + flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #Symbol, :lng_on or :lng_off + act= h[:act] || ((defined? o.act) ? o.act : nil) #Symbol, language set to :en etc. + selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content + tmp= h[:act] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of, @is,@obj,@flag,@act,@selections,@tmp= + of,is, obj, flag, act, selections,tmp + self + end + end + class ObjectLayout + attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num + def initialize + @of=:layout + @is=@is_for=@obj=@from=@tmp=@num=nil + end + def break(h,f=nil) #decide how to deal with + of= @of #Symbol, classification - group + is= :break #Symbol, classification - specific type + obj= h[:obj] #String, text content + from= f + tmp= h[:tmp] #available for processing, empty after use + @of,@is,@obj,@from,@tmp=of,is,obj,from,tmp + self + end + def insert(h,o=nil) #decide how to deal with, could mimic paragraph? + of= @of #Symbol, classification - group + is= :insert #Symbol, classification - specific type + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@obj,@tmp=of,is,obj,tmp + self + end + def open_close(h,o=nil) #useful for poem & quote + of= @of #Symbol, classification - group + is= :open_close_tags #Symbol, classification - specific type + is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close + attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + num= h[:num] || ((defined? o.num) ? o.num : nil) + @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num= + of, is, is_for, obj, sym, attr, tmp, num + self + end + end + class ObjectComment + attr_accessor :obj,:is,:of,:tmp + def initialize + @of=:comment + @is=@obj=@tmp=nil + end + def comment(h,o=nil) + of= @of #Symbol, classification - group + is= :comment #Symbol, classification - specific type + obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content + tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use + @of,@is,@obj,@tmp=of,is,obj,tmp + self + end + end +end +__END__ +# ~# |-# no paragraph number # -# not included in toc diff --git a/lib/sisu/ao_doc_str.rb b/lib/sisu/ao_doc_str.rb new file mode 100644 index 00000000..9da488b6 --- /dev/null +++ b/lib/sisu/ao_doc_str.rb @@ -0,0 +1,2269 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** document abstraction + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_DocumentStructureExtract + require_relative 'ao_persist' # ao_persist.rb + class Instantiate < SiSU_Param::Parameters::Instructions + def initialize + @@counter=@@column=@@columns=0 + @@line_mode='' + end + end + class Build + def initialize(md,data) + @md,@data=md,data + SiSU_AO_DocumentStructureExtract::Instantiate.new + @pb=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) + @pbn=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) + @pbl=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) + @per=SiSU_AO_Persist::PersistDocStructExt.new + end + def ln_get(lv) + case lv + when /A/ then 0 + when /B/ then 1 + when /C/ then 2 + when /D/ then 3 + when /1/ then 4 + when /2/ then 5 + when /3/ then 6 + when /4/ then 7 + when /5/ then 8 + when /6/ then 9 + end + end + def image_test(str) + str=~/\{\s*\S+?\.png.+?\}https?:\/\/\S+/ \ + ? true + : false + end + def bullet_test(str) + (str=~/\*/) \ + ? true + : false + end + def quotes? + @per.quote==:open \ + ? true + : false + end + def hang_and_indent_test(str) + hang_indent=if str=~/^_([1-9])[^_]/ + [$1,$1] + elsif str=~/^__([1-9])/ + [0,$1] + elsif str=~/^_([0-9])_([0-9])/ + [$1,$2] + else + [0,0] + end + hang,indent=hang_indent[0],hang_indent[1] + [hang,indent] + end + def hang_and_indent_def_test(str1,str2) + hang_indent=if str1=~/^_([1-9])[^_]/ + [$1,$1] + elsif str1=~/^__([1-9])/ + [0,$1] + elsif str1=~/^_([0-9])_([0-9])/ + [$1,$2] + else + [0,0] + end + obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/ + str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") + else + str2.gsub(/^(.+?)\n/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") + end + hang,indent=hang_indent[0],hang_indent[1] + [ + hang, + indent, + obj, + ] + end + def endnote_test?(str) + (str=~/~\{.+?\}~|~\[.+?\]~/) \ + ? true + : false + end + def extract_tags(str,nametag=nil) + tags=[] + if str.nil? + else + if str =~/(?:^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/ + str=str.gsub(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, + "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}"). + gsub(/ [ ]+/i,' ') + tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten.uniq + str=str.gsub(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? + end + tags=nametag ? (tags << nametag) : tags + tags.each do |t| + t.gsub!(/[^a-z0-9._-]/,'') + end + end + [ + str, + tags, + ] + end + def rgx_idx_ocn_seg + @rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/ + end + def construct_idx_array_and_hash(idxraw) + idx_array_raw=idxraw.scan(/[^;]+/) + idx_hash,idx_array,idx_lst={},[],[] + idx_array_raw.each do |idx| + idx=idx.strip + idx_lst=case idx + when /\S+?\s*:/ + idx_couplet_tmp=[] + idx_couplet=idx.scan(/\s*[^:]+\s*/) + if idx_couplet[1] =~/[|]/ + idx_couplet_tmp << + idx_couplet[0] << + idx_couplet[1].scan(/\s*[^|]+\s*/) + else + idx_couplet_tmp << + idx_couplet[0] << + [idx_couplet[1]] + end + idx_couplet=idx_couplet_tmp + else [idx] + end + term_nodes=[] + idx_lst.each do |term_node| + case term_node + when String + term_node= + term_node[0].chr.capitalize + + term_node[1,term_node.length] + term_node=(term_node =~/.+?[+]\d+/) \ + ? term_node + : (term_node + '+0') + term_nodes << term_node + use,plus=rgx_idx_ocn_seg.match(term_node)[1,2] + @use=use.strip + unless idx_hash[@use] \ + and defined? idx_hash[@use] + idx_hash[@use]= + { sub: [], plus: plus } + end + when Array + subterm_nodes=[] + term_node.each do |subterm_node| + subterm_node=(subterm_node =~/.+?[+]\d+/) \ + ? subterm_node + : (subterm_node + '+0') + subterm_nodes << subterm_node + sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2] + unless idx_hash[@use] \ + and defined? idx_hash[@use] + idx_hash[@use]= + { sub: [], plus: 0 } + end + idx_hash[@use][:sub] << + { sub.strip => { plus: sub_plus } } + end + term_nodes << subterm_nodes + end + end + idx_array << term_nodes + end + { + hash: idx_hash, + array: idx_array, + } + end + def extract_structure_loop(data,tuned_file) + data.each do |t_o| + if t_o =~/^--([+~-])[#]$/ + h=case $1 + when /[+]/ + @per.ocn=:on + { + flag: :ocn_on, + } + when /[~]/ + @per.ocn=:ocn_off_headings_keep + { + flag: :ocn_off, + mod: :headings_keep, + } + when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text + @per.ocn=:ocn_off_headings_dummy_lev1 + { + flag: :ocn_off, + mod: :headings_exclude, + } + else + @per.ocn=:on + { + flag: :ocn_on, + } + end + t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h) + next + end + if t_o =~/^:[~](#{SiSU_is.language_list_regex?}|-)$/ # work with for identifying language of objects + lng=$1 + h=case lng + when /(?:#{SiSU_is.language_list_regex?})/ + @per.lng=:on + @per.lng_is=lng.to_sym + { + flag: :lng_on, + act: lng.to_sym, + } + else # ^:~- + if @per.lng==:on + @per.lng=:off + @per.lng_is=:doc_default + { + flag: :lng_off, + act: :doc_default, + } + end + end + t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_lng(h) + next + end + t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @per.code==:off + unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any + idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m + m=$1 + m=m.split(/[ ]*\n/).join(' '). + gsub(/\s+([|:;])\s+/,'\1'). + gsub(/\s+([+]\d+)\s+/,'\1') + t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') + idx_array_and_hash=construct_idx_array_and_hash(m) + idx_array_and_hash[:hash] + else nil + end + end + if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \ + and @per.code==:off \ + and @per.poem==:off \ + and @per.group==:off \ + and @per.block==:off \ + and @per.alt==:off \ + and @per.box==:off \ + and @per.table==:off + t_o=case t_o + when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header + if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m + tag,obj=$1,$2 + @metadata[tag]=obj + end + t_o=nil + when /^%+\s/ #comment + t_o=if t_o=~/^%+\s+(.+)/ + h={ obj: $1 } + SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) + else nil + end + when /^:?([A-D1-6])\~/ #heading / lv + lv=$1 + ln=ln_get(lv) + t_o=if t_o=~/^:?[A-D1-6]\~\s+(.+)/m + obj=$1 + note=endnote_test?(obj) + obj,tags=extract_tags(obj) + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m + obj << ' -#' + elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + obj << ' ~#' + end + end + end + h={ + lv: lv, + ln: ln, + obj: obj, + idx: idx, + tags: tags, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m + name,obj=$1,$2 + note=endnote_test?(obj) + obj,tags=extract_tags(obj) + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m + obj << ' -#' + elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + obj << ' ~#' + end + end + end + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + autonum_: false, + tags: tags, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m + name,obj=$1,$2 + note=endnote_test?(obj) + obj,tags=extract_tags(obj,name) + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + and t_o =~/^1\~\S*\s+/m + obj << ' -#' + elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + obj << ' ~#' + end + end + end + h={ + lv: lv, + name: name, + obj: obj, + idx: idx, + tags: tags, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + else nil + end + when /^_(?:[1-9]!?|[1-9]?\*)\s+/ #indented and/or bullet paragraph + t_o=if t_o=~/^(_(?:[1-9]?\*|[1-9]!?)\s+)(.+)/m + tst,obj=$1,$2 + if t_o=~/^_[1-9]!\s+.+/m + hang,indent,obj=hang_and_indent_def_test(tst,obj) + else + hang,indent=hang_and_indent_test(tst) + end + bullet=bullet_test(tst) + image=image_test(obj) + note=endnote_test?(obj) + obj,tags=extract_tags(obj) + unless obj=~/\A\s*\Z/m + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end + h={ + bullet_: bullet, + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + else nil + end + when /^_[0-9]?_[0-9]!?\s+/ #hanging indent paragraph + t_o=if t_o=~/^(_[0-9]?_[0-9]!?\s+)(.+)/m + tst,obj=$1,$2 + if t_o=~/^_[0-9]?_[0-9]!\s+.+/m + hang,indent,obj=hang_and_indent_def_test(tst,obj) + else + hang,indent=hang_and_indent_test(tst) + end + image=image_test(obj) + note=endnote_test?(obj) + obj,tags=extract_tags(obj) + unless obj=~/\A\s*\Z/m + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end + h={ + hang: hang, + indent: indent, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + else nil + end + when /^<(?:br)?:(?:pa?r|o(?:bj|---)?)>\s*$/ #[br:par] #[br:obj] + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) + when /^(?:-\\\\-|<:pb>)\s*$/ #[br:pg] + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page],:markup) + when /^(?:=\\\\=|<:pn>)\s*$/ #[br:pgn] + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new],:markup) + when /^-\.\.-\s*$/ #[br:pgl] + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line],:markup) + else #paragraph + image=image_test(t_o) + note=endnote_test?(t_o) + obj,tags=extract_tags(t_o) + if @per.ocn==:ocn_off_headings_dummy_lev1 \ + or @per.ocn==:ocn_off_headings_keep + unless obj =~ /[~-][#]\s*$/ + obj << ' ~#' + end + end + unless obj=~/\A\s*\Z/m + h={ + bullet_: false, + indent: 0, + hang: 0, + obj: obj, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } + t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require + end + elsif @per.code==:off + if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ + @per.code=case t_o + when /^code(?:\.[a-z][0-9a-z_]+)?\{/ then :curls + when /^```[ ]+code/ then :tics + else @per.code #error + end + @per.lngsyn=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/ + case t_o + when /^code\.([a-z][0-9a-z_]+)\{/ + :"#{$1}" + when /^```[ ]+code\.([a-z][0-9a-z_]+)/ + :"#{$1}" + else :txt + end + else :txt + end + @@counter=1 + @codeblock_numbered= + (t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) \ + ? true + : false + @num_id[:code_block] +=1 + h={ + is_for: :code, + obj: '', + sym: :code_block_open, + num: @num_id[:code_block], + syntax: @per.lngsyn, + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif t_o =~/^(?:poem\{|```[ ]+poem)/ + @per.poem=case t_o + when /^poem\{/ then :curls + when /^```[ ]+poem/ then :tics + else @per.poem #error + end + @num_id[:poem] +=1 + h={ + is_for: :poem, + obj: '', + sym: :poem_open, + num: @num_id[:poem], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/ + @per.box=case t_o + when /^box\{/ then :curls + when /^```[ ]+box/ then :tics + else @per.box #error + end + @num_id[:box] +=1 + h={ + is_for: :box, + obj: '', + sym: :box_open, + num: @num_id[:box], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^(?:group\{|```[ ]+group)/ + @per.group=case t_o + when /^group\{/ then :curls + when /^```[ ]+group/ then :tics + else @per.group #error + end + @num_id[:group] +=1 + h={ + is_for: :group, + obj: '', + sym: :group_open, + num: @num_id[:group], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^(?:block\{|```[ ]+block)/ + @per.block=case t_o + when /^block\{/ then :curls + when /^```[ ]+block/ then :tics + else @per.block #error + end + @num_id[:block] +=1 + h={ + is_for: :block, + obj: '', + sym: :block_open, + num: @num_id[:block], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^(?:alt\{|```[ ]+alt)/ + @per.alt=case t_o + when /^alt\{/ then :curls + when /^```[ ]+alt/ then :tics + else @per.alt #error + end + @num_id[:alt] +=1 + h={ + is_for: :alt, + obj: '', + sym: :alt_open, + num: @num_id[:alt], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << t_o + elsif t_o =~/^`:quote_open`/ + @per.quote=:open + @num_id[:quote] +=1 + h={ + is_for: :quote, + obj: '', + sym: :quote_open, + num: @num_id[:quote], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + #tuned_file << t_o #% find second source, entered twice, should be once so closed off here + elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ + @num_id[:table] +=1 + h={ + is_for: :table, + obj: '', + sym: :table_open, + num: @num_id[:table], + } + ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + tuned_file << ins_o + if t_o=~/^table\{(?:~h)?\s+/ + @per.table=:curls + @rows='' + case t_o + when /table\{~h\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=true + when /table\{\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=false + end + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } + elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ + @per.table=:tics + @rows='' + case t_o + when /^```[ ]+table~h\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=true + when /^```[ ]+table\s+c(\d+);\s+(.+)/ + cols=$1 + col=$2.scan(/\d+/) + heading=false + end + @h={ + head_: heading, + cols: cols, + widths: col, + idx: idx, + } + elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m + m1,m2,hd=nil,nil,nil + tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1] + hd=((t_o =~/^\{table~h/) ? true : false) + tbl,tags=extract_tags(tbl) + rws=tbl.split(/\n/) + rows='' + cols=nil + rws.each do |r| + cols=(cols ? cols : (r.scan('|').length) +1) + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + rows += r + Mx[:tc_c] + end + col=[] + if t_o =~/^\{table(?:~h)?\s+(\d+);?\}/ #width of col 1 given as %, usually when wider than rest that are even + c1=$1.to_i + width=(100 - c1)/(cols - 1) + col=[ c1 ] + (cols - 1).times { col << width } + else #all columns of equal width + width=100.00/cols + cols.times { col << width } + end + h={ + head_: hd, + cols: cols, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ + unless h.nil? + tuned_file << t_o + h={ + is_for: :table, + obj: '', + sym: :table_close, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + t_o + elsif t_o=~/^```[ ]+table(?:~h)?\s+/ + m1,m2,hd=nil,nil,nil + h=case t_o + when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + m1,tbl,hd=$1,$2,true + when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one + m1,tbl,hd=$1,$2,false + else nil + end + tbl,tags=extract_tags(tbl) + col=m1.scan(/\d+/) + rws=tbl.split(/\n/) + rows='' + rws.each do |r| + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + rows += r + Mx[:tc_c] + end + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ + unless h.nil? + tuned_file << t_o + h={ + is_for: :table, + obj: '', + sym: :table_close, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + t_o + elsif t_o=~/^\{table(?:~h)?\s+/ + m1,m2,hd=nil,nil,nil + h=case t_o + when /\{table~h\s+(.+?)\}\n(.+)\Z/m #two table representations should be consolidated as one + m1,tbl,hd=$1,$2,true + when /\{table\s+(.+?)\}\n(.+)\Z/m #two table representations should be consolidated as one + m1,tbl,hd=$1,$2,false + else nil + end + tbl,tags=extract_tags(tbl) + col=m1.scan(/\d+/) + rws=tbl.split(/\n/) + rows='' + rws.each do |r| + r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") + rows += r + Mx[:tc_c] + end + h={ + head_: hd, + cols: col.length, + widths: col, + obj: rows, + idx: idx, + tags: tags, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ + unless h.nil? + tuned_file << t_o + h={ + is_for: :table, + obj: '', + sym: :table_close, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + t_o + end + end + t_o + end + if @per.table==:curls or @per.table==:tics + if (@per.table==:curls \ + and t_o =~/^\}table/) \ + or (@per.table==:tics \ + and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.table=:off + headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] + @h={ + head_: headings, + cols: columns, + widths: widths, + idx: idx, + obj: @rows, + } + t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) + tuned_file << t_o + @h,@rows=nil,'' + h={ + is_for: :table, + obj: '', + sym: :table_close, + num: @num_id[:table], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + t_o + else + if t_o.is_a?(String) \ + and t_o !~/^(?:table\{|```[ ]+table)/ + t_o=t_o.gsub(/^\n+/m,''). + gsub(/\n+/m,"#{Mx[:tc_p]}") + @rows += t_o + Mx[:tc_c] + end + t_o=nil + end + end + if @per.code==:curls \ + or @per.code==:tics + if (@per.code==:curls \ + && t_o =~/^\}code/) \ + or (@per.code==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m) + @per.code=:off + if @tuned_code[-1] + @tuned_code[-1]. + gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') + end + obj=@tuned_code.join("\n") + tags=[] + h={ + obj: obj, + idx: idx, + syntax: @per.lngsyn, + tags: tags, + num: @num_id[:code_block], + number_: @codeblock_numbered, + } + @per.lngsyn=:txt + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) + @tuned_code=[] + tuned_file << t_o + h={ + is_for: :code, + obj: '', + sym: :code_close, + num: @num_id[:code_block], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + end + if (@per.code==:curls \ + || @per.code==:tics) \ + and t_o.is_a?(String) + sub_array=t_o.dup + "#{Mx[:br_nl]}" + @line_mode=[] + sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/} + t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join + @tuned_code << t_o + t_o=nil + end + elsif (@per.poem==:curls \ + || @per.poem==:tics) \ + or (@per.box==:curls \ + || @per.box==:tics) \ + or (@per.group==:curls \ + || @per.group==:tics) \ + or (@per.block==:curls \ + || @per.block==:tics) \ + or (@per.alt==:curls \ + || @per.alt==:tics) \ + or (@per.quote==:open \ + && t_o =~/`:quote_close`/m) #not + if (@per.poem==:curls \ + && t_o =~/^\}poem$/m) \ + or (@per.poem==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.poem=:off + h={ + is_for: :poem, + obj: '', + idx: idx, + sym: :poem_close, + num: @num_id[:poem], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif (@per.box==:curls \ + && t_o =~/^\}box/) \ + or (@per.box==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.box=:off + obj,tags=extract_tags(@tuned_block.join("\n")) + h={ + obj: obj, + idx: idx, + tags: tags, + num: @num_id[:box], + } + @tuned_block=[] + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) + tuned_file << t_o + h={ + is_for: :box, + obj: '', + idx: idx, + sym: :box_close, + num: @num_id[:box], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif (@per.group==:curls \ + && t_o =~/^\}group/) \ + or (@per.group==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.group=:off + obj,tags=extract_tags(@tuned_block.join("\n")) + h={ + obj: obj, + idx: idx, + tags: tags, + num: @num_id[:group], + } + @tuned_block=[] + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) + tuned_file << t_o + h={ + is_for: :group, + obj: '', + sym: :group_close, + num: @num_id[:group], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif (@per.block==:curls \ + && t_o =~/^\}block/) \ + or (@per.block==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.block=:off + obj,tags=extract_tags(@tuned_block.join("\n")) + h={ + obj: obj, + idx: idx, + tags: tags, + num: @num_id[:block], + } + @tuned_block=[] + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) + tuned_file << t_o + h={ + is_for: :block, + obj: '', + sym: :block_close, + num: @num_id[:block], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif (@per.alt==:curls \ + && t_o =~/^\}alt/) \ + or (@per.alt==:tics \ + && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) + @per.alt=:off + obj,tags=extract_tags(@tuned_block.join("\n")) + h={ + obj: obj, + idx: idx, + tags: tags, + num: @num_id[:alt], + } + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) + @tuned_block=[] + tuned_file << t_o + h={ + is_for: :alt, + obj: '', + sym: :alt_close, + num: @num_id[:alt], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif @per.quote==:open \ + and t_o =~/`:quote_close`/m + @per.quote=:off + h={ + is_for: :quote, + idx: idx, + obj: '', + sym: :quote_close, + num: @num_id[:quote], + } + t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) + elsif @per.quote==:open + t_o,tags=extract_tags(t_o) + h={ + indent: 1, + obj: t_o, + idx: idx, + note_: note, + image_: image, + tags: tags, + quote: quotes?, + } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + if (@per.poem==:curls \ + || @per.poem==:tics) \ + or (@per.group==:curls \ + || @per.group==:tics) \ + or (@per.alt==:curls \ + || @per.alt==:tics) \ + and t_o =~/\S/ \ + and t_o !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \ + and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic + sub_array=t_o.dup + @line_mode=sub_array.scan(/.+/) + type=if @per.poem==:curls or @per.poem==:tics + t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join + poem=t_o.split(/\n\n/) + poem.each do |v| + v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") + obj,tags=extract_tags(v) + h={ + obj: obj, + tags: tags, + num: @num_id[:poem], + } + t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) + tuned_file << t_o + end + :poem + else :group + end + end + @verse_count+=1 if @per.poem==:curls or @per.poem==:tics + end + if @per.code==:off + if @per.poem==:curls or @per.poem==:tics \ + or @per.box==:curls or @per.box==:tics \ + or @per.group==:curls or @per.group==:tics \ + or @per.alt==:curls or @per.alt==:tics \ + or (@per.quote==:open and t_o =~/`:quote_close`/m) + if t_o.is_a?(String) + t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + t_o=t_o + Mx[:br_nl] if t_o =~/\S+/ + elsif t_o.is==:group \ + || t_o.is==:block \ + || t_o.is==:alt \ + || t_o.is==:box \ + || t_o.is==:verse + t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}"). + gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + end + @tuned_block << t_o if t_o =~/\S+/ + else tuned_file << t_o + end + else tuned_file << t_o + end + end + tuned_file + end + def identify_parts + tuned_file=[] + @tuned_block,@tuned_code=[],[] + @@counter,@verse_count=0,0 + @num_id={ + code_block: 0, + poem: 0, + box: 0, + group: 0, + alt: 0, + quote: 0, + table: 0, + } + @metadata={} + @data,bibliography=SiSU_AO_References::Bibliography.new(@md,@data).biblio_extraction + tuned_file=extract_structure_loop(@data,tuned_file) + if @md.flag_endnotes + tuned_file << @pb + h={ + ln: 1, + lc: 1, + obj: 'Endnotes', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + ln: 4, + lc: 2, + obj: 'Endnotes', + name: 'endnotes', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + obj: 'Endnotes' + } + end + if @md.flag_auto_biblio + tuned_file << @pb + h={ + ln: 1, + lc: 1, + obj: 'References', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + ln: 4, + lc: 2, + obj: 'Bibliography', + name: 'biblio', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + obj: 'Bibliography' + } + citenumber=0 + bibliography.each do |c| + citenumber +=1 if c.is_a?(Hash) + if c[:is]==:book + h={ + obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]}) #{c[:url]}}, + tags: [c[:id]], + hang: 0, + indent: 2, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + elsif c[:is]==:article + h={ + obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:journal]} #{c[:volume]} (#{c[:year]}) #{c[:url]}}, + tags: [c[:id]], + hang: 0, + indent: 2, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + end + elsif @md.flag_biblio + tuned_file << @pb + h={ + ln: 1, + lc: 1, + obj: 'References', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + ln: 4, + lc: 2, + obj: 'Bibliography', + name: 'biblio', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + obj: 'Bibliography' + } + if bibliography.length > 0 + tuned_file=extract_structure_loop(bibliography,tuned_file) + else + tuned_file, citations = + SiSU_AO_References::Citations.new(@md,tuned_file).songsheet # ao_references.rb + citenumber=0 + citations.compact.each do |c| + citenumber +=1 if c.is_a?(Hash) + if c[:is]==:book + h={ + obj: %{[#{citenumber}] *{#{c[:author]}}* /{#{c[:publication]}}/ (#{c[:year]})}, + hang: 0, + indent: 2, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + elsif c[:is]==:article + h={ + obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:publication]} editor #{c[:editor]} (#{c[:year]})}, + hang: 0, + indent: 2, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + end + end + end + if @md.book_idx + tuned_file << @pb + h={ + ln: 1, + lc: 1, + obj: 'Index', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + ln: 4, + lc: 2, + obj: 'Index', + name: 'book_index', + autonum_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + obj: 'Index' + } + end + tuned_file << @pb + h={ + ln: 1, + lc: 1, + obj: 'Metadata', + autonum_: false, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + ln: 4, + lc: 2, + obj: 'SiSU Metadata, document information', + name: 'metadata', + autonum_: false, + ocn_: false, + } + tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) + h={ + obj: 'eof', + } + meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata) + [tuned_file,meta,bibliography] + end + def table_rows_and_columns_array(table_str) + table=[] + table_str.split(/#{Mx[:tc_c]}/).each do |table_row| + table_row_with_columns=table_row.split(/#{Mx[:tc_p]}/) + table << table_row_with_columns + end + table + end + def meta_heading(h) + h={ + lv: h[:lv], + ln: h[:ln], + name: h[:name], + obj: h[:obj], + ocn: '0', + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + end + def meta_para(str) + h={ + obj: str, + ocn_: false, + } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + def build_lines(type=:none) + lines=@data + lines.each.map do |line| + line=if line =~/\S/ \ + and line !~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|\}code)/ \ + and line !~/^(?:```[ ]+code(?:\.[a-z][0-9a-z_]+)?|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ + and not line.is_a?(Hash) #watch + @@counter+=1 if @per.code==:curls or @per.code==:tics + line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). + gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") + line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case + line=if line =~/(?:https?|file|ftp):\/\/\S+$/ + line.gsub(/\s*$/," #{Mx[:br_nl]}") + else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' + end + elsif line =~/^\s*$/ + line.gsub(/\s*$/,"#{Mx[:br_nl]}") + else line + end + line + end + end + end + class Structure # this must happen early + def initialize(md) + @md=md + end + def structure(data) + data.compact.each do |dob| + structure_markup(dob) + end + end + def structure_markup(dob) #build structure where structure provided only in meta header + dob=if dob.is==:para \ + && (((dob.hang !~/[1-9]/) && (dob.indent !~/[1-9]/)) \ + || (dob.hang != dob.indent)) \ + and not dob.bullet_ + dob=case dob.obj + when /^#{@md.lv0}/ + h={ + is: :heading, + lv: 'A', + ln: 0, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv1}/ + h={ + is: :heading, + lv: 'B', + ln: 1, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv2}/ + h={ + is: :heading, + lv: 'C', + ln: 2, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv3}/ + h={ + is: :heading, + lv: 'D', + ln: 3, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv4}/ + h={ + is: :heading, + lv: '1', + ln: 4, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv5}/ + h={ + is: :heading, + lv: '2', + ln: 5, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + when /^#{@md.lv6}/ + h={ + is: :heading, + lv: '3', + ln: 6, + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) + else dob + end + else dob + end + dob + end + end + class OCN + def initialize(md,data,fnx,process) + @md,@data,@fnx,@process=md,data,fnx,process + end + def structure_info + def lv + %w[A~ B~ C~ D~ 1 2 3 4] + end + def possible_parents(child) + case child + when /A~/ then 'none' + when /B~/ then 'A~' + when /C~/ then 'B~' + when /D~/ then 'C~' + when /1/ then 'A~, B~, C~, D~' + when /2/ then '1' + when /3/ then '2' + when /4/ then '3' + end + end + def possible_children(parent) + case parent + when /A~/ then 'B~, 1' + when /B~/ then 'C~, 1' + when /C~/ then 'D~, 1' + when /D~/ then '1' + when /1/ then '2' + when /2/ then '3' + when /3/ then '4' + when /4/ then 'none' + end + end + self + end + def document_structure_check_info(node,node_parent,status=:ok) + node_ln=/^([0-7])/.match(node)[1].to_i + node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i + if status==:error \ + or @md.opt.act[:maintenance][:set]==:on + puts %{node: #{node}, parent node: #{node_parent} #{status.upcase}} + if status==:error + node_ln=/^([0-7])/.match(node)[1].to_i + node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i + STDERR.puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) +parent level: #{structure_info.lv[node_parent_ln]} (possible child levels: #{structure_info.possible_children(structure_info.lv[node_parent_ln])}) +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end + end + end + end + def warning_incorrect_parent_level_or_level(txt) + puts %{ERROR. There is an error in markup of heading levels either here or in the parent heading. +The current header reads: +"#{txt}" +has incorrect level and/or parent level +--} + end + def required_headers_present? + if @process == :complete + unless (defined? @md.title \ + and @md.title.full) + STDERR.puts %{required header missing: + +@title: +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" +} + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end + end + unless (defined? @md.creator.author \ + and @md.creator.author) + STDERR.puts %{required header missing: + +@creator: + :author: anonymous? +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}" +} + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end + end + end + end + def ocn #and auto segment numbering increment + required_headers_present? + data=@data + @o_array=[] + node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocnh7=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image + regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|
+ if dob.is==:heading + @ln=ln=case dob.lv + when 'A' then 0 + when 'B' then 1 + when 'C' then 2 + when 'D' then 3 + when '1' then 4 + when '2' then 5 + when '3' then 6 + when '4' then 7 + when '5' then 8 + when '6' then 9 + end + end + if not dob.obj =~/~#|-#/ + ocn+=1 + end + if @process == :complete \ + or (@fnx == @md.opt.fns \ + && @md.opt.fns =~/.sst$/) + if dob.is==:heading \ + and (ln.to_s =~/^[0-9]/ \ + or ln.to_s =~@md.lv0 \ + or ln.to_s =~@md.lv1 \ + or ln.to_s =~@md.lv2 \ + or ln.to_s =~@md.lv3 \ + or ln.to_s =~@md.lv4 \ + or ln.to_s =~@md.lv5 \ + or ln.to_s =~@md.lv6 \ + or ln.to_s =~@md.lv7) + if not dob.obj =~/~#|-#/ + ocnh+=1 + end + if ln==0 \ + or ln=~@md.lv0 + @lev_occurences[:a] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh0+=1 #heading + node0="0:#{ocnh0};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node0="0:0;0" + end + document_structure_check_info(node0,node0) + @collapsed_lv0=0 + collapsed_level=@collapsed_lv0 + node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' + elsif ln==1 \ + or ln=~@md.lv1 + @lev_occurences[:b] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh1+=1 #heading + node1="1:#{ocnh1};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node1="1:0;0" + end + parent=if node0 + document_structure_check_info(node1,node0) + @collapsed_lv1=@collapsed_lv0+1 + node0 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node0,node0,:error) + node0 + end + collapsed_level=@collapsed_lv1 + node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX + elsif ln==2 \ + or ln=~@md.lv2 + @lev_occurences[:c] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh2+=1 + node2="2:#{ocnh2};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node2="2:0;0" + end + parent=if node1 + document_structure_check_info(node2,node1) + @collapsed_lv2=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node2,node0,:error) + node0 + end + collapsed_level=@collapsed_lv2 + node,ocn_sp=node2,"h#{ocnh}" + elsif ln==3 \ + or ln=~@md.lv3 + @lev_occurences[:d] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh3+=1 + node3="3:#{ocnh3};#{ocn}" + else + #document_structure_check_info(node0,node0,:error) #fix + ocn_flag=false + node3="3:0;0" + end + parent=if node2 + document_structure_check_info(node3,node2) + @collapsed_lv3=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + puts %{parent is :A~ & this level #{dob.lv} +either parent should be level :B~ +or this level should be level :B~ rather than #{dob.lv}} + document_structure_check_info(node3,node1,:error) + @collapsed_lv3=@collapsed_lv1+1 + node1 + else + document_structure_check_info(node3,node0,:error) + warning_incorrect_parent_level_or_level(dob.obj) + node0 + end + collapsed_level=@collapsed_lv3 + node,ocn_sp=node3,"h#{ocnh}" + elsif ln==4 \ + or ln=~@md.lv4 + @lev_occurences[:l1] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh4+=1 + node4="4:#{ocnh4};#{ocn}" + else + ocn_flag=false + node4="4:0;0" + end + parent=if node3 + document_structure_check_info(node4,node3) + @collapsed_lv4=@collapsed_lv3+1 + node3 + elsif node2 + document_structure_check_info(node4,node2) + @collapsed_lv4=@collapsed_lv2+1 + node2 + elsif node1 + document_structure_check_info(node4,node1) + @collapsed_lv4=@collapsed_lv1+1 + node1 + elsif node0 + document_structure_check_info(node4,node0) + @collapsed_lv4=@collapsed_lv0+1 + node0 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node4,node0,:error) + node0 + end + collapsed_level=@collapsed_lv4 + node,ocn_sp=node4,"h#{ocnh}" + elsif ln==5 \ + or ln=~@md.lv5 + @lev_occurences[:l2] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh5+=1 + node5="5:#{ocnh5};#{ocn}" + else + ocn_flag=false + node5="5:0;0" + end + parent=if node4 + document_structure_check_info(node5,node4) + @collapsed_lv5=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node3,:error) + @collapsed_lv5=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node2,:error) + @collapsed_lv5=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node1,:error) + @collapsed_lv5=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node5,node0,:error) + node0 + end + collapsed_level=@collapsed_lv5 + node,ocn_sp=node5,"h#{ocnh}" + elsif ln==6 \ + or ln=~@md.lv6 + @lev_occurences[:l3] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh6+=1 + node6="6:#{ocnh6};#{ocn}" + else + ocn_flag=false + node6="6:0;0" + end + parent=if node5 + document_structure_check_info(node6,node5) + @collapsed_lv6=@collapsed_lv5+1 + node5 + elsif node4 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) +either parent should be level #5 (2~) +or this level should be #5 (2~) rather ##{dob.ln} (#{dob.lv}~)" + document_structure_check_info(node6,node4,:error) + @collapsed_lv6=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node3,:error) + @collapsed_lv6=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node2,:error) + @collapsed_lv6=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node1,:error) + @collapsed_lv6=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node6,node0,:error) + node0 + end + collapsed_level=@collapsed_lv6 + node,ocn_sp=node6,"h#{ocnh}" + elsif ln==7 \ + or ln=~@md.lv7 + @lev_occurences[:l4] += 1 + if not dob.obj =~/~#|-#/ + ocn_flag=true + ocnh7+=1 + node7="7:#{ocnh7};#{ocn}" + else + ocn_flag=false + node7="7:0;0" + end + parent=if node6 + document_structure_check_info(node7,node6) + @collapsed_lv7=@collapsed_lv6+1 + node5 + elsif node5 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #5 (2~) & this level ##{dob.ln} (#{dob.lv}~) +either parent should be level #6 (3~) +or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" + document_structure_check_info(node7,node5,:error) + @collapsed_lv6=@collapsed_lv5+1 + node5 + elsif node4 + warning_incorrect_parent_level_or_level(dob.obj) + puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) +either parent should be level 6~ +or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" + document_structure_check_info(node7,node4,:error) + @collapsed_lv6=@collapsed_lv4+1 + node4 + elsif node3 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node3,:error) + @collapsed_lv6=@collapsed_lv3+1 + node3 + elsif node2 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node2,:error) + @collapsed_lv6=@collapsed_lv2+1 + node2 + elsif node1 + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node1,:error) + @collapsed_lv6=@collapsed_lv1+1 + node1 + else + warning_incorrect_parent_level_or_level(dob.obj) + document_structure_check_info(node7,node0,:error) + node0 + end + collapsed_level=@collapsed_lv7 + node,ocn_sp=node7,"h#{ocnh}" + end + else + unless @lev_occurences[:l1] > 0 + STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} + puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') + exit + end + unless @ln >= 4 + lev=case @ln + when 0 then 'A' + when 1 then 'B' + when 2 then 'C' + when 3 then 'D' + when 4 then '1' + when 5 then '2' + when 6 then '3' + when 7 then '4' + when 8 then '5' + when 9 then '6' + end + STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} + puts dob.obj.gsub(/^(.{1,80})/,'"\1"') + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + break + else exit + end + end + if not dob.obj =~/~#|-#/ + ocn_flag=true + else + ocn_flag=false + end + ocno+=1 + if dob.is==:table + ocnt+=1 + ocn_sp,parent="t#{ocnt}",node + elsif dob.is==:code + ocnc+=1 + ocn_sp,parent="c#{ocnc}",node + elsif dob.is==:group \ + || dob.is==:box \ + || dob.is==:block \ + || dob.is==:alt \ + || dob.is==:verse + ocng+=1 #group, poem + ocn_sp,parent="g#{ocng}",node + elsif dob.is==:image #check + ocni+=1 + ocn_sp,parent="i#{ocni}",node + else ocnp+=1 #paragraph + ocn_sp,parent="p#{ocnp}",node + end + end + end + if dob.is==:heading + if ocn_flag==true + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc= + ln, node, ocn, ocn_flag, ocn_dv,ocn_sp, parent, collapsed_level + else + ocnu+=1 + heading_use=:ok + if dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') + heading_use=:ok + elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ + dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') + heading_use=:dummy + end + dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_, dob.odv,dob.osp,dob.parent,dob.lc= + ln, node, nil, ocn_flag,heading_use,ocn_dv, ocn_sp, parent, collapsed_level + end + else + if dob.of !=:meta \ + && dob.of !=:comment \ + && dob.of !=:layout + if ocn_flag == true + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + ocn, ocn_flag,ocn_dv, ocn_sp, parent + else + ocnu+=1 + dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj + ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" + dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= + nil, ocn_flag,ocn_dv, ocn_sp, parent + end + end + end + h + else dob + end + if dob.is==:code \ + || dob.is==:verse \ + || dob.is==:alt \ + || dob.is==:box \ + || dob.is==:group \ + || dob.is==:block + dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out + end + @o_array << dob + end + if @process == :complete \ + or (@fnx == @md.opt.fns \ + && @md.opt.fns =~/.sst$/) + unless @lev_occurences[:a] == 1 + STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} +There must be one level A~ (no more and no less) +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end + end + unless @lev_occurences[:l1] > 0 + STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} +There must be at least one level 1~ (and as many as required) +SKIPPED processing file: +[#{@md.opt.lng}] "#{@md.fns}"} + if @md.opt.act[:no_stop][:set]==:on + $process_document = :skip + else exit + end + end + end + @o_array + end + end + class XML + def initialize(md,data) + @data,@md=data,md + end + def dom + @s=[ 'A', 'B', 'C', 'D', '1', '2', '3' ] + tuned_file=structure_build + tuned_file + end + def spaces + Ax[:spaces] + end + def structure_build + data=@data + tuned_file=[] + hs=[0,false,false,false] + t={ + lv: @s[0], + status: :open, + } + tuned_file << tags(t) + if @md.opt.act[:verbose_plus][:set]==:on + puts "\nXML sisu structure outline --->\n" + puts "<#{@s[0]}>" + end + data.each_with_index do |o,i| + if o.is==:heading \ + || o.is==:heading_insert + case o.ln + when 0 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs=[0,true,false,false,false] + when 1 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs=[1,true,true,false,false] + when 2 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs=[2,true,true,true,false] + when 3 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs=[3,true,true,true,true] + when 4 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs[0]=4 + when 5 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs[0]=5 + when 6 + tuned_file << tag_close(o.ln,hs) + tuned_file << tag_open(o,@s) + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(o.ln,hs) + puts_tag_open(o,@s) + end + hs[0]=6 + end + end + tuned_file << o + end + if @md.opt.act[:verbose_plus][:set]==:on + puts_tag_close(0,hs) + end + tuned_file << tag_close(0,hs) + tuned_file=tuned_file.flatten + end + def tags(o) + tag=(o[:status]==:open) \ + ? %{<#{o[:lv]} id="#{o[:node]}">} + : "" + ln=case o[:lv] + when 'A' then 0 + when 'B' then 1 + when 'C' then 2 + when 'D' then 3 + when '1' then 4 + when '2' then 5 + when '3' then 6 + when '4' then 7 + when '5' then 8 + when '6' then 9 + end + h={ + tag: tag, + node: o[:node], + lv: o[:lv], + ln: ln, + status: o[:status], + } + SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments + end + def tag_open(o,tag) + t={ lv: tag[o.ln], node: o.node, status: :open } + t_o=tags(t) + t_o + end + def tag_close(lev,hs) + ary=[] + case hs[0] + when 0 + if (lev <= 0) and hs[0] + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 1 + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 2 + if (lev <= 2) and hs[2] + t={ + lv: @s[2], + status: :close, + } + ary << tags(t) + end + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 3 + if (lev <= 3) and hs[3] + t={ + lv: @s[3], + status: :close, + } + ary << tags(t) + end + if (lev <= 2) and hs[2] + t={ + lv: @s[2], + status: :close, + } + ary << tags(t) + end + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 4 + if (lev <= 4) + t={ + lv: @s[4], + status: :close, + } + ary << tags(t) + end + if (lev <= 3) and hs[3] + t={ + lv: @s[3], + status: :close, + } + ary << tags(t) + end + if (lev <= 2) and hs[2] + t={ + lv: @s[2], + status: :close, + } + ary << tags(t) + end + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 5 + if (lev <= 5) + t={ + lv: @s[5], + status: :close, + } + ary << tags(t) + end + if (lev <= 4) + t={ + lv: @s[4], + status: :close, + } + ary << tags(t) + end + if (lev <= 3) and hs[3] + t={ + lv: @s[3], + status: :close, + } + ary << tags(t) + end + if (lev <= 2) and hs[2] + t={ + lv: @s[2], + status: :close, + } + ary << tags(t) + end + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + when 6 + if (lev <= 6) + t={ + lv: @s[6], + status: :close, + } + ary << tags(t) + end + if (lev <= 5) + t={ + lv: @s[5], + status: :close, + } + ary << tags(t) + end + if (lev <= 4) + t={ + lv: @s[4], + status: :close, + } + ary << tags(t) + end + if (lev <= 3) and hs[3] + t={ + lv: @s[3], + status: :close, + } + ary << tags(t) + end + if (lev <= 2) and hs[2] + t={ + lv: @s[2], + status: :close, + } + ary << tags(t) + end + if (lev <= 1) and hs[1] + t={ + lv: @s[1], + status: :close, + } + ary << tags(t) + end + if (lev==0) + t={ + lv: @s[0], + status: :close, + } + ary << tags(t) + end + end + ary + end + def puts_tag_open(o,tag) + puts %{#{spaces*o.ln}<#{tag[o.ln]} id="#{o.node}">} + end + def puts_tag_close(lev,hs) + case hs[0] + when 0 + #puts "#{spaces*0}" if (lev <= 0) and hs[0] + puts "" if (lev==0) + when 1 + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + when 2 + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + when 3 + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + when 4 + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + when 5 + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + when 6 + puts "#{spaces*6}" if (lev <= 6) + puts "#{spaces*5}" if (lev <= 5) + puts "#{spaces*4}" if (lev <= 4) + puts "#{spaces*3}" if (lev <= 3) and hs[3] + puts "#{spaces*2}" if (lev <= 2) and hs[2] + puts "#{spaces*1}" if (lev <= 1) and hs[1] + puts "" if (lev==0) + end + end + end +end +__END__ diff --git a/lib/sisu/ao_endnotes.rb b/lib/sisu/ao_endnotes.rb new file mode 100644 index 00000000..bcb09e13 --- /dev/null +++ b/lib/sisu/ao_endnotes.rb @@ -0,0 +1,136 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Endnotes + class Endnotes + def initialize(md,data,endnote_array=nil) + @md,@data,@endnote_array= + md, data, endnote_array + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 + end + def endnotes + data=@data + endnote_ref=1 + @tuned_file=data.each.map do |dob| + # manually numbered endnotes --> + if @md.opt.selections.str =~/--no-asterisk|--no-annotate/ + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') + end + if @md.opt.selections.str =~/--no-dagger|--no-annotate/ + dob.obj=dob.obj. + gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') + end + if (defined? dob.obj) \ + && (defined? dob.is) \ + && dob.is !=:code + case dob.obj # auto-numbered endnotes --> + when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ + dob.obj=dob.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') + word_mode=dob.obj.scan(/\S+/m) + word_mode=endnote_call_number(word_mode) + dob.obj=word_mode.join(' ') + endnote_ref+=1 + when /~\^(?:\s|$)/ #%note inserts endnotes previously gathered from /^(|[-~]\{{3})/ (in earlier loop) + word_mode=dob.obj.scan(/\S+/m) + word_mode=endnote_call_number(word_mode) + dob.obj=word_mode.join(' ') + endnote_ref+=1 + end + end + dob + end.flatten + @endnote_counter, + @endnote_counter_asterisk, + @endnote_counter_dag= + 1,1,1 + @tuned_file + end + def endnote_call_number(words) + words.each do |word| + case word + when /#{Mx[:en_a_o]}/ + unless word =~/#{Mx[:en_a_o]}[*+]+/ + word.gsub!(/#{Mx[:en_a_o]}/, + "#{Mx[:en_a_o]}#{@endnote_counter} ") + @endnote_counter+=1 + end + when /#{Mx[:en_b_o]}/ + if word =~/#{Mx[:en_b_o]}[+]/ + word.gsub!(/#{Mx[:en_b_o]}[+]/, + "#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") + @endnote_counter_dag+=1 + else + word.gsub!(/#{Mx[:en_b_o]}[*]?/, + "#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") + @endnote_counter_asterisk+=1 + end + when /~\^/ + if @endnote_array + word.gsub!(/~\^/, + "#{@endnote_array[@endnote_counter-1]}") + @endnote_counter+=1 + end + end + end + end + end +end +__END__ diff --git a/lib/sisu/ao_expand_insertions.rb b/lib/sisu/ao_expand_insertions.rb new file mode 100644 index 00000000..2d93f933 --- /dev/null +++ b/lib/sisu/ao_expand_insertions.rb @@ -0,0 +1,514 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Insertions + class Insertions + def initialize(md,data) + @md,@data=md,data + end + def output_filetypes_in_cmd(cmd_shortcut,lnk=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used + act_defaults=SiSU_Env::InfoProcessingFlag.new + cmd_list=case cmd_shortcut.inspect #check on expectation, string v array + when /0/ then act_defaults.act_0.str + when /1/ then act_defaults.act_1.str + when /2/ then act_defaults.act_2.str + when /3/ then act_defaults.act_3.str + when /4/ then act_defaults.act_4.str + when /5/ then act_defaults.act_5.str + when /6/ then act_defaults.act_6.str + when /7/ then act_defaults.act_7.str + when /8/ then act_defaults.act_8.str + when /9/ then act_defaults.act_9.str + end + file_type_names={} + file_type_names[:gen],file_type_names[:src]=[],[] + file_type_names[:gen] <<= if cmd_list =~ /\b--manifest\b/ + "~^ { document manifest }#{lnk[:manifest]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b--html\b/ + [ + " { html, segmented text }#{lnk[:html_toc]}", + " { html, scroll, document in one }#{lnk[:html_doc]}", + ] + end + file_type_names[:gen] <<= if cmd_list =~ /\b--epub\b/ + [" { epub }#{lnk[:epub]}"] + end + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-landscape/ + [ + " { pdf, landscape }#{lnk[:pdf_landscape]}", + ] + end + file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ + or cmd_list =~ /--pdf-portrait/ + [ + " { pdf, portrait }#{lnk[:pdf_portrait]}", + ] + end + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--odt|--odf)\b/ + " { odf:odt, open document text }#{lnk[:odt]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b--xhtml\b/ + " { xhtml scroll }#{lnk[:xhtml]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b--docbook\b/ + " { docbook }#{lnk[:docbook]}" #CHECK + end + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-sax\b/ + " { xml, sax }#{lnk[:xml_sax]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b--xml-dom\b/ + " { xml, dom }#{lnk[:xml_dom]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b(?:--txt|--text|--plaintext)\b/ + " { plain text utf-8 }#{lnk[:txt]}" + end + #file_type_names[:gen] <<= if cmd_list =~ /g/ + # 'wiki.txt' + #end + file_type_names[:gen] <<= if cmd_list =~ /\b--concordance\b/ + " { concordance }#{lnk[:html_concordance]}" + end + file_type_names[:gen] <<= if cmd_list =~ /\b--digest\b/ + " { dcc, document content certificate (digests) }#{lnk[:digest]}" + end + file_type_names[:src] <<= if source and cmd_shortcut =~ /\b--source\b/ + " { markup source text }#{lnk[:source]}" + end + file_type_names[:src] <<= if cmd_shortcut =~ /\b--sisupod\b/ + " { markup source (zipped) pod }#{lnk[:sisupod]}" + end + file_type_names[:gen]=file_type_names[:gen].flatten + file_type_names[:src]=file_type_names[:src].flatten + file_type_names + end + def by_language(linked_doc,lng,src=nil) + @linked_doc,@lng,@src=linked_doc,lng,src + @base_path="#{@md.file.output_path.base.url}/#{lng}" + def fnh + { + fn: @linked_doc, + } + end + def path_and_file(fn,pth) + @base_path + '/' + pth + '/' + fn + end + def manifest + fn=@md.file.base_filename.manifest(fnh) + path_and_file(fn,'manifest') + end + def html_toc + fn=@md.file.base_filename.html_segtoc(fnh) + @base_path + '/html/' + @linked_doc + '/' + fn + end + def html_doc + fn=@md.file.base_filename.html_scroll(fnh) + path_and_file(fn,'html') + end + def html_concordance + fn=@md.file.base_filename.html_concordance + @base_path + '/html/' + @linked_doc + '/' + fn + end + def epub + fn=@md.file.base_filename.epub(fnh) + path_and_file(fn,'epub') + end + def pdf_landscape + fn=@md.file.base_filename.pdf_l_a4(fnh) + path_and_file(fn,'pdf') + end + def pdf_portrait + fn=@md.file.base_filename.pdf_p_a4(fnh) + path_and_file(fn,'pdf') + end + def odt + fn=@md.file.base_filename.odt(fnh) + path_and_file(fn,'odt') + end + def xhtml + fn=@md.file.base_filename.xhtml(fnh) + path_and_file(fn,'xhtml') + end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end + def xml_sax + fn=@md.file.base_filename.xml_sax(fnh) + path_and_file(fn,'xml_sax') + end + def xml_dom + fn=@md.file.base_filename.xml_dom(fnh) + path_and_file(fn,'xml_dom') + end + def txt + fn=@md.file.base_filename.txt(fnh) + path_and_file(fn,'txt') + end + def digest + fn=@md.file.base_filename.hash_digest(fnh) + path_and_file(fn,'digest') + end + def source + @base_path + '/src/' + @src + end + def sisupod + @base_path + '/src/' + @src + '.zip' + end + self + end + def by_filetype(linked_doc,lng,src=nil) + @linked_doc,@lng,@src=linked_doc,lng,src + @lc=SiSU_Env::FilenameLanguageCodeInsert.new(@md.opt,lng). + language_code_insert + @base_path="#{@md.file.output_path.base.url}" + def fnh + { + fn: @linked_doc, + lng: @lc, + } + end + def path_and_file(fn,pth) + @base_path + '/' + pth + '/' + fn + end + def manifest + fn=@md.file.base_filename.manifest(fnh) + path_and_file(fn,'manifest') + end + def html_toc + fn=@md.file.base_filename.html_segtoc(fnh) + path_and_file(fn,'html') + end + def html_doc + fn=@md.file.base_filename.html_scroll(fnh) + path_and_file(fn,'html') + end + def html_concordance + fn=@md.file.base_filename.html_concordance + path_and_file(fn,'html') + end + def epub + fn=@md.file.base_filename.epub(fnh) + path_and_file(fn,'epub') + end + def pdf_landscape + fn=@md.file.base_filename.pdf_l_a4(fnh) + path_and_file(fn,'pdf') + end + def pdf_portrait + fn=@md.file.base_filename.pdf_p_a4(fnh) + path_and_file(fn,'pdf') + end + def odt + fn=@md.file.base_filename.odt(fnh) + path_and_file(fn,'odt') + end + def xhtml + fn=@md.file.base_filename.xhtml(fnh) + path_and_file(fn,'xhtml') + end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn,'docbook') + end + def xml_sax + fn=@md.file.base_filename.xml_sax(fnh) + path_and_file(fn,'xml_sax') + end + def xml_dom + fn=@md.file.base_filename.xml_dom(fnh) + path_and_file(fn,'xml_dom') + end + def txt + fn=@md.file.base_filename.txt(fnh) + path_and_file(fn,'txt') + end + def digest + fn=@md.file.base_filename.hash_digest(fnh) + path_and_file(fn,'digest') + end + def source + @base_path + '/src/' + @src + end + def sisupod + @base_path + '/src/' + @src + '.zip' + end + self + end + def by_filename(linked_doc,lng,src=nil) + @linked_doc,@lng,@src=linked_doc,lng,src + @lc=SiSU_Env::FilenameLanguageCodeInsert.new(@md.opt,lng).language_code_insert + @base_path="#{@md.file.output_path.base.url}/#{@linked_doc}" + def fnh + { + fn: @linked_doc, + lng: @lc, + } + end + def path_and_file(fn,pth=nil) + (pth.nil?) \ + ? @base_path + '/' + fn + : @base_path + '/' + pth + '/' + fn + end + def manifest + fn=@md.file.base_filename.manifest(fnh) + path_and_file(fn) + end + def html_toc + fn=@md.file.base_filename.html_segtoc(fnh) + path_and_file(fn) + end + def html_doc + fn=@md.file.base_filename.html_scroll(fnh) + path_and_file(fn) + end + def html_concordance + fn=@md.file.base_filename.html_concordance + path_and_file(fn) + end + def epub + fn=@md.file.base_filename.epub(fnh) + path_and_file(fn,'epub') + end + def pdf_landscape + fn=@md.file.base_filename.pdf_l_a4(fnh) + path_and_file(fn) + end + def pdf_portrait + fn=@md.file.base_filename.pdf_p_a4(fnh) + path_and_file(fn) + end + def odt + fn=@md.file.base_filename.odt(fnh) + path_and_file(fn) + end + def xhtml + fn=@md.file.base_filename.xhtml(fnh) + path_and_file(fn) + end + def docbook + fn=@md.file.base_filename.xml_docbook_book(fnh) + path_and_file(fn) + end + def xml_sax + fn=@md.file.base_filename.xml_sax(fnh) + path_and_file(fn) + end + def xml_dom + fn=@md.file.base_filename.xml_dom(fnh) + path_and_file(fn) + end + def txt + fn=@md.file.base_filename.txt(fnh) + path_and_file(fn) + end + def digest + fn=@md.file.base_filename.hash_digest(fnh) + path_and_file(fn) + end + def source + @base_path + '/' + @src + end + def sisupod + @base_path + '/' + @src + '.zip' + end + self + end + def expand_insertions? + data=@data + tuned_file,tuned_file_tmp=[],[] + codeblock_={ + status: :false, + type: :na, + } + data.each do |para| + codeblock_=if para =~/^code(?:\.[a-z][0-9a-z_]+)?\{/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :curl, + } + elsif para =~/^```[ ]+code(?:\.[a-z][0-9a-z_]+)?/ \ + and codeblock_[:status]==:false + { + status: :true, + type: :tics, + } + elsif codeblock_[:type]==:curl \ + and para =~/^\}code/m + { + status: :false, + type: :na, + } + elsif codeblock_[:type]==:tics \ + and para =~/^```(?:\s|$)/m + { + status: :false, + type: :na, + } + else codeblock_ + end + if para !~/^%+\s/ \ + and codeblock_[:status] != :true \ + and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ + @u=SiSU_Env::InfoEnv.new.url + m_cmd='' + if defined? @u.remote + if /(?.+?)\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para + m_pre=m_pre.strip + elsif /\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para + end + if m_linked_doc =~ /(\S+?)\/(\S+)/ + m_linked_doc,m_linked_doc_lang=$1,$2 + else + m_linked_doc,m_linked_doc_lang=m_linked_doc,@md.opt.lng_base + end + else + puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" + if /\{(?:~\^\s+)?(?.+?)\s\[(?\d[sS]*)\]\}\.\.\/(?\S+?)\/(?\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ =~ para + end + end + lnk=case @md.opt.dir_structure_by + when :language + { + manifest: by_language(m_linked_doc,m_linked_doc_lang).manifest, + html_toc: by_language(m_linked_doc,m_linked_doc_lang).html_toc, + html_doc: by_language(m_linked_doc,m_linked_doc_lang).html_doc, + epub: by_language(m_linked_doc,m_linked_doc_lang).epub, + pdf_landscape: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, + pdf_portrait: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, + odt: by_language(m_linked_doc,m_linked_doc_lang).odt, + xhtml: by_language(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_language(m_linked_doc,m_linked_doc_lang).docbook, + xml_sax: by_language(m_linked_doc,m_linked_doc_lang).xml_sax, + xml_dom: by_language(m_linked_doc,m_linked_doc_lang).xml_dom, + txt: by_language(m_linked_doc,m_linked_doc_lang).txt, + html_concordance: by_language(m_linked_doc,m_linked_doc_lang).html_concordance, + digest: by_language(m_linked_doc,m_linked_doc_lang).digest, + sisupod: by_language(m_linked_doc,m_linked_doc_lang,m_source).sisupod, + source: by_language(m_linked_doc,m_linked_doc_lang,m_source).source, + } + when :filetype + { + manifest: by_filetype(m_linked_doc,m_linked_doc_lang).manifest, + html_toc: by_filetype(m_linked_doc,m_linked_doc_lang).html_toc, + html_doc: by_filetype(m_linked_doc,m_linked_doc_lang).html_doc, + epub: by_filetype(m_linked_doc,m_linked_doc_lang).epub, + pdf_landscape: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, + pdf_portrait: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, + odt: by_filetype(m_linked_doc,m_linked_doc_lang).odt, + xhtml: by_filetype(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filetype(m_linked_doc,m_linked_doc_lang).docbook, + xml_sax: by_filetype(m_linked_doc,m_linked_doc_lang).xml_sax, + xml_dom: by_filetype(m_linked_doc,m_linked_doc_lang).xml_dom, + txt: by_filetype(m_linked_doc,m_linked_doc_lang).txt, + html_concordance: by_filetype(m_linked_doc,m_linked_doc_lang).html_concordance, + digest: by_filetype(m_linked_doc,m_linked_doc_lang).digest, + sisupod: by_filetype(m_linked_doc,m_linked_doc_lang,m_source).sisupod, + source: by_filetype(m_linked_doc,m_linked_doc_lang,m_source).source, + } + else + { + manifest: by_filename(m_linked_doc,m_linked_doc_lang).manifest, + html_toc: by_filename(m_linked_doc,m_linked_doc_lang).html_toc, + html_doc: by_filename(m_linked_doc,m_linked_doc_lang).html_doc, + epub: by_filename(m_linked_doc,m_linked_doc_lang).epub, + pdf_landscape: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, + pdf_portrait: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, + odt: by_filename(m_linked_doc,m_linked_doc_lang).odt, + xhtml: by_filename(m_linked_doc,m_linked_doc_lang).xhtml, + docbook: by_filename(m_linked_doc,m_linked_doc_lang).docbook, + xml_sax: by_filename(m_linked_doc,m_linked_doc_lang).xml_sax, + xml_dom: by_filename(m_linked_doc,m_linked_doc_lang).xml_dom, + txt: by_filename(m_linked_doc,m_linked_doc_lang).txt, + html_concordance: by_filename(m_linked_doc,m_linked_doc_lang).html_concordance, + digest: by_filename(m_linked_doc,m_linked_doc_lang).digest, + sisupod: by_filename(m_linked_doc,m_linked_doc_lang,m_source).sisupod, + source: by_filename(m_linked_doc,m_linked_doc_lang,m_source).source, + } + end + linked_title="#{m_pre}{#{m_txt} }#{lnk[:manifest]}#{m_note}\n\n" + tuned_file_tmp << linked_title + output_filetypes=output_filetypes_in_cmd(m_cmd,lnk) + output_filetypes[:gen].each do |desc| + if desc + tuned_file_tmp << if @u.remote + "#{Mx[:nbsp]*4} #{desc} " + else # remove ... + "[provide document placement host location]" + end + end + end + output_filetypes[:src].each do |desc| + if desc + tuned_file_tmp << if @u.remote + "#{Mx[:nbsp]*4} #{desc} " + else + "[provide document placement host location]" + end + end + end + tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' + tuned_file_tmp=[] + else tuned_file << para + end + end + tuned_file + end + end +end +__END__ diff --git a/lib/sisu/ao_hash_digest.rb b/lib/sisu/ao_hash_digest.rb new file mode 100644 index 00000000..ccfd1560 --- /dev/null +++ b/lib/sisu/ao_hash_digest.rb @@ -0,0 +1,174 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Hash + require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb + class ObjectDigest + def initialize(md,data,env=nil) + @md,@data,@env=md,data,env + @env ||=SiSU_Env::InfoEnv.new(@md.fns,@md) + end + def object_digest + # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes + # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) + # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) + # [digests should not include other digests] + data=@data.compact + @tuned_file=[] + sha_ =@env.digest(@md.opt).type + begin + sha_ ? (require 'digest/sha2') : (require 'digest/md5') + rescue LoadError + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error(sha_ + ' NOT FOUND') + end + data.each do |t_o| + unless t_o.obj.is_a?(Array) + t_o.obj=t_o.obj.strip + end + if (t_o.of !=:structure \ + && t_o.of !=:comment \ + && t_o.of !=:layout) \ + && t_o.ocn.is_a?(Fixnum) + case sha_ + when :sha512 + for hash_class in [ Digest::SHA512 ] + @tuned_file << stamped(t_o,hash_class) + end + when :sha256 + for hash_class in [ Digest::SHA256 ] + @tuned_file << stamped(t_o,hash_class) + end + when :md5 + for hash_class in [ Digest::MD5 ] + @tuned_file << stamped(t_o,hash_class) + end + end + else @tuned_file << t_o unless t_o.nil? + end + end + @tuned_file=@tuned_file.flatten + #use md5 or to create hash of each ao object including ocn, & add into to each ao object + end + def endnote_digest(data) + data.each.map do |en_plus| + case en_plus + when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ + if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ + t_o_txt,en_open,en_txt,en_close= + /(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m. + match(en_plus)[1..4] + stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup + digest_en_strip=case @env.digest(@md.opt).type + when :sha512 + Digest::SHA512.hexdigest(stripped_en) + when :sha256 + Digest::SHA256.hexdigest(stripped_en) + when :md5 + Digest::MD5.hexdigest(stripped_en) + else + Digest::SHA256.hexdigest(stripped_en) + end + t_o_txt + + en_open + + en_txt + + Mx[:id_o] + + digest_en_strip + + Mx[:id_c] + + en_close + else STDERR.puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up + end + else en_plus + end + end.join + end + def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary? + t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces + #SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup #check + #SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup #check + #SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst #check + unless t_o.is==:code + case t_o.obj + when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m + en_and_t_o_digest=[] + t_o.obj=t_o.obj. + gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch + t_o_plus_en=t_o.obj. + scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) + t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m + /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1] + else '' + end + t_o_plus_en << t_o_tail + en_and_t_o_digest << endnote_digest(t_o_plus_en) + en_and_t_o_digest.join(' ') + else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil? + end + else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil? + end + t_o #KEEP intact + end + def strip_clean_extra_spaces(s) # ao output tuned + s=s.dup + s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ + s=s.gsub(/ [ ]+/,' '). + gsub(/^ [ ]+/,''). + gsub(/ [ ]+$/,''). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2'). + gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') + end + end +end +__END__ diff --git a/lib/sisu/ao_idx.rb b/lib/sisu/ao_idx.rb new file mode 100644 index 00000000..494b9396 --- /dev/null +++ b/lib/sisu/ao_idx.rb @@ -0,0 +1,422 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_BookIndex + class BookIndex + def initialize(md,data,env=nil) + @md,@data,@env=md,data,env + @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ + @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ + @rgx_idx_ocn=/(.+?)~(\d+)/ + @env ||=SiSU_Env::InfoEnv.new(@md.fns) + end + def indexing_song + data=@data + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx,xhtml_idx= + extract_book_index(data) + data= + clean_and_insert_index( + data, + sisu_markup_idx_rel_html_seg + ) + [ + data, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] + end + def extract_book_index(data) + tuned_file=[] + idx_array=[] + data.each do |dob| + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 + @seg=dob.name + end + if defined? dob.idx \ + and dob.idx.is_a?(Hash) + idx_array << { + idx: dob.idx, + ocn: dob.ocn, + seg: @seg + } + end + tuned_file << dob if dob + end + if idx_array.length > 0 + the_idx=construct_book_index(idx_array) + if @md.book_idx + idx=index(the_idx) + sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx= + idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml] + else + sisu_markup_idx_rel= + sisu_markup_idx_rel_html_seg= + html_idx= + xhtml_idx= + nil + end + end + [ + tuned_file, + sisu_markup_idx_rel, + sisu_markup_idx_rel_html_seg, + html_idx, + xhtml_idx, + ] + end + def construct_book_index(idx_array) + the_idx={} + idx_array.each do |idx| + idx[:idx].each_pair do |term,term_info| + location=(term_info[:plus].to_i > 0) \ + ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}}) + : idx[:ocn].to_s + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms'] \ + and defined? the_idx[term]['node_0_terms'] + the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } + if term_info[:sub].is_a?(Array) \ + and term_info[:sub].length > 0 + term_info[:sub].each do |y| + y.each_pair do |subterm,subterm_info| + location=(subterm_info[:plus].to_i > 0) \ + ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}}) + : idx[:ocn].to_s + the_idx[term]={} \ + unless the_idx[term] \ + and defined? the_idx[term] + the_idx[term]['node_0_terms']=[] \ + unless the_idx[term]['node_0_terms']\ + and defined? the_idx[term]['node_0_terms'] + the_idx[term]['node_1_subterms']={} \ + unless the_idx[term]['node_1_subterms'] \ + and defined? the_idx[term]['node_1_subterms'] + the_idx[term]['node_1_subterms'][subterm]=[] \ + unless the_idx[term]['node_1_subterms'][subterm] \ + and defined? the_idx[term]['node_1_subterms'][subterm] + the_idx[term]['node_1_subterms'][subterm] << + { ocn: idx[:ocn], range: location, seg: idx[:seg] } + end + end + end + end + end + the_idx=the_idx.sort + the_idx + end + def clean_xml(str) + str=str.gsub(/&/,'&') + str + end + def index(the_idx) + @x=1 + idx={} + idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]= + [], [], [], [] + h={ + obj: Mx[:br_page] + } + o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) + idx[:sst_rel_html_seg] << o + idx[:sst_rel] << o + h={ + lv: '1', + name: 'index', + obj: "Index" + } + o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + idx[:sst_rel_html_seg] << o + idx[:sst_rel] << o + h={ + lv: '4', + name: 'idx', + obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}" + } + o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + idx[:sst_rel_html_seg] << o + idx[:sst_rel] << o + alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] + idx[:html] << '

' + idx[:xhtml] << '

' + alph.each do |x| + if x =~/[0-9]/ + idx[:html] << '' + idx[:xhtml] << '' + else + idx[:html] << + %{#{x},#{$ep[:hsp]}} + idx[:xhtml] << + %{#{x},#{$ep[:hsp]}} + end + end + idx[:html] << '

' + idx[:xhtml] << '

' + letter=alph.shift + idx[:html] << + %{\n

} + idx[:xhtml] << + %{\n

0 - 9

} + the_idx.each do |i| + i.each do |x| + if x.is_a?(String) + f=/^(\S)/.match(x)[1] + if letter < f + while letter < f + if alph.length > 0 + letter=alph.shift + idx[:html] << + %{\n

#{letter}

} + idx[:xhtml] << + %{\n

#{letter}

} + else break + end + end + end + idx[:sst_rel_html_seg] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + idx[:sst_rel] << + %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } + aname=x.gsub(/\s+/,'_') + idx[:html] << + %{\n

#{x}, } + c=clean_xml(x.dup) + idx[:xhtml] << + %{\n

#{c}, } + @o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last) + @t=idx[:sst_rel].index(idx[:sst_rel].last) + @q=idx[:html].index(idx[:html].last) + @r=idx[:xhtml].index(idx[:xhtml].last) + print "\n" + x + ', ' if @md.opt.act[:verbose_plus][:set]==:on + elsif x.is_a?(Array) + p 'array error? -->' + print x + elsif x.is_a?(Hash) + if x['node_0_terms'].is_a?(Array) + x['node_0_terms'].each do |a| + if a[:range] + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:range]}, } + print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on + elsif a[:ocn] + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{a[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{a[:ocn]}, } + print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on + else p 'error' + end + end + idx[:html][@q]=idx[:html][@q] + '

' + idx[:xhtml][@r]=idx[:xhtml][@r] + '

' + end + if x['node_1_subterms'] + x['node_1_subterms'].sort.each do |k,y| + if k !~/node_0_terms/ + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{k}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{k}, } + idx[:html][@q]= + idx[:html][@q] + + %{\n

#{k}, } + c=clean_xml(k.dup) + idx[:xhtml][@r]= + idx[:xhtml][@r] + + %{\n

#{c}, } + print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on + y.each do |z| + if z[:range] + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:range]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:range]}, } + print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on + elsif z[:ocn] + idx[:sst_rel_html_seg][@o]= + idx[:sst_rel_html_seg][@o] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } + idx[:sst_rel][@t]= + idx[:sst_rel][@t] + + %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } + idx[:html][@q]= + idx[:html][@q] + + %{#{z[:ocn]}, } + idx[:xhtml][@q]= + idx[:xhtml][@q] + + %{#{z[:ocn]}, } + print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on + else p 'error' + end + end + idx[:html][@q]=idx[:html][@q] + '

' + idx[:xhtml][@r]=idx[:xhtml][@r] + '

' + end + end + end + @x +=1 + end + end + end + print "\n" if @md.opt.act[:verbose_plus][:set]==:on + idx + end + def screen_print(the_idx) + the_idx.each do |i| + i.each do |x| + if x.is_a?(String) + print "\n" + x + ', ' + elsif x.is_a?(Array) + p 'array error? -->' + print x + elsif x.is_a?(Hash) + if x['node_0_terms'].is_a?(Array) + x['node_0_terms'].each do |a| + if a[:range] + print a[:range] + ', ' + elsif a[:ocn] + print a[:ocn] + ', ' + else p 'error' + end + end + end + if x['node_1_subterms'] + x['node_1_subterms'].sort.each do |k,y| + if k !~/node_0_terms/ + print "\n\t" + k + ', ' + y.each do |z| + if z[:range] + print z[:range] + ', ' + elsif z[:ocn] + print z[:ocn] + ', ' + else p 'error' + end + end + end + end + end + end + end + end + end + def output_idx(idx) + if @md.book_idx + path="#{@env.path.output}/#{@md.fnb}" + Dir.mkdir(path) unless FileTest.directory?(path) + puts "#{path}/#{@md.fn[:book_idx_html]} #{__FILE__}::#{__LINE__}" + html_index_file=File.new("#{path}/#{@md.fn[:book_idx_html]}",'w') + idx[:html].each {|x| html_index_file << x } + html_index_file.close + end + end + def clean_and_insert_index(data,sisu_markup_idx) + tuned_file=[] + data.each do |dob| + tuned_file << dob + if dob.obj =~/#{Mx[:br_endnotes]}/ \ + and sisu_markup_idx + sisu_markup_idx.each do |idx| + tuned_file << idx + end + end + end + tuned_file + end + def clean_index(data) #check on use of dob + data.each.map do |para| + para.gsub(/\n*#{@rgx_idx}/m,'') + end + end + end +end +__END__ diff --git a/lib/sisu/ao_images.rb b/lib/sisu/ao_images.rb new file mode 100644 index 00000000..06aec134 --- /dev/null +++ b/lib/sisu/ao_images.rb @@ -0,0 +1,187 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Images + class Images + begin + require 'RMagick' + include Magick + rescue LoadError + #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') + end + def initialize(md,data) + @md,@data=md,data + end + def images + data=@data + @rmgk=false + imagemagick_=true #imagemagick_=SiSU_Env::InfoSettings.new.program?('rmagick') + if imagemagick_ + begin + @rmgk=SiSU_Env::Load.new('RMagick').prog + rescue + @rmgk=false + end + else + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* use of RMagick is not enabled in sisurc.yml' + ).warn + end + end + data.select do |dob| + unless dob.is ==:table + dob.obj=dob.obj.strip + if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/ + m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ + if imagemagick_ + imgs=dob.obj.scan(m).flatten + img_col=img_row=nil + images=imgs.each do |image| + dir=SiSU_Env::InfoEnv.new(@md.fns) + path_image=[ + dir.path.image_source_include_local, + dir.path.image_source_include_remote, + dir.path.image_source_include + ] + image_path=nil + path_image.each do |img_pth| + image_path=img_pth + break if FileTest.exist?("#{img_pth}/#{image}") + end + if FileTest.exist?("#{image_path}/#{image}") + if @rmgk + img=Magick::ImageList.new("#{image_path}/#{image}") + img_col,img_row=img.columns,img.rows + else + if (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* RMagick not present, will attempt to use imagemagick (identify) directly' + ).warn + end + imgk=SiSU_Env::SystemCall.new.imagemagick + gmgk=SiSU_Env::SystemCall.new.graphicsmagick + if imgk or gmgk + if imgk + imgsys=`identify #{image_path}/#{image}`.strip #system call + elsif gmgk + imgsys=`gm identify #{image_path}/#{image}`.strip #system call + end + img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2] + img_col,img_row=img_col.to_i,img_row.to_i + else + errmsg='imagemagick or graphicsmagick are required to process images' + if @md.opt.act[:no_stop][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, proceeding (as requested) without image processing") + break + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + error("#{errmsg}, STOPPING") + exit + end + end + end + row=((img && defined? img.rows) ? img.rows : img_row) + col=((img && defined? img.columns) ? img.columns : img_col) + if img_col > img_row #landscape + if img_col> 640 + img_col=640 + img_row=((1.00*img_col/col)*row).round + end + else #portrait + if img_col> 640 + img_col=640 + img_row=((1.00*img_col/col)*row).round + end + if img_row > 640 + img_row=640 + img_col=((1.00*img_row/row)*col).round + end + end + dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}") + else + dob.obj=dob.obj. + gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, + '[ \1 (\2 missing) ]') + end + end + else + images=dob.obj.scan(m) do |image| + SiSU_Screen::Ansi.new( + @md.opt.act[:color_state][:set], + '*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image + ).warn unless @md.opt.act[:quiet][:set]==:on + end + end + end + end + if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ + dob.obj=dob.obj.gsub(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') + end + end + dob unless dob.nil? + end + end + end +end +__END__ +imgsys=`identify #{image_path}/#{image}`.strip diff --git a/lib/sisu/ao_metadata.rb b/lib/sisu/ao_metadata.rb new file mode 100644 index 00000000..1a9418ce --- /dev/null +++ b/lib/sisu/ao_metadata.rb @@ -0,0 +1,86 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Metadata + class Metadata + def initialize(md,metad) + @md,@metadata=md,metad + l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language + language=l[:n] + @tr=SiSU_Translate::Source.new(md,language) + end + def make_para(obj,ocn) + h={ + obj: obj, + ocn: 0 + } + SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) + end + def make_heading(obj,ocn,name,lv,ln) + h={ + lv: lv, + ln: ln, + name: name, + obj: obj, + ocn: 0 + } + SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) + end + def metadata + end + end +end +__END__ diff --git a/lib/sisu/ao_misc_arrange.rb b/lib/sisu/ao_misc_arrange.rb new file mode 100644 index 00000000..da54bb80 --- /dev/null +++ b/lib/sisu/ao_misc_arrange.rb @@ -0,0 +1,207 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_MiscArrangeText + class SI + def initialize(md,data) + @md,@data=md,data + end + def conditional_headings(para) + para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header + gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, + '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 + if para =~/^@\S+?:/ + para=para.gsub(/^@(\S+?):(\s+|$)/, + "#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). + gsub(/^@(\S+?):([+-])(\s+|$)/, + "#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") + end + para + end + def markup_blocks(para) + def ticks(para) + block_open,block_close,text=nil,nil,nil + if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m + @flag=:close + block_open,text,block_close= + /\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m. + match(para)[1..3] + ((para=~/^```[ ]+table(?:~h)?\s+/) \ + and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ + ? para + : (para=[]; para << block_open << text << block_close) + elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study + @flag=:open + block_open,text=/\A(```(?:[ ]+.+?))\n(.*?)\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << block_open << text + else + para << block_open + end + elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \ + and @flag==:open + @flag=:close + text,block_close= + /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(?:\s+=\{.+?\})?)\s*\Z/m.match(para)[1,2] + para=[] + if not text.to_s.empty? + para << text.to_s << block_close + else + para << block_close + end + else para + end + para + end + def ticks_remove(para) + unless @md.opt.act[:quiet][:set] ==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). + mark("ticks not recognized, ticks removed from pargraph\n#{para}") + end + para=para.gsub(/```[ ]+\S+[ ]*/m,''). + gsub(/```\s*/m,''). + strip + end + def ticks_quote(para) + @flag=:quote_open + text=para + para=[] + if text =~ /```[ ]+quote/m + para << '`:quote_open`' + text=text.gsub(/```[ ]+quote/m,'') + end + text=if text =~/(?:\n|\A)=\{.+?\}/m #exclude book index from indent markup + txt,bkidx,tail=/(.+?)((?:\n|\A)=\{.+?\}$)(.*)/m.match(text).captures + txt=txt.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + txt + bkidx + tail + else text.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') + end + para << text.gsub(/```/m,'') + if text =~/```/m + @flag=:quote_close + para << '`:quote_close`' + end + para + end + def curly_braces(para) + block_open,block_close,text=nil,nil,nil + para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + block_open,text,block_close= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1..3] + para=[] + para << block_open << text << block_close + elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m + block_open,text= + /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m. + match(para)[1,2] + para=[] + if not text.to_s.empty? + para << block_open << text + else + para << block_open + end + elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m + text,block_close= + /\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. + match(para)[1,2] + para=[] + if not text.to_s.empty? + para << text.to_s << block_close + else + para << block_close + end + else para + end + para + end + para=if (para =~/\A```[ ]+quote/m \ + and @flag !=:open) \ + or @flag==:quote_open + ticks_quote(para) + elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ + or @flag==:open + ticks(para) + elsif para =~/```/m + ticks_remove(para) + else + para + end + para=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|box|poem|alt|group|block|table)/m + curly_braces(para) + else + para + end + end + def prepare_text + data=@data + if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) + data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,''). + gsub(/^#!\s*\/usr\/bin\/env sisu/,'') + end + if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier + data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1'). + gsub(/^(sisu-[\d.]+)$/,'% \1') + end + data.each.map do |para| + para=conditional_headings(para) + markup_blocks(para) + end.flatten + end + end +end +__END__ diff --git a/lib/sisu/ao_numbering.rb b/lib/sisu/ao_numbering.rb new file mode 100644 index 00000000..fdf54605 --- /dev/null +++ b/lib/sisu/ao_numbering.rb @@ -0,0 +1,720 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Numbering + class Numbering + attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment + @@segments_count=0 + def initialize(md,data,fnx,process) + @md,@data,@fnx,@process=md,data,fnx,process + @obj=@type=@ocn=@lv=@name=@index=@comment=nil + @chosen_seg_names=[] + end + def chosen_seg_names(chosen,chosen_seg_name,dob,md,type) + @chosen_seg_names=if chosen.compact.uniq.length \ + == chosen.compact.length + chosen + else + if md.opt.act[:maintenance][:set]==:on + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen}\n" \ + + "#{chosen}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + end + chosen=chosen[0..-2] + chosen_seg_name=auto_numbering_exceptions(chosen,md,dob) + chosen << chosen_seg_name + end + end + def number_of_segments? + if @@segments_count==0 + @data.each do |dob| + if dob.is == :heading \ + and dob.lv == '1' + @@segments_count += 1 + end + end + @@segments_count + else @@segments_count + end + end + def numbering_song + begin + data=@data + data=number_plaintext_para(data) + data=auto_number_heading_ie_title(data.compact) #tr issue + data=ocn(data.compact) #watch + data=xml(data.compact) + data=minor_numbering(data.compact) + if @process==:complete + data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) + end + data=set_heading_top(data) unless @md.set_heading_top + [data,tags_map,ocn_html_seg_map] + ensure + @@segments_count=0 + end + end + def set_tags(tags,tag) + tags=if not tag.empty? \ + and tag !~/^\d+$/ + tag=tag.gsub(/[^a-z0-9._-]/,'') + [tag,tags].flatten + else tags + end + end + def number_plaintext_para(data) + @tuned_file=[] + data.each do |dob| + if (dob.of !=:block \ + && dob.of !=:comment \ + && dob.of !=:layout) \ + && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX + dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks + end + unless dob.obj.is_a?(Array) + dob.obj=dob.obj.gsub(/^\s+/,''). + gsub(/\s$/,"\n") + end + @tuned_file << dob + end + @tuned_file=@tuned_file.flatten + end + def number_sub_heading(dob,num,title_no) + unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix + dob.obj=case dob.name + when /-/ then dob.obj.gsub(/^/,"#{title_no} ") + when /^#/ then dob.obj.gsub(/^/,"#{title_no} ") + when /^[a-z_\.]+/ then dob.obj.gsub(/^/,"#{title_no} ") + else + dob.name=title_no if dob.name=~/^$/ #where title contains title number + dob.obj.gsub(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement + end + if @md.toc_lev_limit \ + and @md.toc_lev_limit < num + dob.obj=dob.obj.gsub(/^/,'!_ ') #bold line, watch + end + end + dob + end + def heading_tag_clean(heading_tag) + heading_tag=heading_tag. + gsub(/[ ]+/,'_'). + gsub(/["']/,''). + gsub(/[\/]/,'-'). + gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,''). + gsub(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,''). + gsub(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,''). + gsub(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,''). + gsub(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,''). + gsub(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,''). + gsub(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,''). + gsub(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,''). + gsub(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,''). + gsub(/#{Mx[:gl_bullet]}/,'') + end + def auto_number_heading_ie_title(data) #also does some segment naming + if defined? @md.make.num_top \ + and @md.make.num_top \ + and @md.make.num_top !~/^$/ + input||=@md.make.num_top + end + num_top=(input ? input.to_i : nil) + t_no1=t_no2=t_no3=0 + if num_top + no1=num_top; no2=(num_top + 1); no3=(num_top + 2) + end + chapter_number_counter=0 + data=data.compact + @tuned_file=data.each.map do |dob| #@md.seg_names << [additions to segment names] + title_no=nil + if dob.is ==:heading \ + && dob.autonum_ \ + and defined? @md.make.num_top \ + and @md.make.num_top !~/^$/ + if dob.lv=='1' \ + and dob.obj =~/^#\s|\s#(?:\s|$)/ + chapter_number_counter +=1 + dob.obj=dob.obj.gsub(/^#\s/,"#{chapter_number_counter} "). + gsub(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1") + end + if dob.ln==no1 + @subnumber=1 + @subnumber=0 if dob.ln==no1 + end + if dob.ln.to_s =~/^[0-6]/ \ + and not dob.use_ ==:dummy \ + and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix + if dob.ln==no1 + t_no1+=1; t_no2=0; t_no3=0 + title_no="#{t_no1}" + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(title_no) + if dob.ln==no1 + dob.name="#{title_no}" if not dob.name + dob.tags=set_tags(dob.tags,title_no) + tag=dob.obj. + gsub(/(Article|Clause|Section|Chapter)\s+/, + "\\1_#{title_no}"). + downcase + tag=heading_tag_clean(tag) + dob.tags=set_tags(dob.tags,tag) + dob.obj=(dob.obj =~/(Article|Clause|Section)\s+/) \ + ? (dob.obj.gsub(/(Article|Clause|Section)\s+/,"\\1 #{title_no} ")) + : (dob.obj.gsub(/^/,"#{title_no}. ")) #fix stop later + end + if dob.ln !=no1 \ + and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review + dob.name ="#{title_no}" if not dob.name + dob.tags=set_tags(dob.tags,title_no) + dob.obj=dob.obj.gsub(/^/,"#{title_no}. ") + end + @md.seg_names << title_no + end + if dob.ln!=no1 \ + and dob.name!~/^[a-z_\.]+$/ \ + and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on + dob.tags=set_tags(dob.tags,title_no) + dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ") + end + end + if dob.ln==no1 #watch because here you change dob.name + dob.tags=set_tags(dob.tags,"h#{title_no}") + end + if dob.ln==no2 #watch because here you change dob.name + t_no2+=1; t_no3=0 + title_no="#{t_no1}.#{t_no2}" + dob.tags=set_tags(dob.tags,"h#{title_no}") + dob=number_sub_heading(dob,no2,title_no) + end + if dob.ln==no3 #watch because here you change dob.name + t_no3+=1 + title_no="#{t_no1}.#{t_no2}.#{t_no3}" + dob.tags=set_tags(dob.tags,"h#{title_no}") + dob=number_sub_heading(dob,no3,title_no) + end + elsif dob.ln.to_s =~/^[0-6]/ \ + and dob.name =~ /^[\w-]+-/ # endnotes, watch2005# endnotes, watch2005 + dob.tags=set_tags(dob.tags,dob.name) + dob.name.gsub(/^([a-z_\.]+)-$/,'\1') + end + elsif dob.is ==:heading \ + and dob.autonum_ \ + and @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 + #here lies a bug, as is nil when run from -Dv --update, FIX + if (dob.name.nil? or dob.name.empty?) \ + and dob.ln.to_s =~/^[0-9]/ \ + and dob.obj =~ /^([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d + dob.name=$1 + dob.tags=set_tags(dob.tags,dob.name) + end + if @md.toc_lev_limit + end + elsif defined? dob.name \ + and dob.name + dob.tags=set_tags(dob.tags,dob.name) + end + dob.tags=dob.tags.uniq if defined? dob.tags + dob + end.flatten + end + def ocn(data) #and auto segment numbering increment + @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data,@fnx,@process).ocn + @tuned_file + end + def xml(data) + @tuned_file=SiSU_AO_DocumentStructureExtract::XML.new(@md,data).dom + @tuned_file + end + def minor_numbering(data) #and auto segment numbering increment + number_small,letter_small=0,0 + letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) + @tuned_file=data.each.map do |dob| + if dob.of ==:heading \ + || dob.of ==:heading_insert \ + || dob.of ==:para \ + || dob.of ==:block + if dob.is ==:heading \ + and dob.ln.to_s=~/^[0-9]/ #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) + number_small,letter_small=0,0 + elsif dob.is ==:para + if dob.obj =~/^#[ 1]/ \ + and dob.obj !~/^#\s+(?:~#)?$/ + letter_small=0 + number_small=0 if dob.obj =~ /^#1/ + number_small+=1 + dob.obj=dob.obj.gsub(/^#[ 1]/,"#{number_small}. ") + end + if dob.obj =~/^_# / + dob.obj=dob.obj.gsub(/^_# /,"#{letter[letter_small]}. ") + dob.indent='1' + letter_small+=1 + end + end + end + dob + end.flatten + end + def leading_zeros_fixed_width_number(possible_seg_name) + if possible_seg_name.to_s =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/ + possible_seg_name=possible_seg_name.to_s. + gsub(/\.$/,'') + nl=possible_seg_name.to_s.length + zero='0' + zeros_fixed_width=number_of_segments?.to_s.length + zero_width=(zeros_fixed_width - nl) + zero_width == 0 \ + ? possible_seg_name.to_s + : zero*zero_width + + possible_seg_name.to_s + end + end + def auto_numbering_exceptions(chosen_seg_names_,md,dob) + number_make=case dob.lv.to_i + when 1 + @num_exc={ + t1: @num_exc[:t1] += 1, + t2: 0, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + when 2 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2] += 1, + t3: 0, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + when 3 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3] += 1, + t4: 0 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + when 4 + @num_exc[:t4] += 1 + @num_exc={ + t1: @num_exc[:t1], + t2: @num_exc[:t2], + t3: @num_exc[:t3], + t4: @num_exc[:t4] += 1 + } + Mx[:segname_prefix_auto_num_other] + '_' \ + + @num_exc[:t1].to_s + '_' \ + + @num_exc[:t2].to_s + '_' \ + + @num_exc[:t3].to_s + '_' \ + + @num_exc[:t4].to_s + end + end + def check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,type,md,dob) + begin + chosen_seg_names_ << chosen_seg_name + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + if chosen_seg_names_.compact.uniq.length \ + == chosen_seg_names_.compact.length + #check that all auto given seg names are unique + chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) + chosen_seg_name + else + SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). + mark( + "duplicated auto segment name: #{type} #{chosen_seg_name}\n" \ + + "#{chosen_seg_names_}\n" \ + + " manually name level 1 segments '1~given_name'\n" \ + + 'filename: ' + md.fns + "\n" \ + + 'heading text: "' + dob.obj + '"' + "\n" \ + + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' + ) + chosen_seg_name=auto_numbering_exceptions(chosen_seg_names_,md,dob) + check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,:exception,md,dob) + end + rescue + end + end + def auto_seg_name(possible_seg_name,heading_num_is,dob,type) + prefix=case type + when :auto then Mx[:segname_prefix_auto_num_provide] + when :extract then Mx[:segname_prefix_auto_num_extract] + else '_'*dob.lv.to_i #should not occur + end + if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/ + possible_seg_name=possible_seg_name. + gsub(/\.$/,'') + end + @chosen_seg_name= + if dob.lv=='4' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){3}/m + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + elsif dob.lv=='3' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){2}/m + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + elsif dob.lv=='2' \ + and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){1}/m + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + elsif dob.lv=='1' \ + and possible_seg_name.to_s =~/^[0-9]+[:,-]?$/m + if possible_seg_name.to_i <= heading_num_is.to_i + prefix + leading_zeros_fixed_width_number(possible_seg_name) + else + possible_seg_name=possible_seg_name.to_s. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + prefix + possible_seg_name + end + else + @chosen_seg_name=auto_numbering_exceptions(@chosen_seg_names,md,dob) + end + check_that_seg_names_are_unique(@chosen_seg_names,@chosen_seg_name,type,@md,dob) + end + def set_name_and_tags(dob,possible_seg_name) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + elsif (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts 'warn, there may be a conflicting numbering scheme' + end + end + def name_para_seg_filename(data) #segment naming, remaining + # paragraph name/numbering rules + # manual naming overrides, manual naming may be + # alpha-numeric characters mixed, + # numeric only (a number), if + # all segments have been named, + # the numbers used are over 1000 or + # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) + # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] + # auto-naming takes the form of giving numbers to segments + # the rules for which are as follows + # if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) + # otherwise the level 4 segment number from the embedded document structure info is used + # if there is none a sequential number is designated, preceded by an underscore + @tuned_file,@unique_auto_name=[],[] + tags={} + @art_filename_auto=0 + @counter=1 + if not @md.seg_autoname_safe \ + and (@md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on) + puts 'manual segment names, numbers used as names, risk warning (segmented html)' + end + ocn_html_seg=[] + @num_exc={ t1: 0, t2: 0, t3: 0, t4: 0 } + data.each do |dob| + if dob.is==:heading \ + && dob.ln \ + and dob.ln.to_s =~/^[4-7]/ + heading_num_is=/^\d+:(\d+);\d/m.match(dob.node)[1] + if dob.ln==4 \ + and not dob.name \ + and not @md.set_heading_seg + @md.set_heading_seg=true + end + if dob.name !~/^\S+/ \ + and dob.ln.to_s =~/^[5-7]/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9])+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + if dob.ln==7 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){3})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==6 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){2})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + elsif dob.ln==5 \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){1})/m + possible_seg_name=$1. + gsub(/(?:[:,-]|\W)/,'.'). + gsub(/\.$/,'') + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + end + end + if dob.ln==4 + if dob.name !~/^\S+/ \ + and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+)/m + #heading starts with a recognised numeric + #or word followed by a recognised numeric construct, + #use that as name + possible_seg_name=$1 + possible_seg_name= + auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) + set_name_and_tags(dob,possible_seg_name) + end + if dob.name + #extract segment name from embedded document structure info + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(dob.name) + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << dob.name + end + else + #if no segment name, + #provide a numerical one + @art_filename_auto+=1 + possible_seg_name= + auto_seg_name(@art_filename_auto,heading_num_is,dob,:auto) + if @md.seg_names.is_a?(Array) \ + and not @md.seg_names.include?(possible_seg_name) + dob.name=possible_seg_name + dob.tags=set_tags(dob.tags,dob.name) + @md.seg_names << possible_seg_name + else puts 'segment name (numbering) error' + end + end + if not dob.name #should not occur + puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" + end + end + end + if (dob.is ==:heading \ + || dob.is ==:heading_insert) \ + && dob.ln==4 + @seg=dob.name + end + @tuned_file << if dob.is==:heading \ + && (@md.pagenew || @md.pagebreak || @md.pageline) + m=dob.ln.to_s + dob_tmp=[] + if @md.pagenew.inspect =~/#{m}/ + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << + dob + elsif @md.pagebreak.inspect =~/#{m}/ + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << + dob + elsif @md.pageline.inspect =~/#{m}/ + dob_tmp << + SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << + dob + end + unless dob_tmp.length > 0; dob + else dob_tmp + end + else dob + end + if defined? dob.ocn \ + and dob.ocn + @segname=((dob.is==:heading || dob.is==:heading_insert) && dob.ln==4 && (defined? dob.name)) \ + ? (dob.name) + : @segname + tags["#{dob.ocn}"]={ segname: @segname } + ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) + if dob.ln =~/[0-3]/ + { + seg: nil, + level: dob.ln, + } + #elsif dob.ln =~/[4-6]/ + else + { + seg: @seg, + level: dob.ln, + } + end + else + { + seg: @seg, + level: nil, + } + end + end + dob.tags=dob.tags.uniq if defined? dob.tags + if defined? dob.tags \ + and dob.tags.length > 0 + #@segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ + #? (dob.name) \ + #: @segname + dob.tags.each do |y| + tags[y]={ ocn: dob.ocn.to_s, segname: @segname } + end + end + dob + end + ocn_html_seg.each_with_index do |ocn,i| + if ocn \ + and ocn[:level].to_s=~/[1-3]/ + (1..4).each do |x| + if ocn_html_seg[i+x] \ + and ocn_html_seg[i+x][:level]==4 + ocn[:seg]=ocn_html_seg[i+x][:seg] + end + end + end + end + if @md.seg_names.length > 0 + @md.set_heading_seg=true + end + tuned_file=@tuned_file.flatten + [tuned_file,tags,ocn_html_seg] + end + def set_heading_top(data) #% make sure no false positives + unless @md.set_heading_top + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no top level heading, (will have to manufacture one)" + end + @tuned_file=[] + data.each do |t_o| + unless @md.set_heading_top + if t_o !~/^(?:#{Rx[:meta]}|@\S+:)\s/m \ + and t_o !~/\A\s*\Z/m + @md.set_heading_top=true + if defined? @md.title \ + and @md.title \ + and defined? @md.title.full \ + and defined? @md.creator \ + and @md.creator + head=@md.title.main \ + ? ([@lv='1',@obj=@md.title.main]) + : ([@lv='1',@obj='[no title provided]']) + @tuned_file << head + end + end + end + @tuned_file << t_o + end + @tuned_file=@tuned_file.flatten + end + end + def set_heading_seg(data) #% make sure no false positives + unless @md.set_heading_seg + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\tdocument contains no segment level, (will have to manufacture one)" + end + @tuned_file=[] + data.each do |dob| + unless @md.set_heading_seg + if defined? dob.ln and dob.ln.to_s !~/^[0-3]/m \ + and dob.obj !~/\A\s*\Z/m \ + and dob.is !=:layout + @md.set_heading_seg=true + head=@md.title.main \ + ? (dob.ln,dob.name,dob.obj=4,'seg',@md.title.main) + : (dob.ln,dob.name,dob.obj=4,'seg','[segment]') + @tuned_file << head + end + end + @tuned_file << dob + end + @tuned_file=@tuned_file.flatten + end + end + def set_header_title(data) #% make sure no false positives + unless @md.set_header_title + if (@md.opt.act[:verbose_plus][:set]==:on \ + or @md.opt.act[:maintenance][:set]==:on) + puts "\t no document title provided, (will have to manufacture one)" + end + @tuned_file=[] + data.each do |t_o| + unless @md.set_header_title + if t_o !~/^%{1,2}\s/m \ + and t_o !~/\A\s*\Z/m + @tuned_file << + "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" + @md.title.main=@md.heading_seg_first + @md.set_header_title=true + end + end + @tuned_file << t_o + end + @tuned_file=@tuned_file.flatten + end + end + end +end +__END__ diff --git a/lib/sisu/ao_persist.rb b/lib/sisu/ao_persist.rb new file mode 100644 index 00000000..6111cc41 --- /dev/null +++ b/lib/sisu/ao_persist.rb @@ -0,0 +1,194 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** document abstraction + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_Persist + class Persist + @@persistance=nil + attr_accessor :fns, :ao_arr, :idx_arr_sst, :idx_arr_tex, :idx_arr_html, :idx_arr_xhtml, :map_arr_nametags, :map_arr_ocn_htmlseg + def initialize(args=nil) + @@persistance=args=(args ? args : (@@persistance || persist_init_hash_values)) + @fns=args[:fns] + @ao_arr=args[:ao_arr] + @idx_arr_sst=args[:idx_arr_sst] + @idx_arr_tex=args[:idx_arr_tex] + @idx_arr_html=args[:idx_arr_html] + @idx_arr_xhtml=args[:idx_arr_xhtml] + @map_arr_nametags=args[:map_arr_nametags] + @map_arr_ocn_htmlseg=args[:map_arr_ocn_htmlseg] + end + def fns + @fns + end + def ao_arr + @ao_arr + end + def idx_arr_sst + @idx_arr_sst + end + def idx_arr_tex + @idx_arr_tex + end + def idx_arr_html + @idx_arr_html + end + def idx_arr_xhtml + @idx_arr_xhtml + end + def map_arr_nametags + @map_arr_nametags + end + def map_arr_ocn_htmlseg + @map_arr_ocn_htmlseg + end + def persist_init_hash_values + { + fns: nil, + ao_arr: [], + idx_arr_sst: [], + idx_arr_tex: [], + idx_arr_html: [], + idx_arr_xhtml: [], + map_arr_nametags: [], + map_arr_ocn_htmlseg: [], + } + end + def persist_init + @@persistance=nil + Persist.new(persist_init_hash_values) + end + end + class PersistDocStructExt + @@persist=nil + attr_accessor :ocn, :lng, :lng_is, :code, :lngsyn, :poem, :block, :box, :group, :alt, :quote, :table, :table_to + def initialize(args=nil) + @@persist=args=(args ? args : (@@persist || persist_init_hash_values)) + @ocn=args[:ocn] + @lng=args[:lng] + @lng_is=args[:lng_is] + @code=args[:code] + @lngsyn=args[:lngsyn] + @poem=args[:poem] + @block=args[:block] + @box=args[:box] + @group=args[:group] + @alt=args[:alt] + @quote=args[:quote] + @table=args[:table] + @table_to=args[:table_to] + end + def ocn + @ocn + end + def lng + @lng + end + def lng_is + @lng_is + end + def code + @code + end + def lngsyn + @lngsyn + end + def poem + @poem + end + def block + @block + end + def box + @box + end + def group + @group + end + def alt + @alt + end + def quote + @quote + end + def table + @table + end + def table_to + @table_to + end + def persist_init_hash_values + { + ocn: :on, + lng: :off, + lng_is: :doc_default, + code: :off, + lngsyn: :txt, + poem: :off, + block: :off, + box: :off, + group: :off, + alt: :off, + quote: :off, + table: :off, + table_to: :off, + } + end + def persist_init + @@persist=nil + PersistDocStructExt.new(persist_init_hash_values) + end + end +end +__END__ diff --git a/lib/sisu/ao_references.rb b/lib/sisu/ao_references.rb new file mode 100644 index 00000000..cd410f77 --- /dev/null +++ b/lib/sisu/ao_references.rb @@ -0,0 +1,502 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_AO_References + class Bibliography + def initialize(md,data) + @md,@data=md,data + end + def sort_bibliography_array_by_author_year_title(bib) + if bib + bib.compact.sort_by do |c| + [c[:author_arr][0],c[:year],c[:title]] + end + end + end + def citation_in_prepared_bibliography(cite) + @cite=cite + def article + { + is: :article, + author_raw: nil, + author: nil, + author_arr: nil, + title: nil, + language: nil, + journal: nil, + volume: nil, + editor: nil, + year: nil, + where: nil, + url: nil, + note: nil, + short_name: nil, + id: nil, + } + end + def book + { + is: :book, + author_raw: nil, + author: nil, + author_arr: nil, + #editor: nil, + title: nil, + subtitle: nil, + fulltitle: nil, + language: nil, + publisher: nil, + edition: nil, + year: nil, + where: nil, + url: nil, + note: nil, + short_name: nil, + id: nil, + } + end + def citation_metadata + type=if @cite =~/^jo: \S+/m + :article + elsif @cite =~/^au: \S+/m + :book + end + if type + citeblock=@cite.split("\n") + if type == :article + citation=article + citeblock.select do |meta| + case meta + when /^((?:au|author):\s+)\S+/ #req + citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:ti|title):\s+)\S+/ #req + citation[:title]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:lng|language):\s+)\S+/ + citation[:language]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:jo|journal):\s+)\S+/ #req? + citation[:journal]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:vo|volume):\s+)\S+/ + citation[:volume]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:edr|editor):\s+)\S+/ + citation[:editor]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:yr|year):\s+)\S+/ #req? + citation[:year]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:pst|publisher_state):\s+)\S+/ + citation[:where]=/^#{$1}(.+)/.match(meta)[1] + when /^(url:\s+)\S+/ + citation[:url]=/^#{$1}(.+)/.match(meta)[1] + when /^(note:\s+)\S+/ + citation[:note]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:sn|shortname):\s+)\S+/ + citation[:short_name]=/^#{$1}(.+)/.match(meta)[1] + when /^(id:\s+)\S+/ + citation[:id]=/^#{$1}(.+)/.match(meta)[1] + end + end + end + if type == :book + citation=book + citeblock.select do |meta| + case meta + when /^((?:au|author):\s+)\S+/ #req + citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:ti|title):\s+)\S+/ #req + citation[:title]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:st|subtitle):\s+)\S+/ + citation[:subtitle]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:lng|language):\s+)\S+/ + citation[:language]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:pb|publisher):\s+)\S+/ + citation[:publisher]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:edn|edition):\s+)\S+/ + citation[:edition]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:yr|year):\s+)\S+/ #req? + citation[:year]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:pst|publisher_state):\s+)\S+/ + citation[:where]=/^#{$1}(.+)/.match(meta)[1] + when /^(url:\s+)\S+/ + citation[:url]=/^#{$1}(.+)/.match(meta)[1] + when /^(note:\s+)\S+/ + citation[:note]=/^#{$1}(.+)/.match(meta)[1] + when /^((?:sn|shortname):\s+)\S+/ + citation[:short_name]=/^#{$1}(.+)/.match(meta)[1] + when /^(id:\s+)\S+/ + citation[:id]=/^#{$1}(.+)/.match(meta)[1] + end + end + end + if citation[:is]==:book + if citation[:subtitle] + citation[:fulltitle] = citation[:title] \ + + ' - ' \ + + citation[:subtitle] + else + citation[:fulltitle] = citation[:title] + end + end + citation[:author_arr]=citation[:author_raw].split(/;\s*/) + citation[:author]=citation[:author_arr].map do |author| + author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip + end.join(', ').strip + unless citation[:short_name] + citation[:short_name]=%{#{c[:author]}, "#{c[:short_name]}" (#{c[:date]})} + end + end + citation + end + self + end + def biblio_extraction + bibliography=[] + biblioflag=false + code_flag=false + flag_code_curly=:not_code_curly + flag_code_tics=:not_code_tics + @data=@data.select do |t_o| + if t_o =~/^code\{/ + flag_code_curly=:code_curly + elsif t_o =~/^\}code/ + flag_code_curly=:not_code_curly + elsif t_o =~/^``` code/ + flag_code_tics=:code_tics + elsif flag_code_tics ==:code_tics \ + and t_o =~/^```/ + flag_code_tics=:not_code_tics + end + code_flag=if flag_code_curly==:code_curly \ + or flag_code_tics==:code_tics + true + else false + end + unless code_flag + if @md.flag_auto_biblio + if t_o =~/^1~biblio(?:graphy)?/ + biblioflag = true + t_o + elsif t_o =~/^:?[B-D1]~/ + biblioflag = false + t_o + elsif biblioflag + if t_o !~/\A%+ / + bibliography << citation_in_prepared_bibliography(t_o).citation_metadata + next + else + t_o + end + else t_o + end + elsif @md.flag_biblio + if t_o =~/^1~biblio(?:graphy)?/ + biblioflag = true + next + elsif t_o =~/^:?[B-D]~/ + next + elsif t_o =~/^:?[B-D1]~/ + biblioflag = false + t_o + elsif biblioflag + if t_o !~/\A%+ / + bibliography << t_o + next + else + t_o + end + else t_o + end + else t_o + end + else t_o + end + end.compact + if @md.flag_auto_biblio \ + and bibliography.length > 0 + data_new=[] + bibliography=sort_bibliography_array_by_author_year_title(bibliography) + @data.select do |t_o| + if t_o =~/^1~biblio(?:graphy)?/ + bibliography.each do |c| + if c[:is]==:book + <<-WOK + +!_ #{c[:author]} +/{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]}) + WOK + elsif c[:is]==:article + <<-WOK + +!_ #{c[:author]} +/{"#{c[:title]}"}/ #{c[:journal]} (#{c[:year]}) + WOK + end + end + else data_new << t_o + end + end + @data=data_new + end + [@data,bibliography] + end + end + class Citations + def initialize(md='',data='') + @md,@data=md,data + #@biblio=[] + end + def songsheet + tuned_file,citations=citations_scan(@data) + [tuned_file,citations] + end + def sort_bibliography_array_by_author_year(bib) + bib.sort_by do |c| + [c[:author_raw],c[:year]] + #[c[:author_arr][0],c[:year],c[:title]] + end + end + def citations_regex + def pages_pattern + %r{(?:[,.:]?\s+(?:p{1,2}\.?\s+)?(?:\d+--?\d+)[,.]?\s+)?} + end + def editor_pattern + %r{(?(?:editor|edited by)\s+.+?)} + end + def year_pattern + %r{[(\[]?(?\d{4})[\])]?[.,]?} + end + def authors_year_title_publication_editor_pages + /(?.+?)\s+#{year_pattern}\s+"(?.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor + end + def authors_title_publication_year_editor_pages + /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor + end + def authors_title_publication_editor_year_pages ### + /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+ed.\s+#{editor_pattern}#{year_pattern}#{pages_pattern}/m + # note ed. is usually edition rather than editor + end + def authors_title_publication_editor_pages_year ### + /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}#{year_pattern}/m # note ed. is usually edition rather than editor + end + def authors_year_title_publication_pages + /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?#{pages_pattern}/m + end + def authors_title_publication_year_pages + /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{pages_pattern}/m + end + def authors_title_publication_pages_year ### + /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}#{year_pattern}/m + end + def authors_year_publication_pages + /(?<authors>.+?)\s+#{year_pattern}\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}/m + end + def authors_publication_year_pages + /(?<authors>.+?)\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?\s+(?<publisher>.+?)?#{year_pattern}#{pages_pattern}[.;]?/m + end + self + end + def authors?(citations) + citations.each.map do |b| + if b =~ /^.+\s+::.+?:$/ + c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b) + { + citation: c[:citation], + shortref: c[:shortref], + c[:shortref].to_s => c[:citation] + } + else { citation: b } + end + end + end + def long_and_short_ref?(citations) #could be useful, keep ... ectract shortref + citations.each.map do |b| + if b =~ /^.+\s+::.+?:$/ + c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b) + { + citation: c[:citation], + shortref: c[:shortref], + c[:shortref].to_s => c[:citation] + } + else { citation: b } + end + end + end + def citation_detail(citations) #could be useful, keep ... extract shortref + bibahash=[] + number=0 + missed=0 + citations.select do |b| + z=if b =~citations_regex.authors_year_title_publication_editor_pages + c=citations_regex.authors_year_title_publication_editor_pages.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + editor: c[:editor], + } + elsif b =~citations_regex.authors_title_publication_year_editor_pages + c=citations_regex.authors_title_publication_year_editor_pages.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + editor: c[:editor], + } + elsif b =~citations_regex.authors_title_publication_editor_year_pages + c=citations_regex.authors_title_publication_editor_year_pages.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + editor: c[:editor], + } + elsif b =~citations_regex.authors_title_publication_editor_pages_year + c=citations_regex.authors_title_publication_editor_pages_year.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + editor: c[:editor], + } + elsif b =~citations_regex.authors_year_title_publication_pages + c=citations_regex.authors_year_title_publication_pages.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + } + elsif b =~citations_regex.authors_title_publication_year_pages + c=citations_regex.authors_title_publication_year_pages.match(b) + { + is: :article, + author_raw: c[:authors], + year: c[:year], + title: c[:title], + publication: c[:publication], + } + elsif b =~citations_regex.authors_year_publication_pages + c=citations_regex.authors_year_publication_pages.match(b) + { + is: :book, + author_raw: c[:authors], + year: c[:year], + publication: c[:publication], + } + elsif b =~citations_regex.authors_publication_year_pages + c=citations_regex.authors_publication_year_pages.match(b) + { + is: :book, + author_raw: c[:authors], + year: c[:year], + publication: c[:publication], + } + else b + end + if not z.is_a?(NilClass) \ + and z.is_a?(Hash) \ + and z[:author_raw].length > 0 + z[:author_arr]=z[:author_raw].split(/;\s*/) + z[:author]=z[:author_arr].map do |author| + author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip + end.join(', ').strip + if @md.opt.act[:verbose_plus][:set]==:on \ + || @md.opt.act[:maintenance][:set]==:on + number +=1 if z.is_a?(Hash) + missed +=1 if z.is_a?(String) + (z.is_a?(Hash)) \ + ? (p '[' + number.to_s + '] ' + z.to_s) + : (p '<' + missed.to_s + '> ' + z.to_s) + end + end + bibahash << z if z.is_a?(Hash) + end + bibahash=sort_bibliography_array_by_author_year(bibahash.compact) + bibahash + end + def citations_scan(data) + citations=[] + #short_ref=[] + tuned_file = data.compact.select do |dob| + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table + if dob.obj =~/\.:.+?:\./ + citations << dob.obj.scan(/\.:\s*(.+?)\s*:\./m) + #short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::([^:]+)::\./m) #look at later + ##short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::(.+?)::\./m) #look at later + #short_ref << dob.obj.scan(/\.:\s*(.+?)\s*(::(.+?):)?:\./m) #look at later + citations=citations.flatten.compact + dob.obj=dob.obj. #remove citations delimiter & helpers from text + gsub(/\.:|:\./,'') + end + end + dob if dob.is_a?(Object) + end + #bib=long_and_short_ref?(citations) #could be useful, keep ... extract shortref + citations=citation_detail(citations) + [tuned_file,citations] + end + end +end +__END__ diff --git a/lib/sisu/ao_syntax.rb b/lib/sisu/ao_syntax.rb new file mode 100644 index 00000000..010e9285 --- /dev/null +++ b/lib/sisu/ao_syntax.rb @@ -0,0 +1,640 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** Syntax for markup, input markup syntaxes, determined here + +** Author: Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + +** Git + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/ao_syntax.rb;hb=HEAD> + +=end +module SiSU_AO_Syntax + class Words + def initialize(line,md,mkp) + @line,@md,@mkp=line,md,mkp + end + end + class Markup + def initialize(md='',data='',biblio=[]) + @md,@data,@bibliography=md,data,biblio + @data_new=[] + url_and_stub=SiSU_Env::InfoEnv.new.url + @output_url="#{url_and_stub.remote}" + @env=SiSU_Env::InfoEnv.new + emph_set=if defined? @md.emphasis_set_to \ + and not @md.emphasis_set_to.nil? + @md.emphasis_set_to + else @env.markup_emphasis + end + @emph=case emph_set + when /bold/ + emph_italics=false + { o: Mx[:fa_bold_o], c: Mx[:fa_bold_c] } + when /italics/ + emph_italics=true + { o: Mx[:fa_italics_o], c: Mx[:fa_italics_c] } + when /underscore/ + emph_italics=false + { o: Mx[:fa_underscore_o], c: Mx[:fa_underscore_c] } + else p __LINE__.to_s + '::' + __FILE__ + end + @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} + @manmkp_ital=emph_italics \ + ? '[i/*]\\{.+?\\}[i/*]' + : '[i/]\\{.+?\\}[i/]' + tail_m_ital=%q{(?:\s|'s\b|[.,;:?!'")]|~\^|~\\\{\s|$)} + tail_m_bold=%{(?:(?:#{Mx[:fa_italics_c]})?(?:\s|'s\b|[.,;:?!'")]|~\^|~\\\{\s|$))?} + bold_line=%{^!_\s.+?(?:#{Mx[:br_line]}|\n|$)} + #ital_line=%{^/_\s.+?(?:#{Mx[:br_line]}|\n|$)} #not implemented + @line_scan_ital=if defined? @md.italics_match_list[:str] + /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|#{@md.italics_match_list[:str]}#{tail_m_ital}|\S+|\n/i + end + @manmkp_bold=emph_italics \ + ? '^!_\s.+?(?:\n|$)|[!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[!]' + : '^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]' + @line_scan_bold=if defined? @md.bold_match_list[:str] \ + and @md.bold_match_list[:str] + /#{@http_m}|#{bold_line}|(?:#{@manmkp_bold}|#{@md.bold_match_list[:str]})#{tail_m_bold}|\S+|\n/i + end + end + def songsheet + @data=@data.compact + @data.each do |dob| + dob=breaks(dob) + dob=if @md.sem_tag then sem(dob) else dob end #revisit + dob=line_actions(dob) + dob=paragraph_set(dob) + dob=substitutions(dob) + dob=wordlist_italics(dob) + dob=wordlist_bold(dob) + dob=bodymarkup(dob) + @data_new << dob unless dob.nil? + end + @data_new + end + def sem(dob) #revisit + dob=SiSU_Sem::Tags.new(dob,@md).rm.all + end + def breaks(dob) + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table + dob.obj=dob.obj. + gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). + gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}"). + gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). + gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated + gsub(/(?:<:?pn>)/,"#{Mx[:br_page_new]}"). # depreciated + gsub(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}"). # depreciated + gsub(/(?:^-\.\.-\s*$)/,"#{Mx[:br_page_line]}") + end + dob + end + def wordlist_italics(dob) + dob=dob.dup + if (defined? @md.italics_match_list[:str] \ + and @md.italics_match_list[:str]) + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:layout \ + && dob.is !=:comment + word=dob.obj.scan(@line_scan_ital) + word=word.flatten.compact + line_array=[] + word.each do |w| + unless /#{@manmkp_ital}|#{@http_m}/.match(w) + if defined? @md.italics_match_list[:regx] \ + and @md.italics_match_list[:regx] + w=w.gsub(@md.italics_match_list[:regx], + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") + else w + end + end + line_array << w + end + line_array.join(' ') + else dob.obj + end + end + dob + end + def embolden(given) + given=given. + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). + gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, + "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). + gsub(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + end + def italicise(given) + given=given. + gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s*(.+?)\s*([~-]#)$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). + gsub(/^\/_\s+(.*)?\s*$/, + "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") + end + def line_actions(dob) + dob.obj=if (dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:comment \ + && dob.is !=:meta) \ + and dob.obj =~ /^!_\s+/ + embolden(dob.obj) + elsif dob.obj =~ /^\/_\s+/ + italicise(dob.obj) + else dob.obj + end + dob + end + def paragraph_set(dob) + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table + dob.obj.gsub(/\n/m,' '). + gsub(/ \s+/m,' ') + else dob.obj + end + dob + end + def substitutions(dob) + dob=dob.dup + dob=if @md.flag_auto_biblio \ + and @bibliography.length > 0 + dob=if dob.is !=:meta \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table + @bibliography.each do |c| + if c[:id] and not c[:id].nil? and not c[:id].empty? + dob.obj=dob.obj.gsub(/#{c[:id]}/mi,c[:short_name]) + end + end + dob + else dob + end + dob + else dob + end + dob=if defined? @md.substitution_match_list[:match_and_replace] \ + and @md.substitution_match_list[:match_and_replace].is_a?(Array) + dob=if dob.is !=:meta \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table + if dob.obj =~/#{@md.substitution_match_list[:matches]}/ + @md.substitution_match_list[:match_and_replace].each do |x| + dob.obj=if x[:case_s]==:i + dob.obj.gsub(/#{x[:match]}/mi,x[:replace]) + else + dob.obj.gsub(/#{x[:match]}/m,x[:replace]) + end + end + end + dob + else dob + end + dob + else dob + end + end + def wordlist_bold(dob) + dob=dob.dup + if (defined? @md.bold_match_list[:str] \ + and @md.bold_match_list[:str]) + dob.obj=if dob.is !=:meta \ + && dob.is !=:heading \ + && dob.is !=:heading_insert \ + && dob.is !=:code \ + && dob.is !=:comment \ + && dob.is !=:table + line_array=[] + word=dob.obj.scan(@line_scan_bold) + word=word.flatten.compact + word.each do |w| + unless /#{@manmkp_bold}|#{@http_m}/.match(w) + if defined? @md.bold_match_list[:regx] \ + and @md.bold_match_list[:regx] #document header: @bold: [bold word list] + w=w.gsub(@md.bold_match_list[:regx], + "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") + end + else + w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ + embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! + elsif w =~/^\/_\s+/ + italicise(w) + else w + end + end + line_array << w + end + line_array.join(' ') + else dob.obj + end + else + dob.obj=if dob.is==:heading \ + and dob.ln.to_s =~/[7-9]/ + embolden(dob.obj) + else dob.obj + end + end + dob + end + def fontface_lines(dob,leader) + while (dob.obj =~/#{Mx[:br_nl]}/ \ + and dob.obj =~/(?:#{leader})([*!\/_#])\{(.+?)\}\1/m) \ + and $2 =~/#{Mx[:br_nl]}/ + dob=if dob.obj =~/#{Mx[:br_nl]}/ \ + and dob.obj =~/(#{leader})([*!\/_#])\{(.+?)\}\2/m + lead,fce,txt=$1,$2,$3 + dob=if txt =~/#{Mx[:br_nl]}/ + lead_break=if dob.obj =~/^#{Mx[:br_nl]}/ + dob.obj=dob.obj.sub(/^#{Mx[:br_nl]}/,'') + Mx[:br_nl] + else '' + end + txt="#{lead_break}#{fce}\{" + txt.split(Mx[:br_nl]).join("\}#{fce}#{Mx[:br_nl]}#{fce}\{") + "\}#{fce}" + dob.obj=dob.obj. + sub(/(?:^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m, + "#{lead}#{txt}") + dob + else dob + end + end + dob + end + dob + end + def fontface(dob) + leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。「‹«¿¡]|\>/ + dob=fontface_lines(dob,leader) + dob.obj=dob.obj. + gsub(/(#{leader})\*\{(.+?)\}\*/m, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(#{leader})!\{(.+?)\}!/m, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(#{leader})\/\{(.+?)\}\//m, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(#{leader})_\{(.+?)\}_/m, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(#{leader})#\{(.+?)\}#/m, + "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}"). #monospace + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}]|\(|\>)\"\{(.+?)\}\"/m, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite /blockquote? + gsub(/(^|[^\\])\^\{(.+?)\}\^/m, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #superscript + gsub(/(^|[^\\]),\{(.+?)\},/m, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). #subscript + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). #inserted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). #strikethrough - deleted text + gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added + dob + end + def bodymarkup(dob) + # << http://www.jus.uio.no/sisu/sisu_markup_table/markup >> + # See: data/sisu/sample/document_samples_sisu_markup/ + ## fontface + # *{emphasis}* e{emphasis}e <strong>emphasis</strong> + # !{bold text}! b{bold}b <b>bold text</b> + # _{underline}_ u{underline}u <u>underline</u> + # /{italics}/ i{italics}i <i>italics</i> + # "{citation}" c{citation}c <cite>citation</cite> #blockquote? + # ^{superscript}^ <sup>superscript</sup> + # ,{subscript}, <sub>subscript</sub> + # +{inserted text}+ <ins>inserted text</ins> + # -{deleted text}- <del>deleted text</del> + # #{monospace text}# + # + # {url address}:url + # {image.png}imageurl + # {image.png}png + # ~{endnote}~ + # !_ #bold/emphasise paragraph + # _" #blockquote paragraph + # _1 <:i1> #indent paragraph 1 step + # _2 <:i2> #indent paragraph 2 steps + # _3 <:i3> #indent paragraph 3 steps + # _4 <:i4> #indent paragraph 4 steps + # _* #bullet (list) ● + # _1* #bullet (list) indented + # _1* #bullet (list) indented + # # #numbered (list) level 1 + # _# #numbered (list) level 2 + dob=dob.dup + if dob.is !=:meta \ + && dob.is !=:comment \ + && dob.is !=:code \ + && dob.is !=:table + line_array=[] + word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit + if word + word.each do |w| # _ - / # | : ! ^ ~ + unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! + w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character + end + w=w.gsub(/^\<$/, + "#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character + line_array << w + end + dob.obj=line_array.join(' ') + dob.obj=dob.obj.strip + end + dob.obj=dob.obj. + gsub(/^([*#.-]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators + gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). + gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify + gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) + if dob.is ==:heading \ + and dob.ln ==0 + dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") + dob.obj=if defined? @md.creator.author \ + and @md.creator.author + dob.obj.gsub(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") + else dob.obj.gsub(/\s+(?:@creator|@author)/,'') + end + end + if defined? @md.title \ + and @md.title \ + and defined? @md.title.full \ + and defined? @md.creator \ + and @md.creator + if dob.is ==:heading + dob.obj=dob.obj.gsub(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ + dob.obj=if dob.lv =~/[23]/ \ + and defined? @md.creator.author \ + and @md.creator.author + dob.obj. + gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/, + "\\1#{@md.creator.author}") + else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') + end + end + end + dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup + gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). + gsub(/<!(\S+)!>/,'<:\1>'). #escaped special character + gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character + gsub(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\<</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\>>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}"). #& #escaped special character + gsub(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility + gsub(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}"). #escaped special character + gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character + if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m + if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch + end + if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m + dob.obj=dob.obj. + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") + end + dob.obj=dob.obj. + gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) + gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). + gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}). + gsub(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) + end + if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK + dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, + %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) + end + dob=fontface(dob) + dob.obj=dob.obj. + gsub(/<[:e]\s+(.+?)!?>/, + "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested + gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, + "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/=\{(.+?)\}/, + "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). + gsub(/^\s*_([1-9])\*\s*/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut + gsub(/^\s*_([1-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent + gsub(/^\s*_([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold + gsub(/^\s*__([1-9])\s+/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang + gsub(/^\s*__([1-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef + gsub(/^\s*_([0-9])_([0-9])\s+/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang + gsub(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, + "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef + gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #'<span style="background-color: rgb(255,240,196)">'). # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) + gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #'</span>'). + gsub(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n"). + gsub(/[ ]+($)/,'\1'). + gsub(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image + gsub(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}"). + gsub(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image + gsub(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need + gsub(/\{\s*(.+?)\s*\}(image)/, + "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image + elsif dob.is==:table + dob=fontface(dob) + elsif dob.is ==:code + dob.obj=dob.obj. + gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). + gsub(/(^|#{Mx[:gl_c]}|\s)<(?:br(?: \/)?)>([\s,.]|$)/,'\1<br>\2') #convert <br> <br /> back, clumsy + if dob.number_ + codeline=[] + ln=1 + dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}|<br(?: \/)?>|\n/).each_with_index do |cl,i| + unless i == 0 + cl=cl.gsub(Mx[:br_nl],'') + w=3-ln.to_s.length + cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{cl}#{Mx[:br_nl]}" + ln +=1 + end + codeline << cl + end + codeline= codeline.join("") + dob.obj=codeline + else + dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") + end + dob + else # @\S+?: + end + dob + end + def tech #script markup planned to be more strict for technical documents + # *{emphasis}* e{emphasis}e <strong>emphasis</strong> + # !{bold text}! b{bold}b <b>bold text</b> + # _{underline}_ u{underline}u <u>underline</u> + # /{italics}/ i{italics}i <i>italics</i> + # "{citation}" c{citation}c <cite>citation</cite> + # ^{superscript}^ <sup>superscript</sup> + # ,{subscript}, <sub>subscript</sub> + # +{inserted text}+ <ins>inserted text</ins> + # -{deleted text}- <del>deleted text</del> + # #{monospace text}# + # {url address}:url + # {image.png}imageurl + # {image.png}png + # ~{endnote}~ + # +1 <!i1!> + # +2 <!i2!> + puts 'tech' + @data.each do |line| + line=line. + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, + "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, + "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, + "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, + "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, + "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasise single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, + "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, + "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3"). #italics single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, + "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore single word, watch + gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, + "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #check #superscript single word, watch digit added + gsub(/^\s*_\([1-9]\)\(\*\+\)\s*/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}"). #bullets, shortcut + gsub(/^\s*_\([1-9]\)\s+/, + "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}"). #watch + gsub(/^\s*__\([1-9]\)\s+/, + "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}"). #watch + #line.gsub(/^\s*__\([1-9]\)!\s+/, + # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}"). #watch + gsub(/#{Mx[:br_line]}\s*_[12]\s+/, + "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') + end + @data + end + end +end +__END__ diff --git a/lib/sisu/cgi.rb b/lib/sisu/cgi.rb new file mode 100644 index 00000000..6d8d8e04 --- /dev/null +++ b/lib/sisu/cgi.rb @@ -0,0 +1,84 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** generates naive cgi search form for search of sisu database (pgsql sqlite) + +** Author: Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + +** Git + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/cgi.rb;hb=HEAD> + +=end +module SiSU_CGI #% database building documents + require_relative 'se' # se.rb + require_relative 'cgi_pgsql' # cgi_pgsql.rb + require_relative 'cgi_sqlite' # cgi_sqlite.rb + class SearchSQL + def initialize(opt) + @opt=opt + @webserv=@opt.files[0].to_s.strip + end + def read + if @opt.act[:sample_search_form][:db]==:pg # cgi_pgsql.rb + SiSU_CGI_PgSQL::SearchPgSQL.new(@opt,@webserv).pgsql + elsif @opt.act[:sample_search_form][:db]==:sqlite # cgi_sqlite.rb + SiSU_CGI_SQLite::SearchSQLite.new(@opt,@webserv).sqlite + else + puts <<-WOK + please select database type for which sample search form should be built (pgsql or sqlite) + sisu --sample-search-form --db=sqlite + sisu --sample-search-form --db=pg + other options include + --webserv-cgi='[cgi-server-name]' + --webserv-output='[sisu-output-server-with-base-path]' + WOK + end + end + end +end +__END__ diff --git a/lib/sisu/cgi_pgsql.rb b/lib/sisu/cgi_pgsql.rb new file mode 100644 index 00000000..0011d182 --- /dev/null +++ b/lib/sisu/cgi_pgsql.rb @@ -0,0 +1,270 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** generates naive cgi search form for search of sisu database (pgsql) + +** Author: Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + +** Git + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/cgi_pgsql.rb;hb=HEAD> + +=end +module SiSU_CGI_PgSQL #% database building documents + require_relative 'se' # se.rb + require_relative 'cgi_sql_common' # cgi_sql_common.rb + include SiSU_CGI_SQL + class SearchPgSQL < CGI_Common + def initialize(opt,webserv) + @opt,@webserv=opt,webserv + @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX + @env=SiSU_Env::InfoEnv.new('',opt) + @sys=SiSU_Env::SystemCall.new + @db=SiSU_Env::InfoDb.new + get_init=SiSU_Env::GetInit.new + @rc=get_init.sisu_yaml.rc + @name_of={} + @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ + opt.dir_structure_by.to_s + else 'language' + end + @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ + opt.lingual.to_s + else 'multi' + end + @name_of[:db]=if defined? @rc['search'] \ + and defined? @rc['search']['sisu'] \ + and defined? @rc['search']['sisu']['action'] \ + and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \ + and defined? @rc['search']['sisu']['db'] \ + and @rc['search']['sisu']['db'] =~/\S+/ + @rc['search']['sisu']['db'] + else + @env.path.base_markup_dir_stub #'sisu' #breaks if not present + end + @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} + @name_of[:user]=@db.psql.user(opt) + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) + @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) + end + def pgsql + serve=[] + if @sys.psql + available_db_table=`psql --list` # system call requires psql + available_db=available_db_table.scan(/(#{Db[:name_prefix]}\S+)/) if not available_db_table.nil? + if available_db \ + and available_db.is_a?(Array) + available_db.flatten.each do |x| + serve << x.gsub(/#{Db[:name_prefix]}(\S+)/,'\1') + end + else STDERR.puts "WARNING: no postgresql database available, (have you created one?)" + end + serve=serve.sort + f1,f2='','' + serve.each do |x| + f1 << %{ <option value="#{Db[:name_prefix]}#{x}">#{x}</option>\n} unless x =~/apache|sisu\/image/ #check + end + end + f2 << %q{ selected_db=%{<option value="#{@db_name_prefix}#{@stub}">#{@stub}</option>}} + "\n" + if FileTest.writable?('.') + output=File.open(@cgi_file_name,'w') + output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons1_pgsql << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3 + puts <<-WOK + generated sample search form: #{@cX.green}#{@cgi_file_name}#{@cX.off} + default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]}) + db user: #{@cX.green}#{@name_of[:user]}#{@cX.off} + to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off} + + #{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db}) + NOTE it is first necessary to createdb, + use sisu to create the tables & populate the postgresql db + + the database to be used for this directory (#{@db.psql.db}) + will have to be created manually if it does not exist: + using postgresql tools directly (the following may work): + (i) if you are not yet a postgresql user, + #{@cX.brown}sudo su postgres + createuser -d -a #{@env.user} + exit#{@cX.off} + (ii) create the database: + #{@cX.brown}createdb #{@db.psql.db}#{@cX.off} + [for a list of existing databases try 'psql --list']" + + you can use sisu to create the database tables and populate the database with documents + + sisu --pg --dropall # removes existing postgresql db & tables + sisu --pg --createall -v # creates postgresql db & tables + sisu --pg --update -v *.sst *.ssm # populate the db + sisu --sample-search-form --db-pg # creates the postgresql search form + # this should be done after creating the db + # to be searched + sisu --webrick & # starts ruby webrick web server + + # if necessary make the directory '/usr/lib/cgi-bin' + # here we copy the postgresql search form to cgi-bin + # (copy #{@cgi_file_name} to your cgi directory) + # set file permissions to 755 + WOK + a=case @webserv + when /pwd/ then '' + else <<-WOK + + sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ + sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} + WOK + end + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).warn + a=<<-WOK + #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} + WOK + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue + a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']" + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).txt_grey + else puts 'failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?' + end + end + def header0 + <<-WOK_SQL +#!/usr/bin/env ruby +=begin +#{about} + * Description: generates naive cgi search form for search of sisu database (pgsql) +#{gpl} +=end + begin + require 'cgi' + require 'fcgi' + require 'pg' + rescue LoadError + puts 'cgi, fcgi or pg NOT FOUND (LoadError)' + end + @stub_default='#{@name_of[:db]}' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" + @output_dir_structure_by='#{@name_of[:output_dir_structure]}' + @lingual='#{@name_of[:lingual]}' + @port='#{@db.psql.port}' + @db_name_prefix='#{Db[:name_prefix]}' + @user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}' + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" + WOK_SQL + end + def search_statement + <<-'WOK_SQL' + class DBI_SearchString + def initialize(l,t,q,cse=false) + @l,@t,@q,@c=l,t,q,cse + end + def string + search={ search: [], flag: false } + if @t =~/\S+/ or @q =~/\S+/ + if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) + end + search_construct=[] + unescaped_search=if @c + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '"). + gsub(/(.+)/,"#{@l}~\( '\\1' \)") + else + unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '"). + gsub(/(.+)/,"#{@l}~*\( '\\1' \)") + end + search_construct << unescaped_search + search_construct=search_construct.join(' ') + search[:search] << search_construct + search[:flag]=true + search + end + search + end + end + WOK_SQL + end + def search_query1 + <<-'WOK_SQL' + @search_text='' + @search_text=search[:text].flatten.join(' AND ') + @search_text=@search_text.gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') + end + WOK_SQL + end + def search_query2 + <<-'WOK_SQL' + def sql_select_body + limit ||=@@limit + offset ||=@@offset + @sql_statement[:body]=%{SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg, doc_objects.ocn, metadata_and_text.tid FROM doc_objects, metadata_and_text WHERE (#{@search_text}) AND doc_objects.metadata_tid = metadata_and_text.tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, doc_objects.ocn} + @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} + select=@sql_statement[:body] + ' ' + @sql_statement[:range] + select + end + def sql_select_body_format + %{<font color="#666666" size="2">#{sql_select_body}</font>} + end + def contents + @conn.exec(sql_select_body) + end + end + WOK_SQL + end + def buttons1_pgsql + <<-'WOK_SQL' + <input type="checkbox" name="casesense" #{@checked_case}> case sensitive + WOK_SQL + end + def dbi_connect + <<-'WOK_SQL' + @conn=PG::Connection.open(dbname: @db, port: @port, user: @user) + WOK_SQL + end + end +end +__END__ diff --git a/lib/sisu/cgi_sql_common.rb b/lib/sisu/cgi_sql_common.rb new file mode 100644 index 00000000..2d599bf4 --- /dev/null +++ b/lib/sisu/cgi_sql_common.rb @@ -0,0 +1,986 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** generates naive cgi search form for search of sisu database (pgsql sqlite) + +** Author: Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licensing/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + + <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + +** Git + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> + <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/cgi_sql_common.rb;hb=HEAD> + +=end +module SiSU_CGI_SQL + class CGI_Common + def initialize(webserv,opt,image_src,dir) + @webserv,@opt,@image_src,@env=webserv,opt,image_src,dir + end + def about + <<-'WOK_SQL' + * Name: SiSU information Structuring Universe + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download + WOK_SQL + end + def gpl + <<-'WOK_SQL' + * Name: SiSU generated sample cgi search form + + * Description: generated sample cgi search form for SiSU + (SiSU is a framework for document structuring, publishing and search) + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2014, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + 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 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 <http://www.gnu.org/licenses/>. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + <http://www.fsf.org/licenses/gpl.html> + <http://www.gnu.org/licenses/gpl.html> + <http://www.jus.uio.no/sisu/gpl.fsf> + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + WOK_SQL + end + def header1 + <<-'WOK_SQL' +#Common TOP + @@offset=0 + @@canned_search_url=@base + @color_heading='#DDFFAA' + @color_match='#ffff48' + class Form + def initialize(base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can='') + search_note='' if checked_searched !~/\S/ + the_can='' if checked_url !~/\S/ + search_field='' if checked_echo !~/\S/ + @base,@search_field,@selected_db,@result_type,@checked_sql_limit,@checked_tip,@checked_stats,@checked_searched,@checked_url,@checked_case,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_selected,@checked_default,@search_note,@the_can=base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can + @tip=if checked_tip =~/\S/ + '<font size="2" color="#666666">text:__; fulltxt:__; keywords:__; title:__; author:__; topic_register:__; subject:__; description:__; publisher:__; editor:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__;</font><br>' + else '' + end + end + def submission_form + search_form=<<-WOK + WOK_SQL + end + def header_desc + <<-WOK_SQL + <!DOCTYPE html> + <html> + <head> + <title> + <meta charset="utf-8"> + <meta name="sourcefile" content="SiSU._sst" /> + SiSU search form (sample): SiSU information Structuring Universe + + + + + + + + + +
+ + +
+
+ SiSU + +
+ git + +
+
+ +
+ WOK_SQL + end + def header2 + <<-'WOK_SQL' +
+ + +
+ + + #{@tip} + #{@search_note} + #{@the_can} +
+ + + + + to search: select which database to search (drop-down menu below); enter your search query (in the form above); and click on the search button (below) +
+ + + index + text / grep + WOK_SQL + end + def buttons2 + <<-'WOK_SQL' +
+ match limit: + 1,000 + 2,500 +
+ echo query + result stats + search url + searched + available fields + sql statement +
+ checks: + default + selected + all + none +
+ + +
+ WOK + end + end + WOK_SQL + end + def search_request + <<-'WOK_SQL' + class SearchRequest #% search_for + attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:filename + def initialize(search_field='',q='') + @search_field,@q=search_field,q + @text1=@fulltext=@keywords=@title=@author=@topic_register=@subject=@description=@publisher=@editor=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@comment=@abstract=@owner=@date_created=@date_issued=@date_modified=@date_available=@date_valid=@filename='' + if @search_field=~/\S/ + @text1=text_to_match('text:') + @fulltext=text_to_match('fulltxt:') + @topic_register=text_to_match('topic_register:') + @title=text_to_match('title:') # DublinCore 1 - title + @author=text_to_match('(?:author|creator)s?:') # DublinCore 2 - creator/author + @subject=text_to_match('subj(?:ect)?:') # DublinCore 3 - subject + @description=text_to_match('description:') # DublinCore 4 - description + @publisher=text_to_match('pub(?:lisher)?:') # DublinCore 5 - publisher + @editor=text_to_match('editor:') + @contributor=text_to_match('contributor:') # DublinCore 6 - contributor + @date=text_to_match('date:') # DublinCore 7 - date dd-mm-yy + @type=text_to_match('type:') # DublinCore 8 - type + @format=text_to_match('format:') # DublinCore 9 - format + @identifier=text_to_match('identifier:') # DublinCore 10 - identifier + @source=text_to_match('source:') # DublinCore 11 - source + @language=text_to_match('language:') # DublinCore 12 - language + @relation=text_to_match('relation:') # DublinCore 13 - relation + @coverage=text_to_match('coverage:') # DublinCore 14 - coverage + @rights=text_to_match('rights:') # DublinCore 15 - rights + @keywords=text_to_match('key(?:words?)?:') + @comment=text_to_match('comment:') + @abstract=text_to_match('abs(?:tract)?:') + @owner=text_to_match('owner:') + @date_created=text_to_match('date_created:') + @date_issued=text_to_match('date_issued:') + @date_modified=text_to_match('date_modified:') + @date_available=text_to_match('date_available:') + @date_valid=text_to_match('date_valid:') + @filename=text_to_match('filename:') + @text1=text_to_match unless @keywords or @author or @title or @text1 or @fulltext or @comment or @abstract or @rights or @subject or @publisher or @date or @filename or @topic_register + else + @text1=q['s1'] if q['s1']=~/\S/ + @fulltext=q['ft'] if q['ft']=~/\S/ + @keywords=q['key'] if q['key']=~/\S/ + @title=q['ti'] if q['ti']=~/\S/ + @author=q['au'] if q['au']=~/\S/ + @topic_register=q['tr'] if q['tr']=~/\S/ + @subject=q['sj'] if q['sj']=~/\S/ + @description=q['dsc'] if q['dsc']=~/\S/ + @publisher=q['pb'] if q['pb']=~/\S/ + @editor=q['cntr'] if q['cntr']=~/\S/ + @contributor=q['cntr'] if q['cntr']=~/\S/ + @date=q['dt'] if q['dt']=~/\S/ + @type=q['ty'] if q['ty']=~/\S/ + @identifier=q['id'] if q['id']=~/\S/ + @source=q['src'] if q['src']=~/\S/ + @language=q['lang'] if q['lang']=~/\S/ + @relation=q['rel'] if q['rel']=~/\S/ + @coverage=q['cov'] if q['cov']=~/\S/ + @rights=q['cr'] if q['cr']=~/\S/ + @comment=q['co'] if q['co']=~/\S/ + @abstract=q['ab'] if q['ab']=~/\S/ + @date_created=q['dtc'] if q['dtc']=~/\S/ + @date_issued=q['dti'] if q['dti']=~/\S/ + @date_modified=q['dtm'] if q['dtm']=~/\S/ + @date_available=q['dta'] if q['dta']=~/\S/ + @date_valid=q['dtv'] if q['dtv']=~/\S/ + @filename=if q['doc'] and q['search'] !~/search db/ then q['doc'] + elsif q['fns']=~/\S/ then q['fns'] + end + @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000 + @@offset=q['off'] if q['off']=~/\d+/ # 0 + end + end + def text_to_match(identifier='') + m={ + string: /#{identifier}\s*(.+?)/, + string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, + word: /#{identifier}[\s(]*(\S+)/ + } + search_string=if @search_field =~m[:word] + search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] + elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] + else + str=m[:word].match(@search_field)[1] + str=str.gsub(/[()]/,'') + str + end + search_string=search_string.strip.gsub(/\s+/,'+') + #else + # "__" + end + end + end + WOK_SQL + end + def search_statement_common + <<-'WOK_SQL' + class DBI_SearchStatement + attr_reader :text_search_flag,:sql_select_body_format,:sql_offset,:sql_limit + def initialize(conn,search_for,q,c) + @conn=conn + @text_search_flag=false + @sql_statement={ body: '', endnotes: '', range: '' } + #@offset||=@@offset + #@offset+=@@limit + search={ text: [], endnotes: [] } + cse=(c =~/\S/) ? true : false + st=DBI_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string + se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string + @text_search_flag=st[:flag] + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.title',search_for.title,q['ti'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_type',search_for.type,q['ty'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_relation',search_for.relation,q['rel'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_coverage',search_for.coverage,q['cov'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string + if st[:flag] + search[:text] << st[:search] + end + st=DBI_SearchString.new('metadata_and_text.src_filename',search_for.filename,q['fns'],cse).string + if st[:flag] + search[:text] << st[:search] + end + @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000 + @@offset=q['off'] if q['off']=~/\d+/ # 0 + WOK_SQL + end + def pages + <<-'WOK_SQL' + def sql_offset + @@offset + end + def sql_match_limit + @@limit + end + def sql_canned_search + @offset_next=sql_offset.to_i + sql_match_limit.to_i + @offset_previous=sql_offset.to_i - sql_match_limit.to_i + def current + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s + end + def next + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s + end + def previous + @offset_previous >= 0 \ + ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) + : '' + end + def start + @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s + end + self + end + def pre_next(beyond_limit,img) + can=sql_canned_search + page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i + if beyond_limit + if page.to_s =~ /^1$/ + %{
+ pg. #{page.to_s} + +  >> + +
} + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} + +  >> + +
} + else + %{
+ + |<  + + + <<  + + pg. #{page.to_s} + +  >> + +
} + end + else + if page.to_s =~ /^1$/ then '' + elsif page.to_s =~ /^2$/ + %{
+ + <<  + + pg. #{page.to_s} +
} + else + %{
+ + |<  + + + <<  + + pg. #{page.to_s} +
} + end + end + end + WOK_SQL + end + def tail + v=SiSU_Env::InfoVersion.instance.get_version + <<-WOK_SQL + def tail + <<-'WOK' +


+ + + + + + +
+ + +
+
+ SiSU + +
+ git + +
+
+ +

+ Generated by + #{v.project} #{v.version} #{v.date} (#{v.date_stamp}) +
+ + #{v.project} © Ralph Amissah + 1993, current 2014. + All Rights Reserved. +
+ #{v.project} is software for document structuring, publishing and search, +
+ + www.jus.uio.no/sisu + + and + + www.sisudoc.org + + sources + + git.sisudoc.org + +
+ w3 since October 3 1993 + + ralph@amissah.com + +
+ mailing list subscription + + http://lists.sisudoc.org/listinfo/sisu + +
+ + sisu@lists.sisudoc.org + +

+
+

+ #{v.project} using: +
Standard SiSU markup syntax, +
Standard SiSU meta-markup syntax, and the +
Standard SiSU object citation numbering and system, (object/text identifying/locating system) +
+ © Ralph Amissah 1997, current 2014. + All Rights Reserved. +

+
+

+ + .: + +

+
+

+ SiSU is released under + GPL v3 + or later, + + http://www.gnu.org/licenses/gpl.html + +

+
+

+ #{v.project}, developed using + + Ruby + + on + + Debian/Gnu/Linux + + software infrastructure, + with the usual GPL (or OSS) suspects. +

+
+ + + WOK + end + WOK_SQL + end + def main1 + <<-'WOK_SQL' + @tail=tail + @counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 + @counters_txt,@counters_endn,@sql_select_body='','','' + FCGI.each_cgi do |cgi| + begin # all code goes in begin section + @search={ text: [], endnotes: [] } + q=CGI.new + @db=if cgi['db'] =~ /#{@db_name_prefix}(\S+)/ + @stub=$1 + cgi['db'] + else + @stub=@stub_default + @db_name_prefix + @stub + end + checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','','' + result_type=(cgi['view']=~/text/) \ + ? result_type={ index: '', text: 'checked'} + : result_type={ index: 'checked', text: ''} + @@limit=if cgi['sql_match_limit'].to_s=~/2500/ + checked_sql_limit={ l1000: '', l2500: 'checked'} + '2500' + else + checked_sql_limit={ l1000: 'checked', l2500: ''} + '1000' + end + checked_echo='checked' if cgi['echo'] =~/\S/ + checked_stats='checked' if cgi['stats'] =~/\S/ + checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1 + checked_searched='checked' if cgi['searched'] =~/\S/ + checked_tip='checked' if cgi['tip'] =~/\S/ + checked_case='checked' if cgi['casesense'] =~/\S/ + checked_sql='checked' if cgi['sql'] =~/\S/ + if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1 + checked_all='checked' + checked_echo=checked_stats=checked_url=checked_searched=checked_tip=checked_sql='checked' + checked_none='' + elsif cgi['checks'] =~/check_none/ + checked_none='checked' + checked_all=checked_url=checked_stats=checked_searched=checked_tip=checked_echo=checked_sql='' + elsif cgi['checks'] =~/check_selected/ + checked_selected='checked' + elsif cgi['checks'] =~/check_default/ + checked_default='checked' + checked_echo=checked_stats=checked_url='checked' + checked_searched=checked_tip=checked_case=checked_sql='' + else + checked_selected='checked' + checked_echo=checked_stats=checked_url='checked' + checked_searched=checked_tip=checked_case=checked_sql='' + end + WOK_SQL + end + def main2 + <<-'WOK_SQL' + search_field=cgi['find'] if cgi['find'] # =~/\S+/ + @search_for=SearchRequest.new(search_field,q) #.analyze #% search_for + #% searches + #Canned_search.new(@base,@search_for.text1,cgi) + if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ + s1='s1=' + CGI.escape(@search_for.text1) if @search_for.text1=~/\S/ + ft='&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext=~/\S/ + key='key=' + CGI.escape(@search_for.keywords) if @search_for.keywords=~/\S/ + ti='&ti=' + CGI.escape(@search_for.title) if @search_for.title=~/\S/ + au='&au=' + CGI.escape(@search_for.author) if @search_for.author=~/\S/ + tr='&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register=~/\S/ + sj='&sj=' + CGI.escape(@search_for.subject) if @search_for.subject=~/\S/ + dsc='&dsc=' + CGI.escape(@search_for.description) if @search_for.description=~/\S/ + pb='&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher=~/\S/ + edt='&edt=' + CGI.escape(@search_for.editor) if @search_for.editor=~/\S/ + cntr='&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor=~/\S/ + dt='&dt=' + CGI.escape(@search_for.date) if @search_for.date=~/\S/ + ty='&ty=' + CGI.escape(@search_for.type) if @search_for.type=~/\S/ + id='&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier=~/\S/ + src='&src=' + CGI.escape(@search_for.source) if @search_for.source=~/\S/ + lang='&lang=' + CGI.escape(@search_for.language) if @search_for.language=~/\S/ + rel='&rel=' + CGI.escape(@search_for.relation) if @search_for.relation=~/\S/ + cov='&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage=~/\S/ + cr='&cr=' + CGI.escape(@search_for.rights) if @search_for.rights=~/\S/ + co='&co=' + CGI.escape(@search_for.comment) if @search_for.comment=~/\S/ + ab='&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract=~/\S/ + dtc='&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created=~/\S/ + dti='&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued=~/\S/ + dtm='&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified=~/\S/ + dta='&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available=~/\S/ + dtv='&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid=~/\S/ + fns='&fns=' + CGI.escape(@search_for.filename) if @search_for.filename=~/\S/ + @@canned_search_url=(checked_all =~/checked/) \ + ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" + : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" + mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 + @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" + if checked_case=~/\S/ + @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 + else + @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 + end + canned_note='search url:' + else + @@canned_search_url="#{@base}?db=#{@db}&view=index" + canned_note='search url example:' + end + if search_field =~/\S+/ + analyze_format=search_field.gsub(/\s*\n/,'; ') + elsif checked_all =~/checked/ or checked_url =~/checked/ + canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) + af=canned_search.join('; ') + af=af.gsub(/s1=/,'text: '). + gsub(/ft=/,'fulltxt: '). + gsub(/au=/,'author: '). + gsub(/ti=/,'title: '). + gsub(/fns=/,'filename: '). + gsub(/tr=/,'topic_register: '). + gsub(/%2B/,' ') + analyze_format=af + st=af.split(/\s*;\s*/) + search_field=st.join("\n") + end + green=%{} + canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) + the_can=%{#{canned_note} #{canned_search_url_txt}
} + p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename='' + p_filename=%{filename: #{green}#{@search_for.filename}

} if @search_for.filename =~/\S+/ + p_text=%{text: #{green}#{@search_for.text1}
} if @search_for.text1 =~/\S+/ + p_fulltext=%{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~/\S+/ + p_title=%{title: #{green}#{@search_for.title}
} if @search_for.title =~/\S+/ + p_author=%{author: #{green}#{@search_for.author}
} if @search_for.author =~/\S+/ + p_editor=%{editor: #{green}#{@search_for.editor}
} if @search_for.editor=~/\S+/ + p_contributor=%{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~/\S+/ + p_date=%{date: #{green}#{@search_for.date}
} if @search_for.date =~/\S+/ + p_rights=%{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~/\S+/ + p_topic_register=%{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~/\S+/ + p_subject=%{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~/\S+/ + p_keywords=%{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~/\S+/ + p_identifier=%{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~/\S+/ + p_type=%{type: #{green}#{@search_for.type}
} if @search_for.type =~/\S+/ + p_format=%{format: #{green}#{@search_for.format}
} if @search_for.format =~/\S+/ + p_relation=%{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~/\S+/ + p_coverage=%{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~/\S+/ + p_description=%{description: #{green}#{@search_for.description}
} if @search_for.description =~/\S+/ + p_abstract=%{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~/\S+/ + p_comment=%{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~/\S+/ + p_publisher=%{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~/\S+/ + p_source=%{source: #{green}#{@search_for.source}
} if @search_for.source =~/\S+/ + p_language=%{language: #{green}#{@search_for.language}
} if @search_for.language =~/\S+/ + search_note=<<-WOK + + database: #{green}#{@db}; selected view: #{green}#{cgi['view']} + search string: "#{green}#{analyze_format}"
+ #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename} + + WOK + #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} + #% dbi_canning + @header=Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form + unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ + print "Content-type: text/html\n\n" + puts (@header+@tail) + else #% searches + s1=(@search_for.text1 =~/\S/) \ + ? @search_for.text1 + : 'Unavailable' + if checked_case=~/\S/ + @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} + else + @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} + end + #% dbi_request + dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) + @text_search_flag=false + @text_search_flag=dbi_statement.text_search_flag + s_contents=dbi_statement.contents + @body_main='' + @search_regx=nil + oldtid=0 + if @text_search_flag + if checked_sql =~/\S/ + sql_select_body=dbi_statement.sql_select_body_format + else sql_select_body='' + end + @body_main << sql_select_body + else + end + @hostpath="#{@hosturl_files}/#{@stub}" + WOK_SQL + end + def dir_structure #@opt.dir_structure_by + <<-'WOK_SQL' + def path_manifest(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{@hostpath}/#{fn}/sisu_manifest.html" + : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/manifest/#{fn}.html" + : "#{@hostpath}/manifest/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/manifest/#{fn}.html" + end + end + def path_html_seg(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + "#{@hostpath}/#{fn}" + when 'filetype' + "#{@hostpath}/html/#{fn}" + else + "#{@hostpath}/#{ln}/html/#{fn}" + end + end + def path_toc(fn,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/toc.html" + : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/toc.html" + end + end + def path_filename(fn,seg,ln=nil) + if @output_dir_structure_by =='filename' \ + or @output_dir_structure_by =='filetype' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/#{seg}.html" + : "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" + else + "#{path_html_seg(fn,ln)}/#{seg}.html" + end + end + def path_html_doc(fn,ln=nil) + case @output_dir_structure_by + when 'filename' + @lingual =='mono' \ + ? "#{path_html_seg(fn,ln)}/scroll.html" + : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" + when 'filetype' + @lingual =='mono' \ + ? "#{@hostpath}/html/#{fn}.html" + : "#{@hostpath}/html/#{fn}.#{ln}.html" + else + "#{@hostpath}/#{ln}/html/#{fn}.html" + end + end + WOK_SQL + end + def main3 + <<-'WOK_SQL' + #% text_objects_body + s_contents.each do |c| #% text body + location=c['src_filename'][/(.+?)\.(?:ssm\.sst|sst)$/,1] + file_suffix=c['src_filename'][/.+?\.(ssm\.sst|sst)$/,1] + lang=if location =~ /\S+?~(\S\S\S?)$/ + l=location[/\S+?~(\S\S\S?)$/,1] + location=location.gsub(/(\S+?)~\S\S\S?/,'\1') + l=".#{l}" + else '' + end + #% metadata_found_body + if c['tid'].to_i != oldtid.to_i + ti=c['title'] + can_txt_srch=(cgi['view']=~/index/) \ + ? %{search } + : %{search } + title=%{toc html #{ti} [#{c['language_document_char']}] by #{c['creator_author']} manifest #{can_txt_srch}
} if file_suffix=~/s/ #hmm watch file_suffix + title=@text_search_flag \ + ? '

'+title + : '
'+title + @counter_txt_doc+=1 + oldtid=c['tid'].to_i + else title='' + end + if @text_search_flag + if cgi['view']=~/text/ \ + or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body + text=if c['suffix'] !~/1/ #seg + if @search_for.text1 =~/\S+/ \ + or q['s1'] =~/\S+/ #% only this branch is working !! + unescaped_search=if @search_for.text1 =~/\S+/ + CGI.unescape(@search_for.text1) + elsif q['s1'] =~/\S+/ + CGI.unescape(q['s1']) + else nil + end + @search_regx=if unescaped_search #check + search_regex=unescaped_search.scan(/\S+/).each.map do |g| + (g.to_s =~/(AND|OR)/) \ + ? ('|') + : (%{#{g.to_s}}) + end.join(' ') + search_regex=search_regex.gsub(/\s*\|\s*/,'|') + Regexp.new(search_regex, Regexp::IGNORECASE) + else nil + end + else nil + end + matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ + ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) + : c['body'] + %{

ocn #{c['ocn']}:

#{matched_para}} + elsif c['suffix'] =~/1/ #doc + %{#{title}

ocn #{c['ocn']}:#{c['body']}} + end + @counter_txt_ocn+=1 + output=title+text + else #elsif cgi['view']=~/index/ #% idx body + if c['suffix'] !~/1/ #seg + index=%{#{c['ocn']}, } if @text_search_flag + elsif c['suffix'] =~/1/ #doc #FIX + index=%{#{c['ocn']}, } + end + if c['seg'] =~/\S+/ + if @text_search_flag + @counter_txt_ocn+=1 + output=title+index + end + else + @counter_txt_ocn+=1 + output=c['suffix'] !~/1/ \ + ? title+index + : %{#{title}#{c['ocn'].sort}, } + end + end + else output=title + end + @counters_txt=if @counter_txt_doc > 0 + if checked_stats =~/\S/ + @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false + start=(@@offset.to_i+1).to_s + range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s + %{


Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} + else '' + end + else '' + end + @body_main << output #+ details + end + oldtid = 0 + offset=dbi_statement.sql_offset.to_s + limit=dbi_statement.sql_match_limit.to_s + @@lt_t ||=false; @@lt_e ||=false + canned=(@@lt_t or @@lt_e) \ + ? dbi_statement.pre_next(true,@image_src).to_s + : dbi_statement.pre_next(false,@image_src).to_s + limit=dbi_statement.sql_match_limit.to_s + cgi.out{@header.force_encoding("UTF-8") + @counters_txt.force_encoding("UTF-8") + @counters_endn.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @body_main.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @tail.force_encoding("UTF-8")} #% print cgi_output_header+counters+body + end + rescue Exception => e + s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
+          s << CGI::escapeHTML(e.message) + '
' + cgi.out{s} + next + ensure # eg. disconnect from server + @conn.disconnect if @conn + end + end + WOK_SQL + end + end +end +__END__ diff --git a/lib/sisu/cgi_sqlite.rb b/lib/sisu/cgi_sqlite.rb new file mode 100644 index 00000000..6668028a --- /dev/null +++ b/lib/sisu/cgi_sqlite.rb @@ -0,0 +1,244 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** generates naive cgi search form for search of sisu database (sqlite) + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_CGI_SQLite #% database building documents + require_relative 'se' # se.rb + require_relative 'cgi_sql_common' # cgi_sql_common.rb + include SiSU_CGI_SQL + class SearchSQLite < CGI_Common + def initialize(opt,webserv) + @opt,@webserv=opt,webserv + @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX + @env=SiSU_Env::InfoEnv.new('',opt) + @image_src="#{@env.url.webserv_cgi(opt)}/_sisu/image_sys" + @name_of={} + @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ + opt.dir_structure_by.to_s + else 'language' + end + @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ + opt.lingual.to_s + else 'multi' + end + @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} + @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} + @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} + @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} + @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) + @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) + @name_of_sqlite_db_file='sisu_sqlite.db' + end + def sqlite + serve=[] + Dir.foreach(@env.path.webserv) do |x| + if x !~/^\./ \ + and FileTest.directory?("#{@env.path.webserv}/#{x}") + if FileTest.file?("#{@env.path.webserv}/#{x}/#{@name_of_sqlite_db_file}") + serve << x unless x =~/^_\S+/ + end + end + end + serve=serve.sort + f1,f2,f3='','','' + serve.each do |x| + f1 << %{ \n} + end + f2 << %{ selected_db=case cgi['db']\n} + serve.each do |x| + f2 << %{ when /#{Db[:name_prefix]}#{x}/ then ''\n} + end + f2 << " end\n" + f3 << %{ db_name='#{@name_of_sqlite_db_file}'\n} + f3 << %{ db_sqlite=case cgi['db']\n} + serve.each do |x| + f3 << %{ when /#{Db[:name_prefix]}#{x}/ then "#{@env.path.webserv}/#{x}/\#{db_name}"\n} + end + f3 << %{ else "#{@env.path.webserv}/#{serve[0]}/\#{db_name}"\n end\n} + if FileTest.writable?('.') + output=File.open(@cgi_file_name,'w') + output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << f3 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3 + puts <<-WOK + generated sample search form: #{@cX.green}#{@cgi_file_name}#{@cX.off} + default database name: #{@cX.green}#{Db[:name_prefix]}#{@env.path.base_markup_dir_stub}#{@cX.off} (#{@env.path.base_markup_dir_stub}) + cgi & db host on: #{@cX.blue}#{@env.url.webserv_base_cgi(@opt)}#{@cX.off} + to modify use: #{@cX.brown}sisu --db-sqlite --webserv-search='#{@env.url.webserv_base_cgi(@opt)}'#{@cX.off} + sisu output on: #{@cX.blue}#{@env.url.webserv_files_from_db(@opt)}#{@cX.off} + to modify use: #{@cX.brown}sisu --db-sqlite --webserv-output='#{@env.url.webserv_files_from_db(@opt)}'#{@cX.off} + cgi search form link name: #{@cX.green}#{@env.url.cgi_sample_search_form_name(@opt)}#{@cX.off} + to modify use: #{@cX.brown}sisu --db-sqlite --cgi-search-form-name='#{@env.url.cgi_sample_search_form_name(@opt)}'#{@cX.off} + #{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off} + + #{@cX.fuchsia}NOTE it is first necessary to create the database and tables and populate it#{@cX.off} + + sisu --sqlite --dropall # removes existing postgresql db & tables + sisu --sqlite --createall -v # creates postgresql db & tables + sisu --sqlite --update -v *.sst *.ssm # populate the db + sisu --sample-search-form --sqlite # creates the postgresql search form + # this should be done after creating the db + # to be searched + sisu --webrick & # starts ruby webrick web server + + # if necessary make the directory '/usr/lib/cgi-bin' + # here we copy the postgresql search form to cgi-bin + # (copy #{@cgi_file_name} to your cgi directory) + # set file permissions to 755 + WOK + a=case @webserv + when /pwd/ then '' + else <<-WOK + + sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ + sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} + WOK + end + b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)' + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a,b).warn + a=<<-WOK + + #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} + + WOK + SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue + else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?" + end + end + def header0 + <<-WOK_SQL +#!/usr/bin/env ruby +=begin +#{about} + * Description: generates naive cgi search form for search of sisu database (sqlite) +#{gpl} +=end + begin + require 'cgi' + require 'fcgi' + require 'sqlite3' + rescue LoadError + puts 'cgi, fcgi or sqlite3 NOT FOUND (LoadError)' + end + @stub_default='sisu_sqlite' + @image_src="#{@image_src}" + @hosturl_cgi="#{@name_of[:host_url_cgi]}" + @hosturl_files="#{@name_of[:host_url_docs]}" + @output_dir_structure_by='#{@name_of[:output_dir_structure]}' + @lingual='#{@name_of[:lingual]}' + @db_name_prefix='#{Db[:name_prefix]}' + @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" + WOK_SQL + end + def search_statement + <<-'WOK_SQL' + class DBI_SearchString + def initialize(l,t,q,cse=false) + @l,@t,@q=l,t,q + end + def string + search={ search: [], flag: false } + if @t =~/\S+/ or @q =~/\S+/ + if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) + end + search_construct=[] + unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%"). + gsub(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") + search_construct << unescaped_search + search_construct=search_construct.join(' ') + search[:search] << search_construct + search[:flag]=true + search + end + search + end + end + WOK_SQL + end + def search_query1 + <<-'WOK_SQL' + @search_text='' + @search_text=search[:text].flatten.join(' AND ') + @search_text=@search_text.gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') + end + WOK_SQL + end + def search_query2 + <<-'WOK_SQL' + def sql_select_body + limit ||=@@limit + offset ||=@@offset + @sql_statement[:body]=%{SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg, doc_objects.ocn, metadata_and_text.tid FROM doc_objects, metadata_and_text WHERE #{@search_text} AND doc_objects.metadata_tid = metadata_and_text.tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, doc_objects.ocn} + @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} + select=@sql_statement[:body] + ' ' + @sql_statement[:range] + select + end + def sql_select_body_format + %{#{sql_select_body}} + end + def contents + @conn.execute(sql_select_body) + end + end + WOK_SQL + end + def dbi_connect + <<-'WOK_SQL' + @conn=SQLite3::Database.new(db_sqlite) + @conn.results_as_hash=true + WOK_SQL + end + end +end +__END__ diff --git a/lib/sisu/conf.rb b/lib/sisu/conf.rb new file mode 100644 index 00000000..009dd719 --- /dev/null +++ b/lib/sisu/conf.rb @@ -0,0 +1,287 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** configuration + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_Initialize + require_relative 'se' # se.rb + include SiSU_Env + include SiSU_Screen + require_relative 'relaxng' # relaxng.rb + include SiSU_Relaxng + require_relative 'css' # css.rb + include SiSU_Style + class Source + def initialize(opt) + @opt=opt + end + def read + ConfigSite.new(@opt).make_homepage + ConfigSite.new(@opt).css + ConfigSite.new(@opt).dtd + ConfigSite.new(@opt).cp_local_images + ConfigSite.new(@opt).cp_external_images + ConfigSite.new(@opt).cp_webserver_images + end + end + class ConfigSite #config files such as css are not updated if they already exist unless forced using the --init=site modifier + require_relative 'se' # se.rb + def initialize(opt) + @opt=opt + @env=SiSU_Env::InfoEnv.new(@opt.fns) + @suffix={ + rnc: 'rnc', + rng: 'rng', + xsd: 'xsd', + } + @path={ + xml: @env.path.output + '/_sisu/xml', + xsd: @env.path.output + '/_sisu/xml/xsd', + rnc: @env.path.output + '/_sisu/xml/rnc', + rng: @env.path.output + '/_sisu/xml/rng', + style: @env.path.output + '/' + @env.path.style, + } + @pwd,@home=Dir.pwd,@env.path.home + end + def make_homepage + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Make homepage', + '' + ).colorize unless @opt.act[:quiet][:set]==:on + SiSU_Env::CreateSite.new(@opt).homepage + end + def cp_local_images + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Copy images', + '' + ).colorize unless @opt.act[:quiet][:set]==:on + SiSU_Env::CreateSite.new(@opt).cp_local_images + SiSU_Env::CreateSite.new(@opt).cp_webserver_images_local #this should not have been necessary + SiSU_Env::CreateSite.new(@opt).cp_base_images #base images (nav etc.) used by all html + end + def cp_external_images + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Copy external images', + '' + ).colorize if @opt.act[:verbose_plus][:set]==:on + SiSU_Env::CreateSite.new(@opt).cp_external_images + end + def cp_webserver_images + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Copy webserver/output file images', + '' + ).colorize unless @opt.act[:quiet][:set]==:on + SiSU_Env::CreateSite.new(@opt).cp_webserver_images + end + def css + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Configuring CSSs', + '' + ).colorize unless @opt.act[:quiet][:set]==:on + SiSU_Env::CreateSite.new(@opt).cp_css + end + def dtd + SiSU_Screen::Ansi.new( + @opt.act[:color_state][:set], + 'invert', + 'Configuring DTDs', + '' + ).colorize unless @opt.act[:quiet][:set]==:on + @rxng=SiSU_Relaxng::RelaxNG.new + @path.each { |d| FileUtils::mkdir_p(d[1]) \ + unless FileTest.directory?(d[1]) } + #ugly code, sort later + if @rxng.methods.join =~/[^_]dtd_sax\b/ + if @rxng.dtd_sax.length > 200 + dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_sax}",'w') + dtd << @rxng.dtd_sax + dtd.close + else trang_rnc_model_output_sax + end + else trang_rnc_model_output_sax + end + if @rxng.methods.join =~/[^_]dtd_dom\b/ + if @rxng.dtd_dom.length > 200 + dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_dom}",'w') + dtd << @rxng.dtd_dom + dtd.close + else trang_rnc_model_output_dom + end + else trang_rnc_model_output_dom + end + if @rxng.methods.join =~/[^_]dtd_node\b/ + if @rxng.dtd_node.length > 200 + dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.input_node}",'w') + dtd << @rxng.dtd_node + dtd.close + else trang_rnc_model_input_node + end + else trang_rnc_model_input_node + end + if @rxng.methods.join =~/[^_]dtd_xhtml\b/ + if @rxng.dtd_xhtml.length > 200 + dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_xhtml}",'w') + dtd << @rxng.dtd_xhtml + dtd.close + else trang_rnc_model_output_xhtml + end + else trang_rnc_model_output_xhtml + end + end + def trang_rnc_model_output_sax + s=@suffix + rnc_src=@env.processing_path.ao + '/sax.' + s[:rnc] + rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_sax + rng_file=@path[:rng] + '/' + @rxng.rng_name.output_sax + xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_sax + rnc=File.new(rnc_src,'w') + rnc << @rxng.rnc_model_output_sax + rnc.close + #xsd + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) + schema.relaxng(@opt.selections.str) + #rng + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) + schema.relaxng(@opt.selections.str) + #rnc + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end + end + def trang_rnc_model_output_dom + s=@suffix + rnc_src=@env.processing_path.ao + '/dom.' + s[:rnc] + rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_dom + rng_file=@path[:rng] + '/' + @rxng.rng_name.output_dom + xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_dom + rnc=File.new(rnc_src,'w') + rnc << @rxng.rnc_model_output_dom + rnc.close + #xsd + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) + schema.relaxng(@opt.selections.str) + #rng + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) + schema.relaxng(@opt.selections.str) + #rnc + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end + end + def trang_rnc_model_output_xhtml + s=@suffix + rnc_src=@env.processing_path.ao + '/xhtml.' + s[:rnc] + rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_xhtml + rng_file=@path[:rng] + '/' + @rxng.rng_name.output_xhtml + xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_xhtml + rnc=File.new(rnc_src,'w') + rnc << @rxng.rnc_model_output_xhtml + rnc.close + #xsd + schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) + schema.relaxng(@opt.selections.str) + #rng + schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) + schema.relaxng(@opt.selections.str) + #rnc + if FileTest.file?(rnc_src) + FileUtils::cp(rnc_src,rnc_file) + FileUtils::chmod(0644,rnc_file) + else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} + end + end + def trang_rnc_model_input_sax + rnc_file=@env.processing_path.ao + '/sax.rnc' + dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_sax + rnc=File.new(rnc_file,'w') + rnc << @rxng.rnc_model_output_sax + rnc.close + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) + schema.relaxng(@opt.selections.str) + end + def trang_rnc_model_input_dom + rnc_file=@env.processing_path.ao + '/dom.rnc' + dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_dom + rnc=File.new(rnc_file,'w') + rnc << @rxng.rnc_model_output_dom + rnc.close + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) + schema.relaxng(@opt.selections.str) + end + def trang_rnc_model_input_node + rnc_file=@env.processing_path.ao + '/node.rnc' + dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_node + rnc=File.new(rnc_file,'w') + rnc << @rxng.rnc_model_input_node + rnc.close + schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) + schema.relaxng(@opt.selections.str) + end + end +end +__END__ diff --git a/lib/sisu/constants.rb b/lib/sisu/constants.rb new file mode 100644 index 00000000..d6978a09 --- /dev/null +++ b/lib/sisu/constants.rb @@ -0,0 +1,388 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** constants, system environment, resource control and configuration details + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +#Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}} +YEAR='2014' +Sfx={ + txt: '.txt', + txt_textile: '.textile', + txt_asciidoc: '.ad', + txt_markdown: '.md', + txt_rst: '.rst', + txt_orgmode: '.org', + html: '.html', + xhtml: '.xhtml', + xml: '.xml', + xml_sax: '.sax.xml', + xml_dom: '.dom.xml', + xml_scaffold: '.scaffold.xml', + xml_scaffold_structure_sisu: '.scaffold.sisu.xml', + xml_scaffold_structure_collapse: '.scaffold.collapse.xml', + xml_docbook: '.docbook.xml', + xml_docbook_article: '.article.docbook.xml', + xml_docbook_book: '.book.docbook.xml', + xml_fictionbook: '.fb2', + epub: '.epub', + epub_xhtml: '.xhtml', + odt: '.odt', + pdf: '.pdf', + manpage: '.1', + info: '.info', + texinfo: '.texinfo', + sql: '.sql.db', +} +Ax={ + tab: "\t", + comment: '%', + spaces: ' ', +} +Xx={ + protect: '☞', + split: '✠', + segment: 'Ф', + relative_path: '☼', + html_relative2: '※※', + html_relative1: '※', +} +Mx={ + segname_prefix_auto_num_extract: 'c', + segname_prefix_auto_num_provide: 's', + segname_prefix_auto_num_other: 'x', + ocn_id_char: '', #'o', now as before; remove for html5 + note: 'note_', + note_ref: 'noteref_', + note_astx: 'note_astx_', + note_ref_astx: 'noteref_astx_', + note_plus: 'note_plus_', + note_ref_plus: 'noteref_plus_', + meta_o: '〔@', meta_c: '〕', + lv_o_0: 0, + lv_o_1: 1, + lv_o_2: 2, + lv_o_3: 3, + lv_o_4: 4, + lv_o_5: 5, + lv_o_6: 6, + lv_o_7: 7, + lv_o_8: 8, + lv_o_9: 9, + lv_o: '〔', lv_c: '〕', + en_a_o: '【', en_a_c: '】', #endnote Mx[:en_a_o]='~{'; Mx[:en_a_c]='}~' + en_b_o: '〖', en_b_c: '〗', #endnote Mx[:en_b_o]='~['; Mx[:en_b_c]=']~' + bl_o: '〔', bl_c: '〕', #block text mark + gr_o: '〔', gr_c: '〕', #group text mark #REPLACE & RETIRE + id_o: '〔', id_c: '〕', #object id mark + tc_o: '『', tc_c: "』", #table row mark #Mx[:tc_c]="』\n" + tc_p: '┆', #table col/misc mark + pa_o: '〔', pa_c: '〕', #affects paragraph mark + mk_o: '〔', mk_c: '〕', #generic mark + gl_o: '〔', gl_c: '〕', #glyph + fa_o: '〔', fa_o_c: '¤', fa_c_o: '¤', fa_c: '〕', + idx_o: '▩', idx_c: '▩', + nbsp: '░', #'▭ ' + br_line: '╱', #lB ▌ 9612 ┘ ¶ + br_nl: '╲', #lB ▌ 』 ┘ + br_paragraph: '█', #FB █ 9608 # PP ∥ 8741 #▐ #'┘' #'¶' #FB █ 9608 lB ▌ 9612 RB ▐ 9616 + br_obj: 'break_obj', + br_page_line: '▭', + br_page: '┼', + br_page_new: '╋', + lnk_o: '⌠', lnk_c: '⌡', #'⌈' '⌋' '⌠' '⌡' #Mx[:lnk_o: '◁'; Mx[:lnk_c: '▷' #‹ › + url_o: '◘', url_c: '◙', + rel_o: '⌈', rel_c: '⌋', + tag_o: '⌊', tag_c: '⌉', + sm_set_o: '◢', sm_set_c: '◣', + sm_subset_o: '◢', sm_subset_c: '◣', + vline: '┆', # ¦ | + src_bold_o: '!{', src_bold_c: '}!', + src_italics_o: '/{', src_italics_c: '}/', + src_underscore_o: '_{', src_underscore_c: '}_', + src_cite_o: '"{', src_cite_c: '}"', + src_insert_o: '+{', src_insert_c: '}+', + src_strike_o: '-{', src_strike_c: '}-', + src_superscript_o: '^{', src_superscript_c: '}^', + src_subscript_o: ',{', src_subscript_c: '}', + src_hilite_o: '*{', src_hilite_c: '}*', + src_monospace_o: '#{', src_monospace_c: '}#', + srcrgx_bold_o: '\!\{', srcrgx_bold_c: '\}\!', + srcrgx_italics_o: '\/\{', srcrgx_italics_c: '\}\/', + srcrgx_underscore_o: '_\{', srcrgx_underscore_c: '\}_', + srcrgx_cite_o: '"\{', srcrgx_cite_c: '\}"', + srcrgx_insert_o: '\+\{', srcrgx_insert_c: '\}\+', + srcrgx_strike_o: '\-\{', srcrgx_strike_c: '\}\-', + srcrgx_superscript_o: '\^\{', srcrgx_superscript_c: '\}\^', + srcrgx_subscript_o: ',\{', srcrgx_subscript_c: '\},', + srcrgx_hilite_o: '\*\{', srcrgx_hilite_c: '\}\*', + srcrgx_monospace_o: '\#\{', srcrgx_monospace_c: '\}\#', +} +Mx[:fa_bold_o]= "#{Mx[:fa_o]}b#{Mx[:fa_o_c]}" +Mx[:fa_bold_c]= "#{Mx[:fa_c_o]}b#{Mx[:fa_c]}" +Mx[:fa_italics_o]= "#{Mx[:fa_o]}i#{Mx[:fa_o_c]}" +Mx[:fa_italics_c]= "#{Mx[:fa_c_o]}i#{Mx[:fa_c]}" +Mx[:fa_underscore_o]= "#{Mx[:fa_o]}u#{Mx[:fa_o_c]}" +Mx[:fa_underscore_c]= "#{Mx[:fa_c_o]}u#{Mx[:fa_c]}" +Mx[:fa_cite_o]= "#{Mx[:fa_o]}cite#{Mx[:fa_o_c]}" +Mx[:fa_cite_c]= "#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}" +Mx[:fa_insert_o]= "#{Mx[:fa_o]}ins#{Mx[:fa_o_c]}" +Mx[:fa_insert_c]= "#{Mx[:fa_c_o]}ins#{Mx[:fa_c]}" +Mx[:fa_strike_o]= "#{Mx[:fa_o]}del#{Mx[:fa_o_c]}" +Mx[:fa_strike_c]= "#{Mx[:fa_c_o]}del#{Mx[:fa_c]}" +Mx[:fa_superscript_o]= "#{Mx[:fa_o]}sup#{Mx[:fa_o_c]}" +Mx[:fa_superscript_c]= "#{Mx[:fa_c_o]}sup#{Mx[:fa_c]}" +Mx[:fa_subscript_o]= "#{Mx[:fa_o]}sub#{Mx[:fa_o_c]}" +Mx[:fa_subscript_c]= "#{Mx[:fa_c_o]}sub#{Mx[:fa_c]}" +Mx[:fa_hilite_o]= "#{Mx[:fa_o]}hi#{Mx[:fa_o_c]}" +Mx[:fa_hilite_c]= "#{Mx[:fa_c_o]}hi#{Mx[:fa_c]}" +Mx[:fa_monospace_o]= "#{Mx[:fa_o]}mono#{Mx[:fa_o_c]}" +Mx[:fa_monospace_c]= "#{Mx[:fa_c_o]}mono#{Mx[:fa_c]}" +Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" +Mx[:br_endnotes]= "#{Mx[:mk_o]}ENDNOTES#{Mx[:mk_c]}" +Mx[:br_eof]= "#{Mx[:mk_o]}EOF#{Mx[:mk_c]}" +Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) +Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) +Hx={ + br_obj: { obj: Mx[:br_obj] }, # line sep + br_page_line: { obj: Mx[:br_page_line] }, # line across page + br_page: { obj: Mx[:br_page] }, # newpage + br_page_new: { obj: Mx[:br_page_new] }, # clearpage +} +#Mx[:sm_set_o]='∈ '; Mx[:sm_set_c]='∋ ' +#Mx[:sm_subset_o]='∈ '; Mx[:sm_subset_c]='∋ ' +Rx={ + mx_fa_clean: /#{Mx[:fa_o]}.+?#{Mx[:fa_c]}|#{Mx[:pa_o]}.+?#{Mx[:pa_c]}|#{Mx[:mk_o]}.+?#{Mx[:mk_c]}/, + lv: /〔([0-9]):(\S*?)〕/, + lv_0: /#{Mx[:lv_o_0]}(\S*?)#{Mx[:lv_c]}/, + lv_1: /#{Mx[:lv_o_1]}(\S*?)#{Mx[:lv_c]}/, + lv_2: /#{Mx[:lv_o_2]}(\S*?)#{Mx[:lv_c]}/, + lv_3: /#{Mx[:lv_o_3]}(\S*?)#{Mx[:lv_c]}/, + lv_4: /#{Mx[:lv_o_4]}(\S*?)#{Mx[:lv_c]}/, + lv_5: /#{Mx[:lv_o_5]}(\S*?)#{Mx[:lv_c]}/, + lv_6: /#{Mx[:lv_o_6]}(\S*?)#{Mx[:lv_c]}/, + lv_7: /#{Mx[:lv_o_7]}(\S*?)#{Mx[:lv_c]}/, + lv_8: /#{Mx[:lv_o_8]}(\S*?)#{Mx[:lv_c]}/, + lv_9: /#{Mx[:lv_o_9]}(\S*?)#{Mx[:lv_c]}/, + meta: /#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}/, +} +Dx={ + ocn_o: '「', ocn_c: '」', + url_o: '‹', url_c: '›', + url_o_xml: '<', url_c_xml: '>', + rel_o: '‹', rel_c: '›', + lt_xml: '<', gt_xml: '>', +} +Tex={ + backslash: "\\\\", + backslash: "\\\\", + tilde: '\\\\\\~', +} +Px={ + bold_o: '*', bold_c: '*', + italics_o: '/', italics_c: '/', + underscore_o: '_', underscore_c: '_', + #emphasis_o: '*', emphasis_c: '*', + #bold_o: '!', bold_c: '!', + cite_o: '"', cite_c: '"', + insert_o: '+', insert_c: '+', + strike_o: '-', strike_c: '-', + superscript_o: '^', superscript_c: '^', + subscript_o: '[', subscript_c: ']', + hilite_o: '*', hilite_c: '*', + monospace_o: '', monospace_c: '', + lng_lst: SiSU_is.language_list?, + lng_lst_rgx: SiSU_is.language_list_regex?, + lv1: '*', + lv2: '=', + lv3: '=', + lv4: '-', + lv5: '.', + lv6: '.', +} +Px[:lng_lst_rgx]=Px[:lng_lst].join('|') +Ep={ + alt: :on, + d_oebps: 'OEBPS', + d_image: 'OEBPS/image', + d_css: 'OEBPS/css', + f_ncx: 'toc.ncx', + f_opf: 'content.opf', +} +$ep=if Ep[:alt]==:on + { + o: 'opf:', + hsp: ' ', + } +else + { + o: '', + hsp: ' ', + } +end +Db={ + name_prefix: "SiSU#{SiSU_is.version_major?}a_", + name_prefix_db: "sisu_#{SiSU_is.version_major?}a_", + col_title: 800, + col_title_part: 400, + col_title_edition: 10, + col_name: 600, + col_creator_misc_short: 100, + col_language: 100, + col_language_char: 6, + col_date_text: 10, + col_txt_long: 600, + col_txt_short: 200, + col_identify_hash: 256, + col_library: 30, + col_small: 16, + col_filename: 256, + col_digest: 128, + col_filesize: 10, + col_info_note: 2500, +} +Gt={ + grotto: 'sisu_src', + git: 'sisu:', + src: 'src', + pods: 'pods', + sisupod: 'sisupod', + pod: 'pod', + files: 'files', + doc: 'doc', + po: 'po4a/po', + pot: 'po4a/pot', + image: 'image', + audio: 'audio', + video: 'video', + conf: 'doc/_sisu', +} +S_CONF={ + header_make: 'sisu_document_make', + rc_yml: 'sisurc.yml', +} +ANSI_C={ + red: "\033[#{31}m", + green: "\033[#{32}m", + yellow: "\033[#{33}m", + blue: "\033[#{34}m", + fuchsia: "\033[#{35}m", + cyan: "\033[#{36}m", + inv_red: "\033[#{41}m", + inv_green: "\033[#{42}m", + inv_yellow: "\033[#{43}m", + inv_blue: "\033[#{44}m", + inv_fuchsia: "\033[#{45}m", + inv_cyan: "\033[#{46}m", + b_red: "\033[#{91}m", + b_green: "\033[#{92}m", + b_yellow: "\033[#{93}m", + b_blue: "\033[#{94}m", + b_fuchsia: "\033[#{95}m", + b_cyan: "\033[#{96}m", + off: "\033[m" +} +DISABLE={ + epub: { + internal_navigation: true, + per_section_title: true, + ncx_navpoint_unique_id: true, + }, +} +DEVELOPER={ + maintenance: :false, + under_construction: '_CONSTRUCTION_ZONE', +} +__END__ +utils.rb +consider: + 〔comment〕 + 〔links?????〕 + import document? +check: + bold line + +┆┆⋮┇┊┋ +『』 +「」 +〔〕 +【】 + +· +¤ + #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ✠ ㈣ + Ѳ ѳ Ф + ♩ ♭  ✠  ▭ ▬ ▪ +【】〖〗◢ ◣ ◀ ▶ ◘ ◙ « ▲ » +《》「」 + ‹ › ∗  ∴ ∷ +'〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕' +'〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' +◁▷ +◀this is text or an image▶ http:// +p __FILE__ +':'+ __LINE__.to_s +p __FILE__ + ' ' + __LINE__.to_s + ' ' + html +puts "#{__FILE__} #{__LINE__} #{o.inspect}" +puts __FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect +puts %{-\t#{__FILE__}::#{__LINE__}::#{caller}:\n"#{name}"} +p "\t" + txt.obj + " << #{__FILE__} #{__LINE__} >>" +p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is==:heading +data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is==:heading} +puts "#{__FILE__} #{__LINE__} #{para}" if @opt.act[:maintenance][:set]==:on +puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.act[:maintenance][:set]==:on + dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ + dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ + └ ┘ +Iu ⌠ 8992 Il ⌡ <7 ⌈ 8968 >7 ⌉ 8969 7< ⌊ 8970 7> ⌋ 8971 +<" 『 12302 >" 』 12303 +<' 「 12300 >' 」 12301 diff --git a/lib/sisu/css.rb b/lib/sisu/css.rb new file mode 100644 index 00000000..80f75853 --- /dev/null +++ b/lib/sisu/css.rb @@ -0,0 +1,3484 @@ +# encoding: utf-8 +=begin + +* Name: SiSU + +** Description: documents, structuring, processing, publishing, search +*** css stylesheets + +** Author: Ralph Amissah + + + +** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, + All Rights Reserved. + +** License: GPL 3 or later: + + 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 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 . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + +** SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + +** Hompages: + + + +** Git + + + +=end +module SiSU_Style + require_relative 'se' # se.rb + require_relative 'html_parts' # html_parts.rb + class CSS_HeadInfo + def initialize(md,ft='html') + @md,@ft=md,ft + @env=SiSU_Env::InfoEnv.new('',md) + @fn_css ||=SiSU_Env::CSS_Default.new + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + css_copy + end + def stylesheet + def css_path + SiSU_Env::CSS_Stylesheet.new(@md) + end + def css_embed_content + @css_embed_content ||=SiSU_Style::CSS.new + end + def css_embed? + if @ft=='html' \ + && @o_str.dump_or_redirect? + true + else + false + end + end + def css_embed(css) + <<-WOK + + WOK + end + def css_action + css=case @ft + when 'html' + css=css_embed_content.html + css_embed(css) + when 'xhtml' + css_path.xhtml + when 'xml_sax' + css_path.xml_sax + when 'xml_dom' + css_path.xml_dom + when 'xml_docbook' + css_path.xml_docbook + else + css_embed_content.html + end + end + def css_head + (css_embed?) \ + ? css_action + : "#{css_path.html}#{css_path.html_seg}" + end + def css_head_seg + (css_embed?) \ + ? css_action + : css_path.html_seg + end + def css_head_xml + css_action + end + self + end + def css_copy + if @o_str.dump_or_redirect? + css=SiSU_Style::CSS.new + if @o_str.dump? + css_pth="#{@md.opt.opt_act[:dump][:inst]}/#{@env.path.style}" + elsif @o_str.redirect? + css_pth="#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}/#{@env.path.style}" + end + FileUtils::mkdir_p(css_pth) unless FileTest.directory?(css_pth) + case @ft + when 'html' + style=File.new("#{css_pth}/#{@fn_css.html}",'w') + style << css.html + style.close + when 'xhtml' + style=File.new("#{css_pth}/#{@fn_css.xhtml}",'w') + style << css.xhtml + style.close + when 'xml_sax' + style=File.new("#{css_pth}/#{@fn_css.xml_sax}",'w') + style << css.xml_sax + style.close + when 'xml_dom' + style=File.new("#{css_pth}/#{@fn_css.xml_dom}",'w') + style << css.xml_dom + style.close + css_path.xml_dom + when 'xml_docbook' + style=File.new("#{css_pth}/#{@fn_css.xml_docbook}",'w') + style << css.xml_docbook + style.close + css_path.xml_docbook + end + end + end + end + class CSS + include SiSU_Parts_HTML + def fonts + the_font.set_fonts + end + def html_tables #stylesheet for css table_pages +< - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Air - require_relative 'se_hub_particulars' # se_hub_particulars.rb - class Source - @@ao_array=[] - @@fns=nil - def initialize(opt) - @opt=opt - @@fns||@opt.fns - @particulars=SiSU_Particulars::Combined.new(opt) - #@env=@particulars.env - #@md=@particulars.md - #@ao_array=@particulars.ao_array - end - def read - end - protected - def print - puts @particulars.md.inspect - puts @particulars.env.inspect - puts @particulars.ao_array - end - end -end -__END__ diff --git a/lib/sisu/current/ao.rb b/lib/sisu/current/ao.rb deleted file mode 100644 index b7878dbf..00000000 --- a/lib/sisu/current/ao.rb +++ /dev/null @@ -1,590 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** preprocessing, (document abstraction), data abstraction used in subsequent - processing - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO - require_relative 'se' # se.rb - include SiSU_Env - require_relative 'dp' # dp.rb - include SiSU_Param - require_relative 'ao_doc_objects' # ao_doc_objects.rb - require_relative 'ao_syntax' # ao_syntax.rb - include SiSU_AO_Syntax - require_relative 'ao_doc_str' # ao_doc_str.rb - require_relative 'ao_references' # ao_references.rb - require_relative 'ao_idx' # ao_idx.rb - require_relative 'ao_numbering' # ao_numbering.rb - require_relative 'ao_hash_digest' # ao_hash_digest.rb - require_relative 'ao_endnotes' # ao_endnotes.rb - require_relative 'ao_images' # ao_images.rb - require_relative 'ao_metadata' # ao_metadata.rb - require_relative 'ao_character_check' # ao_character_check.rb - require_relative 'ao_misc_arrange' # ao_misc_arrange.rb - require_relative 'ao_expand_insertions' # ao_expand_insertions.rb - require_relative 'ao_persist' # ao_persist.rb - require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'shared_sem' # shared_sem.rb - class Instantiate < SiSU_Param::Parameters::Instructions - def initialize - @@flag_vocab=0 - @@line_mode='' - end - end - class Source #{cf.meta}" - ).txt_grey - end - end - ao.each {|s| ao_array << s} - if @opt.act[:maintenance][:set]==:on - ao_array.each do |obj| - if defined? obj.parent - if defined? obj.ln - if defined? obj.node - puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}} - else - puts %{#{obj.ln}: #{obj.ocn} : #{obj.parent}} - end - else - if defined? obj.node - puts %{ #{obj.ocn} : #{obj.parent} : #{obj.node} - #{obj.lc}} - else - puts %{ #{obj.ocn} : #{obj.parent}} - end - end - end - end - end - ao_array - end - def read_fnm - ao=[] - ao=(FileTest.file?(@fnm)) \ - ? (File.open(@fnm,'r:utf-8'){ |f| ao=Marshal.load(f)}) - : SiSU_AO::Source.new(@opt).create_ao - end - def read_fnc - ao=[] - ao=(FileTest.file?(@fnc)) \ - ? (File.open(@fnc,'r:utf-8'){ |f| ao=Marshal.load(f)}) - : SiSU_AO::Source.new(@opt,@fnx,@process).create_ao - end - def read_idx_sst - m=[] - m=(FileTest.file?(@idx_sst)) \ - ? (File.open(@idx_sst,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - def read_idx_raw - m=[] - m=(FileTest.file?(@idx_raw)) \ - ? (File.open(@idx_raw,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - def read_idx_html - m=[] - m=(FileTest.file?(@idx_html)) \ - ? (File.open(@idx_html,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - def read_idx_xhtml - m=[] - m=(FileTest.file?(@idx_xhtml)) \ - ? (File.open(@idx_xhtml,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - def read_map_nametags - m=[] - m=(FileTest.file?(@map_nametags)) \ - ? (File.open(@map_nametags,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - def read_map_ocn_htmlseg - m=[] - m=(FileTest.file?(@map_ocn_htmlseg)) \ - ? (File.open(@map_ocn_htmlseg,'r:utf-8'){ |f| m=Marshal.load(f)}) - : nil - end - end - class Output - def initialize(fn,md,data) - @fn,@md,@data=fn,md,data - @cf=SiSU_Env::CreateFile.new(@fn) - @make=SiSU_Env::InfoFile.new(@fn) - @dir=SiSU_Env::InfoEnv.new(@fn) - end - def screen_dump(o) - if defined? o.of - print %{OF: #{o.of}; } - end - if defined? o.is - print %{IS: #{o.is.to_s}; } - end - if defined? o.ocn - print %{OCN: #{o.ocn}; } - end - if defined? o.node - print %{NODE: #{o.node}; } - end - if defined? o.parent - print %{Parent: #{o.parent}; } - end - if defined? o.obj and not o.obj.empty? - puts %{\n#{o.obj}; } - else "\n" - end - end - def screen_print(t_o) - if defined? t_o - print ' ' + t_o.to_s - end - end - def screen_output(data) - data.each do |o| - print o.class - screen_print(o.ocn) - screen_print(o.obj) - puts "\n" - end - end - def hard_output - if @md.opt.act[:maintenance][:set]==:on - filename_meta=@cf.metaverse.file_meta - @data.each {|o| filename_meta.puts o.inspect.sub(/:0x[0-9a-f]{8}\s/,': ')} #to make diffing easier - filename_txt=@cf.metaverse.file_txt - @data.each do |o| - if defined? o.ocn - filename_txt.puts case o.is - when :heading - "[#{o.is.to_s} #{o.lv}~#{o.name} [#{o.ocn}]] #{o.obj}" - else "[#{o.is.to_s} [#{o.ocn}]] #{o.obj}" - end - else - filename_txt.puts case o.is - when :meta - "[m~#{o.tag}] #{o.obj}" - else "[#{o.is.to_s}] #{o.obj}" - end - end - end - filename_debug=@cf.file_debug - @data.each do |o| - if defined? o.ocn - case o.is - when :heading - filename_debug.puts - "#{o.is.to_s} #{o.lv}~#{o.name} odv=#{o.odv} osp=#{o.osp} [#{o.ocn}] -->\n\t#{o.obj}" - end - end - end - else - hard="#{@dir.processing_path.ao}/#{@md.fns}.meta" - File.unlink(hard) if FileTest.file?(hard) - hard="#{@dir.processing_path.ao}/#{@md.fns}.txt" - File.unlink(hard) if FileTest.file?(hard) - hard="#{@dir.processing_path.ao}/#{@md.fns}.debug.txt" - File.unlink(hard) if FileTest.file?(hard) - end - end - def make_marshal_content - marshal_ao=@make.marshal.ao_content - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) - end - def make_marshal_metadata - marshal_ao=@make.marshal.ao_metadata - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} if @data.is_a?(Array) - end - def idx_html_hard_output - if @md.book_idx \ - and @md.opt.act[:maintenance][:set]==:on - filename_meta=@cf.file_meta_idx_html - if @data.is_a?(Array) - @data.each {|s| p s.inspect + "\n" unless s.is_a?(String)} - @data.each {|s| filename_meta.puts s.strip + "\n" unless s.strip.empty?} - end - else - hard_idx_html="#{@dir.processing_path.ao}/#{@md.fns}.idx.html" - File.unlink(hard_idx_html) if FileTest.file?(hard_idx_html) - end - end - def make_marshal_idx_sst_html_seg - marshal_ao=@make.marshal.ao_idx_sst_rel_html_seg - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Array) - end - def make_marshal_idx_sst_rel - marshal_ao=@make.marshal.ao_idx_sst_rel - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Array) - end - def make_marshal_idx_html - marshal_ao=@make.marshal.ao_idx_html - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Array) - end - def make_marshal_idx_xhtml - marshal_ao=@make.marshal.ao_idx_xhtml - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Array) - end - def make_marshal_map_nametags - marshal_ao=@make.marshal.ao_map_nametags - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Hash) - end - def make_marshal_map_name_ocn_htmlseg - marshal_ao=@make.marshal.ao_map_ocn_htmlseg - File.open(marshal_ao,'w'){|f| Marshal.dump(@data,f)} \ - if @data.is_a?(Hash) - end - end - class Make - def initialize(fn,md,data,fnx,process) - @fn,@md,@data,@fnx,@process=fn,md,data,fnx,process - @env=SiSU_Env::InfoEnv.new(@md.fns) - end - def reset - @@flag_vocab=0 - @@line_mode='' - end - def song - reset - data_txt=@data - data_txt= - SiSU_AO_Insertions::Insertions.new(@md,data_txt). # ao_expand_insertions.rb - expand_insertions? - data_txt= - SiSU_AO_MiscArrangeText::SI.new(@md,data_txt). # ao_misc_arrange.rb - prepare_text - data_obj, - metadata, - bibliography= - SiSU_AO_DocumentStructureExtract::Build.new(@md,data_txt). # ao_doc_str.rb - identify_parts - data_obj= - SiSU_AO_Syntax::Markup.new(@md,data_obj,bibliography).songsheet # ao_syntax.rb - data_obj, - endnote_array= - SiSU_AO_CharacterCheck::Check.new(data_obj). # ao_character_check.rb - character_check_and_oldstyle_endnote_array - data_obj= - SiSU_AO_Images::Images.new(@md,data_obj).images # ao_images.rb - data_obj, - tags_map, - ocn_html_seg_map= - SiSU_AO_Numbering::Numbering.new(@md,data_obj,@fnx,@process). # ao_numbering.rb - numbering_song - data_obj, - book_index_rel, - book_index_rel_html_seg, - html_idx, - xhtml_idx= - SiSU_AO_BookIndex::BookIndex.new(@md,data_obj,@env). # ao_idx.rb - indexing_song if @md.book_idx - data_obj= - SiSU_AO_Endnotes::Endnotes.new(@md,data_obj,endnote_array). # ao_endnotes.rb - endnotes - outputdata=data_obj - if (@md.opt.act[:ao][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_AO::Output.new(@fn,@md,outputdata).hard_output - SiSU_AO::Output.new(@fn,@md,outputdata).make_marshal_content - SiSU_AO::Output.new(@fn,@md,metadata).make_marshal_metadata - SiSU_AO::Output.new(@fn,@md,html_idx).idx_html_hard_output - SiSU_AO::Output.new(@fn,@md,book_index_rel_html_seg).make_marshal_idx_sst_html_seg - SiSU_AO::Output.new(@fn,@md,book_index_rel).make_marshal_idx_sst_rel - SiSU_AO::Output.new(@fn,@md,html_idx).make_marshal_idx_html - SiSU_AO::Output.new(@fn,@md,xhtml_idx).make_marshal_idx_xhtml - SiSU_AO::Output.new(@fn,@md,tags_map).make_marshal_map_nametags - SiSU_AO::Output.new(@fn,@md,ocn_html_seg_map).make_marshal_map_name_ocn_htmlseg - end - reset - outputdata - end - protected - end -end -__END__ diff --git a/lib/sisu/current/ao_character_check.rb b/lib/sisu/current/ao_character_check.rb deleted file mode 100644 index 9d91baa5..00000000 --- a/lib/sisu/current/ao_character_check.rb +++ /dev/null @@ -1,102 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_CharacterCheck - class Check - def initialize(data) - @data=data - @comment='%' - @endnote_array=[] - end - def character_check_and_oldstyle_endnote_array - data=@data - @endnote_array=[] - endnote_no=1 - @tuned_file=data.select do |dob| - unless dob.is ==:table - dob.obj=dob.obj.strip. - gsub(/^[{~}]\s*$/,''). - gsub(/~#\s*/,"#{Mx[:pa_non_object_no_heading]}"). - gsub(/-#\s*/,"#{Mx[:pa_non_object_dummy_heading]}"). - gsub(/(#{Mx[:en_a_o]})\s*\s+/,'\1 '). - gsub(/(~\{\s*)\s+/,'\1 '). - gsub(/ \/\//,"#{Mx[:br_line]}"). - gsub(/
/,"#{Mx[:br_line]}"). #needed by xml, xhtml etc. - gsub(/\t/,' '). - gsub(/\342\200\231/u,"'"). #if dob =~/’/ #Avoid #‘ ’ #“ ” - gsub(/\\copy(?:right)?\b/,'©'). - gsub(/\\trademark\b|\\tm\b/,'®') - dob.obj=dob.obj + "\n" - unless dob.is ==:code - case dob.obj - when /\^~/ #% Note must do this first (earlier loop) and then enter gathered data into ~^\d+ - sub_dob=dob.obj.dup - @endnote_array << sub_dob.gsub(/\n/,''). - gsub(/\^~\s+(.+)\s*/, - %{#{Mx[:en_a_o]}#{endnote_no} \\1 #{Mx[:en_a_c]}}). - strip - endnote_no+=1 - dob=nil if dob.obj =~/\^~ .+/ #watch, removes 'binary' endnote now in endnote array for later insertion - end - end - end - dob if dob.is_a?(Object) - end.flatten.compact - [@tuned_file,@endnote_array] - end - end -end -__END__ diff --git a/lib/sisu/current/ao_composite.rb b/lib/sisu/current/ao_composite.rb deleted file mode 100644 index 24683cba..00000000 --- a/lib/sisu/current/ao_composite.rb +++ /dev/null @@ -1,286 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** composite documents, assemble/build documents from other documents - or parts of marked up text - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Assemble - require_relative 'se' # se.rb - require_relative 'utils_composite' # utils_composite.rb - class RemoteImage - def initialize - @env=SiSU_Env::InfoEnv.new - end - def image(dir) - images=[] - images[0]=dir - images - end - def download_images(images_info) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) \ - unless FileTest.directory?(path) - download_from=images_info.shift - images_info.each do |i| - image="#{path}/#{i}" - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - output_path="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_external" - FileUtils::mkdir_p(output_path) \ - unless FileTest.directory?(output_path) - SiSU_Env::SystemCall.new("#{path}/*",output_path,'q').rsync - end - end - class Composite - include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - pwd=Dir.pwd - Dir.chdir(@opt.f_pth[:pth]) - if @opt.fno =~/\S+?\.ssm$/ - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Composite Document', - "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}", - ).grey_title_hi unless @opt.act[:quiet][:set]==:on - composite_and_imported_filenames_array(@opt.fno) # composite doc, .ssm, extract all related insert files, array of filenames test - assembled=loadfile(@opt.fno) - write(assembled) - end - Dir.chdir(pwd) - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns). - location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def insert?(para) - if para =~ /^<<\s+((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest - url($1.strip) - elsif para =~/^<<\s+(\S+?\.ss[it])$/ - loadfilename=$1.strip - insert_array=loadfile(loadfilename) - file=insertion(loadfilename,insert_array) - file[:prepared] - else para - end - end - def loadfile(loadfilename) - begin - if FileTest.file?(loadfilename) - insert_array=IO.readlines(loadfilename,'') - if loadfilename =~/\S+?\.ss[itm]$/ - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'loading:', - loadfilename, - ).txt_grey - end - tuned_file=if loadfilename =~/\S+?\.ss[im]$/ - insert_array.each.map do |para| - insert?(para) - end - elsif loadfilename =~/\S+?\.sst$/ - insert_array.each.map do |para| - para - end - end.flatten.compact - end - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def url(loadfilename) - if loadfilename =~ /((?:https?|file):\/\/\S+?\.ss[it])$/ # and NetTest - loadfilename=$1 - begin - require 'uri' - require 'open-uri' - require 'pp' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri, open-uri or pp NOT FOUND (LoadError)') - end - insert=open(loadfilename) - insert_array=insert.dup - insert.close - file=insertion(loadfilename,insert_array) - file[:prepared] - end - end - def write(assembled) - assembled_file=File.new("#{@env.processing_path.composite_file}/#{@opt.fnb}.ssm.sst",'w+') - assembled.each {|a| assembled_file << a } - assembled_file.close - end - def download_images(download_from,images_array) - path="#{@env.processing_path.processing}/external_document/image" - FileUtils::mkdir_p(path) unless FileTest.directory?(path) - images_array.each do |i| - image="#{path}/#{i}" - unless FileTest.exists?(image) - imagefile=File.new(image,'w+') - open("#{download_from}/#{i}") do |g| - imagefile << g.read - end - imagefile.close - end - end - end - def insertion(fni,insert_array) - file={ prepared: [], images: [] } - rgx_image=/(?:^|[^_\\])\{\s*(\S+?\.(?:png|jpg|gif))/ - file[:prepared] << "\n% |#{fni}|@|^|>>ok\n\n" - @code_flag=false - insert_array.each do |i| - @code_flag=if i =~/^code\{/ then true - elsif i =~/^\}code/ then false - else @code_flag - end - if not @code_flag \ - and i !~/^%+\s/ - i=i. - gsub(/^([123]|:?[ABCD])~\? /, - '% [conditional heading:] \1~ ') #off conditional heading (consider syntax) - if i =~/^@\S+?:/ - i=i.gsub(/\n/m,"\n% "). - gsub(/\n%\s+$/m,''). - gsub(/^@\S+?:/m,"\n% [imported header:] ") #off imported headers - end - end - file[:prepared] << i - if i !~/^%+\s/ \ - and i =~rgx_image - file[:images] << i.scan(rgx_image).uniq - end - end - file[:prepared] << "\n% end import" << "\n\n" - if file[:images].length > 0 - file[:images]=file[:images].flatten.uniq - file[:images].delete_if {|x| x =~/https?:\/\// } - end - file - end - end - class CompositeFileList - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new - end - def read - begin - @opt.fns=@opt.fns.gsub(/\.ssm\.sst$/,'.ssm') #FIX earlier, hub - fns_array=IO.readlines(@opt.fns,'') - insertions?(fns_array) - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def insertions?(fns_array) - tuned_file=[] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Composite Document', - @opt.fno - ).grey_title_hi unless @opt.act[:quiet][:set]==:on - @ssm=[@opt.fns] - fns_array.each do |para| - if para =~/^<<\s+(\S+?\.ss[it])$/ - loadfilename=$1.strip - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'loading:', - loadfilename, - ).txt_grey - end - tuned_file << if loadfilename =~ /(?:https?|file):\/\/\S+?\.ss[it]$/ - @ssm << loadfilename - elsif loadfilename =~ /\.ss[it]$/ \ - and FileTest.file?(loadfilename) - @ssm << loadfilename - else - STDERR.puts %{SKIPPED processing file: [#{@opt.lng}] "#{@opt.fns}" it requires an invalid or non-existent file: "#{loadfilename}"} - $process_document = :skip; break #remove this line to continue processing documents that have missing include files - para - end - end - end - @ssm - end - end -end -__END__ diff --git a/lib/sisu/current/ao_doc_objects.rb b/lib/sisu/current/ao_doc_objects.rb deleted file mode 100644 index a4b2fa8a..00000000 --- a/lib/sisu/current/ao_doc_objects.rb +++ /dev/null @@ -1,565 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document abstraction - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_DocumentStructure - class Extract - def extract(h,o) - h ? h : o - end - end - class ObjectMetadata - attr_accessor :is,:of,:tags,:obj,:digest - def initialize - @tags={} - @is=@tmp=@digest=nil - @of=:meta - end - def metadata(tags) - of = @of #Symbol, classification - group - is = :meta #Symbol, classification - specific type - tags = tags || ((defined? o.tags) ? o.tags : {}) #String, metadata type/tag - obj = nil - @of,@is,@tags,@obj=of,is,tags,obj - self - end - end - class ObjectMeta - attr_accessor :obj,:is,:of,:tag,:digest,:tmp - def initialize - @is=@obj=@tag=@digest=@digest=@tmp=nil - @of=:meta - end - def metadata(h,o=nil) - of = @of #Symbol, classification - group - is = :meta #Symbol, classification - specific type - tag = h[:tag] || ((defined? o.tag) ? o.tag : nil) #String, metadata type/tag - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - @of,@is,@tag,@obj,@digest,@tmp=of,is,tag,obj,digest,tmp - self - end - end - class ObjectHeading - attr_accessor :obj,:is,:tags,:of,:lv,:ln,:lc,:use_,:name,:idx,:ocn,:odv,:osp,:node,:parent,:ocn_,:note_,:autonum_,:digest,:tmp - def initialize - @of=:para - @is=@obj=@lv=@ln=@lc=@use_=@name=@idx=@size=@ocn=@odv=@osp=@node=@parent=@ocn_=@note_=@autonum_=@digest=@tmp=nil - @tags=[] - end - def heading_ln(lv) - case lv - when /A/ then 0 - when /B/ then 1 - when /C/ then 2 - when /D/ then 3 - when /1/ then 4 - when /2/ then 5 - when /3/ then 6 - when /4/ then 7 - when /5/ then 8 - when /6/ then 9 - end - end - def heading_lv(ln) - case ln.to_s - when /0/ then 'A' - when /1/ then 'B' - when /2/ then 'C' - when /3/ then 'D' - when /4/ then '1' - when /5/ then '2' - when /6/ then '3' - when /7/ then '4' - when /8/ then '5' - when /9/ then '6' - end - end - def heading(h,o=nil) - if not h[:ln] \ - and (h[:lv] and h[:lv]=~/[1-6A-D]/) - h[:ln]=heading_ln(h[:lv]) - elsif not h[:lv] \ - and (h[:ln] and h[:ln].to_s=~/[0-9]/) - h[:lv]=heading_lv(h[:ln]) - end - of = @of #Symbol, classification - group - is = :heading #Symbol, classification - specific type - name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - node = h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - lv = h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 - ln = h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 - lc = h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) - use_ = if lv \ - and lv == '1' - h[:use_] || ((defined? o.use_) ? o.use_ : :ok) - elsif not lv.empty? \ - and lv =~ /[A-D2-3]/ - :ok - else - h[:use_] || ((defined? o.use_) ? o.use_ : :ok) - end - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - autonum_ = if h[:autonum_].nil? - ((defined? o.autonum_) ? o.autonum_ : true) #Bool? auto-numbering if requested default on, false suppresses - else h[:autonum_] - end - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@lv,@ln,@lc,@name,@tags,@obj,@idx,@ocn,@odv,@osp,@node,@parent,@use_,@ocn_,@note_,@autonum_,@digest,@tmp= - of, is, lv, ln, lc, name, tags, obj, idx, ocn, odv, osp, node, parent, use_, ocn_, note_, autonum_, digest, tmp - self - end - def heading_insert(h,o=nil) - heading(h,o=nil) - @is = :heading_insert #String, classification - specific type - self - end - end - class ObjectPara - attr_accessor :obj,:is,:tags,:of,:name,:idx,:quote_,:bullet_,:indent,:hang,:ocn,:odv,:osp,:parent,:note_,:image_,:ocn_,:digest,:tmp - def initialize - @of=:para - @is=@obj=@name=@idx=@quote_=@bullet_=@indent=@hang=@size=@ocn=@odv=@osp=@parent=@note_=@image_=@ocn_=@digest=@tmp=nil - @tags=[] - end - def paragraph(h,o=nil) - of = @of #Symbol, classification - group - is = :para #Symbol, classification - specific type - name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent = h[:indent].to_s || ((defined? o.indent) ? o.indent.to_s : nil) #Integer, indent level - hang = h[:hang].to_s || ((defined? o.hang) ? o.hang.to_s : nil) #Integer, hanging indent level - bullet_ = h[:bullet_] || ((defined? o.bullet_) ? o.bullet_ : false) #Bool, bulleted? - quote_ = h[:quote_] || ((defined? o.quote_) ? o.quote_ : false) #Bool, quote (blockquote)? - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@quote_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= - of, is, name, tags, obj, indent, hang, bullet_, quote_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp - self - end - def docinfo(h,o=nil) - of = @of #String, classification - group - is = :docinfo #String, classification - specific type - name = h[:name] || ((defined? o.name) ? o.name : nil) #String, named object? - tags = h[:tags] || ((defined? o.tags) ? o.tags : nil) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = nil #String, book index provided? - ocn = nil #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - indent = nil #Integer, indent level - hang = nil #Integer, indent level - bullet_ = false #Bool, bulleted? - note_ = false #Bool, endnotes/footnotes? (processing optimization) - image_ = h[:image_] || ((defined? o.image_) ? o.image_ : false) #Bool, images? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@name,@tags,@obj,@indent,@hang,@bullet_,@idx,@ocn,@odv,@osp,@parent,@image_,@note_,@ocn_,@digest,@tmp= - of, is, name, tags, obj, indent, hang, bullet_, idx, ocn, odv, osp, parent, image_, note_, ocn_, digest, tmp - self - end - end - class ObjectBlockTxt - attr_accessor :obj,:is,:of,:tags,:lngsyn,:idx,:ocn,:odv,:osp,:parent,:note_,:number_,:ocn_,:digest,:tmp - def initialize - @of=:block - @is=@obj=@lngsyn=@idx=@ocn=@odv=@osp=@parent=@note_=@number_=@ocn_=@digest=@tmp=nil - @tags=[] - end - def code(h,o=nil) - of = @of #Symbol, classification - group #alt 'code' - is = :code #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - lngsyn = h[:lngsyn] || ((defined? o.lngsyn) ? o.lngsyn : :txt) #symbol, code lngsyn - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - number_ = h[:number_] || ((defined? o.number_) ? o.number_ : false) #Bool, numbered or not? - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@lngsyn,@idx,@ocn,@odv,@osp,@parent,@number_,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, lngsyn, idx, ocn, odv, osp, parent, number_, note_, ocn_, num, digest, tmp - self - end - def box(h,o=nil) - of = @of #Symbol, classification - group - is = :box #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp - self - end - def block(h,o=nil) - of = @of #Symbol, classification - group - is = :block #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp - self - end - def group(h,o=nil) - of = @of #Symbol, classification - group - is = :group #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp - self - end - def alt(h,o=nil) #see block - of = @of #Symbol, classification - group - is = :alt #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp - self - end - def verse(h,o=nil) #part of poem decide how you deal with this - of = @of #Symbol, classification - group - is = :verse #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, obj, idx, ocn, odv, osp, parent, note_, ocn_, num, digest, tmp - @h=nil - self - end - end - class ObjectTable - attr_accessor :obj,:is,:of,:lv,:tags,:name,:idx,:indent,:hang,:size,:ocn,:num,:head_,:cols,:widths,:odv,:osp,:parent,:note_,:ocn_,:digest,:tmp - def initialize - @of=:block - @is=@obj=@lv=@name=@idx=@indent=@hang=@size=@ocn,@num,@head_,@cols,@widths=@odv=@osp=@parent=@note_=@ocn_=@num=@digest=@tmp=nil - @tags=[] - end - def table(h,o=nil) - of = @of #Symbol, classification - group - is = :table #Symbol, classification - specific type - tags = h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - cols = h[:cols] || ((defined? o.cols) ? o.cols : nil) - widths = h[:widths] || ((defined? o.widths) ? o.widths : nil) - obj = h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - idx = h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn = h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv = h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp = h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent = h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - head_ = h[:head_] || ((defined? o.head_) ? o.head_ : false) - note_ = h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_ = if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - num = h[:num] || ((defined? o.num) ? o.num : nil) - digest = h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp = h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@cols,@widths,@obj,@idx,@ocn,@odv,@osp,@parent,@head_,@note_,@ocn_,@num,@digest,@tmp= - of, is, tags, cols, widths, obj, idx, ocn, odv, osp, parent, head_, note_, ocn_, num, digest, tmp - self - end - end - class ObjectImage - attr_accessor :obj,:is,:of,:lv,:idx,:size,:ocn,:parent,:note_,:ocn_,:digest,:tmp - def initialize - @of=:image - @is=@obj=@lv=@idx=@size=@ocn=@parent=@note_=@ocn_=@tmp=@digest=nil - @tags=[] - end - def image(h,o=nil) #not yet used, and what of a paragraph containing several images, consider - of= @of #Symbol, classification - group - is= :image #Symbol, classification - specific type - tags= h[:tags] || ((defined? o.tags) ? o.tags : []) #Array, associated object tags, names if any - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - size= h[:size] || ((defined? o.size) ? o.size : nil) - idx= h[:idx] || ((defined? o.idx) ? o.idx : nil) #String, book index provided? - ocn= h[:ocn] || ((defined? o.ocn) ? o.ocn : nil) #Integer, sequential on substantive-content objects - odv= h[:odv] || ((defined? o.odv) ? o.odv : nil) - osp= h[:osp] || ((defined? o.osp) ? o.osp : nil) - parent= h[:parent] || ((defined? o.parent) ? o.parent : nil) #[Node parent] - note_= h[:note_] || ((defined? o.note_) ? o.note_ : false) #Bool, endnotes/footnotes? (processing optimization) - ocn_=if h[:ocn_].nil? - ((defined? o.ocn_) ? o.ocn_ : true) #Bool? no ocn, non-substantive content, do not include in toc #consider - else h[:ocn_] - end - digest= h[:digest] || ((defined? o.digest) ? o.digest : nil) #hash digests, sha512, sha256 or md5 - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@tags,@obj,@size,@idx,@ocn,@odv,@osp,@parent,@note_,@ocn_,@digest,@tmp=of,is,tags,obj,size,idx,ocn,odv,osp,parent,note_,ocn_,digest,tmp - self - end - end - class ObjectStructure - attr_accessor :obj,:tag,:node,:lv,:ln,:lc,:status,:is,:of,:tmp - def initialize - @of=:structure - @is=@obj=@node=@lv=@ln=@lc=@status=@tmp=nil - end - def xml_dom(h,o=nil) - of= @of #Symbol, classification - group - is= :xml_dom #Symbol, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : '') #String, text content - lv= h[:lv] || ((defined? o.lv) ? o.lv : nil) #Alpha-numeric, document structure as used in markup, A-D then 1-6 - ln= h[:ln] || ((defined? o.ln) ? o.ln : nil) #Integer, document structure level, for convenience in processing 1-9 - lc= h[:lc] || ((defined? o.lc) ? o.lc : nil) #Integer, document structure collapsed level, convenience (collapse sisu's dual level document structure for markup with simple linear structure) - node= h[:node] || ((defined? o.node) ? o.node : nil) #[Node relationship doc structure info] - status= h[:status] || ((defined? o.status) ? o.status : nil) #tag status Symbol :open or :close - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@obj,@status,@node,@lv,@ln,@lc,@tmp=of,is,obj,status,node,lv,ln,lc,tmp - self - end - end - class ObjectFlag - attr_accessor :obj,:is,:of,:flag,:act,:selections,:tmp - def initialize - @of=:flag - @is=@obj=@flag=@act=@selections=@tmp=nil - end - def flag(h,o=nil) - of= @of #Symbol, classification - group - is= :flag #Symbol, classification - specific type - obj= nil #String, text content - flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content - act= h[:act] || ((defined? o.act) ? o.act : nil) #String, text content - selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content - tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of, @is,@obj,@flag,@act,@selections,@tmp= - of,is, obj, flag, act, selections, tmp - self - end - def flag_ocn(h,o=nil) - of= @of #Symbol, classification - group - is= :flag_ocn #Symbol, classification - specific type - obj= nil #String, text content - flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #String, text content - act= h[:act] || ((defined? o.act) ? o.act : nil) #String, text content - selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content - tmp= h[:flag] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of, @is,@obj,@flag,@act,@selections,@tmp= - of,is, obj, flag, act, selections,tmp - self - end - def flag_lng(h,o=nil) - of= @of #Symbol, classification - group - is= :flag_lng - obj= nil #String, text content - flag= h[:flag] || ((defined? o.flag) ? o.flag : nil) #Symbol, :lng_on or :lng_off - act= h[:act] || ((defined? o.act) ? o.act : nil) #Symbol, language set to :en etc. - selections= h[:selections] || ((defined? o.selections) ? o.selections : nil) #String, text content - tmp= h[:act] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of, @is,@obj,@flag,@act,@selections,@tmp= - of,is, obj, flag, act, selections,tmp - self - end - end - class ObjectLayout - attr_accessor :obj,:sym,:attr,:is,:is_for,:of,:from,:tmp,:num - def initialize - @of=:layout - @is=@is_for=@obj=@from=@tmp=@num=nil - end - def break(h,f=nil) #decide how to deal with - of= @of #Symbol, classification - group - is= :break #Symbol, classification - specific type - obj= h[:obj] #String, text content - from= f - tmp= h[:tmp] #available for processing, empty after use - @of,@is,@obj,@from,@tmp=of,is,obj,from,tmp - self - end - def insert(h,o=nil) #decide how to deal with, could mimic paragraph? - of= @of #Symbol, classification - group - is= :insert #Symbol, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@obj,@tmp=of,is,obj,tmp - self - end - def open_close(h,o=nil) #useful for poem & quote - of= @of #Symbol, classification - group - is= :open_close_tags #Symbol, classification - specific type - is_for= h[:is_for] || ((defined? o.is_for) ? o.is_for : nil) #String, text content - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - sym= h[:sym] || ((defined? o.sym) ? o.sym : nil) #Symbol tag_open, tag_close - attr= h[:attr] || ((defined? o.attr) ? o.attr : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - num= h[:num] || ((defined? o.num) ? o.num : nil) - @of,@is,@is_for,@obj,@sym,@attr,@tmp,@num= - of, is, is_for, obj, sym, attr, tmp, num - self - end - end - class ObjectComment - attr_accessor :obj,:is,:of,:tmp - def initialize - @of=:comment - @is=@obj=@tmp=nil - end - def comment(h,o=nil) - of= @of #Symbol, classification - group - is= :comment #Symbol, classification - specific type - obj= h[:obj] || ((defined? o.obj) ? o.obj : nil) #String, text content - tmp= h[:tmp] || ((defined? o.tmp) ? o.tmp : nil) #available for processing, empty after use - @of,@is,@obj,@tmp=of,is,obj,tmp - self - end - end -end -__END__ -# ~# |-# no paragraph number # -# not included in toc diff --git a/lib/sisu/current/ao_doc_str.rb b/lib/sisu/current/ao_doc_str.rb deleted file mode 100644 index fba1724e..00000000 --- a/lib/sisu/current/ao_doc_str.rb +++ /dev/null @@ -1,2269 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document abstraction - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_DocumentStructureExtract - require_relative 'ao_persist' # ao_persist.rb - class Instantiate < SiSU_Param::Parameters::Instructions - def initialize - @@counter=@@column=@@columns=0 - @@line_mode='' - end - end - class Build - def initialize(md,data) - @md,@data=md,data - SiSU_AO_DocumentStructureExtract::Instantiate.new - @pb=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) - @pbn=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) - @pbl=SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) - @per=SiSU_AO_Persist::PersistDocStructExt.new - end - def ln_get(lv) - case lv - when /A/ then 0 - when /B/ then 1 - when /C/ then 2 - when /D/ then 3 - when /1/ then 4 - when /2/ then 5 - when /3/ then 6 - when /4/ then 7 - when /5/ then 8 - when /6/ then 9 - end - end - def image_test(str) - str=~/\{\s*\S+?\.png.+?\}https?:\/\/\S+/ \ - ? true - : false - end - def bullet_test(str) - (str=~/\*/) \ - ? true - : false - end - def quotes? - @per.quote==:open \ - ? true - : false - end - def hang_and_indent_test(str) - hang_indent=if str=~/^_([1-9])[^_]/ - [$1,$1] - elsif str=~/^__([1-9])/ - [0,$1] - elsif str=~/^_([0-9])_([0-9])/ - [$1,$2] - else - [0,0] - end - hang,indent=hang_indent[0],hang_indent[1] - [hang,indent] - end - def hang_and_indent_def_test(str1,str2) - hang_indent=if str1=~/^_([1-9])[^_]/ - [$1,$1] - elsif str1=~/^__([1-9])/ - [0,$1] - elsif str1=~/^_([0-9])_([0-9])/ - [$1,$2] - else - [0,0] - end - obj=if str2 =~/^(.+?)\s+\\\\(?:\s+|\n)/ - str2.gsub(/^(.+?)(\s+\\\\(?:\s+|\n))/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2") - else - str2.gsub(/^(.+?)\n/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\n") - end - hang,indent=hang_indent[0],hang_indent[1] - [ - hang, - indent, - obj, - ] - end - def endnote_test?(str) - (str=~/~\{.+?\}~|~\[.+?\]~/) \ - ? true - : false - end - def extract_tags(str,nametag=nil) - tags=[] - if str.nil? - else - if str =~/(?:^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/ - str=str.gsub(/(^|[ ])\*~([a-z0-9._-]+)(?=[ #{Mx[:br_nl]}]|$)/i, - "\\1#{Mx[:tag_o]}\\2#{Mx[:tag_c]}"). - gsub(/ [ ]+/i,' ') - tags=str.scan(/#{Mx[:tag_o]}(\S+?)#{Mx[:tag_c]}/).flatten.uniq - str=str.gsub(/[ ]?#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}[ ]?/,' ') #may be issues with spaces would leave one, but "code" blocks? - end - tags=nametag ? (tags << nametag) : tags - tags.each do |t| - t.gsub!(/[^a-z0-9._-]/,'') - end - end - [ - str, - tags, - ] - end - def rgx_idx_ocn_seg - @rgx_idx_ocn_seg=/(.+?)\s*[+](\d+)/ - end - def construct_idx_array_and_hash(idxraw) - idx_array_raw=idxraw.scan(/[^;]+/) - idx_hash,idx_array,idx_lst={},[],[] - idx_array_raw.each do |idx| - idx=idx.strip - idx_lst=case idx - when /\S+?\s*:/ - idx_couplet_tmp=[] - idx_couplet=idx.scan(/\s*[^:]+\s*/) - if idx_couplet[1] =~/[|]/ - idx_couplet_tmp << - idx_couplet[0] << - idx_couplet[1].scan(/\s*[^|]+\s*/) - else - idx_couplet_tmp << - idx_couplet[0] << - [idx_couplet[1]] - end - idx_couplet=idx_couplet_tmp - else [idx] - end - term_nodes=[] - idx_lst.each do |term_node| - case term_node - when String - term_node= - term_node[0].chr.capitalize + - term_node[1,term_node.length] - term_node=(term_node =~/.+?[+]\d+/) \ - ? term_node - : (term_node + '+0') - term_nodes << term_node - use,plus=rgx_idx_ocn_seg.match(term_node)[1,2] - @use=use.strip - unless idx_hash[@use] \ - and defined? idx_hash[@use] - idx_hash[@use]= - { sub: [], plus: plus } - end - when Array - subterm_nodes=[] - term_node.each do |subterm_node| - subterm_node=(subterm_node =~/.+?[+]\d+/) \ - ? subterm_node - : (subterm_node + '+0') - subterm_nodes << subterm_node - sub,sub_plus=rgx_idx_ocn_seg.match(subterm_node)[1,2] - unless idx_hash[@use] \ - and defined? idx_hash[@use] - idx_hash[@use]= - { sub: [], plus: 0 } - end - idx_hash[@use][:sub] << - { sub.strip => { plus: sub_plus } } - end - term_nodes << subterm_nodes - end - end - idx_array << term_nodes - end - { - hash: idx_hash, - array: idx_array, - } - end - def extract_structure_loop(data,tuned_file) - data.each do |t_o| - if t_o =~/^--([+~-])[#]$/ - h=case $1 - when /[+]/ - @per.ocn=:on - { - flag: :ocn_on, - } - when /[~]/ - @per.ocn=:ocn_off_headings_keep - { - flag: :ocn_off, - mod: :headings_keep, - } - when /[-]/ #of particular relevance with level 1~ which is required to precede substantive text & used e.g. in html segmented text - @per.ocn=:ocn_off_headings_dummy_lev1 - { - flag: :ocn_off, - mod: :headings_exclude, - } - else - @per.ocn=:on - { - flag: :ocn_on, - } - end - t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_ocn(h) - next - end - if t_o =~/^:[~](#{SiSU_is.language_list_regex?}|-)$/ # work with for identifying language of objects - lng=$1 - h=case lng - when /(?:#{SiSU_is.language_list_regex?})/ - @per.lng=:on - @per.lng_is=lng.to_sym - { - flag: :lng_on, - act: lng.to_sym, - } - else # ^:~- - if @per.lng==:on - @per.lng=:off - @per.lng_is=:doc_default - { - flag: :lng_off, - act: :doc_default, - } - end - end - t_o=SiSU_AO_DocumentStructure::ObjectFlag.new.flag_lng(h) - next - end - t_o=t_o.gsub(/(?:\n\s*\n)+/m,"\n") if @per.code==:off - unless t_o =~/^(?:@\S+?:|%+)\s/ # extract book index for paragraph if any - idx=if t_o=~/^=\{\s*(.+)\s*\}\s*$\Z/m - m=$1 - m=m.split(/[ ]*\n/).join(' '). - gsub(/\s+([|:;])\s+/,'\1'). - gsub(/\s+([+]\d+)\s+/,'\1') - t_o=t_o.gsub(/\n=\{.+?\}\s*$/m,'') - idx_array_and_hash=construct_idx_array_and_hash(m) - idx_array_and_hash[:hash] - else nil - end - end - if t_o !~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)\{|^\}(?:code|poem|alt|group|block)|^(?:table\{|\{table)[ ~]/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$|^`:quote_(?:open|close)`/ \ - and @per.code==:off \ - and @per.poem==:off \ - and @per.group==:off \ - and @per.block==:off \ - and @per.alt==:off \ - and @per.box==:off \ - and @per.table==:off - t_o=case t_o - when /^#{Mx[:meta_o]}\S+?#{Mx[:meta_c]}/ #metadata, header - if t_o=~/^#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*(.+)/m - tag,obj=$1,$2 - @metadata[tag]=obj - end - t_o=nil - when /^%+\s/ #comment - t_o=if t_o=~/^%+\s+(.+)/ - h={ obj: $1 } - SiSU_AO_DocumentStructure::ObjectComment.new.comment(h) - else nil - end - when /^:?([A-D1-6])\~/ #heading / lv - lv=$1 - ln=ln_get(lv) - t_o=if t_o=~/^:?[A-D1-6]\~\s+(.+)/m - obj=$1 - note=endnote_test?(obj) - obj,tags=extract_tags(obj) - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - and t_o =~/^1\~\S*\s+/m - obj << ' -#' - elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - obj << ' ~#' - end - end - end - h={ - lv: lv, - ln: ln, - obj: obj, - idx: idx, - tags: tags, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - elsif t_o=~/^:?[A-D1-6]\~(\S+?)-\s+(.+)/m - name,obj=$1,$2 - note=endnote_test?(obj) - obj,tags=extract_tags(obj) - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - and t_o =~/^1\~\S*\s+/m - obj << ' -#' - elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - obj << ' ~#' - end - end - end - h={ - lv: lv, - name: name, - obj: obj, - idx: idx, - autonum_: false, - tags: tags, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - elsif t_o=~/^:?[A-D1-6]\~(\S+)\s+(.+)/m - name,obj=$1,$2 - note=endnote_test?(obj) - obj,tags=extract_tags(obj,name) - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - and t_o =~/^1\~\S*\s+/m - obj << ' -#' - elsif @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - obj << ' ~#' - end - end - end - h={ - lv: lv, - name: name, - obj: obj, - idx: idx, - tags: tags, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - else nil - end - when /^_(?:[1-9]!?|[1-9]?\*)\s+/ #indented and/or bullet paragraph - t_o=if t_o=~/^(_(?:[1-9]?\*|[1-9]!?)\s+)(.+)/m - tst,obj=$1,$2 - if t_o=~/^_[1-9]!\s+.+/m - hang,indent,obj=hang_and_indent_def_test(tst,obj) - else - hang,indent=hang_and_indent_test(tst) - end - bullet=bullet_test(tst) - image=image_test(obj) - note=endnote_test?(obj) - obj,tags=extract_tags(obj) - unless obj=~/\A\s*\Z/m - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - obj << ' ~#' - end - end - h={ - bullet_: bullet, - hang: hang, - indent: indent, - obj: obj, - idx: idx, - note_: note, - image_: image, - tags: tags, - quote: quotes?, - } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - else nil - end - when /^_[0-9]?_[0-9]!?\s+/ #hanging indent paragraph - t_o=if t_o=~/^(_[0-9]?_[0-9]!?\s+)(.+)/m - tst,obj=$1,$2 - if t_o=~/^_[0-9]?_[0-9]!\s+.+/m - hang,indent,obj=hang_and_indent_def_test(tst,obj) - else - hang,indent=hang_and_indent_test(tst) - end - image=image_test(obj) - note=endnote_test?(obj) - obj,tags=extract_tags(obj) - unless obj=~/\A\s*\Z/m - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - obj << ' ~#' - end - end - h={ - hang: hang, - indent: indent, - obj: obj, - idx: idx, - note_: note, - image_: image, - tags: tags, - quote: quotes?, - } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - else nil - end - when /^<(?:br)?:(?:pa?r|o(?:bj|---)?)>\s*$/ #[br:par] #[br:obj] - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_obj]) - when /^(?:-\\\\-|<:pb>)\s*$/ #[br:pg] - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page],:markup) - when /^(?:=\\\\=|<:pn>)\s*$/ #[br:pgn] - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new],:markup) - when /^-\.\.-\s*$/ #[br:pgl] - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line],:markup) - else #paragraph - image=image_test(t_o) - note=endnote_test?(t_o) - obj,tags=extract_tags(t_o) - if @per.ocn==:ocn_off_headings_dummy_lev1 \ - or @per.ocn==:ocn_off_headings_keep - unless obj =~ /[~-][#]\s*$/ - obj << ' ~#' - end - end - unless obj=~/\A\s*\Z/m - h={ - bullet_: false, - indent: 0, - hang: 0, - obj: obj, - idx: idx, - note_: note, - image_: image, - tags: tags, - quote: quotes?, - } - t_o=SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - t_o=SiSU_AO_DocumentStructureExtract::Structure.new(@md).structure_markup(t_o) #must happen earlier, node info etc. require - end - elsif @per.code==:off - if t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|```[ ]+code(?:\.[a-z][0-9a-z_]+)?)/ - @per.code=case t_o - when /^code(?:\.[a-z][0-9a-z_]+)?\{/ then :curls - when /^```[ ]+code/ then :tics - else @per.code #error - end - @per.lngsyn=if t_o =~/^(?:code\.[a-z][0-9a-z_]+\{|```[ ]+code\.[a-z_]+)/ - case t_o - when /^code\.([a-z][0-9a-z_]+)\{/ - :"#{$1}" - when /^```[ ]+code\.([a-z][0-9a-z_]+)/ - :"#{$1}" - else :txt - end - else :txt - end - @@counter=1 - @codeblock_numbered= - (t_o =~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{#|```[ ]+code(?:\.[a-z][0-9a-z_]+)?\s[#])/) \ - ? true - : false - @num_id[:code_block] +=1 - h={ - is_for: :code, - obj: '', - sym: :code_block_open, - num: @num_id[:code_block], - syntax: @per.lngsyn, - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif t_o =~/^(?:poem\{|```[ ]+poem)/ - @per.poem=case t_o - when /^poem\{/ then :curls - when /^```[ ]+poem/ then :tics - else @per.poem #error - end - @num_id[:poem] +=1 - h={ - is_for: :poem, - obj: '', - sym: :poem_open, - num: @num_id[:poem], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << t_o - elsif t_o =~/^(?:box(?:\.[a-z_]+)?\{|```[ ]+box(?:\.[a-z_]+)?)/ - @per.box=case t_o - when /^box\{/ then :curls - when /^```[ ]+box/ then :tics - else @per.box #error - end - @num_id[:box] +=1 - h={ - is_for: :box, - obj: '', - sym: :box_open, - num: @num_id[:box], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << t_o - elsif t_o =~/^(?:group\{|```[ ]+group)/ - @per.group=case t_o - when /^group\{/ then :curls - when /^```[ ]+group/ then :tics - else @per.group #error - end - @num_id[:group] +=1 - h={ - is_for: :group, - obj: '', - sym: :group_open, - num: @num_id[:group], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << t_o - elsif t_o =~/^(?:block\{|```[ ]+block)/ - @per.block=case t_o - when /^block\{/ then :curls - when /^```[ ]+block/ then :tics - else @per.block #error - end - @num_id[:block] +=1 - h={ - is_for: :block, - obj: '', - sym: :block_open, - num: @num_id[:block], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << t_o - elsif t_o =~/^(?:alt\{|```[ ]+alt)/ - @per.alt=case t_o - when /^alt\{/ then :curls - when /^```[ ]+alt/ then :tics - else @per.alt #error - end - @num_id[:alt] +=1 - h={ - is_for: :alt, - obj: '', - sym: :alt_open, - num: @num_id[:alt], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << t_o - elsif t_o =~/^`:quote_open`/ - @per.quote=:open - @num_id[:quote] +=1 - h={ - is_for: :quote, - obj: '', - sym: :quote_open, - num: @num_id[:quote], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - #tuned_file << t_o #% find second source, entered twice, should be once so closed off here - elsif t_o =~/^(?:table\{|```[ ]+table|\{table)[ ~]/ - @num_id[:table] +=1 - h={ - is_for: :table, - obj: '', - sym: :table_open, - num: @num_id[:table], - } - ins_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - tuned_file << ins_o - if t_o=~/^table\{(?:~h)?\s+/ - @per.table=:curls - @rows='' - case t_o - when /table\{~h\s+c(\d+);\s+(.+)/ - cols=$1 - col=$2.scan(/\d+/) - heading=true - when /table\{\s+c(\d+);\s+(.+)/ - cols=$1 - col=$2.scan(/\d+/) - heading=false - end - @h={ - head_: heading, - cols: cols, - widths: col, - idx: idx, - } - elsif t_o=~/^```[ ]+table(?:~h)?\s+c\d+/ - @per.table=:tics - @rows='' - case t_o - when /^```[ ]+table~h\s+c(\d+);\s+(.+)/ - cols=$1 - col=$2.scan(/\d+/) - heading=true - when /^```[ ]+table\s+c(\d+);\s+(.+)/ - cols=$1 - col=$2.scan(/\d+/) - heading=false - end - @h={ - head_: heading, - cols: cols, - widths: col, - idx: idx, - } - elsif t_o=~/^\{table(?:~h)?(?:\s+\d+;?)?\}\n.+\Z/m - m1,m2,hd=nil,nil,nil - tbl=/^\{table(?:~h)?(?:\s+\d+;?)?\}\n(.+)\Z/m.match(t_o)[1] - hd=((t_o =~/^\{table~h/) ? true : false) - tbl,tags=extract_tags(tbl) - rws=tbl.split(/\n/) - rows='' - cols=nil - rws.each do |r| - cols=(cols ? cols : (r.scan('|').length) +1) - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") - rows += r + Mx[:tc_c] - end - col=[] - if t_o =~/^\{table(?:~h)?\s+(\d+);?\}/ #width of col 1 given as %, usually when wider than rest that are even - c1=$1.to_i - width=(100 - c1)/(cols - 1) - col=[ c1 ] - (cols - 1).times { col << width } - else #all columns of equal width - width=100.00/cols - cols.times { col << width } - end - h={ - head_: hd, - cols: cols, - widths: col, - obj: rows, - idx: idx, - tags: tags, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ - unless h.nil? - tuned_file << t_o - h={ - is_for: :table, - obj: '', - sym: :table_close, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - t_o - elsif t_o=~/^```[ ]+table(?:~h)?\s+/ - m1,m2,hd=nil,nil,nil - h=case t_o - when /^```[ ]+table~h\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one - m1,tbl,hd=$1,$2,true - when /^```[ ]+table\s+(.+?)\n(.+)\Z/m #two table representations should be consolidated as one - m1,tbl,hd=$1,$2,false - else nil - end - tbl,tags=extract_tags(tbl) - col=m1.scan(/\d+/) - rws=tbl.split(/\n/) - rows='' - rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") - rows += r + Mx[:tc_c] - end - h={ - head_: hd, - cols: col.length, - widths: col, - obj: rows, - idx: idx, - tags: tags, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ - unless h.nil? - tuned_file << t_o - h={ - is_for: :table, - obj: '', - sym: :table_close, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - t_o - elsif t_o=~/^\{table(?:~h)?\s+/ - m1,m2,hd=nil,nil,nil - h=case t_o - when /\{table~h\s+(.+?)\}\n(.+)\Z/m #two table representations should be consolidated as one - m1,tbl,hd=$1,$2,true - when /\{table\s+(.+?)\}\n(.+)\Z/m #two table representations should be consolidated as one - m1,tbl,hd=$1,$2,false - else nil - end - tbl,tags=extract_tags(tbl) - col=m1.scan(/\d+/) - rws=tbl.split(/\n/) - rows='' - rws.each do |r| - r=r.gsub(/\s*\|\s*/m,"#{Mx[:tc_p]}") #r.gsub!(/\|/m,"#{Mx[:tc_p]}") - rows += r + Mx[:tc_c] - end - h={ - head_: hd, - cols: col.length, - widths: col, - obj: rows, - idx: idx, - tags: tags, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(h) \ - unless h.nil? - tuned_file << t_o - h={ - is_for: :table, - obj: '', - sym: :table_close, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - t_o - end - end - t_o - end - if @per.table==:curls or @per.table==:tics - if (@per.table==:curls \ - and t_o =~/^\}table/) \ - or (@per.table==:tics \ - and t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.table=:off - headings,columns,widths,idx=@h[:head_],@h[:cols],@h[:widths],@h[:idx] - @h={ - head_: headings, - cols: columns, - widths: widths, - idx: idx, - obj: @rows, - } - t_o=SiSU_AO_DocumentStructure::ObjectTable.new.table(@h) - tuned_file << t_o - @h,@rows=nil,'' - h={ - is_for: :table, - obj: '', - sym: :table_close, - num: @num_id[:table], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - t_o - else - if t_o.is_a?(String) \ - and t_o !~/^(?:table\{|```[ ]+table)/ - t_o=t_o.gsub(/^\n+/m,''). - gsub(/\n+/m,"#{Mx[:tc_p]}") - @rows += t_o + Mx[:tc_c] - end - t_o=nil - end - end - if @per.code==:curls \ - or @per.code==:tics - if (@per.code==:curls \ - && t_o =~/^\}code/) \ - or (@per.code==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/m) - @per.code=:off - if @tuned_code[-1] - @tuned_code[-1]. - gsub!(/\s*(?:#{Mx[:br_line]}|#{Mx[:br_nl]})\s*\Z/m,'') - end - obj=@tuned_code.join("\n") - tags=[] - h={ - obj: obj, - idx: idx, - syntax: @per.lngsyn, - tags: tags, - num: @num_id[:code_block], - number_: @codeblock_numbered, - } - @per.lngsyn=:txt - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.code(h) - @tuned_code=[] - tuned_file << t_o - h={ - is_for: :code, - obj: '', - sym: :code_close, - num: @num_id[:code_block], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - end - if (@per.code==:curls \ - || @per.code==:tics) \ - and t_o.is_a?(String) - sub_array=t_o.dup + "#{Mx[:br_nl]}" - @line_mode=[] - sub_array.scan(/.+/) {|w| @line_mode << w if w =~/[\S]+/} - t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(:code).join - @tuned_code << t_o - t_o=nil - end - elsif (@per.poem==:curls \ - || @per.poem==:tics) \ - or (@per.box==:curls \ - || @per.box==:tics) \ - or (@per.group==:curls \ - || @per.group==:tics) \ - or (@per.block==:curls \ - || @per.block==:tics) \ - or (@per.alt==:curls \ - || @per.alt==:tics) \ - or (@per.quote==:open \ - && t_o =~/`:quote_close`/m) #not - if (@per.poem==:curls \ - && t_o =~/^\}poem$/m) \ - or (@per.poem==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.poem=:off - h={ - is_for: :poem, - obj: '', - idx: idx, - sym: :poem_close, - num: @num_id[:poem], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif (@per.box==:curls \ - && t_o =~/^\}box/) \ - or (@per.box==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.box=:off - obj,tags=extract_tags(@tuned_block.join("\n")) - h={ - obj: obj, - idx: idx, - tags: tags, - num: @num_id[:box], - } - @tuned_block=[] - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.box(h) - tuned_file << t_o - h={ - is_for: :box, - obj: '', - idx: idx, - sym: :box_close, - num: @num_id[:box], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif (@per.group==:curls \ - && t_o =~/^\}group/) \ - or (@per.group==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.group=:off - obj,tags=extract_tags(@tuned_block.join("\n")) - h={ - obj: obj, - idx: idx, - tags: tags, - num: @num_id[:group], - } - @tuned_block=[] - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.group(h) - tuned_file << t_o - h={ - is_for: :group, - obj: '', - sym: :group_close, - num: @num_id[:group], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif (@per.block==:curls \ - && t_o =~/^\}block/) \ - or (@per.block==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.block=:off - obj,tags=extract_tags(@tuned_block.join("\n")) - h={ - obj: obj, - idx: idx, - tags: tags, - num: @num_id[:block], - } - @tuned_block=[] - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.block(h) - tuned_file << t_o - h={ - is_for: :block, - obj: '', - sym: :block_close, - num: @num_id[:block], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif (@per.alt==:curls \ - && t_o =~/^\}alt/) \ - or (@per.alt==:tics \ - && t_o =~/^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/) - @per.alt=:off - obj,tags=extract_tags(@tuned_block.join("\n")) - h={ - obj: obj, - idx: idx, - tags: tags, - num: @num_id[:alt], - } - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.alt(h) - @tuned_block=[] - tuned_file << t_o - h={ - is_for: :alt, - obj: '', - sym: :alt_close, - num: @num_id[:alt], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif @per.quote==:open \ - and t_o =~/`:quote_close`/m - @per.quote=:off - h={ - is_for: :quote, - idx: idx, - obj: '', - sym: :quote_close, - num: @num_id[:quote], - } - t_o=SiSU_AO_DocumentStructure::ObjectLayout.new.open_close(h) - elsif @per.quote==:open - t_o,tags=extract_tags(t_o) - h={ - indent: 1, - obj: t_o, - idx: idx, - note_: note, - image_: image, - tags: tags, - quote: quotes?, - } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - if (@per.poem==:curls \ - || @per.poem==:tics) \ - or (@per.group==:curls \ - || @per.group==:tics) \ - or (@per.alt==:curls \ - || @per.alt==:tics) \ - and t_o =~/\S/ \ - and t_o !~/^(?:\}(?:verse|code|box|alt|group|block)|(?:verse|code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|alt|group|block)\{)/ \ - and t_o !~/^```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block)|^```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$/ # fix logic - sub_array=t_o.dup - @line_mode=sub_array.scan(/.+/) - type=if @per.poem==:curls or @per.poem==:tics - t_o=SiSU_AO_DocumentStructureExtract::Build.new(@md,@line_mode).build_lines(type).join - poem=t_o.split(/\n\n/) - poem.each do |v| - v=v.gsub(/\n/m,"#{Mx[:br_nl]}\n") - obj,tags=extract_tags(v) - h={ - obj: obj, - tags: tags, - num: @num_id[:poem], - } - t_o=SiSU_AO_DocumentStructure::ObjectBlockTxt.new.verse(h) - tuned_file << t_o - end - :poem - else :group - end - end - @verse_count+=1 if @per.poem==:curls or @per.poem==:tics - end - if @per.code==:off - if @per.poem==:curls or @per.poem==:tics \ - or @per.box==:curls or @per.box==:tics \ - or @per.group==:curls or @per.group==:tics \ - or @per.alt==:curls or @per.alt==:tics \ - or (@per.quote==:open and t_o =~/`:quote_close`/m) - if t_o.is_a?(String) - t_o=t_o.gsub(/\n/m,"#{Mx[:br_nl]}"). - gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). - gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - t_o=t_o + Mx[:br_nl] if t_o =~/\S+/ - elsif t_o.is==:group \ - || t_o.is==:block \ - || t_o.is==:alt \ - || t_o.is==:box \ - || t_o.is==:verse - t_o.obj=t_o.obj.gsub(/\n/m,"#{Mx[:br_nl]}"). - gsub(/[ ][ ]/m,"#{Mx[:nbsp]*2}"). - gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - end - @tuned_block << t_o if t_o =~/\S+/ - else tuned_file << t_o - end - else tuned_file << t_o - end - end - tuned_file - end - def identify_parts - tuned_file=[] - @tuned_block,@tuned_code=[],[] - @@counter,@verse_count=0,0 - @num_id={ - code_block: 0, - poem: 0, - box: 0, - group: 0, - alt: 0, - quote: 0, - table: 0, - } - @metadata={} - @data,bibliography=SiSU_AO_References::Bibliography.new(@md,@data).biblio_extraction - tuned_file=extract_structure_loop(@data,tuned_file) - if @md.flag_endnotes - tuned_file << @pb - h={ - ln: 1, - lc: 1, - obj: 'Endnotes', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - ln: 4, - lc: 2, - obj: 'Endnotes', - name: 'endnotes', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - obj: 'Endnotes' - } - end - if @md.flag_auto_biblio - tuned_file << @pb - h={ - ln: 1, - lc: 1, - obj: 'References', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - ln: 4, - lc: 2, - obj: 'Bibliography', - name: 'biblio', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - obj: 'Bibliography' - } - citenumber=0 - bibliography.each do |c| - citenumber +=1 if c.is_a?(Hash) - if c[:is]==:book - h={ - obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]}) #{c[:url]}}, - tags: [c[:id]], - hang: 0, - indent: 2, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - elsif c[:is]==:article - h={ - obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:journal]} #{c[:volume]} (#{c[:year]}) #{c[:url]}}, - tags: [c[:id]], - hang: 0, - indent: 2, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - end - elsif @md.flag_biblio - tuned_file << @pb - h={ - ln: 1, - lc: 1, - obj: 'References', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - ln: 4, - lc: 2, - obj: 'Bibliography', - name: 'biblio', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - obj: 'Bibliography' - } - if bibliography.length > 0 - tuned_file=extract_structure_loop(bibliography,tuned_file) - else - tuned_file, citations = - SiSU_AO_References::Citations.new(@md,tuned_file).songsheet # ao_references.rb - citenumber=0 - citations.compact.each do |c| - citenumber +=1 if c.is_a?(Hash) - if c[:is]==:book - h={ - obj: %{[#{citenumber}] *{#{c[:author]}}* /{#{c[:publication]}}/ (#{c[:year]})}, - hang: 0, - indent: 2, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - elsif c[:is]==:article - h={ - obj: %{[#{citenumber}] *{#{c[:author]}}* /{"#{c[:title]}"}/ #{c[:publication]} editor #{c[:editor]} (#{c[:year]})}, - hang: 0, - indent: 2, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - end - end - end - if @md.book_idx - tuned_file << @pb - h={ - ln: 1, - lc: 1, - obj: 'Index', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - ln: 4, - lc: 2, - obj: 'Index', - name: 'book_index', - autonum_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - obj: 'Index' - } - end - tuned_file << @pb - h={ - ln: 1, - lc: 1, - obj: 'Metadata', - autonum_: false, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - ln: 4, - lc: 2, - obj: 'SiSU Metadata, document information', - name: 'metadata', - autonum_: false, - ocn_: false, - } - tuned_file << SiSU_AO_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ - obj: 'eof', - } - meta=SiSU_AO_DocumentStructure::ObjectMetadata.new.metadata(@metadata) - [tuned_file,meta,bibliography] - end - def table_rows_and_columns_array(table_str) - table=[] - table_str.split(/#{Mx[:tc_c]}/).each do |table_row| - table_row_with_columns=table_row.split(/#{Mx[:tc_p]}/) - table << table_row_with_columns - end - table - end - def meta_heading(h) - h={ - lv: h[:lv], - ln: h[:ln], - name: h[:name], - obj: h[:obj], - ocn: '0', - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - end - def meta_para(str) - h={ - obj: str, - ocn_: false, - } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - def build_lines(type=:none) - lines=@data - lines.each.map do |line| - line=if line =~/\S/ \ - and line !~/^(?:code(?:\.[a-z][0-9a-z_]+)?\{|\}code)/ \ - and line !~/^(?:```[ ]+code(?:\.[a-z][0-9a-z_]+)?|```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*$)/ \ - and not line.is_a?(Hash) #watch - @@counter+=1 if @per.code==:curls or @per.code==:tics - line=line.gsub(/\s\s/,"#{Mx[:nbsp]*2}"). - gsub(/#{Mx[:nbsp]}\s/,"#{Mx[:nbsp]*2}") - line=line.gsub(/^/,"#{Mx[:gr_o]}codeline#{Mx[:gr_c]}") if type==:code # REMOVE try sort for texpdf special case - line=if line =~/(?:https?|file|ftp):\/\/\S+$/ - line.gsub(/\s*$/," #{Mx[:br_nl]}") - else line.gsub(/\s*$/,"#{Mx[:br_nl]}") #unless type=='code' - end - elsif line =~/^\s*$/ - line.gsub(/\s*$/,"#{Mx[:br_nl]}") - else line - end - line - end - end - end - class Structure # this must happen early - def initialize(md) - @md=md - end - def structure(data) - data.compact.each do |dob| - structure_markup(dob) - end - end - def structure_markup(dob) #build structure where structure provided only in meta header - dob=if dob.is==:para \ - && (((dob.hang !~/[1-9]/) && (dob.indent !~/[1-9]/)) \ - || (dob.hang != dob.indent)) \ - and not dob.bullet_ - dob=case dob.obj - when /^#{@md.lv0}/ - h={ - is: :heading, - lv: 'A', - ln: 0, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv1}/ - h={ - is: :heading, - lv: 'B', - ln: 1, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv2}/ - h={ - is: :heading, - lv: 'C', - ln: 2, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv3}/ - h={ - is: :heading, - lv: 'D', - ln: 3, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv4}/ - h={ - is: :heading, - lv: '1', - ln: 4, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv5}/ - h={ - is: :heading, - lv: '2', - ln: 5, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - when /^#{@md.lv6}/ - h={ - is: :heading, - lv: '3', - ln: 6, - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h,dob) - else dob - end - else dob - end - dob - end - end - class OCN - def initialize(md,data,fnx,process) - @md,@data,@fnx,@process=md,data,fnx,process - end - def structure_info - def lv - %w[A~ B~ C~ D~ 1 2 3 4] - end - def possible_parents(child) - case child - when /A~/ then 'none' - when /B~/ then 'A~' - when /C~/ then 'B~' - when /D~/ then 'C~' - when /1/ then 'A~, B~, C~, D~' - when /2/ then '1' - when /3/ then '2' - when /4/ then '3' - end - end - def possible_children(parent) - case parent - when /A~/ then 'B~, 1' - when /B~/ then 'C~, 1' - when /C~/ then 'D~, 1' - when /D~/ then '1' - when /1/ then '2' - when /2/ then '3' - when /3/ then '4' - when /4/ then 'none' - end - end - self - end - def document_structure_check_info(node,node_parent,status=:ok) - node_ln=/^([0-7])/.match(node)[1].to_i - node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i - if status==:error \ - or @md.opt.act[:maintenance][:set]==:on - puts %{node: #{node}, parent node: #{node_parent} #{status.upcase}} - if status==:error - node_ln=/^([0-7])/.match(node)[1].to_i - node_parent_ln=/^([0-7])/.match(node_parent)[1].to_i - STDERR.puts %{current level: #{structure_info.lv[node_ln]} (possible parent levels: #{structure_info.possible_parents(structure_info.lv[node_ln])}) -parent level: #{structure_info.lv[node_parent_ln]} (possible child levels: #{structure_info.possible_children(structure_info.lv[node_parent_ln])}) -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit - end - end - end - end - def warning_incorrect_parent_level_or_level(txt) - puts %{ERROR. There is an error in markup of heading levels either here or in the parent heading. -The current header reads: -"#{txt}" -has incorrect level and/or parent level ---} - end - def required_headers_present? - if @process == :complete - unless (defined? @md.title \ - and @md.title.full) - STDERR.puts %{required header missing: - -@title: -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}" -} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit - end - end - unless (defined? @md.creator.author \ - and @md.creator.author) - STDERR.puts %{required header missing: - -@creator: - :author: anonymous? -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}" -} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit - end - end - end - end - def ocn #and auto segment numbering increment - required_headers_present? - data=@data - @o_array=[] - node=ocn=ocn_dv=ocn_sp=ocnh=ocnh0=ocnh1=ocnh2=ocnh3=ocnh4=ocnh5=ocnh6=ocnh7=ocno=ocnp=ocnt=ocnc=ocng=ocni=ocnu=0 # h heading, o other, t table, g group, i image - regex_exclude_ocn_and_node = /#{Rx[:meta]}|^@\S+?:\s|^4~endnotes|^#{Mx[:lv_o]}4:endnotes#{Mx[:lv_c]}|^\^~ |<:e[:_]\d+?>|^<:\#|<:- |<[:!]!4|
- if dob.is==:heading - @ln=ln=case dob.lv - when 'A' then 0 - when 'B' then 1 - when 'C' then 2 - when 'D' then 3 - when '1' then 4 - when '2' then 5 - when '3' then 6 - when '4' then 7 - when '5' then 8 - when '6' then 9 - end - end - if not dob.obj =~/~#|-#/ - ocn+=1 - end - if @process == :complete \ - or (@fnx == @md.opt.fns \ - && @md.opt.fns =~/.sst$/) - if dob.is==:heading \ - and (ln.to_s =~/^[0-9]/ \ - or ln.to_s =~@md.lv0 \ - or ln.to_s =~@md.lv1 \ - or ln.to_s =~@md.lv2 \ - or ln.to_s =~@md.lv3 \ - or ln.to_s =~@md.lv4 \ - or ln.to_s =~@md.lv5 \ - or ln.to_s =~@md.lv6 \ - or ln.to_s =~@md.lv7) - if not dob.obj =~/~#|-#/ - ocnh+=1 - end - if ln==0 \ - or ln=~@md.lv0 - @lev_occurences[:a] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh0+=1 #heading - node0="0:#{ocnh0};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node0="0:0;0" - end - document_structure_check_info(node0,node0) - @collapsed_lv0=0 - collapsed_level=@collapsed_lv0 - node,ocn_sp,parent=node0,"h#{ocnh}",'ROOT' - elsif ln==1 \ - or ln=~@md.lv1 - @lev_occurences[:b] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh1+=1 #heading - node1="1:#{ocnh1};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node1="1:0;0" - end - parent=if node0 - document_structure_check_info(node1,node0) - @collapsed_lv1=@collapsed_lv0+1 - node0 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node0,node0,:error) - node0 - end - collapsed_level=@collapsed_lv1 - node,ocn_sp,parent=node1,"h#{ocnh}",node0 #FIX - elsif ln==2 \ - or ln=~@md.lv2 - @lev_occurences[:c] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh2+=1 - node2="2:#{ocnh2};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node2="2:0;0" - end - parent=if node1 - document_structure_check_info(node2,node1) - @collapsed_lv2=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node2,node0,:error) - node0 - end - collapsed_level=@collapsed_lv2 - node,ocn_sp=node2,"h#{ocnh}" - elsif ln==3 \ - or ln=~@md.lv3 - @lev_occurences[:d] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh3+=1 - node3="3:#{ocnh3};#{ocn}" - else - #document_structure_check_info(node0,node0,:error) #fix - ocn_flag=false - node3="3:0;0" - end - parent=if node2 - document_structure_check_info(node3,node2) - @collapsed_lv3=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - puts %{parent is :A~ & this level #{dob.lv} -either parent should be level :B~ -or this level should be level :B~ rather than #{dob.lv}} - document_structure_check_info(node3,node1,:error) - @collapsed_lv3=@collapsed_lv1+1 - node1 - else - document_structure_check_info(node3,node0,:error) - warning_incorrect_parent_level_or_level(dob.obj) - node0 - end - collapsed_level=@collapsed_lv3 - node,ocn_sp=node3,"h#{ocnh}" - elsif ln==4 \ - or ln=~@md.lv4 - @lev_occurences[:l1] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh4+=1 - node4="4:#{ocnh4};#{ocn}" - else - ocn_flag=false - node4="4:0;0" - end - parent=if node3 - document_structure_check_info(node4,node3) - @collapsed_lv4=@collapsed_lv3+1 - node3 - elsif node2 - document_structure_check_info(node4,node2) - @collapsed_lv4=@collapsed_lv2+1 - node2 - elsif node1 - document_structure_check_info(node4,node1) - @collapsed_lv4=@collapsed_lv1+1 - node1 - elsif node0 - document_structure_check_info(node4,node0) - @collapsed_lv4=@collapsed_lv0+1 - node0 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node4,node0,:error) - node0 - end - collapsed_level=@collapsed_lv4 - node,ocn_sp=node4,"h#{ocnh}" - elsif ln==5 \ - or ln=~@md.lv5 - @lev_occurences[:l2] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh5+=1 - node5="5:#{ocnh5};#{ocn}" - else - ocn_flag=false - node5="5:0;0" - end - parent=if node4 - document_structure_check_info(node5,node4) - @collapsed_lv5=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node3,:error) - @collapsed_lv5=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node2,:error) - @collapsed_lv5=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node1,:error) - @collapsed_lv5=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node5,node0,:error) - node0 - end - collapsed_level=@collapsed_lv5 - node,ocn_sp=node5,"h#{ocnh}" - elsif ln==6 \ - or ln=~@md.lv6 - @lev_occurences[:l3] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh6+=1 - node6="6:#{ocnh6};#{ocn}" - else - ocn_flag=false - node6="6:0;0" - end - parent=if node5 - document_structure_check_info(node6,node5) - @collapsed_lv6=@collapsed_lv5+1 - node5 - elsif node4 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) -either parent should be level #5 (2~) -or this level should be #5 (2~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node6,node4,:error) - @collapsed_lv6=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node3,:error) - @collapsed_lv6=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node2,:error) - @collapsed_lv6=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node1,:error) - @collapsed_lv6=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node6,node0,:error) - node0 - end - collapsed_level=@collapsed_lv6 - node,ocn_sp=node6,"h#{ocnh}" - elsif ln==7 \ - or ln=~@md.lv7 - @lev_occurences[:l4] += 1 - if not dob.obj =~/~#|-#/ - ocn_flag=true - ocnh7+=1 - node7="7:#{ocnh7};#{ocn}" - else - ocn_flag=false - node7="7:0;0" - end - parent=if node6 - document_structure_check_info(node7,node6) - @collapsed_lv7=@collapsed_lv6+1 - node5 - elsif node5 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #5 (2~) & this level ##{dob.ln} (#{dob.lv}~) -either parent should be level #6 (3~) -or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node7,node5,:error) - @collapsed_lv6=@collapsed_lv5+1 - node5 - elsif node4 - warning_incorrect_parent_level_or_level(dob.obj) - puts "parent is level #4 (1~) & this level ##{dob.ln} (#{dob.lv}~) -either parent should be level 6~ -or this level should be #6 (3~) rather ##{dob.ln} (#{dob.lv}~)" - document_structure_check_info(node7,node4,:error) - @collapsed_lv6=@collapsed_lv4+1 - node4 - elsif node3 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node3,:error) - @collapsed_lv6=@collapsed_lv3+1 - node3 - elsif node2 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node2,:error) - @collapsed_lv6=@collapsed_lv2+1 - node2 - elsif node1 - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node1,:error) - @collapsed_lv6=@collapsed_lv1+1 - node1 - else - warning_incorrect_parent_level_or_level(dob.obj) - document_structure_check_info(node7,node0,:error) - node0 - end - collapsed_level=@collapsed_lv7 - node,ocn_sp=node7,"h#{ocnh}" - end - else - unless @lev_occurences[:l1] > 0 - STDERR.puts %{Substantive text objects must follow a level 1~ heading and there are none at this point in processing: #{@lev_occurences[:l1]} -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj #.gsub(/^(.{1,80})/,'"\1"') - exit - end - unless @ln >= 4 - lev=case @ln - when 0 then 'A' - when 1 then 'B' - when 2 then 'C' - when 3 then 'D' - when 4 then '1' - when 5 then '2' - when 6 then '3' - when 7 then '4' - when 8 then '5' - when 9 then '6' - end - STDERR.puts %{Substantive text objects must follow a level 1~ 2~ or 3~ heading: #{lev}~ -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}"} - puts dob.obj.gsub(/^(.{1,80})/,'"\1"') - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - break - else exit - end - end - if not dob.obj =~/~#|-#/ - ocn_flag=true - else - ocn_flag=false - end - ocno+=1 - if dob.is==:table - ocnt+=1 - ocn_sp,parent="t#{ocnt}",node - elsif dob.is==:code - ocnc+=1 - ocn_sp,parent="c#{ocnc}",node - elsif dob.is==:group \ - || dob.is==:box \ - || dob.is==:block \ - || dob.is==:alt \ - || dob.is==:verse - ocng+=1 #group, poem - ocn_sp,parent="g#{ocng}",node - elsif dob.is==:image #check - ocni+=1 - ocn_sp,parent="i#{ocni}",node - else ocnp+=1 #paragraph - ocn_sp,parent="p#{ocnp}",node - end - end - end - if dob.is==:heading - if ocn_flag==true - dob.ln,dob.node,dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent,dob.lc= - ln, node, ocn, ocn_flag, ocn_dv,ocn_sp, parent, collapsed_level - else - ocnu+=1 - heading_use=:ok - if dob.obj=~/#{Mx[:pa_non_object_no_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_no_heading]}/,'') - heading_use=:ok - elsif dob.obj=~/#{Mx[:pa_non_object_dummy_heading]}/ - dob.obj=dob.obj.gsub(/#{Mx[:pa_non_object_dummy_heading]}/,'') - heading_use=:dummy - end - dob.ln,dob.node,dob.ocn,dob.ocn_,dob.use_, dob.odv,dob.osp,dob.parent,dob.lc= - ln, node, nil, ocn_flag,heading_use,ocn_dv, ocn_sp, parent, collapsed_level - end - else - if dob.of !=:meta \ - && dob.of !=:comment \ - && dob.of !=:layout - if ocn_flag == true - dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= - ocn, ocn_flag,ocn_dv, ocn_sp, parent - else - ocnu+=1 - dob.obj=dob.obj.gsub(/#{Mx[:fa_o]}[~-]##{Mx[:fa_c]}/,'') if dob.obj - ocn_dv,ocn_sp="u#{ocnu}","u#{ocnu}" - dob.ocn,dob.ocn_,dob.odv,dob.osp,dob.parent= - nil, ocn_flag,ocn_dv, ocn_sp, parent - end - end - end - h - else dob - end - if dob.is==:code \ - || dob.is==:verse \ - || dob.is==:alt \ - || dob.is==:box \ - || dob.is==:group \ - || dob.is==:block - dob.obj=dob.obj.gsub(/\n+/,"\n") #newlines taken out - end - @o_array << dob - end - if @process == :complete \ - or (@fnx == @md.opt.fns \ - && @md.opt.fns =~/.sst$/) - unless @lev_occurences[:a] == 1 - STDERR.puts %{The number of level A~ in this document: #{@lev_occurences[:a]} -There must be one level A~ (no more and no less) -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit - end - end - unless @lev_occurences[:l1] > 0 - STDERR.puts %{The number of level 1~ in this document: #{@lev_occurences[:l1]} -There must be at least one level 1~ (and as many as required) -SKIPPED processing file: -[#{@md.opt.lng}] "#{@md.fns}"} - if @md.opt.act[:no_stop][:set]==:on - $process_document = :skip - else exit - end - end - end - @o_array - end - end - class XML - def initialize(md,data) - @data,@md=data,md - end - def dom - @s=[ 'A', 'B', 'C', 'D', '1', '2', '3' ] - tuned_file=structure_build - tuned_file - end - def spaces - Ax[:spaces] - end - def structure_build - data=@data - tuned_file=[] - hs=[0,false,false,false] - t={ - lv: @s[0], - status: :open, - } - tuned_file << tags(t) - if @md.opt.act[:verbose_plus][:set]==:on - puts "\nXML sisu structure outline --->\n" - puts "<#{@s[0]}>" - end - data.each_with_index do |o,i| - if o.is==:heading \ - || o.is==:heading_insert - case o.ln - when 0 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs=[0,true,false,false,false] - when 1 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs=[1,true,true,false,false] - when 2 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs=[2,true,true,true,false] - when 3 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs=[3,true,true,true,true] - when 4 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs[0]=4 - when 5 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs[0]=5 - when 6 - tuned_file << tag_close(o.ln,hs) - tuned_file << tag_open(o,@s) - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(o.ln,hs) - puts_tag_open(o,@s) - end - hs[0]=6 - end - end - tuned_file << o - end - if @md.opt.act[:verbose_plus][:set]==:on - puts_tag_close(0,hs) - end - tuned_file << tag_close(0,hs) - tuned_file=tuned_file.flatten - end - def tags(o) - tag=(o[:status]==:open) \ - ? %{<#{o[:lv]} id="#{o[:node]}">} - : "" - ln=case o[:lv] - when 'A' then 0 - when 'B' then 1 - when 'C' then 2 - when 'D' then 3 - when '1' then 4 - when '2' then 5 - when '3' then 6 - when '4' then 7 - when '5' then 8 - when '6' then 9 - end - h={ - tag: tag, - node: o[:node], - lv: o[:lv], - ln: ln, - status: o[:status], - } - SiSU_AO_DocumentStructure::ObjectStructure.new.xml_dom(h) #downstream code utilise else ignore like comments - end - def tag_open(o,tag) - t={ lv: tag[o.ln], node: o.node, status: :open } - t_o=tags(t) - t_o - end - def tag_close(lev,hs) - ary=[] - case hs[0] - when 0 - if (lev <= 0) and hs[0] - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 1 - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 2 - if (lev <= 2) and hs[2] - t={ - lv: @s[2], - status: :close, - } - ary << tags(t) - end - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 3 - if (lev <= 3) and hs[3] - t={ - lv: @s[3], - status: :close, - } - ary << tags(t) - end - if (lev <= 2) and hs[2] - t={ - lv: @s[2], - status: :close, - } - ary << tags(t) - end - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 4 - if (lev <= 4) - t={ - lv: @s[4], - status: :close, - } - ary << tags(t) - end - if (lev <= 3) and hs[3] - t={ - lv: @s[3], - status: :close, - } - ary << tags(t) - end - if (lev <= 2) and hs[2] - t={ - lv: @s[2], - status: :close, - } - ary << tags(t) - end - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 5 - if (lev <= 5) - t={ - lv: @s[5], - status: :close, - } - ary << tags(t) - end - if (lev <= 4) - t={ - lv: @s[4], - status: :close, - } - ary << tags(t) - end - if (lev <= 3) and hs[3] - t={ - lv: @s[3], - status: :close, - } - ary << tags(t) - end - if (lev <= 2) and hs[2] - t={ - lv: @s[2], - status: :close, - } - ary << tags(t) - end - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - when 6 - if (lev <= 6) - t={ - lv: @s[6], - status: :close, - } - ary << tags(t) - end - if (lev <= 5) - t={ - lv: @s[5], - status: :close, - } - ary << tags(t) - end - if (lev <= 4) - t={ - lv: @s[4], - status: :close, - } - ary << tags(t) - end - if (lev <= 3) and hs[3] - t={ - lv: @s[3], - status: :close, - } - ary << tags(t) - end - if (lev <= 2) and hs[2] - t={ - lv: @s[2], - status: :close, - } - ary << tags(t) - end - if (lev <= 1) and hs[1] - t={ - lv: @s[1], - status: :close, - } - ary << tags(t) - end - if (lev==0) - t={ - lv: @s[0], - status: :close, - } - ary << tags(t) - end - end - ary - end - def puts_tag_open(o,tag) - puts %{#{spaces*o.ln}<#{tag[o.ln]} id="#{o.node}">} - end - def puts_tag_close(lev,hs) - case hs[0] - when 0 - #puts "#{spaces*0}" if (lev <= 0) and hs[0] - puts "" if (lev==0) - when 1 - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - when 2 - puts "#{spaces*2}" if (lev <= 2) and hs[2] - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - when 3 - puts "#{spaces*3}" if (lev <= 3) and hs[3] - puts "#{spaces*2}" if (lev <= 2) and hs[2] - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - when 4 - puts "#{spaces*4}" if (lev <= 4) - puts "#{spaces*3}" if (lev <= 3) and hs[3] - puts "#{spaces*2}" if (lev <= 2) and hs[2] - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - when 5 - puts "#{spaces*5}" if (lev <= 5) - puts "#{spaces*4}" if (lev <= 4) - puts "#{spaces*3}" if (lev <= 3) and hs[3] - puts "#{spaces*2}" if (lev <= 2) and hs[2] - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - when 6 - puts "#{spaces*6}" if (lev <= 6) - puts "#{spaces*5}" if (lev <= 5) - puts "#{spaces*4}" if (lev <= 4) - puts "#{spaces*3}" if (lev <= 3) and hs[3] - puts "#{spaces*2}" if (lev <= 2) and hs[2] - puts "#{spaces*1}" if (lev <= 1) and hs[1] - puts "" if (lev==0) - end - end - end -end -__END__ diff --git a/lib/sisu/current/ao_endnotes.rb b/lib/sisu/current/ao_endnotes.rb deleted file mode 100644 index 508d798a..00000000 --- a/lib/sisu/current/ao_endnotes.rb +++ /dev/null @@ -1,136 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Endnotes - class Endnotes - def initialize(md,data,endnote_array=nil) - @md,@data,@endnote_array= - md, data, endnote_array - @endnote_counter, - @endnote_counter_asterisk, - @endnote_counter_dag= - 1,1,1 - end - def endnotes - data=@data - endnote_ref=1 - @tuned_file=data.each.map do |dob| - # manually numbered endnotes --> - if @md.opt.selections.str =~/--no-asterisk|--no-annotate/ - dob.obj=dob.obj. - gsub(/#{Mx[:en_b_o]}\s.+?#{Mx[:en_b_c]}/,'') - end - if @md.opt.selections.str =~/--no-dagger|--no-annotate/ - dob.obj=dob.obj. - gsub(/#{Mx[:en_b_o]}[+]\s.+?#{Mx[:en_b_c]}/,'') - end - if (defined? dob.obj) \ - && (defined? dob.is) \ - && dob.is !=:code - case dob.obj # auto-numbered endnotes --> - when /#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\s+.+?#{Mx[:en_b_c]}/ - dob.obj=dob.obj. - gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/,'\1') - word_mode=dob.obj.scan(/\S+/m) - word_mode=endnote_call_number(word_mode) - dob.obj=word_mode.join(' ') - endnote_ref+=1 - when /~\^(?:\s|$)/ #%note inserts endnotes previously gathered from /^(|[-~]\{{3})/ (in earlier loop) - word_mode=dob.obj.scan(/\S+/m) - word_mode=endnote_call_number(word_mode) - dob.obj=word_mode.join(' ') - endnote_ref+=1 - end - end - dob - end.flatten - @endnote_counter, - @endnote_counter_asterisk, - @endnote_counter_dag= - 1,1,1 - @tuned_file - end - def endnote_call_number(words) - words.each do |word| - case word - when /#{Mx[:en_a_o]}/ - unless word =~/#{Mx[:en_a_o]}[*+]+/ - word.gsub!(/#{Mx[:en_a_o]}/, - "#{Mx[:en_a_o]}#{@endnote_counter} ") - @endnote_counter+=1 - end - when /#{Mx[:en_b_o]}/ - if word =~/#{Mx[:en_b_o]}[+]/ - word.gsub!(/#{Mx[:en_b_o]}[+]/, - "#{Mx[:en_b_o]}\+#{@endnote_counter_dag} ") - @endnote_counter_dag+=1 - else - word.gsub!(/#{Mx[:en_b_o]}[*]?/, - "#{Mx[:en_b_o]}\*#{@endnote_counter_asterisk} ") - @endnote_counter_asterisk+=1 - end - when /~\^/ - if @endnote_array - word.gsub!(/~\^/, - "#{@endnote_array[@endnote_counter-1]}") - @endnote_counter+=1 - end - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/ao_expand_insertions.rb b/lib/sisu/current/ao_expand_insertions.rb deleted file mode 100644 index 3d4ea8cb..00000000 --- a/lib/sisu/current/ao_expand_insertions.rb +++ /dev/null @@ -1,514 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Insertions - class Insertions - def initialize(md,data) - @md,@data=md,data - end - def output_filetypes_in_cmd(cmd_shortcut,lnk=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used - act_defaults=SiSU_Env::InfoProcessingFlag.new - cmd_list=case cmd_shortcut.inspect #check on expectation, string v array - when /0/ then act_defaults.act_0.str - when /1/ then act_defaults.act_1.str - when /2/ then act_defaults.act_2.str - when /3/ then act_defaults.act_3.str - when /4/ then act_defaults.act_4.str - when /5/ then act_defaults.act_5.str - when /6/ then act_defaults.act_6.str - when /7/ then act_defaults.act_7.str - when /8/ then act_defaults.act_8.str - when /9/ then act_defaults.act_9.str - end - file_type_names={} - file_type_names[:gen],file_type_names[:src]=[],[] - file_type_names[:gen] <<= if cmd_list =~ /\b--manifest\b/ - "~^ { document manifest }#{lnk[:manifest]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b--html\b/ - [ - " { html, segmented text }#{lnk[:html_toc]}", - " { html, scroll, document in one }#{lnk[:html_doc]}", - ] - end - file_type_names[:gen] <<= if cmd_list =~ /\b--epub\b/ - [" { epub }#{lnk[:epub]}"] - end - file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ - or cmd_list =~ /--pdf-landscape/ - [ - " { pdf, landscape }#{lnk[:pdf_landscape]}", - ] - end - file_type_names[:gen] <<= if cmd_list =~ /\b--pdf\b/ \ - or cmd_list =~ /--pdf-portrait/ - [ - " { pdf, portrait }#{lnk[:pdf_portrait]}", - ] - end - file_type_names[:gen] <<= if cmd_list =~ /\b(?:--odt|--odf)\b/ - " { odf:odt, open document text }#{lnk[:odt]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b--xhtml\b/ - " { xhtml scroll }#{lnk[:xhtml]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b--docbook\b/ - " { docbook }#{lnk[:docbook]}" #CHECK - end - file_type_names[:gen] <<= if cmd_list =~ /\b--xml-sax\b/ - " { xml, sax }#{lnk[:xml_sax]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b--xml-dom\b/ - " { xml, dom }#{lnk[:xml_dom]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b(?:--txt|--text|--plaintext)\b/ - " { plain text utf-8 }#{lnk[:txt]}" - end - #file_type_names[:gen] <<= if cmd_list =~ /g/ - # 'wiki.txt' - #end - file_type_names[:gen] <<= if cmd_list =~ /\b--concordance\b/ - " { concordance }#{lnk[:html_concordance]}" - end - file_type_names[:gen] <<= if cmd_list =~ /\b--digest\b/ - " { dcc, document content certificate (digests) }#{lnk[:digest]}" - end - file_type_names[:src] <<= if source and cmd_shortcut =~ /\b--source\b/ - " { markup source text }#{lnk[:source]}" - end - file_type_names[:src] <<= if cmd_shortcut =~ /\b--sisupod\b/ - " { markup source (zipped) pod }#{lnk[:sisupod]}" - end - file_type_names[:gen]=file_type_names[:gen].flatten - file_type_names[:src]=file_type_names[:src].flatten - file_type_names - end - def by_language(linked_doc,lng,src=nil) - @linked_doc,@lng,@src=linked_doc,lng,src - @base_path="#{@md.file.output_path.base.url}/#{lng}" - def fnh - { - fn: @linked_doc, - } - end - def path_and_file(fn,pth) - @base_path + '/' + pth + '/' + fn - end - def manifest - fn=@md.file.base_filename.manifest(fnh) - path_and_file(fn,'manifest') - end - def html_toc - fn=@md.file.base_filename.html_segtoc(fnh) - @base_path + '/html/' + @linked_doc + '/' + fn - end - def html_doc - fn=@md.file.base_filename.html_scroll(fnh) - path_and_file(fn,'html') - end - def html_concordance - fn=@md.file.base_filename.html_concordance - @base_path + '/html/' + @linked_doc + '/' + fn - end - def epub - fn=@md.file.base_filename.epub(fnh) - path_and_file(fn,'epub') - end - def pdf_landscape - fn=@md.file.base_filename.pdf_l_a4(fnh) - path_and_file(fn,'pdf') - end - def pdf_portrait - fn=@md.file.base_filename.pdf_p_a4(fnh) - path_and_file(fn,'pdf') - end - def odt - fn=@md.file.base_filename.odt(fnh) - path_and_file(fn,'odt') - end - def xhtml - fn=@md.file.base_filename.xhtml(fnh) - path_and_file(fn,'xhtml') - end - def docbook - fn=@md.file.base_filename.xml_docbook_book(fnh) - path_and_file(fn,'docbook') - end - def xml_sax - fn=@md.file.base_filename.xml_sax(fnh) - path_and_file(fn,'xml_sax') - end - def xml_dom - fn=@md.file.base_filename.xml_dom(fnh) - path_and_file(fn,'xml_dom') - end - def txt - fn=@md.file.base_filename.txt(fnh) - path_and_file(fn,'txt') - end - def digest - fn=@md.file.base_filename.hash_digest(fnh) - path_and_file(fn,'digest') - end - def source - @base_path + '/src/' + @src - end - def sisupod - @base_path + '/src/' + @src + '.zip' - end - self - end - def by_filetype(linked_doc,lng,src=nil) - @linked_doc,@lng,@src=linked_doc,lng,src - @lc=SiSU_Env::FilenameLanguageCodeInsert.new(@md.opt,lng). - language_code_insert - @base_path="#{@md.file.output_path.base.url}" - def fnh - { - fn: @linked_doc, - lng: @lc, - } - end - def path_and_file(fn,pth) - @base_path + '/' + pth + '/' + fn - end - def manifest - fn=@md.file.base_filename.manifest(fnh) - path_and_file(fn,'manifest') - end - def html_toc - fn=@md.file.base_filename.html_segtoc(fnh) - path_and_file(fn,'html') - end - def html_doc - fn=@md.file.base_filename.html_scroll(fnh) - path_and_file(fn,'html') - end - def html_concordance - fn=@md.file.base_filename.html_concordance - path_and_file(fn,'html') - end - def epub - fn=@md.file.base_filename.epub(fnh) - path_and_file(fn,'epub') - end - def pdf_landscape - fn=@md.file.base_filename.pdf_l_a4(fnh) - path_and_file(fn,'pdf') - end - def pdf_portrait - fn=@md.file.base_filename.pdf_p_a4(fnh) - path_and_file(fn,'pdf') - end - def odt - fn=@md.file.base_filename.odt(fnh) - path_and_file(fn,'odt') - end - def xhtml - fn=@md.file.base_filename.xhtml(fnh) - path_and_file(fn,'xhtml') - end - def docbook - fn=@md.file.base_filename.xml_docbook_book(fnh) - path_and_file(fn,'docbook') - end - def xml_sax - fn=@md.file.base_filename.xml_sax(fnh) - path_and_file(fn,'xml_sax') - end - def xml_dom - fn=@md.file.base_filename.xml_dom(fnh) - path_and_file(fn,'xml_dom') - end - def txt - fn=@md.file.base_filename.txt(fnh) - path_and_file(fn,'txt') - end - def digest - fn=@md.file.base_filename.hash_digest(fnh) - path_and_file(fn,'digest') - end - def source - @base_path + '/src/' + @src - end - def sisupod - @base_path + '/src/' + @src + '.zip' - end - self - end - def by_filename(linked_doc,lng,src=nil) - @linked_doc,@lng,@src=linked_doc,lng,src - @lc=SiSU_Env::FilenameLanguageCodeInsert.new(@md.opt,lng).language_code_insert - @base_path="#{@md.file.output_path.base.url}/#{@linked_doc}" - def fnh - { - fn: @linked_doc, - lng: @lc, - } - end - def path_and_file(fn,pth=nil) - (pth.nil?) \ - ? @base_path + '/' + fn - : @base_path + '/' + pth + '/' + fn - end - def manifest - fn=@md.file.base_filename.manifest(fnh) - path_and_file(fn) - end - def html_toc - fn=@md.file.base_filename.html_segtoc(fnh) - path_and_file(fn) - end - def html_doc - fn=@md.file.base_filename.html_scroll(fnh) - path_and_file(fn) - end - def html_concordance - fn=@md.file.base_filename.html_concordance - path_and_file(fn) - end - def epub - fn=@md.file.base_filename.epub(fnh) - path_and_file(fn,'epub') - end - def pdf_landscape - fn=@md.file.base_filename.pdf_l_a4(fnh) - path_and_file(fn) - end - def pdf_portrait - fn=@md.file.base_filename.pdf_p_a4(fnh) - path_and_file(fn) - end - def odt - fn=@md.file.base_filename.odt(fnh) - path_and_file(fn) - end - def xhtml - fn=@md.file.base_filename.xhtml(fnh) - path_and_file(fn) - end - def docbook - fn=@md.file.base_filename.xml_docbook_book(fnh) - path_and_file(fn) - end - def xml_sax - fn=@md.file.base_filename.xml_sax(fnh) - path_and_file(fn) - end - def xml_dom - fn=@md.file.base_filename.xml_dom(fnh) - path_and_file(fn) - end - def txt - fn=@md.file.base_filename.txt(fnh) - path_and_file(fn) - end - def digest - fn=@md.file.base_filename.hash_digest(fnh) - path_and_file(fn) - end - def source - @base_path + '/' + @src - end - def sisupod - @base_path + '/' + @src + '.zip' - end - self - end - def expand_insertions? - data=@data - tuned_file,tuned_file_tmp=[],[] - codeblock_={ - status: :false, - type: :na, - } - data.each do |para| - codeblock_=if para =~/^code(?:\.[a-z][0-9a-z_]+)?\{/ \ - and codeblock_[:status]==:false - { - status: :true, - type: :curl, - } - elsif para =~/^```[ ]+code(?:\.[a-z][0-9a-z_]+)?/ \ - and codeblock_[:status]==:false - { - status: :true, - type: :tics, - } - elsif codeblock_[:type]==:curl \ - and para =~/^\}code/m - { - status: :false, - type: :na, - } - elsif codeblock_[:type]==:tics \ - and para =~/^```(?:\s|$)/m - { - status: :false, - type: :na, - } - else codeblock_ - end - if para !~/^%+\s/ \ - and codeblock_[:status] != :true \ - and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/ - @u=SiSU_Env::InfoEnv.new.url - m_cmd='' - if defined? @u.remote - if /(?.+?)\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para - m_pre=m_pre.strip - elsif /\{(?.+?)\s\[(?\d[sS]*)\]\}(?(?\S+?)\.ss[tm]\b)(?.*)/m =~ para - end - if m_linked_doc =~ /(\S+?)\/(\S+)/ - m_linked_doc,m_linked_doc_lang=$1,$2 - else - m_linked_doc,m_linked_doc_lang=m_linked_doc,@md.opt.lng_base - end - else - puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}" - if /\{(?:~\^\s+)?(?.+?)\s\[(?\d[sS]*)\]\}\.\.\/(?\S+?)\/(?\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ =~ para - end - end - lnk=case @md.opt.dir_structure_by - when :language - { - manifest: by_language(m_linked_doc,m_linked_doc_lang).manifest, - html_toc: by_language(m_linked_doc,m_linked_doc_lang).html_toc, - html_doc: by_language(m_linked_doc,m_linked_doc_lang).html_doc, - epub: by_language(m_linked_doc,m_linked_doc_lang).epub, - pdf_landscape: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, - pdf_portrait: by_language(m_linked_doc,m_linked_doc_lang).pdf_landscape, - odt: by_language(m_linked_doc,m_linked_doc_lang).odt, - xhtml: by_language(m_linked_doc,m_linked_doc_lang).xhtml, - docbook: by_language(m_linked_doc,m_linked_doc_lang).docbook, - xml_sax: by_language(m_linked_doc,m_linked_doc_lang).xml_sax, - xml_dom: by_language(m_linked_doc,m_linked_doc_lang).xml_dom, - txt: by_language(m_linked_doc,m_linked_doc_lang).txt, - html_concordance: by_language(m_linked_doc,m_linked_doc_lang).html_concordance, - digest: by_language(m_linked_doc,m_linked_doc_lang).digest, - sisupod: by_language(m_linked_doc,m_linked_doc_lang,m_source).sisupod, - source: by_language(m_linked_doc,m_linked_doc_lang,m_source).source, - } - when :filetype - { - manifest: by_filetype(m_linked_doc,m_linked_doc_lang).manifest, - html_toc: by_filetype(m_linked_doc,m_linked_doc_lang).html_toc, - html_doc: by_filetype(m_linked_doc,m_linked_doc_lang).html_doc, - epub: by_filetype(m_linked_doc,m_linked_doc_lang).epub, - pdf_landscape: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, - pdf_portrait: by_filetype(m_linked_doc,m_linked_doc_lang).pdf_landscape, - odt: by_filetype(m_linked_doc,m_linked_doc_lang).odt, - xhtml: by_filetype(m_linked_doc,m_linked_doc_lang).xhtml, - docbook: by_filetype(m_linked_doc,m_linked_doc_lang).docbook, - xml_sax: by_filetype(m_linked_doc,m_linked_doc_lang).xml_sax, - xml_dom: by_filetype(m_linked_doc,m_linked_doc_lang).xml_dom, - txt: by_filetype(m_linked_doc,m_linked_doc_lang).txt, - html_concordance: by_filetype(m_linked_doc,m_linked_doc_lang).html_concordance, - digest: by_filetype(m_linked_doc,m_linked_doc_lang).digest, - sisupod: by_filetype(m_linked_doc,m_linked_doc_lang,m_source).sisupod, - source: by_filetype(m_linked_doc,m_linked_doc_lang,m_source).source, - } - else - { - manifest: by_filename(m_linked_doc,m_linked_doc_lang).manifest, - html_toc: by_filename(m_linked_doc,m_linked_doc_lang).html_toc, - html_doc: by_filename(m_linked_doc,m_linked_doc_lang).html_doc, - epub: by_filename(m_linked_doc,m_linked_doc_lang).epub, - pdf_landscape: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, - pdf_portrait: by_filename(m_linked_doc,m_linked_doc_lang).pdf_landscape, - odt: by_filename(m_linked_doc,m_linked_doc_lang).odt, - xhtml: by_filename(m_linked_doc,m_linked_doc_lang).xhtml, - docbook: by_filename(m_linked_doc,m_linked_doc_lang).docbook, - xml_sax: by_filename(m_linked_doc,m_linked_doc_lang).xml_sax, - xml_dom: by_filename(m_linked_doc,m_linked_doc_lang).xml_dom, - txt: by_filename(m_linked_doc,m_linked_doc_lang).txt, - html_concordance: by_filename(m_linked_doc,m_linked_doc_lang).html_concordance, - digest: by_filename(m_linked_doc,m_linked_doc_lang).digest, - sisupod: by_filename(m_linked_doc,m_linked_doc_lang,m_source).sisupod, - source: by_filename(m_linked_doc,m_linked_doc_lang,m_source).source, - } - end - linked_title="#{m_pre}{#{m_txt} }#{lnk[:manifest]}#{m_note}\n\n" - tuned_file_tmp << linked_title - output_filetypes=output_filetypes_in_cmd(m_cmd,lnk) - output_filetypes[:gen].each do |desc| - if desc - tuned_file_tmp << if @u.remote - "#{Mx[:nbsp]*4} #{desc} " - else # remove ... - "[provide document placement host location]" - end - end - end - output_filetypes[:src].each do |desc| - if desc - tuned_file_tmp << if @u.remote - "#{Mx[:nbsp]*4} #{desc} " - else - "[provide document placement host location]" - end - end - end - tuned_file << 'group{' << tuned_file_tmp.join("\n") << '}group' - tuned_file_tmp=[] - else tuned_file << para - end - end - tuned_file - end - end -end -__END__ diff --git a/lib/sisu/current/ao_hash_digest.rb b/lib/sisu/current/ao_hash_digest.rb deleted file mode 100644 index 0864989c..00000000 --- a/lib/sisu/current/ao_hash_digest.rb +++ /dev/null @@ -1,174 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Hash - require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb - class ObjectDigest - def initialize(md,data,env=nil) - @md,@data,@env=md,data,env - @env ||=SiSU_Env::InfoEnv.new(@md.fns,@md) - end - def object_digest - # 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes - # 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph) - # 3. whole object, text with markup and any endnotes, (question: with or without the endnote digests??? presumption better without, [however may be easier to check with?]) - # [digests should not include other digests] - data=@data.compact - @tuned_file=[] - sha_ =@env.digest(@md.opt).type - begin - sha_ ? (require 'digest/sha2') : (require 'digest/md5') - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error(sha_ + ' NOT FOUND') - end - data.each do |t_o| - unless t_o.obj.is_a?(Array) - t_o.obj=t_o.obj.strip - end - if (t_o.of !=:structure \ - && t_o.of !=:comment \ - && t_o.of !=:layout) \ - && t_o.ocn.is_a?(Fixnum) - case sha_ - when :sha512 - for hash_class in [ Digest::SHA512 ] - @tuned_file << stamped(t_o,hash_class) - end - when :sha256 - for hash_class in [ Digest::SHA256 ] - @tuned_file << stamped(t_o,hash_class) - end - when :md5 - for hash_class in [ Digest::MD5 ] - @tuned_file << stamped(t_o,hash_class) - end - end - else @tuned_file << t_o unless t_o.nil? - end - end - @tuned_file=@tuned_file.flatten - #use md5 or to create hash of each ao object including ocn, & add into to each ao object - end - def endnote_digest(data) - data.each.map do |en_plus| - case en_plus - when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/ - t_o_txt,en_open,en_txt,en_close= - /(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m. - match(en_plus)[1..4] - stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup - digest_en_strip=case @env.digest(@md.opt).type - when :sha512 - Digest::SHA512.hexdigest(stripped_en) - when :sha256 - Digest::SHA256.hexdigest(stripped_en) - when :md5 - Digest::MD5.hexdigest(stripped_en) - else - Digest::SHA256.hexdigest(stripped_en) - end - t_o_txt + - en_open + - en_txt + - Mx[:id_o] + - digest_en_strip + - Mx[:id_c] + - en_close - else STDERR.puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up - end - else en_plus - end - end.join - end - def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary? - t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces - #SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup #check - #SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup #check - #SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst #check - unless t_o.is==:code - case t_o.obj - when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m - en_and_t_o_digest=[] - t_o.obj=t_o.obj. - gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch - t_o_plus_en=t_o.obj. - scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m) - t_o_tail=if t_o.obj =~/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+([\s\S]+)/m - /(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1] - else '' - end - t_o_plus_en << t_o_tail - en_and_t_o_digest << endnote_digest(t_o_plus_en) - en_and_t_o_digest.join(' ') - else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil? - end - else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil? - end - t_o #KEEP intact - end - def strip_clean_extra_spaces(s) # ao output tuned - s=s.dup - s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/ - s=s.gsub(/ [ ]+/,' '). - gsub(/^ [ ]+/,''). - gsub(/ [ ]+$/,''). - gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2'). - gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2') - end - end -end -__END__ diff --git a/lib/sisu/current/ao_idx.rb b/lib/sisu/current/ao_idx.rb deleted file mode 100644 index defad2c3..00000000 --- a/lib/sisu/current/ao_idx.rb +++ /dev/null @@ -1,422 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_BookIndex - class BookIndex - def initialize(md,data,env=nil) - @md,@data,@env=md,data,env - @rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/ - @rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/ - @rgx_idx_ocn=/(.+?)~(\d+)/ - @env ||=SiSU_Env::InfoEnv.new(@md.fns) - end - def indexing_song - data=@data - data, - sisu_markup_idx_rel, - sisu_markup_idx_rel_html_seg, - html_idx,xhtml_idx= - extract_book_index(data) - data= - clean_and_insert_index( - data, - sisu_markup_idx_rel_html_seg - ) - [ - data, - sisu_markup_idx_rel, - sisu_markup_idx_rel_html_seg, - html_idx, - xhtml_idx, - ] - end - def extract_book_index(data) - tuned_file=[] - idx_array=[] - data.each do |dob| - if (dob.is ==:heading \ - || dob.is ==:heading_insert) \ - && dob.ln==4 - @seg=dob.name - end - if defined? dob.idx \ - and dob.idx.is_a?(Hash) - idx_array << { - idx: dob.idx, - ocn: dob.ocn, - seg: @seg - } - end - tuned_file << dob if dob - end - if idx_array.length > 0 - the_idx=construct_book_index(idx_array) - if @md.book_idx - idx=index(the_idx) - sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx= - idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml] - else - sisu_markup_idx_rel= - sisu_markup_idx_rel_html_seg= - html_idx= - xhtml_idx= - nil - end - end - [ - tuned_file, - sisu_markup_idx_rel, - sisu_markup_idx_rel_html_seg, - html_idx, - xhtml_idx, - ] - end - def construct_book_index(idx_array) - the_idx={} - idx_array.each do |idx| - idx[:idx].each_pair do |term,term_info| - location=(term_info[:plus].to_i > 0) \ - ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}}) - : idx[:ocn].to_s - the_idx[term]={} \ - unless the_idx[term] \ - and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] \ - unless the_idx[term]['node_0_terms'] \ - and defined? the_idx[term]['node_0_terms'] - the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] } - if term_info[:sub].is_a?(Array) \ - and term_info[:sub].length > 0 - term_info[:sub].each do |y| - y.each_pair do |subterm,subterm_info| - location=(subterm_info[:plus].to_i > 0) \ - ? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}}) - : idx[:ocn].to_s - the_idx[term]={} \ - unless the_idx[term] \ - and defined? the_idx[term] - the_idx[term]['node_0_terms']=[] \ - unless the_idx[term]['node_0_terms']\ - and defined? the_idx[term]['node_0_terms'] - the_idx[term]['node_1_subterms']={} \ - unless the_idx[term]['node_1_subterms'] \ - and defined? the_idx[term]['node_1_subterms'] - the_idx[term]['node_1_subterms'][subterm]=[] \ - unless the_idx[term]['node_1_subterms'][subterm] \ - and defined? the_idx[term]['node_1_subterms'][subterm] - the_idx[term]['node_1_subterms'][subterm] << - { ocn: idx[:ocn], range: location, seg: idx[:seg] } - end - end - end - end - end - the_idx=the_idx.sort - the_idx - end - def clean_xml(str) - str=str.gsub(/&/,'&') - str - end - def index(the_idx) - @x=1 - idx={} - idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]= - [], [], [], [] - h={ - obj: Mx[:br_page] - } - o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h) - idx[:sst_rel_html_seg] << o - idx[:sst_rel] << o - h={ - lv: '1', - name: 'index', - obj: "Index" - } - o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - idx[:sst_rel_html_seg] << o - idx[:sst_rel] << o - h={ - lv: '4', - name: 'idx', - obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}" - } - o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - idx[:sst_rel_html_seg] << o - idx[:sst_rel] << o - alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z] - idx[:html] << '

' - idx[:xhtml] << '

' - alph.each do |x| - if x =~/[0-9]/ - idx[:html] << '' - idx[:xhtml] << '' - else - idx[:html] << - %{#{x},#{$ep[:hsp]}} - idx[:xhtml] << - %{#{x},#{$ep[:hsp]}} - end - end - idx[:html] << '

' - idx[:xhtml] << '

' - letter=alph.shift - idx[:html] << - %{\n

} - idx[:xhtml] << - %{\n

0 - 9

} - the_idx.each do |i| - i.each do |x| - if x.is_a?(String) - f=/^(\S)/.match(x)[1] - if letter < f - while letter < f - if alph.length > 0 - letter=alph.shift - idx[:html] << - %{\n

#{letter}

} - idx[:xhtml] << - %{\n

#{letter}

} - else break - end - end - end - idx[:sst_rel_html_seg] << - %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } - idx[:sst_rel] << - %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} } - aname=x.gsub(/\s+/,'_') - idx[:html] << - %{\n

#{x}, } - c=clean_xml(x.dup) - idx[:xhtml] << - %{\n

#{c}, } - @o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last) - @t=idx[:sst_rel].index(idx[:sst_rel].last) - @q=idx[:html].index(idx[:html].last) - @r=idx[:xhtml].index(idx[:xhtml].last) - print "\n" + x + ', ' if @md.opt.act[:verbose_plus][:set]==:on - elsif x.is_a?(Array) - p 'array error? -->' - print x - elsif x.is_a?(Hash) - if x['node_0_terms'].is_a?(Array) - x['node_0_terms'].each do |a| - if a[:range] - idx[:sst_rel_html_seg][@o]= - idx[:sst_rel_html_seg][@o] + - %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]= - idx[:sst_rel][@t] + - %{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]= - idx[:html][@q] + - %{#{a[:range]}, } - idx[:xhtml][@q]= - idx[:xhtml][@q] + - %{#{a[:range]}, } - print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on - elsif a[:ocn] - idx[:sst_rel_html_seg][@o]= - idx[:sst_rel_html_seg][@o] + - %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]= - idx[:sst_rel][@t] + - %{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]= - idx[:html][@q] + - %{#{a[:ocn]}, } - idx[:xhtml][@q]= - idx[:xhtml][@q] + - %{#{a[:ocn]}, } - print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on - else p 'error' - end - end - idx[:html][@q]=idx[:html][@q] + '

' - idx[:xhtml][@r]=idx[:xhtml][@r] + '

' - end - if x['node_1_subterms'] - x['node_1_subterms'].sort.each do |k,y| - if k !~/node_0_terms/ - idx[:sst_rel_html_seg][@o]= - idx[:sst_rel_html_seg][@o] + - %{#{k}, } - idx[:sst_rel][@t]= - idx[:sst_rel][@t] + - %{#{k}, } - idx[:html][@q]= - idx[:html][@q] + - %{\n

#{k}, } - c=clean_xml(k.dup) - idx[:xhtml][@r]= - idx[:xhtml][@r] + - %{\n

#{c}, } - print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on - y.each do |z| - if z[:range] - idx[:sst_rel_html_seg][@o]= - idx[:sst_rel_html_seg][@o] + - %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]= - idx[:sst_rel][@t] + - %{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]= - idx[:html][@q] + - %{#{z[:range]}, } - idx[:xhtml][@q]= - idx[:xhtml][@q] + - %{#{z[:range]}, } - print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on - elsif z[:ocn] - idx[:sst_rel_html_seg][@o]= - idx[:sst_rel_html_seg][@o] + - %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, } - idx[:sst_rel][@t]= - idx[:sst_rel][@t] + - %{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, } - idx[:html][@q]= - idx[:html][@q] + - %{#{z[:ocn]}, } - idx[:xhtml][@q]= - idx[:xhtml][@q] + - %{#{z[:ocn]}, } - print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on - else p 'error' - end - end - idx[:html][@q]=idx[:html][@q] + '

' - idx[:xhtml][@r]=idx[:xhtml][@r] + '

' - end - end - end - @x +=1 - end - end - end - print "\n" if @md.opt.act[:verbose_plus][:set]==:on - idx - end - def screen_print(the_idx) - the_idx.each do |i| - i.each do |x| - if x.is_a?(String) - print "\n" + x + ', ' - elsif x.is_a?(Array) - p 'array error? -->' - print x - elsif x.is_a?(Hash) - if x['node_0_terms'].is_a?(Array) - x['node_0_terms'].each do |a| - if a[:range] - print a[:range] + ', ' - elsif a[:ocn] - print a[:ocn] + ', ' - else p 'error' - end - end - end - if x['node_1_subterms'] - x['node_1_subterms'].sort.each do |k,y| - if k !~/node_0_terms/ - print "\n\t" + k + ', ' - y.each do |z| - if z[:range] - print z[:range] + ', ' - elsif z[:ocn] - print z[:ocn] + ', ' - else p 'error' - end - end - end - end - end - end - end - end - end - def output_idx(idx) - if @md.book_idx - path="#{@env.path.output}/#{@md.fnb}" - Dir.mkdir(path) unless FileTest.directory?(path) - puts "#{path}/#{@md.fn[:book_idx_html]} #{__FILE__}::#{__LINE__}" - html_index_file=File.new("#{path}/#{@md.fn[:book_idx_html]}",'w') - idx[:html].each {|x| html_index_file << x } - html_index_file.close - end - end - def clean_and_insert_index(data,sisu_markup_idx) - tuned_file=[] - data.each do |dob| - tuned_file << dob - if dob.obj =~/#{Mx[:br_endnotes]}/ \ - and sisu_markup_idx - sisu_markup_idx.each do |idx| - tuned_file << idx - end - end - end - tuned_file - end - def clean_index(data) #check on use of dob - data.each.map do |para| - para.gsub(/\n*#{@rgx_idx}/m,'') - end - end - end -end -__END__ diff --git a/lib/sisu/current/ao_images.rb b/lib/sisu/current/ao_images.rb deleted file mode 100644 index 38fde812..00000000 --- a/lib/sisu/current/ao_images.rb +++ /dev/null @@ -1,187 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Images - class Images - begin - require 'RMagick' - include Magick - rescue LoadError - #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('RMagic NOT FOUND') - end - def initialize(md,data) - @md,@data=md,data - end - def images - data=@data - @rmgk=false - imagemagick_=true #imagemagick_=SiSU_Env::InfoSettings.new.program?('rmagick') - if imagemagick_ - begin - @rmgk=SiSU_Env::Load.new('RMagick').prog - rescue - @rmgk=false - end - else - if (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - '*WARN* use of RMagick is not enabled in sisurc.yml' - ).warn - end - end - data.select do |dob| - unless dob.is ==:table - dob.obj=dob.obj.strip - if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)(?:\s*|\s+.+)?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - if dob.obj !~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif)\s+\d+x\d+/ - m=/#{Mx[:lnk_o]}\s*(\S+\.(?:png|jpg|gif))/ - if imagemagick_ - imgs=dob.obj.scan(m).flatten - img_col=img_row=nil - images=imgs.each do |image| - dir=SiSU_Env::InfoEnv.new(@md.fns) - path_image=[ - dir.path.image_source_include_local, - dir.path.image_source_include_remote, - dir.path.image_source_include - ] - image_path=nil - path_image.each do |img_pth| - image_path=img_pth - break if FileTest.exist?("#{img_pth}/#{image}") - end - if FileTest.exist?("#{image_path}/#{image}") - if @rmgk - img=Magick::ImageList.new("#{image_path}/#{image}") - img_col,img_row=img.columns,img.rows - else - if (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - '*WARN* RMagick not present, will attempt to use imagemagick (identify) directly' - ).warn - end - imgk=SiSU_Env::SystemCall.new.imagemagick - gmgk=SiSU_Env::SystemCall.new.graphicsmagick - if imgk or gmgk - if imgk - imgsys=`identify #{image_path}/#{image}`.strip #system call - elsif gmgk - imgsys=`gm identify #{image_path}/#{image}`.strip #system call - end - img_col,img_row=/(\d+)x(\d+)/m.match(imgsys)[1,2] - img_col,img_row=img_col.to_i,img_row.to_i - else - errmsg='imagemagick or graphicsmagick are required to process images' - if @md.opt.act[:no_stop][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, proceeding (as requested) without image processing") - break - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, STOPPING") - exit - end - end - end - row=((img && defined? img.rows) ? img.rows : img_row) - col=((img && defined? img.columns) ? img.columns : img_col) - if img_col > img_row #landscape - if img_col> 640 - img_col=640 - img_row=((1.00*img_col/col)*row).round - end - else #portrait - if img_col> 640 - img_col=640 - img_row=((1.00*img_col/col)*row).round - end - if img_row > 640 - img_row=640 - img_col=((1.00*img_row/row)*col).round - end - end - dob.obj=dob.obj.gsub(/(#{image})/,"#{image} #{img_col}x#{img_row}") - else - dob.obj=dob.obj. - gsub(/#{Mx[:lnk_o]}\s*(\S+)\.(png|jpg|gif).+?#{Mx[:lnk_c]}(#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - '[ \1 (\2 missing) ]') - end - end - else - images=dob.obj.scan(m) do |image| - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - '*WARN* where image dimensions have not been provided RMagick or imagemagick is required',image - ).warn unless @md.opt.act[:quiet][:set]==:on - end - end - end - end - if dob.obj =~/#{Mx[:lnk_o]}\s*\S+\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/ - dob.obj=dob.obj.gsub(/(#{Mx[:lnk_o]})\s*(\S+\.(?:png|jpg|gif))\s+/i,'\1\2 ') - end - end - dob unless dob.nil? - end - end - end -end -__END__ -imgsys=`identify #{image_path}/#{image}`.strip diff --git a/lib/sisu/current/ao_metadata.rb b/lib/sisu/current/ao_metadata.rb deleted file mode 100644 index 46e80a7d..00000000 --- a/lib/sisu/current/ao_metadata.rb +++ /dev/null @@ -1,86 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Metadata - class Metadata - def initialize(md,metad) - @md,@metadata=md,metad - l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language - language=l[:n] - @tr=SiSU_Translate::Source.new(md,language) - end - def make_para(obj,ocn) - h={ - obj: obj, - ocn: 0 - } - SiSU_AO_DocumentStructure::ObjectPara.new.paragraph(h) - end - def make_heading(obj,ocn,name,lv,ln) - h={ - lv: lv, - ln: ln, - name: name, - obj: obj, - ocn: 0 - } - SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h) - end - def metadata - end - end -end -__END__ diff --git a/lib/sisu/current/ao_misc_arrange.rb b/lib/sisu/current/ao_misc_arrange.rb deleted file mode 100644 index d023c44f..00000000 --- a/lib/sisu/current/ao_misc_arrange.rb +++ /dev/null @@ -1,207 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_MiscArrangeText - class SI - def initialize(md,data) - @md,@data=md,data - end - def conditional_headings(para) - para=para.gsub(/^(:?A~)\s*$/,'\1~ @title @author'). #conditional header - gsub(/^((?:[1-9]|:?[A-D])~\S*)\s*$/, - '\1~ [Note: heading marker::required title missing]~#') #conditional header for incorporated document 2004w12 - if para =~/^@\S+?:/ - para=para.gsub(/^@(\S+?):(\s+|$)/, - "#{Mx[:meta_o]}\\1#{Mx[:meta_c]}\\2"). - gsub(/^@(\S+?):([+-])(\s+|$)/, - "#{Mx[:meta_o]}\\1\\2#{Mx[:meta_c]}\\3") - end - para - end - def markup_blocks(para) - def ticks(para) - block_open,block_close,text=nil,nil,nil - if para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.+?\n```(?:\s+[~-][#]|\s+\~\{.+?\}\~)?\s*\Z/m - @flag=:close - block_open,text,block_close= - /\A(```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?)\n(.+?)\n(```([ ]+[~-][#]|\s+\~\{.+?\}\~)?)\s*\Z/m. - match(para)[1..3] - ((para=~/^```[ ]+table(?:~h)?\s+/) \ - and (para !~/^```[ ]+table(?:~h)?\s+c\d+/)) \ - ? para - : (para=[]; para << block_open << text << block_close) - elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m #look at, study - @flag=:open - block_open,text=/\A(```(?:[ ]+.+?))\n(.*?)\Z/m.match(para)[1,2] - para=[] - if not text.to_s.empty? - para << block_open << text - else - para << block_open - end - elsif para =~/\A.+?\n```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(\s*=\{.+?\})?\s*\Z/m \ - and @flag==:open - @flag=:close - text,block_close= - /\A(.+?)\n(```(?:\s+\~\{.+?\}\~)?(?:\s+[~-][#])?(?:\s+=\{.+?\})?)\s*\Z/m.match(para)[1,2] - para=[] - if not text.to_s.empty? - para << text.to_s << block_close - else - para << block_close - end - else para - end - para - end - def ticks_remove(para) - unless @md.opt.act[:quiet][:set] ==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - mark("ticks not recognized, ticks removed from pargraph\n#{para}") - end - para=para.gsub(/```[ ]+\S+[ ]*/m,''). - gsub(/```\s*/m,''). - strip - end - def ticks_quote(para) - @flag=:quote_open - text=para - para=[] - if text =~ /```[ ]+quote/m - para << '`:quote_open`' - text=text.gsub(/```[ ]+quote/m,'') - end - text=if text =~/(?:\n|\A)=\{.+?\}/m #exclude book index from indent markup - txt,bkidx,tail=/(.+?)((?:\n|\A)=\{.+?\}$)(.*)/m.match(text).captures - txt=txt.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') - txt + bkidx + tail - else text.gsub(/(?:\n|\A)([^`\n]+)/m,'_1 \1') - end - para << text.gsub(/```/m,'') - if text =~/```/m - @flag=:quote_close - para << '`:quote_close`' - end - para - end - def curly_braces(para) - block_open,block_close,text=nil,nil,nil - para=if para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - block_open,text,block_close= - /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. - match(para)[1..3] - para=[] - para << block_open << text << block_close - elsif para =~/\A(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?\n.+?\Z/m - block_open,text= - /\A((?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{ .+?)\n(.+?)\Z/m. - match(para)[1,2] - para=[] - if not text.to_s.empty? - para << block_open << text - else - para << block_open - end - elsif para =~/\A.+?\n\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?\s*\Z/m - text,block_close= - /\A(.+?)\n(\}(?:code|box|poem|alt|group|block|table)(?: [~-][#])?)\s*\Z/m. - match(para)[1,2] - para=[] - if not text.to_s.empty? - para << text.to_s << block_close - else - para << block_close - end - else para - end - para - end - para=if (para =~/\A```[ ]+quote/m \ - and @flag !=:open) \ - or @flag==:quote_open - ticks_quote(para) - elsif para =~/\A```[ ]+(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table).*?\n.*?\Z/m \ - or @flag==:open - ticks(para) - elsif para =~/```/m - ticks_remove(para) - else - para - end - para=if para =~/^(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|poem|alt|group|block|table)\{|^\}(?:code|box|poem|alt|group|block|table)/m - curly_braces(para) - else - para - end - end - def prepare_text - data=@data - if data[0] =~ /^#!\s*(?:\/usr\/bin\/env sisu|\/usr\/bin\/sisu)/ # remove bang from top #! (however file is stripped, so will be removed provided no content precedes it) - data[0]=data[0].gsub(/^#!\s*\/usr\/bin\/sisu/,''). - gsub(/^#!\s*\/usr\/bin\/env sisu/,'') - end - if data[0] =~ /^(SiSU\s+[\d.]*|sisu-[\d.]+)$/ # SiSU identifier - data[0]=data[0].gsub(/^(SiSU\s*[\d.]*)$/,'% \1'). - gsub(/^(sisu-[\d.]+)$/,'% \1') - end - data.each.map do |para| - para=conditional_headings(para) - markup_blocks(para) - end.flatten - end - end -end -__END__ diff --git a/lib/sisu/current/ao_numbering.rb b/lib/sisu/current/ao_numbering.rb deleted file mode 100644 index 861bbf07..00000000 --- a/lib/sisu/current/ao_numbering.rb +++ /dev/null @@ -1,720 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Numbering - class Numbering - attr_accessor :obj,:osp,:ocn,:lv,:name,:index,:comment - @@segments_count=0 - def initialize(md,data,fnx,process) - @md,@data,@fnx,@process=md,data,fnx,process - @obj=@type=@ocn=@lv=@name=@index=@comment=nil - @chosen_seg_names=[] - end - def chosen_seg_names(chosen,chosen_seg_name,dob,md,type) - @chosen_seg_names=if chosen.compact.uniq.length \ - == chosen.compact.length - chosen - else - if md.opt.act[:maintenance][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). - mark( - "duplicated auto segment name: #{type} #{chosen}\n" \ - + "#{chosen}\n" \ - + " manually name level 1 segments '1~given_name'\n" \ - + 'filename: ' + md.fns + "\n" \ - + 'heading text: "' + dob.obj + '"' + "\n" \ - + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' - ) - end - chosen=chosen[0..-2] - chosen_seg_name=auto_numbering_exceptions(chosen,md,dob) - chosen << chosen_seg_name - end - end - def number_of_segments? - if @@segments_count==0 - @data.each do |dob| - if dob.is == :heading \ - and dob.lv == '1' - @@segments_count += 1 - end - end - @@segments_count - else @@segments_count - end - end - def numbering_song - begin - data=@data - data=number_plaintext_para(data) - data=auto_number_heading_ie_title(data.compact) #tr issue - data=ocn(data.compact) #watch - data=xml(data.compact) - data=minor_numbering(data.compact) - if @process==:complete - data,tags_map,ocn_html_seg_map=name_para_seg_filename(data) - end - data=set_heading_top(data) unless @md.set_heading_top - [data,tags_map,ocn_html_seg_map] - ensure - @@segments_count=0 - end - end - def set_tags(tags,tag) - tags=if not tag.empty? \ - and tag !~/^\d+$/ - tag=tag.gsub(/[^a-z0-9._-]/,'') - [tag,tags].flatten - else tags - end - end - def number_plaintext_para(data) - @tuned_file=[] - data.each do |dob| - if (dob.of !=:block \ - && dob.of !=:comment \ - && dob.of !=:layout) \ - && dob.ocn_ #and dob.obj !~ /#{Mx[:gr_o]}Th|#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}/ #FIX - dob.obj=dob.obj.gsub(/(.+)\n/,'\1 ') #messy, but idea is that tables should retain breaks - end - unless dob.obj.is_a?(Array) - dob.obj=dob.obj.gsub(/^\s+/,''). - gsub(/\s$/,"\n") - end - @tuned_file << dob - end - @tuned_file=@tuned_file.flatten - end - def number_sub_heading(dob,num,title_no) - unless dob.obj =~/\d+\.|(?:chapter|article|section|clause)\s+\d+/i #name selection arbitrary, fix - dob.obj=case dob.name - when /-/ then dob.obj.gsub(/^/,"#{title_no} ") - when /^#/ then dob.obj.gsub(/^/,"#{title_no} ") - when /^[a-z_\.]+/ then dob.obj.gsub(/^/,"#{title_no} ") - else - dob.name=title_no if dob.name=~/^$/ #where title contains title number - dob.obj.gsub(/^/,"#{title_no} ") if title_no =~/\d+/ #main, where title number is to be provided #watch changed placement - end - if @md.toc_lev_limit \ - and @md.toc_lev_limit < num - dob.obj=dob.obj.gsub(/^/,'!_ ') #bold line, watch - end - end - dob - end - def heading_tag_clean(heading_tag) - heading_tag=heading_tag. - gsub(/[ ]+/,'_'). - gsub(/["']/,''). - gsub(/[\/]/,'-'). - gsub(/#{Mx[:fa_bold_o]}|#{Mx[:fa_bold_c]}/,''). - gsub(/#{Mx[:fa_italics_o]}|#{Mx[:fa_italics_c]}/,''). - gsub(/#{Mx[:fa_underscore_o]}|#{Mx[:fa_underscore_c]}/,''). - gsub(/#{Mx[:fa_cite_o]}|#{Mx[:fa_cite_c]}/,''). - gsub(/#{Mx[:fa_insert_o]}|#{Mx[:fa_insert_c]}/,''). - gsub(/#{Mx[:fa_strike_o]}|#{Mx[:fa_strike_c]}/,''). - gsub(/#{Mx[:fa_superscript_o]}|#{Mx[:fa_superscript_c]}/,''). - gsub(/#{Mx[:fa_subscript_o]}|#{Mx[:fa_subscript_c]}/,''). - gsub(/#{Mx[:fa_hilite_o]}|#{Mx[:fa_hilite_c]}/,''). - gsub(/#{Mx[:gl_bullet]}/,'') - end - def auto_number_heading_ie_title(data) #also does some segment naming - if defined? @md.make.num_top \ - and @md.make.num_top \ - and @md.make.num_top !~/^$/ - input||=@md.make.num_top - end - num_top=(input ? input.to_i : nil) - t_no1=t_no2=t_no3=0 - if num_top - no1=num_top; no2=(num_top + 1); no3=(num_top + 2) - end - chapter_number_counter=0 - data=data.compact - @tuned_file=data.each.map do |dob| #@md.seg_names << [additions to segment names] - title_no=nil - if dob.is ==:heading \ - && dob.autonum_ \ - and defined? @md.make.num_top \ - and @md.make.num_top !~/^$/ - if dob.lv=='1' \ - and dob.obj =~/^#\s|\s#(?:\s|$)/ - chapter_number_counter +=1 - dob.obj=dob.obj.gsub(/^#\s/,"#{chapter_number_counter} "). - gsub(/#([:,]?\s|[.]?$)/,"#{chapter_number_counter}\\1") - end - if dob.ln==no1 - @subnumber=1 - @subnumber=0 if dob.ln==no1 - end - if dob.ln.to_s =~/^[0-6]/ \ - and not dob.use_ ==:dummy \ - and dob.obj !~/#{Mx[:fa_o]}(?:~#|-#)#{Mx[:fa_c]}/ # <-- fix - if dob.ln==no1 - t_no1+=1; t_no2=0; t_no3=0 - title_no="#{t_no1}" - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(title_no) - if dob.ln==no1 - dob.name="#{title_no}" if not dob.name - dob.tags=set_tags(dob.tags,title_no) - tag=dob.obj. - gsub(/(Article|Clause|Section|Chapter)\s+/, - "\\1_#{title_no}"). - downcase - tag=heading_tag_clean(tag) - dob.tags=set_tags(dob.tags,tag) - dob.obj=(dob.obj =~/(Article|Clause|Section)\s+/) \ - ? (dob.obj.gsub(/(Article|Clause|Section)\s+/,"\\1 #{title_no} ")) - : (dob.obj.gsub(/^/,"#{title_no}. ")) #fix stop later - end - if dob.ln !=no1 \ - and dob.obj =~/^[\d.]+\s/ #fix -> if the title starts with a numbering scheme, do not auto-number, review - dob.name ="#{title_no}" if not dob.name - dob.tags=set_tags(dob.tags,title_no) - dob.obj=dob.obj.gsub(/^/,"#{title_no}. ") - end - @md.seg_names << title_no - end - if dob.ln!=no1 \ - and dob.name!~/^[a-z_\.]+$/ \ - and dob.obj !~/[A-Z]\.?\s/ #bug -> tmp fix, excludes A. B. C. lettering, but not roman numerals, is arbitrary, review required # not fixed, work on - dob.tags=set_tags(dob.tags,title_no) - dob.obj=dob.obj.gsub(/^/i,"#{title_no}. ") - end - end - if dob.ln==no1 #watch because here you change dob.name - dob.tags=set_tags(dob.tags,"h#{title_no}") - end - if dob.ln==no2 #watch because here you change dob.name - t_no2+=1; t_no3=0 - title_no="#{t_no1}.#{t_no2}" - dob.tags=set_tags(dob.tags,"h#{title_no}") - dob=number_sub_heading(dob,no2,title_no) - end - if dob.ln==no3 #watch because here you change dob.name - t_no3+=1 - title_no="#{t_no1}.#{t_no2}.#{t_no3}" - dob.tags=set_tags(dob.tags,"h#{title_no}") - dob=number_sub_heading(dob,no3,title_no) - end - elsif dob.ln.to_s =~/^[0-6]/ \ - and dob.name =~ /^[\w-]+-/ # endnotes, watch2005# endnotes, watch2005 - dob.tags=set_tags(dob.tags,dob.name) - dob.name.gsub(/^([a-z_\.]+)-$/,'\1') - end - elsif dob.is ==:heading \ - and dob.autonum_ \ - and @md.markup =~/num_extract/ #AS DANGEROUS force enable with document, note already does this type of numbering for cisg, locate and coordinate logic, is currently misplaced in code, chengwei inspired 2004w23/4 - #here lies a bug, as is nil when run from -Dv --update, FIX - if (dob.name.nil? or dob.name.empty?) \ - and dob.ln.to_s =~/^[0-9]/ \ - and dob.obj =~ /^([\d\.]+)/ #risky (must be unique) consider output to 4~~\d instead of 4~\d - dob.name=$1 - dob.tags=set_tags(dob.tags,dob.name) - end - if @md.toc_lev_limit - end - elsif defined? dob.name \ - and dob.name - dob.tags=set_tags(dob.tags,dob.name) - end - dob.tags=dob.tags.uniq if defined? dob.tags - dob - end.flatten - end - def ocn(data) #and auto segment numbering increment - @tuned_file=SiSU_AO_DocumentStructureExtract::OCN.new(@md,data,@fnx,@process).ocn - @tuned_file - end - def xml(data) - @tuned_file=SiSU_AO_DocumentStructureExtract::XML.new(@md,data).dom - @tuned_file - end - def minor_numbering(data) #and auto segment numbering increment - number_small,letter_small=0,0 - letter=%w( a b c d e f g h i j k l m n o p q r s t u v w x y z ) - @tuned_file=data.each.map do |dob| - if dob.of ==:heading \ - || dob.of ==:heading_insert \ - || dob.of ==:para \ - || dob.of ==:block - if dob.is ==:heading \ - and dob.ln.to_s=~/^[0-9]/ #% sub-number system, (baby numbering) reset with any change of major number (more obviously should be placed in number titles, but that is conditionally executed, check and move later) - number_small,letter_small=0,0 - elsif dob.is ==:para - if dob.obj =~/^#[ 1]/ \ - and dob.obj !~/^#\s+(?:~#)?$/ - letter_small=0 - number_small=0 if dob.obj =~ /^#1/ - number_small+=1 - dob.obj=dob.obj.gsub(/^#[ 1]/,"#{number_small}. ") - end - if dob.obj =~/^_# / - dob.obj=dob.obj.gsub(/^_# /,"#{letter[letter_small]}. ") - dob.indent='1' - letter_small+=1 - end - end - end - dob - end.flatten - end - def leading_zeros_fixed_width_number(possible_seg_name) - if possible_seg_name.to_s =~/^([0-9]+?\.|[0-9]+)$/m #!~/[.,:-]+/ - possible_seg_name=possible_seg_name.to_s. - gsub(/\.$/,'') - nl=possible_seg_name.to_s.length - zero='0' - zeros_fixed_width=number_of_segments?.to_s.length - zero_width=(zeros_fixed_width - nl) - zero_width == 0 \ - ? possible_seg_name.to_s - : zero*zero_width + - possible_seg_name.to_s - end - end - def auto_numbering_exceptions(chosen_seg_names_,md,dob) - number_make=case dob.lv.to_i - when 1 - @num_exc={ - t1: @num_exc[:t1] += 1, - t2: 0, - t3: 0, - t4: 0 - } - Mx[:segname_prefix_auto_num_other] + '_' \ - + @num_exc[:t1].to_s - when 2 - @num_exc={ - t1: @num_exc[:t1], - t2: @num_exc[:t2] += 1, - t3: 0, - t4: 0 - } - Mx[:segname_prefix_auto_num_other] + '_' \ - + @num_exc[:t1].to_s + '_' \ - + @num_exc[:t2].to_s - when 3 - @num_exc={ - t1: @num_exc[:t1], - t2: @num_exc[:t2], - t3: @num_exc[:t3] += 1, - t4: 0 - } - Mx[:segname_prefix_auto_num_other] + '_' \ - + @num_exc[:t1].to_s + '_' \ - + @num_exc[:t2].to_s + '_' \ - + @num_exc[:t3].to_s - when 4 - @num_exc[:t4] += 1 - @num_exc={ - t1: @num_exc[:t1], - t2: @num_exc[:t2], - t3: @num_exc[:t3], - t4: @num_exc[:t4] += 1 - } - Mx[:segname_prefix_auto_num_other] + '_' \ - + @num_exc[:t1].to_s + '_' \ - + @num_exc[:t2].to_s + '_' \ - + @num_exc[:t3].to_s + '_' \ - + @num_exc[:t4].to_s - end - end - def check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,type,md,dob) - begin - chosen_seg_names_ << chosen_seg_name - chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) - if chosen_seg_names_.compact.uniq.length \ - == chosen_seg_names_.compact.length - #check that all auto given seg names are unique - chosen_seg_names_=chosen_seg_names(chosen_seg_names_,chosen_seg_name,dob,md,type) - chosen_seg_name - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green). - mark( - "duplicated auto segment name: #{type} #{chosen_seg_name}\n" \ - + "#{chosen_seg_names_}\n" \ - + " manually name level 1 segments '1~given_name'\n" \ - + 'filename: ' + md.fns + "\n" \ - + 'heading text: "' + dob.obj + '"' + "\n" \ - + 'duplication: "' + chosen_seg_name + '" (level: ' + dob.lv + '; numbering type: ' + type.to_s + ')' - ) - chosen_seg_name=auto_numbering_exceptions(chosen_seg_names_,md,dob) - check_that_seg_names_are_unique(chosen_seg_names_,chosen_seg_name,:exception,md,dob) - end - rescue - end - end - def auto_seg_name(possible_seg_name,heading_num_is,dob,type) - prefix=case type - when :auto then Mx[:segname_prefix_auto_num_provide] - when :extract then Mx[:segname_prefix_auto_num_extract] - else '_'*dob.lv.to_i #should not occur - end - if possible_seg_name =~/^[0-9]+?\.$/m #!~/[.,:-]+/ - possible_seg_name=possible_seg_name. - gsub(/\.$/,'') - end - @chosen_seg_name= - if dob.lv=='4' \ - and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){3}/m - possible_seg_name=possible_seg_name.to_s. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - prefix + possible_seg_name - elsif dob.lv=='3' \ - and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){2}/m - possible_seg_name=possible_seg_name.to_s. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - prefix + possible_seg_name - elsif dob.lv=='2' \ - and possible_seg_name.to_s =~/^[0-9]+(?:[.,:-][0-9]){1}/m - possible_seg_name=possible_seg_name.to_s. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - prefix + possible_seg_name - elsif dob.lv=='1' \ - and possible_seg_name.to_s =~/^[0-9]+[:,-]?$/m - if possible_seg_name.to_i <= heading_num_is.to_i - prefix + leading_zeros_fixed_width_number(possible_seg_name) - else - possible_seg_name=possible_seg_name.to_s. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - prefix + possible_seg_name - end - else - @chosen_seg_name=auto_numbering_exceptions(@chosen_seg_names,md,dob) - end - check_that_seg_names_are_unique(@chosen_seg_names,@chosen_seg_name,type,@md,dob) - end - def set_name_and_tags(dob,possible_seg_name) - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - elsif (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts 'warn, there may be a conflicting numbering scheme' - end - end - def name_para_seg_filename(data) #segment naming, remaining - # paragraph name/numbering rules - # manual naming overrides, manual naming may be - # alpha-numeric characters mixed, - # numeric only (a number), if - # all segments have been named, - # the numbers used are over 1000 or - # it is not minded that auto-numbering uses a funny scheme for naming segments (not yet implemented) - # [for now a warning is printed for such documents on use of maintenance or very-verbose flag] - # auto-naming takes the form of giving numbers to segments - # the rules for which are as follows - # if the title/heading text starts with a numeric, then that is used (1 3.1 3rd etc.) - # otherwise the level 4 segment number from the embedded document structure info is used - # if there is none a sequential number is designated, preceded by an underscore - @tuned_file,@unique_auto_name=[],[] - tags={} - @art_filename_auto=0 - @counter=1 - if not @md.seg_autoname_safe \ - and (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - puts 'manual segment names, numbers used as names, risk warning (segmented html)' - end - ocn_html_seg=[] - @num_exc={ t1: 0, t2: 0, t3: 0, t4: 0 } - data.each do |dob| - if dob.is==:heading \ - && dob.ln \ - and dob.ln.to_s =~/^[4-7]/ - heading_num_is=/^\d+:(\d+);\d/m.match(dob.node)[1] - if dob.ln==4 \ - and not dob.name \ - and not @md.set_heading_seg - @md.set_heading_seg=true - end - if dob.name !~/^\S+/ \ - and dob.ln.to_s =~/^[5-7]/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9])+)/m - #heading starts with a recognised numeric - #or word followed by a recognised numeric construct, - #use that as name - if dob.ln==7 \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){3})/m - possible_seg_name=$1. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - set_name_and_tags(dob,possible_seg_name) - elsif dob.ln==6 \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){2})/m - possible_seg_name=$1. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - set_name_and_tags(dob,possible_seg_name) - elsif dob.ln==5 \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+(?:[.,:-][0-9]){1})/m - possible_seg_name=$1. - gsub(/(?:[:,-]|\W)/,'.'). - gsub(/\.$/,'') - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - set_name_and_tags(dob,possible_seg_name) - end - end - if dob.ln==4 - if dob.name !~/^\S+/ \ - and dob.obj =~/^\s*(?:\S+\s+)?([0-9]+)/m - #heading starts with a recognised numeric - #or word followed by a recognised numeric construct, - #use that as name - possible_seg_name=$1 - possible_seg_name= - auto_seg_name(possible_seg_name,heading_num_is,dob,:extract) - set_name_and_tags(dob,possible_seg_name) - end - if dob.name - #extract segment name from embedded document structure info - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(dob.name) - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << dob.name - end - else - #if no segment name, - #provide a numerical one - @art_filename_auto+=1 - possible_seg_name= - auto_seg_name(@art_filename_auto,heading_num_is,dob,:auto) - if @md.seg_names.is_a?(Array) \ - and not @md.seg_names.include?(possible_seg_name) - dob.name=possible_seg_name - dob.tags=set_tags(dob.tags,dob.name) - @md.seg_names << possible_seg_name - else puts 'segment name (numbering) error' - end - end - if not dob.name #should not occur - puts "e r r o r -\t#{__FILE__}::#{__LINE__}\n#{dob.inspect}" - end - end - end - if (dob.is ==:heading \ - || dob.is ==:heading_insert) \ - && dob.ln==4 - @seg=dob.name - end - @tuned_file << if dob.is==:heading \ - && (@md.pagenew || @md.pagebreak || @md.pageline) - m=dob.ln.to_s - dob_tmp=[] - if @md.pagenew.inspect =~/#{m}/ - dob_tmp << - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_new]) << - dob - elsif @md.pagebreak.inspect =~/#{m}/ - dob_tmp << - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page]) << - dob - elsif @md.pageline.inspect =~/#{m}/ - dob_tmp << - SiSU_AO_DocumentStructure::ObjectLayout.new.break(Hx[:br_page_line]) << - dob - end - unless dob_tmp.length > 0; dob - else dob_tmp - end - else dob - end - if defined? dob.ocn \ - and dob.ocn - @segname=((dob.is==:heading || dob.is==:heading_insert) && dob.ln==4 && (defined? dob.name)) \ - ? (dob.name) - : @segname - tags["#{dob.ocn}"]={ segname: @segname } - ocn_html_seg[dob.ocn]=if (dob.is==:heading || dob.is==:heading_insert) - if dob.ln =~/[0-3]/ - { - seg: nil, - level: dob.ln, - } - #elsif dob.ln =~/[4-6]/ - else - { - seg: @seg, - level: dob.ln, - } - end - else - { - seg: @seg, - level: nil, - } - end - end - dob.tags=dob.tags.uniq if defined? dob.tags - if defined? dob.tags \ - and dob.tags.length > 0 - #@segname=((dob.is=='heading'|| dob.is=='heading_insert') && dob.ln==4 && (defined? dob.name)) \ - #? (dob.name) \ - #: @segname - dob.tags.each do |y| - tags[y]={ ocn: dob.ocn.to_s, segname: @segname } - end - end - dob - end - ocn_html_seg.each_with_index do |ocn,i| - if ocn \ - and ocn[:level].to_s=~/[1-3]/ - (1..4).each do |x| - if ocn_html_seg[i+x] \ - and ocn_html_seg[i+x][:level]==4 - ocn[:seg]=ocn_html_seg[i+x][:seg] - end - end - end - end - if @md.seg_names.length > 0 - @md.set_heading_seg=true - end - tuned_file=@tuned_file.flatten - [tuned_file,tags,ocn_html_seg] - end - def set_heading_top(data) #% make sure no false positives - unless @md.set_heading_top - if (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts "\tdocument contains no top level heading, (will have to manufacture one)" - end - @tuned_file=[] - data.each do |t_o| - unless @md.set_heading_top - if t_o !~/^(?:#{Rx[:meta]}|@\S+:)\s/m \ - and t_o !~/\A\s*\Z/m - @md.set_heading_top=true - if defined? @md.title \ - and @md.title \ - and defined? @md.title.full \ - and defined? @md.creator \ - and @md.creator - head=@md.title.main \ - ? ([@lv='1',@obj=@md.title.main]) - : ([@lv='1',@obj='[no title provided]']) - @tuned_file << head - end - end - end - @tuned_file << t_o - end - @tuned_file=@tuned_file.flatten - end - end - def set_heading_seg(data) #% make sure no false positives - unless @md.set_heading_seg - if (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts "\tdocument contains no segment level, (will have to manufacture one)" - end - @tuned_file=[] - data.each do |dob| - unless @md.set_heading_seg - if defined? dob.ln and dob.ln.to_s !~/^[0-3]/m \ - and dob.obj !~/\A\s*\Z/m \ - and dob.is !=:layout - @md.set_heading_seg=true - head=@md.title.main \ - ? (dob.ln,dob.name,dob.obj=4,'seg',@md.title.main) - : (dob.ln,dob.name,dob.obj=4,'seg','[segment]') - @tuned_file << head - end - end - @tuned_file << dob - end - @tuned_file=@tuned_file.flatten - end - end - def set_header_title(data) #% make sure no false positives - unless @md.set_header_title - if (@md.opt.act[:verbose_plus][:set]==:on \ - or @md.opt.act[:maintenance][:set]==:on) - puts "\t no document title provided, (will have to manufacture one)" - end - @tuned_file=[] - data.each do |t_o| - unless @md.set_header_title - if t_o !~/^%{1,2}\s/m \ - and t_o !~/\A\s*\Z/m - @tuned_file << - "#{Mx[:meta_o]}title#{Mx[:meta_c]} #{@md.heading_seg_first}" - @md.title.main=@md.heading_seg_first - @md.set_header_title=true - end - end - @tuned_file << t_o - end - @tuned_file=@tuned_file.flatten - end - end - end -end -__END__ diff --git a/lib/sisu/current/ao_persist.rb b/lib/sisu/current/ao_persist.rb deleted file mode 100644 index 72126c90..00000000 --- a/lib/sisu/current/ao_persist.rb +++ /dev/null @@ -1,194 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document abstraction - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_Persist - class Persist - @@persistance=nil - attr_accessor :fns, :ao_arr, :idx_arr_sst, :idx_arr_tex, :idx_arr_html, :idx_arr_xhtml, :map_arr_nametags, :map_arr_ocn_htmlseg - def initialize(args=nil) - @@persistance=args=(args ? args : (@@persistance || persist_init_hash_values)) - @fns=args[:fns] - @ao_arr=args[:ao_arr] - @idx_arr_sst=args[:idx_arr_sst] - @idx_arr_tex=args[:idx_arr_tex] - @idx_arr_html=args[:idx_arr_html] - @idx_arr_xhtml=args[:idx_arr_xhtml] - @map_arr_nametags=args[:map_arr_nametags] - @map_arr_ocn_htmlseg=args[:map_arr_ocn_htmlseg] - end - def fns - @fns - end - def ao_arr - @ao_arr - end - def idx_arr_sst - @idx_arr_sst - end - def idx_arr_tex - @idx_arr_tex - end - def idx_arr_html - @idx_arr_html - end - def idx_arr_xhtml - @idx_arr_xhtml - end - def map_arr_nametags - @map_arr_nametags - end - def map_arr_ocn_htmlseg - @map_arr_ocn_htmlseg - end - def persist_init_hash_values - { - fns: nil, - ao_arr: [], - idx_arr_sst: [], - idx_arr_tex: [], - idx_arr_html: [], - idx_arr_xhtml: [], - map_arr_nametags: [], - map_arr_ocn_htmlseg: [], - } - end - def persist_init - @@persistance=nil - Persist.new(persist_init_hash_values) - end - end - class PersistDocStructExt - @@persist=nil - attr_accessor :ocn, :lng, :lng_is, :code, :lngsyn, :poem, :block, :box, :group, :alt, :quote, :table, :table_to - def initialize(args=nil) - @@persist=args=(args ? args : (@@persist || persist_init_hash_values)) - @ocn=args[:ocn] - @lng=args[:lng] - @lng_is=args[:lng_is] - @code=args[:code] - @lngsyn=args[:lngsyn] - @poem=args[:poem] - @block=args[:block] - @box=args[:box] - @group=args[:group] - @alt=args[:alt] - @quote=args[:quote] - @table=args[:table] - @table_to=args[:table_to] - end - def ocn - @ocn - end - def lng - @lng - end - def lng_is - @lng_is - end - def code - @code - end - def lngsyn - @lngsyn - end - def poem - @poem - end - def block - @block - end - def box - @box - end - def group - @group - end - def alt - @alt - end - def quote - @quote - end - def table - @table - end - def table_to - @table_to - end - def persist_init_hash_values - { - ocn: :on, - lng: :off, - lng_is: :doc_default, - code: :off, - lngsyn: :txt, - poem: :off, - block: :off, - box: :off, - group: :off, - alt: :off, - quote: :off, - table: :off, - table_to: :off, - } - end - def persist_init - @@persist=nil - PersistDocStructExt.new(persist_init_hash_values) - end - end -end -__END__ diff --git a/lib/sisu/current/ao_references.rb b/lib/sisu/current/ao_references.rb deleted file mode 100644 index 9a5e195b..00000000 --- a/lib/sisu/current/ao_references.rb +++ /dev/null @@ -1,502 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_AO_References - class Bibliography - def initialize(md,data) - @md,@data=md,data - end - def sort_bibliography_array_by_author_year_title(bib) - if bib - bib.compact.sort_by do |c| - [c[:author_arr][0],c[:year],c[:title]] - end - end - end - def citation_in_prepared_bibliography(cite) - @cite=cite - def article - { - is: :article, - author_raw: nil, - author: nil, - author_arr: nil, - title: nil, - language: nil, - journal: nil, - volume: nil, - editor: nil, - year: nil, - where: nil, - url: nil, - note: nil, - short_name: nil, - id: nil, - } - end - def book - { - is: :book, - author_raw: nil, - author: nil, - author_arr: nil, - #editor: nil, - title: nil, - subtitle: nil, - fulltitle: nil, - language: nil, - publisher: nil, - edition: nil, - year: nil, - where: nil, - url: nil, - note: nil, - short_name: nil, - id: nil, - } - end - def citation_metadata - type=if @cite =~/^jo: \S+/m - :article - elsif @cite =~/^au: \S+/m - :book - end - if type - citeblock=@cite.split("\n") - if type == :article - citation=article - citeblock.select do |meta| - case meta - when /^((?:au|author):\s+)\S+/ #req - citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:ti|title):\s+)\S+/ #req - citation[:title]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:lng|language):\s+)\S+/ - citation[:language]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:jo|journal):\s+)\S+/ #req? - citation[:journal]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:vo|volume):\s+)\S+/ - citation[:volume]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:edr|editor):\s+)\S+/ - citation[:editor]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:yr|year):\s+)\S+/ #req? - citation[:year]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:pst|publisher_state):\s+)\S+/ - citation[:where]=/^#{$1}(.+)/.match(meta)[1] - when /^(url:\s+)\S+/ - citation[:url]=/^#{$1}(.+)/.match(meta)[1] - when /^(note:\s+)\S+/ - citation[:note]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:sn|shortname):\s+)\S+/ - citation[:short_name]=/^#{$1}(.+)/.match(meta)[1] - when /^(id:\s+)\S+/ - citation[:id]=/^#{$1}(.+)/.match(meta)[1] - end - end - end - if type == :book - citation=book - citeblock.select do |meta| - case meta - when /^((?:au|author):\s+)\S+/ #req - citation[:author_raw]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:ti|title):\s+)\S+/ #req - citation[:title]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:st|subtitle):\s+)\S+/ - citation[:subtitle]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:lng|language):\s+)\S+/ - citation[:language]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:pb|publisher):\s+)\S+/ - citation[:publisher]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:edn|edition):\s+)\S+/ - citation[:edition]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:yr|year):\s+)\S+/ #req? - citation[:year]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:pst|publisher_state):\s+)\S+/ - citation[:where]=/^#{$1}(.+)/.match(meta)[1] - when /^(url:\s+)\S+/ - citation[:url]=/^#{$1}(.+)/.match(meta)[1] - when /^(note:\s+)\S+/ - citation[:note]=/^#{$1}(.+)/.match(meta)[1] - when /^((?:sn|shortname):\s+)\S+/ - citation[:short_name]=/^#{$1}(.+)/.match(meta)[1] - when /^(id:\s+)\S+/ - citation[:id]=/^#{$1}(.+)/.match(meta)[1] - end - end - end - if citation[:is]==:book - if citation[:subtitle] - citation[:fulltitle] = citation[:title] \ - + ' - ' \ - + citation[:subtitle] - else - citation[:fulltitle] = citation[:title] - end - end - citation[:author_arr]=citation[:author_raw].split(/;\s*/) - citation[:author]=citation[:author_arr].map do |author| - author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip - end.join(', ').strip - unless citation[:short_name] - citation[:short_name]=%{#{c[:author]}, "#{c[:short_name]}" (#{c[:date]})} - end - end - citation - end - self - end - def biblio_extraction - bibliography=[] - biblioflag=false - code_flag=false - flag_code_curly=:not_code_curly - flag_code_tics=:not_code_tics - @data=@data.select do |t_o| - if t_o =~/^code\{/ - flag_code_curly=:code_curly - elsif t_o =~/^\}code/ - flag_code_curly=:not_code_curly - elsif t_o =~/^``` code/ - flag_code_tics=:code_tics - elsif flag_code_tics ==:code_tics \ - and t_o =~/^```/ - flag_code_tics=:not_code_tics - end - code_flag=if flag_code_curly==:code_curly \ - or flag_code_tics==:code_tics - true - else false - end - unless code_flag - if @md.flag_auto_biblio - if t_o =~/^1~biblio(?:graphy)?/ - biblioflag = true - t_o - elsif t_o =~/^:?[B-D1]~/ - biblioflag = false - t_o - elsif biblioflag - if t_o !~/\A%+ / - bibliography << citation_in_prepared_bibliography(t_o).citation_metadata - next - else - t_o - end - else t_o - end - elsif @md.flag_biblio - if t_o =~/^1~biblio(?:graphy)?/ - biblioflag = true - next - elsif t_o =~/^:?[B-D]~/ - next - elsif t_o =~/^:?[B-D1]~/ - biblioflag = false - t_o - elsif biblioflag - if t_o !~/\A%+ / - bibliography << t_o - next - else - t_o - end - else t_o - end - else t_o - end - else t_o - end - end.compact - if @md.flag_auto_biblio \ - and bibliography.length > 0 - data_new=[] - bibliography=sort_bibliography_array_by_author_year_title(bibliography) - @data.select do |t_o| - if t_o =~/^1~biblio(?:graphy)?/ - bibliography.each do |c| - if c[:is]==:book - <<-WOK - -!_ #{c[:author]} -/{"#{c[:fulltitle]}"}/ #{c[:publisher]} (#{c[:year]}) - WOK - elsif c[:is]==:article - <<-WOK - -!_ #{c[:author]} -/{"#{c[:title]}"}/ #{c[:journal]} (#{c[:year]}) - WOK - end - end - else data_new << t_o - end - end - @data=data_new - end - [@data,bibliography] - end - end - class Citations - def initialize(md='',data='') - @md,@data=md,data - #@biblio=[] - end - def songsheet - tuned_file,citations=citations_scan(@data) - [tuned_file,citations] - end - def sort_bibliography_array_by_author_year(bib) - bib.sort_by do |c| - [c[:author_raw],c[:year]] - #[c[:author_arr][0],c[:year],c[:title]] - end - end - def citations_regex - def pages_pattern - %r{(?:[,.:]?\s+(?:p{1,2}\.?\s+)?(?:\d+--?\d+)[,.]?\s+)?} - end - def editor_pattern - %r{(?(?:editor|edited by)\s+.+?)} - end - def year_pattern - %r{[(\[]?(?\d{4})[\])]?[.,]?} - end - def authors_year_title_publication_editor_pages - /(?.+?)\s+#{year_pattern}\s+"(?.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor - end - def authors_title_publication_year_editor_pages - /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{editor_pattern}#{pages_pattern}/m # note ed. is usually edition rather than editor - end - def authors_title_publication_editor_year_pages ### - /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+ed.\s+#{editor_pattern}#{year_pattern}#{pages_pattern}/m - # note ed. is usually edition rather than editor - end - def authors_title_publication_editor_pages_year ### - /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{editor_pattern}#{pages_pattern}#{year_pattern}/m # note ed. is usually edition rather than editor - end - def authors_year_title_publication_pages - /(?<authors>.+?)\s+#{year_pattern}\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?#{pages_pattern}/m - end - def authors_title_publication_year_pages - /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})\s+#{year_pattern}\s+#{pages_pattern}/m - end - def authors_title_publication_pages_year ### - /(?<authors>.+?)\s+"(?<title>.+?)"\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}#{year_pattern}/m - end - def authors_year_publication_pages - /(?<authors>.+?)\s+#{year_pattern}\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})#{pages_pattern}/m - end - def authors_publication_year_pages - /(?<authors>.+?)\s+(?:#{Mx[:fa_italics_o]}|#{Mx[:srcrgx_italics_o]})(?<publication>.+?)(?:#{Mx[:fa_italics_c]}|#{Mx[:srcrgx_italics_c]})[,.;]?\s+(?<publisher>.+?)?#{year_pattern}#{pages_pattern}[.;]?/m - end - self - end - def authors?(citations) - citations.each.map do |b| - if b =~ /^.+\s+::.+?:$/ - c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b) - { - citation: c[:citation], - shortref: c[:shortref], - c[:shortref].to_s => c[:citation] - } - else { citation: b } - end - end - end - def long_and_short_ref?(citations) #could be useful, keep ... ectract shortref - citations.each.map do |b| - if b =~ /^.+\s+::.+?:$/ - c=/^(?<citation>.+?)\s+::(?<shortref>.+?):$/.match(b) - { - citation: c[:citation], - shortref: c[:shortref], - c[:shortref].to_s => c[:citation] - } - else { citation: b } - end - end - end - def citation_detail(citations) #could be useful, keep ... extract shortref - bibahash=[] - number=0 - missed=0 - citations.select do |b| - z=if b =~citations_regex.authors_year_title_publication_editor_pages - c=citations_regex.authors_year_title_publication_editor_pages.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - editor: c[:editor], - } - elsif b =~citations_regex.authors_title_publication_year_editor_pages - c=citations_regex.authors_title_publication_year_editor_pages.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - editor: c[:editor], - } - elsif b =~citations_regex.authors_title_publication_editor_year_pages - c=citations_regex.authors_title_publication_editor_year_pages.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - editor: c[:editor], - } - elsif b =~citations_regex.authors_title_publication_editor_pages_year - c=citations_regex.authors_title_publication_editor_pages_year.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - editor: c[:editor], - } - elsif b =~citations_regex.authors_year_title_publication_pages - c=citations_regex.authors_year_title_publication_pages.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - } - elsif b =~citations_regex.authors_title_publication_year_pages - c=citations_regex.authors_title_publication_year_pages.match(b) - { - is: :article, - author_raw: c[:authors], - year: c[:year], - title: c[:title], - publication: c[:publication], - } - elsif b =~citations_regex.authors_year_publication_pages - c=citations_regex.authors_year_publication_pages.match(b) - { - is: :book, - author_raw: c[:authors], - year: c[:year], - publication: c[:publication], - } - elsif b =~citations_regex.authors_publication_year_pages - c=citations_regex.authors_publication_year_pages.match(b) - { - is: :book, - author_raw: c[:authors], - year: c[:year], - publication: c[:publication], - } - else b - end - if not z.is_a?(NilClass) \ - and z.is_a?(Hash) \ - and z[:author_raw].length > 0 - z[:author_arr]=z[:author_raw].split(/;\s*/) - z[:author]=z[:author_arr].map do |author| - author.gsub(/(.+?),\s+(.+)/,'\2 \1').strip - end.join(', ').strip - if @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on - number +=1 if z.is_a?(Hash) - missed +=1 if z.is_a?(String) - (z.is_a?(Hash)) \ - ? (p '[' + number.to_s + '] ' + z.to_s) - : (p '<' + missed.to_s + '> ' + z.to_s) - end - end - bibahash << z if z.is_a?(Hash) - end - bibahash=sort_bibliography_array_by_author_year(bibahash.compact) - bibahash - end - def citations_scan(data) - citations=[] - #short_ref=[] - tuned_file = data.compact.select do |dob| - if dob.is !=:meta \ - && dob.is !=:comment \ - && dob.is !=:code \ - && dob.is !=:table - if dob.obj =~/\.:.+?:\./ - citations << dob.obj.scan(/\.:\s*(.+?)\s*:\./m) - #short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::([^:]+)::\./m) #look at later - ##short_ref << dob.obj.scan(/\.:\s+(.+?)\s+::(.+?)::\./m) #look at later - #short_ref << dob.obj.scan(/\.:\s*(.+?)\s*(::(.+?):)?:\./m) #look at later - citations=citations.flatten.compact - dob.obj=dob.obj. #remove citations delimiter & helpers from text - gsub(/\.:|:\./,'') - end - end - dob if dob.is_a?(Object) - end - #bib=long_and_short_ref?(citations) #could be useful, keep ... extract shortref - citations=citation_detail(citations) - [tuned_file,citations] - end - end -end -__END__ diff --git a/lib/sisu/current/ao_syntax.rb b/lib/sisu/current/ao_syntax.rb deleted file mode 100644 index c3108668..00000000 --- a/lib/sisu/current/ao_syntax.rb +++ /dev/null @@ -1,640 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** Syntax for markup, input markup syntaxes, determined here - -** Author: Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - -** Git - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/ao_syntax.rb;hb=HEAD> - -=end -module SiSU_AO_Syntax - class Words - def initialize(line,md,mkp) - @line,@md,@mkp=line,md,mkp - end - end - class Markup - def initialize(md='',data='',biblio=[]) - @md,@data,@bibliography=md,data,biblio - @data_new=[] - url_and_stub=SiSU_Env::InfoEnv.new.url - @output_url="#{url_and_stub.remote}" - @env=SiSU_Env::InfoEnv.new - emph_set=if defined? @md.emphasis_set_to \ - and not @md.emphasis_set_to.nil? - @md.emphasis_set_to - else @env.markup_emphasis - end - @emph=case emph_set - when /bold/ - emph_italics=false - { o: Mx[:fa_bold_o], c: Mx[:fa_bold_c] } - when /italics/ - emph_italics=true - { o: Mx[:fa_italics_o], c: Mx[:fa_italics_c] } - when /underscore/ - emph_italics=false - { o: Mx[:fa_underscore_o], c: Mx[:fa_underscore_c] } - else p __LINE__.to_s + '::' + __FILE__ - end - @http_m=%r{\{.+?\}https?://\S+|https?:\S+|:\S+|\.\.\/\S+|#\S+|\S+?\.png\b|[*]~\S+|^#{Mx[:meta_o]}.+|#{Mx[:gr_o]}(?:code(?:\.[a-z][0-9a-z_]+)?|box(?:\.[a-z_]+)?|block|group|alt|verse)(?:-end)?#{Mx[:gr_c]}|#{Mx[:fa_o]}:br#{Mx[:fa_c]}} - @manmkp_ital=emph_italics \ - ? '[i/*]\\{.+?\\}[i/*]' - : '[i/]\\{.+?\\}[i/]' - tail_m_ital=%q{(?:\s|'s\b|[.,;:?!'")]|~\^|~\\\{\s|$)} - tail_m_bold=%{(?:(?:#{Mx[:fa_italics_c]})?(?:\s|'s\b|[.,;:?!'")]|~\^|~\\\{\s|$))?} - bold_line=%{^!_\s.+?(?:#{Mx[:br_line]}|\n|$)} - #ital_line=%{^/_\s.+?(?:#{Mx[:br_line]}|\n|$)} #not implemented - @line_scan_ital=if defined? @md.italics_match_list[:str] - /#{@http_m}|#{bold_line}|#{@manmkp_ital}#{tail_m_ital}|#{@md.italics_match_list[:str]}#{tail_m_ital}|\S+|\n/i - end - @manmkp_bold=emph_italics \ - ? '^!_\s.+?(?:\n|$)|[!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[!]' - : '^!_\s.+?(?:\n|$)|[*!b]\\{.+?\\}[*!b]|[*!][a-zA-Z0-9\-_]+[*!]' - @line_scan_bold=if defined? @md.bold_match_list[:str] \ - and @md.bold_match_list[:str] - /#{@http_m}|#{bold_line}|(?:#{@manmkp_bold}|#{@md.bold_match_list[:str]})#{tail_m_bold}|\S+|\n/i - end - end - def songsheet - @data=@data.compact - @data.each do |dob| - dob=breaks(dob) - dob=if @md.sem_tag then sem(dob) else dob end #revisit - dob=line_actions(dob) - dob=paragraph_set(dob) - dob=substitutions(dob) - dob=wordlist_italics(dob) - dob=wordlist_bold(dob) - dob=bodymarkup(dob) - @data_new << dob unless dob.nil? - end - @data_new - end - def sem(dob) #revisit - dob=SiSU_Sem::Tags.new(dob,@md).rm.all - end - def breaks(dob) - if dob.is !=:meta \ - && dob.is !=:comment \ - && dob.is !=:code \ - && dob.is !=:table - dob.obj=dob.obj. - gsub(/^-\\\\-\s*$/,"#{Mx[:br_page]}"). - gsub(/^=\\\\=\s*$/,"#{Mx[:br_page_new]}"). - gsub(/ \\\\(?: |$)/,"#{Mx[:br_line]}"). - gsub(/(?:<:?pb>)/,"#{Mx[:br_page]}"). # depreciated - gsub(/(?:<:?pn>)/,"#{Mx[:br_page_new]}"). # depreciated - gsub(/(?:<:?br>|<br \/>)/,"#{Mx[:br_line]}"). # depreciated - gsub(/(?:^-\.\.-\s*$)/,"#{Mx[:br_page_line]}") - end - dob - end - def wordlist_italics(dob) - dob=dob.dup - if (defined? @md.italics_match_list[:str] \ - and @md.italics_match_list[:str]) - dob.obj=if dob.is !=:meta \ - && dob.is !=:heading \ - && dob.is !=:heading_insert \ - && dob.is !=:code \ - && dob.is !=:layout \ - && dob.is !=:comment - word=dob.obj.scan(@line_scan_ital) - word=word.flatten.compact - line_array=[] - word.each do |w| - unless /#{@manmkp_ital}|#{@http_m}/.match(w) - if defined? @md.italics_match_list[:regx] \ - and @md.italics_match_list[:regx] - w=w.gsub(@md.italics_match_list[:regx], - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") - else w - end - end - line_array << w - end - line_array.join(' ') - else dob.obj - end - end - dob - end - def embolden(given) - given=given. - gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}\\2"). - gsub(/^!_\s+((?:\{|#{Mx[:lnk_o]})(?:~^ )?.+?(?:\}|#{Mx[:lnk_o]})https?:\/\/\S+.*)/, - "#{Mx[:fa_bold_o]} \\1 #{Mx[:fa_bold_c]}"). - gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). - gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). - gsub(/(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}\\2"). - gsub(/(?:^!_\s+|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]}\s*)(.*)?\s*$/, - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") - end - def italicise(given) - given=given. - gsub(/^\/_\s*(.+?)([#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}])/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). - gsub(/^\/_\s*(.+?)\s+((?:[*]~\S+\s*)+)/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). - gsub(/^\/_\s*(.+?)\s*([~-]#)$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}\\2"). - gsub(/^\/_\s+(.*)?\s*$/, - "#{Mx[:fa_italics_o]}\\1#{Mx[:fa_italics_c]}") - end - def line_actions(dob) - dob.obj=if (dob.is !=:heading \ - && dob.is !=:heading_insert \ - && dob.is !=:comment \ - && dob.is !=:meta) \ - and dob.obj =~ /^!_\s+/ - embolden(dob.obj) - elsif dob.obj =~ /^\/_\s+/ - italicise(dob.obj) - else dob.obj - end - dob - end - def paragraph_set(dob) - dob.obj=if dob.is !=:meta \ - && dob.is !=:heading \ - && dob.is !=:heading_insert \ - && dob.is !=:code \ - && dob.is !=:comment \ - && dob.is !=:table - dob.obj.gsub(/\n/m,' '). - gsub(/ \s+/m,' ') - else dob.obj - end - dob - end - def substitutions(dob) - dob=dob.dup - dob=if @md.flag_auto_biblio \ - and @bibliography.length > 0 - dob=if dob.is !=:meta \ - && dob.is !=:heading_insert \ - && dob.is !=:code \ - && dob.is !=:comment \ - && dob.is !=:table - @bibliography.each do |c| - if c[:id] and not c[:id].nil? and not c[:id].empty? - dob.obj=dob.obj.gsub(/#{c[:id]}/mi,c[:short_name]) - end - end - dob - else dob - end - dob - else dob - end - dob=if defined? @md.substitution_match_list[:match_and_replace] \ - and @md.substitution_match_list[:match_and_replace].is_a?(Array) - dob=if dob.is !=:meta \ - && dob.is !=:heading_insert \ - && dob.is !=:code \ - && dob.is !=:comment \ - && dob.is !=:table - if dob.obj =~/#{@md.substitution_match_list[:matches]}/ - @md.substitution_match_list[:match_and_replace].each do |x| - dob.obj=if x[:case_s]==:i - dob.obj.gsub(/#{x[:match]}/mi,x[:replace]) - else - dob.obj.gsub(/#{x[:match]}/m,x[:replace]) - end - end - end - dob - else dob - end - dob - else dob - end - end - def wordlist_bold(dob) - dob=dob.dup - if (defined? @md.bold_match_list[:str] \ - and @md.bold_match_list[:str]) - dob.obj=if dob.is !=:meta \ - && dob.is !=:heading \ - && dob.is !=:heading_insert \ - && dob.is !=:code \ - && dob.is !=:comment \ - && dob.is !=:table - line_array=[] - word=dob.obj.scan(@line_scan_bold) - word=word.flatten.compact - word.each do |w| - unless /#{@manmkp_bold}|#{@http_m}/.match(w) - if defined? @md.bold_match_list[:regx] \ - and @md.bold_match_list[:regx] #document header: @bold: [bold word list] - w=w.gsub(@md.bold_match_list[:regx], - "#{Mx[:fa_bold_o]}\\1#{Mx[:fa_bold_c]}") - end - else - w=if w =~ /(?:^!_|^#{Mx[:lv_o]}[7-9]:\S*?#{Mx[:lv_c]})\s+/ - embolden(w) #bold paragraph/emphasize #may wish to remove think about 7{ 8{ conversion not satisfactory, as information is lost! - elsif w =~/^\/_\s+/ - italicise(w) - else w - end - end - line_array << w - end - line_array.join(' ') - else dob.obj - end - else - dob.obj=if dob.is==:heading \ - and dob.ln.to_s =~/[7-9]/ - embolden(dob.obj) - else dob.obj - end - end - dob - end - def fontface_lines(dob,leader) - while (dob.obj =~/#{Mx[:br_nl]}/ \ - and dob.obj =~/(?:#{leader})([*!\/_#])\{(.+?)\}\1/m) \ - and $2 =~/#{Mx[:br_nl]}/ - dob=if dob.obj =~/#{Mx[:br_nl]}/ \ - and dob.obj =~/(#{leader})([*!\/_#])\{(.+?)\}\2/m - lead,fce,txt=$1,$2,$3 - dob=if txt =~/#{Mx[:br_nl]}/ - lead_break=if dob.obj =~/^#{Mx[:br_nl]}/ - dob.obj=dob.obj.sub(/^#{Mx[:br_nl]}/,'') - Mx[:br_nl] - else '' - end - txt="#{lead_break}#{fce}\{" + txt.split(Mx[:br_nl]).join("\}#{fce}#{Mx[:br_nl]}#{fce}\{") + "\}#{fce}" - dob.obj=dob.obj. - sub(/(?:^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|\>)([*!\/_#])\{.+?\}\1/m, - "#{lead}#{txt}") - dob - else dob - end - end - dob - end - dob - end - def fontface(dob) - leader=/^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}#{Mx[:lnk_o]}#{Mx[:br_nl]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:tc_c]}#{Mx[:tc_p]}]|[\(\[\{]|[、。「‹«¿¡]|\>/ - dob=fontface_lines(dob,leader) - dob.obj=dob.obj. - gsub(/(#{leader})\*\{(.+?)\}\*/m, - "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis - gsub(/(#{leader})!\{(.+?)\}!/m, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold - gsub(/(#{leader})\/\{(.+?)\}\//m, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics - gsub(/(#{leader})_\{(.+?)\}_/m, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore - gsub(/(#{leader})#\{(.+?)\}#/m, - "\\1#{Mx[:fa_monospace_o]}\\2#{Mx[:fa_monospace_c]}"). #monospace - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|[#{Mx[:nbsp]}#{Mx[:fa_o_c]}#{Mx[:fa_c]}]|\(|\>)\"\{(.+?)\}\"/m, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite /blockquote? - gsub(/(^|[^\\])\^\{(.+?)\}\^/m, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #superscript - gsub(/(^|[^\\]),\{(.+?)\},/m, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). #subscript - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/m, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). #inserted text - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/m, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). #strikethrough - deleted text - gsub(/(^|#{Mx[:gl_c]}|\s+|['"]|#{Mx[:nbsp]}|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>|\d+)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}") #superscript single word, watch digit added - dob - end - def bodymarkup(dob) - # << http://www.jus.uio.no/sisu/sisu_markup_table/markup >> - # See: data/sisu/sample/document_samples_sisu_markup/ - ## fontface - # *{emphasis}* e{emphasis}e <strong>emphasis</strong> - # !{bold text}! b{bold}b <b>bold text</b> - # _{underline}_ u{underline}u <u>underline</u> - # /{italics}/ i{italics}i <i>italics</i> - # "{citation}" c{citation}c <cite>citation</cite> #blockquote? - # ^{superscript}^ <sup>superscript</sup> - # ,{subscript}, <sub>subscript</sub> - # +{inserted text}+ <ins>inserted text</ins> - # -{deleted text}- <del>deleted text</del> - # #{monospace text}# - # - # {url address}:url - # {image.png}imageurl - # {image.png}png - # ~{endnote}~ - # !_ #bold/emphasise paragraph - # _" #blockquote paragraph - # _1 <:i1> #indent paragraph 1 step - # _2 <:i2> #indent paragraph 2 steps - # _3 <:i3> #indent paragraph 3 steps - # _4 <:i4> #indent paragraph 4 steps - # _* #bullet (list) ● - # _1* #bullet (list) indented - # _1* #bullet (list) indented - # # #numbered (list) level 1 - # _# #numbered (list) level 2 - dob=dob.dup - if dob.is !=:meta \ - && dob.is !=:comment \ - && dob.is !=:code \ - && dob.is !=:table - line_array=[] - word=dob.obj.scan(/\S+|\n/) #unless line =~/^(?:#{Mx[:meta_o]}|%+\s)/ #visit - if word - word.each do |w| # _ - / # | : ! ^ ~ - unless w =~/~\{|\}~|~\[|\]~|^\^~|~\^|\*~\S+|~#|\{t?~|\{table|https?:\/\/\S+/ # do something earlier about table!! - w=w.gsub(/\\?~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}") #escaped special character - end - w=w.gsub(/^\<$/, - "#{Mx[:gl_o]}#lt#{Mx[:gl_c]}").gsub(/^\>$/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}") #escaped special character - line_array << w - end - dob.obj=line_array.join(' ') - dob.obj=dob.obj.strip - end - dob.obj=dob.obj. - gsub(/^([*#.-]{1,12})$/,'\1 ~#'). #ocn off for these paragraph separators - gsub(/~\{(.+?)\}~/m,Mx[:en_a_o] + '\1' + Mx[:en_a_c]). - gsub(/~\[([^*+].+?)\]~/m,Mx[:en_b_o] + '* \1' + Mx[:en_b_c]). #default if markup does not specify - gsub(/~\[(.+?)\]~/m,Mx[:en_b_o] + '\1' + Mx[:en_b_c]) - if dob.is ==:heading \ - and dob.ln ==0 - dob.obj=dob.obj.gsub(/\s*@title\b/," #{@md.title.full}") - dob.obj=if defined? @md.creator.author \ - and @md.creator.author - dob.obj.gsub(/\s+(?:@creator|@author)/,",#{Mx[:br_line]}#{@md.creator.author}") - else dob.obj.gsub(/\s+(?:@creator|@author)/,'') - end - end - if defined? @md.title \ - and @md.title \ - and defined? @md.title.full \ - and defined? @md.creator \ - and @md.creator - if dob.is ==:heading - dob.obj=dob.obj.gsub(/^\s*@title\s*$/,@md.title.full) if dob.lv =~/1/ - dob.obj=if dob.lv =~/[23]/ \ - and defined? @md.creator.author \ - and @md.creator.author - dob.obj. - gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/, - "\\1#{@md.creator.author}") - else dob.obj.gsub(/^\s*(?:(by\s+)?(?:@creator|@author))\s*$/,'\1') - end - end - end - dob.obj=dob.obj.gsub(/<(https?:\/\/\S+?)>/,'< \1 >'). #catch problem markup - gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image'). - gsub(/<!(\S+)!>/,'<:\1>'). #escaped special character - gsub(/ /,"#{Mx[:nbsp]}"). #escaped special character - gsub(/\\~/,"#{Mx[:gl_o]}#126#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\{/,"#{Mx[:gl_o]}#123#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\}/,"#{Mx[:gl_o]}#125#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\<</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\>>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\</,"#{Mx[:gl_o]}#lt#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\>/,"#{Mx[:gl_o]}#gt#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\_/,"#{Mx[:gl_o]}#095#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\-/,"#{Mx[:gl_o]}#045#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\+/,"#{Mx[:gl_o]}#043#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\//,"#{Mx[:gl_o]}#047#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\#/,"#{Mx[:gl_o]}#035#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\&/,"#{Mx[:gl_o]}#038#{Mx[:gl_c]}"). #& #escaped special character - gsub(/\\\|/,"#{Mx[:gl_o]}#124#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility - gsub(/\\\:/,"#{Mx[:gl_o]}#058#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility - gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility - gsub(/\\\^/,"#{Mx[:gl_o]}#094#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility - gsub(/\\\,/,"#{Mx[:gl_o]}#044#{Mx[:gl_c]}"). #not really a sisu special character but made available as possibility - gsub(/\\\\/,"#{Mx[:gl_o]}#092#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\*/,"#{Mx[:gl_o]}#042#{Mx[:gl_c]}"). #escaped special character - gsub(/\\\!/,"#{Mx[:gl_o]}#033#{Mx[:gl_c]}") #escaped special character - if dob.obj=~/(?:https?:|ftp:|\{([^{}]+?)\}(?:#|:|[.]{1,2}\/))\S+/m - if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m - dob.obj=dob.obj. - gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ ([^}]+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)\s*#{Mx[:en_a_o]}(.+?)#{Mx[:en_a_c]}/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3 #{Mx[:en_a_o]}\\3 \\4#{Mx[:en_a_c]}") # watch - end - if dob.obj=~/(?:^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (?:.+?)\s*\}(?:(?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m - dob.obj=dob.obj. - gsub(/(^|[#{Mx[:gl_c]}#{Mx[:nbsp]} ])\{~\^ (.+?)\s*\}((?:https?:|ftp:|:|[.]{1,2}\/)\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4 #{Mx[:en_a_o]}\\3#{Mx[:en_a_c]} ") - end - dob.obj=dob.obj. - gsub(/(^|[^#])\{\s*([^{}]+?)\s*\}((?:https?:|:|[.]{2}\/|#)\S+?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3"). #linked (text or image, however text cannot include modified face, e.g. bold, ital, underline) - gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])((?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}). - gsub(/#{Mx[:lnk_c]}#(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}\\1#{Mx[:rel_c]}\\2}). - gsub(/#{Mx[:lnk_c]}:(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}). - gsub(/#{Mx[:lnk_c]}[.]{2}\/(\S+?[^>< ]+?)([()\[\]]*[,.;:!?'"]{0,2})(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{#{Mx[:lnk_c]}#{Mx[:rel_o]}:\\1#{Mx[:rel_c]}\\2}) - end - if dob.obj=~/_(?:https?|ftp):\S+/m # _http://url #CHECK - dob.obj=dob.obj.gsub(/(^|[#{Mx[:gl_c]}#{Mx[:lnk_c]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}(\s])(_(?:https?|ftp):\/\/\S+?\.[^>< ]+?)([,.;'"]?)(?=[\s#{Mx[:en_a_c]}#{Mx[:en_b_c]}#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}]|$)/m, - %{\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3}) - end - dob=fontface(dob) - dob.obj=dob.obj. - gsub(/<[:e]\s+(.+?)!?>/, - "#{Mx[:en_a_o]}\\1#{Mx[:en_a_c]}"). #not tested - gsub(/(^|#{Mx[:br_nl]})\s*_\*\s*/, - "\\1#{Mx[:gl_bullet]}"). #bullets, shortcut - gsub(/=\{(.+?)\}/, - "#{Mx[:idx_o]}\\1#{Mx[:idx_c]}"). - gsub(/^\s*_([1-9])\*\s*/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:gl_bullet]}"). #bullets, shortcut - gsub(/^\s*_([1-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}"). #indent - gsub(/^\s*_([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #indent bold - gsub(/^\s*__([1-9])\s+/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}"). #hang - gsub(/^\s*__([1-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i0:\\1#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]} "). #hangdef - gsub(/^\s*_([0-9])_([0-9])\s+/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}"). #hang - gsub(/^\s*_([0-9])_([0-9])!\s+(.+?)\s*$/, - "#{Mx[:pa_o]}:i\\1:\\2#{Mx[:pa_c]}#{Mx[:fa_bold_o]}\\3#{Mx[:fa_bold_c]} "). #hangdef - gsub(/<:hi>/,"#{Mx[:fa_hilite_o]}"). #'<span style="background-color: rgb(255,240,196)">'). # bright yellow rgb(255,255,0) pale yellow rgb(255,255,200) - gsub(/<:\/hi>/,"#{Mx[:fa_hilite_c]}"). #'</span>'). - gsub(/(#{Mx[:gr_o]}verse#{Mx[:gr_c]}.+)/m,"\\1\n"). - gsub(/[ ]+($)/,'\1'). - gsub(/\{\s*(.+?)\s*\}(https?:\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:url_o]}\\2#{Mx[:url_c]}\\3"). #any remaining linked text or image - gsub(/\{\s*(.+?)\s*\}(#{Mx[:url_o]}\S+?#{Mx[:url_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image - gsub(/(^|\s)([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)/,"\\1#{Mx[:url_o]}\\2#{Mx[:url_c]}"). - gsub(/(^|[ ])\{\s*(.+?)\s*\}(\S+?)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "\\1#{Mx[:lnk_o]}\\2#{Mx[:lnk_c]}\\3\\4"). #any remaining linked text or image - gsub(/\{\s*(.+?)\s*\}#([a-zA-Z0-9][a-zA-Z0-9_-]*)([;,.]?)(?=\s|[#{Mx[:br_line]}#{Mx[:br_paragraph]}#{Mx[:br_nl]}#{Mx[:en_a_o]}#{Mx[:en_b_o]}]|$)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}#{Mx[:rel_o]}\\2#{Mx[:rel_c]}\\3"). #any remaining linked text or image, check need - gsub(/\{\s*(.+?)\s*\}(#{Mx[:rel_o]}\S+?#{Mx[:rel_c]})/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2"). #any remaining linked text or image, check need - gsub(/\{\s*(.+?)\s*\}(image)/, - "#{Mx[:lnk_o]}\\1#{Mx[:lnk_c]}\\2") #linked image - elsif dob.is==:table - dob=fontface(dob) - elsif dob.is ==:code - dob.obj=dob.obj. - gsub(/#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}\s*/,'@\1: '). - gsub(/(^|#{Mx[:gl_c]}|\s)<(?:br(?: \/)?)>([\s,.]|$)/,'\1<br>\2') #convert <br> <br /> back, clumsy - if dob.number_ - codeline=[] - ln=1 - dob.obj.split(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}|<br(?: \/)?>|\n/).each_with_index do |cl,i| - unless i == 0 - cl=cl.gsub(Mx[:br_nl],'') - w=3-ln.to_s.length - cl = "#{ln}#{Mx[:nbsp]*w}#{Mx[:vline]}#{cl}#{Mx[:br_nl]}" - ln +=1 - end - codeline << cl - end - codeline= codeline.join("") - dob.obj=codeline - else - dob.obj=dob.obj.gsub(/#{Mx[:gr_o]}codeline#{Mx[:gr_c]}/,"\n") - end - dob - else # @\S+?: - end - dob - end - def tech #script markup planned to be more strict for technical documents - # *{emphasis}* e{emphasis}e <strong>emphasis</strong> - # !{bold text}! b{bold}b <b>bold text</b> - # _{underline}_ u{underline}u <u>underline</u> - # /{italics}/ i{italics}i <i>italics</i> - # "{citation}" c{citation}c <cite>citation</cite> - # ^{superscript}^ <sup>superscript</sup> - # ,{subscript}, <sub>subscript</sub> - # +{inserted text}+ <ins>inserted text</ins> - # -{deleted text}- <del>deleted text</del> - # #{monospace text}# - # {url address}:url - # {image.png}imageurl - # {image.png}png - # ~{endnote}~ - # +1 <!i1!> - # +2 <!i2!> - puts 'tech' - @data.each do |line| - line=line. - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)e\{(.+?)\}e/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)b\{(.+?)\}b/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)u\{(.+?)\}u/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)c\{(.+?)\}c/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). #cite - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)i\{(.+?)\}i/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)!\{(.+?)\}!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)\*\{(.+?)\}\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasis - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\>)_\{(.+?)\}_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|[\(\[]|\(|\>)\/\{(.+?)\}\//, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}"). #italics - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\"\{(.+?)\}\"/, - "\\1#{Mx[:fa_cite_o]}\\2#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^\{(.+?)\}\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)9\{(.+?)\}9/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>),\{(.+?)\},/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)6\{(.+?)\}6/, - "\\1#{Mx[:fa_subscript_o]}\\2#{Mx[:fa_subscript_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\+\{(.+?)\}\+/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)v\{(.+?)\}v/, - "\\1#{Mx[:fa_insert_o]}\\2#{Mx[:fa_insert_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)-\{(.+?)\}-/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)x\{(.+?)\}x/, - "\\1#{Mx[:fa_strike_o]}\\2#{Mx[:fa_strike_c]}"). - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\*(\S+?)\*/, - "\\1#{@emph[:o]}\\2#{@emph[:c]}"). #emphasise single word, watch - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\!(\S+?)\!/, - "\\1#{Mx[:fa_bold_o]}\\2#{Mx[:fa_bold_c]}"). #bold single word, watch - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\/([\(\)a-zA-Z0-9']+?)\/([ ,.;:'"~$]|[^a-zA-Z0-9])/, - "\\1#{Mx[:fa_italics_o]}\\2#{Mx[:fa_italics_c]}\\3"). #italics single word, watch - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)_(\S+?)_/, - "\\1#{Mx[:fa_underscore_o]}\\2#{Mx[:fa_underscore_c]}"). #underscore single word, watch - gsub(/(^|\s+|['"]|#{Mx[:fa_o_c]}|#{Mx[:fa_c]}|\(|\>)\^(\S+?)\^/, - "\\1#{Mx[:fa_superscript_o]}\\2#{Mx[:fa_superscript_c]}"). #check #superscript single word, watch digit added - gsub(/^\s*_\([1-9]\)\(\*\+\)\s*/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}#{Mx[:fa_o]}\\2#{Mx[:fa_c_o]}"). #bullets, shortcut - gsub(/^\s*_\([1-9]\)\s+/, - "#{Mx[:pa_o]}:i\\1#{Mx[:pa_c]}"). #watch - gsub(/^\s*__\([1-9]\)\s+/, - "#{Mx[:pa_o]}:h\\1#{Mx[:pa_c]}"). #watch - #line.gsub(/^\s*__\([1-9]\)!\s+/, - # "#{Mx[:pa_o]}:hd\\1#{Mx[:pa_c]}"). #watch - gsub(/#{Mx[:br_line]}\s*_[12]\s+/, - "#{Mx[:br_line]} ") #indent used in endnotes, not implemented, replace when ready with: line.gsub(/(?:<br>|<br \/>)\s*_([12])\s+/,'<br><:i\1> ') - end - @data - end - end -end -__END__ diff --git a/lib/sisu/current/cgi.rb b/lib/sisu/current/cgi.rb deleted file mode 100644 index 99f2e987..00000000 --- a/lib/sisu/current/cgi.rb +++ /dev/null @@ -1,84 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** generates naive cgi search form for search of sisu database (pgsql sqlite) - -** Author: Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - -** Git - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/cgi.rb;hb=HEAD> - -=end -module SiSU_CGI #% database building documents - require_relative 'se' # se.rb - require_relative 'cgi_pgsql' # cgi_pgsql.rb - require_relative 'cgi_sqlite' # cgi_sqlite.rb - class SearchSQL - def initialize(opt) - @opt=opt - @webserv=@opt.files[0].to_s.strip - end - def read - if @opt.act[:sample_search_form][:db]==:pg # cgi_pgsql.rb - SiSU_CGI_PgSQL::SearchPgSQL.new(@opt,@webserv).pgsql - elsif @opt.act[:sample_search_form][:db]==:sqlite # cgi_sqlite.rb - SiSU_CGI_SQLite::SearchSQLite.new(@opt,@webserv).sqlite - else - puts <<-WOK - please select database type for which sample search form should be built (pgsql or sqlite) - sisu --sample-search-form --db=sqlite - sisu --sample-search-form --db=pg - other options include - --webserv-cgi='[cgi-server-name]' - --webserv-output='[sisu-output-server-with-base-path]' - WOK - end - end - end -end -__END__ diff --git a/lib/sisu/current/cgi_pgsql.rb b/lib/sisu/current/cgi_pgsql.rb deleted file mode 100644 index 9a4c555b..00000000 --- a/lib/sisu/current/cgi_pgsql.rb +++ /dev/null @@ -1,270 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** generates naive cgi search form for search of sisu database (pgsql) - -** Author: Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - -** Git - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/cgi_pgsql.rb;hb=HEAD> - -=end -module SiSU_CGI_PgSQL #% database building documents - require_relative 'se' # se.rb - require_relative 'cgi_sql_common' # cgi_sql_common.rb - include SiSU_CGI_SQL - class SearchPgSQL < CGI_Common - def initialize(opt,webserv) - @opt,@webserv=opt,webserv - @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX - @env=SiSU_Env::InfoEnv.new('',opt) - @sys=SiSU_Env::SystemCall.new - @db=SiSU_Env::InfoDb.new - get_init=SiSU_Env::GetInit.new - @rc=get_init.sisu_yaml.rc - @name_of={} - @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ - opt.dir_structure_by.to_s - else 'language' - end - @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ - opt.lingual.to_s - else 'multi' - end - @name_of[:db]=if defined? @rc['search'] \ - and defined? @rc['search']['sisu'] \ - and defined? @rc['search']['sisu']['action'] \ - and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \ - and defined? @rc['search']['sisu']['db'] \ - and @rc['search']['sisu']['db'] =~/\S+/ - @rc['search']['sisu']['db'] - else - @env.path.base_markup_dir_stub #'sisu' #breaks if not present - end - @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} - @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} - @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} - @name_of[:user]=@db.psql.user(opt) - @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} - @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) - @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) - end - def pgsql - serve=[] - if @sys.psql - available_db_table=`psql --list` # system call requires psql - available_db=available_db_table.scan(/(#{Db[:name_prefix]}\S+)/) if not available_db_table.nil? - if available_db \ - and available_db.is_a?(Array) - available_db.flatten.each do |x| - serve << x.gsub(/#{Db[:name_prefix]}(\S+)/,'\1') - end - else STDERR.puts "WARNING: no postgresql database available, (have you created one?)" - end - serve=serve.sort - f1,f2='','' - serve.each do |x| - f1 << %{ <option value="#{Db[:name_prefix]}#{x}">#{x}</option>\n} unless x =~/apache|sisu\/image/ #check - end - end - f2 << %q{ selected_db=%{<option value="#{@db_name_prefix}#{@stub}">#{@stub}</option>}} + "\n" - if FileTest.writable?('.') - output=File.open(@cgi_file_name,'w') - output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons1_pgsql << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3 - puts <<-WOK - generated sample search form: #{@cX.green}#{@cgi_file_name}#{@cX.off} - default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]}) - db user: #{@cX.green}#{@name_of[:user]}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off} - - #{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db}) - NOTE it is first necessary to createdb, - use sisu to create the tables & populate the postgresql db - - the database to be used for this directory (#{@db.psql.db}) - will have to be created manually if it does not exist: - using postgresql tools directly (the following may work): - (i) if you are not yet a postgresql user, - #{@cX.brown}sudo su postgres - createuser -d -a #{@env.user} - exit#{@cX.off} - (ii) create the database: - #{@cX.brown}createdb #{@db.psql.db}#{@cX.off} - [for a list of existing databases try 'psql --list']" - - you can use sisu to create the database tables and populate the database with documents - - sisu --pg --dropall # removes existing postgresql db & tables - sisu --pg --createall -v # creates postgresql db & tables - sisu --pg --update -v *.sst *.ssm # populate the db - sisu --sample-search-form --db-pg # creates the postgresql search form - # this should be done after creating the db - # to be searched - sisu --webrick & # starts ruby webrick web server - - # if necessary make the directory '/usr/lib/cgi-bin' - # here we copy the postgresql search form to cgi-bin - # (copy #{@cgi_file_name} to your cgi directory) - # set file permissions to 755 - WOK - a=case @webserv - when /pwd/ then '' - else <<-WOK - - sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ - sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} - WOK - end - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).warn - a=<<-WOK - #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} - WOK - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue - a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']" - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).txt_grey - else puts 'failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?' - end - end - def header0 - <<-WOK_SQL -#!/usr/bin/env ruby -=begin -#{about} - * Description: generates naive cgi search form for search of sisu database (pgsql) -#{gpl} -=end - begin - require 'cgi' - require 'fcgi' - require 'pg' - rescue LoadError - puts 'cgi, fcgi or pg NOT FOUND (LoadError)' - end - @stub_default='#{@name_of[:db]}' - @image_src="#{@image_src}" - @hosturl_cgi="#{@name_of[:host_url_cgi]}" - @hosturl_files="#{@name_of[:host_url_docs]}" - @output_dir_structure_by='#{@name_of[:output_dir_structure]}' - @lingual='#{@name_of[:lingual]}' - @port='#{@db.psql.port}' - @db_name_prefix='#{Db[:name_prefix]}' - @user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}' - @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" - WOK_SQL - end - def search_statement - <<-'WOK_SQL' - class DBI_SearchString - def initialize(l,t,q,cse=false) - @l,@t,@q,@c=l,t,q,cse - end - def string - search={ search: [], flag: false } - if @t =~/\S+/ or @q =~/\S+/ - if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) - elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) - end - search_construct=[] - unescaped_search=if @c - unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~\( '"). - gsub(/(.+)/,"#{@l}~\( '\\1' \)") - else - unescaped_search.gsub(/\s*(AND|OR)\s*/,"' \) \\1 #{@l}~*\( '"). - gsub(/(.+)/,"#{@l}~*\( '\\1' \)") - end - search_construct << unescaped_search - search_construct=search_construct.join(' ') - search[:search] << search_construct - search[:flag]=true - search - end - search - end - end - WOK_SQL - end - def search_query1 - <<-'WOK_SQL' - @search_text='' - @search_text=search[:text].flatten.join(' AND ') - @search_text=@search_text.gsub(/(doc_objects\.clean~[*]?\(\s*'[^']+'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean~[*]?\(\s*'[^']+'\s*\))+)/,'(\1)') - end - WOK_SQL - end - def search_query2 - <<-'WOK_SQL' - def sql_select_body - limit ||=@@limit - offset ||=@@offset - @sql_statement[:body]=%{SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg, doc_objects.ocn, metadata_and_text.tid FROM doc_objects, metadata_and_text WHERE (#{@search_text}) AND doc_objects.metadata_tid = metadata_and_text.tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, doc_objects.ocn} - @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} - select=@sql_statement[:body] + ' ' + @sql_statement[:range] - select - end - def sql_select_body_format - %{<font color="#666666" size="2">#{sql_select_body}</font>} - end - def contents - @conn.exec(sql_select_body) - end - end - WOK_SQL - end - def buttons1_pgsql - <<-'WOK_SQL' - <input type="checkbox" name="casesense" #{@checked_case}> case sensitive - WOK_SQL - end - def dbi_connect - <<-'WOK_SQL' - @conn=PG::Connection.open(dbname: @db, port: @port, user: @user) - WOK_SQL - end - end -end -__END__ diff --git a/lib/sisu/current/cgi_sql_common.rb b/lib/sisu/current/cgi_sql_common.rb deleted file mode 100644 index 62bec041..00000000 --- a/lib/sisu/current/cgi_sql_common.rb +++ /dev/null @@ -1,986 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** generates naive cgi search form for search of sisu database (pgsql sqlite) - -** Author: Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licensing/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - - <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html> - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - -** Git - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary> - <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/current/cgi_sql_common.rb;hb=HEAD> - -=end -module SiSU_CGI_SQL - class CGI_Common - def initialize(webserv,opt,image_src,dir) - @webserv,@opt,@image_src,@env=webserv,opt,image_src,dir - end - def about - <<-'WOK_SQL' - * Name: SiSU information Structuring Universe - * Author: Ralph Amissah - * http://www.jus.uio.no/sisu - * http://www.jus.uio.no/sisu/SiSU/download - WOK_SQL - end - def gpl - <<-'WOK_SQL' - * Name: SiSU generated sample cgi search form - - * Description: generated sample cgi search form for SiSU - (SiSU is a framework for document structuring, publishing and search) - - * Author: Ralph Amissah - - * Copyright: (C) 1997 - 2014, Ralph Amissah, All Rights Reserved. - - * License: GPL 3 or later: - - 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 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 <http://www.gnu.org/licenses/>. - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - <http://www.fsf.org/licenses/gpl.html> - <http://www.gnu.org/licenses/gpl.html> - <http://www.jus.uio.no/sisu/gpl.fsf> - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - - * Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - WOK_SQL - end - def header1 - <<-'WOK_SQL' -#Common TOP - @@offset=0 - @@canned_search_url=@base - @color_heading='#DDFFAA' - @color_match='#ffff48' - class Form - def initialize(base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can='') - search_note='' if checked_searched !~/\S/ - the_can='' if checked_url !~/\S/ - search_field='' if checked_echo !~/\S/ - @base,@search_field,@selected_db,@result_type,@checked_sql_limit,@checked_tip,@checked_stats,@checked_searched,@checked_url,@checked_case,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_selected,@checked_default,@search_note,@the_can=base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can - @tip=if checked_tip =~/\S/ - '<font size="2" color="#666666">text:__; fulltxt:__; keywords:__; title:__; author:__; topic_register:__; subject:__; description:__; publisher:__; editor:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__;</font><br>' - else '' - end - end - def submission_form - search_form=<<-WOK - WOK_SQL - end - def header_desc - <<-WOK_SQL - <!DOCTYPE html> - <html> - <head> - <title> - <meta charset="utf-8"> - <meta name="sourcefile" content="SiSU._sst" /> - SiSU search form (sample): SiSU information Structuring Universe - - - - - - - - - -
- - -
-
- SiSU - -
- git - -
-
- -
- WOK_SQL - end - def header2 - <<-'WOK_SQL' -
- - -
- - - #{@tip} - #{@search_note} - #{@the_can} -
- - - - - to search: select which database to search (drop-down menu below); enter your search query (in the form above); and click on the search button (below) -
- - - index - text / grep - WOK_SQL - end - def buttons2 - <<-'WOK_SQL' -
- match limit: - 1,000 - 2,500 -
- echo query - result stats - search url - searched - available fields - sql statement -
- checks: - default - selected - all - none -
- - -
- WOK - end - end - WOK_SQL - end - def search_request - <<-'WOK_SQL' - class SearchRequest #% search_for - attr_accessor :text1,:fulltext,:keywords,:title,:author,:topic_register,:subject,:description,:publisher,:editor,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid,:filename - def initialize(search_field='',q='') - @search_field,@q=search_field,q - @text1=@fulltext=@keywords=@title=@author=@topic_register=@subject=@description=@publisher=@editor=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@comment=@abstract=@owner=@date_created=@date_issued=@date_modified=@date_available=@date_valid=@filename='' - if @search_field=~/\S/ - @text1=text_to_match('text:') - @fulltext=text_to_match('fulltxt:') - @topic_register=text_to_match('topic_register:') - @title=text_to_match('title:') # DublinCore 1 - title - @author=text_to_match('(?:author|creator)s?:') # DublinCore 2 - creator/author - @subject=text_to_match('subj(?:ect)?:') # DublinCore 3 - subject - @description=text_to_match('description:') # DublinCore 4 - description - @publisher=text_to_match('pub(?:lisher)?:') # DublinCore 5 - publisher - @editor=text_to_match('editor:') - @contributor=text_to_match('contributor:') # DublinCore 6 - contributor - @date=text_to_match('date:') # DublinCore 7 - date dd-mm-yy - @type=text_to_match('type:') # DublinCore 8 - type - @format=text_to_match('format:') # DublinCore 9 - format - @identifier=text_to_match('identifier:') # DublinCore 10 - identifier - @source=text_to_match('source:') # DublinCore 11 - source - @language=text_to_match('language:') # DublinCore 12 - language - @relation=text_to_match('relation:') # DublinCore 13 - relation - @coverage=text_to_match('coverage:') # DublinCore 14 - coverage - @rights=text_to_match('rights:') # DublinCore 15 - rights - @keywords=text_to_match('key(?:words?)?:') - @comment=text_to_match('comment:') - @abstract=text_to_match('abs(?:tract)?:') - @owner=text_to_match('owner:') - @date_created=text_to_match('date_created:') - @date_issued=text_to_match('date_issued:') - @date_modified=text_to_match('date_modified:') - @date_available=text_to_match('date_available:') - @date_valid=text_to_match('date_valid:') - @filename=text_to_match('filename:') - @text1=text_to_match unless @keywords or @author or @title or @text1 or @fulltext or @comment or @abstract or @rights or @subject or @publisher or @date or @filename or @topic_register - else - @text1=q['s1'] if q['s1']=~/\S/ - @fulltext=q['ft'] if q['ft']=~/\S/ - @keywords=q['key'] if q['key']=~/\S/ - @title=q['ti'] if q['ti']=~/\S/ - @author=q['au'] if q['au']=~/\S/ - @topic_register=q['tr'] if q['tr']=~/\S/ - @subject=q['sj'] if q['sj']=~/\S/ - @description=q['dsc'] if q['dsc']=~/\S/ - @publisher=q['pb'] if q['pb']=~/\S/ - @editor=q['cntr'] if q['cntr']=~/\S/ - @contributor=q['cntr'] if q['cntr']=~/\S/ - @date=q['dt'] if q['dt']=~/\S/ - @type=q['ty'] if q['ty']=~/\S/ - @identifier=q['id'] if q['id']=~/\S/ - @source=q['src'] if q['src']=~/\S/ - @language=q['lang'] if q['lang']=~/\S/ - @relation=q['rel'] if q['rel']=~/\S/ - @coverage=q['cov'] if q['cov']=~/\S/ - @rights=q['cr'] if q['cr']=~/\S/ - @comment=q['co'] if q['co']=~/\S/ - @abstract=q['ab'] if q['ab']=~/\S/ - @date_created=q['dtc'] if q['dtc']=~/\S/ - @date_issued=q['dti'] if q['dti']=~/\S/ - @date_modified=q['dtm'] if q['dtm']=~/\S/ - @date_available=q['dta'] if q['dta']=~/\S/ - @date_valid=q['dtv'] if q['dtv']=~/\S/ - @filename=if q['doc'] and q['search'] !~/search db/ then q['doc'] - elsif q['fns']=~/\S/ then q['fns'] - end - @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000 - @@offset=q['off'] if q['off']=~/\d+/ # 0 - end - end - def text_to_match(identifier='') - m={ - string: /#{identifier}\s*(.+?)/, - string: /#{identifier}\s*(.+?)(?:;|\n|\r|$)/, - word: /#{identifier}[\s(]*(\S+)/ - } - search_string=if @search_field =~m[:word] - search_string=if @search_field =~m[:braces] then m[:braces].match(@search_field)[1] - elsif @search_field =~m[:string] then m[:string].match(@search_field)[1] - else - str=m[:word].match(@search_field)[1] - str=str.gsub(/[()]/,'') - str - end - search_string=search_string.strip.gsub(/\s+/,'+') - #else - # "__" - end - end - end - WOK_SQL - end - def search_statement_common - <<-'WOK_SQL' - class DBI_SearchStatement - attr_reader :text_search_flag,:sql_select_body_format,:sql_offset,:sql_limit - def initialize(conn,search_for,q,c) - @conn=conn - @text_search_flag=false - @sql_statement={ body: '', endnotes: '', range: '' } - #@offset||=@@offset - #@offset+=@@limit - search={ text: [], endnotes: [] } - cse=(c =~/\S/) ? true : false - st=DBI_SearchString.new('doc_objects.clean',search_for.text1,q['s1'],cse).string - se=DBI_SearchString.new('endnotes.clean',search_for.text1,q['s1'],cse).string - @text_search_flag=st[:flag] - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.fulltext',search_for.fulltext,q['ft'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.title',search_for.title,q['ti'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.creator_author',search_for.author,q['au'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.classify_topic_register',search_for.topic_register,q['tr'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.classify_subject',search_for.subject,q['sj'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.classify_keywords',search_for.keywords,q['key'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_description',search_for.description,q['dsc'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.publisher',search_for.publisher,q['pb'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.creator_editor',search_for.editor,q['cntr'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.creator_contributor',search_for.contributor,q['cntr'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.date_published',search_for.date,q['dt'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_type',search_for.type,q['ty'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.original_source',search_for.source,q['src'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.language_document_char',search_for.language,q['lang'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_relation',search_for.relation,q['rel'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_coverage',search_for.coverage,q['cov'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.rights_all',search_for.rights,q['cr'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_comment',search_for.comment,q['co'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.notes_abstract',search_for.abstract,q['ab'],cse).string - if st[:flag] - search[:text] << st[:search] - end - st=DBI_SearchString.new('metadata_and_text.src_filename',search_for.filename,q['fns'],cse).string - if st[:flag] - search[:text] << st[:search] - end - @@limit=q['ltd'] if q['ltd']=~/\d+/ # 1000 - @@offset=q['off'] if q['off']=~/\d+/ # 0 - WOK_SQL - end - def pages - <<-'WOK_SQL' - def sql_offset - @@offset - end - def sql_match_limit - @@limit - end - def sql_canned_search - @offset_next=sql_offset.to_i + sql_match_limit.to_i - @offset_previous=sql_offset.to_i - sql_match_limit.to_i - def current - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + sql_offset.to_s - end - def next - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_next.to_s - end - def previous - @offset_previous >= 0 \ - ? (@@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + @offset_previous.to_s) - : '' - end - def start - @@canned_search_url.to_s + '<d=' + sql_match_limit.to_s + '&off=' + 0.to_s - end - self - end - def pre_next(beyond_limit,img) - can=sql_canned_search - page=(sql_offset.to_i + sql_match_limit.to_i)/sql_match_limit.to_i - if beyond_limit - if page.to_s =~ /^1$/ - %{
- pg. #{page.to_s} - -  >> - -
} - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} - -  >> - -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} - -  >> - -
} - end - else - if page.to_s =~ /^1$/ then '' - elsif page.to_s =~ /^2$/ - %{
- - <<  - - pg. #{page.to_s} -
} - else - %{
- - |<  - - - <<  - - pg. #{page.to_s} -
} - end - end - end - WOK_SQL - end - def tail - v=SiSU_Env::InfoVersion.instance.get_version - <<-WOK_SQL - def tail - <<-'WOK' -


- - - - - - -
- - -
-
- SiSU - -
- git - -
-
- -

- Generated by - #{v.project} #{v.version} #{v.date} (#{v.date_stamp}) -
- - #{v.project} © Ralph Amissah - 1993, current 2014. - All Rights Reserved. -
- #{v.project} is software for document structuring, publishing and search, -
- - www.jus.uio.no/sisu - - and - - www.sisudoc.org - - sources - - git.sisudoc.org - -
- w3 since October 3 1993 - - ralph@amissah.com - -
- mailing list subscription - - http://lists.sisudoc.org/listinfo/sisu - -
- - sisu@lists.sisudoc.org - -

-
-

- #{v.project} using: -
Standard SiSU markup syntax, -
Standard SiSU meta-markup syntax, and the -
Standard SiSU object citation numbering and system, (object/text identifying/locating system) -
- © Ralph Amissah 1997, current 2014. - All Rights Reserved. -

-
-

- - .: - -

-
-

- SiSU is released under - GPL v3 - or later, - - http://www.gnu.org/licenses/gpl.html - -

-
-

- #{v.project}, developed using - - Ruby - - on - - Debian/Gnu/Linux - - software infrastructure, - with the usual GPL (or OSS) suspects. -

-
- - - WOK - end - WOK_SQL - end - def main1 - <<-'WOK_SQL' - @tail=tail - @counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 - @counters_txt,@counters_endn,@sql_select_body='','','' - FCGI.each_cgi do |cgi| - begin # all code goes in begin section - @search={ text: [], endnotes: [] } - q=CGI.new - @db=if cgi['db'] =~ /#{@db_name_prefix}(\S+)/ - @stub=$1 - cgi['db'] - else - @stub=@stub_default - @db_name_prefix + @stub - end - checked_url,checked_stats,checked_searched,checked_tip,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,selected_db='','','','','','','','','' - result_type=(cgi['view']=~/text/) \ - ? result_type={ index: '', text: 'checked'} - : result_type={ index: 'checked', text: ''} - @@limit=if cgi['sql_match_limit'].to_s=~/2500/ - checked_sql_limit={ l1000: '', l2500: 'checked'} - '2500' - else - checked_sql_limit={ l1000: 'checked', l2500: ''} - '1000' - end - checked_echo='checked' if cgi['echo'] =~/\S/ - checked_stats='checked' if cgi['stats'] =~/\S/ - checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1 - checked_searched='checked' if cgi['searched'] =~/\S/ - checked_tip='checked' if cgi['tip'] =~/\S/ - checked_case='checked' if cgi['casesense'] =~/\S/ - checked_sql='checked' if cgi['sql'] =~/\S/ - if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1 - checked_all='checked' - checked_echo=checked_stats=checked_url=checked_searched=checked_tip=checked_sql='checked' - checked_none='' - elsif cgi['checks'] =~/check_none/ - checked_none='checked' - checked_all=checked_url=checked_stats=checked_searched=checked_tip=checked_echo=checked_sql='' - elsif cgi['checks'] =~/check_selected/ - checked_selected='checked' - elsif cgi['checks'] =~/check_default/ - checked_default='checked' - checked_echo=checked_stats=checked_url='checked' - checked_searched=checked_tip=checked_case=checked_sql='' - else - checked_selected='checked' - checked_echo=checked_stats=checked_url='checked' - checked_searched=checked_tip=checked_case=checked_sql='' - end - WOK_SQL - end - def main2 - <<-'WOK_SQL' - search_field=cgi['find'] if cgi['find'] # =~/\S+/ - @search_for=SearchRequest.new(search_field,q) #.analyze #% search_for - #% searches - #Canned_search.new(@base,@search_for.text1,cgi) - if @search_for.text1=~/\S+/ or @search_for.fulltext=~/\S+/ or @search_for.author=~/\S+/ or @search_for.topic_register=~/\S+/ #and search_field =~/\S/ - s1='s1=' + CGI.escape(@search_for.text1) if @search_for.text1=~/\S/ - ft='&ft=' + CGI.escape(@search_for.fulltext) if @search_for.fulltext=~/\S/ - key='key=' + CGI.escape(@search_for.keywords) if @search_for.keywords=~/\S/ - ti='&ti=' + CGI.escape(@search_for.title) if @search_for.title=~/\S/ - au='&au=' + CGI.escape(@search_for.author) if @search_for.author=~/\S/ - tr='&tr=' + CGI.escape(@search_for.topic_register) if @search_for.topic_register=~/\S/ - sj='&sj=' + CGI.escape(@search_for.subject) if @search_for.subject=~/\S/ - dsc='&dsc=' + CGI.escape(@search_for.description) if @search_for.description=~/\S/ - pb='&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher=~/\S/ - edt='&edt=' + CGI.escape(@search_for.editor) if @search_for.editor=~/\S/ - cntr='&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor=~/\S/ - dt='&dt=' + CGI.escape(@search_for.date) if @search_for.date=~/\S/ - ty='&ty=' + CGI.escape(@search_for.type) if @search_for.type=~/\S/ - id='&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier=~/\S/ - src='&src=' + CGI.escape(@search_for.source) if @search_for.source=~/\S/ - lang='&lang=' + CGI.escape(@search_for.language) if @search_for.language=~/\S/ - rel='&rel=' + CGI.escape(@search_for.relation) if @search_for.relation=~/\S/ - cov='&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage=~/\S/ - cr='&cr=' + CGI.escape(@search_for.rights) if @search_for.rights=~/\S/ - co='&co=' + CGI.escape(@search_for.comment) if @search_for.comment=~/\S/ - ab='&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract=~/\S/ - dtc='&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created=~/\S/ - dti='&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued=~/\S/ - dtm='&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified=~/\S/ - dta='&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available=~/\S/ - dtv='&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid=~/\S/ - fns='&fns=' + CGI.escape(@search_for.filename) if @search_for.filename=~/\S/ - @@canned_search_url=(checked_all =~/checked/) \ - ? "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" - : "#{@base}?#{s1}#{ft}#{key}#{ti}#{au}#{tr}#{sj}#{dsc}#{pb}#{edt}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&db=#{cgi['db']}&view=#{cgi['view']}" - mod=ft=~/\S+/ ? (ft.gsub(/ft/,'s1')) : s1 - @canned_base_url="#{@base}?#{mod}&db=#{cgi['db']}" - if checked_case=~/\S/ - @search[:text][1]=%{doc_objects.clean~'#{@search_for.text1}'} #s1 - else - @search[:text][1]=%{doc_objects.clean~*'#{@search_for.text1}'} #s1 - end - canned_note='search url:' - else - @@canned_search_url="#{@base}?db=#{@db}&view=index" - canned_note='search url example:' - end - if search_field =~/\S+/ - analyze_format=search_field.gsub(/\s*\n/,'; ') - elsif checked_all =~/checked/ or checked_url =~/checked/ - canned_search=@@canned_search_url.scan(/(?:s1|ft|au|ti|fns|tr)=[^&]+/) - af=canned_search.join('; ') - af=af.gsub(/s1=/,'text: '). - gsub(/ft=/,'fulltxt: '). - gsub(/au=/,'author: '). - gsub(/ti=/,'title: '). - gsub(/fns=/,'filename: '). - gsub(/tr=/,'topic_register: '). - gsub(/%2B/,' ') - analyze_format=af - st=af.split(/\s*;\s*/) - search_field=st.join("\n") - end - green=%{} - canned_search_url_txt=CGI.escapeHTML(@@canned_search_url) - the_can=%{#{canned_note} #{canned_search_url_txt}
} - p_text=p_fulltext=p_keywords=p_title=p_author=p_topic_register=p_subject=p_description=p_publisher=p_editor=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_filename='' - p_filename=%{filename: #{green}#{@search_for.filename}

} if @search_for.filename =~/\S+/ - p_text=%{text: #{green}#{@search_for.text1}

} if @search_for.text1 =~/\S+/ - p_fulltext=%{fulltxt: #{green}#{@search_for.fulltext}
} if @search_for.fulltext =~/\S+/ - p_title=%{title: #{green}#{@search_for.title}
} if @search_for.title =~/\S+/ - p_author=%{author: #{green}#{@search_for.author}
} if @search_for.author =~/\S+/ - p_editor=%{editor: #{green}#{@search_for.editor}
} if @search_for.editor=~/\S+/ - p_contributor=%{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~/\S+/ - p_date=%{date: #{green}#{@search_for.date}
} if @search_for.date =~/\S+/ - p_rights=%{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~/\S+/ - p_topic_register=%{topic_register: #{green}#{@search_for.topic_register}
} if @search_for.topic_register =~/\S+/ - p_subject=%{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~/\S+/ - p_keywords=%{keywords: #{green}#{@search_for.keywords}
} if @search_for.keywords =~/\S+/ - p_identifier=%{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~/\S+/ - p_type=%{type: #{green}#{@search_for.type}
} if @search_for.type =~/\S+/ - p_format=%{format: #{green}#{@search_for.format}
} if @search_for.format =~/\S+/ - p_relation=%{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~/\S+/ - p_coverage=%{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~/\S+/ - p_description=%{description: #{green}#{@search_for.description}
} if @search_for.description =~/\S+/ - p_abstract=%{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~/\S+/ - p_comment=%{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~/\S+/ - p_publisher=%{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~/\S+/ - p_source=%{source: #{green}#{@search_for.source}
} if @search_for.source =~/\S+/ - p_language=%{language: #{green}#{@search_for.language}
} if @search_for.language =~/\S+/ - search_note=<<-WOK - - database: #{green}#{@db}; selected view: #{green}#{cgi['view']} - search string: "#{green}#{analyze_format}"
- #{p_text} #{p_fulltext} #{p_keywords} #{p_title} #{p_author} #{p_topic_register} #{p_subject} #{p_description} #{p_publisher} #{p_editor} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} #{p_filename} - - WOK - #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} - #% dbi_canning - @header=Form.new(@base,search_field,selected_db,result_type,checked_sql_limit,checked_tip,checked_stats,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_selected,checked_default,search_note,the_can).submission_form #% form - unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ - print "Content-type: text/html\n\n" - puts (@header+@tail) - else #% searches - s1=(@search_for.text1 =~/\S/) \ - ? @search_for.text1 - : 'Unavailable' - if checked_case=~/\S/ - @search[:text]<<%{doc_objects.clean~'#{CGI.unescape(s1)}'} - else - @search[:text]<<%{doc_objects.clean~*'#{CGI.unescape(s1)}'} - end - #% dbi_request - dbi_statement=DBI_SearchStatement.new(@conn,@search_for,q,checked_case) - @text_search_flag=false - @text_search_flag=dbi_statement.text_search_flag - s_contents=dbi_statement.contents - @body_main='' - @search_regx=nil - oldtid=0 - if @text_search_flag - if checked_sql =~/\S/ - sql_select_body=dbi_statement.sql_select_body_format - else sql_select_body='' - end - @body_main << sql_select_body - else - end - @hostpath="#{@hosturl_files}/#{@stub}" - WOK_SQL - end - def dir_structure #@opt.dir_structure_by - <<-'WOK_SQL' - def path_manifest(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{@hostpath}/#{fn}/sisu_manifest.html" - : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/manifest/#{fn}.html" - : "#{@hostpath}/manifest/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/manifest/#{fn}.html" - end - end - def path_html_seg(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - "#{@hostpath}/#{fn}" - when 'filetype' - "#{@hostpath}/html/#{fn}" - else - "#{@hostpath}/#{ln}/html/#{fn}" - end - end - def path_toc(fn,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/toc.html" - : "#{path_html_seg(fn,ln)}/toc.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/toc.html" - end - end - def path_filename(fn,seg,ln=nil) - if @output_dir_structure_by =='filename' \ - or @output_dir_structure_by =='filetype' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/#{seg}.html" - : "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" - else - "#{path_html_seg(fn,ln)}/#{seg}.html" - end - end - def path_html_doc(fn,ln=nil) - case @output_dir_structure_by - when 'filename' - @lingual =='mono' \ - ? "#{path_html_seg(fn,ln)}/scroll.html" - : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html" - when 'filetype' - @lingual =='mono' \ - ? "#{@hostpath}/html/#{fn}.html" - : "#{@hostpath}/html/#{fn}.#{ln}.html" - else - "#{@hostpath}/#{ln}/html/#{fn}.html" - end - end - WOK_SQL - end - def main3 - <<-'WOK_SQL' - #% text_objects_body - s_contents.each do |c| #% text body - location=c['src_filename'][/(.+?)\.(?:ssm\.sst|sst)$/,1] - file_suffix=c['src_filename'][/.+?\.(ssm\.sst|sst)$/,1] - lang=if location =~ /\S+?~(\S\S\S?)$/ - l=location[/\S+?~(\S\S\S?)$/,1] - location=location.gsub(/(\S+?)~\S\S\S?/,'\1') - l=".#{l}" - else '' - end - #% metadata_found_body - if c['tid'].to_i != oldtid.to_i - ti=c['title'] - can_txt_srch=(cgi['view']=~/index/) \ - ? %{search } - : %{search } - title=%{toc html #{ti} [#{c['language_document_char']}] by #{c['creator_author']} manifest #{can_txt_srch}
} if file_suffix=~/s/ #hmm watch file_suffix - title=@text_search_flag \ - ? '

'+title - : '
'+title - @counter_txt_doc+=1 - oldtid=c['tid'].to_i - else title='' - end - if @text_search_flag - if cgi['view']=~/text/ \ - or (cgi['view']!~/index/ and cgi['search'] !~/search db/) #% txt body - text=if c['suffix'] !~/1/ #seg - if @search_for.text1 =~/\S+/ \ - or q['s1'] =~/\S+/ #% only this branch is working !! - unescaped_search=if @search_for.text1 =~/\S+/ - CGI.unescape(@search_for.text1) - elsif q['s1'] =~/\S+/ - CGI.unescape(q['s1']) - else nil - end - @search_regx=if unescaped_search #check - search_regex=unescaped_search.scan(/\S+/).each.map do |g| - (g.to_s =~/(AND|OR)/) \ - ? ('|') - : (%{#{g.to_s}}) - end.join(' ') - search_regex=search_regex.gsub(/\s*\|\s*/,'|') - Regexp.new(search_regex, Regexp::IGNORECASE) - else nil - end - else nil - end - matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \ - ? (c['body'].gsub(/(<\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{\\1})) - : c['body'] - %{

ocn #{c['ocn']}:

#{matched_para}} - elsif c['suffix'] =~/1/ #doc - %{#{title}

ocn #{c['ocn']}:#{c['body']}} - end - @counter_txt_ocn+=1 - output=title+text - else #elsif cgi['view']=~/index/ #% idx body - if c['suffix'] !~/1/ #seg - index=%{#{c['ocn']}, } if @text_search_flag - elsif c['suffix'] =~/1/ #doc #FIX - index=%{#{c['ocn']}, } - end - if c['seg'] =~/\S+/ - if @text_search_flag - @counter_txt_ocn+=1 - output=title+index - end - else - @counter_txt_ocn+=1 - output=c['suffix'] !~/1/ \ - ? title+index - : %{#{title}#{c['ocn'].sort}, } - end - end - else output=title - end - @counters_txt=if @counter_txt_doc > 0 - if checked_stats =~/\S/ - @@lt_t=(@counter_txt_ocn==dbi_statement.sql_match_limit.to_i) ? true : false - start=(@@offset.to_i+1).to_s - range=(@@offset.to_i+@counter_txt_ocn.to_i).to_s - %{


Found #{@counter_txt_ocn} times in the main body of #{@counter_txt_doc} documents [ matches #{start} to #{range} ]
} - else '' - end - else '' - end - @body_main << output #+ details - end - oldtid = 0 - offset=dbi_statement.sql_offset.to_s - limit=dbi_statement.sql_match_limit.to_s - @@lt_t ||=false; @@lt_e ||=false - canned=(@@lt_t or @@lt_e) \ - ? dbi_statement.pre_next(true,@image_src).to_s - : dbi_statement.pre_next(false,@image_src).to_s - limit=dbi_statement.sql_match_limit.to_s - cgi.out{@header.force_encoding("UTF-8") + @counters_txt.force_encoding("UTF-8") + @counters_endn.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @body_main.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @tail.force_encoding("UTF-8")} #% print cgi_output_header+counters+body - end - rescue Exception => e - s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
-          s << CGI::escapeHTML(e.message) + '
' - cgi.out{s} - next - ensure # eg. disconnect from server - @conn.disconnect if @conn - end - end - WOK_SQL - end - end -end -__END__ diff --git a/lib/sisu/current/cgi_sqlite.rb b/lib/sisu/current/cgi_sqlite.rb deleted file mode 100644 index 91444237..00000000 --- a/lib/sisu/current/cgi_sqlite.rb +++ /dev/null @@ -1,244 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** generates naive cgi search form for search of sisu database (sqlite) - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_CGI_SQLite #% database building documents - require_relative 'se' # se.rb - require_relative 'cgi_sql_common' # cgi_sql_common.rb - include SiSU_CGI_SQL - class SearchSQLite < CGI_Common - def initialize(opt,webserv) - @opt,@webserv=opt,webserv - @cX=SiSU_Screen::Ansi.new(opt.act[:color_state][:set]).cX - @env=SiSU_Env::InfoEnv.new('',opt) - @image_src="#{@env.url.webserv_cgi(opt)}/_sisu/image_sys" - @name_of={} - @name_of[:output_dir_structure]=if opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/ - opt.dir_structure_by.to_s - else 'language' - end - @name_of[:lingual]=if opt.lingual.to_s =~/(?:mono|multi)/ - opt.lingual.to_s - else 'multi' - end - @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} - @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} - @name_of[:cgi_script]=%q{#{ENV['SCRIPT_NAME']}} - @image_src=%q{http://#{ENV['HTTP_HOST']}/_sisu/image_sys} - @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,opt,@image_src,@env) - @cgi_file_name=@env.url.cgi_sample_search_form_name(opt) - @name_of_sqlite_db_file='sisu_sqlite.db' - end - def sqlite - serve=[] - Dir.foreach(@env.path.webserv) do |x| - if x !~/^\./ \ - and FileTest.directory?("#{@env.path.webserv}/#{x}") - if FileTest.file?("#{@env.path.webserv}/#{x}/#{@name_of_sqlite_db_file}") - serve << x unless x =~/^_\S+/ - end - end - end - serve=serve.sort - f1,f2,f3='','','' - serve.each do |x| - f1 << %{ \n} - end - f2 << %{ selected_db=case cgi['db']\n} - serve.each do |x| - f2 << %{ when /#{Db[:name_prefix]}#{x}/ then ''\n} - end - f2 << " end\n" - f3 << %{ db_name='#{@name_of_sqlite_db_file}'\n} - f3 << %{ db_sqlite=case cgi['db']\n} - serve.each do |x| - f3 << %{ when /#{Db[:name_prefix]}#{x}/ then "#{@env.path.webserv}/#{x}/\#{db_name}"\n} - end - f3 << %{ else "#{@env.path.webserv}/#{serve[0]}/\#{db_name}"\n end\n} - if FileTest.writable?('.') - output=File.open(@cgi_file_name,'w') - output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << f3 << dbi_connect << @common.main2 << @common.dir_structure << @common.main3 - puts <<-WOK - generated sample search form: #{@cX.green}#{@cgi_file_name}#{@cX.off} - default database name: #{@cX.green}#{Db[:name_prefix]}#{@env.path.base_markup_dir_stub}#{@cX.off} (#{@env.path.base_markup_dir_stub}) - cgi & db host on: #{@cX.blue}#{@env.url.webserv_base_cgi(@opt)}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-sqlite --webserv-search='#{@env.url.webserv_base_cgi(@opt)}'#{@cX.off} - sisu output on: #{@cX.blue}#{@env.url.webserv_files_from_db(@opt)}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-sqlite --webserv-output='#{@env.url.webserv_files_from_db(@opt)}'#{@cX.off} - cgi search form link name: #{@cX.green}#{@env.url.cgi_sample_search_form_name(@opt)}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-sqlite --cgi-search-form-name='#{@env.url.cgi_sample_search_form_name(@opt)}'#{@cX.off} - #{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off} - - #{@cX.fuchsia}NOTE it is first necessary to create the database and tables and populate it#{@cX.off} - - sisu --sqlite --dropall # removes existing postgresql db & tables - sisu --sqlite --createall -v # creates postgresql db & tables - sisu --sqlite --update -v *.sst *.ssm # populate the db - sisu --sample-search-form --sqlite # creates the postgresql search form - # this should be done after creating the db - # to be searched - sisu --webrick & # starts ruby webrick web server - - # if necessary make the directory '/usr/lib/cgi-bin' - # here we copy the postgresql search form to cgi-bin - # (copy #{@cgi_file_name} to your cgi directory) - # set file permissions to 755 - WOK - a=case @webserv - when /pwd/ then '' - else <<-WOK - - sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\ - sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name} - WOK - end - b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)' - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a,b).warn - a=<<-WOK - - #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name} - - WOK - SiSU_Screen::Ansi.new(@opt.act[:color_state][:set],a).print_blue - else puts "failed in attempt to write #{@cgi_file_name} to present directory, is directory writable?" - end - end - def header0 - <<-WOK_SQL -#!/usr/bin/env ruby -=begin -#{about} - * Description: generates naive cgi search form for search of sisu database (sqlite) -#{gpl} -=end - begin - require 'cgi' - require 'fcgi' - require 'sqlite3' - rescue LoadError - puts 'cgi, fcgi or sqlite3 NOT FOUND (LoadError)' - end - @stub_default='sisu_sqlite' - @image_src="#{@image_src}" - @hosturl_cgi="#{@name_of[:host_url_cgi]}" - @hosturl_files="#{@name_of[:host_url_docs]}" - @output_dir_structure_by='#{@name_of[:output_dir_structure]}' - @lingual='#{@name_of[:lingual]}' - @db_name_prefix='#{Db[:name_prefix]}' - @base="#{@name_of[:host_url_cgi]}#{@name_of[:cgi_script]}" - WOK_SQL - end - def search_statement - <<-'WOK_SQL' - class DBI_SearchString - def initialize(l,t,q,cse=false) - @l,@t,@q=l,t,q - end - def string - search={ search: [], flag: false } - if @t =~/\S+/ or @q =~/\S+/ - if @t =~/\S+/ then unescaped_search=CGI.unescape(@t) - elsif @q =~/\S+/ then unescaped_search=CGI.unescape(@q) - end - search_construct=[] - unescaped_search=unescaped_search.gsub(/\s*(AND|OR)\s*/,"%' \) \\1 #{@l} LIKE \( '%"). - gsub(/(.+)/,"#{@l} LIKE \( '%\\1%' \)") - search_construct << unescaped_search - search_construct=search_construct.join(' ') - search[:search] << search_construct - search[:flag]=true - search - end - search - end - end - WOK_SQL - end - def search_query1 - <<-'WOK_SQL' - @search_text='' - @search_text=search[:text].flatten.join(' AND ') - @search_text=@search_text.gsub(/(doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\)\s+(?:(?:AND|OR)\s+doc_objects\.clean\s+LIKE\s+\(\s*'%[^']+%'\s*\))+)/,'(\1)') - end - WOK_SQL - end - def search_query2 - <<-'WOK_SQL' - def sql_select_body - limit ||=@@limit - offset ||=@@offset - @sql_statement[:body]=%{SELECT metadata_and_text.title, metadata_and_text.creator_author, metadata_and_text.src_filename, metadata_and_text.language_document_char, metadata_and_text.notes_suffix, doc_objects.body, doc_objects.seg, doc_objects.ocn, metadata_and_text.tid FROM doc_objects, metadata_and_text WHERE #{@search_text} AND doc_objects.metadata_tid = metadata_and_text.tid ORDER BY metadata_and_text.language_document_char, metadata_and_text.title, metadata_and_text.src_filename, doc_objects.ocn} - @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} - select=@sql_statement[:body] + ' ' + @sql_statement[:range] - select - end - def sql_select_body_format - %{#{sql_select_body}} - end - def contents - @conn.execute(sql_select_body) - end - end - WOK_SQL - end - def dbi_connect - <<-'WOK_SQL' - @conn=SQLite3::Database.new(db_sqlite) - @conn.results_as_hash=true - WOK_SQL - end - end -end -__END__ diff --git a/lib/sisu/current/conf.rb b/lib/sisu/current/conf.rb deleted file mode 100644 index 2bc71ce7..00000000 --- a/lib/sisu/current/conf.rb +++ /dev/null @@ -1,287 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** configuration - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Initialize - require_relative 'se' # se.rb - include SiSU_Env - include SiSU_Screen - require_relative 'relaxng' # relaxng.rb - include SiSU_Relaxng - require_relative 'css' # css.rb - include SiSU_Style - class Source - def initialize(opt) - @opt=opt - end - def read - ConfigSite.new(@opt).make_homepage - ConfigSite.new(@opt).css - ConfigSite.new(@opt).dtd - ConfigSite.new(@opt).cp_local_images - ConfigSite.new(@opt).cp_external_images - ConfigSite.new(@opt).cp_webserver_images - end - end - class ConfigSite #config files such as css are not updated if they already exist unless forced using the --init=site modifier - require_relative 'se' # se.rb - def initialize(opt) - @opt=opt - @env=SiSU_Env::InfoEnv.new(@opt.fns) - @suffix={ - rnc: 'rnc', - rng: 'rng', - xsd: 'xsd', - } - @path={ - xml: @env.path.output + '/_sisu/xml', - xsd: @env.path.output + '/_sisu/xml/xsd', - rnc: @env.path.output + '/_sisu/xml/rnc', - rng: @env.path.output + '/_sisu/xml/rng', - style: @env.path.output + '/' + @env.path.style, - } - @pwd,@home=Dir.pwd,@env.path.home - end - def make_homepage - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Make homepage', - '' - ).colorize unless @opt.act[:quiet][:set]==:on - SiSU_Env::CreateSite.new(@opt).homepage - end - def cp_local_images - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Copy images', - '' - ).colorize unless @opt.act[:quiet][:set]==:on - SiSU_Env::CreateSite.new(@opt).cp_local_images - SiSU_Env::CreateSite.new(@opt).cp_webserver_images_local #this should not have been necessary - SiSU_Env::CreateSite.new(@opt).cp_base_images #base images (nav etc.) used by all html - end - def cp_external_images - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Copy external images', - '' - ).colorize if @opt.act[:verbose_plus][:set]==:on - SiSU_Env::CreateSite.new(@opt).cp_external_images - end - def cp_webserver_images - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Copy webserver/output file images', - '' - ).colorize unless @opt.act[:quiet][:set]==:on - SiSU_Env::CreateSite.new(@opt).cp_webserver_images - end - def css - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Configuring CSSs', - '' - ).colorize unless @opt.act[:quiet][:set]==:on - SiSU_Env::CreateSite.new(@opt).cp_css - end - def dtd - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'invert', - 'Configuring DTDs', - '' - ).colorize unless @opt.act[:quiet][:set]==:on - @rxng=SiSU_Relaxng::RelaxNG.new - @path.each { |d| FileUtils::mkdir_p(d[1]) \ - unless FileTest.directory?(d[1]) } - #ugly code, sort later - if @rxng.methods.join =~/[^_]dtd_sax\b/ - if @rxng.dtd_sax.length > 200 - dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_sax}",'w') - dtd << @rxng.dtd_sax - dtd.close - else trang_rnc_model_output_sax - end - else trang_rnc_model_output_sax - end - if @rxng.methods.join =~/[^_]dtd_dom\b/ - if @rxng.dtd_dom.length > 200 - dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_dom}",'w') - dtd << @rxng.dtd_dom - dtd.close - else trang_rnc_model_output_dom - end - else trang_rnc_model_output_dom - end - if @rxng.methods.join =~/[^_]dtd_node\b/ - if @rxng.dtd_node.length > 200 - dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.input_node}",'w') - dtd << @rxng.dtd_node - dtd.close - else trang_rnc_model_input_node - end - else trang_rnc_model_input_node - end - if @rxng.methods.join =~/[^_]dtd_xhtml\b/ - if @rxng.dtd_xhtml.length > 200 - dtd=File.new("#{@path[:style]}/#{@rxng.rng_name.output_xhtml}",'w') - dtd << @rxng.dtd_xhtml - dtd.close - else trang_rnc_model_output_xhtml - end - else trang_rnc_model_output_xhtml - end - end - def trang_rnc_model_output_sax - s=@suffix - rnc_src=@env.processing_path.ao + '/sax.' + s[:rnc] - rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_sax - rng_file=@path[:rng] + '/' + @rxng.rng_name.output_sax - xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_sax - rnc=File.new(rnc_src,'w') - rnc << @rxng.rnc_model_output_sax - rnc.close - #xsd - schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) - schema.relaxng(@opt.selections.str) - #rng - schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) - schema.relaxng(@opt.selections.str) - #rnc - if FileTest.file?(rnc_src) - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) - else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} - end - end - def trang_rnc_model_output_dom - s=@suffix - rnc_src=@env.processing_path.ao + '/dom.' + s[:rnc] - rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_dom - rng_file=@path[:rng] + '/' + @rxng.rng_name.output_dom - xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_dom - rnc=File.new(rnc_src,'w') - rnc << @rxng.rnc_model_output_dom - rnc.close - #xsd - schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) - schema.relaxng(@opt.selections.str) - #rng - schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) - schema.relaxng(@opt.selections.str) - #rnc - if FileTest.file?(rnc_src) - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) - else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} - end - end - def trang_rnc_model_output_xhtml - s=@suffix - rnc_src=@env.processing_path.ao + '/xhtml.' + s[:rnc] - rnc_file=@path[:rnc] + '/' + @rxng.rnc_name.output_xhtml - rng_file=@path[:rng] + '/' + @rxng.rng_name.output_xhtml - xsd_file=@path[:xsd] + '/' + @rxng.xsd_name.output_xhtml - rnc=File.new(rnc_src,'w') - rnc << @rxng.rnc_model_output_xhtml - rnc.close - #xsd - schema=SiSU_Env::SystemCall.new(rnc_src,xsd_file) - schema.relaxng(@opt.selections.str) - #rng - schema=SiSU_Env::SystemCall.new(rnc_src,rng_file) - schema.relaxng(@opt.selections.str) - #rnc - if FileTest.file?(rnc_src) - FileUtils::cp(rnc_src,rnc_file) - FileUtils::chmod(0644,rnc_file) - else STDERR.puts %{\t*WARN* did not find rnc - "#{rnc_src}" [#{__FILE__}:#{__LINE__}]} - end - end - def trang_rnc_model_input_sax - rnc_file=@env.processing_path.ao + '/sax.rnc' - dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_sax - rnc=File.new(rnc_file,'w') - rnc << @rxng.rnc_model_output_sax - rnc.close - schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) - schema.relaxng(@opt.selections.str) - end - def trang_rnc_model_input_dom - rnc_file=@env.processing_path.ao + '/dom.rnc' - dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_dom - rnc=File.new(rnc_file,'w') - rnc << @rxng.rnc_model_output_dom - rnc.close - schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) - schema.relaxng(@opt.selections.str) - end - def trang_rnc_model_input_node - rnc_file=@env.processing_path.ao + '/node.rnc' - dtd_file=@path[:xsd] + '/' + @rxng.rng_name.input_node - rnc=File.new(rnc_file,'w') - rnc << @rxng.rnc_model_input_node - rnc.close - schema=SiSU_Env::SystemCall.new(rnc_file,dtd_file) - schema.relaxng(@opt.selections.str) - end - end -end -__END__ diff --git a/lib/sisu/current/constants.rb b/lib/sisu/current/constants.rb deleted file mode 100644 index 175c2e70..00000000 --- a/lib/sisu/current/constants.rb +++ /dev/null @@ -1,388 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** constants, system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -#Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}} -YEAR='2014' -Sfx={ - txt: '.txt', - txt_textile: '.textile', - txt_asciidoc: '.ad', - txt_markdown: '.md', - txt_rst: '.rst', - txt_orgmode: '.org', - html: '.html', - xhtml: '.xhtml', - xml: '.xml', - xml_sax: '.sax.xml', - xml_dom: '.dom.xml', - xml_scaffold: '.scaffold.xml', - xml_scaffold_structure_sisu: '.scaffold.sisu.xml', - xml_scaffold_structure_collapse: '.scaffold.collapse.xml', - xml_docbook: '.docbook.xml', - xml_docbook_article: '.article.docbook.xml', - xml_docbook_book: '.book.docbook.xml', - xml_fictionbook: '.fb2', - epub: '.epub', - epub_xhtml: '.xhtml', - odt: '.odt', - pdf: '.pdf', - manpage: '.1', - info: '.info', - texinfo: '.texinfo', - sql: '.sql.db', -} -Ax={ - tab: "\t", - comment: '%', - spaces: ' ', -} -Xx={ - protect: '☞', - split: '✠', - segment: 'Ф', - relative_path: '☼', - html_relative2: '※※', - html_relative1: '※', -} -Mx={ - segname_prefix_auto_num_extract: 'c', - segname_prefix_auto_num_provide: 's', - segname_prefix_auto_num_other: 'x', - ocn_id_char: '', #'o', now as before; remove for html5 - note: 'note_', - note_ref: 'noteref_', - note_astx: 'note_astx_', - note_ref_astx: 'noteref_astx_', - note_plus: 'note_plus_', - note_ref_plus: 'noteref_plus_', - meta_o: '〔@', meta_c: '〕', - lv_o_0: 0, - lv_o_1: 1, - lv_o_2: 2, - lv_o_3: 3, - lv_o_4: 4, - lv_o_5: 5, - lv_o_6: 6, - lv_o_7: 7, - lv_o_8: 8, - lv_o_9: 9, - lv_o: '〔', lv_c: '〕', - en_a_o: '【', en_a_c: '】', #endnote Mx[:en_a_o]='~{'; Mx[:en_a_c]='}~' - en_b_o: '〖', en_b_c: '〗', #endnote Mx[:en_b_o]='~['; Mx[:en_b_c]=']~' - bl_o: '〔', bl_c: '〕', #block text mark - gr_o: '〔', gr_c: '〕', #group text mark #REPLACE & RETIRE - id_o: '〔', id_c: '〕', #object id mark - tc_o: '『', tc_c: "』", #table row mark #Mx[:tc_c]="』\n" - tc_p: '┆', #table col/misc mark - pa_o: '〔', pa_c: '〕', #affects paragraph mark - mk_o: '〔', mk_c: '〕', #generic mark - gl_o: '〔', gl_c: '〕', #glyph - fa_o: '〔', fa_o_c: '¤', fa_c_o: '¤', fa_c: '〕', - idx_o: '▩', idx_c: '▩', - nbsp: '░', #'▭ ' - br_line: '╱', #lB ▌ 9612 ┘ ¶ - br_nl: '╲', #lB ▌ 』 ┘ - br_paragraph: '█', #FB █ 9608 # PP ∥ 8741 #▐ #'┘' #'¶' #FB █ 9608 lB ▌ 9612 RB ▐ 9616 - br_obj: 'break_obj', - br_page_line: '▭', - br_page: '┼', - br_page_new: '╋', - lnk_o: '⌠', lnk_c: '⌡', #'⌈' '⌋' '⌠' '⌡' #Mx[:lnk_o: '◁'; Mx[:lnk_c: '▷' #‹ › - url_o: '◘', url_c: '◙', - rel_o: '⌈', rel_c: '⌋', - tag_o: '⌊', tag_c: '⌉', - sm_set_o: '◢', sm_set_c: '◣', - sm_subset_o: '◢', sm_subset_c: '◣', - vline: '┆', # ¦ | - src_bold_o: '!{', src_bold_c: '}!', - src_italics_o: '/{', src_italics_c: '}/', - src_underscore_o: '_{', src_underscore_c: '}_', - src_cite_o: '"{', src_cite_c: '}"', - src_insert_o: '+{', src_insert_c: '}+', - src_strike_o: '-{', src_strike_c: '}-', - src_superscript_o: '^{', src_superscript_c: '}^', - src_subscript_o: ',{', src_subscript_c: '}', - src_hilite_o: '*{', src_hilite_c: '}*', - src_monospace_o: '#{', src_monospace_c: '}#', - srcrgx_bold_o: '\!\{', srcrgx_bold_c: '\}\!', - srcrgx_italics_o: '\/\{', srcrgx_italics_c: '\}\/', - srcrgx_underscore_o: '_\{', srcrgx_underscore_c: '\}_', - srcrgx_cite_o: '"\{', srcrgx_cite_c: '\}"', - srcrgx_insert_o: '\+\{', srcrgx_insert_c: '\}\+', - srcrgx_strike_o: '\-\{', srcrgx_strike_c: '\}\-', - srcrgx_superscript_o: '\^\{', srcrgx_superscript_c: '\}\^', - srcrgx_subscript_o: ',\{', srcrgx_subscript_c: '\},', - srcrgx_hilite_o: '\*\{', srcrgx_hilite_c: '\}\*', - srcrgx_monospace_o: '\#\{', srcrgx_monospace_c: '\}\#', -} -Mx[:fa_bold_o]= "#{Mx[:fa_o]}b#{Mx[:fa_o_c]}" -Mx[:fa_bold_c]= "#{Mx[:fa_c_o]}b#{Mx[:fa_c]}" -Mx[:fa_italics_o]= "#{Mx[:fa_o]}i#{Mx[:fa_o_c]}" -Mx[:fa_italics_c]= "#{Mx[:fa_c_o]}i#{Mx[:fa_c]}" -Mx[:fa_underscore_o]= "#{Mx[:fa_o]}u#{Mx[:fa_o_c]}" -Mx[:fa_underscore_c]= "#{Mx[:fa_c_o]}u#{Mx[:fa_c]}" -Mx[:fa_cite_o]= "#{Mx[:fa_o]}cite#{Mx[:fa_o_c]}" -Mx[:fa_cite_c]= "#{Mx[:fa_c_o]}cite#{Mx[:fa_c]}" -Mx[:fa_insert_o]= "#{Mx[:fa_o]}ins#{Mx[:fa_o_c]}" -Mx[:fa_insert_c]= "#{Mx[:fa_c_o]}ins#{Mx[:fa_c]}" -Mx[:fa_strike_o]= "#{Mx[:fa_o]}del#{Mx[:fa_o_c]}" -Mx[:fa_strike_c]= "#{Mx[:fa_c_o]}del#{Mx[:fa_c]}" -Mx[:fa_superscript_o]= "#{Mx[:fa_o]}sup#{Mx[:fa_o_c]}" -Mx[:fa_superscript_c]= "#{Mx[:fa_c_o]}sup#{Mx[:fa_c]}" -Mx[:fa_subscript_o]= "#{Mx[:fa_o]}sub#{Mx[:fa_o_c]}" -Mx[:fa_subscript_c]= "#{Mx[:fa_c_o]}sub#{Mx[:fa_c]}" -Mx[:fa_hilite_o]= "#{Mx[:fa_o]}hi#{Mx[:fa_o_c]}" -Mx[:fa_hilite_c]= "#{Mx[:fa_c_o]}hi#{Mx[:fa_c]}" -Mx[:fa_monospace_o]= "#{Mx[:fa_o]}mono#{Mx[:fa_o_c]}" -Mx[:fa_monospace_c]= "#{Mx[:fa_c_o]}mono#{Mx[:fa_c]}" -Mx[:gl_bullet]= "#{Mx[:gl_o]}●#{Mx[:gl_c]}" -Mx[:br_endnotes]= "#{Mx[:mk_o]}ENDNOTES#{Mx[:mk_c]}" -Mx[:br_eof]= "#{Mx[:mk_o]}EOF#{Mx[:mk_c]}" -Mx[:pa_non_object_dummy_heading]="#{Mx[:pa_o]}-##{Mx[:pa_c]}" #unnumbered paragraph, delete when not required [used in dummy headings, eg. for segmented html] (place marker at end of paragraph) -Mx[:pa_non_object_no_heading]="#{Mx[:pa_o]}~##{Mx[:pa_c]}" #unnumbered paragraph (place marker at end of paragraph) -Hx={ - br_obj: { obj: Mx[:br_obj] }, # line sep - br_page_line: { obj: Mx[:br_page_line] }, # line across page - br_page: { obj: Mx[:br_page] }, # newpage - br_page_new: { obj: Mx[:br_page_new] }, # clearpage -} -#Mx[:sm_set_o]='∈ '; Mx[:sm_set_c]='∋ ' -#Mx[:sm_subset_o]='∈ '; Mx[:sm_subset_c]='∋ ' -Rx={ - mx_fa_clean: /#{Mx[:fa_o]}.+?#{Mx[:fa_c]}|#{Mx[:pa_o]}.+?#{Mx[:pa_c]}|#{Mx[:mk_o]}.+?#{Mx[:mk_c]}/, - lv: /〔([0-9]):(\S*?)〕/, - lv_0: /#{Mx[:lv_o_0]}(\S*?)#{Mx[:lv_c]}/, - lv_1: /#{Mx[:lv_o_1]}(\S*?)#{Mx[:lv_c]}/, - lv_2: /#{Mx[:lv_o_2]}(\S*?)#{Mx[:lv_c]}/, - lv_3: /#{Mx[:lv_o_3]}(\S*?)#{Mx[:lv_c]}/, - lv_4: /#{Mx[:lv_o_4]}(\S*?)#{Mx[:lv_c]}/, - lv_5: /#{Mx[:lv_o_5]}(\S*?)#{Mx[:lv_c]}/, - lv_6: /#{Mx[:lv_o_6]}(\S*?)#{Mx[:lv_c]}/, - lv_7: /#{Mx[:lv_o_7]}(\S*?)#{Mx[:lv_c]}/, - lv_8: /#{Mx[:lv_o_8]}(\S*?)#{Mx[:lv_c]}/, - lv_9: /#{Mx[:lv_o_9]}(\S*?)#{Mx[:lv_c]}/, - meta: /#{Mx[:meta_o]}(\S+?)#{Mx[:meta_c]}/, -} -Dx={ - ocn_o: '「', ocn_c: '」', - url_o: '‹', url_c: '›', - url_o_xml: '<', url_c_xml: '>', - rel_o: '‹', rel_c: '›', - lt_xml: '<', gt_xml: '>', -} -Tex={ - backslash: "\\\\", - backslash: "\\\\", - tilde: '\\\\\\~', -} -Px={ - bold_o: '*', bold_c: '*', - italics_o: '/', italics_c: '/', - underscore_o: '_', underscore_c: '_', - #emphasis_o: '*', emphasis_c: '*', - #bold_o: '!', bold_c: '!', - cite_o: '"', cite_c: '"', - insert_o: '+', insert_c: '+', - strike_o: '-', strike_c: '-', - superscript_o: '^', superscript_c: '^', - subscript_o: '[', subscript_c: ']', - hilite_o: '*', hilite_c: '*', - monospace_o: '', monospace_c: '', - lng_lst: SiSU_is.language_list?, - lng_lst_rgx: SiSU_is.language_list_regex?, - lv1: '*', - lv2: '=', - lv3: '=', - lv4: '-', - lv5: '.', - lv6: '.', -} -Px[:lng_lst_rgx]=Px[:lng_lst].join('|') -Ep={ - alt: :on, - d_oebps: 'OEBPS', - d_image: 'OEBPS/image', - d_css: 'OEBPS/css', - f_ncx: 'toc.ncx', - f_opf: 'content.opf', -} -$ep=if Ep[:alt]==:on - { - o: 'opf:', - hsp: ' ', - } -else - { - o: '', - hsp: ' ', - } -end -Db={ - name_prefix: "SiSU#{SiSU_is.branch_version?}c_", - name_prefix_db: "sisu_#{SiSU_is.branch_version?}c_", - col_title: 800, - col_title_part: 400, - col_title_edition: 10, - col_name: 600, - col_creator_misc_short: 100, - col_language: 100, - col_language_char: 6, - col_date_text: 10, - col_txt_long: 600, - col_txt_short: 200, - col_identify_hash: 256, - col_library: 30, - col_small: 16, - col_filename: 256, - col_digest: 128, - col_filesize: 10, - col_info_note: 2500, -} -Gt={ - grotto: 'sisu_src', - git: 'sisu:', - src: 'src', - pods: 'pods', - sisupod: 'sisupod', - pod: 'pod', - files: 'files', - doc: 'doc', - po: 'po4a/po', - pot: 'po4a/pot', - image: 'image', - audio: 'audio', - video: 'video', - conf: 'doc/_sisu', -} -S_CONF={ - header_make: 'sisu_document_make', - rc_yml: 'sisurc.yml', -} -ANSI_C={ - red: "\033[#{31}m", - green: "\033[#{32}m", - yellow: "\033[#{33}m", - blue: "\033[#{34}m", - fuchsia: "\033[#{35}m", - cyan: "\033[#{36}m", - inv_red: "\033[#{41}m", - inv_green: "\033[#{42}m", - inv_yellow: "\033[#{43}m", - inv_blue: "\033[#{44}m", - inv_fuchsia: "\033[#{45}m", - inv_cyan: "\033[#{46}m", - b_red: "\033[#{91}m", - b_green: "\033[#{92}m", - b_yellow: "\033[#{93}m", - b_blue: "\033[#{94}m", - b_fuchsia: "\033[#{95}m", - b_cyan: "\033[#{96}m", - off: "\033[m" -} -DISABLE={ - epub: { - internal_navigation: true, - per_section_title: true, - ncx_navpoint_unique_id: true, - }, -} -DEVELOPER={ - maintenance: :false, - under_construction: '_CONSTRUCTION_ZONE', -} -__END__ -utils.rb -consider: - 〔comment〕 - 〔links?????〕 - import document? -check: - bold line - -┆┆⋮┇┊┋ -『』 -「」 -〔〕 -【】 - -· -¤ - #˝ " λ Ω β α π Ѫ Ж Я Ѳ ѳ Ф ✠ ㈣ - Ѳ ѳ Ф - ♩ ♭  ✠  ▭ ▬ ▪ -【】〖〗◢ ◣ ◀ ▶ ◘ ◙ « ▲ » -《》「」 - ‹ › ∗  ∴ ∷ -'〔lv1〕','〔lv2〕','〔lv3〕','〔lv4〕','〔lv5〕','〔lv6〕','〔lv7〕','〔lv8〕','〔lv9〕' -'〔 Ѳ1〕','〔 Ѳ2〕','〔 Ѳ3〕','〔 Ѳ4〕','〔 Ѳ5〕','〔Ѳ6〕','〔Ѳ7〕','〔Ѳ8〕','〔Ѳ9〕' -◁▷ -◀this is text or an image▶ http:// -p __FILE__ +':'+ __LINE__.to_s -p __FILE__ + ' ' + __LINE__.to_s + ' ' + html -puts "#{__FILE__} #{__LINE__} #{o.inspect}" -puts __FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect -puts %{-\t#{__FILE__}::#{__LINE__}::#{caller}:\n"#{name}"} -p "\t" + txt.obj + " << #{__FILE__} #{__LINE__} >>" -p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + dob.inspect) if dob.is==:heading -data.each {|o| p (__FILE__ + ' ' + __LINE__.to_s + '--> ' + o.inspect) if o.is==:heading} -puts "#{__FILE__} #{__LINE__} #{para}" if @opt.act[:maintenance][:set]==:on -puts "#{__FILE__} #{__LINE__} #{t_o}" if @opt.act[:maintenance][:set]==:on - dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ - dr ┌ 9484 dR ┍ 9485 Dr ┎ 9486 DR ┏ 9487 dl ┐ 9488 dL ┑ 9489 Dl ┒ 9490 LD ┓ 9491 ur └ 9492 uR ┕ 9493 Ur ┖ 9494 UR ┗ 9495 ul ┘ 9496 uL ┙ 9497 Ul ┚ 9498 UL ┛ 9499 vr ├ - └ ┘ -Iu ⌠ 8992 Il ⌡ <7 ⌈ 8968 >7 ⌉ 8969 7< ⌊ 8970 7> ⌋ 8971 -<" 『 12302 >" 』 12303 -<' 「 12300 >' 」 12301 diff --git a/lib/sisu/current/css.rb b/lib/sisu/current/css.rb deleted file mode 100644 index 1832b66c..00000000 --- a/lib/sisu/current/css.rb +++ /dev/null @@ -1,3484 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** css stylesheets - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Style - require_relative 'se' # se.rb - require_relative 'html_parts' # html_parts.rb - class CSS_HeadInfo - def initialize(md,ft='html') - @md,@ft=md,ft - @env=SiSU_Env::InfoEnv.new('',md) - @fn_css ||=SiSU_Env::CSS_Default.new - @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - css_copy - end - def stylesheet - def css_path - SiSU_Env::CSS_Stylesheet.new(@md) - end - def css_embed_content - @css_embed_content ||=SiSU_Style::CSS.new - end - def css_embed? - if @ft=='html' \ - && @o_str.dump_or_redirect? - true - else - false - end - end - def css_embed(css) - <<-WOK - - WOK - end - def css_action - css=case @ft - when 'html' - css=css_embed_content.html - css_embed(css) - when 'xhtml' - css_path.xhtml - when 'xml_sax' - css_path.xml_sax - when 'xml_dom' - css_path.xml_dom - when 'xml_docbook' - css_path.xml_docbook - else - css_embed_content.html - end - end - def css_head - (css_embed?) \ - ? css_action - : "#{css_path.html}#{css_path.html_seg}" - end - def css_head_seg - (css_embed?) \ - ? css_action - : css_path.html_seg - end - def css_head_xml - css_action - end - self - end - def css_copy - if @o_str.dump_or_redirect? - css=SiSU_Style::CSS.new - if @o_str.dump? - css_pth="#{@md.opt.opt_act[:dump][:inst]}/#{@env.path.style}" - elsif @o_str.redirect? - css_pth="#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}/#{@env.path.style}" - end - FileUtils::mkdir_p(css_pth) unless FileTest.directory?(css_pth) - case @ft - when 'html' - style=File.new("#{css_pth}/#{@fn_css.html}",'w') - style << css.html - style.close - when 'xhtml' - style=File.new("#{css_pth}/#{@fn_css.xhtml}",'w') - style << css.xhtml - style.close - when 'xml_sax' - style=File.new("#{css_pth}/#{@fn_css.xml_sax}",'w') - style << css.xml_sax - style.close - when 'xml_dom' - style=File.new("#{css_pth}/#{@fn_css.xml_dom}",'w') - style << css.xml_dom - style.close - css_path.xml_dom - when 'xml_docbook' - style=File.new("#{css_pth}/#{@fn_css.xml_docbook}",'w') - style << css.xml_docbook - style.close - css_path.xml_docbook - end - end - end - end - class CSS - include SiSU_Parts_HTML - def fonts - the_font.set_fonts - end - def html_tables #stylesheet for css table_pages -< - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbColumns - require_relative 'se' # se.rb - require_relative 'db_sqltxt' # db_sqltxt.rb - class Columns < SiSU_DbText::Prepare - def initialize(md=nil) - @md=md - @db=SiSU_Env::InfoDb.new #watch - @lang ||=SiSU_i18n::Languages.new - if defined? md.opt.act \ - and ((md.opt.act[:psql_import][:set]==:on \ - || md.opt.act[:psql_update][:set]==:on) \ - or (md.opt.act[:sqlite_import][:set]==:on \ - || md.opt.act[:sqlite_update][:set]==:on)) \ - and FileTest.exist?(md.fns) - txt_arr=IO.readlines(md.fns,'') - src=txt_arr.join("\n") - if @db.share_source? - @sisutxt=special_character_escape(src) - else @sisutxt='' - end - @fulltext=clean_searchable_text_from_document_objects(txt_arr) - else @sisutxt,@fulltext='','' - end - end -#% structures - #def column_define - # def varchar(name,size) - # "#{name} VARCHAR(#{size}) NULL," - # end - #end -=begin -#% title -@title: - :subtitle: - :short: - :edition: - :language: - :note: -=end - def column - def title # DublinCore 1 - title - def name - 'title' - end - def create_column - "#{name} VARCHAR(#{Db[:col_title]}) NOT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata full document title [DC1]';} - end - def tuple - if defined? @md.title.full \ - and @md.title.full=~/\S+/ - txt=@md.title.full - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_main - def name - 'title_main' - end - def create_column - "#{name} VARCHAR(#{Db[:col_title_part]}) NOT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata main document title';} - end - def tuple - if defined? @md.title.main \ - and @md.title.main=~/\S+/ - txt=@md.title.main - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_sub - def name - 'title_sub' - end - def create_column - "#{name} VARCHAR(#{Db[:col_title_part]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document subtitle';} - end - def tuple - if defined? @md.title.sub \ - and @md.title.sub=~/\S+/ - txt=@md.title.sub - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_short - def name - 'title_short' - end - def create_column - "#{name} VARCHAR(#{Db[:col_title_part]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document short title if any';} - end - def tuple - if defined? @md.title.short \ - and @md.title.short=~/\S+/ - txt=@md.title.short - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_edition - def name - 'title_edition' - end - def create_column - "#{name} VARCHAR(#{Db[:col_title_edition]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document edition (version)';} - end - def tuple - if defined? @md.title.edition \ - and @md.title.edition=~/\S+/ - txt=@md.title.edition - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_note - def name - 'title_note' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes associated with title';} - end - def tuple - if defined? @md.title.note \ - and @md.title.note=~/\S+/ - txt=@md.title.note - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_language - def name - 'title_language' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document language [DC12]';} - end - def tuple - if @lang.list[@md.opt.lng][:n] - txt=@lang.list[@md.opt.lng][:n] - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def title_language_char # consider - def name - 'title_language_char' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language_char]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document language iso code';} - end - def tuple - if defined? @md.opt.lng \ - and @md.opt.lng=~/\S+/ - txt=@md.opt.lng - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% creator -@creator: - :author: - :editor: - :contributor: - :illustrator: - :photographer: - :translator: - :prepared_by: - :digitized_by: - :audio: - :video: -=end - def creator_author # DublinCore 2 - creator/author (author) - def name - 'creator_author' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document author (creator) [DC2]';} - end - def tuple - if defined? @md.creator.author_detail \ - and @md.creator.author_detail.is_a?(Array) \ - and @md.creator.author_detail.length > 0 - txt='' - @md.creator.author_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_author_honorific # consider - def name - 'creator_author_hon' - end - def create_column - "#{name} VARCHAR(#{Db[:col_creator_misc_short]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document author honorific (title e.g, Ms. Dr. Prof.)';} - end - def tuple - if defined? @md.creator.author_hon \ - and @md.creator.author_hon=~/\S+/ - txt=@md.creator.author_hon - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_author_nationality # consider - def name - 'creator_author_nationality' - end - def create_column - "#{name} VARCHAR(#{Db[:col_creator_misc_short]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata nationality of document author (creator)';} - end - def tuple - if defined? @md.creator.author_nationality_detail \ - and @md.creator.author_nationality=~/\S+/ - txt=@md.creator.author_nationality_detail - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_editor - def name - 'creator_editor' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document editor name(s)';} - end - def tuple - if defined? @md.creator.editor_detail \ - and @md.creator.editor_detail.is_a?(Array) \ - and @md.creator.editor_detail.length > 0 - txt='' - @md.creator.editor_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_contributor # DublinCore 6 - contributor - def name - 'creator_contributor' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document contributor name(s) [DC6]';} - end - def tuple - if defined? @md.creator.contributor_detail \ - and @md.creator.contributor_detail.is_a?(Array) \ - and @md.creator.contributor_detail.length > 0 - txt='' - @md.creator.contributor_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_illustrator - def name - 'creator_illustrator' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document illustrator name(s)';} - end - def tuple - if defined? @md.creator.illustrator_detail \ - and @md.creator.illustrator_detail.is_a?(Array) \ - and @md.creator.illustrator_detail.length > 0 - txt='' - @md.creator.illustrator_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_photographer - def name - 'creator_photographer' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document photographer name(s)';} - end - def tuple - if defined? @md.creator.photographer_detail \ - and @md.creator.photographer_detail.is_a?(Array) \ - and @md.creator.photographer_detail.length > 0 - txt='' - @md.creator.photographer_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_translator - def name - 'creator_translator' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document translator name(s)';} - end - def tuple - if defined? @md.creator.translator_detail \ - and @md.creator.translator_detail.is_a?(Array) \ - and @md.creator.translator_detail.length > 0 - txt='' - @md.creator.translator_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_prepared_by - def name - 'creator_prepared_by' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document prepared by name(s)';} - end - def tuple - if defined? @md.creator.prepared_by_detail \ - and @md.creator.prepared_by_detail.is_a?(Array) \ - and @md.creator.prepared_by_detail.length > 0 - txt='' - @md.creator.prepared_by_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_digitized_by - def name - 'creator_digitized_by' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document digitized by name(s)';} - end - def tuple - if defined? @md.creator.digitized_by_detail \ - and @md.creator.digitized_by_detail.is_a?(Array) \ - and @md.creator.digitized_by_detail.length > 0 - txt='' - @md.creator.digitized_by_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_audio - def name - 'creator_audio' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document audio by name(s)';} - end - def tuple - if defined? @md.creator.audio_detail \ - and @md.creator.audio_detail.is_a?(Array) \ - and @md.creator.audio_detail.length > 0 - txt='' - @md.creator.audio_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def creator_video - def name - 'creator_video' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document video by name(s)';} - end - def tuple - if defined? @md.creator.video_detail \ - and @md.creator.video_detail.is_a?(Array) \ - and @md.creator.video_detail.length > 0 - txt='' - @md.creator.video_detail.each do |h| - txt=txt + %{#{h[:the]}, #{h[:others]}; } - end - txt=txt.gsub(/[;, ]+\s*$/,'') - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% language -#taken from other fields -@title: - :language: -@original: - :language: -#not available --> -#@language: -# :document: -# :original: -=end - def language_document - def name - 'language_document' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document language';} - end - def tuple - if @lang.list[@md.opt.lng][:n] - txt=@lang.list[@md.opt.lng][:n] - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def language_document_char - def name - 'language_document_char' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language_char]}) NOT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document language';} - end - def tuple - #modify check, is now required, SiSUv3d_ - if defined? @md.opt.lng \ - and @md.opt.lng=~/\S+/ - txt=@md.opt.lng - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def language_original - def name - 'language_original' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata original document/text language';} - end - def tuple - if defined? @md.language.original \ - and @md.language.original=~/\S+/ - txt=@md.language.original - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def language_original_char - def name - 'language_original_char' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language_char]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document language';} - end - def tuple - if defined? @md.language.original_char \ - and @md.language.original_char=~/\S+/ - txt=@md.language.original_char - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% date -@date: - :added_to_site: - :available: - :created: - :issued: - :modified: - :published: - :valid: - :translated: - :original_publication: -=end - def date_added_to_site - def name - 'date_added_to_site' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - #"#{name} DATE," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date added to site';} - end - def tuple - if defined? @md.date.added_to_site \ - and @md.date.added_to_site=~/\S+/ - txt=@md.date.added_to_site - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_available - def name - 'date_available' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date added to site [DC]';} - end - def tuple - if defined? @md.date.available \ - and @md.date.available=~/\S+/ - txt=@md.date.available - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_created - def name - 'date_created' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date created [DC]';} - end - def tuple - if defined? @md.date.created \ - and @md.date.created=~/\S+/ - txt=@md.date.created - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_issued - def name - 'date_issued' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date issued [DC]';} - end - def tuple - if defined? @md.date.issued \ - and @md.date.issued=~/\S+/ - txt=@md.date.issued - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_modified - def name - 'date_modified' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date modified [DC]';} - end - def tuple - if defined? @md.date.modified \ - and @md.date.modified=~/\S+/ - txt=@md.date.modified - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_published - def name - 'date_published' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date published [DC7]';} - end - def tuple - if defined? @md.date.published \ - and @md.date.published=~/\S+/ - txt=@md.date.published - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_valid - def name - 'date_valid' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date valid [DC]';} - end - def tuple - if defined? @md.date.valid \ - and @md.date.valid=~/\S+/ - txt=@md.date.valid - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_translated - def name - 'date_translated' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date translated';} - end - def tuple - if defined? @md.date.translated \ - and @md.date.translated=~/\S+/ - txt=@md.date.translated - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_original_publication - def name - 'date_original_publication' - end - def create_column - "#{name} VARCHAR(#{Db[:col_date_text]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date of original publication';} - end - def tuple - if defined? @md.date.original_publication \ - and @md.date.original_publication=~/\S+/ - txt=@md.date.original_publication - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def date_generated - def name - 'date_generated' - end - def create_column #choose other representation of time - "#{name} VARCHAR(30) NULL," - #"#{name} VARCHAR(10) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata date of sisu generation of document, automatically populated';} - end - def tuple #choose other representation of time - if defined? @md.generated \ - and @md.generated.to_s=~/\S+/ - txt=@md.generated.to_s - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% publisher -@publisher: -=end - def publisher - def name - 'publisher' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document publisher [DC5]';} - end - def tuple - if defined? @md.publisher \ - and @md.publisher=~/\S+/ - txt=@md.publisher - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -##% current -# def current_publisher -# def name -# 'current_publisher' -# end -# def size -# 10 -# end -# def create_column -# "#{name} VARCHAR(#{current_publisher.size}) NULL," -# end -# def tuple -# t=if defined? @md.current.publisher \ -# and @md.current.publisher=~/\S+/ -# txt=@md.current.publisher -# txt=special_character_escape(txt) -# "'#{txt}', " -# end -# end -# self -# end -=begin -#% original -@original: - :publisher: - #:date: #repeated under date - :language: - :institution: - :nationality: - :source: -=end - def original_publisher - def name - 'original_publisher' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original publisher [DC5]';} - end - def tuple - if defined? @md.original.publisher \ - and @md.original.publisher=~/\S+/ - txt=@md.original.publisher - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def original_language - def name - 'original_language' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original language';} - end - def tuple - if defined? @md.original.language \ - and @md.original.language=~/\S+/ - txt=@md.original.language - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def original_language_char # consider - def name - 'original_language_char' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language_char]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original language iso character';} - end - def tuple - if defined? @md.original.language_char \ - and @md.original.language_char=~/\S+/ - txt=@md.original.language_char - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def original_source - def name - 'original_source' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original source [DC11]';} - end - def tuple - if defined? @md.original.source \ - and @md.original.source=~/\S+/ - txt=@md.original.source - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def original_institution - def name - 'original_institution' - end - def create_column - "#{name} VARCHAR(#{Db[:col_name]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original institution';} - end - def tuple - if defined? @md.original.institution \ - and @md.original.institution=~/\S+/ - txt=@md.original.institution - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def original_nationality - def name - 'original_nationality' - end - def create_column - "#{name} VARCHAR(#{Db[:col_language]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document original nationality';} - end - def tuple - if defined? @md.original.nationality \ - and @md.original.nationality=~/\S+/ - txt=@md.original.nationality - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% rights -@rights: - #:copyright: #mapped to :text: used where no other copyrights and included in :all: - :text: - :translation: - :illustrations: - :photographs: - :preparation: - :digitization: - :audio: - :video: - :license: - :all: -=end - def rights_all - def name - 'rights' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata rights associated with document (composite) [DC15]';} - end - def tuple - if defined? @md.rights.all \ - and @md.rights.all=~/\S+/ - txt=@md.rights.all - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_text - def name - 'rights_copyright_text' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text';} - end - def tuple - if defined? @md.rights.copyright_text \ - and @md.rights.copyright_text=~/\S+/ - txt=@md.rights.copyright_text - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_translation - def name - 'rights_copyright_translation' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text translation (if any)';} - end - def tuple - if defined? @md.rights.copyright_translation \ - and @md.rights.copyright_translation=~/\S+/ - txt=@md.rights.copyright_translation - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_illustrations - def name - 'rights_copyright_illustrations' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text illustrations (if any)';} - end - def tuple - if defined? @md.rights.copyright_illustrations \ - and @md.rights.copyright_illustrations=~/\S+/ - txt=@md.rights.copyright_illustrations - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_photographs - def name - 'rights_copyright_photographs' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text photographs (if any)';} - end - def tuple - if defined? @md.rights.copyright_photographs \ - and @md.rights.copyright_photographs=~/\S+/ - txt=@md.rights.copyright_photographs - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_preparation - def name - 'rights_copyright_preparation' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text preparation (if any)';} - end - def tuple - if defined? @md.rights.copyright_preparation \ - and @md.rights.copyright_preparation=~/\S+/ - txt=@md.rights.copyright_preparation - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_digitization - def name - 'rights_copyright_digitization' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text digitization (if any)';} - end - def tuple - if defined? @md.rights.copyright_digitization \ - and @md.rights.copyright_digitization=~/\S+/ - txt=@md.rights.copyright_digitization - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_audio - def name - 'rights_copyright_audio' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text audio (if any)';} - end - def tuple - if defined? @md.rights.copyright_audio \ - and @md.rights.copyright_audio=~/\S+/ - txt=@md.rights.copyright_audio - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_copyright_video - def name - 'rights_copyright_video' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata copyright associated for document text video (if any)';} - end - def tuple - if defined? @md.rights.copyright_video \ - and @md.rights.copyright_video=~/\S+/ - txt=@md.rights.copyright_video - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def rights_license - def name - 'rights_license' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata license granted for use of document if any)';} - end - def tuple - if defined? @md.rights.license \ - and @md.rights.license=~/\S+/ - txt=@md.rights.license - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% identifier -@identifier: - :oclc: - :isbn: -=end - def identifier_oclc - def name - 'identifier_oclc' - end - def create_column - "#{name} VARCHAR(#{Db[:col_library]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata identifier document Online Computer Library Center number';} - end - def tuple - if defined? @md.identifier.oclc \ - and @md.identifier.oclc=~/\S+/ - txt=@md.identifier.oclc - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def identifier_isbn - def name - 'identifier_isbn' - end - def create_column - "#{name} VARCHAR(#{Db[:col_small]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata identifier document isbn (if any)';} - end - def tuple - if defined? @md.identifier.isbn \ - and @md.identifier.isbn=~/\S+/ - txt=@md.identifier.isbn - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% classify -@classify: - :topic_register: - :subject: - :keywords: - :type: - :loc: - :dewey: -=end - def classify_topic_register - def name - 'classify_topic_register' - end - def create_column - "#{name} VARCHAR(#{Db[:col_info_note]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document topic register (semi-structured document subject information)';} - end - def tuple - if defined? @md.classify.topic_register \ - and @md.classify.topic_register=~/\S+/ - txt=@md.classify.topic_register - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def classify_subject - def name - 'classify_subject' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_long]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document subject matter [DC3]';} - end - def tuple - if defined? @md.classify.subject \ - and @md.classify.subject=~/\S+/ - txt=@md.classify.subject - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def classify_loc - def name - 'classify_loc' - end - def create_column - "#{name} VARCHAR(#{Db[:col_library]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document Library of Congress';} - end - def tuple - if defined? @md.classify.loc \ - and @md.classify.loc=~/\S+/ - txt=@md.classify.loc - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def classify_dewey - def name - 'classify_dewey' - end - def create_column - "#{name} VARCHAR(#{Db[:col_library]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document Dewey';} - end - def tuple - if defined? @md.classify.dewey \ - and @md.classify.dewey=~/\S+/ - txt=@md.classify.dewey - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def classify_keywords - def name - 'classify_keywords' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_long]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document keywords';} - end - def tuple - if defined? @md.classify.keywords \ - and @md.classify.keywords=~/\S+/ - txt=@md.classify.keywords - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% notes -@notes: - :abstract: - :description: - :comment: - :coverage: - :relation: - :format: - :history: - :prefix: - :prefix_a: - :prefix_b: - :suffix: -=end - def notes_abstract - def name - 'notes_abstract' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes abstract';} - end - def tuple - if defined? @md.notes.abstract \ - and @md.notes.abstract=~/\S+/ - txt=@md.notes.abstract - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_description - def name - 'notes_description' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes description [DC4]';} - end - def tuple - if defined? @md.notes.description \ - and @md.notes.description=~/\S+/ - txt=@md.notes.description - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_comment - def name - 'notes_comment' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes comment';} - end - def tuple - if defined? @md.notes.comment \ - and @md.notes.comment=~/\S+/ - txt=@md.notes.comment - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_coverage - def name - 'notes_coverage' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_short]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document coverage [DC14]';} - end - def tuple - if defined? @md.classify.coverage \ - and @md.classify.coverage=~/\S+/ - txt=@md.classify.coverage - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_relation - def name - 'notes_relation' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_short]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document relation [DC13]';} - end - def tuple - if defined? @md.classify.relation \ - and @md.classify.relation=~/\S+/ - txt=@md.classify.relation - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_history #check, consider removal - def name - 'notes_history' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_long]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes history';} - end - def tuple - if defined? @md.notes.history \ - and @md.notes.history=~/\S+/ - txt=@md.notes.history - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_type #check - def name - 'notes_type' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_long]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata notes document type [DC8]';} - end - def tuple - if defined? @md.notes.type \ - and @md.notes.type=~/\S+/ - txt=@md.notes.type - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_format - def name - 'notes_format' - end - def create_column - "#{name} VARCHAR(#{Db[:col_txt_long]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata classify document format [DC9]';} - end - def tuple - if defined? @md.classify.format \ - and @md.classify.format=~/\S+/ - txt=@md.classify.format - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_prefix - def name - 'notes_prefix' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes prefix';} - end - def tuple - if defined? @md.notes.prefix \ - and @md.notes.prefix=~/\S+/ - txt=@md.notes.prefix - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_prefix_a - def name - 'notes_prefix_a' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes prefix_a';} - end - def tuple - if defined? @md.notes.prefix_a \ - and @md.notes.prefix_a=~/\S+/ - txt=@md.notes.prefix_a - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_prefix_b - def name - 'notes_prefix_b' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes prefix_b';} - end - def tuple - if defined? @md.notes.prefix_b \ - and @md.notes.prefix_b=~/\S+/ - txt=@md.notes.prefix_b - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def notes_suffix - def name - 'notes_suffix' - end - def create_column # keep text - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document notes suffix';} - end - def tuple - if defined? @md.notes.suffix \ - and @md.notes.suffix=~/\S+/ - txt=@md.notes.suffix - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end -=begin -#% src -=end - def src_filename - def name - 'src_filename' - end - def create_column - "#{name} VARCHAR(#{Db[:col_filename]}) NOT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text filename';} - end - def tuple - if defined? @md.fns \ - and @md.fns=~/\S+/ - txt=@md.fns - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def src_fingerprint - def name - 'src_fingerprint' #hash/digest, sha512, sha256 or md5 - end - def create_column - "#{name} VARCHAR(#{Db[:col_digest]}) NULL," - #"#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text fingerprint, hash digest sha512, sha256 or md5';} - end - def tuple - if defined? @md.dgst \ - and @md.dgst.is_a?(Array) \ - and @md.dgst[1]=~/\S+/ - txt=@md.dgst[1] - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def src_filesize - def name - 'src_filesize' - end - def create_column - "#{name} VARCHAR(#{Db[:col_filesize]}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text file size';} - end - def tuple - if defined? @md.filesize \ - and @md.filesize=~/\S+/ - txt=@md.filesize - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def src_word_count - def name - 'src_word_count' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text word count';} - end - def tuple - if defined? @md.wc_words \ - and @md.wc_words=~/\S+/ - txt=@md.wc_words - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - def src_txt # consider naming sisusrc - def name - 'src_text' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'sisu markup source text (if shared)';} - end - def tuple - if ((@md.opt.act[:psql_import][:set]==:on \ - || @md.opt.act[:psql_update][:set]==:on) \ - or (@md.opt.act[:sqlite_import][:set]==:on \ - || @md.opt.act[:sqlite_update][:set]==:on)) \ - and FileTest.exist?(@md.fns) - ["#{name}, ","'#{@sisutxt}', "] - else ['',''] - end - end - self - end -=begin -#% misc -@links: -=end - def fulltext - def name - 'fulltext' - end - def create_column - "#{name} TEXT NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'document full text clean, searchable';} - end - def tuple - if ((@md.opt.act[:psql_import][:set]==:on \ - || @md.opt.act[:psql_update][:set]==:on) \ - or (@md.opt.act[:sqlite_import][:set]==:on \ - || @md.opt.act[:sqlite_update][:set]==:on)) \ - and FileTest.exist?(@md.fns) - ["#{name}, ","'#{@fulltext}', "] - else ['',''] - end - end - self - end - def links - def name - 'links' - end - def create_column - "#{name} TEXT NULL," - #"#{name} VARCHAR(#{links.size}) NULL," - end - def column_comment - %{COMMENT ON COLUMN metadata_and_text.#{name} - IS 'metadata document links';} - end - def tuple - if defined? @md.links \ - and @md.links=~/\S+/ - txt=@md.links - txt=special_character_escape(txt) - ["#{name}, ","'#{txt}', "] - else ['',''] - end - end - self - end - self - end - end - class ColumnSize - def document_clean # restriction not necessary - 60000 - end - def document_body - 16000 - end - def document_seg - 120 - end - def document_seg_full - 120 - end - def endnote_clean # restriction not necessary - 60000 - end - def endnote_body - 16000 - end - end -end -__END__ diff --git a/lib/sisu/current/db_create.rb b/lib/sisu/current/db_create.rb deleted file mode 100644 index df8983d2..00000000 --- a/lib/sisu/current/db_create.rb +++ /dev/null @@ -1,689 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbCreate - require_relative 'db_columns' # db_columns.rb - class Create < SiSU_DbColumns::Columns - require_relative 'se' # se.rb - @@dl=nil - def initialize(opt,conn,file,sql_type=:pg) - @opt,@conn,@file,@sql_type=opt,conn,file,sql_type - @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - @comment=(@sql_type==:pg) \ - ? (SiSU_DbCreate::Comment.new(@conn,@sql_type)) - : nil - @@dl ||=SiSU_Env::InfoEnv.new.digest.length - end - def available - DBI.available_drivers.each do |driver| - puts "Driver: #{driver}" - DBI.data_sources(driver).each do |dsn| - puts "\tDatasource: #{dsn}" - end - end - end - def create_db - @env=SiSU_Env::InfoEnv.new(@opt.fns) - tell=(@sql_type==:sqlite) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Create SQLite db tables in:', - %{"#{@file}"} - ) - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Create pgSQL db tables in:', - %{"#{Db[:name_prefix]}#{@env.path.base_markup_dir_stub}"} - ) - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - tell.dark_grey_title_hi - end - SiSU_Env::SystemCall.new.create_pg_db(@env.path.base_markup_dir_stub) if @sql_type==:pg #watch use of path.base_markup_dir_stub instead of stub - end - def output_dir? - dir=SiSU_Env::InfoEnv.new('') - if @opt.act[:sqlite][:set]==:on - dir.path.webserv_stub_ensure - end - end - def create_table - def conn_exec(sql) - if @sql_type==:pg - conn_exec_pg(sql) - elsif @sql_type==:sqlite - conn_exec_sqlite(sql) - end - end - def conn_exec_pg(sql) - begin - @conn.exec_params(sql) - rescue - if @conn.is_a?(NilClass) - errmsg="No pg connection (check pg dependencies)" - if @opt.act[:no_stop][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, proceeding without pg output (as requested)") - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, STOPPING") - exit - end - end - end - end - def conn_exec_sqlite(sql) - begin - @conn.execute(sql) - rescue - if @conn.is_a?(NilClass) - errmsg="No sqlite3 connection (check sqlite3 dependencies)" - if @opt.act[:no_stop][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, proceeding without sqlite output (as requested)") - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, STOPPING") - exit - end - end - end - end - def metadata_and_text - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - currently using sisu_dbi module - to be populated from document files - create tables metadata_and_text - data import through ruby transfer - } - end - create_metadata_and_text=%{ - CREATE TABLE metadata_and_text ( - tid BIGINT PRIMARY KEY, - /* title */ - #{column.title.create_column} - #{column.title_main.create_column} - #{column.title_sub.create_column} - #{column.title_short.create_column} - #{column.title_edition.create_column} - #{column.title_note.create_column} - #{column.title_language.create_column} - #{column.title_language_char.create_column} - /* creator */ - #{column.creator_author.create_column} - #{column.creator_author_honorific.create_column} - #{column.creator_author_nationality.create_column} - #{column.creator_editor.create_column} - #{column.creator_contributor.create_column} - #{column.creator_illustrator.create_column} - #{column.creator_photographer.create_column} - #{column.creator_translator.create_column} - #{column.creator_prepared_by.create_column} - #{column.creator_digitized_by.create_column} - #{column.creator_audio.create_column} - #{column.creator_video.create_column} - /* language */ - #{column.language_document.create_column} - #{column.language_document_char.create_column} - #{column.language_original.create_column} - #{column.language_original_char.create_column} - /* date */ - #{column.date_added_to_site.create_column} - #{column.date_available.create_column} - #{column.date_created.create_column} - #{column.date_issued.create_column} - #{column.date_modified.create_column} - #{column.date_published.create_column} - #{column.date_valid.create_column} - #{column.date_translated.create_column} - #{column.date_original_publication.create_column} - #{column.date_generated.create_column} - /* publisher */ - #{column.publisher.create_column} - /* original */ - #{column.original_publisher.create_column} - #{column.original_language.create_column} - #{column.original_language_char.create_column} - #{column.original_source.create_column} - #{column.original_institution.create_column} - #{column.original_nationality.create_column} - /* rights */ - #{column.rights_all.create_column} - #{column.rights_copyright_text.create_column} - #{column.rights_copyright_translation.create_column} - #{column.rights_copyright_illustrations.create_column} - #{column.rights_copyright_photographs.create_column} - #{column.rights_copyright_preparation.create_column} - #{column.rights_copyright_digitization.create_column} - #{column.rights_copyright_audio.create_column} - #{column.rights_copyright_video.create_column} - #{column.rights_license.create_column} - /* classify */ - #{column.classify_topic_register.create_column} - #{column.classify_subject.create_column} - #{column.classify_loc.create_column} - #{column.classify_dewey.create_column} - #{column.classify_keywords.create_column} - /* identifier */ - #{column.identifier_oclc.create_column} - #{column.identifier_isbn.create_column} - /* notes */ - #{column.notes_abstract.create_column} - #{column.notes_description.create_column} - #{column.notes_comment.create_column} - #{column.notes_history.create_column} - #{column.notes_coverage.create_column} - #{column.notes_relation.create_column} - /* column.notes_source.create_column */ - #{column.notes_type.create_column} - #{column.notes_format.create_column} - #{column.notes_prefix.create_column} - #{column.notes_prefix_a.create_column} - #{column.notes_prefix_b.create_column} - #{column.notes_suffix.create_column} - /* src */ - #{column.src_filename.create_column} - #{column.src_fingerprint.create_column} - #{column.src_filesize.create_column} - #{column.src_word_count.create_column} - #{column.src_txt.create_column} - /* misc */ - #{column.fulltext.create_column} - #{column.links.create_column.gsub(/,$/,'')} -/* subj VARCHAR(64) NULL, */ -/* contact VARCHAR(100) NULL, */ -/* information VARCHAR(100) NULL, */ -/* types CHAR(1) NULL, */ -/* writing_focus_nationality VARCHAR(100) NULL, */ - ); - } - conn_exec(create_metadata_and_text) - @comment.psql.metadata_and_text if @comment - end - def doc_objects # create doc_objects base - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - to be populated from documents files - create tables doc_objects - data import through ruby transfer - } - end - create_doc_objects=%{ - CREATE TABLE doc_objects ( - lid BIGINT PRIMARY KEY, - metadata_tid BIGINT REFERENCES metadata_and_text, - ocn SMALLINT, - ocnd VARCHAR(6), - ocns VARCHAR(6), - clean TEXT NULL, - body TEXT NULL, - book_idx TEXT NULL, - seg VARCHAR(256) NULL, - lev_an VARCHAR(1), - lev SMALLINT NULL, - lev0 SMALLINT, - lev1 SMALLINT, - lev2 SMALLINT, - lev3 SMALLINT, - lev4 SMALLINT, - lev5 SMALLINT, - lev6 SMALLINT, - lev7 SMALLINT, - en_a SMALLINT NULL, - en_z SMALLINT NULL, - en_a_asterisk SMALLINT NULL, - en_z_asterisk SMALLINT NULL, - en_a_plus SMALLINT NULL, - en_z_plus SMALLINT NULL, - t_of VARCHAR(16), - t_is VARCHAR(16), - node VARCHAR(16) NULL, - parent VARCHAR(16) NULL, - digest_clean CHAR(#{@@dl}), - digest_all CHAR(#{@@dl}), - types CHAR(1) NULL - ); - } - conn_exec(create_doc_objects) - @comment.psql.doc_objects if @comment - end - def endnotes - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - to be populated from document files - create tables endnotes - data import through ruby transfer - } - end - create_endnotes=%{ - CREATE TABLE endnotes ( - nid BIGINT PRIMARY KEY, - document_lid BIGINT REFERENCES doc_objects, - nr SMALLINT, - clean TEXT NULL, - body TEXT NULL, - ocn SMALLINT, - ocnd VARCHAR(6), - ocns VARCHAR(6), - digest_clean CHAR(#{@@dl}), - metadata_tid BIGINT REFERENCES metadata_and_text - ); - } - conn_exec(create_endnotes) - @comment.psql.endnotes if @comment - end - def endnotes_asterisk - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - to be populated from document files - create tables endnotes_asterisk - data import through ruby transfer - } - end - create_endnotes_asterisk=%{ - CREATE TABLE endnotes_asterisk ( - nid BIGINT PRIMARY KEY, - document_lid BIGINT REFERENCES doc_objects, - nr SMALLINT, - clean TEXT NULL, - body TEXT NULL, - ocn SMALLINT, - ocnd VARCHAR(6), - ocns VARCHAR(6), - digest_clean CHAR(#{@@dl}), - metadata_tid BIGINT REFERENCES metadata_and_text - ); - } - conn_exec(create_endnotes_asterisk) - @comment.psql.endnotes_asterisk if @comment - end - def endnotes_plus - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - to be populated from document files - create tables endnotes_plus - data import through ruby transfer - } - end - create_endnotes_plus=%{ - CREATE TABLE endnotes_plus ( - nid BIGINT PRIMARY KEY, - document_lid BIGINT REFERENCES doc_objects, - nr SMALLINT, - clean TEXT NULL, - body TEXT NULL, - ocn SMALLINT, - ocnd VARCHAR(6), - ocns VARCHAR(6), - digest_clean CHAR(#{@@dl}), - metadata_tid BIGINT REFERENCES metadata_and_text - ); - } - conn_exec(create_endnotes_plus) - @comment.psql.endnotes_plus if @comment - end - def urls # create doc_objects file links mapping - if (@opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on) - print %{ - currently using sisu_dbi module - to be populated from doc_objects files - create tables urls - data import through ruby transfer - } - end - create_urls=%{ - CREATE TABLE urls ( - metadata_tid BIGINT REFERENCES metadata_and_text, - plaintext varchar(512), - html_toc varchar(512), - html_doc varchar(512), - xhtml varchar(512), - xml_sax varchar(512), - xml_dom varchar(512), - odf varchar(512), - pdf_p varchar(512), - pdf_l varchar(512), - concordance varchar(512), - latex_p varchar(512), - latex_l varchar(512), - digest varchar(512), - manifest varchar(512), - markup varchar(512), - sisupod varchar(512) - ); - } - conn_exec(create_urls) - @comment.psql.urls if @comment - end - self - end - end - class Comment < SiSU_DbColumns::Columns - def initialize(conn,sql_type=:pg) - @conn=conn - if sql_type == :pg then psql - end - end - def psql - def conn_execute_array(sql_arr) - @conn.transaction do |conn| - sql_arr.each do |sql| - conn.exec_params(sql) - end - end - end - def metadata_and_text - sql_arr=[ - %{COMMENT ON Table metadata_and_text - IS 'contains SiSU metadata and fulltext for search (including source .sst if shared)';}, - %{COMMENT ON COLUMN metadata_and_text.tid - IS 'unique';}, - %{#{column.title.column_comment}}, - %{#{column.title_main.column_comment}}, - %{#{column.title_sub.column_comment}}, - %{#{column.title_short.column_comment}}, - %{#{column.title_edition.column_comment}}, - %{#{column.title_note.column_comment}}, - %{#{column.title_language.column_comment}}, - %{#{column.title_language_char.column_comment}}, - %{#{column.creator_author.column_comment}}, - %{#{column.creator_author_honorific.column_comment}}, - %{#{column.creator_author_nationality.column_comment}}, - %{#{column.creator_editor.column_comment}}, - %{#{column.creator_contributor.column_comment}}, - %{#{column.creator_illustrator.column_comment}}, - %{#{column.creator_photographer.column_comment}}, - %{#{column.creator_translator.column_comment}}, - %{#{column.creator_prepared_by.column_comment}}, - %{#{column.creator_digitized_by.column_comment}}, - %{#{column.creator_audio.column_comment}}, - %{#{column.creator_video.column_comment}}, - %{#{column.language_document.column_comment}}, - %{#{column.language_document_char.column_comment}}, - %{#{column.language_original.column_comment}}, - %{#{column.language_original_char.column_comment}}, - %{#{column.date_added_to_site.column_comment}}, - %{#{column.date_available.column_comment}}, - %{#{column.date_created.column_comment}}, - %{#{column.date_issued.column_comment}}, - %{#{column.date_modified.column_comment}}, - %{#{column.date_published.column_comment}}, - %{#{column.date_valid.column_comment}}, - %{#{column.date_translated.column_comment}}, - %{#{column.date_original_publication.column_comment}}, - %{#{column.date_generated.column_comment}}, - %{#{column.publisher.column_comment}}, - %{#{column.original_publisher.column_comment}}, - %{#{column.original_language.column_comment}}, - %{#{column.original_language_char.column_comment}}, - %{#{column.original_source.column_comment}}, - %{#{column.original_institution.column_comment}}, - %{#{column.original_nationality.column_comment}}, - %{#{column.rights_all.column_comment}}, - %{#{column.rights_copyright_text.column_comment}}, - %{#{column.rights_copyright_translation.column_comment}}, - %{#{column.rights_copyright_illustrations.column_comment}}, - %{#{column.rights_copyright_photographs.column_comment}}, - %{#{column.rights_copyright_preparation.column_comment}}, - %{#{column.rights_copyright_digitization.column_comment}}, - %{#{column.rights_copyright_audio.column_comment}}, - %{#{column.rights_copyright_video.column_comment}}, - %{#{column.rights_license.column_comment}}, - %{#{column.classify_topic_register.column_comment}}, - %{#{column.classify_subject.column_comment}}, - %{#{column.classify_loc.column_comment}}, - %{#{column.classify_dewey.column_comment}}, - %{#{column.classify_keywords.column_comment}}, - %{#{column.identifier_oclc.column_comment}}, - %{#{column.identifier_isbn.column_comment}}, - %{#{column.notes_abstract.column_comment}}, - %{#{column.notes_comment.column_comment}}, - %{#{column.notes_description.column_comment}}, - %{#{column.notes_history.column_comment}}, - %{#{column.notes_coverage.column_comment}}, - %{#{column.notes_relation.column_comment}}, - %{#{column.notes_type.column_comment}}, - %{#{column.notes_format.column_comment}}, - %{#{column.notes_prefix.column_comment}}, - %{#{column.notes_prefix_a.column_comment}}, - %{#{column.notes_prefix_b.column_comment}}, - %{#{column.notes_suffix.column_comment}}, - %{#{column.src_filename.column_comment}}, - %{#{column.src_fingerprint.column_comment}}, - %{#{column.src_filesize.column_comment}}, - %{#{column.src_word_count.column_comment}}, - %{#{column.src_txt.column_comment}}, - %{#{column.fulltext.column_comment}}, - %{#{column.links.column_comment}}, - ] - conn_execute_array(sql_arr) - end - def doc_objects - sql_arr=[ - %{COMMENT ON Table doc_objects - IS 'contains searchable text of SiSU document objects';}, - %{COMMENT ON COLUMN doc_objects.lid - IS 'unique';}, - %{COMMENT ON COLUMN doc_objects.metadata_tid - IS 'tie to title in metadata_and_text';}, - %{COMMENT ON COLUMN doc_objects.lev_an - IS 'doc level A-D 1-4';}, - %{COMMENT ON COLUMN doc_objects.lev - IS 'doc level 0-7 \d\~';}, - %{COMMENT ON COLUMN doc_objects.seg - IS 'segment name from level number 4 (lv 1)';}, - %{COMMENT ON COLUMN doc_objects.ocn - IS 'object citation number';}, - %{COMMENT ON COLUMN doc_objects.en_a - IS 'first endnote number in text object (eg. NULL or 34) (used with en_z to create range)';}, - %{COMMENT ON COLUMN doc_objects.en_z - IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a to create range)';}, - %{COMMENT ON COLUMN doc_objects.en_a_asterisk - IS 'first endnote number in text object (eg. NULL or 34) (used with en_z_asterisk to create range)';}, - %{COMMENT ON COLUMN doc_objects.en_z_asterisk - IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a_asterisk to create range)';}, - %{COMMENT ON COLUMN doc_objects.en_a_plus - IS 'first endnote number in text object (eg. NULL or 34) (used with en_z_plus to create range)';}, - %{COMMENT ON COLUMN doc_objects.en_z_plus - IS 'last endnote number within text object (eg. NULL, 34 or say 47) (used with en_a_plus to create range)';}, - %{COMMENT ON COLUMN doc_objects.types - IS 'document types seg scroll';}, - %{COMMENT ON COLUMN doc_objects.clean - IS 'text object - substantive text: clean, stripped of markup';}, - %{COMMENT ON COLUMN doc_objects.body - IS 'text object - substantive text: light html markup';}, - %{COMMENT ON COLUMN doc_objects.book_idx - IS 'book index creation information for paragraph, if provided';}, - %{COMMENT ON COLUMN doc_objects.lev0 - IS 'document structure, level number 0';}, - %{COMMENT ON COLUMN doc_objects.lev1 - IS 'document structure, level number 1';}, - %{COMMENT ON COLUMN doc_objects.lev2 - IS 'document structure, level number 2';}, - %{COMMENT ON COLUMN doc_objects.lev3 - IS 'document structure, level number 3';}, - %{COMMENT ON COLUMN doc_objects.lev4 - IS 'document structure, level number 4';}, - %{COMMENT ON COLUMN doc_objects.lev5 - IS 'document structure, level number 5';}, - %{COMMENT ON COLUMN doc_objects.lev6 - IS 'document structure, level number 6';}, - %{COMMENT ON COLUMN doc_objects.lev7 - IS 'document structure, level number 7';}, - %{COMMENT ON COLUMN doc_objects.t_of - IS 'document structure, type of object (object is of)';}, - %{COMMENT ON COLUMN doc_objects.t_is - IS 'document structure, object is';}, - %{COMMENT ON COLUMN doc_objects.node - IS 'document structure, object node if heading';}, - %{COMMENT ON COLUMN doc_objects.parent - IS 'document structure, object parent (is a heading)';} - ] - conn_execute_array(sql_arr) - end - def endnotes - sql_arr=[ - %{COMMENT ON Table endnotes - IS 'contains searchable text of SiSU documents endnotes';}, - %{COMMENT ON COLUMN endnotes.nid - IS 'unique';}, - %{COMMENT ON COLUMN endnotes.document_lid - IS 'ties to text block from which referenced';}, - %{COMMENT ON COLUMN endnotes.nr - IS 'endnote number ';}, - %{COMMENT ON COLUMN endnotes.clean - IS 'endnote substantive content, stripped of markup';}, - %{COMMENT ON COLUMN endnotes.body - IS 'endnote substantive content';}, - %{COMMENT ON COLUMN endnotes.ocn - IS 'object citation no# <\~(\d+)> from which endnote is referenced';}, - %{COMMENT ON COLUMN doc_objects.metadata_tid - IS 'tie to title in metadata_and_text - unique for each document';} - ] - conn_execute_array(sql_arr) - end - def endnotes_asterisk - sql_arr=[ - %{COMMENT ON Table endnotes_asterisk - IS 'contains searchable text of SiSU documents endnotes marked with asterisk';}, - %{COMMENT ON COLUMN endnotes_asterisk.nid - IS 'unique';}, - %{COMMENT ON COLUMN endnotes_asterisk.document_lid - IS 'ties to text block from which referenced';}, - %{COMMENT ON COLUMN endnotes_asterisk.nr - IS 'endnote number ';}, - %{COMMENT ON COLUMN endnotes_asterisk.clean - IS 'endnote substantive content, stripped of markup';}, - %{COMMENT ON COLUMN endnotes_asterisk.body - IS 'endnote substantive content';}, - %{COMMENT ON COLUMN endnotes_asterisk.ocn - IS 'object citation no# <\~(\d+)> from which endnote is referenced';}, - %{COMMENT ON COLUMN doc_objects.metadata_tid - IS 'tie to title in metadata_and_text - unique for each document';} - ] - conn_execute_array(sql_arr) - end - def endnotes_plus - sql_arr=[ - %{COMMENT ON Table endnotes_plus - IS 'contains searchable text of SiSU documents endnotes marked with plus';}, - %{COMMENT ON COLUMN endnotes_plus.nid - IS 'unique';}, - %{COMMENT ON COLUMN endnotes_plus.document_lid - IS 'ties to text block from which referenced';}, - %{COMMENT ON COLUMN endnotes_plus.nr - IS 'endnote number ';}, - %{COMMENT ON COLUMN endnotes_plus.clean - IS 'endnote substantive content, stripped of markup';}, - %{COMMENT ON COLUMN endnotes_plus.body - IS 'endnote substantive content';}, - %{COMMENT ON COLUMN endnotes_plus.ocn - IS 'object citation no# <\~(\d+)> from which endnote is referenced';}, - %{COMMENT ON COLUMN doc_objects.metadata_tid - IS 'tie to title in metadata_and_text - unique for each document';}, - ] - conn_execute_array(sql_arr) - end - def urls - sql_arr=[ - %{COMMENT ON Table urls - IS 'contains base url links to different SiSU output';}, - %{COMMENT ON COLUMN doc_objects.metadata_tid - IS 'tie to title in metadata_and_text - unique for each document, the mapping of rows is one to one';}, - %{COMMENT ON COLUMN urls.plaintext - IS 'plaintext utf-8';}, - %{COMMENT ON COLUMN urls.html_toc - IS 'table of contents for segmented html document';}, - %{COMMENT ON COLUMN urls.html_doc - IS 'html document (scroll)';}, - %{COMMENT ON COLUMN urls.xhtml - IS 'xhtml document (scroll)';}, - %{COMMENT ON COLUMN urls.xml_sax - IS 'xml sax oriented document (scroll)';}, - %{COMMENT ON COLUMN urls.xml_dom - IS 'xml dom oriented document (scroll)';}, - %{COMMENT ON COLUMN urls.odf - IS 'opendocument format text';}, - %{COMMENT ON COLUMN urls.pdf_p - IS 'pdf portrait';}, - %{COMMENT ON COLUMN urls.pdf_l - IS 'pdf landscape';}, - %{COMMENT ON COLUMN urls.concordance - IS 'rudimentary document index linked to html';}, - %{COMMENT ON COLUMN urls.latex_p - IS 'latex portrait';}, - %{COMMENT ON COLUMN urls.latex_l - IS 'latex_landscape';}, - %{COMMENT ON COLUMN urls.markup - IS 'markup';}, - %{COMMENT ON COLUMN urls.sisupod - IS 'SiSU document format .tgz (all SiSU information on document)';}, - ] - conn_execute_array(sql_arr) - end - self - end - end -end -__END__ diff --git a/lib/sisu/current/db_dbi.rb b/lib/sisu/current/db_dbi.rb deleted file mode 100644 index 9824a6c5..00000000 --- a/lib/sisu/current/db_dbi.rb +++ /dev/null @@ -1,90 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbDBI - require_relative 'db_columns' # db_columns.rb - require_relative 'db_tests' # db_tests.rb - require_relative 'db_create' # db_create.rb - require_relative 'db_select' # db_select.rb - require_relative 'db_indexes' # db_indexes.rb - require_relative 'db_drop' # db_drop.rb - require_relative 'db_remove' # db_remove.rb - require_relative 'db_load_tuple' # db_load_tuple.rb - require_relative 'db_import' # db_import.rb - class ColumnSize < SiSU_DbColumns::ColumnSize # db_columns.rb - end - class Test < SiSU_DbTests::Test # db_tests.rb - end - class Create - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbDrop - require_relative 'utils_response' # utils_response.rb - class Drop - include SiSU_Response - def initialize(opt,conn,db_info,sql_type) - @opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type - case @sql_type - when :sqlite - cascade='' - else - cascade='CASCADE' - end - @drop_table=[ - "DROP TABLE metadata_and_text #{cascade};", - "DROP TABLE doc_objects #{cascade};", - "DROP TABLE urls #{cascade};", - "DROP TABLE endnotes #{cascade};", - "DROP TABLE endnotes_asterisk #{cascade};", - "DROP TABLE endnotes_plus #{cascade};", - ] - end - def drop - def tables #% drop all tables - begin - msg_sqlite="as not all disk space is recovered after dropping the database << #{@db_info.sqlite.db} >>, you may be better off deleting the file, and recreating it as necessary" - case @sql_type - when :sqlite - puts msg_sqlite - ans=response?('remove sql database?') - if ans \ - and File.exist?(@db_info.sqlite.db) - @conn.close - File.unlink(@db_info.sqlite.db) - db=SiSU_Env::InfoDb.new - conn=db.sqlite.conn_sqlite3 - sdb=SiSU_DbDBI::Create.new(@opt,conn,@db_info,@sql_type) - sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@db_info,@sql_type) - sdb.output_dir? - begin - sdb.create_db - sdb.create_table.metadata_and_text - sdb.create_table.doc_objects - sdb.create_table.endnotes - sdb.create_table.endnotes_asterisk - sdb.create_table.endnotes_plus - sdb.create_table.urls - sdb_index.create_indexes - rescue - SiSU_Errors::Rescued.new($!,$@,'-D').location do - __LINE__.to_s + ':' + __FILE__ - end - sdb.output_dir? - end - exit - else - @conn.transaction - @drop_table.each do |d| - begin - @conn.exec_params(d) - rescue - next - end - end - @conn.commit - end - when :pg - @conn.transaction - @drop_table.each do |d| - begin - @conn.exec_params(d) - rescue - next - end - end - @conn.commit - end - rescue - case @sql_type - when :sqlite - ans=response?('remove sql database?') - if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db) - end - else - @drop_table.each do |d| - begin - @conn.exec_params(d) - rescue - next - end - end - end - ensure - end - end - def indexes - def conn_execute_array(sql_arr) - @conn.transaction do |conn| - sql_arr.each do |sql| - begin - conn.exec_params(sql) - rescue - next - end - end - end - end - def base #% drop base indexes - print "\n drop documents common indexes\n" unless @opt.act[:quiet][:set]==:on - sql_arr=[ - %{DROP INDEX idx_title;}, - %{DROP INDEX idx_author;}, - %{DROP INDEX idx_filename;}, - %{DROP INDEX idx_topics;}, - %{DROP INDEX idx_ocn;}, - %{DROP INDEX idx_digest_clean;}, - %{DROP INDEX idx_digest_all;}, - %{DROP INDEX idx_lev0;}, - %{DROP INDEX idx_lev1;}, - %{DROP INDEX idx_lev2;}, - %{DROP INDEX idx_lev3;}, - %{DROP INDEX idx_lev4;}, - %{DROP INDEX idx_lev5;}, - %{DROP INDEX idx_lev6;}, - %{DROP INDEX idx_endnote_nr;}, - %{DROP INDEX idx_digest_en;}, - %{DROP INDEX idx_endnote_nr_asterisk;}, - %{DROP INDEX idx_endnote_asterisk;}, - %{DROP INDEX idx_digest_en_asterisk;}, - %{DROP INDEX idx_endnote_nr_plus;}, - %{DROP INDEX idx_endnote_plus;}, - %{DROP INDEX idx_digest_en_plus}, - ] - conn_execute_array(sql_arr) - end - def text #% drop TEXT indexes, sqlite - print "\n drop documents TEXT indexes\n" unless @opt.act[:quiet][:set]==:on - sql_arr=[ - %{DROP INDEX idx_clean;}, - %{DROP INDEX idx_endnote}, - ] - conn_execute_array(sql_arr) - end - self - end - indexes.base - @opt.act[:psql][:set]==:on ? '' : indexes.text - self - end - end -end -__END__ diff --git a/lib/sisu/current/db_import.rb b/lib/sisu/current/db_import.rb deleted file mode 100644 index 43da9c44..00000000 --- a/lib/sisu/current/db_import.rb +++ /dev/null @@ -1,877 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbImport - require_relative 'db_columns' # db_columns.rb - require_relative 'db_load_tuple' # db_load_tuple.rb - require_relative 'db_sqltxt' # db_sqltxt.rb - require_relative 'html_lite_shared' # html_lite_shared.rb - class Import < SiSU_DbText::Prepare - include SiSU_Param - include SiSU_Screen - include SiSU_DbAction - @@dl=nil - @@hname=nil - attr_accessor :tp - def initialize(opt,conn,file_maint,sql_type=:pg) - @opt,@conn,@file_maint,@sql_type=opt,conn,file_maint,sql_type - @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - @env=SiSU_Env::InfoEnv.new(@opt.fns) - @dal="#{@env.processing_path.ao}" - @fnb=if @opt.fns.empty? \ - or @opt.selections.str.empty? - '' - else - @md=SiSU_Param::Parameters.new(@opt).get - @md.fnb - end - @fnc="#{@dal}/#{@opt.fns}.content.rbm" - @@seg,@@seg_full='','' #create? consider placing field just before clean text as opposed to seg which contains seg(.html) name info seg_full would contain seg info for levels 5 & 6 where available eg seg_full may be 7.3 (level 5) and 7.3.1 (level 6) where seg is 7 - @col=Hash.new('') - @col[:ocn]='' - @counter={} - @db=SiSU_Env::InfoDb.new - if @sql_type==:sqlite - @driver_sqlite3= - (@conn.inspect.match(/^(.{10})/)[1] \ - == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ - ? true - : false - end - sql='SELECT MAX(lid) FROM doc_objects' - begin - @col[:lid] ||=0 - @col[:lid]=@driver_sqlite3 \ - ? @conn.execute( sql ).join.to_i - : @conn.exec( sql ).getvalue(0,0).to_i - rescue - if @opt.act[:maintenance][:set]==:on - puts "#{__FILE__}:#{__LINE__}" - end - end - @col[:lid]=0 if @col[:lid].nil? or @col[:lid].to_s.empty? - sql='SELECT MAX(nid) FROM endnotes' - begin - @id_n=@driver_sqlite3 \ - ? @conn.execute( sql ).join.to_i - : @conn.exec( sql ).getvalue(0,0).to_i - @id_n ||=0 - rescue - if @opt.act[:maintenance][:set]==:on - puts "#{__FILE__}:#{__LINE__}" - end - end - @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? - @col[:lv0]=@col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=@col[:lv7]=0 - @db=SiSU_Env::InfoDb.new - @pdf_fn=SiSU_Env::FileOp.new(@md).base_filename - @@dl ||=SiSU_Env::InfoEnv.new.digest.length - end - def marshal_load - require_relative 'ao' # ao.rb - @ao_array=SiSU_AO::Source.new(@opt).get # ao file drawn here - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "#{@db.psql.db}::#{@opt.fns}" - ).puts_blue - end - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Marshal Load', - @fnc - ).puts_grey if @opt.act[:verbose][:set]==:on - select_first_match=%{ - SELECT metadata_and_text.tid - FROM metadata_and_text - WHERE metadata_and_text.src_filename = '#{@md.fns}' - AND metadata_and_text.language_document_char = '#{@opt.lng}' - ;} # note, for .ssm: @md.fns (is set during runtime & is) != @opt.fns @md.opt.fns - file_exist=if @sql_type==:sqlite - begin - @conn.get_first_value(select_first_match) - rescue SQLite3::Exception => e - # not tested - puts "Exception occurred" - puts e - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - sdb={ - create: SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type), - index: SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type), - } - db_action(sdb).create - end - else - begin - @conn.exec(select_first_match).field_values("tid")[0] - rescue PG::Error => e - err=[ - e.result.error_field( PG::Result::PG_DIAG_SEVERITY ), - e.result.error_field( PG::Result::PG_DIAG_SQLSTATE ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_PRIMARY ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_DETAIL ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_HINT ), - e.result.error_field( PG::Result::PG_DIAG_STATEMENT_POSITION ), - e.result.error_field( PG::Result::PG_DIAG_INTERNAL_POSITION ), - e.result.error_field( PG::Result::PG_DIAG_INTERNAL_QUERY ), - e.result.error_field( PG::Result::PG_DIAG_CONTEXT ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_FILE ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_LINE ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_FUNCTION ), - ] - p err - if err[2] =~/relation "\S+?" does not exist/ \ - or err.inspect =~/relation "\S+?" does not exist/ - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + err[2] + "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - sdb={ - create: SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type), - index: SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type), - } - db_action(sdb).create - retry - end - end - end - if not file_exist - t_d=[] # transaction_data - t_d << db_import_metadata - t_d << db_import_documents(@ao_array) - t_d << db_import_urls(@ao_array,@fnc) #import OID on/off - t_d=t_d.flatten - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - puts @conn.class if defined? @conn.class - puts @conn.driver_name if defined? @conn.driver_name - puts @conn.driver if defined? @conn.driver - end - begin #% sql - if @sql_type==:sqlite - @conn.transaction do |conn| - t_d.each do |sql| - conn.execute(sql) - end - end - #also 'execute' works for sqlite - #@conn.execute("BEGIN") - # t_d.each do |sql| - # @conn.execute(sql) - # end - #@conn.execute("COMMIT") - else - #'do' works for postgresql - @conn.exec("BEGIN") - t_d.each do |sql| - @conn.exec(sql) - end - @conn.exec("COMMIT") - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - sqlfn="#{@env.processing_path.sql}/#{@md.fnb}.sql" - sql=File.new(sqlfn,'w') - t_d.each {|i| sql.puts i} - p sqlfn - if @opt.act[:maintenance][:set]==:on - puts sql - p @conn.methods.sort - puts "#{__FILE__}:#{__LINE__}" - end - ensure - end - else - if file_exist - @db=SiSU_Env::InfoDb.new - puts "\nfile #{@opt.fns} in language code #{@opt.lng} already exists in database #{@db.psql.db}, use --update instead?" - end - end - end - def pf_db_import_transaction_open - end - def pf_db_import_transaction_close - end - def book_idx_hash_to_str(book_idx) - book_idx=book_idx ? book_idx : '' - book_idx_str,book_subidx_part='','' - if not book_idx.empty? - book_idx_str='' - book_idx.each_pair do |k0,v0| - book_idx_str << %{#{k0}+#{v0[:plus]}} - book_subidx_part='' - if v0[:sub].length > 0 - v0[:sub].each do |subterms| - subterms.each_pair do |k1,v1| - book_subidx_part << %{\n #{k1}+#{v1[:plus]} | } - end - end - book_idx_str=book_idx_str + ':' + book_subidx_part - end - end - end - book_idx_str - end - def db_import_metadata #% import documents - populate database - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - print %{ #{@cX.grey}import documents dbi_unit #{@cX.off} } - end - @tp={} - @md=SiSU_Param::Parameters.new(@opt).get -#% sisutxt & fulltxt - if FileTest.exist?(@md.fns) - txt_arr=IO.readlines(@md.fns,'') - src=txt_arr.join("\n") - src=special_character_escape(src) - @tp[:sisutxt_f],@tp[:sisutxt_i]='sisutxt, ',"'#{src}', " - txt=clean_searchable_text_from_document_source(txt_arr) - #txt=special_character_escape(txt) - @tp[:fulltxt_f],@tp[:fulltxt_i]='fulltxt, ',"'#{txt}', " - end -#% title - if defined? @md.title.full \ - and @md.title.full=~/\S+/ # DublinCore 1 - title - #@tp[:title]=@md.title.full - #special_character_escape(@tp[:title]) - #@tp[:title_f],@tp[:title_i]='title, ',"'#{@tp[:title]}', " - sql='SELECT MAX(tid) FROM metadata_and_text;' - begin - @@id_t ||=0 - id_t=@driver_sqlite3 \ - ? @conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i } - : @conn.exec( sql ).getvalue(0,0).to_i - @@id_t=id_t if id_t - rescue - if @opt.act[:maintenance][:set]==:on - puts "#{__FILE__} #{__LINE__}" - end - end - @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks @title: - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - puts %{\n#{@cX.grey}Processing file number#{@cX.off}: #{@cX.green}#{@@id_t}#{@@cX.off}} - end - end - ################ CLEAR ############## - SiSU_DbDBI::Test.new(self,@opt).verify #% import title names, filenames (tuple) - t=SiSU_DbTuple::LoadMetadata.new(@conn,@@id_t,@md,@file_maint) - tuple=t.tuple - tuple - end - def db_import_documents(ao_array) #% import documents - populate main database table, import into substantive database tables (tuple) - begin - @col[:tid]=@@id_t - @en,@en_ast,@en_pls,@tuple_array=[],[],[],[] - @col[:en_a],@col[:en_z]=nil,nil - ao_array.each do |data| - data.obj=data.obj.gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\1'). - gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,'\1'). - gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,'\1'). - gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,'\1'). - gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,'\1'). - gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'\1'). - gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'\1'). - gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'\1'). - gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). - gsub(/#{Mx[:gl_o]}(●)#{Mx[:gl_c]}\s*/,'\1 '). - gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,'') #check - @col[:seg]=@@seg - if data.of ==:para \ - || data.of ==:heading \ - || data.of ==:heading_insert \ - || data.of ==:block \ - || data.of ==:group # regular text what of code-blocks grouped text etc. - notedata=data.obj.dup - #% :headings - if data.is==:heading \ - && (data.ln.inspect=~/[0-3]/) - ( - @col[:lev], - txt,@col[:ocn], - @col[:lev_an], - @col[:ocnd],@col[:ocns], - @col[:t_of],@col[:t_is], - @col[:node],@col[:parent], - @col[:digest_clean],@col[:digest_all]= - data.ln, - data.obj,data.ocn, - data.lv, - data.odv,data.osp, - data.of,data.is, - data.node,data.parent, - '','' - ) - @col[:lid]+=1 - txt=endnotes(txt).extract_any - body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_minus - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - if @en[0] then @en_a,@en_z=@en[0].first,@en[0].last - end - if @en_ast[0] then @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last - end - if @en_pls[0] then @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last - end - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - case @col[:lev] - when /0/ then @col[:lv0]+=1 - when /1/ then @col[:lv1]+=1 - when /2/ then @col[:lv2]+=1 - when /3/ then @col[:lv3]+=1 - when /4/ then @col[:lv4]+=1 - end - @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is==:heading \ - && data.ln==4 - ( - @@seg,txt, - @col[:ocn],@col[:lev_an], - @col[:ocnd],@col[:ocns], - @col[:t_of],@col[:t_is], - @col[:node],@col[:parent], - @col[:digest_clean],@col[:digest_all]= - data.name,data.obj, - data.ocn,data.lv, - data.odv,data.osp, - data.of,data.is, - data.node,data.parent, - '','' - ) - @col[:seg]=@@seg - @col[:lv4]+=1 - @col[:lid]+=1 - @col[:lev]=4 - @hname=if @col[:seg] \ - and not @col[:seg].to_s.empty? - @@hname=@col[:seg].to_s - else @@hname - end - @env=SiSU_Env::InfoEnv.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" - txt=endnotes(txt).extract_any - body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - @en_a,@en_z=@en[0].first,@en[0].last if @en[0] - @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] - @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is==:heading \ - && data.ln==5 - ( - txt, - @col[:ocn],@col[:lev_an], - @col[:ocnd],@col[:ocns], - @col[:t_of],@col[:t_is], - @col[:node],@col[:parent], - @col[:digest_clean],@col[:digest_all]= - data.obj, - data.ocn,data.lv, - data.odv,data.osp, - data.of,data.is, - data.node,data.parent, - '','' - ) - @@seg_full=data.name if data.is==:heading \ - && data.ln==5 \ - && data.name #check data.name - @@seg ||='' #nil # watch - @col[:seg]=@@seg - @col[:lv5]+=1 - @col[:lid]+=1 - @col[:lev]=5 - @hname=if @col[:seg] \ - and not @col[:seg].to_s.empty? - @@hname=@col[:seg].to_s - else @@hname - end - @env=SiSU_Env::InfoEnv.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" - txt=endnotes(txt).extract_any - body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - @en_a,@en_z=@en[0].first,@en[0].last if @en[0] - @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] - @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is==:heading \ - && data.ln==6 - txt, @col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]= - data.obj,data.ocn, data.lv, data.odv, data.osp, data.of, data.is, data.node, data.parent, '', '' - @@seg_full=data.name if data.is==:heading && data.ln==6 && data.name #check data.name - @@seg ||='' #nil # watch - @col[:seg]=@@seg - @col[:lv6]+=1 - @col[:lid]+=1 - @col[:lev]=6 - @hname=if @col[:seg] \ - and not @col[:seg].to_s.empty? - @@hname=@col[:seg].to_s - else @@hname - end - @env=SiSU_Env::InfoEnv.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" - txt=endnotes(txt).extract_any - body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - @en_a,@en_z=@en[0].first,@en[0].last if @en[0] - @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] - @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - @col[:lev]=@col[:plaintext]=@col[:body]='' - elsif data.is==:heading \ - && data.ln==7 - txt, @col[:ocn],@col[:lev_an],@col[:ocnd],@col[:ocns],@col[:t_of],@col[:t_is],@col[:node],@col[:parent],@col[:digest_clean],@col[:digest_all]= - data.obj,data.ocn, data.lv, data.odv, data.osp, data.of, data.is, data.node, data.parent, '', '' - @@seg_full=data.name if data.is==:heading && data.ln==7 && data.name #check data.name - @@seg ||='' #nil # watch - @col[:seg]=@@seg - @col[:lv7]+=1 - @col[:lid]+=1 - @col[:lev]=7 - @hname=if @col[:seg] \ - and not @col[:seg].to_s.empty? - @@hname=@col[:seg].to_s - else @@hname - end - @env=SiSU_Env::InfoEnv.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" - txt=endnotes(txt).extract_any - body=SiSU_FormatShared::CSS_Format.new(@md,data).lev4_plus - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - @en_a,@en_z=@en[0].first,@en[0].last if @en[0] - @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] - @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - @col[:lev]=@col[:plaintext]=@col[:body]='' - #% :structure :layout :comment - elsif data.of==:structure \ - || data.of==:layout \ - || data.of==:comment - #added watch - #% : - else #% regular text - @col[:lid]+=1 - ( - txt='' - txt,@col[:ocn], - @col[:ocnd],@col[:ocns], - @col[:t_of],@col[:t_is], - @col[:node],@col[:parent], - @col[:digest_clean],@col[:digest_all], - @col[:lev]= - data.obj,data.ocn, - data.odv,data.osp, - data.of,data.is, - '',data.parent, - '','', - 9 - ) - @hname=if @col[:seg] \ - and not @col[:seg].to_s.empty? - @@hname=@col[:seg].to_s - else @@hname - end - @env=SiSU_Env::InfoEnv.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" - txt=endnotes(txt).extract_any - if @sql_type==:pg \ - and txt.size > (SiSU_DbColumns::ColumnSize.new.document_clean - 1) # examine pg build & remove limitation - puts "\n\nTOO LARGE (TXT - see error log)\n\n" - open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| - error.puts("\n#{@opt.fns}\nTEXT BODY\n#{@col[:body].size} object #{@col[:ocn]} -> #{@col[:body].slice(0..500)}") - end - txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n} - end - @en_a,@en_z=@en[0].first,@en[0].last if @en[0] - @en_a_asterisk,@en_z_asterisk=@en_ast[0].first,@en_ast[0].last if @en_ast[0] - @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last if @en_pls[0] - body=if data.is==:table - SiSU_FormatShared::CSS_Format.new(@md,data).html_table - elsif data.is==:code - SiSU_FormatShared::CSS_Format.new(@md,data).code - elsif defined? data.indent \ - and defined? data.hang \ - and data.indent =~/[1-9]/ \ - and data.indent == data.hang - SiSU_FormatShared::CSS_Format.new(@md,data).indent(data.indent) - elsif defined? data.indent \ - and defined? data.hang \ - and data.hang =~/[0-9]/ \ - and data.indent != data.hang - SiSU_FormatShared::CSS_Format.new(@md,data).hang_indent(data.hang,data.indent) - else - SiSU_FormatShared::CSS_Format.new(@md,data).norm - end - @col[:body]=clean_document_objects_body(body) - plaintext=@col[:body].dup - plaintext=strip_markup(plaintext) - @col[:plaintext]=clean_searchable_text_from_document_objects(plaintext) - book_idx=book_idx_hash_to_str(data.idx) - @col[:book_idx]=clean_searchable_text_from_document_objects(book_idx) - t=SiSU_DbTuple::LoadDocuments.new(@conn,@col,@opt,@file_maint) - @tuple_array << t.tuple - @en,@en_ast,@en_pls=[],[],[] - @col[:en_a]=@col[:en_z]=nil - @col[:lev]=@col[:plaintext]=@col[:body]=@col[:words]='' - end - if notedata =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/ #% import into database endnotes tables - endnote_array=notedata.scan(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/) - endnote_array.each do |inf| - if inf[/#{Mx[:en_a_o]}\d+.+?#{Mx[:en_a_c]}/] - if inf[/#{Mx[:en_a_o]}(\d+)(.+?)#{Mx[:en_a_c]}/] - nr,txt,digest_clean=$1,$2.strip,0 - end - @id_n ||=0 - @id_n+=1 - txt=special_character_escape(txt) - body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - txt=strip_markup(txt) - if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) - puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" - open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| - error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") - end - txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n} - end - if txt - en={ - type: 'endnotes', - id: @id_n, - lid: @col[:lid], - nr: nr, - txt: txt, - body: body, - ocn: @col[:ocn], - ocnd: @col[:ocnd], - ocns: @col[:ocns], - id_t: @@id_t, - hash: digest_clean - } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) - @tuple_array << t.tuple - end - end - end - word_mode=notedata.scan(/\S+/) - end - if notedata =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/ #% import into database endnotes tables - endnote_array=notedata.scan(/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/) - endnote_array.each do |inf| - if inf[/#{Mx[:en_b_o]}\*\d+.+?#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1 - if inf[/#{Mx[:en_b_o]}[*](\d+)(.+?)#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1 - nr,txt,digest_clean=$1,$2.strip,0 - end - @id_n+=1 - txt=special_character_escape(txt) - body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - txt=strip_markup(txt) - if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) - puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" - open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| - error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") - end - txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n} - end - if txt - en={ - type: 'endnotes_asterisk', - id: @id_n, - lid: @col[:lid], - nr: nr, - txt: txt, - body: body, - ocn: @col[:ocn], - ocnd: @col[:ocnd], - ocns: @col[:ocns], - id_t: @@id_t, - hash: digest_clean - } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) - @tuple_array << t.tuple - end - end - end - word_mode=notedata.scan(/\S+/) - end - if notedata =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/ #% import into database endnotes tables - endnote_array=notedata.scan(/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/) - endnote_array.each do |inf| - if inf[/#{Mx[:en_b_o]}\+\d+.+?#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1 - if inf[/#{Mx[:en_b_o]}[+](\d+)(.+?)#{Mx[:en_b_c]}/] # dal new endnotes 2003w31/1 - nr,txt,digest_clean=$1,$2.strip,0 - end - @id_n+=1 - txt=special_character_escape(txt) - body=SiSU_FormatShared::CSS_Format.new(@md,data).endnote(nr,txt) - txt=strip_markup(txt) - if txt.size > (SiSU_DbColumns::ColumnSize.new.endnote_clean - 1) - puts "\n\nTOO LARGE (ENDNOTE - see error log)\n\n" - open("#{Dir.pwd}/pg_documents_error_log",'a') do |error| - error.puts("\n#{@opt.fns}\nENDNOTE\n#{txt.size} object #{@col[:ocn]},#{@col[:ocnd]},#{@col[:ocns]} -> #{txt.slice(0..500)}") - end - txt=%{\n\nLARGE TEXT BLOCK OMITTED\n\n} - end - if txt - en={ - type: 'endnotes_plus', - id: @id_n, - lid: @col[:lid], - nr: nr, - txt: txt, - body: body, - ocn: @col[:ocn], - ocnd: @col[:ocnd], - ocns: @col[:ocns], - id_t: @@id_t, - hash: digest_clean - } - t=SiSU_DbTuple::LoadEndnotes.new(@conn,en,@opt,@file_maint) - @tuple_array << t.tuple - end - end - end - word_mode=notedata.scan(/\S+/) - end - end - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - @tuple_array - end - def endnotes(txt) - @txt=txt - def extract_any - if @txt =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[*+]?(\d+)\s+.+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/ - endnotes(@txt).range - @en << endnotes(@txt).standard if @txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/ - @en_ast << endnotes(@txt).asterisk if @txt =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/ - @en_pls << endnotes(@txt).plus if @txt =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/ - @txt=endnotes(@txt).clean_text - end - @txt - end - def standard - (@txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/) \ - ? @txt.scan(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/) - : nil - end - def asterisk - (@txt =~/#{Mx[:en_b_o]}\*.+?#{Mx[:en_b_c]}/) \ - ? @txt.scan(/#{Mx[:en_b_o]}[*](\d+).+?#{Mx[:en_b_c]}/) - : nil - end - def plus - (@txt =~/#{Mx[:en_b_o]}\+.+?#{Mx[:en_b_c]}/) \ - ? @txt.scan(/#{Mx[:en_b_o]}[+](\d+).+?#{Mx[:en_b_c]}/) - : nil - end - def clean_text(base_url=nil) - @txt=if base_url - @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,%{\\1}). - gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,%{\\1}). - gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,%{\\1}) - else - @txt.gsub(/#{Mx[:en_a_o]}(\d+).+?#{Mx[:en_a_c]}/,'\1'). - gsub(/#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}/,'\1'). - gsub(/#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/,'\1') - end - @txt - end - def range - @col[:en_a]=@col[:en_z]=nil - if @txt =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}([*]\d+).+?#{Mx[:en_b_c]}|#{Mx[:en_b_o]}([+]\d+).+?#{Mx[:en_b_c]}/ - word_array=@txt.scan(/\S+/) - word_array.each do |w| - if w[/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[*+]?(\d+)\s+.+?(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})(?:#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/] # not tested since change 2003w31 - @col[:en_a]=$1 unless @col[:en_a] - @col[:en_z]=@col[:en_a].dup unless @col[:en_a] - @col[:en_z]=$1 if @col[:en_a] - end - end - end - @col - end - self - end - def db_import_urls(dbi_unit,content) #% import documents OID - populate database - begin - @fnc=content - @env=SiSU_Env::InfoEnv.new(@opt.fns) - f,u={},{} - if @fnb.empty? \ - or @fnb.nil? - p 'file output path error' #remove - end - if FileTest.file?("#{@md.file.output_path.txt.dir}/#{@md.file.base_filename.txt}")==true - f[:txt],u[:txt]='plaintext,', "'#{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}'," - end - if FileTest.file?("#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}")==true - f[:html_toc],u[:html_toc]='html_toc,', "'#{@md.file.output_path.html_seg.url}/#{@md.file.base_filename.html_segtoc}'," - end - if FileTest.file?("#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_scroll}")==true - f[:html_doc],u[:html_doc]='html_doc,', "'#{@md.file.output_path.html_scroll.url}/#{@md.file.base_filename.html_scroll}'," - end - if FileTest.file?("#{@md.file.output_path.xhtml.dir}/#{@md.file.base_filename.xhtml}")==true - f[:xhtml],u[:xhtml]='xhtml,', "'#{@md.file.output_path.xhtml.url}/#{@md.file.base_filename.xhtml}'," - end - if FileTest.file?("#{@md.file.output_path.xml_sax.dir}/#{@md.file.base_filename.xml_sax}")==true - f[:xml_sax],u[:xml_sax]='xml_sax,', "'#{@md.file.output_path.xml_sax.url}/#{@md.file.base_filename.xml_sax}'," - end - if FileTest.file?("#{@md.file.output_path.xml_dom.dir}/#{@md.file.base_filename.xml_dom}")==true - f[:xml_dom],u[:xml_dom]='xml_dom,', "'#{@md.file.output_path.xml_dom.url}/#{@md.file.base_filename.xml_dom}'," - end - if FileTest.file?("#{@md.file.output_path.epub.dir}/#{@md.file.base_filename.epub}")==true - f[:epub],u[:epub]='epub,', "'#{@md.file.output_path.epub.url}/#{@md.file.base_filename.epub}'," - end - if FileTest.file?("#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}")==true - f[:odf],u[:odf]='odf,', "'#{@md.file.output_path.odt.url}/#{@md.file.base_filename.odt}'," - end - if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_a4}")==true #\ - #or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_p_letter}")==true - f[:pdf_p],u[:pdf_p]='pdf_p,', "'#{@md.file.output_path.pdf.url}/#{@pdf_fn.pdf_p_a4}'," - end - if FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_a4}")==true #\ - #or FileTest.file?("#{@md.file.output_path.pdf.dir}/#{@pdf_fn.pdf_l_letter}")==true - f[:pdf_l],u[:pdf_l]='pdf_l,', "'#{@md.file.output_path.pdf.url}/#{@pdf_fn.pdf_l_a4}'," - end - if FileTest.file?("#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}")==true - f[:concordance],u[:concordance]='concordance,', "'#{@md.file.output_path.html_concordance.url}/#{@md.file.base_filename.html_concordance}'," - end - #if FileTest.file?("#{@md.file.output_path.x.dir}/#{@md.file.base_filename.x}")==true - # f[:latex_p],u[:latex_p]='latex_p,', "'#{@md.file.output_path.x.url}/#{@md.file.base_filename.x}'," - #end - ##if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.tex")==true - ## f[:latex_p],u[:latex_p]='latex_p,', "'#{base}/#{@fnb}/#{@opt.fns}.tex'," - ##end - #if FileTest.file?("#{@md.file.output_path.x.dir}/#{@md.file.base_filename.x}")==true - # f[:latex_l],u[:latex_l]='latex_l,', "'#{@md.file.output_path.x.url}/#{@md.file.base_filename.x}'," - #end - ##if FileTest.file?("#{out}/#{@fnb}/#{@opt.fns}.landscape.tex")==true - ## f[:latex_l],u[:latex_l]='latex_l,', "'#{base}/#{@fnb}/#{@opt}.fns}.landscape.tex'," - ##end - if FileTest.file?("#{@md.file.output_path.digest.dir}/#{@md.file.base_filename.digest}")==true - f[:digest],u[:digest]='digest,', "'#{@md.file.output_path.digest.url}/#{@md.file.base_filename.digest}'," - end - if FileTest.file?("#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}")==true #revisit, was to be text, this is html - f[:manifest],u[:manifest]='manifest,', "'#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}'," - end - if FileTest.file?("#{@md.file.output_path.src.dir}/#{@md.file.base_filename.src}")==true - f[:markup],u[:markup]='markup,', "'#{@md.file.output_path.src.url}/#{@md.file.base_filename.src}'," - end - if FileTest.file?("#{@md.file.output_path.sisupod.dir}/#{@md.file.base_filename.sisupod}")==true - f[:sisupod],u[:sisupod]='sisupod,', "'#{@md.file.output_path.sisupod.url}/#{@md.file.base_filename.sisupod}'," - end - t=SiSU_DbTuple::LoadUrls.new(@conn,f,u,@@id_t,@opt,@file_maint) - tuple=t.tuple - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - tuple - end - end -end -__END__ diff --git a/lib/sisu/current/db_indexes.rb b/lib/sisu/current/db_indexes.rb deleted file mode 100644 index 25373bf5..00000000 --- a/lib/sisu/current/db_indexes.rb +++ /dev/null @@ -1,146 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbIndex - class Index # create documents Indexes def initialize(opt,conn='',sql_type) - def initialize(opt,conn,file,sql_type) - @opt,@conn,@file,@sql_type=opt,conn,file,sql_type - end - def create_indexes # check added from pg not tested - def conn_execute_sql_pg(conn,sql) - conn.exec_params(sql) - end - def conn_execute_sql_sqlite(conn,sql) - conn.execute(sql) - end - def conn_execute_sql(conn,sql) - if @sql_type==:pg - conn_execute_sql_pg(conn,sql) - elsif @sql_type==:sqlite - conn_execute_sql_sqlite(conn,sql) - else - end - end - def conn_execute_array(sql_arr) - begin - @conn.transaction do |conn| - sql_arr.each do |sql| - conn_execute_sql(conn,sql) - end - end - rescue - if @conn.is_a?(NilClass) - errmsg="No sqlite3 connection (check sqlite3 dependencies)" - if @opt.act[:no_stop][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, proceeding without sqlite output (as requested)") - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error("#{errmsg}, STOPPING") - exit - end - end - end - end - def base - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - print "\n create documents common indexes\n" - end - sql_arr=[ - %{CREATE INDEX idx_ocn ON doc_objects(ocn);}, - %{CREATE INDEX idx_digest_clean ON doc_objects(digest_clean);}, - %{CREATE INDEX idx_digest_all ON doc_objects(digest_all);}, - %{CREATE INDEX idx_lev0 ON doc_objects(lev0);}, - %{CREATE INDEX idx_lev1 ON doc_objects(lev1);}, - %{CREATE INDEX idx_lev2 ON doc_objects(lev2);}, - %{CREATE INDEX idx_lev3 ON doc_objects(lev3);}, - %{CREATE INDEX idx_lev4 ON doc_objects(lev4);}, - %{CREATE INDEX idx_lev5 ON doc_objects(lev5);}, - %{CREATE INDEX idx_lev6 ON doc_objects(lev6);}, - %{CREATE INDEX idx_endnote_nr ON endnotes(nr);}, - %{CREATE INDEX idx_digest_en ON endnotes(digest_clean);}, - %{CREATE INDEX idx_endnote_nr_asterisk ON endnotes_asterisk(nr);}, - %{CREATE INDEX idx_endnote_asterisk ON endnotes_asterisk(clean);}, - %{CREATE INDEX idx_digest_en_asterisk ON endnotes_asterisk(digest_clean);}, - %{CREATE INDEX idx_endnote_nr_plus ON endnotes_plus(nr);}, - %{CREATE INDEX idx_endnote_plus ON endnotes_plus(clean);}, - %{CREATE INDEX idx_digest_en_plus ON endnotes_plus(digest_clean);}, - %{CREATE INDEX idx_title ON metadata_and_text(title);}, - %{CREATE INDEX idx_author ON metadata_and_text(creator_author);}, - %{CREATE INDEX idx_filename ON metadata_and_text(src_filename);}, - %{CREATE INDEX idx_language ON metadata_and_text(language_document_char);}, - %{CREATE INDEX idx_topics ON metadata_and_text(classify_topic_register)}, - ] - conn_execute_array(sql_arr) - end - def text - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - print "\n create documents TEXT indexes\n" - end - sql_arr=[ - %{CREATE INDEX idx_clean ON doc_objects(clean);}, - %{CREATE INDEX idx_endnote ON endnotes(clean);} - ] - conn_execute_array(sql_arr) - end - base - @opt.act[:psql][:set]==:on ? '' : text - end - end -end -__END__ diff --git a/lib/sisu/current/db_load_tuple.rb b/lib/sisu/current/db_load_tuple.rb deleted file mode 100644 index ebf7a45e..00000000 --- a/lib/sisu/current/db_load_tuple.rb +++ /dev/null @@ -1,323 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbTuple - require_relative 'db_columns' # db_columns.rb - class LoadDocuments - require_relative 'dp' # dp.rb - include SiSU_Param - def initialize(conn,col,opt,file_maint) - @conn,@col,@opt,@file_maint=conn,col,opt,file_maint - @col[:lev]=@col[:lev].to_i - unless @col[:lev].inspect=~/^[0-7]/ \ - or @col[:lev]==0..7 - @col[:lev]=9 - end - @col[:ocn]=0 unless @col[:ocn].inspect=~/\d+/ - @cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - end - def tuple #% import line - sql_entry=if @col[:en_a] - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev0, lev1, lev2, lev3, lev4, lev5, lev6, lev7, en_a, en_z, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv0]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:lv7]}', '#{@col[:en_a]}', '#{@col[:en_z]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" - else - "INSERT INTO doc_objects (lid, metadata_tid, lev, lev_an, clean, body, book_idx, ocn, ocnd, ocns, seg, lev0, lev1, lev2, lev3, lev4, lev5, lev6, lev7, t_of, t_is, node, parent, digest_clean, digest_all) " + - "VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:lev_an]}', '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:book_idx]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv0]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:lv7]}', '#{@col[:t_of]}', '#{@col[:t_is]}', '#{@col[:node]}', '#{@col[:parent]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');" - end - if @opt.act[:verbose_plus][:set]==:on - if @opt.act[:maintenance][:set]==:on - puts @file_maint.inspect - puts sql_entry - end - @file_maint.puts sql_entry - else - if @opt.act[:verbose_plus][:set]==:on - puts sql_entry - @file_maint.puts sql_entry - end - end - if @opt.act[:verbose][:set]==:on - if @col[:lev].inspect =~/[0-35-7]/ - lev=case @col[:lev].inspect - when /0/ then ':A' - when /1/ then ':B' - when /2/ then ':C' - when /3/ then ':D' - when /5/ then ' 2' - when /6/ then ' 3' - when /7/ then ' 4' - end - puts %{#{lev}>\t#{@col[:lv0]}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:lv7]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}} - elsif @col[:lev].inspect =~/[4]/ - puts %{ #{@cX.green}1>#{@cX.off}\t#{@col[:lv0]}\t#{@col[:lv1]}\t#{@col[:lv2]}\t#{@col[:lv3]}\t#{@col[:lv4]}\t#{@col[:lv5]}\t#{@col[:lv6]}\t#{@col[:lv7]}\t#{@col[:ocn]}\t#{@col[:node]}\t#{@col[:ocns]}\t#{@col[:seg]}} - end - end - sql_entry - end - end - class LoadMetadata #< SiSU_DbColumns::Columns - def initialize(conn,id,md,file_maint) - @conn,@id,@md,@file_maint=conn,id,md,file_maint - @tp=SiSU_DbColumns::Columns.new(md) - end - def tuple - sql_entry="INSERT INTO metadata_and_text ( -#{@tp.column.title.tuple[0]} -#{@tp.column.title_main.tuple[0]} -#{@tp.column.title_sub.tuple[0]} -#{@tp.column.title_short.tuple[0]} -#{@tp.column.title_edition.tuple[0]} -#{@tp.column.title_note.tuple[0]} -#{@tp.column.title_language.tuple[0]} -#{@tp.column.title_language_char.tuple[0]} -#{@tp.column.creator_author.tuple[0]} -#{@tp.column.creator_author_honorific.tuple[0]} -#{@tp.column.creator_author_nationality.tuple[0]} -#{@tp.column.creator_editor.tuple[0]} -#{@tp.column.creator_contributor.tuple[0]} -#{@tp.column.creator_illustrator.tuple[0]} -#{@tp.column.creator_photographer.tuple[0]} -#{@tp.column.creator_translator.tuple[0]} -#{@tp.column.creator_prepared_by.tuple[0]} -#{@tp.column.creator_digitized_by.tuple[0]} -#{@tp.column.creator_audio.tuple[0]} -#{@tp.column.creator_video.tuple[0]} -#{@tp.column.language_document.tuple[0]} -#{@tp.column.language_document_char.tuple[0]} -#{@tp.column.language_original.tuple[0]} -#{@tp.column.language_original_char.tuple[0]} -#{@tp.column.date_added_to_site.tuple[0]} -#{@tp.column.date_available.tuple[0]} -#{@tp.column.date_created.tuple[0]} -#{@tp.column.date_issued.tuple[0]} -#{@tp.column.date_modified.tuple[0]} -#{@tp.column.date_published.tuple[0]} -#{@tp.column.date_valid.tuple[0]} -#{@tp.column.date_translated.tuple[0]} -#{@tp.column.date_original_publication.tuple[0]} -#{@tp.column.date_generated.tuple[0]} -#{@tp.column.publisher.tuple[0]} -#{@tp.column.original_publisher.tuple[0]} -#{@tp.column.original_language.tuple[0]} -#{@tp.column.original_language_char.tuple[0]} -#{@tp.column.original_source.tuple[0]} -#{@tp.column.original_institution.tuple[0]} -#{@tp.column.original_nationality.tuple[0]} -#{@tp.column.rights_all.tuple[0]} -#{@tp.column.rights_copyright_text.tuple[0]} -#{@tp.column.rights_copyright_translation.tuple[0]} -#{@tp.column.rights_copyright_illustrations.tuple[0]} -#{@tp.column.rights_copyright_photographs.tuple[0]} -#{@tp.column.rights_copyright_preparation.tuple[0]} -#{@tp.column.rights_copyright_digitization.tuple[0]} -#{@tp.column.rights_copyright_audio.tuple[0]} -#{@tp.column.rights_copyright_video.tuple[0]} -#{@tp.column.rights_license.tuple[0]} -#{@tp.column.classify_topic_register.tuple[0]} -#{@tp.column.classify_subject.tuple[0]} -#{@tp.column.classify_loc.tuple[0]} -#{@tp.column.classify_dewey.tuple[0]} -#{@tp.column.classify_keywords.tuple[0]} -#{@tp.column.identifier_oclc.tuple[0]} -#{@tp.column.identifier_isbn.tuple[0]} -#{@tp.column.notes_abstract.tuple[0]} -#{@tp.column.notes_description.tuple[0]} -#{@tp.column.notes_comment.tuple[0]} -#{@tp.column.notes_history.tuple[0]} -#{@tp.column.notes_format.tuple[0]} -#{@tp.column.notes_relation.tuple[0]} -#{@tp.column.notes_coverage.tuple[0]} -#{@tp.column.notes_type.tuple[0]} -#{@tp.column.notes_prefix.tuple[0]} -#{@tp.column.notes_prefix_a.tuple[0]} -#{@tp.column.notes_prefix_b.tuple[0]} -#{@tp.column.notes_suffix.tuple[0]} -#{@tp.column.src_filename.tuple[0]} -#{@tp.column.src_fingerprint.tuple[0]} -#{@tp.column.src_filesize.tuple[0]} -#{@tp.column.src_word_count.tuple[0]} -#{@tp.column.src_txt.tuple[0]} -#{@tp.column.fulltext.tuple[0]} -#{@tp.column.links.tuple[0]} -tid) -" + - "VALUES ( -#{@tp.column.title.tuple[1]} -#{@tp.column.title_main.tuple[1]} -#{@tp.column.title_sub.tuple[1]} -#{@tp.column.title_short.tuple[1]} -#{@tp.column.title_edition.tuple[1]} -#{@tp.column.title_note.tuple[1]} -#{@tp.column.title_language.tuple[1]} -#{@tp.column.title_language_char.tuple[1]} -#{@tp.column.creator_author.tuple[1]} -#{@tp.column.creator_author_honorific.tuple[1]} -#{@tp.column.creator_author_nationality.tuple[1]} -#{@tp.column.creator_editor.tuple[1]} -#{@tp.column.creator_contributor.tuple[1]} -#{@tp.column.creator_illustrator.tuple[1]} -#{@tp.column.creator_photographer.tuple[1]} -#{@tp.column.creator_translator.tuple[1]} -#{@tp.column.creator_prepared_by.tuple[1]} -#{@tp.column.creator_digitized_by.tuple[1]} -#{@tp.column.creator_audio.tuple[1]} -#{@tp.column.creator_video.tuple[1]} -#{@tp.column.language_document.tuple[1]} -#{@tp.column.language_document_char.tuple[1]} -#{@tp.column.language_original.tuple[1]} -#{@tp.column.language_original_char.tuple[1]} -#{@tp.column.date_added_to_site.tuple[1]} -#{@tp.column.date_available.tuple[1]} -#{@tp.column.date_created.tuple[1]} -#{@tp.column.date_issued.tuple[1]} -#{@tp.column.date_modified.tuple[1]} -#{@tp.column.date_published.tuple[1]} -#{@tp.column.date_valid.tuple[1]} -#{@tp.column.date_translated.tuple[1]} -#{@tp.column.date_original_publication.tuple[1]} -#{@tp.column.date_generated.tuple[1]} -#{@tp.column.publisher.tuple[1]} -#{@tp.column.original_publisher.tuple[1]} -#{@tp.column.original_language.tuple[1]} -#{@tp.column.original_language_char.tuple[1]} -#{@tp.column.original_source.tuple[1]} -#{@tp.column.original_institution.tuple[1]} -#{@tp.column.original_nationality.tuple[1]} -#{@tp.column.rights_all.tuple[1]} -#{@tp.column.rights_copyright_text.tuple[1]} -#{@tp.column.rights_copyright_translation.tuple[1]} -#{@tp.column.rights_copyright_illustrations.tuple[1]} -#{@tp.column.rights_copyright_photographs.tuple[1]} -#{@tp.column.rights_copyright_preparation.tuple[1]} -#{@tp.column.rights_copyright_digitization.tuple[1]} -#{@tp.column.rights_copyright_audio.tuple[1]} -#{@tp.column.rights_copyright_video.tuple[1]} -#{@tp.column.rights_license.tuple[1]} -#{@tp.column.classify_topic_register.tuple[1]} -#{@tp.column.classify_subject.tuple[1]} -#{@tp.column.classify_loc.tuple[1]} -#{@tp.column.classify_dewey.tuple[1]} -#{@tp.column.classify_keywords.tuple[1]} -#{@tp.column.identifier_oclc.tuple[1]} -#{@tp.column.identifier_isbn.tuple[1]} -#{@tp.column.notes_abstract.tuple[1]} -#{@tp.column.notes_comment.tuple[1]} -#{@tp.column.notes_description.tuple[1]} -#{@tp.column.notes_history.tuple[1]} -#{@tp.column.notes_format.tuple[1]} -#{@tp.column.notes_relation.tuple[1]} -#{@tp.column.notes_coverage.tuple[1]} -#{@tp.column.notes_type.tuple[1]} -#{@tp.column.notes_prefix.tuple[1]} -#{@tp.column.notes_prefix_a.tuple[1]} -#{@tp.column.notes_prefix_b.tuple[1]} -#{@tp.column.notes_suffix.tuple[1]} -#{@tp.column.src_filename.tuple[1]} -#{@tp.column.src_fingerprint.tuple[1]} -#{@tp.column.src_filesize.tuple[1]} -#{@tp.column.src_word_count.tuple[1]} -#{@tp.column.src_txt.tuple[1]} -#{@tp.column.fulltext.tuple[1]} -#{@tp.column.links.tuple[1]} -#{@id} -);" - if @md.opt.act[:maintenance][:set]==:on - puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file_maint.inspect}" - @file_maint.puts sql_entry - else - if @md.opt.act[:verbose_plus][:set]==:on - @file_maint.puts sql_entry - end - end - sql_entry - end - end - class LoadUrls - def initialize(conn,f,u,id,opt,file_maint) - @conn,@f,@u,@id,@opt,@file_maint=conn,f,u,id,opt,file_maint - end - def tuple - sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) " + - "VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});" - if @opt.act[:maintenance][:set]==:on - @file_maint.puts sql_entry - else - if @opt.act[:verbose_plus][:set]==:on - @file_maint.puts sql_entry - end - end - sql_entry - end - end - class LoadEndnotes - def initialize(conn,en,opt,file_maint) - @conn,@en,@opt,@file_maint=conn,en,opt,file_maint - end - def tuple - sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) " + - "VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');" - if @opt.act[:maintenance][:set]==:on - @file_maint.puts sql_entry - else - if @opt.act[:verbose_plus][:set]==:on - @file_maint.puts sql_entry - end - end - sql_entry - end - end -end -__END__ diff --git a/lib/sisu/current/db_remove.rb b/lib/sisu/current/db_remove.rb deleted file mode 100644 index c8287aa9..00000000 --- a/lib/sisu/current/db_remove.rb +++ /dev/null @@ -1,182 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbRemove - class Remove - include SiSU_DbAction - def initialize(opt,conn,file,sql_type) - @opt,@conn,@file,@sql_type=opt,conn,file,sql_type - @md=SiSU_Param::Parameters.new(@opt).get - @fnb=@md.fnb - @db=SiSU_Env::InfoDb.new - end - def remove - driver_sqlite3=if @sql_type==:sqlite - (@conn.inspect.match(/^(.{10})/)[1]==@db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]) \ - ? true - : false - end - del_id=if driver_sqlite3 - begin - remove_selected=%{ - SELECT tid - FROM metadata_and_text - WHERE src_filename = '#{@md.fns}' - AND metadata_and_text.language_document_char = '#{@opt.lng}' - ;} # note, for .ssm: @md.fns (is set during runtime & is) != @opt.fns @md.opt.fns - @conn.get_first_value(remove_selected).to_i - rescue SQLite3::Exception => e - #not tested - puts "Exception occurred" - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark(e.inspect) - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - sdb={ - create: SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type), - index: SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type), - } - db_action(sdb).create - end - else - begin - remove_selected=%{ - SELECT metadata_and_text.tid - FROM metadata_and_text - WHERE metadata_and_text.src_filename = '#{@md.fns}' - AND metadata_and_text.language_document_char = '#{@opt.lng}' - ;} # note, for .ssm: @md.fns (is set during runtime & is) != @opt.fns @md.opt.fns - x=@conn.exec(remove_selected) - x.field_values("tid")[0] - rescue PG::Error => e - err=[ - e.result.error_field( PG::Result::PG_DIAG_SEVERITY ), - e.result.error_field( PG::Result::PG_DIAG_SQLSTATE ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_PRIMARY ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_DETAIL ), - e.result.error_field( PG::Result::PG_DIAG_MESSAGE_HINT ), - e.result.error_field( PG::Result::PG_DIAG_STATEMENT_POSITION ), - e.result.error_field( PG::Result::PG_DIAG_INTERNAL_POSITION ), - e.result.error_field( PG::Result::PG_DIAG_INTERNAL_QUERY ), - e.result.error_field( PG::Result::PG_DIAG_CONTEXT ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_FILE ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_LINE ), - e.result.error_field( PG::Result::PG_DIAG_SOURCE_FUNCTION ), - ] - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark("\n" + err.inspect) - if err[2] =~/relation "\S+?" does not exist/ \ - or err.inspect =~/relation "\S+?" does not exist/ - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + err[2] + "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - sdb={ - create: SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type), - index: SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type), - } - db_action(sdb).create - end - end - end - if del_id - sql_entry=[ - "DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';", - "DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';", - "DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';", - "DELETE FROM doc_objects WHERE metadata_tid = '#{del_id}';", - "DELETE FROM urls WHERE metadata_tid = '#{del_id}';", - "DELETE FROM metadata_and_text WHERE metadata_and_text.tid = '#{del_id}';", - ] - if driver_sqlite3 - @conn.transaction - sql_entry.each do |s| - begin - @conn.execute(s) - rescue - next - end - end - @conn.commit if driver_sqlite3 - else - sql_entry.each do |s| - begin - @conn.exec_params(s) - rescue - next - end - end - end - if @opt.act[:maintenance][:set]==:on - @file.puts sql_entry - end - else - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.selections.str, - "no such file in database #{@db.psql.db}::#{@opt.fns}" - ).puts_grey - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/db_select.rb b/lib/sisu/current/db_select.rb deleted file mode 100644 index 284bd135..00000000 --- a/lib/sisu/current/db_select.rb +++ /dev/null @@ -1,230 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbAction - def db_action(sdb) - @sdb=sdb - def createdb - @sdb[:create].output_dir? - begin - @sdb[:create].create_db - rescue - @sdb[:create].output_dir? - end - end - def drop - @sdb[:drop].drop.tables - end - def create - @sdb[:create].output_dir? - begin - @sdb[:create].create_table.metadata_and_text - @sdb[:create].create_table.doc_objects - @sdb[:create].create_table.endnotes - @sdb[:create].create_table.endnotes_asterisk - @sdb[:create].create_table.endnotes_plus - @sdb[:create].create_table.urls - @sdb[:index].create_indexes - rescue - SiSU_Errors::Rescued.new($!,$@,'--sqlite').location - @sdb[:create].output_dir? do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def import - db_exist? - @sdb[:import].marshal_load - tell=case @sql_type - when :sqlite - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{@db.sqlite.db} database?" - ) - when :pg - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "pgaccess or psql #{@db.psql.db} database?" - ) - else '???' - end - tell.puts_grey if @opt.act[:verbose][:set]==:on - end - def remove - db_exist? - @sdb[:remove_doc].remove - end - def update - remove - import - end - self - end -end -module SiSU_DbSelect - class Case - include SiSU_DbAction - def initialize(opt,conn='',sql_type=:pg) - @opt,@conn,@sql_type=opt,conn,sql_type - @db=SiSU_Env::InfoDb.new - @file_maint=sql_maintenance_file - @sdb={ - create: SiSU_DbDBI::Create.new(@opt,@conn,@file_maint,@sql_type), - index: SiSU_DbDBI::Index.new(@opt,@conn,@file_maint,@sql_type), - drop: SiSU_DbDBI::Drop.new(@opt,@conn,@db,@sql_type), - } - if (@opt.act[:psql_import][:set]==:on \ - || @opt.act[:psql_update][:set]==:on) \ - or (@opt.act[:sqlite_import][:set]==:on \ - || @opt.act[:sqlite_update][:set]==:on) - @sdb[:import]=SiSU_DbDBI::Import.new(@opt,@conn,@file_maint,@sql_type) - @sdb[:remove_doc]=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) - elsif (@opt.act[:psql_remove][:set]==:on \ - or @opt.act[:sqlite_remove][:set]==:on) - @sdb[:remove_doc]=SiSU_DbDBI::Remove.new(@opt,@conn,@file_maint,@sql_type) - end - end - def db_exist? - if @sql_type==:sqlite \ - and (not (FileTest.file?(@db.sqlite.db)) \ - or FileTest.zero?(@db.sqlite.db)) - puts %{no connection with sqlite database established, you may need to run:\n} \ - + %{ sisu --sqlite --createall\n} \ - + %{ before attempting to populate the database} - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - db_action(@sdb).create - end - if @conn.is_a?(NilClass) - if @sql_type==:sqlite - puts %{no connection with sqlite database established, you may need to run:\n} \ - + %{ sisu --sqlite --createall\n} \ - + %{ before attempting to populate the database} - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).mark( - "\n" \ - + 'Attempting to initialize db' + "\n" \ - + 'Creating db tables' - ) - db_action(@sdb).create - @db.sqlite.db - else - puts %{no connection with pg database established, you may need to run:\n} \ - + %{ createdb "#{@db.psql.db}"\n} \ - + %{ after that don't forget to run:\n} \ - + %{ sisu --pg --createall\n} \ - + %{ before attempting to populate the database} - @db.psql.db - end - exit - end - end - def sql_maintenance_file - file=if @opt.act[:maintenance][:set]==:on - if @opt.fns and not @opt.fns.empty? - @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - if @sql_type ==:sqlite - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" - end - @db=SiSU_Env::InfoDb.new - @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - if @sql_type ==:sqlite - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') - else - File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') - end - elsif @opt.fns \ - and (@opt.act[:sqlite_create][:set] ==:on \ - || @opt.act[:psql_create][:set] ==:on) - nil #sort variations later - else nil - end - else nil - end - file - end - def cases - if @opt.act[:psql_drop][:set] ==:on \ - or @opt.act[:sqlite_drop][:set] ==:on - db_action(@sdb).drop - end - if @opt.act[:psql_createdb][:set] ==:on \ - or @opt.act[:sqlite_createdb][:set] ==:on - db_action(@sdb).createdb - end - if @opt.act[:psql_create][:set] ==:on \ - or @opt.act[:sqlite_create][:set] ==:on - db_action(@sdb).create - end - if @opt.act[:psql_update][:set] ==:on \ - or @opt.act[:sqlite_update][:set] ==:on - db_action(@sdb).update - else - if @opt.act[:psql_remove][:set] ==:on \ - or @opt.act[:sqlite_remove][:set] ==:on - db_action(@sdb).remove - end - if @opt.act[:psql_import][:set] ==:on \ - or @opt.act[:sqlite_import][:set] ==:on - db_action(@sdb).import - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/db_sqltxt.rb b/lib/sisu/current/db_sqltxt.rb deleted file mode 100644 index de717cc6..00000000 --- a/lib/sisu/current/db_sqltxt.rb +++ /dev/null @@ -1,173 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbText - class Prepare - def special_character_escape(str) - str=str.gsub(/'/m,"''"). #string.gsub!(/'/,"\047") #string.gsub!(/'/,"\\'") - gsub(/(\\)/m,'\1\1'). #ok but with warnings, double backslash on sqlite #str.gsub!(/[\\]/m,'\\x5C') #ok but with warnings, but not for sqlite #str.gsub!(/(\\)/m,'\1') #ok for sqlite not for pgsql - gsub(/#{Mx[:br_line]}|#{Mx[:br_nl]}/m,"
\n"). - gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/m,''). #check - gsub(/#{Mx[:lnk_o]}\s*(\S+?\.(?:png|jpg))(?:\s+\d+x\d+)?(.+?)#{Mx[:lnk_c]}\S+/m,'[image: \1] \2'). - gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}(?:file|ftp):\/\/\S+?([.,!?]?(?:\s|$))/m,'\1\2'). - gsub(/#{Mx[:lnk_o]}\s*(.+?)\s*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/m,'\1') - end - def clean_searchable_text_from_document_objects(arr) - en=[] - arr=(arr.is_a?(String)) ? [ arr ] : arr - txt_arr=arr.each.map do |s| - s=s.gsub(/#{Mx[:fa_o]}[a-z]{1,4}#{Mx[:fa_o_c]}/m,''). - gsub(/#{Mx[:fa_c_o]}[a-z]{1,4}#{Mx[:fa_c]}/m,''). - gsub(/
/m,' ') - en << s.scan(/#{Mx[:en_a_o]}\s*(.+?)\s*#{Mx[:en_a_c]}/m) - s=s.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/m,''). - gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m,''). - gsub(/ \s+/m,' ') - #p s if s =~/[^ \nA-Za-z0-9'"`?!#@$%^&*=+,.;:\[\]()<>{}‹›|\\\/~_-]/ - s - end - txt_arr=txt_arr << en - txt=txt_arr.flatten.join("\n") - special_character_escape(txt) - end - def clean_document_objects_body(arr) - en=[] - arr=(arr.is_a?(String)) ? [ arr ] : arr - txt_arr=arr.each.map do |s| - en << s.scan(/#{Mx[:en_a_o]}\s*(.+?)\s*#{Mx[:en_a_c]}/m) - s=s. - gsub(/#{Mx[:en_a_o]}\s*(\d+).+?#{Mx[:en_a_c]}/m, - '\1'). - gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m,''). - gsub(/ \s+/m,' ') - s - end - en_arr=en.flatten.each.map do |e| - e.sub(/^(\d+)\s*/,'\1 ') - end - txt_arr=txt_arr << en_arr - txt=txt_arr.flatten.join("\n
") - special_character_escape(txt) - end - def clean_searchable_text_from_document_source(arr) - txt_arr,en=[],[] - arr=(arr.is_a?(String)) ? arr.split(/\n+/m) : arr - arr.each do |s| - s=s.gsub(/([*\/_-])\{(.+?)\}\1/m,'\2'). - gsub(/^(?:block|group|poem|code)\{/m,''). - gsub(/^\}(?:block|group|poem|code)/m,''). - gsub(/\A(?:@\S+:\s+.+)\Z/m,'') - if s =~/^:A~/ - if defined? @md.creator \ - and defined? @md.creator.author \ - and not @md.creator.author.empty? - s=s.gsub(/@author/,@md.creator.author) - else - SiSU_Screen::Ansi.new( - 'v', - 'WARNING Document Author information missing; provide @creator: :author:', - @md.fnb - ).warn unless @md.opt.act[:quiet][:set]==:on - end - if defined? @md.title \ - and defined? @md.title.full \ - and not @md.title.full.empty? - s=s.gsub(/@title/,@md.title.full) - else - SiSU_Screen::Ansi.new( - 'v', - 'WARNING Document Title missing; provide @title:', - @md.fnb - ).warn unless @md.opt.act[:quiet][:set]==:on - end - end - s=s.gsub(/^(?:_[1-9]\*?|_\*)\s+/m,''). - gsub(/^(?:[1-9]\~(\S+)?)\s+/m,''). - gsub(/^(?::?[A-C]\~(\S+)?)\s+/m,''). - gsub(/^%{1,3} .+/m,''). #removed even if contained in code block - gsub(/
/m,' ') - #en << s.scan(/~\{\s*(.+?)\s*\}~/m) - s=s.gsub(/~\{.+?\}~/m,''). - gsub(/ \s+/m,' ') - ##special_character_escape(s) - #p s if s =~/[^ \nA-Za-z0-9'"`?!#@$%^&*=+,.;:\[\]()<>{}‹›|\\\/~_-]/ - s - end - txt_arr << arr << en - txt=txt_arr.flatten.join("\n") - txt=special_character_escape(txt) - txt - end - def strip_markup(str) #define rules, make same as in dal clean - str=str.gsub(/#{Mx[:fa_superscript_o]}(\d+)#{Mx[:fa_superscript_c]}/,'[\1]'). - gsub(/(?: \\;|#{Mx[:nbsp]})+/,' '). - gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}\d+(.+)#{Mx[:tc_c]}/u,'\1'). #tables - gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}\d+#{Mx[:tc_p]}/u,' '). #tables - gsub(/#{Mx[:tc_p]}/u,' '). #tables tidy later - gsub(/<.+?>/,''). - gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}(?:file|ftp)\/\/:\S+ /,' [image] '). # else image names found in search - gsub(/#{Mx[:lnk_o]}.+?\.(?:png|jpg|gif).+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/,' [image]'). # else image names found in search - gsub(/\s\s+/,' '). - strip - end - def unique_words(str) - a=str.scan(/[a-zA-Z0-9\\\/_-]{2,}/) #a=str.scan(/\S+{2,}/) - str=a.uniq.sort.join(' ') - str - end - end -end -__END__ diff --git a/lib/sisu/current/db_tests.rb b/lib/sisu/current/db_tests.rb deleted file mode 100644 index 137850ab..00000000 --- a/lib/sisu/current/db_tests.rb +++ /dev/null @@ -1,114 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** modules shared by the different db types, dbi, postgresql, sqlite - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DbTests - class Test - def initialize(info,opt) - @ck,@opt=info,opt - unless @opt.act[:quiet][:set]==:on - puts @ck.tp[:fns] if @ck.tp[:fns] and not @ck.tp[:fns].empty? - puts @ck.tp[:title] if @ck.tp[:title] and not @ck.tp[:title].empty? - puts @ck.tp[:creator] if @ck.tp[:creator] and not @ck.tp[:creator].empty? - end - end - def verify - unless @opt.act[:quiet][:set]==:on - puts @ck.tp[:fns].length.to_s + ' checklength ' + @ck.tp[:fns] if @ck.tp[:fns] and @ck.tp[:fns].length >@ck.lt_filename - puts @ck.tp[:title].length.to_s + ' checklength ' + @ck.tp[:title] if @ck.tp[:title] and @ck.tp[:title].length >@ck.lt_title - puts @ck.tp[:subtitle].length.to_s + ' checklength ' + @ck.tp[:subtitle] if @ck.tp[:subtitle] and @ck.tp[:subtitle].length >@ck.lt_subtitle - puts @ck.tp[:creator].length.to_s + ' checklength ' + @ck.tp[:creator] if @ck.tp[:creator] and @ck.tp[:creator].length >@ck.lt_creator - puts @ck.tp[:author_title].length.to_s + ' checklength ' + @ck.tp[:author_title] if @ck.tp[:author_title] and @ck.tp[:author_title].length >@ck.lt_author_title - puts @ck.tp[:illustrator].length.to_s + ' checklength ' + @ck.tp[:illustrator] if @ck.tp[:illustrator] and @ck.tp[:illustrator].length >@ck.lt_illustrator - puts @ck.tp[:translator].length.to_s + ' checklength ' + @ck.tp[:translator] if @ck.tp[:translator] and @ck.tp[:translator].length >@ck.lt_translator - puts @ck.tp[:prepared_by].length.to_s + ' checklength ' + @ck.tp[:prepared_by] if @ck.tp[:prepared_by] and @ck.tp[:prepared_by].length >@ck.lt_prepared_by - puts @ck.tp[:digitized_by].length.to_s + ' checklength ' + @ck.tp[:digitized_by] if @ck.tp[:digitized_by] and @ck.tp[:digitized_by].length >@ck.lt_digitized_by - puts @ck.tp[:subject].length.to_s + ' checklength ' + @ck.tp[:subject] if @ck.tp[:subject] and @ck.tp[:subject].length >@ck.lt_subject - puts @ck.tp[:description].length.to_s + ' checklength ' + @ck.tp[:description] if @ck.tp[:description] and @ck.tp[:description].length >@ck.lt_description - puts @ck.tp[:publisher].length.to_s + ' checklength ' + @ck.tp[:publisher] if @ck.tp[:publisher] and @ck.tp[:publisher].length >@ck.lt_publisher - puts @ck.tp[:contributor].length.to_s + ' checklength ' + @ck.tp[:contributor] if @ck.tp[:contributor] and @ck.tp[:contributor].length >@ck.lt_contributor - puts @ck.tp[:date].length.to_s + ' checklength ' + @ck.tp[:date] if @ck.tp[:date] and @ck.tp[:date].length >@ck.lt_date - puts @ck.tp[:date_created].length.to_s + ' checklength ' + @ck.tp[:date_created] if @ck.tp[:date_created] and @ck.tp[:date_created].length >@ck.lt_date - puts @ck.tp[:date_issued].length.to_s + ' checklength ' + @ck.tp[:date_issued] if @ck.tp[:date_issued] and @ck.tp[:date_issued].length >@ck.lt_date - puts @ck.tp[:date_valid].length.to_s + ' checklength ' + @ck.tp[:date_valid] if @ck.tp[:date_valid] and @ck.tp[:date_valid].length >@ck.lt_date - puts @ck.tp[:date_available].length.to_s + ' checklength ' + @ck.tp[:date_available] if @ck.tp[:date_available] and @ck.tp[:date_available].length >@ck.lt_date - puts @ck.tp[:date_modified].length.to_s + ' checklength ' + @ck.tp[:date_modified] if @ck.tp[:date_modified] and @ck.tp[:date_modified].length >@ck.lt_date - puts @ck.tp[:date_translated].length.to_s + ' checklength ' + @ck.tp[:date_translated] if @ck.tp[:date_translated] and @ck.tp[:date_translated].length >@ck.lt_date - puts @ck.tp[:date_added_to_site].length.to_s + ' checklength ' + @ck.tp[:date_added_to_site] if @ck.tp[:date_added_to_site] and @ck.tp[:date_added_to_site].length >@ck.lt_date - puts @ck.tp[:type].length.to_s + ' checklength ' + @ck.tp[:type] if @ck.tp[:type] and @ck.tp[:type].length >@ck.lt_type - puts @ck.tp[:format].length.to_s + ' checklength ' + @ck.tp[:format] if @ck.tp[:format] and @ck.tp[:format].length >@ck.lt_format - puts @ck.tp[:identifier].length.to_s + ' checklength ' + @ck.tp[:identifier] if @ck.tp[:identifier] and @ck.tp[:identifier].length >@ck.lt_identifier - puts @ck.tp[:source].length.to_s + ' checklength ' + @ck.tp[:source] if @ck.tp[:source] and @ck.tp[:source].length >@ck.lt_source - puts @ck.tp[:language].length.to_s + ' checklength ' + @ck.tp[:language] if @ck.tp[:language] and @ck.tp[:language].length >@ck.lt_language - puts @ck.tp[:language_original].length.to_s + ' checklength ' + @ck.tp[:language_original] if @ck.tp[:language_original] and @ck.tp[:language_original].length >@ck.lt_language_original - puts @ck.tp[:relation].length.to_s + ' checklength ' + @ck.tp[:relation] if @ck.tp[:relation] and @ck.tp[:relation].length >@ck.lt_relation - puts @ck.tp[:coverage].length.to_s + ' checklength ' + @ck.tp[:coverage] if @ck.tp[:coverage] and @ck.tp[:coverage].length >@ck.lt_coverage - puts @ck.tp[:rights].length.to_s + ' checklength ' + @ck.tp[:rights] if @ck.tp[:rights] and @ck.tp[:rights].length >@ck.lt_rights - puts @ck.tp[:copyright].length.to_s + ' checklength ' + @ck.tp[:copyright] if @ck.tp[:copyright] and @ck.tp[:copyright].length >@ck.lt_copyright - puts @ck.tp[:owner].length.to_s + ' checklength ' + @ck.tp[:owner] if @ck.tp[:owner] and @ck.tp[:owner].length >@ck.lt_owner - puts @ck.tp[:keywords].length.to_s + ' checklength ' + @ck.tp[:keywords] if @ck.tp[:keywords] and @ck.tp[:keywords].length >@ck.lt_keywords - puts @ck.tp[:abstract].length.to_s + ' checklength ' + @ck.tp[:abstract] if @ck.tp[:abstract] and @ck.tp[:abstract].length >@ck.lt_abstract - puts @ck.tp[:comment].length.to_s + ' checklength ' + @ck.tp[:comment] if @ck.tp[:comment] and @ck.tp[:comment].length >@ck.lt_comment - puts @ck.tp[:loc].length.to_s + ' checklength ' + @ck.tp[:loc] if @ck.tp[:loc] and @ck.tp[:loc].length >@ck.lt_loc - puts @ck.tp[:dewey].length.to_s + ' checklength ' + @ck.tp[:dewey] if @ck.tp[:dewey] and @ck.tp[:dewey].length >@ck.lt_dewey - puts @ck.tp[:isbn].length.to_s + ' checklength ' + @ck.tp[:isbn] if @ck.tp[:isbn] and @ck.tp[:isbn].length >@ck.lt_isbn - puts @ck.tp[:pg].length.to_s + ' checklength ' + @ck.tp[:pg] if @ck.tp[:pg] and @ck.tp[:pg].length >@ck.lt_pg - puts @ck.tp[:topic_register].length.to_s + ' checklength ' + @ck.tp[:topic_register] if @ck.tp[:topic_register] and @ck.tp[:topci_register].length >@ck.lt_topic_register - puts @ck.tp[:date] if @ck.tp[:date] and not @ck.tp[:date].empty? and @ck.tp[:date] !~/\d\d-\d\d-\d\d/ - end - end - end -end -__END__ diff --git a/lib/sisu/current/dbi.rb b/lib/sisu/current/dbi.rb deleted file mode 100644 index 93e4769a..00000000 --- a/lib/sisu/current/dbi.rb +++ /dev/null @@ -1,166 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** postgresql module, dbi import frame - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DBI #% database building - require_relative 'se' # se.rb - include SiSU_Env; include SiSU_Screen - require_relative 'dp' # dp.rb - include SiSU_Param - require_relative 'db_dbi' # db_dbi.rb - include SiSU_DbDBI - require_relative 'html_lite_shared' # html_lite_shared.rb - include SiSU_FormatShared - class SQL - def initialize(opt) - @opt=opt - @db=SiSU_Env::InfoDb.new - if @opt.act[:psql][:set]==:on \ - or @opt.act[:sqlite][:set]==:on - @sql_type=if @opt.act[:psql][:set]==:on - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - :pg - elsif @opt.act[:psql][:set]==:on - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - :pg - elsif @opt.act[:sqlite][:set]==:on - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - :sqlite - elsif @opt.act[:sqlite][:set]==:on - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - :sqlite - else - maintenance_check(@opt,__FILE__,__LINE__) if @opt.act[:maintenance][:set]==:on - :sqlite - end - if @sql_type==:pg then SiSU_Env::Load.new('pg',true).prog - elsif @sql_type==:sqlite then SiSU_Env::Load.new('sqlite3',true).prog - end - end - end - def maintenance_check(opt,file,line) - p opt.selections.str - p "at #{file} #{line}" - end - def read_psql - begin - begin - require 'pg' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('pg NOT FOUND (LoadError)') - end - @conn=@db.psql.conn_pg - rescue - if @opt.act[:psql_create][:set]==:on - cX=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]).cX - puts <<-WOK -manually create the database: "#{cX.green}#{@db.db}#{cX.off}" if it does not yet exist - #{cX.yellow}createdb #{@db.db}#{cX.off} - WOK - #sudo su -p postgres; createdb #{@db.db}; #[createuser?] - end - ensure - end - end - def read_sqlite - begin - begin - begin - require 'sqlite3' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('sqlite3 NOT FOUND (LoadError)') - end - @conn=@db.sqlite.conn_sqlite3 - rescue LoadError - errmsg='sqlite3 NOT FOUND (LoadError)' - if @opt.act[:no_stop][:set]==:on - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error(errmsg + ', ' + 'attempt to proceed without sqlite output (as requested)') - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error(errmsg + ', ' + 'STOPPING') - exit - end - end - end - end - def connect - case @sql_type - when :pg then read_psql #read_pg - when :sqlite then read_sqlite - end - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "SQL DB #{@sql_type.upcase}", - @opt.fno - ).dbi_title unless @opt.act[:quiet][:set]==:on - begin - SiSU_DbDBI::Case.new(@opt,@conn,@sql_type).cases - rescue - SiSU_Errors::Rescued.new($!,$@,@cf,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - begin - rescue - connect - end - end - end -end -__END__ diff --git a/lib/sisu/current/dbi_discrete.rb b/lib/sisu/current/dbi_discrete.rb deleted file mode 100644 index f62204c6..00000000 --- a/lib/sisu/current/dbi_discrete.rb +++ /dev/null @@ -1,206 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** postgresql module, dbi import frame - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DBI_Discrete #% database building - require_relative 'se' # se.rb - include SiSU_Env; include SiSU_Screen - require_relative 'dp' # dp.rb - include SiSU_Param - require_relative 'db_dbi' # db_dbi.rb - include SiSU_DbDBI - require_relative 'html_lite_shared' # html_lite_shared.rb - include SiSU_FormatShared - begin - require 'fileutils' - include FileUtils::Verbose - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('fileutils NOT FOUND (LoadError)') - end - class SQL - def initialize(opt) - SiSU_Env::Load.new('sqlite3',true).prog - @opt=opt - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - @md=@particulars.md - if @opt.act[:sqlite][:set]==:on - @sql_type=:sqlite - if @opt.act[:maintenance][:set]==:on - maintenance_check(@opt,__FILE__,__LINE__) - end - end - @output_path=@md.file.output_path.sqlite_discrete.dir - @filename=@md.file.base_filename.sqlite_discrete - @file_maint=sql_maintenance_file - @file="#{@output_path}/#{@filename}" - end - def build - prepare - create_and_populate - end - def maintenance_check(opt,file,line) - #p opt.selections.str - p "at #{file} #{line}" - end - def prepare - if not FileTest.directory?(@output_path) - FileUtils::mkdir_p(@output_path) - elsif @file - FileUtils::rm_rf(@file) - end - end - def db_exist?(db,conn) - msg=%{no connection with sqlite database established, createdb "#{db.sqlite.db}"?} - if (not (FileTest.file?(db.sqlite.db)) \ - or FileTest.zero?(db.sqlite.db)) - puts msg - exit - end - if conn.is_a?(NilClass) - puts msg - exit - end - end - def create_and_populate - db=SiSU_Env::DbOp.new(@md) - conn=db.sqlite_discrete.conn_sqlite3 - sdb=SiSU_DbDBI::Create.new(@opt,conn,@file,:sqlite) - sdb_index=SiSU_DbDBI::Index.new(@opt,conn,@file,:sqlite) - sdb.output_dir? - begin - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'SQLite (discrete)', - "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - ).green_title_hi unless @opt.act[:quiet][:set]==:on - sdb.create_db - sdb.create_table.metadata_and_text - sdb.create_table.doc_objects - sdb.create_table.endnotes - sdb.create_table.endnotes_asterisk - sdb.create_table.endnotes_plus - sdb.create_table.urls - sdb_index.create_indexes - db_exist?(db,conn) - sdb_import=SiSU_DbDBI::Import.new(@opt,conn,@file_maint,:sqlite) - sdb_import.marshal_load - tell=SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "sqlite3 #{db.sqlite.db} database?" - ) - tell.puts_grey if @opt.act[:verbose][:set]==:on - rescue - SiSU_Errors::Rescued.new($!,$@,'-d').location do - __LINE__.to_s + ':' + __FILE__ - end - sdb.output_dir? - end - end - def read_sqlite - begin - begin - require 'sqlite3' - @conn=@db.sqlite.conn_sqlite3 - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('sqlite3 not available') - ensure - Dir.chdir(@opt.f_pth[:pth]) - end - end - end - def connect - begin - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "DBI (#{@sql_type}) #{@opt.selections.str}", - @opt.fns - ).dbi_title unless @opt.act[:quiet][:set]==:on - @db.sqlite_discrete.conn_sqlite3 - rescue - SiSU_Errors::Rescued.new($!,$@,@cf,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def populate - end - def sql_maintenance_file - file=if @opt.act[:maintenance][:set]==:on - if @opt.fns and not @opt.fns.empty? - @env=SiSU_Env::InfoEnv.new(@opt.fns) if @opt.fns - if @sql_type ==:sqlite - puts "\n#{@env.processing_path.sqlite}/#{@opt.fns}.sql" - end - @db=SiSU_Env::InfoDb.new - @job="sqlite3 #{@db.sqlite.db} < #{@env.processing_path.sqlite}/#{@opt.fns}.sql" - if @sql_type ==:sqlite - File.new("#{@env.processing_path.sqlite}/#{@opt.fns}.sql",'w+') - else - File.new("#{@env.processing_path.postgresql}/#{@opt.fns}.sql",'w+') - end - elsif @opt.fns \ - and @opt.fns.inspect =~/create/ - nil #sort variations later - else nil - end - else nil - end - file - end - end -end -__END__ diff --git a/lib/sisu/current/digests.rb b/lib/sisu/current/digests.rb deleted file mode 100644 index 8a3a2d08..00000000 --- a/lib/sisu/current/digests.rb +++ /dev/null @@ -1,306 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document digests (md5|sha256) and structure processing - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_DigestView - require_relative 'se_hub_particulars' # se_hub_particulars.rb - require_relative 'prog_text_translation' # prog_text_translation.rb - require_relative 'shared_markup_alt.rb' # shared_markup_alt.rb - class Source - @@dg=nil - def initialize(opt) - @opt=opt - @fnb=@opt.fnb - @@endnotes_para=[] - @@dg=nil - @dg=@@dg ||=SiSU_Env::InfoEnv.new.digest(opt).type - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - end - def read - begin - @env,@md,@ao_array=@particulars.env,@particulars.md,@particulars.ao_array - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.text_editor} file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "Document #{@dg} Digests", - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "Document #{@dg} Digests", - tool - ).green_title_hi - if @opt.act[:verbose_plus][:set]==:on \ - or @opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "file://#{@md.file.output_path.hash_digest.dir}/#{@md.file.base_filename.hash_digest}" - ).flow - end - end - if SiSU_Env::SystemCall.new.openssl - SiSU_DigestView::Source::Scroll.new(@particulars).songsheet - else - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error('*EXITED* hash digests will not run without openssl') - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - private - class Scroll 0 - end - ao_structure_summary("objects (ocn) = #{ocn}\n") - ao_structure_summary("endnotes = #{endnotes}\n") - ao_structure_summary(" [*] number of headers (@) and of each heading level (:A to :D and 1 to 3)\n") - end - def supplementary - if defined? @md.sc_number \ - and @md.sc_number - rcinfo("------------\n") - rcinfo("source control information\n") - rcinfo(" (the following information while not important for document content certification\n may help the publisher in locating the version referred to)\n") - rcinfo(" rcs version number: #{@md.sc_number}\n") - if defined? @md.sc_date \ - and @md.sc_date - rcinfo(" rcs date: #{@md.sc_date}\n") - end - if defined? @md.sc_time \ - and @md.sc_time - rcinfo(" rcs time: #{@md.sc_time}\n") - end - end - rcinfo("------------\n") - rcinfo("Note: the time generated related fields (text and digests) will vary between otherwise identical document outputs\n") - end - end - end -end -__END__ diff --git a/lib/sisu/current/dp.rb b/lib/sisu/current/dp.rb deleted file mode 100644 index 85264771..00000000 --- a/lib/sisu/current/dp.rb +++ /dev/null @@ -1,1606 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document parameters extracted from input files for program use - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Param - begin - require 'uri' - require 'pstore' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('uri or pstore NOT FOUND (LoadError)') - end - require_relative 'se' # se.rb - include SiSU_Env - require_relative 'dp_make' # dp_make.rb - require_relative 'dp_identify_markup' # dp_identify_markup.rb - @@date=SiSU_Env::InfoDate.new - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - req: {}, - } - @@trigger=nil - @@lv,@@flag={},{} - @@tex_backslash="\\\\" - class Parameters - @@publisher='SiSU scribe' - @@md=@@fns=@@pth=nil - def initialize(opt) - @opt=opt - @cX||=SiSU_Screen::Ansi.new(@opt.act[:color_state][:set]) - @fns=if @opt.act[:psql][:set] == [:on] #revisit CHECK - opt.fns - else opt.fns.gsub(/\.ssm$/,'.ssm.sst') - end - SiSU_Param::Instantiate.new.param_instantiate - @env=SiSU_Env::InfoEnv.new(@fns) - @pstorefile="#{@env.processing_path.ao}/#{@fns}.pstore" - end - def get - if @opt.f_pth \ - and @opt.f_pth[:pth] != Dir.pwd #BUG check - # you may need to change Dir.pwd to @opt.f_pth[:pth] where the latter - # has a path value that is different, however, f_pth is not always set! - Dir.chdir(@opt.f_pth[:pth]) - end - if @@fns !=@fns \ - or @@pth !=Dir.pwd #@opt.f_pth[:pth] - @@fns,@@pth=@fns,Dir.pwd #@opt.f_pth[:pth] - @@md=nil - end - if @@md.nil? \ - or @opt.act[:maintenance][:set]==:on #not particularly helpful, as current cycle is through output types, with files changing, only helpful if deal with a file all output types before going to next file - if File.exist?(@pstorefile) - param_msg='Parameters from pstore' - store=PStore.new(@pstorefile) - store.transaction do - @md=store['md'] - end - @md - else - param_msg='Parameters extracted' - fns_array=@env.read_source_file(@opt.fns) - @md=SiSU_Param::Parameters::Instructions.new(fns_array,@opt).extract - @md - end - if defined? @md.title.main # on removal check problems with -U - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - param_msg, - @md.title.main - ).txt_grey - end - end - @@md=@md - else @@md - end - begin - @@md.opt=@opt - @@md - rescue - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - mark('has an existing option been selected?') - exit - end - end - class MdDefault - def rights(author,date) - @author,@date=author,date - def assignment(author) - 'copyright not explicitly stated, ' \ - + 'program "assigning" copyright to author: ' \ - + author - end - def all - s=nil - if @author - #puts assignment(@author) - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def copyright_and_license - s=nil - if @author - #puts assignment(@author) - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - def copyright - def all - s=nil - if @author - s ||=((@date =~/((?:1[4-9]|2[01])\d{2})/ ) \ - ? ("Copyright (C) #{$1} #{@author}") - : ('Copyright (C)' + @author)) #matches years 1400 through 21\d\d - end - s - end - def text - all - end - self - end - self - end - end - class MdMake < SiSU_Param_Make::MdMake - end - class Md - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%\s/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - b=b.gsub(/\s*\s*/,' \\\\\\ ') - b=if b =~/\n/m - (b =~/;\n/m) \ - ? (b.split(/;\s*\n\s*/).join(';')) - : (b.split(/\s*\n\s*/).join(' ')) - else - b - end - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def title - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def main - s=@h['main'] - l,n=Db[:col_title_part],'title.main' - validate_length(s,l,n) - end - def sub - s=@h['subtitle'] - l,n=Db[:col_title_part],'title.subtitle' - validate_length(s,l,n) - end - def edition - s=@h['edition'] - l,n=Db[:col_title_edition],'title.edition' - validate_length(s,l,n) - end - def note - s=@h['note'] - l,n=Db[:col_info_note],'title.note' - validate_length(s,l,n) - end - def short - s=@h['short'] \ - ? @h['short'] - : @h['main'] - l,n=Db[:col_title_part],'title.short' - validate_length(s,l,n) - end - def full - s=@h['subtitle'] \ - ? (@h['main'] + ' - ' + @h['subtitle']) - : @h['main'] - l,n=Db[:col_title],'title.full' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'title.language' - validate_length(s,l,n) - end - def language_char # look into, this must be set, from 1 directory stub (.fi), 2 filename (~fi), [3 (not used) document header (@title:\n :language_char: fi)] - s=@h['language_char'] - l,n=Db[:col_language_char],'title.language_char' - validate_length(s,l,n) - end - self - end - def creator #there are sub categories that need to be catered for and sometimes more than one author etc.; implement array.to_s.length validation test later, current test on string approximate as string is not used - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def author - @h['author']=(@h['author'] \ - ? @h['author'] - : @h['main']) - names=name_format(@h['author']) - s=names[:name_str] - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - end - def author_detail - s=@h['author'] \ - ? @h['author'] - : @h['main'] - names=name_format(s) - names[:name_a_h] - end - def editor - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.editor' - validate_length(s,l,n) - else nil - end - end - def editor_detail - names=@h['editor'] \ - ? name_format(@h['editor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def contributor - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.author' - validate_length(s,l,n) - else nil - end - end - def contributor_detail - names=@h['contributor'] \ - ? name_format(@h['contributor']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def illustrator - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.illustrator' - validate_length(s,l,n) - else nil - end - end - def illustrator_detail - names=@h['illustrator'] \ - ? name_format(@h['illustrator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def photographer - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.photographer' - validate_length(s,l,n) - else nil - end - end - def photographer_detail - names=@h['photographer'] \ - ? name_format(@h['photographer']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def translator - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.translator' - validate_length(s,l,n) - else nil - end - end - def translator_detail - names=@h['translator'] \ - ? name_format(@h['translator']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def audio - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.audio' - validate_length(s,l,n) - else nil - end - end - def audio_detail - names=@h['audio'] \ - ? name_format(@h['audio']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def digitized_by - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.digitized_by' - validate_length(s,l,n) - else nil - end - end - def digitized_by_detail - names=@h['digitized_by'] \ - ? name_format(@h['digitized_by']) - : nil - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - def prepared_by - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - s=(names.is_a?(Hash)) \ - ? names[:name_str] - : nil - s=if s - l,n=Db[:col_name],'creator.prepared_by' - validate_length(s,l,n) - else nil - end - end - def prepared_by_detail - names=@h['prepared_by'] \ - ? name_format(@h['prepared_by']) - : nil - names=name_format(@h['prepared_by']) - (names.is_a?(Hash)) \ - ? names[:name_a_h] - : nil - end - self - end - def rights - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def copyright - def text #you may wish to expand to take from all - s=if @h['copyright'] then @h['copyright'] - elsif @h['text'] then @h['text'] - elsif @h['main'] then @h['main'] - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Copyright missing; provide @rights: :copyright:' - ).warn if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - '' - end - l,n=Db[:col_info_note],'rights.copyright.text' - validate_length(s,l,n) - end - def translation - s=@h['translation'] \ - ? @h['translation'] - : nil - l,n=Db[:col_info_note],'rights.copyright.translation' - validate_length(s,l,n) - end - def illustrations - s=@h['illustrations'] \ - ? @h['illustrations'] - : nil - l,n=Db[:col_info_note],'rights.copyright.illustrations' - validate_length(s,l,n) - end - def photographs - s=@h['photographs'] \ - ? @h['photographs'] - : nil - l,n=Db[:col_info_note],'rights.copyright.photographs' - validate_length(s,l,n) - end - def digitization - s=@h['digitization'] \ - ? @h['digitization'] - : nil - l,n=Db[:col_info_note],'rights.copyright.digitization' - validate_length(s,l,n) - end - def audio - s=@h['audio'] \ - ? @h['audio'] - : nil - l,n=Db[:col_info_note],'rights.copyright.audio' - validate_length(s,l,n) - end - self - end - def license - s=@h['license'] \ - ? @h['license'] - : nil - l,n=Db[:col_info_note],'rights.license' - validate_length(s,l,n) - end - def sep(str) - ' \\\\ ' - end - def copyright_and_license - s=if @h['copyright_and_license'] then @h['copyright_and_license'] - else - s='' - if defined? copyright.text \ - and copyright.text \ - and not copyright.text.empty? - v=sep(copyright.text) - s +=copyright.text + v - end - if defined? copyright.license \ - and copyright.license \ - and not copyright.license.empty? - s +=copyright.license - end - if s.empty? - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - else - l,n=Db[:col_info_note],'rights.all' - validate_length(s,l,n) - end - s=s.gsub(/ [\\]+\s+$/,'') - end - s - end - def all - s=if @h['all'] then @h['all'] - else - s='' - if defined? copyright.text \ - and copyright.text \ - and not copyright.text.empty? - v=sep(copyright.text) - s +='Copyright: ' + copyright.text + v - end - if defined? copyright.translation \ - and copyright.translation \ - and not copyright.translation.empty? - v=sep(copyright.translation) - s +='translation: ' + copyright.translation + v - end - if defined? copyright.illustrations \ - and copyright.illustrations \ - and not copyright.illustrations.empty? - v=sep(copyright.illustrations) - s +='illustrations: ' + copyright.illustrations + v - end - if defined? copyright.photographs \ - and copyright.photographs \ - and not copyright.photographs.empty? - v=sep(copyright.photographs) - s +='photographs: ' + copyright.photographs + v - end - if defined? copyright.digitization \ - and copyright.digitization \ - and not copyright.digitization.empty? - v=sep(copyright.digitization) - s +='digitization: ' + copyright.digitization + v - end - if defined? copyright.audio \ - and copyright.audio \ - and not copyright.audio.empty? - v=sep(copyright.audio) - s +='audio: ' + copyright.audio + v - end - if defined? copyright.license \ - and copyright.license \ - and not copyright.license.empty? - s +='License: ' + copyright.license - end - if s.empty? - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING Document Rights information missing; provide @rights: :copyright:' - ).warn if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - else - l,n=Db[:col_info_note],'rights.all' - validate_length(s,l,n) - end - s=s.gsub(/ [\\]+\s+$/,'') - end - s - end - self - end - def identifier - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def oclc - s=@h['oclc'] - l,n=Db[:col_library],'identifier.oclc' - validate_length(s,l,n) - end - def isbn - s=@h['isbn'] - l,n=Db[:col_small],'identifier.isbn' - validate_length(s,l,n) - end - def pg - s=@h['pg'] - l,n=Db[:col_small],'identifier.pg' - validate_length(s,l,n) - end - self - end - def classify - a=@s.split(/(\n%\s.+?$|[ ]*)(?:\n[ ]*(?=:)|\Z)/m) - @h=build_hash(a) - def topic_register - s=@h['topic_register'] - l,n=Db[:col_info_note],'classify.topic_register' - validate_length(s,l,n) - end - def subject - s=@h['subject'] - l,n=Db[:col_txt_long],'classify.subject' - validate_length(s,l,n) - end - def keywords - s=@h['keywords'] - l,n=Db[:col_txt_long],'classify.keywords' - validate_length(s,l,n) - end - def loc - s=@h['loc'] - l,n=Db[:col_library],'classify.loc' - validate_length(s,l,n) - end - def dewey - s=@h['dewey'] - l,n=Db[:col_library],'classify.dewey' - validate_length(s,l,n) - end - self - end - def publisher - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - s=@h['main'] - l,n=Db[:col_name],'publisher' - validate_length(s,l,n) - end - def date - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def added_to_site - s=@h['added_to_site'] - l,n=Db[:col_date_text],'date.added_to_site' - validate_length(s,l,n) - end - def available - s=@h['available'] - l,n=Db[:col_date_text],'date.available' - validate_length(s,l,n) - end - def created - s=@h['created'] - l,n=Db[:col_date_text],'date.created' - validate_length(s,l,n) - end - def issued - s=@h['issued'] - l,n=Db[:col_date_text],'date.issued' - validate_length(s,l,n) - end - def modified - s=@h['modified'] - l,n=Db[:col_date_text],'date.modified' - validate_length(s,l,n) - end - def published - s=@h['published']=(@h['published'] ? @h['published'] : @h['main']) - l,n=Db[:col_date_text],'date.published' - validate_length(s,l,n) - end - def valid - s=@h['valid'] - l,n=Db[:col_date_text],'date.valid' - validate_length(s,l,n) - end - self - end - #def language # as things stand this should really be populated from title.language and original.language, resolve - # a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - # @h=build_hash(a) - # def document - # s=@h['document']=(@h['document'] ? @h['document'] : @h['main']) - # l,n=Db[:col_language],'language.document' - # validate_length(s,l,n) - # end - # def document_char - # s=@h['document_char']=(@h['document_char'] ? @h['document_char'] : nil) - # l,n=Db[:col_language_char],'language.document_char' - # validate_length(s,l,n) - # end - # def original - # s=@h['original'] - # l,n=Db[:col_language],'language.original' - # validate_length(s,l,n) - # end - # def original_char - # s=@h['original_char'] - # l,n=Db[:col_language_char],'language.original_char' - # validate_length(s,l,n) - # end - # self - #end - def current_publisher - @s - end - def original - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def publisher - s=@h['publisher'] - l,n=Db[:col_name],'original.publisher' - validate_length(s,l,n) - end - def language - s=@h['language'] - l,n=Db[:col_language],'original.language' - validate_length(s,l,n) - end - def language_char - s=@h['language_char'] - l,n=Db[:col_language_char],'original.language_char' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_name],'original.source' - validate_length(s,l,n) - end - def institution - s=@h['institution'] - l,n=Db[:col_name],'original.institution' - validate_length(s,l,n) - end - def nationality - s=@h['nationality'] - l,n=Db[:col_language],'original.nationality' - validate_length(s,l,n) - end - self - end - def notes - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def description - s=@h['description'] - l,n=Db[:col_info_note],'notes.description' - validate_length(s,l,n) - end - def abstract - s=@h['abstract'] - l,n=Db[:col_info_note],'notes.abstract' - validate_length(s,l,n) - end - def comment - s=@h['comment'] - l,n=Db[:col_info_note],'notes.comment' - validate_length(s,l,n) - end - def coverage - s=@h['coverage'] - l,n=Db[:col_info_note],'notes.coverage' - validate_length(s,l,n) - end - def relation - s=@h['relation'] - l,n=Db[:col_info_note],'notes.relation' - validate_length(s,l,n) - end - def source - s=@h['source'] - l,n=Db[:col_txt_long],'notes.source' - validate_length(s,l,n) - end - def history - s=@h['history'] - l,n=Db[:col_txt_long],'notes.history' - validate_length(s,l,n) - end - def type - s=@h['type'] - l,n=Db[:col_txt_long],'notes.relation' - validate_length(s,l,n) - end - def format - s=@h['format'] - l,n=Db[:col_txt_short],'notes.format' - validate_length(s,l,n) - end - def prefix - @h['prefix'] - end - self - end - end - class Instructions - @doc={ lv: [] } - @doc[:fns],@doc[:fnb],@doc[:scr_suffix]='','','' - @@publisher='SiSU scribe' - attr_accessor :make,:env,:path,:file,:fn,:fns,:fno,:fnb,:fnn,:fnt,:fnl,:flv,:fnz,:fnstex,:ocn,:sfx_src,:pdf,:file_type,:dir_out,:dir_tex,:dir_lout,:txt_path,:sisu,:project_details,:ruby_version,:title,:subtitle,:full_title,:html_title,:subtitle_tex,:creator,:classify,:author_home,:author,:author_title,:author_nationality,:authors,:authorship,:translator,:illustrator,:prepared_by,:digitized_by,:subject,:description,:publisher,:current_publisher,:contributor,:date,:date_created,:date_issued,:date_available,:date_valid,:date_modified,:date_translated,:date_added_to_site,:date_scheme,:date_created_scheme,:date_issued_scheme,:date_available_scheme,:date_valid_scheme,:date_modified_scheme,:type,:format,:identifier,:source,:language,:language_original,:relation,:coverage,:rights,:keywords,:comments,:abstract,:cls_loc,:cls_dewey,:cls_pg,:cls_isbn,:papersize,:papersize_array,:toc,:lv0,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:lvs,:pagenew,:pagebreak,:pageline,:num_top,:bold_match_list,:italics_match_list,:substitution_match_list,:emphasis_set_to,:toc_lev_limit,:flag_biblio,:flag_auto_biblio,:flag_endnotes,:flag_auto_endnotes,:flag_separate_endnotes,:flag_separate_endnotes_make,:markup,:markup_instruction,:flag_tables,:vocabulary,:doc_css,:yaml,:lnk,:links,:prefix_a,:prefix_b,:suffix,:information,:contact,:icon,:image,:ad_url,:ad_png,:ad_alt,:ad_began,:flag_promo,:promo,:ad_home,:stmp,:stmpd,:sc_filename,:sc_number,:sc_date,:sc_time,:sc_info,:yamladdr,:locale,:wc_lines,:wc_words,:wc_bytes,:file_encoding,:filesize,:user,:home,:hostname,:pwd,:firstseg,:programs,:author_copymark,:i18n,:lang,:lang_code_insert,:en,:notes,:dgst,:generated,:tags,:tag_array,:concord_make,:seg_names,:seg_autoname_safe,:set_header_title,:set_heading_top,:set_heading_seg,:heading_seg_first,:heading_seg_first_flag,:base_program,:ec,:opt,:sem_tag,:book_idx,:topic_register,:topic_register_array,:original,:writing_focus,:audio,:daisy,:home_button_image,:home_button_links,:footer_links,:cover_image,:man_section - def initialize(fns_array,opt) - @env=@path,@file=@fn=@fns=@fno=@fnb=@fnn=@fnt=@fnl=@flv=@fnz=@fnstex=@ocn=@sfx_src=@pdf=@file_type=@dir_out=@dir_tex=@dir_lout=@txt_path=@make=@flag_biblio=@flag_auto_biblio=@flag_endnotes=@flag_auto_endnotes=@flag_separate_endnotes=@flag_separate_endnotes_make=@sisu=@project_details=@ruby_version=@title=@subtitle=@full_title=@html_title=@subtitle_tex=@creator=@classify=@author_home=@author=@author_title=@author_nationality=@translator=@illustrator=@prepared_by=@digitized_by=@subject=@description=@publisher=@current_publisher=@contributor=@date=@date_created=@date_issued=@date_available=@date_valid=@date_modified=@date_translated=@date_added_to_site=@date_scheme=@date_created_scheme=@date_issued_scheme=@date_available_scheme=@date_valid_scheme=@date_modified_scheme=@type=@format=@identifier=@source=@language=@language_original=@relation=@coverage=@rights=@keywords=@comments=@abstract=@cls_loc=@cls_dewey=@cls_pg=@cls_isbn=@papersize=@toc=@lv0=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@pagenew=@pagebreak=@pageline=@num_top=@bold_match_list=@italics_match_list=@substitution_match_list=@emphasis_set_to=@toc_lev_limit=@flag_tables=@vocabulary=@doc_css=@yaml=@lnk=@links=@prefix_a=@prefix_b=@suffix=@information=@contact=@icon=@ad_url=@ad_png=@ad_alt=@ad_began=@promo=@ad_home=@stmp=@stmpd=@sc_filename=@sc_number=@sc_date=@sc_time=@sc_info=@yamladdr=@locale=@wc_lines=@wc_words=@wc_bytes=@file_encoding=@filesize=@firstseg=@programs=@author_copymark=@i18n=@lang=@lang_code_insert=@en=@notes=@dgst=@generated=@heading_seg_first=@base_program=@topic_register=@original=@writing_focus=@audio=@home_button_image=@home_button_links=@cover_image=@man_section=nil - @data, @path, @fns, @fno, @opt= - fns_array,opt.pth,opt.fns,opt.fno,opt #@data used as data - @flag_tables,@set_header_title,@set_heading_top,@set_heading_seg,@heading_seg_first_flag,@flag_promo,@book_idx= - false, false, false, false, false, false, false - @seg_autoname_safe=true - @daisy,@sem_tag=false,false - @authorship,@markup_instruction,@image='','','','' #check which other values should be set to empty rather than nil - @markup=@markup_instruction #use @markup_instruction - @doc,@fn,@make_italic,@tag_hash,@ec={},{},{},{},{},{} - @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} - @authors,@topic_register_array,@papersize_array=[],[],[] - @lvs=[nil,0,0,0,0,0,0] - @emphasis_set_to='bold' - @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m - @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ - @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg - Dir.chdir(@opt.f_pth[:pth]) - begin - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - @header_make_links_append=:no - common_makes=(defined? @opt.make_instructions_pod) \ - && @opt.make_instructions_pod !=nil \ - && @opt.make_instructions_pod[:makeset]==true \ - ? @opt.make_instructions_pod - : @opt.make_instructions - if common_makes[:makeset] - @pagenew=common_makes[:pagenew] - @pagebreak=common_makes[:pagebreak] - @pageline=common_makes[:pageline] - @toc=common_makes[:toc] - @lv0=common_makes[:lv0] - @lv1=common_makes[:lv1] - @lv2=common_makes[:lv2] - @lv3=common_makes[:lv3] - @lv4=common_makes[:lv4] - @lv5=common_makes[:lv5] - @lv6=common_makes[:lv6] - @num_top=common_makes[:num_top] - @i18n=common_makes[:i18n] - @man_section=common_makes[:man_section] - @emphasis_set_to=common_makes[:emphasis_set_to] - @bold_match_list=common_makes[:bold_match_list] - @italics_match_list=common_makes[:italics_match_list] - @substitution_match_list=common_makes[:substitution_match_list] - @footer_links=common_makes[:footer_links] - @home_button_links=common_makes[:home_button_links] - @home_button_image=common_makes[:home_button_image] - @cover_image=common_makes[:cover_image] - @lnk=@links=common_makes[:links] - @header_make_links_append=common_makes[:links_append] - end - end - #protected - def extract - begin - @user,@home,@hostname,@pwd=ENV['USER'],ENV['HOME'],ENV['HOSTNAME'],ENV['PWD'] - @programs,@wc,@language,@language_original={},{},{},{} - @en={ sum: 0, mark: 0, note: 0, mismatch: 0 } - @prog=SiSU_Env::InfoSettings.new - @sys=SiSU_Env::SystemCall.new - @env=SiSU_Env::InfoEnv.new(@fns) #watch - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - puts 'system locale: ' + @sys.locale - end - if @prog.wc \ - and @sys.wc - wc=%x{wc #{fns}} - wca=wc.scan(/\d+/) - @wc_lines,@wc_words,@wc_bytes=wca[0].to_i,wca[1].to_i,wca[2].to_i - else - fns_a=@data.dup - tmp=fns_a.join - fns_a=tmp.scan(/\S+/) - @wc_words=fns_a.length - fns_a=tmp=nil - end - @concord_make=(@wc_words > @env.concord_max) ? false : true - @locale=@sys.locale - @file_encoding=@sys.file_encoding(fns,@opt.act) - # programs set here for things that affect output appearance only - @programs[:pdf]=SiSU_Env::SystemCall.new.program_found?('pdflatex') - if @opt.act[:psql][:set] == [:ok] - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm|ssi)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - else - m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss - @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3] - @flv=@env.document_language_versions_found[:f] - @fnz=(@fns =~/\.(?:ssm\.sst|ssm)$/) ? (@fnn + '.ssm.txz') : (@fnn + '.sst.txz') - end - @papersize=@env.papersize #'A4' #default size #get first from SiSU_Env:: # @env is probably no longer most appropriate name! as default info is more general - @sfx_src=@fns[m,2] - if @fns =~ /(?:-|ssm\.)?sst$/ \ - and not @opt.act[:psql][:set] == [:ok] - @env_out_root=@env.path.output - @dir_out="#{@env.path.output}/#{@fnb}" - @dir_tex=@env.processing_path.tex - @dir_lout=@env.processing_path.lout - @@publisher='SiSU http://www.jus.uio.no/sisu' - end - @txt_path=@txt_path ||= @env.path.output - @stmp=%{#{@fns}}[/^(.+?)\..*/m,1] - @fnstex=@fns.gsub(/_/,'\_\-').gsub(/\./,'.\-') - @flag_endnotes,@flag_auto_endnotes,@flag_separate_endnotes=false,false,false - @flag_separate_endnotes_make=true - @flag_biblio,@flag_auto_biblio=false,false - ver=SiSU_Env::InfoVersion.instance - @project_details=ver.get_version - @ruby_version=ver.rbversion - @generated=Time.now - fns_array=@data.dup - skip unless fns_array # consider - @code_flag=false - flag_code_curly=:not_code_curly - flag_code_tics=:not_code_tics - fns_array.each do |para| #% scan document - if para !~/^%+\s/ \ - and para =~/|

|
|
)\s*/,' '). - gsub(/~\{.+?\}~/,'') - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Document Parameters', - %{#{title}#{creator}} - ).txt_grey if @opt.act[:verbose][:set]==:on - end - unless @code_flag - if para =~/^1~biblio(?:graphy)?/ - @flag_auto_biblio,@flag_biblio=false,true - #@flag_biblio=true - elsif @flag_biblio ==true \ - and @flag_auto_biblio ==false \ - and para =~/^(?:au|author):/m - @flag_auto_biblio =true - end - end - if not @book_idx \ - and para =~/^=\{(.+?)\}[\s`]*\Z/m - @book_idx=true - end - unless @code_flag - case para - when /~\{\s+.+?\}~/m #% processing - en=para.scan(/~\{.+?\}~/m) - en.each { |e| @en[:sum] +=1 } - when /~\^(?:\s|$)/m #% processing - mk=para.scan(/~\^(?:\s|$)/) - mk.each { |e| @en[:mark] +=1 } - when /^\^~\s+\S/ then @en[:note] +=1 #% processing - end - end - if para =~/~\{|\^~ |~\^|\{.+?\[[1-6]\]\}\S+?\.ss[tm]/m - @flag_auto_endnotes,@flag_endnotes=true,true - end - if para =~/^(?:table\{|\{table)/i - @flag_tables=true - end - end - if para =~/^:?A~/ - @set_heading_top=true - end - if para =~/^1~/ - m=nil - if para =~/^1~(\S+)\s+(.+)$/ - m,t=$1,$2 - elsif para =~/^1~\s+(.+)$/ - t=$1 - end - unless @heading_seg_first_flag # extract first segment name - @heading_seg_first=t - @heading_seg_first_flag=true - end - if m # list all segment names - @seg_names << m - @set_heading_seg=true - if m=~/^\d{1,3}/ \ - and m !~/^0/ - @seg_autoname_safe=false - end - end - end - para=para.gsub(/<:=(\S+?)>/,'{ c_\1.png 14x14 }image') # embedded symbol (image) - if para !~/^%+\s/ \ - and para =~@rgx_image - @ec[:image] << para.scan(@rgx_image).uniq - end - @ec[:audio] << para.scan(@rgx_audio).uniq if para =~@rgx_audio #embedded content - @ec[:multimedia] << para.scan(@rgx_mm).uniq if para =~@rgx_mm #embedded content - unless @sem_tag - @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later - end - end #% here endeth the document loop - unless @make - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '@make:', - 'header absent' - ).warn - end - @make=SiSU_Param::Parameters::MdMake.new('@make: ',@opt,@env).make - end - if @cover_image \ - and @cover_image.is_a?(Hash) \ - and (@cover_image[:cover] =~@rgx_image \ - or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) - @ec[:image] << @cover_image[:cover] - end - if @home_button_image \ - and @home_button_image.is_a?(Hash) \ - and (@home_button_image =~@rgx_image \ - or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) - @ec[:image] << @home_button_image - end - if @ec[:image].length > 0 - @ec[:image]=@ec[:image].flatten.uniq - @ec[:image].delete_if {|x| x =~/https?:\/\// } - @ec[:image]=@ec[:image].sort - end - @ec[:audio]=@ec[:audio].uniq.flatten.sort - @ec[:multimedia]=@ec[:multimedia].uniq.flatten.sort - unless @rights - if defined? @creator.author \ - and @creator.author.is_a?(String) \ - and defined? @date.published \ - and @date.published.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights(@creator.author,@date.published) - elsif defined? @creator.author \ - and @creator.author.is_a?(String) - @rights=SiSU_Param::Parameters::MdDefault.new.rights("[#{@creator.author}]",'') - end - end - if defined? @classify.topic_register \ - and @classify.topic_register.is_a?(String) \ - and @classify.topic_register.length >3 - topic_register=@classify.topic_register - u=topic_register.scan(/[^;]+/m).sort - v=[] - u.each do |l| - v << l.scan(/[^:]+/m) - end - v.each do |s| - s[-1]=s[-1].scan(/[^|]+/m) if s[-1] =~/[|]/m - @topic_register_array << s - end - @topic_register_array - end - if @i18n - @i18n=@i18n.uniq - @i18n << 'en' unless @i18n.find_index("en") - else - @i18n=[ 'en' ] - end - translated=[] - translate_list=[@pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit] - translate_list.each do |t| - translate=t.to_s if t - translated << if translate - translate.gsub!(/3/,'6') - translate.gsub!(/2/,'5') - translate.gsub!(/1/,'4') - translate.gsub!(/:?C/,'3') - translate.gsub!(/:?B/,'2') - translate.gsub!(/:?A/,'1') - # looks like an ok substituion for the above but is not, causes problems, check why - #translate=translate.gsub(/3/,'6'). - # gsub(/2/,'5'). - # gsub(/1/,'4'). - # gsub(/:?C/,'3'). - # gsub(/:?B/,'2'). - # gsub(/:?A/,'1') - translate=(translate =~/^\d+$/) \ - ? translate.to_i - : translate - else nil - end - end - @pagenew,@pagebreak,@pageline,@num_top,@toc_lev_limit=translated - @markup=@markup.gsub(/page_new\s*=\s*([\dA-C])/,"page_new=#{@pagenew}"). - gsub(/page_break\s*=\s*([\dA-C])/,"page_break=#{@pagebreak}"). - gsub(/page_line\s*=\s*([\dA-C])/,"page_line=#{@pageline}"). - gsub(/num_top\s*=\s*([\dA-C])/,"num_top=#{@num_top}"). - gsub(/toc_lev_limit\s*=\s*([\dA-C])/,"toc_lev_limit=#{@toc_lev_limit}") - papersize_array_rc=@papersize.downcase.scan(/(?:a4|letter|legal|book|a5|b5)/) - papersize_array_opt=[ - ((@opt.act[:pdf_a4][:set]==:on) ? 'a4' : ''), - ((@opt.act[:pdf_a5][:set]==:on) ? 'a5' : ''), - ((@opt.act[:pdf_b5][:set]==:on) ? 'b5' : ''), - ((@opt.act[:pdf_letter][:set]==:on) ? 'letter' : ''), - ((@opt.act[:pdf_legal][:set]==:on) ? 'legal' : ''), - ] - [""] - @papersize_array=(papersize_array_opt.length > 0) \ - ? papersize_array_opt - : papersize_array_rc - fn=@opt.fno #decide what to do a filesize on .ssm tells very little about actual document size - @filesize=(File.size(fn)).to_s - if @sys.openssl !=false \ - and FileTest.file?(@env.source_file_with_path) - @dgst=[] - case @env.digest(@opt).type - when :sha512 - dgst=@sys.sha512(@env.source_file_with_path) - @dgst=dgst[1].length==128 ? dgst : nil - puts 'check document (sha512) digest' if not @dgst - when :sha256 - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - when :md5 - dgst=@sys.md5(@env.source_file_with_path) - @dgst=dgst[1].length==32 ? dgst : nil - puts 'check document (md5) digest' if not @dgst - else - dgst=@sys.sha256(@env.source_file_with_path) - @dgst=dgst[1].length==64 ? dgst : nil - puts 'check document (sha256) digest' if not @dgst - end - elsif not FileTest.file?(@env.source_file_with_path) - #puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) - end - @publisher ||= "#{@@publisher} (this copy)" - fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language - unless @language[:code] \ - and @language[:name] - lang=@env.i18n.language #default language settings for directory by name, or in sysrc.yml - @language[:code] ||= lang.code - @language[:name] ||= lang.title - end - unless fn_set_lang[:d]==true #decide, naming convention overrides other settings, within document, etc. - @language[:code]=fn_set_lang[:c] - @language[:name]=fn_set_lang[:n] - end - @fnl=@env.i18n.lang_filename(fn_set_lang[:c]) - @lang=@lang.uniq - @fn=SiSU_Env::EnvCall.new(@fns).lang(fn_set_lang[:c]) - if @en[:note] > 0 \ - and @en[:sum] > 0 - if @en[:sum] > 0 - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* both endnote styles used', - "~{ #{@en[:sum]} }~ and ^~ #{@en[:mark]}" - ).warn unless @opt.act[:quiet][:set]==:on - end - end - if @en[:mark] != @en[:note] \ - and @en[:note] > 0 - @en[:mismatch]=@en[:note] - @en[:mark] - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - '*WARN* endnote number mismatch', - "endnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ - + "(difference = #{@en[:mismatch]})" - ).warn unless @opt.act[:quiet][:set]==:on - footnote_conversion_errors=File.new("#{Dir.pwd}/footnote_conversion_errors.txt",'a') - footnote_conversion_errors << - "#{@fns}:\n\tendnotes: #{@en[:note]} != endnote reference marks: #{@en[:mark]} " \ - + "(difference = #{@en[:mismatch]})\n" - end - if not @title \ - or not defined? @title.main \ - or @title.main !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@title=Md.new('Text Insert',@opt,@env).title - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Title missing', - 'please provide @title:' - ).warn if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - end - end - if @author !~/[\S]/ - if @fns =~/\.ssm$/ \ - and @opt.inspect =~/P/ - #@creator=SiSU_Param::Md.new('Text Insert',@opt,@env).creator - else - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'WARNING: Document Author missing', - 'please provide @creator: :author:' - ).warn if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - end - end - @struct={} - doc_struct=Hash.new(0) - if @lv1.nil? - fns_array.each do |para| - if para =~/^(Part|Chapter|Section|Article)\b/i - case para - when /^(Part|PART)\b/ - @struct[:part]=doc_struct[:part] - doc_struct[:part]=doc_struct[:part] + 1 - when /^(Chapter|CHAPTER)\b/ - @struct[:chapter]=doc_struct[:chapter] - doc_struct[:chapter]=doc_struct[:chapter] + 1 - when /^(Section|SECTION)\b/ - @struct[:section]=doc_struct[:section] - doc_struct[:section]=doc_struct[:section] + 1 - when /^(Article|ARTICLE)\b/ - @struct[:article]=doc_struct[:article] - doc_struct[:article]=doc_struct[:article] + 1 - when /^(Clause|CLAUSE)\b/ - @struct[:clause]=doc_struct[:clause] - doc_struct[:clause]=doc_struct[:clause] + 1 - when /^\d\..*[^\.]$/ - @struct[:number]=doc_struct[:number] - doc_struct[:number]=doc_struct[:number] + 1 - end - end - end - if doc_struct[:article] > 2 #%~level 4 - @lv4=/^(?:Article|ARTICLE)\b/ - elsif doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] < 3 - @lv4=/^(?:Chapter|CHAPTER)\b/ - elsif doc_struct[:clause] > 2 - @lv4=/^(?:Clause|CLAUSE)\b/ - elsif doc_struct[:number] > 2 - @lv4="^\d\..*[^\.]$" - end - if doc_struct[:section] > 2 #%~level 3 - @lv3=/^(?:Section|SECTION)\b/ - end - if doc_struct[:chapter] > 2 \ - and doc_struct[:article] \ - and doc_struct[:article] > 2 - @lv2=/^(?:Chapter|CHAPTER)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].nil? - @lv2=/^(?:Part|PART)\b/ - end - if doc_struct[:part] > 2 \ - and @lv[2].inspect !~/Part/ \ - and @lv[1].nil? - @lv1=/^(Part|PART)\b/ - end - end - @lnk=@lnk.compact if @lnk - @lv0 ||=/^0~/ - @lv1 ||=/^1~/ - @lv2 ||=/^2~/ - @lv3 ||=/^3~/ - @lv4 ||=/^4~/ - @lv5 ||=/^5~/ - @lv6 ||=/^6~/ - @data=nil #else whole file's contents are stored in md pstore & is not required to be... big waste actually - @file=SiSU_Env::FileOp.new(self) #watch - Store.new(self,@env).store #% pstore - self - rescue - if @opt.act[:harvest][:set]==:on - exit - end - end - end - private - class Store - def initialize(md,env) - @md,@env=md,env - end - def store - begin - pstorefile="#{@env.processing_path.ao}/#{@md.fns}.pstore" - File.unlink(pstorefile) if FileTest.file?(pstorefile) - if (@md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - "PStore -> #{pstorefile}" - ).txt_grey - end - store=PStore.new(pstorefile) - store.transaction do - store['md']=@md - store.commit - end - @@md=@md=nil - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - end - end - end - class Instantiate - def param_instantiate - @@date=SiSU_Env::InfoDate.new - @doc={ - initialise: nil, - markup: '', - lnks: '', - stmp: '', - prefix_a: '', - prefix_b: '', - req: {} - } - @@flag={} - @@publisher='SiSU scribe' - end - end -end -__END__ diff --git a/lib/sisu/current/dp_identify_markup.rb b/lib/sisu/current/dp_identify_markup.rb deleted file mode 100644 index acb6070a..00000000 --- a/lib/sisu/current/dp_identify_markup.rb +++ /dev/null @@ -1,161 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** A conversion script for canned substitutions, a fairly generic simple tool - that can be used to store other canned conversions, used here for altering - SiSU markup - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_MarkupType - class MarkupIdentify - @@version={} - @@fns,@@version[:determined],@@version[:declared],@@declared_doc_type='','','','[text?]' - attr_accessor :version,:declared_doc_type - def initialize(content,opt) - @cont,@opt=content,opt - end - def identify - @version,@declared_doc_type=@@version,@@declared_doc_type - if @opt.fns != @@fns - if @cont[0] =~ /^(?:%\s+)?SiSU\s+(text|master|insert)\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @declared_doc_type,@version[:declared]=$1,$2 - elsif @cont[0] =~ /^(?:%\s+)?SiSU\s+([0-9](?:\.[0-9]+){1,2})/ \ - or @cont[0] =~ /^(?:%\s+)?sisu-([0-9](?:\.[0-9]+){1,2})/ - @version[:declared]=$1 - end - @flag_2_0,@flag_66,@flag_57,@flag_38=false,false,false,false - @cont.each_with_index do |y,i| - if y =~/^@make:|^@classify|^\s\s?:\S+?:\s+\S/ - version=2.0.to_f - @version[:determined]=version - @flag_2_0=true - break - end - unless @flag_38 - if y =~/^:?A~/ - version=0.38.to_f - @version[:determined]=version - @flag_38=true - end - end - if @flag_38 - if @flag_69 \ - or y =~/^=\{.+?\}\s*$/ - version=0.69.to_f - @flag_69=true - @version[:determined]=version - break - end - if @flag_66 \ - or y =~/[:;]\{.+?\}[:;][a-z+]/ - version=0.66.to_f - @flag_66=true - @version[:determined]=version - break - end - end - end - @flag_57,@flag_38=false,false - unless @flag_2_0 \ - or @flag_66 \ - or @flag_69 - @cont.each_with_index do |y,i| - if @flag_57 \ - or y =~/^:?A~\?? @title/ - @version[:determined]=0.57.to_f - @flag_57=true - break - end - if @flag_38 \ - or y =~/^:?A~/ - @version[:determined]=0.38.to_f - @flag_38=true - break if i >= 200 - if y =~ /(?:~{\*+|~\[\*|~\[\+)\s/ - @version[:determined]=0.42 #0.38 can safely be treated as 0.42 - break - end - end - if y =~/^0~/ \ - and not @flag_38 - @version[:determined]=0.16.to_f - break - end - end - end - @@fns=@opt.fns - @@version,@@declared_doc_type=@version,@declared_doc_type - end - self - end - def markup_version? - def determined - identify.version[:determined].to_f - end - def series - s=case identify.version[:determined].to_s - when /^[01]\./ then '1.0' - when /^[2]\./ then '2.0' - else '2.0' - end - "series #{s}" - end - def declared - identify.version[:declared].to_f - end - self - end - end -end -__END__ diff --git a/lib/sisu/current/dp_make.rb b/lib/sisu/current/dp_make.rb deleted file mode 100644 index f65717bb..00000000 --- a/lib/sisu/current/dp_make.rb +++ /dev/null @@ -1,668 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** document parameters make extracted for program use - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 Lic/home/ralph/live-manual/build/manual/manifest/live-manual.ca.htmlense for - more details. - - You should have received a copy of the GNU General Public License along with - this program. If not, see . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end - -module SiSU_Param_Make - class MdMake - def initialize(str,opt,env) - @s,@opt,@env=str,opt,env - end - def validate_length(s,l,n) - #s=(s.length <= l) ? s : nil - s=if s.is_a?(String) \ - and s.length <= l - s - elsif s.is_a?(NilClass) - nil - elsif s.class !=String - STDERR.puts "#{n} is #{s.class}: programming error, String expected #{__FILE__}:#{__LINE__}" - s - else - SiSU_Screen::Ansi.new( - 'v', - "*WARN* #{n} length #{s.length} exceeds set db field length #{l}, metadata dropped", - @opt.fns - ).warn unless @opt.act[:quiet][:set]==:on - nil - end - end - def name_format(name) - if name - name=name.strip - @name_a_h=[] - authors=name.scan(/[^;]+/) - authors.each_with_index do |a,i| - b=((a =~/\s*\|\s*/) ? (a.split(/\|/)) : [a]) - if b[0] =~/"(.+?)"/ - @name_a_h << { the: $1 } - else - x=b[0].scan(/[^,]+/) - if x.length==1 - @name_a_h << { the: x[0].strip } - elsif x.length==2 - @name_a_h << { the: x[0].strip, others: x[1].strip } - else #p x.length - end - end - b.delete_at(0) - b.each do |d| - k,c=nil - k,c=/^(\S+)\s+(.*)/.match(d)[1,2] if d - @name_a_h[i][:hon]=c.strip if k=='hon' - @name_a_h[i][:affiliation]=c.strip if k=='affiliation' - @name_a_h[i][:nationality]=c.strip if k=='nationality' - end - end - l=@name_a_h.length - name_str='' - @name_a_h.each_with_index do |a,i| - name_str += if a[:others] - z=(((l - i) > 1) ? ', ' : '') - "#{a[:others].strip} #{a[:the].strip}" + z - else - z=(((l - i) > 2) ? ', ' : '') - "#{a[:the].strip}" + z - end - end - { name_a_h: @name_a_h, name_str: name_str } - else nil - end - end - def build_hash(arr) - @h={} - arr.each_with_index do |x,i| - a,b=nil,nil - if x =~/^%[:\s]/ #ignore comment - elsif x =~/:(\S+?):\s+(.+)/ - a,b=/:(\S+?):\s+(.+)\Z/m.match(x)[1,2] - elsif i == 0 - a='main' - b=x - else - end - @h[a]=b - end - @h - end - def make - a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - @h=build_hash(a) - def headings - lv=[] - x=@h['headings'] - x=((x =~/;/) ? (x.split(/;\s*/)) : [ x ]) - lv[0]=x - lv0 ||='A~ ' #root level, single document apex, document title - lv1=x[0] ||='B~ ' - lv[1]=/^#{lv1}/ - lv2=x[1] ||='C~ ' - lv[2]=/^#{lv2}/ - lv3=x[2] ||='D~ ' - lv[3]=/^#{lv3}/ - lv4=x[3] ||='1~ ' - lv[4]=/^#{lv4}/ - lv5=x[4] ||='2~ ' - lv[5]=/^#{lv5}/ - lv6=x[5] ||='3~ ' - lv[6]=/^#{lv6}/ - lv - end - def num_top - @h['num_top'] - end - def breaks - pagebreaks=((@h['breaks'] =~/;/) \ - ? (@h['breaks'].split(/;\s*/)) - : [ @h['breaks'] ]) - page_new,page_break,page_line=nil,nil,nil - pagebreaks.each do |x| - page_new=x[/(:?[\dA-C],?)+/] if x=~/new|clear/ - page_break=x[/(:?[\dA-C],?)+/] if x =~/break/ - page_line=x[/(:?[\dA-C],?)+/] if x =~/line/ - end - { page_new: page_new, page_break: page_break, page_line: page_line } - end - def language - if @h['language'] && (@h['language']=~/\S{2,}/) - ((@h['language'] =~/,/) \ - ? (@h['language'].split(/,\s*/)) - : [ @h['language'] ]) - else [ 'en' ] - end - end - def bold - m=@h['bold'] - i=(m=~/\/i$/)? 'i' : '' - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def italics - m=@h['italics'] - i=((m=~/\/i$/) ? 'i' : '') - if m - x=m.gsub(/^\/(.+?)\/i?/,'\1'). - gsub(/\((?:\?:)?/,'(?:') # avoid need to escape use of brackets within regex provided - rgx='\b(' + x + ')\b' - y=((i =~/i/) ? (/#{rgx}/i) : (/#{rgx}/)) - { str: '\b(?:' + x + ')\b', regx: y, i: i } - else nil - end - end - def emphasis - if @h['emphasis'] =~/bold/ then 'bold' - elsif @h['emphasis'] =~/italics?/ then 'italics' - elsif @h['emphasis'] =~/under(?:line|score)/ then 'underscore' - else nil - end - end - def substitute - m=@h['substitute'] - if m - w=m.scan(/\/(.+?)\/(i?,)\s*'(.+?)'(?:\s+|\s*;\s*|$)/) - arr_hash=[] - matches='' - w.each do |x| - c=(x[1] =~/[i],/) ? :i : :s - matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' - arr_hash << { - match: x[0].gsub(/([${}])/,'\\\\\1'), - replace: x[2], - case_s: c - } - end - matches.chop! - { match_and_replace: arr_hash, matches: matches } - else nil - end - end - def plaintext_wrap - if @h['plaintext_wrap'].to_s =~/\d\d+/ \ - and @h['plaintext_wrap'].to_i > 19 \ - and @h['plaintext_wrap'].to_i < 201 - @h['plaintext_wrap'].to_i - else nil - end - end - def omit - m=@h['omit'] - @m=m ? (m.split(/,\s+/)) : nil - def list - @m - end - self - end - def ocn? - (omit.list.inspect =~/"ocn"/) \ - ? :off - : :na - end - def toc? - (omit.list.inspect =~/"toc"/) \ - ? :off - : :na - end - def manifest? - (omit.list.inspect =~/"manifest"/) \ - ? :off - : :na - end - def links_to_manifest? - (omit.list.inspect =~/"manifest_links"|"links_to_manifest"/) \ - ? :off - : :na - end - def metadata? - (omit.list.inspect =~/"metadata"/) \ - ? :off - : :na - end - def minitoc? - (omit.list.inspect =~/"minitoc"/) \ - ? :off - : :na - end - def html_minitoc? - (omit.list.inspect =~/"html_minitoc"/) \ - ? :off - : :na - end - def html_top_band? - (omit.list.inspect =~/"html_top_band"/) \ - ? :off - : :na - end - def html_navigation? - (omit.list.inspect =~/"html_navigation"/) \ - ? :off - : :na - end - def html_navigation_bar? - (omit.list.inspect =~/"html_navigation_bar"/) \ - ? :off - : :na - end - def segsubtoc? - (omit.list.inspect =~/"segsubtoc"/) \ - ? :off - : :na - end - def search_form? - (omit.list.inspect =~/"search_form"/) \ - ? :off - : :na - end - def html_search_form? - (omit.list.inspect =~/"html_search_form"/) \ - ? :off - : :na - end - def html_right_pane? - (omit.list.inspect =~/"html_right_column"|"html_right_pane"/) \ - ? :off - : :na - end - def manifest_minitoc? - (omit.list.inspect =~/"manifest_minitoc"/) \ - ? :off - : :na - end - def cover_image? - (omit.list.inspect =~/"cover_image"/) \ - ? :off - : :na - end - def home_button_image? - (omit.list.inspect =~/"home_button_image"/) \ - ? :off - : :na - end - def texpdf_font - def main - @h['texpdf_font'] \ - && (@h['texpdf_font']=~/\S{3,}/) \ - ? @h['texpdf_font'] - : @env.font.texpdf.main - end - def sans # not used - @h['texpdf_font_sans'] \ - && (@h['texpdf_font_sans']=~/\S{3,}/) \ - ? @h['texpdf_font_sans'] - : @env.font.texpdf.sans - end - def serif # not used - @h['texpdf_font_serif'] \ - && (@h['texpdf_font_serif']=~/\S{3,}/) \ - ? @h['texpdf_font_serif'] - : @env.font.texpdf.serif - end - def mono - @h['texpdf_font_mono'] \ - && (@h['texpdf_font_mono']=~/\S{3,}/) \ - ? @h['texpdf_font_mono'] - : @env.font.texpdf.mono - end - def cjk - @h['texpdf_font_cjk'] \ - && (@h['texpdf_font_cjk']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk'] - : @env.font.texpdf.cjk - end - def cjk_zh - @h['texpdf_font_cjk_zh'] \ - && (@h['texpdf_font_cjk_zh']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_zh'] - : @env.font.texpdf.cjk_zh - end - def cjk_ja - @h['texpdf_font_cjk_ja'] \ - && (@h['texpdf_font_cjk_ja']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ja'] - : @env.font.texpdf.cjk_ja - end - def cjk_ko - @h['texpdf_font_cjk_ko'] \ - && (@h['texpdf_font_cjk_ko']=~/\S{3,}/) \ - ? @h['texpdf_font_cjk_ko'] - : @env.font.texpdf.cjk_ko - end - self - end - def promo - @h['promo'] - end - def ad - @h['ad'] - end - def manpage - manpage={} - if @h['manpage'] - if @h['manpage'] =~/;/m - man=@h['manpage'].split(/;/m) - man.each do |x| - m=(x=~/=/m) ? x.split(/=/m) : nil - if m - manpage[m[0].strip] = m[1].split(/ \. /) - end - end - end - end - if manpage['name'] - manpage['name']=manpage['name'].join("\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH NAME\n.br\n") - else - manpage['name']='man page "name/whatis" information not provided, set in header @man: name=[whatis information]' - end - if manpage['synopsis'] - manpage['synopsis']=manpage['synopsis'].join("\n\n.br\n"). - gsub(/(-)/m,"\\\\\\1"). - gsub(/\A/,"\n.br\n.SH SYNOPSIS\n.br\n") - else - manpage['synopsis']='' - end - unless manpage['section'] - manpage['section']=1 - end - manpage - end - def get_image_dimensions(img) - imgk=SiSU_Env::SystemCall.new.imagemagick - gmgk=SiSU_Env::SystemCall.new.graphicsmagick - img_pth={ - sst: @env.path.image_source_include, - pod: File.expand_path("../../../sisupod/image" ) - } - path_img=if FileTest.file?("#{img_pth[:pod]}/#{img}") - "#{img_pth[:pod]}/#{img}" - elsif FileTest.file?("#{img_pth[:sst]}/#{img}") - "#{img_pth[:sst]}/#{img}" - else nil - end - if path_img - if imgk or gmgk - if imgk - imgsys=`identify #{path_img}`.strip #system call - elsif gmgk - imgsys=`gm identify #{path_img}`.strip #system call - end - w,h=/(\d+)x(\d+)/m.match(imgsys)[1,2] - else - w,h='600','800' - end - else - w,h=nil,nil - end - {w: w, h: h} - end - def home_button_text - if @h['home_button_text'] - @h['home_button_text'].split(/\s*;\s*/) - else nil - end - end - def home_button_image - s=nil - s=if @h['home_button_image'] - s=@h['home_button_image'].split(/\s*;\s*/) - s0=s[0] #if - image={} - s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ - image[:home_button]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:home_button]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:link]=$3 - image - end - else nil - end - end - def cover_image - s=nil - if @h['cover_image'] - s=@h['cover_image'].split(/\s*;\s*/) - s=s[0] #if - image={} - if s =~/{\s*(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?(?:\s+"(.+?)")?\s*}image/ - image[:cover]=$1 - if $2 - image[:dimensions]=$2 - image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimensions])[1,2] - else - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - end - image[:note]=$3 - elsif s =~/(\S+\.(?:jpg|png|gif))/ - image[:cover]=$1 - d=get_image_dimensions(image[:cover]) - image[:w],image[:h]=d[:w],d[:h] - image[:dimensions]="#{d[:w]}x#{d[:h]}" - image[:note]=nil - end - image - else nil - end - end - def footer - if @h['footer'] - @h['footer'].split(/\s*;\s*/) - else nil - end - end - self - end - def make_links - @doc_links=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) - def links - lnks,a_idx=[],0 - @doc_links.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - lnks[a_idx]={ say: say, url: url } - a_idx +=1 - end - end - lnks - end - def append? - (@doc_links[0]=='+') \ - ? :yes - : :no - end - self - end - end - class MakeHead - attr_accessor :pagenew,:pagebreak,:pageline,:toc,:lv1,:lv2,:lv3,:lv4,:lv5,:lv6,:num_top,:i18n,:man_section,:substitution_match_list,:bold_match_list,:italics_match_list,:emphasis_set_to,:footer_links,:home_button_links,:home_button_image,:cover_image - def initialize(make) - @make=make - end - def clear - @pagenew=@pagebreak=@pageline=@toc=@lv1=@lv2=@lv3=@lv4=@lv5=@lv6=@num_top=@i18n=@man_section=@footer_links=@substitution_match_list=@bold_match_list=@italics_match_list=@emphasis_set_to=@home_button_links=@home_button_image=@cover_image=nil - end - def make_instruct - clear - if defined? @make.breaks \ - and @make.breaks[:page_new] #clearpage - @pagenew=@make.breaks[:page_new] - end - if defined? @make.breaks \ - and @make.breaks[:page_break] #newpage - @pagebreak=@make.breaks[:page_break] - end - if defined? @make.breaks \ - and @make.breaks[:page_line] #page line across - @pagebreak=@make.breaks[:page_line] - end - if defined? @make.headings \ - and @make.headings - @toc=@make.headings[0] - @lv1=@make.headings[1] - @lv2=@make.headings[2] - @lv3=@make.headings[3] - @lv4=@make.headings[4] - @lv5=@make.headings[5] - @lv6=@make.headings[6] - end - if defined? @make.num_top \ - and @make.num_top - @num_top=@make.num_top # remove @num_top - end - if defined? @make.language \ - and @make.language[0] - @i18n=@make.language - end - if defined? @make.manpage \ - and @make.manpage - @man_section=(defined? @make.manpage.section) \ - ? @make.manpage.section - : 1 - end - if defined? @make.substitute \ - and @make.substitute - @substitution_match_list=@make.substitute - end - if defined? @make.bold \ - and @make.bold - @bold_match_list=@make.bold - end - if defined? @make.italics \ - and @make.italics - @italics_match_list=@make.italics - end - if defined? @make.emphasis \ - and @make.emphasis - @emphasis_set_to=@make.emphasis - end - if defined? @make.footer \ - and @make.footer.is_a?(Array) - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } #already set - @footer_links[:left]=if @make.footer[0]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[0])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links[:center]=if @make.footer[1]=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(@make.footer[1])[1,2] - { say: say, url: url } - else - { say: '', url: '' } - end - @footer_links - else #already set - @footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } } - end - if defined? @make.home_button_text \ - and @make.home_button_text.is_a?(Array) - a_idx=0 - @home_button_links=[] - @make.home_button_text.each do |doc_link| - if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ - say,url=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] - @home_button_links[a_idx]= { say: say, url: url } - a_idx +=1 - end - end - @home_button_links - end - if defined? @make.home_button_image \ - and @make.home_button_image.is_a?(Hash) - @home_button_image=@make.home_button_image - end - if defined? @make.cover_image \ - and @make.cover_image.is_a?(Hash) - @cover_image=@make.cover_image - end - { pagenew: @pagenew, - pagebreak: @pagebreak, - pageline: @pageline, - toc: @toc, - lv1: @lv1, - lv2: @lv2, - lv3: @lv3, - lv4: @lv4, - lv5: @lv5, - lv6: @lv6, - num_top: @num_top, - i18n: @i18n, - emphasis_set_to: @emphasis_set_to, - bold_match_list: @bold_match_list, - italics_match_list: @italics_match_list, - substitution_match_list: @substitution_match_list, - man_section: @man_section, - footer_links: @footer_links, - home_button_links: @home_button_links, - home_button_image: @home_button_image, - cover_image: @cover_image, - } - end - end -end -__END__ diff --git a/lib/sisu/current/embedded.rb b/lib/sisu/current/embedded.rb deleted file mode 100644 index 14f2bd4a..00000000 --- a/lib/sisu/current/embedded.rb +++ /dev/null @@ -1,149 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** sitemap created from parameters extracted from input file(s) - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Embedded - require_relative 'dp' # dp.rb - include SiSU_Param - require_relative 'se' # se.rb - include SiSU_Env - class Source - def initialize(opt) - @opt=opt - @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::InfoEnv.new(@md.fns) - @rhost=SiSU_Env::InfoRemote.new(@opt).remote_host_base - @base_src_dir=@opt.f_pth[:pth].sub(/\/#{@opt.f_pth[:lng]}$/,'') - @f=SiSU_Env::FileOp.new(@md) - end - def read - songsheet - end - def songsheet - images - audio - multimedia - begin - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - end - end - def images - src="#{@base_src_dir}/_sisu/image" - ldest=@env.path.output - img_dir="#{@env.path.output}/_sisu/image" - @rhost.each do |remote_conn| - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on \ - || @md.opt.act[:rsync][:set]==:on) \ - and FileTest.directory?(src) - FileUtils::mkdir_p(img_dir) unless FileTest.directory?(img_dir) - src_ec=@f.place_file.images.rel + '/' + @md.ec[:image].join(" #{@f.output_path.images.rel}/") - unless @opt.fns =~/\.-sst$/ - SiSU_Env::SystemCall.new(src_ec,ldest,'q').rsync('--relative',@opt.base_path) - #if @md.opt.selections.str.inspect =~/R/ #rsync to remote image directory - # SiSU_Env::SystemCall.new(src_ec,remote_rel,'q').rsync('--relative') - #end - end - end - end - end - def audio - #p @md.ec[:audio] - src="#{@base_src_dir}/_sisu/mm/audio" - ldest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/mm/audio" - @rhost.each do |remote_conn| - rdest="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/_sisu/mm/audio" - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on \ - || @md.opt.act[:rsync][:set]==:on) \ - and FileTest.directory?(src) - FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:audio].join(" #{src}/") - SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync - if @md.opt.act[:rsync][:set]==:on #rsync to remote audio directory - SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync - end - end - end - end - def multimedia - #p @md.ec[:multimedia] - src="#{@base_src_dir}/_sisu/mm/video" - ldest="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/mm/video" - @rhost.each do |remote_conn| - rdest="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/_sisu/mm/video" - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on \ - || @md.opt.act[:rsync][:set]==:on) \ - and FileTest.directory?(src) - FileUtils::mkdir_p(ldest) unless FileTest.directory?(ldest) - src_ec="#{src}/" + @md.ec[:multimedia].join(" #{src}/") - SiSU_Env::SystemCall.new(src_ec,"#{ldest}/.",'q').rsync - if @md.opt.act[:rsync][:set]==:on #rsync to remote video directory - SiSU_Env::SystemCall.new(src_ec,"#{rdest}/.",'q').rsync - end - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/errors.rb b/lib/sisu/current/errors.rb deleted file mode 100644 index 73b2feaa..00000000 --- a/lib/sisu/current/errors.rb +++ /dev/null @@ -1,84 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, error screen reporting - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Errors - require_relative 'se' # se.rb - include SiSU_Env; include SiSU_Screen - class Rescued - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Parts_Generic - def the_url - def urify(uri) - URI.parse(uri) - end - def sisu - 'http://www.sisudoc.org/' - end - def sisudoc - 'http://www.sisudoc.org' - end - def footer_signature - 'http://www.sisudoc.org/' - end - def rl_root - '/sisu' #watch - end - def root_http - 'http://www.sisudoc.org/' #watch - end - def home - 'http://www.sisudoc.org/' # used in pdf header - end - def site #used as stub... where there are subdirectories and is different from home - home - end - def home_txt - 'www.sisudoc.org' - end - def sisu_txt - 'www.sisudoc.org' - end - self - end - def the_text - def home - 'SiSU' - end - def txt_hp - ' SiSU' - end - def txt_hp_alias - 'SiSU' - end - def txt_home - 'SiSU' - end - def txt_signature # used in latex/pdf footer - 'SiSU' - end - def url_open - '<' - end - def url_close - '>' - end - self - end - def the_icon - def i_ico - 'rb7.ico' - end - def i_home_button - 'sisu.png' - end - def i_choice - 'b_choice.png' - end - def i_new - 'b_new.png' - end - self - end -end -__END__ diff --git a/lib/sisu/current/git.rb b/lib/sisu/current/git.rb deleted file mode 100644 index b8b5f106..00000000 --- a/lib/sisu/current/git.rb +++ /dev/null @@ -1,277 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** system environment, resource control and configuration details - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Git - require_relative 'dp' # dp.rb - require_relative 'se' # se.rb - require_relative 'ao' # ao.rb - class Source - def initialize(opt,process=:complete) - @opt,@process=opt,process - @env=SiSU_Env::InfoEnv.new - @md=SiSU_Param::Parameters.new(@opt).get - @file=SiSU_Env::FileOp.new(@md) - l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language - unless @opt.lng==l[:c] # @md.i18n[0]==l[:c] - p "using: #{@opt.lng} (@make: :language:); filename #{@md.fns} filename language: #{l[:c]}, mismatch" - end - if @env.output_dir_structure.multilingual? - m=/((.+?)(?:\~\w{2,3})?)\.((?:-|ssm\.)?sst|ssm)$/ #watch added match for sss - fnb,fnt=@opt.fns[m,2],@opt.fns[m,3] - else m=/(.+?)\.((?:-|ssm\.)?sst|ssm)$/ - fnb=@fnn=@opt.fns[m,1] - fnt=@opt.fns[m,2] - end - git_path_fnb=@env.processing_path.git + '/' + fnb - lng=(@md.opt.lng) ? (@md.opt.lng) : (@md.i18n[0]) - @git_path={ - fnb: git_path_fnb, - doc: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:doc] + '/' + lng, - po: git_path_fnb + '/' + Gt[:po] + '/' + lng, - pot: git_path_fnb + '/' + Gt[:pot], - conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf], - image: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:image], - audio: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:audio], - video: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:video], - conf: git_path_fnb + '/' + Gt[:sisupod] + '/' + Gt[:conf] - } - SiSU_AO::Source.new(@opt,nil,@process).read # -m - end - def create_file_structure_git - make_dir_fnb - if program_found? - git_init - end - end - def read - create_file_structure_git - populate.sisusrc_files - #if program_found? - # git_commit - #end - unless @opt.act[:quiet][:set]==:on - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Git path', - @git_path[:fnb] - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Git path', - @git_path[:fnb] - ).green_title_hi - if (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "Git path", - "#{@opt.fns} -> #{@git_path[:fnb]}" - ).warn - end - end - end - def program_found? - found=`whereis git` - (found =~/bin\/git\b/) ? true : false - end - def make_dir_fnb - FileUtils::mkdir_p(@git_path[:fnb]) \ - unless FileTest.directory?(@git_path[:fnb]) - FileUtils::mkdir_p(@git_path[:doc]) \ - unless FileTest.directory?(@git_path[:doc]) - FileUtils::mkdir_p(@git_path[:po]) \ - unless FileTest.directory?(@git_path[:po]) - FileUtils::mkdir_p(@git_path[:pot]) \ - unless FileTest.directory?(@git_path[:pot]) - FileUtils::mkdir_p(@git_path[:conf]) \ - unless FileTest.directory?(@git_path[:conf]) - FileUtils::mkdir_p(@git_path[:image]) \ - unless FileTest.directory?(@git_path[:image]) - #FileUtils::mkdir_p(@git_path[:audio]) \ - # unless FileTest.directory?(@git_path[:audio]) - #FileUtils::mkdir_p(@git_path[:video]) \ - # unless FileTest.directory?(@git_path[:video]) - end - def git_init - unless FileTest.directory?("#{@git_path[:fnb]}/.git") - pwd=Dir.pwd - Dir.chdir(@git_path[:fnb]) - system("git init ") - Dir.chdir(pwd) - end - end - def git_commit - if program_found? - if FileTest.directory?("#{@git_path[:fnb]}") - pwd=Dir.pwd - Dir.chdir(@git_path[:fnb]) - system(" - git add . \ - && git commit -a - ") - Dir.chdir(pwd) - end - end - end - def populate - def identify_language_versions - print __FILE__ + ':' - p __LINE__ - end - def copy_src_head - if @opt.f_pth[:lng] \ - and File.exist?("#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}") - FileUtils::cp_r( - "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{@opt.fns}", - @git_path[:doc] - ) - elsif @opt.fns =~/\.ssm\.sst/ - ssm=@opt.fns.gsub(/\.ssm\.sst/,'.ssm') - FileUtils::cp_r( - "#{@env.path.pwd}/#{ssm}", - @git_path[:doc] - ) - elsif File.exist?("#{@env.path.pwd}/#{@opt.fns}") - FileUtils::cp_r( - "#{@env.path.pwd}/#{@opt.fns}", - @git_path[:doc] - ) - end - end - def copy_related_sst_ssi - doc_import=[] - @rgx_doc_import=/^<<\s(\S+?\.ss[ti])/ - file_array=IO.readlines(@opt.fns,'') - file_array.each do |f| - if f =~@rgx_doc_import - doc_import = doc_import \ - + f.scan(@rgx_doc_import).uniq.flatten - end - end - doc_import.each do |f| - if @opt.f_pth[:lng] - FileUtils::cp_r( - "#{@env.path.pwd}/#{@opt.f_pth[:lng]}/#{f}", - @git_path[:doc] - ) - else - FileUtils::cp_r( - "#{@env.path.pwd}/#{f}", - @git_path[:doc] - ) - end - end - end - def locate_parse_file - composite_src=@opt.fns=~/\.ssm$/ ? true : false - if composite_src \ - and not @opt.act[:ao][:set]==:on - ##SiSU_Assemble::Composite.new(@opt).read - #SiSU_AO::Source.new(@opt).read # -m - @env.processing_path.composite_file \ - + '/' \ - + @opt.fnb \ - + '.ssm.sst' - elsif composite_src - @env.processing_path.composite_file \ - + '/' \ - + @opt.fnb \ - + '.ssm.sst' - else - @env.path.pwd - + '/' \ - + @opt.fns - end - end - def read_composite - #print __FILE__ + ':' - #p __LINE__ - end - def sisuyaml_rc - sisurc=@env.path.sisurc_path - if FileTest.file?(sisurc) - FileUtils::cp_r(sisurc,@git_path[:conf]) - end - end - def read_src - print __FILE__ + ':' - p __LINE__ - end - def composite_src? - @opt.fns=~/\.ssm$/ ? true : false - end - def sisusrc_files - populate.copy_src_head - if composite_src? - populate.copy_related_sst_ssi - end - #parse_file_name=locate_parse_file - #parse_file=IO.readlines(parse_file_name,'') - populate.sisuyaml_rc #(parse_file) - #populate.extract_composite_source - #populate.read_composite # or read_each_composite - populate.identify_language_versions - end - self - end - end -end -__END__ -@file.output_path.sisugit diff --git a/lib/sisu/current/html.rb b/lib/sisu/current/html.rb deleted file mode 100644 index 3aab3be7..00000000 --- a/lib/sisu/current/html.rb +++ /dev/null @@ -1,775 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** html generation, processing - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_HTML - begin - require 'pstore' - rescue LoadError - SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia). - error('pstore NOT FOUND (LoadError)') - end - require_relative 'se_hub_particulars' # se_hub_particulars.rb - include SiSU_Particulars - require_relative 'html_table' # html_table.rb - require_relative 'html_parts' # html_parts.rb - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'html_segments' # html_segments.rb - include SiSU_HTML_Seg - require_relative 'html_scroll' # html_scroll.rb - require_relative 'html_promo' # html_promo.rb - include SiSU_HTML_Promo - require_relative 'html_tune' # html_tune.rb - include SiSU_HTML_Tune - class Source - def initialize(opt) - @opt=opt - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - end - def read - begin - songsheet - ensure - SiSU_Env::CreateSite.new(@opt).cp_css - SiSU_Env::CreateSite.new(@opt).cp_base_images - Dir.chdir(@opt.f_pth[:pth]) - end - end - def songsheet - begin - @md=@particulars.md - @fnb=@md.fnb - @env=@particulars.env - primary_output_file=(@opt.act[:html_seg][:set]==:on) \ - ? (@md.file.output_path.html_seg.dir + '/' + @md.file.base_filename.html_segtoc) - : (@md.file.output_path.html_scroll.dir + '/' + @md.file.base_filename.html_scroll) - unless @opt.act[:quiet][:set]==:on - tool=(@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? ("#{@env.program.web_browser} file://#{primary_output_file}") - : ("[#{@opt.f_pth[:lng_is]}] #{@opt.fno}") - (@opt.act[:verbose][:set]==:on \ - || @opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'HTML', - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'HTML', - tool - ).green_title_hi - if (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - @opt.fns, - "file://#{primary_output_file}" - ).flow - end - end - data=nil - tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions - data=tuned_file_array - if @opt.act[:html_scroll][:set]==:on - scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll - end - toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet - links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc - data=tuned_file_array - scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch - if @opt.act[:html_seg][:set]==:on - SiSU_HTML::Source::Seg.new(@md,data).songsheet - end - data=tuned_file_array - if @opt.act[:html_scroll][:set]==:on - scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet - scroll=SiSU_HTML::Source::ScrollOutput.new( - scr_toc, - scr[:body], - scr[:metadata], - scr[:owner_details], - scr[:tails], - @md - ).publish - SiSU_HTML::Source::Output.new(scroll,@md).scroll - end - rescue - SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - unless (@opt.act[:verbose_plus][:set]==:on \ - || @opt.act[:maintenance][:set]==:on) - texfiles=Dir["#{@env.processing_path.tune}/#{@opt.fns}*"] - texfiles.each do |f| - if FileTest.file?(f) - File.unlink(f) - end - end - end - SiSU_Env::Clear.new(@opt.selections.str,@opt.fns,@md).param_instantiate - @@flag,@@scr,@@seg,@@seg_endnotes,@@seg_subtoc={},{},{},{},{} - @@tracker=0 - @@seg_name,@@seg_name_x,@@seg_subtoc_array,@@seg_endnotes_array,@@tablefoot=Array.new(5){[]} - @@filename_seg,@@seg_url,@@to_lev4,@@get_hash_to,@@get_hash_fn='','','','','' - end - end - private - class HTML_Environment - def initialize(particulars) - @particulars=particulars - @md,@env=particulars.md,particulars.env - @env,@css=particulars.env,SiSU_Style::CSS.new - end - def tuned_file_instructions - @tell=SiSU_Screen::Ansi.new(@md.opt.act[:color_state][:set]) - ao_array=@particulars.ao_array # ao file drawn here - tuned_file_array=SiSU_HTML_Tune::Tune.new(ao_array,@md).songsheet - tuned_file_array - end - end - class LinksGuide - @links_guide_toc=[] - def initialize(data,md) - @data,@md=data,md - @links_guide_=SiSU_Env::CreateSite.new(@md.opt).html_quick_ref? - end - def toc - @links_guide_toc=[] - if @links_guide_ - format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) - guide_type='horzontal' #values: horizontal or vertical - @links_guide_toc << format_head_toc.links_guide_open(guide_type) - if defined? @md.lnk \ - and @md.lnk - @md.lnk.each do |l| - if defined? l[:say] - target=(l[:url] !~/^\.(\.)?\//) \ - ? 'external' - : '_top' - s_lnk_url,s_lnk_lnk=l[:url],l[:say] - txt_obj={ - lnk_url: s_lnk_url, - lnk_txt: s_lnk_lnk, - target: target, - } - lev_dob_ocn=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - @links_guide_toc << lev_dob_ocn.links_guide if s_lnk_lnk - end - end - end - format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) - @links_guide_toc << format_head_toc.links_guide_close #(guide_type) - @links_guide_toc - else '' - end - end - end - class Endnotes - include SiSU_HTML_Format - def initialize(data,md) - @data,@md=data,md - end - def scroll - @scr_endnotes=[] - SiSU_HTML_Format::HeadScroll.new(@md) - @data.each do |dob| - pg=dob.dup - unless pg.is ==:code - if pg.obj =~/(?:#{Mx[:en_a_o]}|#{Mx[:en_b_o]})[\d*+]+ / - endnote_array=[] - if pg.obj=~/#{Mx[:en_a_o]}[\d*+].+?#{Mx[:en_a_c]}/m - endnote_array = pg.obj.scan(/#{Mx[:en_a_o]}[\d*+]+(.+?)#{Mx[:en_a_c]}/m) - end - if pg.obj=~/#{Mx[:en_b_o]}[\d*]+\s.+?#{Mx[:en_b_c]}/m - endnote_array = pg.obj.scan(/#{Mx[:en_b_o]}[\d*]+(.+?)#{Mx[:en_b_c]}/m) - end - if pg.obj=~/#{Mx[:en_b_o]}[\d+]+\s.+?#{Mx[:en_b_c]}/m - endnote_array = pg.obj.scan(/#{Mx[:en_b_o]}[\d+]+(.+?)#{Mx[:en_b_c]}/m) - end - endnote_array.flatten.each do |note| - txt_obj={ txt: note } - format_scroll=SiSU_HTML_Format::FormatScroll.new(@md,txt_obj) - @scr_endnotes << format_scroll.endnote_body - end - end - end - end - @scr_endnotes - end - end - class Toc ' + minitoc + '' - end - protected - def rss #sort all wrong, disabled but kept - @@toc[:seg] <<< -
-

-(relatively static) RSS feeds for DOCUMENTS:
-RSS feed http://www.jus.uio.no/lm/rssfeed/documents.xml
-RSS feed http://www.jus.uio.no/lm/rssfeed/tradelaw.xml
-RSS feed http://www.jus.uio.no/lm/rssfeed/environmental.xml
-

info@address.com
-

-
-WOK - end -#not used --> - def level_endnotes - if @md.flag_endnotes - format_head_scroll=SiSU_HTML_Format::HeadScroll.new(@md) - @@toc[:scr] << format_head_scroll.toc_endnote - end - end - def level_concordance - format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) - @@toc[:seg_mini] << format_head_toc.mini_seg_concordance - end - def level_metadata - format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) - @@toc[:scr] << format_head_toc.metadata - @@toc[:seg] << format_head_toc.seg_metadata - @@toc[:seg_mini] << format_head_toc.mini_seg_metadata - end - def level_word_index - format_head_toc=SiSU_HTML_Format::HeadToc.new(@d0c) - @@toc[:scr] << format_head_toc.concordance - @@toc[:seg] << format_head_toc.concordance - @@toc[:seg_mini] << format_head_toc.mini_concordance - end -# <-- not used - def level_0 - dob=@data - linkname,link=dob.obj.strip,dob.ocn - if link \ - and link !~/#/ #% keep eye on link - SiSU_HTML_Format::ParagraphNumber.new(@md,link) - end - title=linkname - toc={} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:seg]=format_toc.lev0 - toc[:seg_mini]=format_toc.mini_lev0 - title=if dob.ocn ==0 then linkname - else - @@toc[:scr] << '
' - %{#{linkname}} - end - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev0 - toc - end - def level_1 - dob=@data - linkname,link=dob.obj.strip,dob.ocn - if link \ - and link !~/#/ #% keep eye on link - SiSU_HTML_Format::ParagraphNumber.new(@md,link) - end - title=if dob.obj !~/^Metadata$/ then linkname - else - link='metadata' - %{#{linkname}} - end - toc={} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:seg]=if dob.name =~/^meta/ \ - and dob.obj =~/Document Information/ - format_toc.lev0 - else format_toc.lev1 - end - toc[:seg_mini]=if dob.name =~/^meta/ \ - and dob.obj =~/Document Information/ - @md.concord_make \ - ? format_toc.mini_concord_tail - : format_toc.mini_tail - else format_toc.mini_lev1 - end - title=if dob.ocn ==0 - if dob.name =~/^meta/ \ - and dob.obj =~/Document Information/ - %{#{linkname}} - else linkname - end - else - @@toc[:scr] << '
' - %{#{linkname}} - end - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=if dob.obj =~/^Metadata$/ then '' - elsif txt_obj[:txt] =~// - format_toc.lev1.gsub(/|<\/a>/,'') - else format_toc.lev1 - end - toc - end - def level_2 - dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - p_num=if ocn \ - and ocn !~/#/ - SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) - else nil - end - txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc={} - toc[:seg]=format_toc.lev2 - toc[:seg_mini]=format_toc.mini_lev2 - if p_num - title=%{#{p_num.goto}#{linkname}} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=if txt_obj[:txt] =~// - format_toc.lev2.gsub(/|<\/a>/,'') - else format_toc.lev2 - end - end - toc - end - def level_3 - dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - p_num=if ocn \ - and ocn !~/#/ - SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) - else nil - end - txt_obj={ txt: linkname } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc={} - toc[:seg]=format_toc.lev3 - toc[:seg_mini]=format_toc.mini_lev3 - if p_num - title=%{#{p_num.goto}#{linkname}} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=if txt_obj[:txt] =~// - format_toc.lev3.gsub(/|<\/a>/,'') - else format_toc.lev3 - end - end - toc - end - def level_4 - dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn - if dob.ln ==4 - fnh={ - fn: dob.name, - } - f=@md.file.base_filename.html_seg(fnh) - seg_link=%{ - #{dob.obj} - } - @@seg_url=dob.name - elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ - fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2] - fnh={ - fn: fn, - } - f=@md.file.base_filename.html_seg(fnh) - seg_link=%{#{fn} #{hd} } - end - p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn - @file=SiSU_Env::FileOp.new(@md) if @md - txt_obj=if seg_link=~/sisu_manifest\.html/ - man_link=if @file.output_dir_structure.by_language_code? \ - or @file.output_dir_structure.by_filetype? - seg_link.gsub(/sisu_manifest\.html/,"../../manifest/#{@file.base_filename.manifest}") - else seg_link - end - { txt: man_link } - else { txt: seg_link } - end - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc={} - toc[:seg]=format_toc.lev4 - toc[:seg_mini]=format_toc.mini_lev4 - title=%{#{p_num.goto}#{linkname}} if p_num - txt_obj=if title=~/sisu_manifest.html/ - man_link=title.gsub(/sisu_manifest.html/,"../manifest/#{@file.base_filename.manifest}") - { txt: man_link } - else { txt: title } - end - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev4 - toc - #end - end - def level_5 - dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - toc={} - if ocn \ - and ocn !~/#/ - fnh={ - fn: @@seg_url, - } - f=@md.file.base_filename.html_seg(fnh) - p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) - lnk_n_txt=%{ - #{linkname} - } - txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:seg]=format_toc.lev5 - toc[:seg_mini]=format_toc.mini_lev5 - title=%{#{p_num.goto}#{linkname}} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev5 - end - toc - end - def level_6 - dob=@data - linkname,ocn=dob.obj.strip,dob.ocn - toc={} - if ocn \ - and ocn !~/#/ - fnh={ - fn: @@seg_url, - } - f=@md.file.base_filename.html_seg(fnh) - p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) - lnk_n_txt=%{ - #{linkname} -} - txt_obj={ txt: lnk_n_txt } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:seg]=format_toc.lev6 - toc[:seg_mini]=format_toc.mini_lev6 - title=%{#{p_num.goto}#{linkname}} - txt_obj={ txt: title } - format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) - toc[:scr]=format_toc.lev6 - end - toc - end - def level_crosslink - dob=@data - dob=if dob !~/^4~!/ - dob.gsub(/^4~!\s+(\S+)\s+(.+)/, - %{ -
- #{@png.crosslink_ext} -   \\2 - <\/a> -
-}) - else - dob.gsub(/^4~!\s+(\S+)\s+(.+)/, - %{
- - - #{@png.crosslink} -   \\2 - <\/a> -
-}) - end - end - end - class ScrollHeadAndSegToc < Toc - include SiSU_Parts_HTML - def initialize(md='',toc='',links_guide_toc='') - @md,@toc,@links_guide_toc=md,toc,links_guide_toc - @make=SiSU_Env::ProcessingSettings.new(@md) - end - def in_common - toc_shared=[] - @segtoc=[] - if (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - 'Scroll & Segtoc' - ).txt_grey - end - format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) - dochead=format_head_toc.head - dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge - toc_shared << dochead - @segtoc << format_head_toc.head - if @make.build.html_top_band? - toc_shared << format_head_toc.scroll_head_navigation_band - end - if defined? @md.rights.all - rights=format_head_toc.rights.all - rights=SiSU_HTML_Tune::CleanHTML.new(rights).clean - end - if @md.prefix_b - prefix_b=format_head_toc.notes.prefix_b - prefix_b=SiSU_HTML_Tune::CleanHTML.new(prefix_b).clean - end - if @make.build.html_top_band? - @segtoc << format_head_toc.seg_head_navigation_band - end - toc_shared << format_head_toc.scroll_head_title_banner_open - @segtoc << format_head_toc.seg_head_title_banner_open - tmp_head=nil - doc_title_endnote=@md.title.full.gsub(/(\*+)/, - '\1') - tmp_head=doc_title_endnote + "\n" - txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) - toc_shared << format_txt_obj.center_bold - @segtoc << format_txt_obj.center_bold - if defined? @md.creator.author - creator=SiSU_HTML_Tune::CleanHTML.new(@md.creator.author).clean_for_html - creator_endnote=creator.gsub(/(\*+)/, - %{ \\1}) - tmp_head=creator_endnote + "\n" - txt_obj={ txt: tmp_head } - format_txt_obj=SiSU_HTML_Format::FormatTextObject.new(@md,txt_obj) - toc_shared << format_txt_obj.center_bold - @segtoc << format_txt_obj.center_bold - end - toc_shared << "#{the_table_close*1}\n" - @segtoc << "#{the_table_close*1}\n" - tmp_head=nil - if @md.prefix_a - tmp_head ||= %{

#{@md.prefix_a}\n} - toc_shared << tmp_head.dup - @segtoc << tmp_head.dup - end - tmp_head=nil - toc_shared << @links_guide_toc - if defined? @md.rights.all #and ? @md.rights.all - toc_shared << rights - end - if defined? @md.prefix_b - toc_shared << prefix_b - end - if @make.build.toc? #Table of Contents added/appended here - toc_shared << @toc[:scr] - end - @segtoc << @links_guide_toc - @segtoc << @toc[:seg] - if defined? @md.rights.all \ - and not @md.rights.all.empty? - @segtoc << rights - end - @segtoc << prefix_b if @md.prefix_b - #Segtoc tail added here - @segtoc << "

\n" #bugfix sort later DEBUGNOW - @segtoc << @seg_toc_band_bottom - @segtoc << format_head_toc.seg_navigation_tail << format_head_toc.html_close - @segtoc=@segtoc.flatten.compact #watch - if @md.opt.act[:html_seg][:set]==:on - SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc - end - @segtoc=[] - @toc[:scr],@toc[:seg]=[],[] - toc_shared - end - end - class Table < SiSU_HTML_Table::TableHTML - end - class Scroll < SiSU_HTML_Scroll::Scroll - end - class ScrollOutput - def initialize(scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md) - @scr_toc,@scr_body,@scr_metadata,@scr_owner_details,@scr_tails,@md=scr_toc,scr_body,scr_metadata,scr_owner_details,scr_tails,md - end - def publish - scroll=[] - scroll << @scr_toc << '
' << @scr_body << @scr_endnotes << @scr_owner_details << '
' << @scr_tails - scroll=scroll.flatten.compact #watch - end - end - class Seg < SiSU_HTML_Seg::Seg - end - class Output - def initialize(data='',md='') - @data,@md=data,md - @file=SiSU_Env::FileOp.new(md) - @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - end - def scroll - if @md.opt.act[:html_scroll][:set]==:on - begin - @filename_html_scroll=@file.write_file.html_scroll - @data.each do |para| - para=para.strip. - gsub(/<:.+?>/,''). - gsub(Xx[:html_relative2],@file.path_rel_links.html_scroll_2). - gsub(Xx[:html_relative1],@file.path_rel_links.html_scroll_1). - #gsub(/#{Xx[:html_relative]}/,@file.path_rel_links.html_scroll). - gsub(/#{Rx[:mx_fa_clean]}/,'') - unless para =~/\A\s*\Z/ - @filename_html_scroll.puts para,"\n" - end - end - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - @filename_html_scroll.close - end - end - end - def segtoc - if @md.opt.act[:html_seg][:set]==:on - begin - @filename_html_segtoc=@file.write_file.html_segtoc - @data.each do |para| - para=para.strip. - gsub(//,''). - gsub(Xx[:html_relative2],@file.path_rel_links.html_seg_2). - gsub(Xx[:html_relative1],@file.path_rel_links.html_seg_1) - unless para =~/\A\s*\Z/ - @filename_html_segtoc.puts para,"\n" - end - end - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - @filename_html_segtoc.close - pwd_set=Dir.pwd - idx_lnk=(@o_str.dump_or_redirect?) \ - ? @file.base_filename.manifest - : @file.base_filename.html_segtoc - mlnk=@file.base_filename.html_seg_index - Dir.chdir(@file.output_path.html_seg.dir) - FileUtils::rm_f(mlnk) - FileUtils::ln_s(idx_lnk,mlnk) - Dir.chdir(pwd_set) - end - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/html_concordance.rb b/lib/sisu/current/html_concordance.rb deleted file mode 100644 index 3b3275e3..00000000 --- a/lib/sisu/current/html_concordance.rb +++ /dev/null @@ -1,391 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** concordance file (html, wordmap, linked index of words in document) - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_Concordance - require_relative 'se_hub_particulars' # se_hub_particulars.rb - include SiSU_Particulars - require_relative 'se' # se.rb - include SiSU_Env - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'html_minitoc' # html_minitoc.rb - class Source - def initialize(opt) - @opt=opt - @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) - end - def read - begin - @env,@md=@particulars.env,@particulars.md - @env.url.output_tell - unless @md.opt.act[:quiet][:set]==:on - tool=(@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? "#{@env.program.web_browser} #{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" - : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}" - (@md.opt.act[:verbose][:set]==:on \ - || @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on) \ - ? SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - "Concordance", - tool - ).green_hi_blue - : SiSU_Screen::Ansi.new( - @opt.act[:color_state][:set], - 'Concordance', - tool - ).green_title_hi - end - wordmax=@env.concord_max - unless @md.wc_words.nil? - if @md.wc_words < wordmax - SiSU_Concordance::Source::Words.new(@particulars).songsheet - else - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - "concordance skipped, large document has over #{wordmax} words (#{@md.wc_words})" - ).warn unless @md.opt.act[:quiet][:set]==:on - end - else - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - "wc (word count) is off, concordance will be processed for all files including those over the max set size of: #{wordmax} words" - ).warn unless @md.opt.act[:quiet][:set]==:on - SiSU_Concordance::Source::Words.new(@particulars).songsheet - end - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - SiSU_Env::CreateSite.new(@opt).cp_css - Dir.chdir(@opt.f_pth[:pth]) - end - end - private - class DocTitle - #revisit, both requires (html & xml_shared) needed for stand alone operation (sisu -w [filename]) - require_relative 'xml_shared' # xml_shared.rb - require_relative 'html' # html.rb - def initialize(particulars) - @particulars,@md=particulars,particulars.md - @data=SiSU_HTML::Source::HTML_Environment.new(particulars).tuned_file_instructions - @file=SiSU_Env::FileOp.new(@md) - @fnb=@md.fnb - @lex_button=%{SiSU home -->} - @doc_details =< 

#{@md.title.full}

#{@md.author}

-WOK - @make=SiSU_Env::ProcessingSettings.new(@md) - end - def create - head_banner=SiSU_HTML_Format::HeadToc.new(@md) - minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") - stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet - if @make.build.manifest_minitoc? - toc='
' + minitoc + '
' - div_class='content' - else - toc='' - div_class='content0' - end - top_band=if @make.build.html_top_band? - head_banner.concordance_navigation_band - else '' - end - < - - - - - SiSU created WordIndex for: #{@md.title.full} - - - - - - - - #{stylesheet.css_head_seg} - - - #{top_band} - #{toc} -
- #{@doc_details} -

Word index links are to html versions of the text the segmented version followed by the scroll (single document) version.
[For segmented text references [T1], [T2] or [T3] appearing without a link, indicates that the word appears in a title (or subtitle) of the text (that is identifiable by the appended object citation number).]

-

(The word listing/index is Case sensitive: Capitalized words appear before lower case)

-

- word (number of occurences)
linked references to word within document
- [if number of occurences exceed number of references - word occurs more than once in at least one reference. Footnote/endnotes are either assigned to the paragraph from which they are referenced or ignored, so it is relevant to check the footnotes referenced from within a paragraph as well.] -

-

- (After the page is fully loaded) you can jump directly to a word by appending a hash (#) and the word to the url for this text, (do not forget that words are case sensitive, and may be listed twice (starting with and without an upper case letter)), #your_word # [ http://[web host]/#{@fnb}/concordance.html#your_word ] -

-WOK - end - end - class Word - @@word_previous='' - def initialize(word,freq) - @word,@freq=word,freq - end - def html - w=if @word.capitalize==@@word_previous - %{\n

#{@word}

(#{@freq})

\n\t

} - else n=@word.strip.gsub(/\s+/,'_') #also need to convert extended character set to html - %{\n

#{@word}

(#{@freq})

\n\t

} - end - @@word_previous=@word.capitalize - w - end - end - class Words - require_relative 'i18n' # i18n.rb - include SiSU_i18n - require_relative 'html_format' # html_format.rb - include SiSU_HTML_Format - require_relative 'se' # se.rb - include SiSU_Screen - @@dp=nil - def initialize(particulars) - @particulars=particulars - begin - @env,@md,@ao_array=particulars.env,particulars.md,particulars.ao_array - @file=SiSU_Env::FileOp.new(@md) - @freq=Hash.new(0) - @dp=@@dp ||=SiSU_Env::InfoEnv.new.digest.pattern - @rxp_lv1=/^#{Mx[:lv_o]}1:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv2=/^#{Mx[:lv_o]}2:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_lv3=/^#{Mx[:lv_o]}3:/ #fix @rxp_lv # Mx[:lv_o] - @rxp_title=Regexp.new("^#{Mx[:meta_o]}title#{Mx[:meta_c]}\s*(.+?)\s*$") - @rxp_t1=Regexp.new('^T1') - @rxp_t2=Regexp.new('^T2') - @rxp_t3=Regexp.new('^T3') - @rxp_excluded1=/#{Mx[:url_o]}\S+?#{Mx[:url_c]}|#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/ - @rxp_excluded0=/^(?:#{Mx[:fa_bold_o]}|#{Mx[:fa_italics_o]})?(?:to\d+|\d+| |#{Mx[:br_endnotes]}|EOF|#{Mx[:br_eof]}|thumb_\S+|snap_\S+|_+|-+|[(]?(?:ii+|iv|vi+|ix|xi+|xiv|xv|xvi+|xix|xx)[).]?|\S+?_\S+|[\d_]+\w\S+|[\w\d]{1,2}|\d{1,3}\w?|#{@dp}|[0-9a-f]{16,64}|\d{2,3}x\d{2,3}|\S{0,2}sha\d|\S{0,3}\d{4}w\d\d|\b\w\d+|\d_all\b|e\.?g\.?)(?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})?$/mi #this regex causes and cures a stack dump in ruby 1.9 !!! - @rgx_splitlist=%r{[—.,;:#{Mx[:nbsp]}-]}mi - @alph=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_arrays - @alphlst=SiSU_i18n::Alphabet.new(@md.opt.lng).hash_strings - @rgx_scanlist=%r{#{Mx[:fa_italics_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_italics_c]}|#{Mx[:fa_bold_o]}[#{@alphlst[:l]}#{@alphlst[:u]}0-9"\s]{2,12}#{Mx[:fa_bold_c]}|(?:https?|file)://\S+|<\S+?>|[#{@alphlst[:l]}#{@alphlst[:u]}]+|\w+}mi - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - end - end - def songsheet - begin - FileUtils::mkdir_p(@file.output_path.html_concordance.dir) \ - unless FileTest.directory?(@file.output_path.html_concordance.dir) - @file_concordance=File.open(@file.place_file.html_concordance.dir,'w') - map_para - rescue - SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.fns).location do - __LINE__.to_s + ':' + __FILE__ - end - ensure - @file_concordance.close - end - end - protected - def location_scroll(wordlocation,show) # not used - %{#{wordlocation}; } - end - def location_seg(wordlocation,show) - unless wordlocation.nil? - wl=wordlocation.gsub(/(.+?)\#(\d+)/, - "\\1#{@md.lang_code_insert}#{Sfx[:html]}##{Mx[:ocn_id_char]}\\2") # id="o\d+" always available; a name="\d+" not available if html strict used - case wordlocation - when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/ - %{[H]#{show}, } - when /(.+?)\#(\d+)/ - %{#{show}, } - end - end - end - def map_para - @seg,ocn=nil,nil - @word_map={} - @ao_array.each do |line| - if defined? line.ocn \ - and line.ocn.to_s =~/\d/ - if (line.is ==:heading \ - || line.is ==:heading_insert) \ - && line.ln==4 - @seg=line.name - end - ocn=line.ocn.to_s - if ocn =~/\d+/ \ - and ocn !~/^0$/ - line.obj=line.obj.gsub(/#{@rxp_excluded1}/,' ') - line.obj=line.obj.split(@rgx_splitlist).join(' ') #%take in word or other match - for word in line.obj.scan(@rgx_scanlist) #%take in word or other match - if word =~ /^([#{@alphlst[:l]}])/ - firstletter=$1 - flu=firstletter.tr(@alphlst[:l],@alphlst[:u]) - word=word.gsub(/^#{firstletter}/,flu ) - end - word=word.gsub(/#{Mx[:lnk_o]}|#{Mx[:lnk_c]}|#{Mx[:url_o]}|#{Mx[:url_c]}/,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:gl_o]}#[a-z]+#{Mx[:gl_c]}/,''). - gsub(/#{Mx[:gl_o]}#[0-9]+#{Mx[:gl_c]}/,'') - word=word.gsub(/[0-9a-f]{10,}/,' ') if word =~/[0-9]/ - word=word.gsub(/#{Mx[:br_line]}/,' '). - gsub(/^ +/,''). - gsub(/^\S$/,'') - word=nil if word.empty? - word=nil if word =~@rxp_excluded0 #watch - word=nil if word =~/^\S$/ - if word - word=word.gsub(/#{Mx[:br_nl]}|#{Mx[:br_line]}/,' '). - gsub(/#{Mx[:fa_o]}[a-z]{1,7}#{Mx[:fa_o_c]}|#{Mx[:fa_c_o]}[a-z]{1,7}#{Mx[:fa_c]}/,''). - gsub(/#{Mx[:en_a_o]}(?:\d|[*+])*|#{Mx[:en_b_o]}(?:\d|[*+])*|#{Mx[:en_a_c]}|#{Mx[:en_b_c]}/mi,''). - gsub(/#{Mx[:fa_o]}\S+?#{Mx[:fa_o_c]}/,''). - gsub(/#{Mx[:fa_c_o]}\S+?#{Mx[:fa_c]}/,''). - gsub(/<\/?\S+?>/,''). - gsub(/^\@+/,''). - strip. - gsub(/#{Mx[:tc_p]}.+/,''). - gsub(/[\.,;:"]$/,''). - gsub(/["]/,''). - gsub(/^\s*[\(]/,''). - gsub(/[\(]\s*$/,''). - gsub(/^(?:See|e\.?g\.?).+/,''). - gsub(/^\s*[.,;:]\s*/,''). - strip. - gsub(/^\(?[a-zA-Z]\)$/,''). - gsub(/^\d+(st|nd|rd|th)$/,''). - gsub(/^(\d+\.?)+$/, ''). - gsub(/#{Mx[:mk_o]}|#{Mx[:mk_c]}/,''). - gsub(/:name#\S+/,''). - gsub(/^\S$/,'') - word=nil if word =~/^\S$/ - word=nil if word =~/^\s*$/ #watch - if word - unless word =~/[A-Z][A-Z]/ \ - or word =~/\w+\s\w+/ - word=word.capitalize - end - @freq[word] +=1 - @word_map[word] ||= [] - if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/ - loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}} - unless loc_.empty? - @word_map[word] << loc_ - end - else - @word_map[word] << case line - when @rxp_lv1 then location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv2 then location_seg('T2',ocn) #fix @rxp_lv # Mx[:lv_o] - when @rxp_lv3 then location_seg('T3',ocn) #fix @rxp_lv # Mx[:lv_o] - end - end - end - end - end - end - end - end - seg='' - head=SiSU_Concordance::Source::DocTitle.new(@particulars).create - head=head.gsub(/#{Xx[:html_relative2]}/m,@file.path_rel_links.html_seg_2). - gsub(/#{Xx[:html_relative1]}/m,@file.path_rel_links.html_seg_1) - @file_concordance << head - @file_concordance << '

' - alph=@alph[:u] - alph.each {|x| @file_concordance << %{#{x}, }} - @file_concordance << '

' - letter=alph.shift - @file_concordance << %{\n

A

} - for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} - f=/^(\S)/.match(word)[1] - if letter < f.upcase - while letter < f.upcase - if alph.length > 0 - letter=alph.shift - @file_concordance << %{\n

#{letter}

} - else break - end - end - end - keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html - if keyword !~ @rxp_excluded0 - if @word_map[word][0] =~ /\d+/ - @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}} - end - @file_concordance << '

' - end - # special cases endnotes and header levels 1 - 3 - end - @file_concordance << %{
\n} # footer - if @md.opt.act[:verbose_plus][:set]==:on \ - || @md.opt.act[:maintenance][:set]==:on - SiSU_Screen::Ansi.new( - @md.opt.act[:color_state][:set], - @md.fns, - "#{@md.file.output_path.html_concordance.dir}/#{@md.file.base_filename.html_concordance}" - ).flow - end - end - end - end -end -__END__ diff --git a/lib/sisu/current/html_format.rb b/lib/sisu/current/html_format.rb deleted file mode 100644 index b350170f..00000000 --- a/lib/sisu/current/html_format.rb +++ /dev/null @@ -1,1348 +0,0 @@ -# encoding: utf-8 -=begin - -* Name: SiSU - -** Description: documents, structuring, processing, publishing, search -*** html formating, css template - -** Author: Ralph Amissah - - - -** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah, - All Rights Reserved. - -** License: GPL 3 or later: - - 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 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 . - - If you have Internet connection, the latest version of the GPL should be - available at these locations: - - - - - -** SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - -** Hompages: - - - -** Git - - - -=end -module SiSU_HTML_Format - require_relative 'html_parts' # html_parts.rb - class ParagraphNumber - def initialize(md,ocn) - @md,@ocn=md,ocn.to_s - @ocn ||='' - @make=SiSU_Env::ProcessingSettings.new(@md) - end - def ocn_display - if @make.build.ocn? - if @ocn.to_i==0 \ - or @ocn.empty? - '' - else - %{} - end - else - '' - end - end - def name - if @make.build.html_strict? \ - or @ocn==(nil || @ocn.empty?) - '' - else - %{} - end - end - def id #w3c? "tidy" complains about numbers as identifiers ! annoying - (@ocn==nil || @ocn.empty?) \ - ? '' : %{id="#{Mx[:ocn_id_char]}#{@ocn}"} - end - def goto - (@ocn==nil || @ocn.empty?) \ - ? '' : %{} - end - end - class HeadInformation - require_relative 'css' # css.rb - include SiSU_Parts_HTML - require_relative 'xml_shared' # xml_shared.rb - attr_reader :md,:rdf - def initialize(md) - @md=md - # DublinCore 1 - title - @bits=SiSU_Proj_HTML::Bits.new - @per=SiSU_HTML_Persist::Persist.new - @per.seg_name_x=SiSU_HTML::Seg.new.seg_name_x - @per.seg_name_x_tracker=SiSU_HTML::Seg.new.seg_name_x_tracker - @tocband_scroll,@tocband_segtoc=nil,nil - @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet - @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @index,@metalink='index','#metadata' - @toc=@md.file.base_filename.html_segtoc - end - def url_path_image_sys - (@o_str.dump_or_redirect?) \ - ? './image' - : "#{Xx[:html_relative2]}_sisu/image_sys" - end - def icon - def up - 'arrow_up_red.png' - end - def next - 'arrow_next_red.png' - end - def previous - 'arrow_prev_red.png' - end - def dot_clear - 'dot_clear.png' - end - def dot_white - 'dot_white.png' - end - def dot - dot_white - end - self - end - def png_nav - def toc - %{toc} - end - def pre - %{<< previous} - end - def nxt - %{next >>} - end - def dot_toc - %{^} - end - def dot_pre - %{<} - end - def dot_nxt - %{>} - end - self - end - def doc_types(page=:seg) #used in toc & seg_nav_band - wgt=SiSU_HTML_Format::Widget.new(@md) - %{ - - -
- #{wgt.manifest(page)} - #{wgt.search} -
} - end - def rdf - SiSU_XML_Tags::RDF.new(md) - end - def button_home(page=:seg) - button=%{ \n \n
\n} - if @md.make.home_button_image.is_a?(Hash) - image_path=if page==:manifest - @md.file.output_path.manifest.rel_image - elsif page==:scroll - @md.file.output_path.html_scroll.rel_image - else - @md.file.output_path.html_seg.rel_image - end - SiSU_Env::FileOp.new(@md) - button +=%{

home icon -->

\n} - elsif @md.home_button_links.is_a?(Array) - @md.home_button_links.each do |links| - button +=%{

\n #{links[:say]}\n

\n} - end - end - button +=%{
} - button - end - def html_close #moved - %{ -} - end - end - class Widget < HeadInformation - include SiSU_Parts_HTML - def initialize(md) - super(md) - @md=md - @cf_defaults=SiSU_Env::InfoProcessingFlag.new - @env=SiSU_Env::InfoEnv.new(md.fns) - @file=SiSU_Env::FileOp.new(md) - @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @make=SiSU_Env::ProcessingSettings.new(md) - end - def home - %{ -
- #{the_nav.txt_homepage} - -} - end - def scroll(text) - if @md.fns =~ /\.(?:-|ssm\.)?sst$/ - %{ - - #{text} - - -} - end - end - def seg(text) - %{ - - #{text} - - -} - end - def search - if @make.build.html_search_form? - env=SiSU_Env::InfoEnv.new(@md.fns,@md) - env.widget.search_form('sisusearch',nil,nil,true) - else '' - end - end - def manifest(page=:seg) - if @make.build.links_to_manifest? \ - and not @o_str.dump_or_redirect? - manifest_lnk=if @file.output_dir_structure.by_language_code? \ - or @file.output_dir_structure.by_filetype? - "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" - else @file.base_filename.manifest - end - if page==:manifest - manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}" - %{ - - #{the_url_decoration.xml_open}#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}#{the_url_decoration.xml_close} - -} - else - %{ - - #{the_nav.txt_manifest} - -} - end - else '' - end - end - end - class XML - end - class HeadToc < HeadInformation - def initialize(md) - super(md) - @md=md - @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @make=SiSU_Env::ProcessingSettings.new(@md) - @file=SiSU_Env::FileOp.new(@md) - end - def scroll_head_navigation_band - if @make.build.html_top_band? - < - #{make_scroll_search_form_and_manifest_link} - -WOK - %{ - - - -
- #{button_home(:scroll)} - - #{doc_types} - -   -#{the_table_close} -

} - else '' - end - end - def concordance_navigation_band - up_button=if @make.build.html_navigation? - %{

-   - #{png_nav.toc} -   -} - else '' - end - if @make.build.html_top_band? - %{ - - -} - %{
- #{button_home} - - #{doc_types} -#{up_button} -#{the_table_close} -

} - else '' - end - end - def seg_head_navigation_band(page=:seg) - if @make.build.html_navigation? - if page==:manifest - nxt=(@file.output_dir_structure.by_language_code? \ - || @file.output_dir_structure.by_filetype?) \ - ? "../html/#{@md.fnb}/toc#{@md.lang_code_insert}#{Sfx[:html]}" - : "toc#{@md.lang_code_insert}#{Sfx[:html]}" - firstseg=%{ - #{png_nav.nxt}} - elsif @md.firstseg =~/\S+/ - firstseg=%{ - #{png_nav.nxt}} - end - else '' - end - if @make.build.html_top_band? - %{ - - - -} - %{
-#{button_home(page)} - - #{doc_types(page)} - -  #{firstseg}  -#{the_table_close} -

} - else '' - end - end - def manifest_link(text) -# @file=SiSU_Env::FileOp.new(@md) if @md - %{ - #{text} - } - end - def concordance_link(text) - if @md.concord_make - %{ - - #{text} - - } - else '' - end - end - def make_scroll_search_form_and_manifest_link - wgt=SiSU_HTML_Format::Widget.new(@md) - %{

- #{the_nav.txt_doc_link} -
- - #{wgt.manifest} - #{wgt.search} -
} - end - def make_scroll_seg_pdf - seg='' - wgt=SiSU_HTML_Format::Widget.new(@md) - seg=%{

- #{the_nav.txt_toc_link} -
- -
- #{wgt.manifest} - #{wgt.search} -
} - end - def make_concordance - wgt=SiSU_HTML_Format::Widget.new(@md) - %{ - -
- #{wgt.manifest} - #{wgt.search} -
} - end - def head - rdf=SiSU_XML_Tags::RDF.new(@md) - %{ - - - - - #{@md.title.full} - - -#{rdf.metatag_html} -#{@stylesheet.css_head} - - -} - end - def concordance - if @md.concord_make - %{#{the_margin.css} -

- - Concordance - -

-#{table_close}} - else - %{#{the_margin.css} -#{table_close}} - end - end - def links_guide_vertical_open -# @file=SiSU_Env::FileOp.new(@md) if @md - %{ -