sisu 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/sisu +367 -0
- data/bin/sisugem +367 -0
- data/data/sisu/image/arrow_next_red.png +0 -0
- data/data/sisu/image/arrow_prev_red.png +0 -0
- data/data/sisu/image/arrow_up_red.png +0 -0
- data/data/sisu/image/b_bluebell.png +0 -0
- data/data/sisu/image/b_doc.png +0 -0
- data/data/sisu/image/b_epub.png +0 -0
- data/data/sisu/image/b_home.png +0 -0
- data/data/sisu/image/b_info.png +0 -0
- data/data/sisu/image/b_odf.png +0 -0
- data/data/sisu/image/b_pdf.png +0 -0
- data/data/sisu/image/b_search.png +0 -0
- data/data/sisu/image/b_toc.png +0 -0
- data/data/sisu/image/bullet_08.png +0 -0
- data/data/sisu/image/bullet_09.png +0 -0
- data/data/sisu/image/bullet_10.png +0 -0
- data/data/sisu/image/bullet_11.png +0 -0
- data/data/sisu/image/bullet_12.png +0 -0
- data/data/sisu/image/bullet_doc.png +0 -0
- data/data/sisu/image/bullet_red.png +0 -0
- data/data/sisu/image/dot_clear.png +0 -0
- data/data/sisu/image/dot_white.png +0 -0
- data/data/sisu/image/gplv3.png +0 -0
- data/data/sisu/image/gplv3_free_software.png +0 -0
- data/data/sisu/image/next.png +0 -0
- data/data/sisu/image/previous.png +0 -0
- data/data/sisu/image/rb7.ico +0 -0
- data/data/sisu/image/sisu.png +0 -0
- data/data/sisu/image/toctoc.png +0 -0
- data/data/sisu/version.yml +5 -0
- data/lib/sisu.rb +94 -0
- data/lib/sisu/air.rb +80 -0
- data/lib/sisu/ao.rb +590 -0
- data/lib/sisu/ao_character_check.rb +102 -0
- data/lib/sisu/ao_composite.rb +286 -0
- data/lib/sisu/ao_doc_objects.rb +565 -0
- data/lib/sisu/ao_doc_str.rb +2269 -0
- data/lib/sisu/ao_endnotes.rb +136 -0
- data/lib/sisu/ao_expand_insertions.rb +514 -0
- data/lib/sisu/ao_hash_digest.rb +174 -0
- data/lib/sisu/ao_idx.rb +422 -0
- data/lib/sisu/ao_images.rb +187 -0
- data/lib/sisu/ao_metadata.rb +86 -0
- data/lib/sisu/ao_misc_arrange.rb +207 -0
- data/lib/sisu/ao_numbering.rb +720 -0
- data/lib/sisu/ao_persist.rb +194 -0
- data/lib/sisu/ao_references.rb +502 -0
- data/lib/sisu/ao_syntax.rb +640 -0
- data/lib/sisu/cgi.rb +84 -0
- data/lib/sisu/cgi_pgsql.rb +270 -0
- data/lib/sisu/cgi_sql_common.rb +986 -0
- data/lib/sisu/cgi_sqlite.rb +244 -0
- data/lib/sisu/conf.rb +287 -0
- data/lib/sisu/constants.rb +388 -0
- data/lib/sisu/css.rb +3484 -0
- data/lib/sisu/db_columns.rb +1997 -0
- data/lib/sisu/db_create.rb +689 -0
- data/lib/sisu/db_dbi.rb +90 -0
- data/lib/sisu/db_drop.rb +207 -0
- data/lib/sisu/db_import.rb +877 -0
- data/lib/sisu/db_indexes.rb +146 -0
- data/lib/sisu/db_load_tuple.rb +323 -0
- data/lib/sisu/db_remove.rb +182 -0
- data/lib/sisu/db_select.rb +230 -0
- data/lib/sisu/db_sqltxt.rb +173 -0
- data/lib/sisu/db_tests.rb +114 -0
- data/lib/sisu/dbi.rb +166 -0
- data/lib/sisu/dbi_discrete.rb +206 -0
- data/lib/sisu/digests.rb +306 -0
- data/lib/sisu/dp.rb +1606 -0
- data/lib/sisu/dp_identify_markup.rb +161 -0
- data/lib/sisu/dp_make.rb +668 -0
- data/lib/sisu/embedded.rb +149 -0
- data/lib/sisu/errors.rb +84 -0
- data/lib/sisu/generic_parts.rb +131 -0
- data/lib/sisu/git.rb +277 -0
- data/lib/sisu/html.rb +775 -0
- data/lib/sisu/html_concordance.rb +391 -0
- data/lib/sisu/html_format.rb +1348 -0
- data/lib/sisu/html_harvest.rb +109 -0
- data/lib/sisu/html_harvest_author_format.rb +111 -0
- data/lib/sisu/html_harvest_authors.rb +466 -0
- data/lib/sisu/html_harvest_topics.rb +893 -0
- data/lib/sisu/html_lite_shared.rb +324 -0
- data/lib/sisu/html_manifest.rb +1032 -0
- data/lib/sisu/html_minitoc.rb +230 -0
- data/lib/sisu/html_parts.rb +437 -0
- data/lib/sisu/html_persist.rb +237 -0
- data/lib/sisu/html_promo.rb +440 -0
- data/lib/sisu/html_scroll.rb +235 -0
- data/lib/sisu/html_segments.rb +716 -0
- data/lib/sisu/html_shared.rb +62 -0
- data/lib/sisu/html_table.rb +64 -0
- data/lib/sisu/html_tune.rb +301 -0
- data/lib/sisu/hub.rb +277 -0
- data/lib/sisu/hub_actions.rb +1122 -0
- data/lib/sisu/hub_loop_markup_files.rb +170 -0
- data/lib/sisu/hub_options.rb +1695 -0
- data/lib/sisu/i18n.rb +702 -0
- data/lib/sisu/manpage.rb +377 -0
- data/lib/sisu/manpage_format.rb +85 -0
- data/lib/sisu/object_munge.rb +307 -0
- data/lib/sisu/prog_text_translation.rb +1702 -0
- data/lib/sisu/qrcode.rb +754 -0
- data/lib/sisu/relaxng.rb +1153 -0
- data/lib/sisu/remote.rb +246 -0
- data/lib/sisu/rexml.rb +148 -0
- data/lib/sisu/se.rb +158 -0
- data/lib/sisu/se_cleanoutput.rb +145 -0
- data/lib/sisu/se_clear.rb +105 -0
- data/lib/sisu/se_createsite.rb +273 -0
- data/lib/sisu/se_css.rb +221 -0
- data/lib/sisu/se_date.rb +92 -0
- data/lib/sisu/se_db.rb +214 -0
- data/lib/sisu/se_envcall.rb +326 -0
- data/lib/sisu/se_file_op.rb +2758 -0
- data/lib/sisu/se_filemap.rb +247 -0
- data/lib/sisu/se_get_init.rb +238 -0
- data/lib/sisu/se_hub_particulars.rb +234 -0
- data/lib/sisu/se_info_env.rb +2179 -0
- data/lib/sisu/se_info_port.rb +70 -0
- data/lib/sisu/se_info_system.rb +202 -0
- data/lib/sisu/se_load.rb +108 -0
- data/lib/sisu/se_processing.rb +659 -0
- data/lib/sisu/se_programs.rb +394 -0
- data/lib/sisu/se_remotes.rb +553 -0
- data/lib/sisu/se_standardise_lang.rb +176 -0
- data/lib/sisu/se_version.rb +174 -0
- data/lib/sisu/shared_images.rb +137 -0
- data/lib/sisu/shared_markup_alt.rb +336 -0
- data/lib/sisu/shared_metadata.rb +1361 -0
- data/lib/sisu/shared_sem.rb +156 -0
- data/lib/sisu/sisu_thor_lib.rb +407 -0
- data/lib/sisu/sitemaps.rb +224 -0
- data/lib/sisu/src_kdissert_share.rb +102 -0
- data/lib/sisu/src_po4a_share.rb +309 -0
- data/lib/sisu/src_po4a_shelf.rb +1217 -0
- data/lib/sisu/src_po4a_shelf_set.rb +297 -0
- data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
- data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
- data/lib/sisu/src_po4a_sstm.rb +135 -0
- data/lib/sisu/src_shared.rb +347 -0
- data/lib/sisu/src_sisupod_make.rb +171 -0
- data/lib/sisu/src_sisupod_sstm.rb +109 -0
- data/lib/sisu/sst_convert_markup.rb +323 -0
- data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
- data/lib/sisu/sst_from_xml.rb +178 -0
- data/lib/sisu/sst_identify_markup.rb +482 -0
- data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
- data/lib/sisu/termsheet.rb +163 -0
- data/lib/sisu/texinfo.rb +430 -0
- data/lib/sisu/texinfo_format.rb +541 -0
- data/lib/sisu/texpdf.rb +1162 -0
- data/lib/sisu/texpdf_format.rb +1689 -0
- data/lib/sisu/texpdf_parts.rb +235 -0
- data/lib/sisu/txt_asciidoc.rb +354 -0
- data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
- data/lib/sisu/txt_markdown.rb +389 -0
- data/lib/sisu/txt_markdown_decorate.rb +207 -0
- data/lib/sisu/txt_orgmode.rb +376 -0
- data/lib/sisu/txt_orgmode_decorate.rb +186 -0
- data/lib/sisu/txt_output.rb +86 -0
- data/lib/sisu/txt_plain.rb +410 -0
- data/lib/sisu/txt_plain_decorate.rb +189 -0
- data/lib/sisu/txt_read.rb +109 -0
- data/lib/sisu/txt_rst.rb +371 -0
- data/lib/sisu/txt_rst_decorate.rb +186 -0
- data/lib/sisu/txt_shared.rb +241 -0
- data/lib/sisu/txt_textile.rb +367 -0
- data/lib/sisu/txt_textile_decorate.rb +186 -0
- data/lib/sisu/update.rb +141 -0
- data/lib/sisu/urls.rb +696 -0
- data/lib/sisu/utils.rb +232 -0
- data/lib/sisu/utils_composite.rb +115 -0
- data/lib/sisu/utils_response.rb +114 -0
- data/lib/sisu/utils_screen_text_color.rb +472 -0
- data/lib/sisu/utils_spell.rb +99 -0
- data/lib/sisu/webrick.rb +191 -0
- data/lib/sisu/wikispeak.rb +375 -0
- data/lib/sisu/xhtml.rb +472 -0
- data/lib/sisu/xhtml_epub2.rb +890 -0
- data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
- data/lib/sisu/xhtml_epub2_format.rb +2272 -0
- data/lib/sisu/xhtml_epub2_persist.rb +278 -0
- data/lib/sisu/xhtml_epub2_segments.rb +599 -0
- data/lib/sisu/xhtml_epub2_tune.rb +330 -0
- data/lib/sisu/xhtml_parts.rb +183 -0
- data/lib/sisu/xhtml_shared.rb +62 -0
- data/lib/sisu/xhtml_table.rb +97 -0
- data/lib/sisu/xml_docbook5.rb +376 -0
- data/lib/sisu/xml_dom.rb +624 -0
- data/lib/sisu/xml_fictionbook2.rb +389 -0
- data/lib/sisu/xml_format.rb +865 -0
- data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
- data/lib/sisu/xml_odf_odt.rb +887 -0
- data/lib/sisu/xml_odf_odt_format.rb +674 -0
- data/lib/sisu/xml_parts.rb +191 -0
- data/lib/sisu/xml_persist.rb +126 -0
- data/lib/sisu/xml_sax.rb +521 -0
- data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
- data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
- data/lib/sisu/xml_shared.rb +665 -0
- data/lib/sisu/xml_tables.rb +261 -0
- data/lib/sisu/zap.rb +90 -0
- metadata +251 -0
@@ -0,0 +1,174 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
|
4
|
+
* Name: SiSU
|
5
|
+
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
7
|
+
*** system environment, resource control and configuration details
|
8
|
+
|
9
|
+
** Author: Ralph Amissah
|
10
|
+
<ralph@amissah.com>
|
11
|
+
<ralph.amissah@gmail.com>
|
12
|
+
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
15
|
+
All Rights Reserved.
|
16
|
+
|
17
|
+
** License: GPL 3 or later:
|
18
|
+
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
20
|
+
|
21
|
+
Copyright (C) Ralph Amissah
|
22
|
+
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
26
|
+
any later version.
|
27
|
+
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
31
|
+
more details.
|
32
|
+
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
35
|
+
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
37
|
+
available at these locations:
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
40
|
+
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
42
|
+
|
43
|
+
** SiSU uses:
|
44
|
+
* Standard SiSU markup syntax,
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
46
|
+
* Standard SiSU object citation numbering and system
|
47
|
+
|
48
|
+
** Hompages:
|
49
|
+
<http://www.jus.uio.no/sisu>
|
50
|
+
<http://www.sisudoc.org>
|
51
|
+
|
52
|
+
** Git
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/ao_hash_digest.rb;hb=HEAD>
|
55
|
+
|
56
|
+
=end
|
57
|
+
module SiSU_AO_Hash
|
58
|
+
require_relative 'shared_markup_alt.rb' #shared_markup_alt.rb
|
59
|
+
class ObjectDigest
|
60
|
+
def initialize(md,data,env=nil)
|
61
|
+
@md,@data,@env=md,data,env
|
62
|
+
@env ||=SiSU_Env::InfoEnv.new(@md.fns,@md)
|
63
|
+
end
|
64
|
+
def object_digest
|
65
|
+
# 1. clean/stripped text without any markup, paragraph, headings etc. without endnotes
|
66
|
+
# 2. endnotes clean/stripped text digest only (there may be several endnotes within a paragraph)
|
67
|
+
# 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?])
|
68
|
+
# [digests should not include other digests]
|
69
|
+
data=@data.compact
|
70
|
+
@tuned_file=[]
|
71
|
+
sha_ =@env.digest(@md.opt).type
|
72
|
+
begin
|
73
|
+
sha_ ? (require 'digest/sha2') : (require 'digest/md5')
|
74
|
+
rescue LoadError
|
75
|
+
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).error(sha_ + ' NOT FOUND')
|
76
|
+
end
|
77
|
+
data.each do |t_o|
|
78
|
+
unless t_o.obj.is_a?(Array)
|
79
|
+
t_o.obj=t_o.obj.strip
|
80
|
+
end
|
81
|
+
if (t_o.of !=:structure \
|
82
|
+
&& t_o.of !=:comment \
|
83
|
+
&& t_o.of !=:layout) \
|
84
|
+
&& t_o.ocn.is_a?(Fixnum)
|
85
|
+
case sha_
|
86
|
+
when :sha512
|
87
|
+
for hash_class in [ Digest::SHA512 ]
|
88
|
+
@tuned_file << stamped(t_o,hash_class)
|
89
|
+
end
|
90
|
+
when :sha256
|
91
|
+
for hash_class in [ Digest::SHA256 ]
|
92
|
+
@tuned_file << stamped(t_o,hash_class)
|
93
|
+
end
|
94
|
+
when :md5
|
95
|
+
for hash_class in [ Digest::MD5 ]
|
96
|
+
@tuned_file << stamped(t_o,hash_class)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
else @tuned_file << t_o unless t_o.nil?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
@tuned_file=@tuned_file.flatten
|
103
|
+
#use md5 or to create hash of each ao object including ocn, & add into to each ao object
|
104
|
+
end
|
105
|
+
def endnote_digest(data)
|
106
|
+
data.each.map do |en_plus|
|
107
|
+
case en_plus
|
108
|
+
when /#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
|
109
|
+
if en_plus =~/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/
|
110
|
+
t_o_txt,en_open,en_txt,en_close=
|
111
|
+
/(.*?)(#{Mx[:en_a_o]}|#{Mx[:en_b_o]})(.+?)(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m.
|
112
|
+
match(en_plus)[1..4]
|
113
|
+
stripped_en=SiSU_TextRepresentation::Alter.new(en_txt).strip_clean_of_markup
|
114
|
+
digest_en_strip=case @env.digest(@md.opt).type
|
115
|
+
when :sha512
|
116
|
+
Digest::SHA512.hexdigest(stripped_en)
|
117
|
+
when :sha256
|
118
|
+
Digest::SHA256.hexdigest(stripped_en)
|
119
|
+
when :md5
|
120
|
+
Digest::MD5.hexdigest(stripped_en)
|
121
|
+
else
|
122
|
+
Digest::SHA256.hexdigest(stripped_en)
|
123
|
+
end
|
124
|
+
t_o_txt +
|
125
|
+
en_open +
|
126
|
+
en_txt +
|
127
|
+
Mx[:id_o] +
|
128
|
+
digest_en_strip +
|
129
|
+
Mx[:id_c] +
|
130
|
+
en_close
|
131
|
+
else STDERR.puts "Error Exception - problem encountered with:\n#{en_plus}" #arbitrary exception, tidy up
|
132
|
+
end
|
133
|
+
else en_plus
|
134
|
+
end
|
135
|
+
end.join
|
136
|
+
end
|
137
|
+
def stamped(t_o,hash_class) #decide what hash information is most useful, is compromise necessary?
|
138
|
+
t_o.obj=SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_extra_spaces
|
139
|
+
#SiSU_TextRepresentation::Alter.new(t_o).strip_clean_of_markup #check
|
140
|
+
#SiSU_TextRepresentation::Alter.new(t_o).semi_revert_markup #check
|
141
|
+
#SiSU_TextRepresentation::ModifiedTextPlusHashDigest.new(@md,t_o).composite.dgst #check
|
142
|
+
unless t_o.is==:code
|
143
|
+
case t_o.obj
|
144
|
+
when /#{Mx[:en_a_o]}[\d*+]+\s+.+?#{Mx[:en_a_c]}|#{Mx[:en_b_o]}[*+]\d+\s+.+?#{Mx[:en_b_c]}/m
|
145
|
+
en_and_t_o_digest=[]
|
146
|
+
t_o.obj=t_o.obj.
|
147
|
+
gsub(/\s*(#{Mx[:en_a_c]}|#{Mx[:en_b_c]})/m,' \1') #watch
|
148
|
+
t_o_plus_en=t_o.obj.
|
149
|
+
scan(/.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/m)
|
150
|
+
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
|
151
|
+
/(?:.*?#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}|.*?#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]})+.*/m.match(t_o.obj)[1]
|
152
|
+
else ''
|
153
|
+
end
|
154
|
+
t_o_plus_en << t_o_tail
|
155
|
+
en_and_t_o_digest << endnote_digest(t_o_plus_en)
|
156
|
+
en_and_t_o_digest.join(' ')
|
157
|
+
else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil?
|
158
|
+
end
|
159
|
+
else #@tuned << t_o + Mx[:id_o] + digest_strip + ':' + digest_all + Mx[:id_c] unless t_o.nil?
|
160
|
+
end
|
161
|
+
t_o #KEEP intact
|
162
|
+
end
|
163
|
+
def strip_clean_extra_spaces(s) # ao output tuned
|
164
|
+
s=s.dup
|
165
|
+
s=s.gsub(/[ ]+([,.;:?](?:$|\s))/,'\1') unless s =~/#{Mx[:en_a_o]}|#{Mx[:en_b_o]}/
|
166
|
+
s=s.gsub(/ [ ]+/,' ').
|
167
|
+
gsub(/^ [ ]+/,'').
|
168
|
+
gsub(/ [ ]+$/,'').
|
169
|
+
gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2').
|
170
|
+
gsub(/((?:#{Mx[:fa_bold_c]}|#{Mx[:fa_italics_c]})')[ ]+(s )/,'\1\2')
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
__END__
|
data/lib/sisu/ao_idx.rb
ADDED
@@ -0,0 +1,422 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
=begin
|
3
|
+
|
4
|
+
* Name: SiSU
|
5
|
+
|
6
|
+
** Description: documents, structuring, processing, publishing, search
|
7
|
+
*** system environment, resource control and configuration details
|
8
|
+
|
9
|
+
** Author: Ralph Amissah
|
10
|
+
<ralph@amissah.com>
|
11
|
+
<ralph.amissah@gmail.com>
|
12
|
+
|
13
|
+
** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
|
14
|
+
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
|
15
|
+
All Rights Reserved.
|
16
|
+
|
17
|
+
** License: GPL 3 or later:
|
18
|
+
|
19
|
+
SiSU, a framework for document structuring, publishing and search
|
20
|
+
|
21
|
+
Copyright (C) Ralph Amissah
|
22
|
+
|
23
|
+
This program is free software: you can redistribute it and/or modify it
|
24
|
+
under the terms of the GNU General Public License as published by the Free
|
25
|
+
Software Foundation, either version 3 of the License, or (at your option)
|
26
|
+
any later version.
|
27
|
+
|
28
|
+
This program is distributed in the hope that it will be useful, but WITHOUT
|
29
|
+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
30
|
+
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
31
|
+
more details.
|
32
|
+
|
33
|
+
You should have received a copy of the GNU General Public License along with
|
34
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
35
|
+
|
36
|
+
If you have Internet connection, the latest version of the GPL should be
|
37
|
+
available at these locations:
|
38
|
+
<http://www.fsf.org/licensing/licenses/gpl.html>
|
39
|
+
<http://www.gnu.org/licenses/gpl.html>
|
40
|
+
|
41
|
+
<http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
|
42
|
+
|
43
|
+
** SiSU uses:
|
44
|
+
* Standard SiSU markup syntax,
|
45
|
+
* Standard SiSU meta-markup syntax, and the
|
46
|
+
* Standard SiSU object citation numbering and system
|
47
|
+
|
48
|
+
** Hompages:
|
49
|
+
<http://www.jus.uio.no/sisu>
|
50
|
+
<http://www.sisudoc.org>
|
51
|
+
|
52
|
+
** Git
|
53
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
|
54
|
+
<http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/ao_idx.rb;hb=HEAD>
|
55
|
+
|
56
|
+
=end
|
57
|
+
module SiSU_AO_BookIndex
|
58
|
+
class BookIndex
|
59
|
+
def initialize(md,data,env=nil)
|
60
|
+
@md,@data,@env=md,data,env
|
61
|
+
@rgx_idx=/#{Mx[:idx_o]}(?:.+?)#{Mx[:idx_c]}\s*/
|
62
|
+
@rgx_idx_ocn_seg=/(.+?)~(\d+)~(\S+)/
|
63
|
+
@rgx_idx_ocn=/(.+?)~(\d+)/
|
64
|
+
@env ||=SiSU_Env::InfoEnv.new(@md.fns)
|
65
|
+
end
|
66
|
+
def indexing_song
|
67
|
+
data=@data
|
68
|
+
data,
|
69
|
+
sisu_markup_idx_rel,
|
70
|
+
sisu_markup_idx_rel_html_seg,
|
71
|
+
html_idx,xhtml_idx=
|
72
|
+
extract_book_index(data)
|
73
|
+
data=
|
74
|
+
clean_and_insert_index(
|
75
|
+
data,
|
76
|
+
sisu_markup_idx_rel_html_seg
|
77
|
+
)
|
78
|
+
[
|
79
|
+
data,
|
80
|
+
sisu_markup_idx_rel,
|
81
|
+
sisu_markup_idx_rel_html_seg,
|
82
|
+
html_idx,
|
83
|
+
xhtml_idx,
|
84
|
+
]
|
85
|
+
end
|
86
|
+
def extract_book_index(data)
|
87
|
+
tuned_file=[]
|
88
|
+
idx_array=[]
|
89
|
+
data.each do |dob|
|
90
|
+
if (dob.is ==:heading \
|
91
|
+
|| dob.is ==:heading_insert) \
|
92
|
+
&& dob.ln==4
|
93
|
+
@seg=dob.name
|
94
|
+
end
|
95
|
+
if defined? dob.idx \
|
96
|
+
and dob.idx.is_a?(Hash)
|
97
|
+
idx_array << {
|
98
|
+
idx: dob.idx,
|
99
|
+
ocn: dob.ocn,
|
100
|
+
seg: @seg
|
101
|
+
}
|
102
|
+
end
|
103
|
+
tuned_file << dob if dob
|
104
|
+
end
|
105
|
+
if idx_array.length > 0
|
106
|
+
the_idx=construct_book_index(idx_array)
|
107
|
+
if @md.book_idx
|
108
|
+
idx=index(the_idx)
|
109
|
+
sisu_markup_idx_rel,sisu_markup_idx_rel_html_seg,html_idx, xhtml_idx=
|
110
|
+
idx[:sst_rel], idx[:sst_rel_html_seg], idx[:html],idx[:xhtml]
|
111
|
+
else
|
112
|
+
sisu_markup_idx_rel=
|
113
|
+
sisu_markup_idx_rel_html_seg=
|
114
|
+
html_idx=
|
115
|
+
xhtml_idx=
|
116
|
+
nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
[
|
120
|
+
tuned_file,
|
121
|
+
sisu_markup_idx_rel,
|
122
|
+
sisu_markup_idx_rel_html_seg,
|
123
|
+
html_idx,
|
124
|
+
xhtml_idx,
|
125
|
+
]
|
126
|
+
end
|
127
|
+
def construct_book_index(idx_array)
|
128
|
+
the_idx={}
|
129
|
+
idx_array.each do |idx|
|
130
|
+
idx[:idx].each_pair do |term,term_info|
|
131
|
+
location=(term_info[:plus].to_i > 0) \
|
132
|
+
? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + term_info[:plus].to_i}})
|
133
|
+
: idx[:ocn].to_s
|
134
|
+
the_idx[term]={} \
|
135
|
+
unless the_idx[term] \
|
136
|
+
and defined? the_idx[term]
|
137
|
+
the_idx[term]['node_0_terms']=[] \
|
138
|
+
unless the_idx[term]['node_0_terms'] \
|
139
|
+
and defined? the_idx[term]['node_0_terms']
|
140
|
+
the_idx[term]['node_0_terms'] << { ocn: idx[:ocn], range: location, seg: idx[:seg] }
|
141
|
+
if term_info[:sub].is_a?(Array) \
|
142
|
+
and term_info[:sub].length > 0
|
143
|
+
term_info[:sub].each do |y|
|
144
|
+
y.each_pair do |subterm,subterm_info|
|
145
|
+
location=(subterm_info[:plus].to_i > 0) \
|
146
|
+
? (%{#{idx[:ocn]}-#{idx[:ocn].to_i + subterm_info[:plus].to_i}})
|
147
|
+
: idx[:ocn].to_s
|
148
|
+
the_idx[term]={} \
|
149
|
+
unless the_idx[term] \
|
150
|
+
and defined? the_idx[term]
|
151
|
+
the_idx[term]['node_0_terms']=[] \
|
152
|
+
unless the_idx[term]['node_0_terms']\
|
153
|
+
and defined? the_idx[term]['node_0_terms']
|
154
|
+
the_idx[term]['node_1_subterms']={} \
|
155
|
+
unless the_idx[term]['node_1_subterms'] \
|
156
|
+
and defined? the_idx[term]['node_1_subterms']
|
157
|
+
the_idx[term]['node_1_subterms'][subterm]=[] \
|
158
|
+
unless the_idx[term]['node_1_subterms'][subterm] \
|
159
|
+
and defined? the_idx[term]['node_1_subterms'][subterm]
|
160
|
+
the_idx[term]['node_1_subterms'][subterm] <<
|
161
|
+
{ ocn: idx[:ocn], range: location, seg: idx[:seg] }
|
162
|
+
end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
the_idx=the_idx.sort
|
168
|
+
the_idx
|
169
|
+
end
|
170
|
+
def clean_xml(str)
|
171
|
+
str=str.gsub(/&/,'&')
|
172
|
+
str
|
173
|
+
end
|
174
|
+
def index(the_idx)
|
175
|
+
@x=1
|
176
|
+
idx={}
|
177
|
+
idx[:sst_rel_html_seg],idx[:sst_rel],idx[:html],idx[:xhtml]=
|
178
|
+
[], [], [], []
|
179
|
+
h={
|
180
|
+
obj: Mx[:br_page]
|
181
|
+
}
|
182
|
+
o=SiSU_AO_DocumentStructure::ObjectLayout.new.break(h)
|
183
|
+
idx[:sst_rel_html_seg] << o
|
184
|
+
idx[:sst_rel] << o
|
185
|
+
h={
|
186
|
+
lv: '1',
|
187
|
+
name: 'index',
|
188
|
+
obj: "Index"
|
189
|
+
}
|
190
|
+
o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
|
191
|
+
idx[:sst_rel_html_seg] << o
|
192
|
+
idx[:sst_rel] << o
|
193
|
+
h={
|
194
|
+
lv: '4',
|
195
|
+
name: 'idx',
|
196
|
+
obj: " [Index] #{Mx[:pa_non_object_dummy_heading]}"
|
197
|
+
}
|
198
|
+
o=SiSU_AO_DocumentStructure::ObjectHeading.new.heading(h)
|
199
|
+
idx[:sst_rel_html_seg] << o
|
200
|
+
idx[:sst_rel] << o
|
201
|
+
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]
|
202
|
+
idx[:html] << '<p>'
|
203
|
+
idx[:xhtml] << '<p>'
|
204
|
+
alph.each do |x|
|
205
|
+
if x =~/[0-9]/
|
206
|
+
idx[:html] << ''
|
207
|
+
idx[:xhtml] << ''
|
208
|
+
else
|
209
|
+
idx[:html] <<
|
210
|
+
%{<a href="##{x}">#{x}</a>,#{$ep[:hsp]}}
|
211
|
+
idx[:xhtml] <<
|
212
|
+
%{<a href="##{x.downcase}">#{x}</a>,#{$ep[:hsp]}}
|
213
|
+
end
|
214
|
+
end
|
215
|
+
idx[:html] << '</p>'
|
216
|
+
idx[:xhtml] << '</p>'
|
217
|
+
letter=alph.shift
|
218
|
+
idx[:html] <<
|
219
|
+
%{\n<p class="book_index_lev1"><a name="numeral"></a></p>}
|
220
|
+
idx[:xhtml] <<
|
221
|
+
%{\n<p class="letter" id="numeral">0 - 9</p>}
|
222
|
+
the_idx.each do |i|
|
223
|
+
i.each do |x|
|
224
|
+
if x.is_a?(String)
|
225
|
+
f=/^(\S)/.match(x)[1]
|
226
|
+
if letter < f
|
227
|
+
while letter < f
|
228
|
+
if alph.length > 0
|
229
|
+
letter=alph.shift
|
230
|
+
idx[:html] <<
|
231
|
+
%{\n<p class="letter"><a name="#{letter}">#{letter}</a></p><p class="book_index_lev1"><a name="#{letter.downcase}"> </a></p>}
|
232
|
+
idx[:xhtml] <<
|
233
|
+
%{\n<p class="letter" id="#{letter.downcase}">#{letter}</p>}
|
234
|
+
else break
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
idx[:sst_rel_html_seg] <<
|
239
|
+
%{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} }
|
240
|
+
idx[:sst_rel] <<
|
241
|
+
%{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} }
|
242
|
+
aname=x.gsub(/\s+/,'_')
|
243
|
+
idx[:html] <<
|
244
|
+
%{\n<p class="book_index_lev1"><a name="#{aname}"><b>#{x}</b></a>, }
|
245
|
+
c=clean_xml(x.dup)
|
246
|
+
idx[:xhtml] <<
|
247
|
+
%{\n<p class="book_index_lev1"><b>#{c}</b>, }
|
248
|
+
@o=idx[:sst_rel_html_seg].index(idx[:sst_rel_html_seg].last)
|
249
|
+
@t=idx[:sst_rel].index(idx[:sst_rel].last)
|
250
|
+
@q=idx[:html].index(idx[:html].last)
|
251
|
+
@r=idx[:xhtml].index(idx[:xhtml].last)
|
252
|
+
print "\n" + x + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
253
|
+
elsif x.is_a?(Array)
|
254
|
+
p 'array error? -->'
|
255
|
+
print x
|
256
|
+
elsif x.is_a?(Hash)
|
257
|
+
if x['node_0_terms'].is_a?(Array)
|
258
|
+
x['node_0_terms'].each do |a|
|
259
|
+
if a[:range]
|
260
|
+
idx[:sst_rel_html_seg][@o]=
|
261
|
+
idx[:sst_rel_html_seg][@o] +
|
262
|
+
%{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}/#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, }
|
263
|
+
idx[:sst_rel][@t]=
|
264
|
+
idx[:sst_rel][@t] +
|
265
|
+
%{#{Mx[:lnk_o]}#{a[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, }
|
266
|
+
idx[:html][@q]=
|
267
|
+
idx[:html][@q] +
|
268
|
+
%{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:range]}</a>, }
|
269
|
+
idx[:xhtml][@q]=
|
270
|
+
idx[:xhtml][@q] +
|
271
|
+
%{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:range]}</a>, }
|
272
|
+
print a[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
273
|
+
elsif a[:ocn]
|
274
|
+
idx[:sst_rel_html_seg][@o]=
|
275
|
+
idx[:sst_rel_html_seg][@o] +
|
276
|
+
%{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:seg]}.html##{a[:ocn]}#{Mx[:rel_c]}, }
|
277
|
+
idx[:sst_rel][@t]=
|
278
|
+
idx[:sst_rel][@t] +
|
279
|
+
%{#{Mx[:lnk_o]}#{a[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{a[:ocn]}#{Mx[:rel_c]}, }
|
280
|
+
idx[:html][@q]=
|
281
|
+
idx[:html][@q] +
|
282
|
+
%{<a href="#{a[:seg]}.html##{a[:ocn]}">#{a[:ocn]}</a>, }
|
283
|
+
idx[:xhtml][@q]=
|
284
|
+
idx[:xhtml][@q] +
|
285
|
+
%{<a href="#{a[:seg]}.xhtml#o#{a[:ocn]}">#{a[:ocn]}</a>, }
|
286
|
+
print a[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
287
|
+
else p 'error'
|
288
|
+
end
|
289
|
+
end
|
290
|
+
idx[:html][@q]=idx[:html][@q] + '</p>'
|
291
|
+
idx[:xhtml][@r]=idx[:xhtml][@r] + '</p>'
|
292
|
+
end
|
293
|
+
if x['node_1_subterms']
|
294
|
+
x['node_1_subterms'].sort.each do |k,y|
|
295
|
+
if k !~/node_0_terms/
|
296
|
+
idx[:sst_rel_html_seg][@o]=
|
297
|
+
idx[:sst_rel_html_seg][@o] +
|
298
|
+
%{#{k}, }
|
299
|
+
idx[:sst_rel][@t]=
|
300
|
+
idx[:sst_rel][@t] +
|
301
|
+
%{#{k}, }
|
302
|
+
idx[:html][@q]=
|
303
|
+
idx[:html][@q] +
|
304
|
+
%{\n<p class="book_index_lev2">#{k}, }
|
305
|
+
c=clean_xml(k.dup)
|
306
|
+
idx[:xhtml][@r]=
|
307
|
+
idx[:xhtml][@r] +
|
308
|
+
%{\n<p class="book_index_lev2">#{c}, }
|
309
|
+
print "\n\t" + k + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
310
|
+
y.each do |z|
|
311
|
+
if z[:range]
|
312
|
+
idx[:sst_rel_html_seg][@o]=
|
313
|
+
idx[:sst_rel_html_seg][@o] +
|
314
|
+
%{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, }
|
315
|
+
idx[:sst_rel][@t]=
|
316
|
+
idx[:sst_rel][@t] +
|
317
|
+
%{#{Mx[:lnk_o]}#{z[:range]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, }
|
318
|
+
idx[:html][@q]=
|
319
|
+
idx[:html][@q] +
|
320
|
+
%{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:range]}</a>, }
|
321
|
+
idx[:xhtml][@q]=
|
322
|
+
idx[:xhtml][@q] +
|
323
|
+
%{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:range]}</a>, }
|
324
|
+
print z[:range] + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
325
|
+
elsif z[:ocn]
|
326
|
+
idx[:sst_rel_html_seg][@o]=
|
327
|
+
idx[:sst_rel_html_seg][@o] +
|
328
|
+
%{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:seg]}.html##{z[:ocn]}#{Mx[:rel_c]}, }
|
329
|
+
idx[:sst_rel][@t]=
|
330
|
+
idx[:sst_rel][@t] +
|
331
|
+
%{#{Mx[:lnk_o]}#{z[:ocn]}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{z[:ocn]}#{Mx[:rel_c]}, }
|
332
|
+
idx[:html][@q]=
|
333
|
+
idx[:html][@q] +
|
334
|
+
%{<a href="#{z[:seg]}.html##{z[:ocn]}">#{z[:ocn]}</a>, }
|
335
|
+
idx[:xhtml][@q]=
|
336
|
+
idx[:xhtml][@q] +
|
337
|
+
%{<a href="#{z[:seg]}.xhtml#o#{z[:ocn]}">#{z[:ocn]}</a>, }
|
338
|
+
print z[:ocn] + ', ' if @md.opt.act[:verbose_plus][:set]==:on
|
339
|
+
else p 'error'
|
340
|
+
end
|
341
|
+
end
|
342
|
+
idx[:html][@q]=idx[:html][@q] + '</p>'
|
343
|
+
idx[:xhtml][@r]=idx[:xhtml][@r] + '</p>'
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
@x +=1
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
351
|
+
print "\n" if @md.opt.act[:verbose_plus][:set]==:on
|
352
|
+
idx
|
353
|
+
end
|
354
|
+
def screen_print(the_idx)
|
355
|
+
the_idx.each do |i|
|
356
|
+
i.each do |x|
|
357
|
+
if x.is_a?(String)
|
358
|
+
print "\n" + x + ', '
|
359
|
+
elsif x.is_a?(Array)
|
360
|
+
p 'array error? -->'
|
361
|
+
print x
|
362
|
+
elsif x.is_a?(Hash)
|
363
|
+
if x['node_0_terms'].is_a?(Array)
|
364
|
+
x['node_0_terms'].each do |a|
|
365
|
+
if a[:range]
|
366
|
+
print a[:range] + ', '
|
367
|
+
elsif a[:ocn]
|
368
|
+
print a[:ocn] + ', '
|
369
|
+
else p 'error'
|
370
|
+
end
|
371
|
+
end
|
372
|
+
end
|
373
|
+
if x['node_1_subterms']
|
374
|
+
x['node_1_subterms'].sort.each do |k,y|
|
375
|
+
if k !~/node_0_terms/
|
376
|
+
print "\n\t" + k + ', '
|
377
|
+
y.each do |z|
|
378
|
+
if z[:range]
|
379
|
+
print z[:range] + ', '
|
380
|
+
elsif z[:ocn]
|
381
|
+
print z[:ocn] + ', '
|
382
|
+
else p 'error'
|
383
|
+
end
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
end
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
end
|
392
|
+
def output_idx(idx)
|
393
|
+
if @md.book_idx
|
394
|
+
path="#{@env.path.output}/#{@md.fnb}"
|
395
|
+
Dir.mkdir(path) unless FileTest.directory?(path)
|
396
|
+
puts "#{path}/#{@md.fn[:book_idx_html]} #{__FILE__}::#{__LINE__}"
|
397
|
+
html_index_file=File.new("#{path}/#{@md.fn[:book_idx_html]}",'w')
|
398
|
+
idx[:html].each {|x| html_index_file << x }
|
399
|
+
html_index_file.close
|
400
|
+
end
|
401
|
+
end
|
402
|
+
def clean_and_insert_index(data,sisu_markup_idx)
|
403
|
+
tuned_file=[]
|
404
|
+
data.each do |dob|
|
405
|
+
tuned_file << dob
|
406
|
+
if dob.obj =~/#{Mx[:br_endnotes]}/ \
|
407
|
+
and sisu_markup_idx
|
408
|
+
sisu_markup_idx.each do |idx|
|
409
|
+
tuned_file << idx
|
410
|
+
end
|
411
|
+
end
|
412
|
+
end
|
413
|
+
tuned_file
|
414
|
+
end
|
415
|
+
def clean_index(data) #check on use of dob
|
416
|
+
data.each.map do |para|
|
417
|
+
para.gsub(/\n*#{@rgx_idx}/m,'')
|
418
|
+
end
|
419
|
+
end
|
420
|
+
end
|
421
|
+
end
|
422
|
+
__END__
|