dal_idx, and concordance, letter list for navigation
authorRalph Amissah <ralph@amissah.com>
Sun, 14 Sep 2008 03:27:28 +0000 (23:27 -0400)
committerRalph Amissah <ralph@amissah.com>
Sun, 14 Sep 2008 03:27:28 +0000 (23:27 -0400)
CHANGELOG
lib/sisu/v0/concordance.rb
lib/sisu/v0/dal_idx.rb

index f066aac962b6a26b605c22be9ce5227fb7e02b16..3c345cbd9698bc2c6ba09f194ec7612cc8ea8ff8 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -41,6 +41,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_0.69.0.orig.tar.gz
     * markup adjustment, book type index introduced
     * dal, book type indexing module
 
+  * book type index and concordance, letter list for navigation
+
   * middle layer, url representation changed, downstream code affected
 
   * dummy headings removed when not used, latex/pdf, odf, html scroll
index fad91d140897e76fbf2a928e5c8d2ca5fcc9dcdc..dd4411acde9c0e494c4c806d7e6054d47c18ade3 100644 (file)
@@ -207,11 +207,11 @@ WOK
       def songsheet
         begin
           mkdir_p(@path) unless FileTest.directory?(@path)
-          @file_index_all=File.open("#@path/#{@md.fn[:concordance]}",'w')
+          @file_concordance=File.open("#@path/#{@md.fn[:concordance]}",'w')
           map_para
         rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error
         ensure
-          @file_index_all.close
+          @file_concordance.close
         end
       end
     protected
@@ -315,20 +315,33 @@ WOK
         end
         scr='<font size="1" color="#777777" face=times new roman><img border="0" height="15" width="15" src="../_sisu/image/b_doc.png" alt="Full Text">&nbsp;scroll:&nbsp;</font><font size="1" color="#222222" face=times new roman>doc#&nbsp;</font> '
         seg=''
-        @file_index_all << SiSU_Concordance::Source::Doc_title.new(@particulars).create
+        @file_concordance << SiSU_Concordance::Source::Doc_title.new(@particulars).create
+        alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
+        @file_concordance << '<p>'
+        alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>,&nbsp;}}
+        @file_concordance << '</p>'
+        letter=alph.shift
+        @file_concordance << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>}
         for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase}
+          f=/^(\S)/.match(word)[1]
+          if letter < f.upcase
+            while letter < f.upcase
+              letter=alph.shift
+              @file_concordance << %{\n<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a></p>}
+            end
+          end
           keyword=SiSU_Concordance::Source::Word.new(word,@freq[word]).html
           if keyword !~ @rxp_excluded0
             if @word_map[word][0] =~ /\d+/
               wm=[]
-              @file_index_all << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}}
+              @file_concordance << %{#{keyword}#{seg}#{@word_map[word].uniq.compact.join}}
             end
-            @file_index_all << '</p>'
+            @file_concordance << '</p>'
           end
           # special cases endnotes and header levels 1 - 3
         end
         credits=@vz.credits_sisu
-        @file_index_all << %{</div><div class="content">#{credits}<div></body>\n</html>} # footer
+        @file_concordance << %{</div><div class="content">#{credits}<div></body>\n</html>} # footer
         tell=SiSU_Screen::Ansi.new(@md.cmd,@md.fns,"#{@env.path.output_tell}/#{@md.fn[:concordance]}")
         tell.flow if @md.cmd =~/[MV]/
       end
index 9691a99704e27f5b316f988df0a469270027bc85..a5806d06142cc1bcd4f6ededf2f454cd7c3f27f5 100644 (file)
@@ -169,20 +169,20 @@ module SiSU_book_index
       @idx[:sst] << "\n\n#{Mx[:br_page_new]}"
       @idx[:sst] << "\n\n#{Mx[:lv_o]}2:#{Mx[:lv_c]}Index #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
       @idx[:sst] << "\n\n#{Mx[:lv_o]}4:idx#{Mx[:lv_c]} [Index] #{Mx[:pa_non_object_dummy_heading]} #{Mx[:id_o]}~0;0:0;x0#{Mx[:id_c]}"
-      @alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
+      alph=%W[A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]
       @idx[:html] << '<p>'
-      @alph.each {|x| @idx[:html] << %{<a href="##{x}">#{x}</a>,&nbsp;}}
+      alph.each {|x| @idx[:html] << %{<a href="##{x}">#{x}</a>,&nbsp;}}
       @idx[:html] << '</p>'
-      @letter=@alph.shift
+      letter=alph.shift
       @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>}
       the_idx.each do |i|
         i.each do |x|
           if x.class == String
             f=/^(\S)/.match(x)[1]
-            if @letter < f
-              while @letter < f
-                @letter=@alph.shift
-                @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="#{@letter}">#{@letter}</a></p>}
+            if letter < f
+              while letter < f
+                letter=alph.shift
+                @idx[:html] << %{\n<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a></p>}
               end
             end
             @idx[:sst] << %{\n\n#{Mx[:fa_bold_o]}#{x},#{Mx[:fa_bold_c]} }