diff options
Diffstat (limited to 'lib/sisu/v0/db_import.rb')
-rw-r--r-- | lib/sisu/v0/db_import.rb | 71 |
1 files changed, 48 insertions, 23 deletions
diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index 1148ab63..b9528063 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -63,6 +63,7 @@ module SiSU_DB_import include SiSU_Param include SiSU_Screen @@dl=nil + @@hname=nil attr_accessor :tp def initialize(opt,conn='',sql_type='pg') @opt,@conn,@sql_type=opt,conn,sql_type @@ -381,7 +382,7 @@ module SiSU_DB_import @en_pls << txt.scan(/~\[[+](\d+).+?\]~/) txt.gsub!(/~\[([+]\d+).+?\]~/,'<sup>\1</sup>') end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:lev]).lev4_minus + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_minus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -405,25 +406,31 @@ module SiSU_DB_import @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::Info_env.new(@md.fns) + @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" if txt =~ /~\{.+?\}~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en << txt.scan(/~\{(\d+).+?\}~/) - txt.gsub!(/~\{(\d+).+?\}~/,'<sup>\1</sup>') + txt.gsub!(/~\{(\d+).+?\}~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\*.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_ast << txt.scan(/~\[[*](\d+).+?\]~/) - txt.gsub!(/~\[([*]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([*]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\+.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_pls << txt.scan(/~\[[+](\d+).+?\]~/) - txt.gsub!(/~\[([+]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([+]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:lev],@col[:seg]).lev4_plus + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -445,25 +452,31 @@ module SiSU_DB_import @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::Info_env.new(@md.fns) + @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" if txt =~ /~\{.+?\}~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en << txt.scan(/~\{(\d+).+?\}~/) - txt.gsub!(/~\{(\d+).+?\}~/,'<sup>\1</sup>') + txt.gsub!(/~\{(\d+).+?\}~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\*.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_ast << txt.scan(/~\[[*](\d+).+?\]~/) - txt.gsub!(/~\[([*]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([*]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\+.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_pls << txt.scan(/~\[[+](\d+).+?\]~/) - txt.gsub!(/~\[([+]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([+]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:lev],@col[:seg]).lev4_plus + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -485,25 +498,31 @@ module SiSU_DB_import @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::Info_env.new(@md.fns) + @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" if txt =~ /~\{.+?\}~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en << txt.scan(/~\{(\d+).+?\}~/) - txt.gsub!(/~\{(\d+).+?\}~/,'<sup>\1</sup>') + txt.gsub!(/~\{(\d+).+?\}~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\*.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_ast << txt.scan(/~\[[*](\d+).+?\]~/) - txt.gsub!(/~\[([*]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([*]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\+.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_pls << txt.scan(/~\[[+](\d+).+?\]~/) - txt.gsub!(/~\[([+]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([+]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end - @col[:body]=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:lev],@col[:seg]).lev4_plus + @col[:body]=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).lev4_plus special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup strip_markup(@col[:plaintext]) @@ -520,24 +539,30 @@ module SiSU_DB_import @col[:lid]+=1 txt='' txt,@col[:ocn],@col[:ocnd],@col[:ocns],@col[:digest_clean],@col[:digest_all]=(/(.+?)<~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)><([0-9a-f]{#{@@dl}}):([0-9a-f]{#{@@dl}})>/m).match(data).captures + @hname=if @col[:seg] and not @col[:seg].to_s.empty? + @@hname=@col[:seg].to_s + else @@hname + end + @env=SiSU_Env::Info_env.new(@md.fns) + @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" if txt =~ /~\{.+?\}~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en << txt.scan(/~\{(\d+).+?\}~/) - txt.gsub!(/~\{(\d+).+?\}~/,'<sup>\1</sup>') + txt.gsub!(/~\{(\d+).+?\}~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) #txt.gsub!(/~\{(\d+).+?\}~/,'^[\1]') # remove endnote, keep endnote reference number, display as, e.g. [^1] end if txt =~/~\[\*.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_ast << txt.scan(/~\[[*](\d+).+?\]~/) - txt.gsub!(/~\[([*]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([*]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if txt =~/~\[\+.+?\]~/ word_mode=txt.scan(/\S+/) endnote_range(word_mode) @en_pls << txt.scan(/~\[[+](\d+).+?\]~/) - txt.gsub!(/~\[([+]\d+).+?\]~/,'<sup>\1</sup>') + txt.gsub!(/~\[([+]\d+).+?\]~/,%{<sup><a href="#@base_url#_\\1" name="-\\1">\\1</a></sup>}) end if @sql_type=~/pg/ and txt.size > (document_clean - 1) #% examine pg build & remove limitation puts "\n\nTOO LARGE (TXT - see error log)\n\n" @@ -553,13 +578,13 @@ module SiSU_DB_import if @en_pls[0]; @en_a_plus,@en_z_plus=@en_pls[0].first,@en_pls[0].last end @col[:body]=if txt=~/<!T[h]?ยก.+?!~\d+;\w\d+;\w\d+>/ #watch - SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns]).html_table + SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).html_table elsif txt=~/<:i1>/ - SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns]).indent1 + SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).indent1 elsif txt=~/<:i2>/ - SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns]).indent2 + SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).indent2 else - SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns]).norm + SiSU_Format_Shared::CSS_Format.new(@md,txt,@col).norm end special_character_escape(@col[:body]) @col[:plaintext]=@col[:body].dup @@ -578,7 +603,7 @@ module SiSU_DB_import en,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns],en).endnote + body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,en).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -607,7 +632,7 @@ module SiSU_DB_import en,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns],en).endnote + body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,en).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) @@ -636,7 +661,7 @@ module SiSU_DB_import en,txt,digest_clean=$1,$2,$3 end @id_n+=1 - body=SiSU_Format_Shared::CSS_Format.new(txt,@col[:ocn],@col[:ocnd],@col[:ocns],en).endnote + body=SiSU_Format_Shared::CSS_Format.new(@md,txt,@col,en).endnote special_character_escape(body) special_character_escape(txt) strip_markup(txt) |