diff options
Diffstat (limited to 'lib/sisu/v3/harvest_topics.rb')
-rw-r--r-- | lib/sisu/v3/harvest_topics.rb | 137 |
1 files changed, 89 insertions, 48 deletions
diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 30155e5f..f6966331 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -133,9 +133,6 @@ module SiSU_HarvestTopics name.sub(/\.ss[mt]$/,'') end page=if @env.output_dir_structure.by? == :language - #fix - end - page=if @env.output_dir_structure.by? == :language "#{lang}/sisu_manifest.html" else "sisu_manifest.#{lang}.html" @@ -165,8 +162,6 @@ module SiSU_HarvestTopics def song the_idx=construct_book_topic_keys the_hash=construct_book_topic_hash(the_idx) - #traverse_base - #traverse end def capital(txt) txt_a=txt.scan(/\S+/) @@ -179,7 +174,7 @@ module SiSU_HarvestTopics def capital_(txt) txt[0].chr.capitalize + txt[1,txt.length] end - def contents(idx) + def contents(idx,lang) names='' idx[:author][:last_first_format_a].each do |n| s=n.sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') @@ -194,28 +189,26 @@ module SiSU_HarvestTopics def capital_(txt) txt[0].chr.capitalize + txt[1,txt.length] end - def key_create(c) + def key_create(c,alt) x=nil - x=if c.length==5 + x=if c.length==6 + c[0].to_s + '|' + + capital(c[1][0].to_s) + '|' + + capital(c[2][0].to_s) + '|' + + capital(c[3][0].to_s) + '|' + + capital(alt.to_s) + elsif c.length==5 c[0].to_s + '|' + capital(c[1][0].to_s) + '|' + capital(c[2][0].to_s) + '|' + - capital(c[3][0].to_s) #+ '|' + - #((c[4].class == String) ? c[4][0] : '') + capital(alt.to_s) elsif c.length==4 c[0].to_s + '|' + capital(c[1][0].to_s) + '|' + - capital(c[2][0].to_s) #+ '|' + - #((c[3].class == String) ? c[3][0] : '') + capital(alt.to_s) elsif c.length==3 c[0].to_s + '|' + - capital(c[1][0].to_s) #+ '|' + - #((c[2].class == String) ? c[2][0] : '') - elsif c.length==2 - c[0].to_s #+ '|' + - #((c[1].class == String) ? c[1][0] : '') - elsif c.length==1 - c[0].to_s + capital(alt.to_s) end end def construct_book_topic_keys @@ -235,51 +228,54 @@ module SiSU_HarvestTopics idx_lst.each do |c| idx_a << c.scan(/[^|\n]+/m) end - idx_a << contents(idx) + idx_a << contents(idx,lang) @idx_a << [lang] + idx_a end end @idx_a.each do |c| - if c.length > 0 \ - and c.class == Array - if c[0].class == Hash - v=key_create(c) - @the_a << [v, c[0]] - end - end - if c.length > 0 \ - and c.class == Array - if c[1].class == Hash - v=key_create(c) - @the_a << [v, c[1]] if v - end - end if c.length > 1 \ and c.class == Array if c[2].class == Hash - v=key_create(c) - @the_a << [v, c[2]] if v + c[1].each do |alt| + v=key_create(c,alt) + @the_a << [v, c[2]] if v + end end end if c.length > 2 \ and c.class == Array if c[3].class == Hash - v=key_create(c) - @the_a << [v, c[3]] if v + c[2].each do |alt| + v=key_create(c,alt) + @the_a << [v, c[3]] if v + end end end if c.length > 3 \ and c.class == Array if c[4].class == Hash - v=key_create(c) - @the_a << [v, c[4]] if v + c[3].each do |alt| + v=key_create(c,alt) + @the_a << [v, c[4]] if v + end end end if c.length > 4 \ and c.class == Array if c[5].class == Hash - v=key_create(c) - @the_a << [v, c[5]] if v + c[4].each do |alt| + v=key_create(c,alt) + @the_a << [v, c[5]] if v + end + end + end + if c.length > 5 \ + and c.class == Array + if c[6].class == Hash + c[5].each do |alt| + v=key_create(c,alt) + @the_a << [v, c[6]] if v + end end end end @@ -345,8 +341,19 @@ module SiSU_HarvestTopics if extract == 4 @the_h[x0][x1][x2][x3][x4] ||={ md: [] } @the_h[x0][x1][x2][x3][x4][:md] << y + else + @the_h[x0][x1][x2][x3][x4] ||={} end #puts ' '*4 + x4 + if extract == 5 + y.each_pair do |x5,y| + if extract == 5 + @the_h[x0][x1][x2][x3][x4][x5] ||={ md: [] } + @the_h[x0][x1][x2][x3][x4][x5][:md] << y + end + #puts ' '*5 + x5 + end + end end end end @@ -376,6 +383,11 @@ module SiSU_HarvestTopics if y.class == Hash y.each_pair do |x4,y| puts ' '*4 + x4 if x4.class == String + if y.class == Hash + y.each_pair do |x5,y| + puts ' '*5 + x5 if x5.class == String + end + end end end end @@ -413,6 +425,14 @@ module SiSU_HarvestTopics end y.each_pair do |x4,y| puts ' '*4 + x4 if x4.class == String + if y.class == Hash + if y.has_key?(:md) + y[:md].each { |x| puts ' '*5 + x[:title] } + end + y.each_pair do |x5,y| + puts ' '*5 + x4 if x4.class == String + end + end end end end @@ -446,6 +466,9 @@ module SiSU_HarvestTopics elsif @env.output_dir_structure.by? == :filetype harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/manifest" file="#{harvest_pth}/topics.#{lng}.html" + elsif @env.output_dir_structure.by? == :filename + harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}" + file="#{harvest_pth}/topics.#{lng}.html" end FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) puts "file://#{file}" @@ -526,6 +549,20 @@ module SiSU_HarvestTopics do_string(lng,'lev3',x4) #puts ' '*4 + x4 end + if y.class == Hash + if y.has_key?(:md) + y[:md].each do |x| + do_hash(lng,3,x) + #puts ' '*5 + x[:title] + end + end + y.each_pair do |x5,y| + if x5.class == String + do_string(lng,'lev4',x5) + #puts ' '*5 + x5 + end + end + end end end end @@ -550,7 +587,7 @@ module SiSU_HarvestTopics authors="authors.#{lng}.html" elsif @env.output_dir_structure.by? == :filename css_path=(type !~/maintenance/) \ - ? '../_sisu/css/harvest.css' + ? './_sisu/css/harvest.css' : 'harvest.css' authors="authors.#{lng}.html" end @@ -560,7 +597,10 @@ module SiSU_HarvestTopics if @env.output_dir_structure.by? == :language harvest_pth="../../#{lng}/manifest" file="#{harvest_pth}/topics.html" - else @env.output_dir_structure.by? == :filetype + elsif @env.output_dir_structure.by? == :filetype + harvest_pth='.' + file="#{harvest_pth}/topics.#{lng}.html" + elsif @env.output_dir_structure.by? == :filename harvest_pth='.' file="#{harvest_pth}/topics.#{lng}.html" end @@ -682,12 +722,13 @@ WOK end end def do_hash_md(lng,attrib,hash) - if @env.output_dir_structure.by? == :language - manifest_at=hash[:file] + '.html' + manifest_at=if @env.output_dir_structure.by? == :language + hash[:file] + '.html' elsif @env.output_dir_structure.by? == :filetype - manifest_at=hash[:file] + '.' + lng + '.html' + hash[:file] + '.' + lng + '.html' elsif @env.output_dir_structure.by? == :filename - manifest_at="../#{hash[:file]}/#{hash[:page]}" + "./#{hash[:file]}/#{hash[:page]}" + else '' #error end html=%{<a href="#{manifest_at}">#{hash[:title]}</a> - #{hash[:author]}} do_string_default(lng,attrib,html) |