From b26ce9d5a57b0d4a8eb2f7ee118fae1cd1526365 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 19 May 2012 23:19:28 -0400 Subject: v3: harvest, fix some details * harvest by filename output paths * harvest_topics, add level * harvest_topics, alternative headings, fix --- data/doc/sisu/CHANGELOG_v3 | 5 ++ lib/sisu/v3/harvest_authors.rb | 15 +++-- lib/sisu/v3/harvest_topics.rb | 137 ++++++++++++++++++++++++++--------------- 3 files changed, 103 insertions(+), 54 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 3b4fa79c..8b2f2ea7 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -21,6 +21,11 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.2.9.orig.tar.xz sisu_3.2.9-1.dsc sisu_3.2.9-1.debian.tar.gz +* v3: harvest + * harvest by filename output paths + * harvest_topics, add level + * harvest_topics, alternative headings, fix + %% 3.2.8.orig.tar.xz (2012-05-12:19/6) http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/sisu_3.2.8 http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/sisu_3.2.8-1 diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 2c541c48..c4107139 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -187,9 +187,12 @@ module SiSU_HarvestAuthors if @env.output_dir_structure.by? == :language harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/#{lng}/manifest" file="#{harvest_pth}/authors.html" - else + elsif @env.output_dir_structure.by? == :filetype harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/manifest" file="#{harvest_pth}/authors.#{lng}.html" + elsif @env.output_dir_structure.by? == :filename + harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}" + file="#{harvest_pth}/authors.#{lng}.html" end FileUtils::mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) puts "file://#{file}" @@ -235,7 +238,7 @@ module SiSU_HarvestAuthors if @env.output_dir_structure.by? == :language harvest_pth="../../#{lng}/manifest" file="#{harvest_pth}/authors.html" - else @env.output_dir_structure.by? == :filetype + elsif @env.output_dir_structure.by? == :filetype harvest_pth='.' file="#{harvest_pth}/authors.#{lng}.html" end @@ -344,14 +347,14 @@ WOK @output[lng][:html] << x works=[] a[1][:md].each do |x| - if @env.output_dir_structure.by? == :language + manifest_at=if @env.output_dir_structure.by? == :language manifest_pth="#{@env.path.output}/#{x[:file]}" - manifest_at=x[:file] + '.html' + x[:file] + '.html' elsif @env.output_dir_structure.by? == :filetype manifest_name=x[:file] - manifest_at=x[:file] + '.' + lng + '.html' + x[:file] + '.' + lng + '.html' elsif @env.output_dir_structure.by? == :filename - manifest_at="../#{x[:file]}/#{x[:page]}" + "../#{x[:file]}/#{x[:page]}" end work=[ "#{x[:date]} #{x[:title]}", %{

#{x[:date]} #{x[:title]}, #{x[:author][:authors_s]}

} ] works<<=(@output[lng][:html_mnt].class==File) \ 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 @@ -132,9 +132,6 @@ module SiSU_HarvestTopics else 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 @@ -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=%{#{hash[:title]} - #{hash[:author]}} do_string_default(lng,attrib,html) -- cgit v1.2.3