diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-03-27 21:08:22 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-03-27 21:08:22 -0400 |
commit | 5ac46db47efc453fc3c7e045ca4933a316008dc3 (patch) | |
tree | 34d67fda4d6c2494e0428b5d1229aa882ef9cffd /lib/sisu/v2/harvest_topics.rb | |
parent | sha256 (2.0.4) (diff) |
harvest (v2): add search widgets; fixes bug in harvest_topics; other minor
Diffstat (limited to 'lib/sisu/v2/harvest_topics.rb')
-rw-r--r-- | lib/sisu/v2/harvest_topics.rb | 54 |
1 files changed, 27 insertions, 27 deletions
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 += %{<a href="harvest_authors.html##{s}">#{n}</a>, } 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 <<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" @@ -301,23 +301,23 @@ module HARVEST_topics <a name="start" id="start"></a> <h1>SiSU Metadata Harvest - Topics</h1> <p>[<a href="../index.html"> HOME </a>] also see <a href="harvest_authors.html">SiSU Metadata Harvest - Authors</a></p> +<p>#{@env.widget_static.search_form}</p> <hr /> 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 << '<p>' @alph.each do |x| - a << if x =~/[0-9]/; '' - else - %{<a href="##{x}">#{x}</a>, } - end + a << (x =~/[0-9]/) \ + ? '' \ + : %{<a href="##{x}">#{x}</a>, } 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 |