diff options
26 files changed, 253 insertions, 369 deletions
diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 751247a1..40cd979b 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -38,6 +38,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.3.3.orig.tar.xz    * .is_a?(X) replaces .class==X (& for some defined? and nil? tests)    * remove javascript holders js_ (not used) +* v3: some fixes, cleaning, removing +  * v3: sisu -v, provide version information, fix  * v3: options, opt_act, limit calls diff --git a/data/doc/sisu/markup-samples/sisu_manual/_sisu/image/ruby_logo.png b/data/doc/sisu/markup-samples/sisu_manual/_sisu/image/ruby_logo.png Binary files differnew file mode 100644 index 00000000..829e2458 --- /dev/null +++ b/data/doc/sisu/markup-samples/sisu_manual/_sisu/image/ruby_logo.png diff --git a/lib/sisu/v3/concordance.rb b/lib/sisu/v3/concordance.rb index a7581112..84245643 100644 --- a/lib/sisu/v3/concordance.rb +++ b/lib/sisu/v3/concordance.rb @@ -134,7 +134,7 @@ WOK            div_class='content0'          end          top_band=if make.build.html_top_band? -          head_banner.concordance_navigation_band('pdf') +          head_banner.concordance_navigation_band          else ''          end          <<WOK diff --git a/lib/sisu/v3/defaults.rb b/lib/sisu/v3/defaults.rb index 6a082813..0b1c4d6c 100644 --- a/lib/sisu/v3/defaults.rb +++ b/lib/sisu/v3/defaults.rb @@ -77,9 +77,6 @@ module SiSU_Viz      def html_hardspace        ' '      end -    #% php -    def php_persist -    end      def semantic_tags        def default          { @@ -714,8 +711,6 @@ module SiSU_Viz      def paragraph_table        %{<p align="left"><font #{font_small} #{font_color} #{font_face}>}      end -    def paragraph_table_xml -    end      def paragraph_tiny        %{<p class="tiny">}      end diff --git a/lib/sisu/v3/epub.rb b/lib/sisu/v3/epub.rb index f3b94e3d..a4dce6ab 100644 --- a/lib/sisu/v3/epub.rb +++ b/lib/sisu/v3/epub.rb @@ -142,7 +142,6 @@ module SiSU_EPUB        def tuned_file_instructions          @tell=SiSU_Screen::Ansi.new(@md.opt.cmd)          @md.opt.cmd=@md.opt.cmd.gsub(/H/,'h') -        @md.file_type='html' if @md.opt.cmd =~/[hon]/          directories          dal_array=@particulars.dal_array # dal file drawn here          @tuned_file_array=SiSU_EPUB_Tune::Tune.new(dal_array,@md).songsheet @@ -490,10 +489,6 @@ module SiSU_EPUB          dochead=dochead.gsub(/toc\.(html)/,'doc.\1') #kludge          toc_shared << dochead #<< ads.div.major          segtoc << format_head_toc.head #<< ads.div.major -        if SiSU_EPUB_Format::HeadToc.method_defined? :toc_head_escript -          toc_shared << format_head_toc.toc_head_escript -          segtoc << format_head_toc.toc_head_escript -        end          if defined? @md.rights.all \          and @md.rights.all            rights=format_head_toc.rights.all @@ -504,8 +499,6 @@ module SiSU_EPUB            prefix_b=format_head_toc.prefix_b            prefix_b=SiSU_EPUB_Tune::CleanXHTML.new(prefix_b).clean          end -        seg_toc_band=format_head_toc.seg_head_navigation_band -        seg_toc_band_bottom=format_head_toc.seg_head_navigation_band_bottom          tmp_head=nil          doc_title_endnote=@md.title.full.gsub(/(\*+)/,'<sup><a href="#endnotes">\1</a></sup>')          tmp_head=doc_title_endnote + "\n" @@ -522,7 +515,6 @@ module SiSU_EPUB            toc_shared << format_txt_obj.center_bold            segtoc << format_txt_obj.center_bold          end -        segtoc << seg_toc_band          tmp_head=nil          if defined? @md.prefix_a \          and @md.prefix_a @@ -553,7 +545,6 @@ module SiSU_EPUB            segtoc << prefix_b          end          #Segtoc tail added here -        segtoc << seg_toc_band_bottom          segtoc << format_head_toc.xhtml_close          segtoc=segtoc.flatten.compact #watch          SiSU_EPUB::Source::Output.new(@md,segtoc).segtoc @@ -667,14 +658,14 @@ module SiSU_EPUB        def segtoc          begin            if @make.build.toc? -            filename_html_index=@make_file.epub.xhtml_index +            filename_xhtml=@make_file.epub.xhtml_index              @output.each do |para|                para=para.strip                unless para =~/\A\s*\Z/ -                filename_html_index.puts para,"\n" +                filename_xhtml.puts para,"\n"                end              end -            filename_html_index.close +            filename_xhtml.close            end          rescue            SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error do diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index ab6f34c7..70636fb1 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1233,7 +1233,7 @@ WOK      end      def doc_type_xhtml  <<WOK -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='utf-8'?>  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">  <html xmlns="http://www.w3.org/1999/xhtml"> @@ -1277,7 +1277,7 @@ WOK        #simple, make sure full-path of rootfile points to metadata.opf        #epub_metadata.opf content.opf        <<WOK -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='utf-8'?>  <container version="1.0"    xmlns="urn:oasis:names:tc:opendocument:xmlns:container">    <rootfiles> @@ -1298,7 +1298,7 @@ WOK      #{dob.obj} -      #{@md.html_title}    </title> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />  #{@css.xhtml_epub}  </head>  #{@vz.color_body} @@ -1435,7 +1435,7 @@ WOK        end        def package_open          <<WOK -<?xml version="1.0" encoding="UTF-8"?> +<?xml version='1.0' encoding='utf-8'?>  <package xmlns="http://www.idpf.org/2007/opf" unique-identifier="EPB-UUID" version="2.0">  WOK        end @@ -1658,25 +1658,10 @@ WOK        end        self      end -    def toc_head_escript -    end -    def seg_head_escript -    end      def table_close        %{  </font>  #{@vz.table_close}}      end -    def buttons_home -      %{<!- home and index buttons -!> -  #{@vz.banner_home_and_index_buttons} -<!- home and index buttons -!>} -    end -    def copyat -      %{<p class="tiny">copy @ -  <a href="#{@vz.url_home}"> -    #{@vz.txt_home} -  </a></p>} -    end      def xhtml_close      %{#{@vz.credits_sisu_epub}    </body> @@ -1689,22 +1674,6 @@ WOK        @md=md        @tocband_segtoc=make_seg      end -    def seg_head_navigation_band -      firstseg=%{<a href="#{@md.firstseg}#{Sfx[:epub_xhtml]}" target="_top"> -      #{@vz.epub_png_nav_nxt} -    </a>} if @md.firstseg =~/\S+/ -      DISABLE[:epub][:internal_navigation] \ -      ? '' -      : %{<p class="align_right">#{firstseg}</p>} -    end -    def seg_head_navigation_band_bottom -      firstseg=%{<a href="#{@md.firstseg}#{Sfx[:epub_xhtml]}" target="_top"> -      #{@vz.epub_png_nav_nxt} -    </a>} if @md.firstseg =~/\S+/ -      DISABLE[:epub][:internal_navigation] \ -      ? '' -      : %{<p class="align_right">#{firstseg}</p>} -    end      def manifest_link(text)    %{ <a href="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}" target="_top">#{text}</a>}      end @@ -1719,7 +1688,7 @@ WOK      def head        %{#{doc_type}  <head> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />  #{@css.xhtml_epub}  </head>  #{@vz.color_body}} @@ -1804,7 +1773,7 @@ WOK      #{@seg_name_xhtml[@seg_name_xhtml_tracker]} -      #{@md.html_title}    </title> -<meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> +<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />  #{@css.xhtml_epub}  </head>  #{@vz.color_body}} diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 7c044425..1846584a 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -117,7 +117,7 @@ module SiSU_HarvestAuthors          if para=~ rgx[:date]            @date=rgx[:date].match(para)[1]          end -        break if @title and @subtitle and @author and @date +        break if @title && @subtitle && @author && @date        end        @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title        if @title \ @@ -354,6 +354,7 @@ WOK                  x[:file] + '.' + lng +  '.html'                elsif @env.output_dir_structure.by? == :filename                  "../#{x[:file]}/#{x[:page]}" +              else '' #error                end                work=[ "#{x[:date]} #{x[:title]}", %{<p class="publication">#{x[:date]} <a href="#{manifest_at}">#{x[:title]}</a>, #{x[:author][:authors_s]}</p>} ]                works<<=(@output[lng][:html_mnt].is_a?(File)) \ diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 952f1411..445d8c8e 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -118,7 +118,7 @@ module SiSU_HarvestTopics          if para=~ rgx[:author]            @author_format=rgx[:author].match(para)[1]          end -        break if @title and @subtitle and @author and @idx_lst +        break if @title && @subtitle && @author && @idx_lst        end        @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title        if @title \ @@ -324,7 +324,7 @@ module SiSU_HarvestTopics                      else                        @the_h[x0][x1][x2] ||={}                      end -                    #puts '  '*2 + x2   +                    #puts '  '*2 + x2                      if extract >= 3                        y.each_pair do |x3,y|                          if extract == 3 @@ -333,7 +333,7 @@ module SiSU_HarvestTopics                          else                            @the_h[x0][x1][x2][x3] ||={}                          end -                        #puts '  '*3 + x3   +                        #puts '  '*3 + x3                          if extract == 4                            y.each_pair do |x4,y|                              if extract == 4 @@ -342,14 +342,14 @@ module SiSU_HarvestTopics                              else                                @the_h[x0][x1][x2][x3][x4] ||={}                              end -                            #puts '  '*4 + x4   +                            #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   +                                #puts '  '*5 + x5                                end                              end                            end @@ -502,7 +502,7 @@ module SiSU_HarvestTopics            if y.is_a?(Hash)              if y.has_key?(:md)                y[:md].each do |x| -                #do_hash(lng,attrib,x) #lv==0 ?  +                #do_hash(lng,attrib,x) #lv==0 ?                  #puts '  '*5 + x[:title]                end              end diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index b4fd96ba..132394d6 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -528,8 +528,6 @@ WOK          ads=SiSU_HTML_Promo::Ad.new(@md)          toc_shared << dochead << ads.div.major          @segtoc << format_head_toc.head << ads.div.major -        toc_shared << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript -        @segtoc << format_head_toc.toc_head_escript if SiSU_HTML_Format::HeadToc.method_defined? :toc_head_escript          if @make.build.html_top_band?            toc_shared << format_head_toc.scroll_head_navigation_band          end @@ -609,8 +607,7 @@ WOK        end        def publish          scroll=[] -        hr='<center><hr width=90% /></center>' -        scroll << @scr_toc << '<div class="scroll">' << hr << @scr_body << @scr_endnotes << hr << @scr_owner_details << '</div>' << @scr_tails +        scroll << @scr_toc << '<div class="scroll">' << @scr_body << @scr_endnotes << @scr_owner_details << '</div>' << @scr_tails          scroll=scroll.flatten.compact #watch        end      end diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb index 433652e0..fa9ac462 100644 --- a/lib/sisu/v3/html_format.rb +++ b/lib/sisu/v3/html_format.rb @@ -135,7 +135,7 @@ module SiSU_HTML_Format      end      def png_nav        def toc -        %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.up}" alt="TOC" />} +        %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.up}" alt="toc" />}        end        def pre          %{<img border="0" width="22" height="22" src="#{url_path_image_sys}/#{icon.previous}" alt="<< previous" />} @@ -745,42 +745,6 @@ WOK  <tr><td valign="top">    <font size="2">}      end -    def heading_advert_local_1 -      dir=SiSU_Env::InfoEnv.new(@fns) -      %{  <center> -<table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> -<tr><td align="center" bgcolor="white"> -  <a href="http://#{@md.ad_url}#{Sfx[:html]}" target="_top"> -    <img border="0" src="#{dir.url.images_local}/#{@md.ad_png}" alt="#{@md.ad_alt}"> -  </a> -  <p /> -#{@vz.table_close} -</center>} -    end -    def heading_advert_local_2 -      dir=SiSU_Env::InfoEnv.new(@fns) -      %{  <center> -<table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> -<tr><td align="center" bgcolor="white"> -  <a href="#{@md.ad_url}#{Sfx[:html]}" target="_top"> -    <img border="0" src="#{dir.url.images_local}/#{@md.ad_png}" alt="#{@md.ad_alt}"> -  </a> -  <p /> -#{@vz.table_close} -</center>} -    end -    def heading_advert_external -      dir=SiSU_Env::InfoEnv.new(@fns) -      %{  <center> -<table summary="image" border="0" cellpadding="3" cellspacing="0" align="center"> -<tr><td align="center" bgcolor="white"> -  <a href="#{@md.ad_url}#{Sfx[:html]}" target="external"> -    <img border="0" src="#{dir.url.images_local}/#{@md.ad_png}" alt="#{@md.ad_alt}"> -  </a> -  <p /> -#{@vz.table_close} -</center>} -    end      def credit        %{  <div class="main_column"> @@ -1033,16 +997,14 @@ WOK        end        para_form_css('p','norm')      end -    def break -      @txt=@txt.gsub(/#{Mx[:br_page_new]}|#{Mx[:br_page]}/,'<hr /><br />'). -        gsub(/#{Mx[:br_obj]}/,'<hr style="width:30%" /><br />') -      para_form_css('p','norm') -    end      def format(tag,attrib)        para_form_css(tag,attrib)      end      def heading_normal(tag,attrib) -      %{ +      section_break=(tag=~/h[1-4]/) \ +      ? '<p><hr width=90% /></p>' +      : '' +      %{#{section_break}  <div class="substance">    #{@p_num.ocn_display}    <#{tag} class="#{attrib}" #{@p_num.id}>#{@p_num.name} diff --git a/lib/sisu/v3/html_scroll.rb b/lib/sisu/v3/html_scroll.rb index 8e9b6e11..170285cf 100644 --- a/lib/sisu/v3/html_scroll.rb +++ b/lib/sisu/v3/html_scroll.rb @@ -125,14 +125,22 @@ module SiSU_HTML_Scroll              end            elsif dob.is==:heading_insert              x=if dob.ln==1 -              sto.heading_body1 +              unless dob.obj.empty? +                sto.heading_body1 +              end              elsif dob.ln==2 -              sto.heading_body2 +              unless dob.obj.empty? +                sto.heading_body2 +              end              elsif dob.ln==3 -              sto.heading_body3 +              unless dob.obj.empty? +                sto.heading_body3 +              end              elsif dob.ln==4 \              and dob.obj !~/^(?:Endnotes|Index|Metadata|Manifest)$/ -              sto.heading_body4 +              unless dob.obj.empty? +                sto.heading_body4 +              end              elsif dob.ln==4 \              and dob.obj=='Endnotes'                sto.heading_body4 @@ -141,19 +149,18 @@ module SiSU_HTML_Scroll              and dob.obj=='Index'                sto.heading_body4                book_idx=SiSU_Particulars::CombinedSingleton.instance.get_idx_html(@md.opt).html_idx -              book_idx.each do |x| #takes book index prepared for segments and strips segment identifying info +              book_idx.each do |x| #takes book index prepared for segments & strips segment identifying info                  x=x.gsub(/<a href="\S+?\.html#(\d+)">(\1(?:-\d+)?)<\/a>/,'<a href="#\1">\2</a>')                end                book_idx.join("\n") -            #elsif dob.ln==4 \ -            #and dob.obj=~/Meta/ -            #p __LINE__ -            ##and dob.obj=='Metadata' -            #metadata=SiSU_Metadata::Summary.new(@md).xhtml.metadata              elsif dob.ln==5 -              sto.heading_body5 +              unless dob.obj.empty? +                sto.heading_body5 +              end              elsif dob.ln==6 -              sto.heading_body6 +              unless dob.obj.empty? +                sto.heading_body6 +              end              end            elsif dob.is==:para              if dob.indent \ @@ -187,14 +194,13 @@ module SiSU_HTML_Scroll            elsif dob.is==:table              sto.table            elsif dob.is==:break -            sto.break            end            if dob =~/<a name="n\d+">/ \            and dob =~/^(?:\^~\d+\s|<!e[:_]\d+!>)/ # hmmm re-adjusted 200507, for alt endnote which should again be matched ^~ ... not in response to problem though              dob=''            end -          unless @rcdc; @scr[:body] << para_html unless para_html =~/\A\s*\Z/ -          else          #@scr[:metadata] << dob.obj +          unless @rcdc +            @scr[:body] << para_html unless para_html =~/\A\s*\Z/            end          end        end diff --git a/lib/sisu/v3/html_segments.rb b/lib/sisu/v3/html_segments.rb index 14c13d36..81bb08d4 100644 --- a/lib/sisu/v3/html_segments.rb +++ b/lib/sisu/v3/html_segments.rb @@ -370,7 +370,6 @@ module SiSU_HTML_Seg          else ''          end          @@seg[:tocband_bannerless] << '<br />' << conditional_div_close << format_head_seg.navigation_band_bottom(@@segtocband,@@seg[:dot_nav]) -        @@seg[:headings] << format_head_seg.seg_head_escript if SiSU_HTML_Format::HeadSeg.method_defined? :seg_head_escript #debug PHP move up in text #bug          if @title_banner_            @@seg[:headings] << format_head_seg.title_banner(@md.title.main,@md.title.sub,@author).gsub(clean,'')          end @@ -472,7 +471,6 @@ module SiSU_HTML_Seg          elsif dob.is==:table            sto.table          elsif dob.is==:break -          sto.break          end          if @md.flag_separate_endnotes            dob.obj=dob.obj.gsub(/"\s+href="#_(\d+)">/,%{" href=\"endnotes#{Sfx[:html]}#_\\1">})       #endnote- twice #removed file type diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 8a67ce10..2e0fb92c 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -215,13 +215,10 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on        SiSU_Screen::Ansi.new(@opt.cmd,@@n_do,'Termsheet(s) processed').term_sheet_title unless @opt.act[:quiet][:set] ==:on      end      def webrick                                            # -W -      port=prt=@fns -      prt=if prt !~/\d+/ -        'webrick default (sysenv)' -      else "webrick port set to #{prt}" -      end +      prt=SiSU_Env::InfoEnv.new(@fns).port.webrick_port        puts %{#{@cX.blue}<<#{@cX.off}#{@cX.green}Start Webrick web server on port: #{prt}#{@cX.off}#{@cX.blue}>> #{@cX.off*2} } -      system("sisu_webrick #{port}&\n") +      require_relative 'webrick' +      SiSU_Webserv::WebrickStart.new      end      def not_found        puts "\n#{@cX.fuschia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.cmd} processing skipped\n" diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index fdacf164..c2490837 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -87,7 +87,7 @@ module SiSU_Manifest            url_html="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}"            @opt.cmd=~/[MVvz]/ \            ? SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"#{xbrowser} #{url_html}").green_hi_blue -          : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}] #{@opt.fno}").grey_title_hi +          : SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}]", "#{url_html}").grey_title_grey_blue            SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i          end          data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions @@ -111,7 +111,7 @@ module SiSU_Manifest          @base_url="#{@env.url.root}/#{@fnb}"          @o_str=SiSU_Env::FileOp.new(md).output_dir_structure          @image_path=if @o_str.dump_or_redirect? -          %{./image} +          './image'          else            %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys}          end @@ -225,7 +225,7 @@ module SiSU_Manifest          end        end        def metadata(id,info) -        info=info.to_s.gsub(/#{Mx[:br_line]}/,'<br />') +        info=info.to_s.gsub(/(?:#{Mx[:br_line]}|\\)+/,'<br />')          @manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{id}:</p></th><td><p class="left">#{info}</p></td></tr>\n}        end        def links(url,lnk,target) diff --git a/lib/sisu/v3/manpage_format.rb b/lib/sisu/v3/manpage_format.rb index 8698ee40..a102b094 100644 --- a/lib/sisu/v3/manpage_format.rb +++ b/lib/sisu/v3/manpage_format.rb @@ -76,11 +76,6 @@ module SiSU_ManpageFormat    class FormatTextObject      def initialize(md,dob)        @md,@dob=md,dob -if @dob.class==Hash -  puts __FILE__ + ' ' + __LINE__.to_s #+ "-->\n" + caller.inspect -elsif @dob.class==String -  puts __FILE__ + ' ' + __LINE__.to_s #+ "-->\n" + caller.inspect -end        rgx=/#{Mx[:en_a_o]}[\d*+]+\s+(.+?)#{Mx[:en_a_c]}/        @dob.obj.gsub!(rgx,'\1') if @dob.obj =~rgx        @vz=SiSU_Env::GetInit.instance.skin diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index ba2864fd..39c392a9 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -57,7 +57,7 @@  =end  module SiSU_Commandline -  require "pathname" +  require 'pathname'    require_relative 'sysenv'                             # sysenv.rb    @@base_path=nil    class Options @@ -216,7 +216,7 @@ module SiSU_Commandline              if x =~/^(?:https?|file):\/\/\S+/ #\              end              pwd=Dir.pwd -            fn_pod=x.gsub(/.+?([^\/]+)\.txz$/,'\1') +            fn_pod=x.gsub(/([^\/]+)\.txz$/,'\1')              fullname=@env.processing_path.processing + '/sisupod/' + fn_pod              pt=Pathname.new(fullname)              FileUtils::mkdir_p(pt.to_s) @@ -224,7 +224,7 @@ module SiSU_Commandline              options=s.gsub(/(\s+--?\S+)+.+/,'\1')              system("                chdir #{fullname} -              tar xaf #{x} +              tar xaf #{pwd}/#{x}                chdir #{pwd}              ")              Dir.chdir(pt.realpath.to_s + '/sisupod/doc') diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 64baf271..492b8044 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -554,36 +554,36 @@ module SiSU_Param              and copyright.translation \              and not copyright.translation.empty?                v=sep(copyright.translation) -              s +='<br> translation ' + copyright.translation + v +              s +='\\\\ translation ' + copyright.translation + v              end              if defined? copyright.illustrations \              and copyright.illustrations \              and not copyright.illustrations.empty?                v=sep(copyright.illustrations) -              s +='<br> illustrations ' + copyright.illustrations + v +              s +='\\\\ illustrations ' + copyright.illustrations + v              end              if defined? copyright.photographs \              and copyright.photographs \              and not copyright.photographs.empty?                v=sep(copyright.photographs) -              s +='<br> photographs ' + copyright.photographs + v +              s +='\\\\ photographs ' + copyright.photographs + v              end              if defined? copyright.digitization \              and copyright.digitization \              and not copyright.digitization.empty?                v=sep(copyright.digitization) -              s +='<br> digitization ' + copyright.digitization + v +              s +='\\\\ digitization ' + copyright.digitization + v              end              if defined? copyright.audio \              and copyright.audio \              and not copyright.audio.empty?                v=sep(copyright.audio) -              s +='<br> audio ' + copyright.audio + v +              s +='\\\\ audio ' + copyright.audio + v              end              if defined? copyright.license \              and copyright.license \              and not copyright.license.empty? -              s +='<br> License: ' + copyright.license +              s +='\\\\ License: ' + copyright.license              end              if s.empty?                SiSU_Screen::Ansi.new(@opt.cmd,'WARNING Document Rights information missing; provide @rights: :copyright:').warn unless @opt.cmd =~/q/ @@ -812,8 +812,8 @@ module SiSU_Param              matches=''              w.each do |x|                c=(x[1] =~/[i],/) ? :i : :s -              matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|'   -              arr_hash << {  +              matches=matches + x[0].gsub(/([${}])/,'\\\\\1') + '|' +              arr_hash << {                  match: x[0].gsub(/([${}])/,'\\\\\1'),                  replace: x[2],                  case_s: c @@ -1025,7 +1025,6 @@ module SiSU_Param        end        def links          a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) -        a        end        def notes          a=@s.split(/\n%\s.+?$|[ ]*\n[ ]*/m) @@ -1230,13 +1229,13 @@ module SiSU_Param                @notes=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).notes              when /^@links:\s+(.+?)\Z/m                                         #% * header metadata - links                doc_links=SiSU_Param::Parameters::Md.new($1.strip,@opt,@env).links -              count=1 +              a_idx=0                @links=[]                doc_links.each do |doc_link|                  if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ -                  @links[count]={} -                  @links[count][:say],@links[count][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] -                  count +=1 +                  @links[a_idx]={} +                  @links[a_idx][:say],@links[a_idx][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] +                  a_idx +=1                  end                end                @lnk=@links @@ -1397,6 +1396,12 @@ module SiSU_Param              @sem_tag=true if para=~/[:;]\{.+?\}[:;][a-z+]/ #refix later            end          end                                                                    #% here endeth the document loop +        unless @make +          if @opt.cmd =~/[VM]/ +            SiSU_Screen::Ansi.new(@opt.cmd,'@make:','header absent').warn +          end +          @make=SiSU_Param::Parameters::Md.new('@make: ',@opt,@env).make +        end          if @ec[:image].length > 0            @ec[:image]=@ec[:image].flatten.uniq            @ec[:image].delete_if {|x| x =~/https?:\/\// } @@ -1491,7 +1496,7 @@ module SiSU_Param              @dgst_skin=skin ? (@sys.md5(skin)) : nil            end          end -        @publisher ||= "#@@publisher (this copy)" +        @publisher ||= "#{@@publisher} (this copy)"          fn_set_lang=SiSU_Env::StandardiseLanguage.new(@opt.lng).language          unless @language[:code] \          and @language[:name] diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index 3908a1d4..0d126266 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -117,16 +117,18 @@ module SiSU_QRcode        def output_metadata          fn=@f.base_filename.manifest_txt          mn='' -        if @md.opt =~/M/ +        if @md.opt.cmd =~/M/            pt=@f.output_path.manifest.dir            fn=@f.base_filename.manifest_txt            manifest=@f.write_file.manifest_txt          end          @manifest[:txt].each do |x| -          manifest << x if @md.opt =~/M/ +          x=x.gsub(/\\\\/m,"\n") +          puts x if @md.opt.cmd =~/V/ +          manifest << x if @md.opt.cmd =~/M/            mn += x          end -        manifest.close if @md.opt =~/M/ +        manifest.close if @md.opt.cmd =~/M/          #system(%{          #  cat  #{pt}/#{fn} | qrencode -s 3 -o qrcm.autonomy_markup0.png          #}) diff --git a/lib/sisu/v3/screen_text_color.rb b/lib/sisu/v3/screen_text_color.rb index cef15585..a9c0b367 100644 --- a/lib/sisu/v3/screen_text_color.rb +++ b/lib/sisu/v3/screen_text_color.rb @@ -73,7 +73,7 @@ module SiSU_Screen          @use_color=(flag.color) \          ? ((@cmd =~/c/) ? false : true)          : ((@cmd =~/c/) ? true : false) -        if @cmd =~/k/ then @use_color=false +        if @cmd =~/k/ then @use_color=false # useful color off switch, however, k may be used for something else in future          end        else @use_color=false        end @@ -249,13 +249,6 @@ module SiSU_Screen          %{#{@cX.off} } +          %{#{@cX.cyan}nav only: #{@txt[4]}#{@cX.off}.}      end -    def php_numbers -      puts %{  #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.cyan}files processed#{@cX.off}. } + -        %{php_scr only: #{@txt[1]}, } + -        %{#{@cX.cyan}php_seg only: #{@txt[2]}#{@cX.off}, } + -        %{joint php scroll & seg: #{@txt[3]}, } + -        %{php_nav only: #{@txt[4]}} -    end      def txt_white        puts "\t#{@cX.white}#{@txt[0]}#{@cX.off} #{@cX.white}#{@txt[1]}#{@cX.off}"      end @@ -343,6 +336,9 @@ module SiSU_Screen      def grey_title_hi        puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}      end +    def grey_title_grey_blue +      puts %{#{@cX.grey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.grey}#{@txt[1]}#{@cX.off} #{@cX.blue}#{@txt[2]}#{@cX.off}} +    end      def dark_grey_title_hi        puts %{#{@cX.darkgrey_hi}#{@cX.black}#{@txt[0]}#{@cX.off*2} #{@cX.blue}#{@txt[1]}#{@cX.off}}      end @@ -398,9 +394,6 @@ module SiSU_Screen      def html_output        puts %{\t#{@cX.grey}#{@txt[0]}#{@cX.off} #{@cX.ruby}->#{@cX.off}\n\t  #{@cX.blue}#{@txt[1]}#{@cX.off}}      end -    def php_title -      puts %{\n#{@cX.green_hi}#{@cX.black}PHP#{@cX.off*2}} -    end      def segmented        puts "\t#{@cX.grey}Seg#{@cX.off} #{@cX.green}#{@txt[0]}#{@cX.off} #{@cX.grey}segments#{@cX.off}"      end diff --git a/lib/sisu/v3/shared_images.rb b/lib/sisu/v3/shared_images.rb index c92719f6..e55f03ad 100644 --- a/lib/sisu/v3/shared_images.rb +++ b/lib/sisu/v3/shared_images.rb @@ -78,7 +78,7 @@ module SiSU_Images          end        end        def images_set -        @pwd=ENV['PWD'] +        @pwd=(/(\S+?)(?:\/(?:#{Px[:lng_lst_rgx]}))?$/).match(Dir.pwd)[1]          def copy(src_path,dest_path,images=nil)            if FileTest.directory?(src_path)              FileUtils::cd(src_path) diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 1c813fd8..40880701 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -224,10 +224,6 @@ module SiSU_Env        "#{@@home}/.sisu",        "#{@@sisu_etc}/#{SiSU_version_dir}",      ] -    @@yamlrc_path=@@rc_path -    #@@yamlrc_path=(stub_pwd !~/^sisupod$/) \ -    #? (["#{@@pwd}/_sisu/#{SiSU_version_dir}","#{@@pwd}/_sisu","#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"]) -    #: ["#{@@home}/.sisu/#{SiSU_version_dir}","#{@@home}/.sisu","#{@@sisu_etc}/#{SiSU_version_dir}"]  #security policy: prevent reading of sisurc.yml in sisupod      @@ad_path=(stub_pwd !~/^sisupod$/) \      ? ([          "#{@@pwd}/.sisu/skin/yml", @@ -236,10 +232,10 @@ module SiSU_Env          "#{@@sisu_etc}/skin/yml",        ])      : ["#{@@home}/.sisu",@@sisu_etc] -    attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:yamlrc_path,:ad_path +    attr_accessor :user,:home,:hostname,:pwd,:host,:arch,:rbver,:dir_arch,:dir_sitearch,:dir_bin,:locale,:webserv_path,:webserv_host_cgi,:webserv_port_cgi,:default_dir,:rc_path,:ad_path      def initialize -      @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@yamlrc_path,@ad_path=\ -      @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@yamlrc_path,@@ad_path +      @user,@home,@hostname,@pwd,@sisu_etc,@host,@arch,@rbver,@dir_arch,@dir_sitearch,@dir_bin,@locale,@default_dir,@rc_path,@ad_path=\ +      @@user,@@home,@@hostname,@@pwd,@@sisu_etc,@@host,@@arch,@@rbver,@@dir_arch,@@dir_sitearch,@@dir_bin,@@locale,@@default_dir,@@rc_path,@@ad_path        #note rbver is duplicated in InfoVersion      end    end @@ -297,7 +293,7 @@ module SiSU_Env      def sisu_yaml        def rc          unless @@rc -          @yamlrc_path.each do |v| +          @rc_path.each do |v|              if @@noyaml \              or FileTest.exist?("#{v}/noyaml")                STDERR.puts "WARNING - YAML loading switched off, to enable delete the file:\n\t#{v}/noyaml\n\n" unless @@noyaml @@ -2282,59 +2278,18 @@ WOK          else   defaults[:webserv_host_cgi]          end        end -      def webrick_port -        if @md \ -        and @md.opt.cmd.inspect=~/-F/ \ -        and @md.opt.mod.inspect=~/port=(\d+)/ -           $1 -        else -          if defined? @rc['webserv_cgi']['port'] -            if @rc['webserv_cgi']['port'].nil? \ -            and (defined? @md.opt.mod \ -            and not @md.opt.mod.nil? \ -            and @md.opt.mod.inspect=~/webrick/) -              defaults[:webserv_port_cgi] -            elsif not @rc['webserv_cgi']['port'].nil? -              @rc['webserv_cgi']['port'] -            else defaults[:webserv_port_cgi] -            end -          else   defaults[:webserv_port_cgi] -          end -        end -      end -      def webserv_port_cgi -        if @md \ -        and defined? @md.opt \ -        and @md.opt.cmd.inspect=~/-F/ \ -        and @md.opt.mod.inspect=~/port=(\d+)/ -           $1 -        else -          if defined? @rc['webserv_cgi']['port'] -            if @rc['webserv_cgi']['port'].nil? \ -            and (defined? @md.opt.mod \ -            and not @md.opt.mod.nil? \ -            and @md.opt.mod.inspect=~/webrick/) -              defaults[:webserv_port_cgi] -            elsif not @rc['webserv_cgi']['port'].nil? -              @rc['webserv_cgi']['port'] -            else nil -            end -          else   nil -          end -        end -      end        def webserv_cgi                                                          #web url for local webserv (localhost, or hostname)          if defined? @rc['webserv_cgi']['host'] \          and @rc['webserv_cgi']['host'].is_a?(String)            http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing -          if webserv_port_cgi -            "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}/#{@stub_pwd}" +          if port.webserv_port_cgi +            "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}/#{@stub_pwd}"            else "#{http}#{@rc['webserv_cgi']['host']}/#{@stub_pwd}"            end          else            http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') -          if webserv_port_cgi -            "#{http}#{webserv_host_base}:#{webserv_port_cgi}/#{@stub_pwd}" +          if port.webserv_port_cgi +            "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}/#{@stub_pwd}"            else "#{http}#{webserv_host_base}/#{@stub_pwd}"            end          end @@ -2343,14 +2298,14 @@ WOK          if defined? @rc['webserv_cgi']['host'] \          and @rc['webserv_cgi']['host'].is_a?(String)            http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') -          if webserv_port_cgi -            "#{http}#{@rc['webserv_cgi']['host']}:#{webserv_port_cgi}" +          if port.webserv_port_cgi +            "#{http}#{@rc['webserv_cgi']['host']}:#{port.webserv_port_cgi}"            else "#{http}#{@rc['webserv_cgi']['host']}"            end          else            http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://') -          if webserv_port_cgi -            "#{http}#{webserv_host_base}:#{webserv_port_cgi}" +          if port.webserv_port_cgi +            "#{http}#{webserv_host_base}:#{port.webserv_port_cgi}"            else "#{http}#{webserv_host_base}"            end          end @@ -2381,8 +2336,8 @@ WOK          elsif defined? @rc['webserv']['webrick_url'] \          and @rc['webserv']['webrick_url']==false            "file://#{path.webserv}" -        elsif webserv_port_cgi =~/\S+/ -          "#{url.hostname}:#{webserv_port_cgi}" +        elsif port.webserv_port_cgi =~/\S+/ +          "#{url.hostname}:#{port.webserv_port_cgi}"          else            url.hostname          end @@ -2475,6 +2430,50 @@ WOK        end        self      end +    def port +      def webrick_port +        if @md \ +        and @md.opt.cmd.inspect=~/-F/ \ +        and @md.opt.mod.inspect=~/port=(\d+)/ +           $1 +        else +          if defined? @rc['webserv_cgi']['port'] +            if @rc['webserv_cgi']['port'].nil? \ +            and (defined? @md.opt.mod \ +            and not @md.opt.mod.nil? \ +            and @md.opt.mod.inspect=~/webrick/) +              defaults[:webserv_port_cgi] +            elsif not @rc['webserv_cgi']['port'].nil? +              @rc['webserv_cgi']['port'] +            else defaults[:webserv_port_cgi] +            end +          else   defaults[:webserv_port_cgi] +          end +        end +      end +      def webserv_port_cgi +        if @md \ +        and defined? @md.opt \ +        and @md.opt.cmd.inspect=~/-F/ \ +        and @md.opt.mod.inspect=~/port=(\d+)/ +           $1 +        else +          if defined? @rc['webserv_cgi']['port'] +            if @rc['webserv_cgi']['port'].nil? \ +            and (defined? @md.opt.mod \ +            and not @md.opt.mod.nil? \ +            and @md.opt.mod.inspect=~/webrick/) +              defaults[:webserv_port_cgi] +            elsif not @rc['webserv_cgi']['port'].nil? +              @rc['webserv_cgi']['port'] +            else nil +            end +          else   nil +          end +        end +      end +      self +    end      def digest        def type          if defined? @rc['default']['digest'] \ @@ -5614,7 +5613,7 @@ WOK        @env=SiSU_Env::InfoEnv.new      end      def webrick -      @env.url.webrick_port +      @env.port.webrick_port      end    end    class InfoProgram < InfoEnv                                                #revisit @@ -6017,15 +6016,3 @@ module SiSU_Errors  end  __END__  https? intro check 2007-09-22 - -fns_array=unless fns =~/\.ssm.sst$/ -  if RUBY_VERSION < '1.9' -    IO.readlines(fns,'') -  else IO.readlines(fns,'r:utf-8') -  end -else -  if RUBY_VERSION < '1.9' -    IO.readlines("#{processing_path.composite_file}/#{fns}",'') -  else IO.readlines("#{processing_path.composite_file}/#{fns}",'r:utf-8') -  end -end diff --git a/lib/sisu/v3/texpdf_format.rb b/lib/sisu/v3/texpdf_format.rb index a7331447..2bd558bc 100644 --- a/lib/sisu/v3/texpdf_format.rb +++ b/lib/sisu/v3/texpdf_format.rb @@ -1284,8 +1284,7 @@ WOK            "\\1#{@brace_url.tex_open}\\begin{scriptsize}\\url{\\2}\\end{scriptsize}#{@brace_url.tex_close}\\3") #url matching with decoration <url> positive lookahead, sequence issue with { linked }http://url cannot use \b at start        end        str=str.gsub(/<:ee>/,''). -        gsub(/<!>/,' '). -      #proposed change, insert, but may be redundant +        gsub(/<!>/,' ').  #proposed change, insert, but may be redundant          gsub(/<(br|p)>|<\/\s*(br|p)>|<(br|p)\s*\/>/," #{Tex[:backslash]*2} "). # Work Area          gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,'\begin{bfseries}\1 \end{bfseries}').          gsub(/<h\d+>(.+?)<\/h\d+>/,'\begin{bfseries}\1 \end{bfseries}'). diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index 1dcf988f..0aba1d89 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -278,10 +278,11 @@ module SiSU_Urls      end      def urls_select        unless @opt.cmd =~/q/ -        i="(output manifest) [#{@opt.f_pth[:lng_is]}] #{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}" +        i1="[#{@opt.f_pth[:lng_is]}]" +        i2="file://#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}"          @opt.cmd=~/[MVvz]/ \          ? SiSU_Screen::Ansi.new(@opt.cmd,'URLs').green_title_hi -        : SiSU_Screen::Ansi.new(@opt.cmd,'URL',i).grey_title_hi +        : SiSU_Screen::Ansi.new(@opt.cmd,'URL (output manifest)',i1, i2).grey_title_grey_blue          SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@md.file.output_path.manifest.dir}/#{@md.file.base_filename.manifest}").flow if @opt.cmd =~/[MVv]/        end        m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m diff --git a/lib/sisu/v3/webrick.rb b/lib/sisu/v3/webrick.rb index f8189bba..96280d0c 100644 --- a/lib/sisu/v3/webrick.rb +++ b/lib/sisu/v3/webrick.rb @@ -56,77 +56,54 @@      suffixes, see man pages for options  =end -def brick(port,get='') -  cgidir=if get=~/pwd/; Dir.pwd -  else                  '/usr/lib/cgi-bin'  # @env.path.cgi -  end -  port=SiSU_Env::InfoPort.new.webrick -  begin -    s=HTTPServer.new( -      Port:         port, -      DocumentRoot: Dir::pwd + '/htdocs', -      CGIPathEnv:   ENV['PATH'] -    ) -    cgi_dir=File.expand_path(cgidir) -    @mount.each { |x,y|                                                        # mount subdirectories -      s.mount(x, HTTPServlet::FileHandler, y, true) -    } -    s.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, { FancyIndexing: true }) -    trap("INT"){ s.shutdown } -    s.start -  rescue -    SiSU_Errors::InfoError.new($!,$@,'-W',nil).error do #fix -      __LINE__.to_s + ':' + __FILE__ -    end -  ensure -  end -end -begin                                                                          #% -  require 'webrick' -    include WEBrick -  require 'time' -  require_relative 'sysenv'                             # sysenv.rb -    include SiSU_Env; include SiSU_Screen -  @cX=SiSU_Screen::Ansi.new('yes').cX -  @env=SiSU_Env::InfoEnv.new -  port=SiSU_Env::InfoPort.new -  @argv=$* -  @host=@env.url.webrick -  host='localhost' -  @port="#{@argv[0].to_i}" -  @port="#{port.webrick}" if @port =~ /^0$/ -  @serve=[] -  Dir.foreach(@env.path.webserv) do |x| -    if x !~/^\./ \ -    and FileTest.directory?("#{@env.path.webserv}/#{x}") -      @serve << x -    end -  end -  @mount=[] -  @serve.each {|x| @mount << ["/#{x}", "#{@env.path.webserv}/#{x}"]} -  @pwd=Dir.pwd -  @week=Time.now.strftime(%{%Yw%W}) -  puts "\n" -  @mount.each { |x,y| -    puts "        #{@cX.cyan}#{x}#{@cX.off}\t#{@cX.grey}see#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/wb.cgi#{@cX.off} #{@cX.ruby}@#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/#{@cX.off}" -  } -  puts "#{@cX.grey}" -  wb_s2=[] -                                                           #% writes file wb.cgi to shared directories ... -                                                           #% wb_top -  wb_top=%q(#!/usr/bin/env ruby -  # * arch-tag: webrick info on environment, mounted directories, and contents of pwd -  require 'time' -  require 'cgi' -  require 'fcgi' -  ls=Dir.entries('./') -  dir_contents=[] -  ls.each { |x| dir_contents << "<a href=\"./#{x}/\">#{x}</a><br>" unless x =~/^(\.)+$/ } -  dir_contents=dir_contents.sort.join(' ') -  #host=ENV['HOSTNAME'] -  #host=%x{echo $HOSTNAME} -  ) -  wb_s1=<<WOK +module SiSU_Webserv +  class WebrickStart +      require 'webrick' +        include WEBrick +      require 'time' +      require_relative 'sysenv'                             # sysenv.rb +        include SiSU_Env +        include SiSU_Screen +    def initialize +    begin                                                                          #% +      @cX=SiSU_Screen::Ansi.new('yes').cX +      @env=SiSU_Env::InfoEnv.new +      port=SiSU_Env::InfoPort.new +      @host=@env.url.webrick +      host='localhost' +      @port=port.webrick +      @serve=[] +      Dir.foreach(@env.path.webserv) do |x| +        if x !~/^\./ \ +        and FileTest.directory?("#{@env.path.webserv}/#{x}") +          @serve << x +        end +      end +      @mount=[] +      @serve.each {|x| @mount << ["/#{x}", "#{@env.path.webserv}/#{x}"]} +      @pwd=Dir.pwd +      @week=Time.now.strftime(%{%Yw%W}) +      puts "\n" +      @mount.each { |x,y| +        puts "        #{@cX.cyan}#{x}#{@cX.off}\t#{@cX.grey}see#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/wb.cgi#{@cX.off} #{@cX.ruby}@#{@cX.off} #{@cX.blue}#{@host}:#{@port}#{x}/#{@cX.off}" +      } +      puts "#{@cX.grey}" +      wb_s2=[] +                                                               #% writes file wb.cgi to shared directories ... +                                                               #% wb_top +      wb_top=%q(#!/usr/bin/env ruby +      # * arch-tag: webrick info on environment, mounted directories, and contents of pwd +      require 'time' +      require 'cgi' +      require 'fcgi' +      ls=Dir.entries('./') +      dir_contents=[] +      ls.each { |x| dir_contents << "<a href=\"./#{x}/\">#{x}</a><br>" unless x =~/^(\.)+$/ } +      dir_contents=dir_contents.sort.join(' ') +      #host=ENV['HOSTNAME'] +      #host=%x{echo $HOSTNAME} +      ) +      wb_s1=<<WOK    page=CGI.new "html3"    page.out { @@ -142,36 +119,66 @@ begin                                                                          #          page.p {''} +          page.p {page.b{"Webrick Served Directories: "}} +  WOK -                                                           #% wb_s2 (mounts) -  @mount.each do |x,y| wb_s2 <<<<WOK -        page.p {page.b{'<a href="#{@host}:#{@port}#{x}/">#{x}</a> '} + '<a href="#{@host}:#{@port}#{x}/">#{@host}:#{@port}#{x}</a> (mounts: #{y}/)   <a href="#{@host}:#{@port}#{x}/wb.cgi">info (wb.cgi)</a>'} + +                                                               #% wb_s2 (mounts) +      @mount.each do |x,y| wb_s2 <<<<WOK +            page.p {page.b{'<a href="#{@host}:#{@port}#{x}/">#{x}</a> '} + '<a href="#{@host}:#{@port}#{x}/">#{@host}:#{@port}#{x}</a> (mounts: #{y}/)   <a href="#{@host}:#{@port}#{x}/wb.cgi">info (wb.cgi)</a>'} +  WOK -end -                                                           #% wb_end -  wb_end=<<WOK +    end +                                                               #% wb_end +      wb_end=<<WOK          page.p {page.b{"Contents of PWD (see URL): "}} +          page.p {"#\{dir_contents}"}        }      }    }  WOK -  @mount.each { |x,y|                                      #% wb puts -    puts y -      filename=File.new("#{y}/wb.cgi",'w') -      filename << wb_top -      filename << wb_s1 -      filename << wb_s2 -      filename << wb_end -      filename.close -      FileUtils::chmod(0755,"#{y}/wb.cgi &") if FileTest.file?("#{y}/wb.cgi &") -  } -  puts "        #{@cX.off}" -  get=@argv.shift if @argv[0] =~/pwd/                      #% argv -  brick(@port,get) -rescue; -  require_relative 'sysenv'                             # sysenv.rb -  SiSU_Errors::InfoError.new($!,$@,'-W',nil).error do #fix -    __LINE__.to_s + ':' + __FILE__ +      @mount.each { |x,y|                                      #% wb puts +        puts y +          filename=File.new("#{y}/wb.cgi",'w') +          filename << wb_top +          filename << wb_s1 +          filename << wb_s2 +          filename << wb_end +          filename.close +          FileUtils::chmod(0755,"#{y}/wb.cgi &") if FileTest.file?("#{y}/wb.cgi &") +      } +      puts "        #{@cX.off}" +      #get=@argv.shift if @argv[0] =~/pwd/                      #% argv +      get=Dir.pwd +      brick(@port,get) +    rescue +      require_relative 'sysenv'                             # sysenv.rb +      SiSU_Errors::InfoError.new($!,$@,'-W',nil).error do #fix +        __LINE__.to_s + ':' + __FILE__ +      end +    ensure +    end +    end +    def brick(port,get='') +      cgidir=if get=~/pwd/; Dir.pwd +      else                  '/usr/lib/cgi-bin'  # @env.path.cgi +      end +      port=SiSU_Env::InfoPort.new.webrick +      begin +        s=HTTPServer.new( +          Port:         port, +          DocumentRoot: Dir::pwd + '/htdocs', +          CGIPathEnv:   ENV['PATH'] +        ) +        cgi_dir=File.expand_path(cgidir) +        @mount.each { |x,y|                                                        # mount subdirectories +          s.mount(x, HTTPServlet::FileHandler, y, true) +        } +        s.mount('/cgi-bin', HTTPServlet::FileHandler, cgi_dir, { FancyIndexing: true }) +        trap("INT"){ s.shutdown } +        s.start +      rescue +        SiSU_Errors::InfoError.new($!,$@,'-W',nil).error do #fix +          __LINE__.to_s + ':' + __FILE__ +        end +      ensure +      end +    end    end  ensure  end diff --git a/lib/sisu/v3/xml_format.rb b/lib/sisu/v3/xml_format.rb index 1c6aa67d..52874eb1 100644 --- a/lib/sisu/v3/xml_format.rb +++ b/lib/sisu/v3/xml_format.rb @@ -195,17 +195,9 @@ module SiSU_XML_Format        @vz=SiSU_Env::GetInit.instance.skin #margin,paragraph,table,banner,url,png,txt,color,font,nav_txt,nav_png,credits,js,php        @index='index'      end -    def toc_head_escript #embedded script in this case PHP -    end      def table_close        '</font> </td></tr></table>'      end -    def buttons_home -      %{\n#{@banner.home_and_index_buttons}\n} -    end -    def copyat -      %{copy @ <a href="#{@url.home}" #{@js.home}>#{@txt.home}</a>} -    end      def toc_head        <<WOK  <html> @@ -382,17 +374,6 @@ WOK        %{  </font>  #{@vz.table_close}}      end -    def buttons_home -      %{<!- home and index buttons -!> -  #{@vz.banner_home_and_index_buttons} -<!- home and index buttons -!>} -    end -    def copyat -      %{#{@vz.paragraph_font_tiny}copy @ -  <a href="#{@vz.url_home}"> -    #{@vz.txt_home} -  </a></font>} -    end      def html_close #moved      %{</body>  </html>} diff --git a/lib/sisu/v3/xml_tables.rb b/lib/sisu/v3/xml_tables.rb index 98dc0140..ba89e791 100644 --- a/lib/sisu/v3/xml_tables.rb +++ b/lib/sisu/v3/xml_tables.rb @@ -97,11 +97,9 @@ module SiSU_Tables          if @parablock =~/#{Mx[:tc_p]}#{Mx[:tc_p]}/u            @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,              %{<tr> -  <td width="\\1%" valign="top"> -    #{@vz.paragraph_table_xml}<b>}). +  <td width="\\1%" valign="top"><b>}).              gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u, -              %{</b></td><td width="\\1%" valign="top"> -  #{@vz.paragraph_table_xml}<b>}). +              %{</b></td><td width="\\1%" valign="top"><b>}).              gsub(/#{Mx[:tc_c]}/,"</b>\n</td>\n</tr>")            @@tablehead=0          end @@ -109,13 +107,11 @@ module SiSU_Tables        else          @parablock=@parablock.gsub(/#{Mx[:tc_o]}#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,            %{<tr> -  <td width="\\1%" valign="top"> -    #{@vz.paragraph_table_xml}}). +  <td width="\\1%" valign="top">}).            gsub(/#{Mx[:tc_p]}#{Mx[:tc_p]}(\d+?)#{Mx[:tc_p]}/u,              %{    </td> -  <td width="\\1%" valign="top"> -    #{@vz.paragraph_table_xml}}). +  <td width="\\1%" valign="top">}).            gsub(/#{Mx[:tc_c]}/,"\n</td>\n</tr>\n")        end        @parablock  | 
