From 5ac46db47efc453fc3c7e045ca4933a316008dc3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 27 Mar 2010 21:08:22 -0400 Subject: harvest (v2): add search widgets; fixes bug in harvest_topics; other minor --- lib/sisu/v1/harvest_topics.rb | 12 ++++++---- lib/sisu/v2/harvest_authors.rb | 46 ++++++++++++++++------------------- lib/sisu/v2/harvest_topics.rb | 54 +++++++++++++++++++++--------------------- 3 files changed, 55 insertions(+), 57 deletions(-) diff --git a/lib/sisu/v1/harvest_topics.rb b/lib/sisu/v1/harvest_topics.rb index 3ebd2da6..2ac181d0 100644 --- a/lib/sisu/v1/harvest_topics.rb +++ b/lib/sisu/v1/harvest_topics.rb @@ -91,7 +91,7 @@ module HARVEST_topics idx_array=HARVEST_topics::Harvest.new(file_array,filename,idx_array).extract_harvest end the_idx=HARVEST_topics::Index.new(idx_array,@@the_idx_topics).construct_book_topic_index - #HARVEST_topics::Output_index.new(the_idx).screen_print.cycle + #HARVEST_topics::Output_index.new('',the_idx).screen_print.cycle if @opt.cmd.inspect =~/[VM]/ HARVEST_topics::Output_index.new(@opt,the_idx).html_print.html_songsheet puts "file://#{@env.path.output_md_harvest}/harvest_topics.html" puts "file://#{@env.path.pwd}/harvest_topics.html" if @opt.cmd.inspect =~/-M/ @@ -125,7 +125,9 @@ module HARVEST_topics break if @title and @subtitle and @author and @idx_lst end @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title - if @title and @author_format and @idx_list + if @title \ + and @author_format \ + and @idx_list creator=FORMAT::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if filename=~/~[a-z]{2,3}\.ss[mt]$/ @@ -141,10 +143,10 @@ module HARVEST_topics idxl=[] g.each do |i| i.strip! - idxl << { :filename => filename, :file => file, :rough_idx => i, :title => @fulltitle, :author => creator, :page => page} + idxl << { :filename =>filename,:file =>file,:rough_idx =>i,:title =>@fulltitle,:author =>creator,:page =>page} end idxl - else { :filename => filename, :file => file, :rough_idx => @idx_list, :title => @fulltitle, :author => creator, :page => page } + else { :filename =>filename,:file =>file,:rough_idx =>@idx_list,:title =>@fulltitle,:author =>creator,:page =>page} end else p "missing author field: #@filename title: #@title; author: #@author_format; idx: #@idx_list" @@ -167,7 +169,7 @@ module HARVEST_topics s=n.sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') names += %{#{n}, } end - hash << { :filename => idx[:filename], :file => idx[:file], :author => names, :title => idx[:title], :page => idx[:page] } + hash << { :filename =>idx[:filename],:file =>idx[:file],:author =>names,:title =>idx[:title],:page =>idx[:page]} end def construct_book_topic_index idx_array=@idx_array diff --git a/lib/sisu/v2/harvest_authors.rb b/lib/sisu/v2/harvest_authors.rb index 75fad6f6..33042dcf 100644 --- a/lib/sisu/v2/harvest_authors.rb +++ b/lib/sisu/v2/harvest_authors.rb @@ -69,11 +69,9 @@ module HARVEST_authors def songsheet files,idx_array=[],[] @file_list.each do |f| - if f =~/.+?\.ss[tm]$/ - files << f[/(.+?\.ss[tm])$/,1] - else - print "not .sst or .ssm ? << #{f} >> " - end + (f =~/.+?\.ss[tm]$/) \ + ? (files << f[/(.+?\.ss[tm])$/,1]) \ + : (print "not .sst or .ssm ? << #{f} >> ") end files.each do |filename| file_array=[] @@ -92,7 +90,7 @@ module HARVEST_authors the_idx=HARVEST_authors::Index.new(idx_array,@@the_idx_authors).construct_book_author_index HARVEST_authors::Output_index.new(@opt,the_idx).html_print.html_songsheet puts "file://#{@env.path.output_md_harvest}/harvest_authors.html" - puts "file://#{@env.path.pwd}/harvest_authors.html" if @opt.cmd.inspect =~/-M/ + puts "file://#{@env.path.pwd}/harvest_authors.html" if @opt.cmd.inspect =~/M/ end end class Harvest @@ -101,7 +99,7 @@ module HARVEST_authors end def extract_harvest data,filename,idx_array=@data,@filename,@idx_array - @orig_pub,@title,@subtitle,@fulltitle,@author,@author_format,@date=nil,nil,nil,nil,nil,nil,nil + @title,@subtitle,@fulltitle,@author,@author_format,@date=nil,nil,nil,nil,nil,nil @authors=[] rgx={} rgx[:author]=/^@creator:(?:[ ]+|.+?:author:[ ]+)(.+?)(?:\||\n)/m @@ -121,10 +119,10 @@ module HARVEST_authors if para=~ rgx[:date] @date=rgx[:date].match(para)[1] end - break if @title and @subtitle and @author and @date and @orig_pub + break if @title and @subtitle and @author and @date end - @fulltitle=(@subtitle ? (@title + ' - ' + @subtitle) : @title) - if @title and @author_format #and @orig_pub (publication details) + @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title + if @title and @author_format creator=FORMAT::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if filename=~/~[a-z]{2,3}\.ss[mt]$/ @@ -135,9 +133,9 @@ module HARVEST_authors filename.sub(/\.ss[mt]$/,'') end page="sisu_manifest#{lang}.html" - idx_array <<= { :filename => filename, :file => file, :orig_pub => @orig_pub, :date => @date, :title => @fulltitle, :author => creator, :page => page } + idx_array <<= { :filename => filename, :file => file, :date => @date, :title => @fulltitle, :author => creator, :page => page } else - #p "missing author field: #{@filename} title: #{@title}; author: #{@author_format}; idx: #{@orig_pub}" + #p "missing author field: #{@filename} title: #{@title}; author: #{@author_format}" end idx_array.flatten! idx_array @@ -177,10 +175,9 @@ module HARVEST_authors def html_file_open @output={} @output[:html]=File.new("#{@env.path.output_md_harvest}/harvest_authors.html",'w') - @output[:html_mnt]= if @opt.cmd.inspect =~/-M/ - File.new("#{@env.path.pwd}/harvest_authors.html",'w') - else nil - end + @output[:html_mnt]=(@opt.cmd.inspect =~/M/) \ + ? File.new("#{@env.path.pwd}/harvest_authors.html",'w') \ + : nil end def html_file_close @output[:html].close @@ -196,10 +193,9 @@ module HARVEST_authors html_file_close end def html_head_adjust(type='') - css_path=if type !~/maintenance/ - '../_sisu/css/harvest.css' - else 'harvest.css' - end + css_path=(type !~/maintenance/) \ + ? '../_sisu/css/harvest.css' \ + : 'harvest.css' sv=SiSU_Env::Info_version.instance.get_version <

SiSU Metadata Harvest - Authors

[ HOME ] also see SiSU Metadata Harvest - Topics

+

#{@env.widget_static.search_form}


WOK end def html_head - @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/-M/ + @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/M/ @output[:html] << html_head_adjust end def html_alph @@ -290,10 +287,9 @@ WOK works=[] a[1][:md].each do |x| work=[ "#{x[:date]} #{x[:title]}", %{

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

} ] - works<<=if @output[:html_mnt].class==File - work.concat([%{

[src]  #{x[:date]} #{x[:title]}, #{x[:author][:authors_s]} -- [#{x[:file]}.sst]

}]) - else work - end + works<<=(@output[:html_mnt].class==File) \ + ? (work.concat([%{

[src]  #{x[:date]} #{x[:title]}, #{x[:author][:authors_s]} -- [#{x[:file]}.sst]

}])) \ + : work end works.sort_by {|x| x[0]}.each do |x| @output[:html] << x[1] diff --git a/lib/sisu/v2/harvest_topics.rb b/lib/sisu/v2/harvest_topics.rb index cf913b80..45b14496 100644 --- a/lib/sisu/v2/harvest_topics.rb +++ b/lib/sisu/v2/harvest_topics.rb @@ -69,11 +69,9 @@ module HARVEST_topics def songsheet files,idx_array=[],[] @file_list.each do |f| - if f =~/.+?\.ss[tm]$/ - files << f[/(.+?\.ss[tm])$/,1] - else - print "not .sst or .ssm ? << #{f} >> " - end + (f =~/.+?\.ss[tm]$/) \ + ? (files << f[/(.+?\.ss[tm])$/,1]) \ + : (print "not .sst or .ssm ? << #{f} >> ") end files.each do |filename| file_array=[] @@ -87,17 +85,18 @@ module HARVEST_topics end end end - idx_array=HARVEST_topics::Harvest.new(file_array,filename,idx_array).extract_harvest + idx_array=HARVEST_topics::Harvest.new(@opt,file_array,filename,idx_array).extract_harvest end the_idx=HARVEST_topics::Index.new(idx_array,@@the_idx_topics).construct_book_topic_index + #HARVEST_topics::Output_index.new('',the_idx).screen_print.cycle if @opt.cmd.inspect =~/[VM]/ HARVEST_topics::Output_index.new(@opt,the_idx).html_print.html_songsheet puts "file://#{@env.path.output_md_harvest}/harvest_topics.html" - puts "file://#{@env.path.pwd}/harvest_topics.html" if @opt.cmd.inspect =~/-M/ + puts "file://#{@env.path.pwd}/harvest_topics.html" if @opt.cmd.inspect =~/M/ end end class Harvest - def initialize(data,filename,idx_array) - @data,@filename,@idx_array=data,filename,idx_array + def initialize(opt,data,filename,idx_array) + @opt,@data,@filename,@idx_array=opt,data,filename,idx_array end def extract_harvest data,filename,idx_array=@data,@filename,@idx_array @@ -120,10 +119,12 @@ module HARVEST_topics if para=~ rgx[:author] @author_format=rgx[:author].match(para)[1] end - break if @title and @subtitle and @author and @idx_lst #and @date + break if @title and @subtitle and @author and @idx_lst end - @fulltitle=(@subtitle ? (@title + ' - ' + @subtitle) : @title) - if @title and @author_format and @idx_list + @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title + if @title \ + and @author_format \ + and @idx_list creator=FORMAT::Author.new(@author_format.strip).author_details @authors,@authorship=creator[:authors],creator[:authorship] file=if filename=~/~[a-z]{2,3}\.ss[mt]$/ @@ -142,10 +143,10 @@ module HARVEST_topics idxl << { :filename =>filename,:file =>file,:rough_idx =>i,:title =>@fulltitle,:author =>creator,:page =>page} end idxl - else { :filename =>filename,:file =>file,:rough_idx =>@idx_list,:title =>@fulltitle,:author =>creator,:page =>page } + else { :filename =>filename,:file =>file,:rough_idx =>@idx_list,:title =>@fulltitle,:author =>creator,:page =>page} end else - p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" + p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" if @opt.cmd.inspect =~/[VM]/ end idx_array.flatten! idx_array @@ -165,7 +166,7 @@ module HARVEST_topics s=n.sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') names += %{#{n}, } end - hash << { :filename =>idx[:filename],:file =>idx[:file],:author => names,:title =>idx[:title],:page =>idx[:page] } + hash << { :filename =>idx[:filename],:file =>idx[:file],:author =>names,:title =>idx[:title],:page =>idx[:page]} end def construct_book_topic_index idx_array=@idx_array @@ -276,10 +277,9 @@ module HARVEST_topics html_file_close end def html_head_adjust(type='') - css_path=if type !~/maintenance/ - '../_sisu/css/harvest.css' - else 'harvest.css' - end + css_path=(type !~/maintenance/) \ + ? '../_sisu/css/harvest.css' \ + : 'harvest.css' sv=SiSU_Env::Info_version.instance.get_version <

SiSU Metadata Harvest - Topics

[ HOME ] also see SiSU Metadata Harvest - Authors

+

#{@env.widget_static.search_form}


WOK end def html_head - @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/-M/ + @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/M/ @output[:html] << html_head_adjust end def html_alph a=[] a << '

' @alph.each do |x| - a << if x =~/[0-9]/; '' - else - %{#{x}, } - end + a << (x =~/[0-9]/) \ + ? '' \ + : %{#{x}, } end - @output[:html_mnt] << a if @opt.cmd.inspect =~/-M/ + @output[:html_mnt] << a if @opt.cmd.inspect =~/M/ @output[:html] << a.join end def html_tail @@ -407,7 +407,7 @@ WOK if key.length > 0 key.sort.each do |m| attrib="lev#{lv}" - lv==(0 ? do_string_name(attrib,m) : do_string(attrib,m)) + lv==0 ? do_string_name(attrib,m) : do_string(attrib,m) do_case(lv,hash[m]) end end @@ -417,7 +417,7 @@ WOK case when y==String attrib="lev#{lv}" - lv==(0 ? do_string_name(attrib,a) : do_string(attrib,a)) + lv==0 ? do_string_name(attrib,a) : do_string(attrib,a) when y==Array do_array(lv,a) when y==Hash -- cgit v1.2.3