root/platform/tdiary/util/tdiary-for-ruby1.9/tdiary-2.3.1.patch

Revision 23744, 7.7 kB (checked in by hsbt, 8 months ago)

fix ruby1.9 compatible.

  • index.rb

    === index.rb
    ==================================================================
     
    11#!/usr/bin/env ruby 
    22# 
    3 # index.rb $Revision: 1.35 $ 
     3# index.rb 
    44# 
    5 # Copyright (C) 2001-2006, TADA Tadashi <sho@spc.gr.jp> 
     5# Copyright (C) 2001-2008, TADA Tadashi <sho@spc.gr.jp> 
    66# You can redistribute it and/or modify it under GPL2. 
    77# 
    8 BEGIN { $defout.binmode } 
     8BEGIN { $stdout.binmode } 
    99$KCODE = 'n' 
    1010 
    1111begin 
     
    7070                        if @cgi.mobile_agent? then 
    7171                                body = conf.to_mobile( tdiary.eval_rhtml( 'i.' ) ) 
    7272                                head['charset'] = conf.mobile_encoding 
    73                                 head['Content-Length'] = body.size.to_s 
     73                                head['Content-Length'] = body.bytesize.to_s 
    7474                        else 
    7575                                require 'digest/md5' 
    7676                                body = tdiary.eval_rhtml 
     
    8080                                        body = '' 
    8181                                else 
    8282                                        head['charset'] = conf.encoding 
    83                                         head['Content-Length'] = body.size.to_s 
     83                                        head['Content-Length'] = body.bytesize.to_s 
    8484                                end 
    8585                                head['Pragma'] = 'no-cache' 
    8686                                head['Cache-Control'] = 'no-cache' 
  • plugin/00default.rb

    === plugin/00default.rb
    ==================================================================
     
    697697        mail_header = (@conf['comment_mail.header'] || '').dup 
    698698        mail_header << ":#{@conf.date_format}" unless /%[a-zA-Z%]/ =~ mail_header 
    699699        mail_header = @date.strftime( mail_header ) 
    700         mail_header = comment_mail_mime( @conf.to_mail( mail_header ) ).join( "\n " ) if /[\x80-\xff]/ =~ mail_header 
     700        mail_header = comment_mail_mime( @conf.to_mail( mail_header ) ).join( "\n " )  
    701701 
    702702        rmail = '' 
    703703        begin 
  • plugin/05referer.rb

    === plugin/05referer.rb
    ==================================================================
     
    159159 
    160160def referer_add_to_diary( diary, body ) 
    161161        return unless body 
    162         body.each do |r| 
     162        body.each_line do |r| 
    163163                count, ref = r.chomp.split( / /, 2 ) 
    164164                next unless ref 
    165165                diary.add_referer( ref.chomp, count.to_i ) 
  • plugin/ja/05referer.rb

    === plugin/ja/05referer.rb
    ==================================================================
     
    3131        <p>→<a href="#{h @update}?referer=volatile" target="referer">既存設定はこちら</a></p> 
    3232        <p><textarea name="only_volatile" cols="70" rows="10">#{h @conf.only_volatile2.join( "\n" )}</textarea></p> 
    3333        <h3 class="subtitle">#{label_referer_table}</h3> 
    34         #{"<p>リンク元リストのURLを、特定の文字列に変換する対応表を指定できます。1件につき、URLと表示文字列を空白で区切って指定します。正規表現が使えるので、URL中に現れた「(〜)」は、置換文字列中で「\\1」のような「\数字」で利用できます。</p>" unless @conf.mobile_agent?} 
     34        #{"<p>リンク元リストのURLを、特定の文字列に変換する対応表を指定できます。1件につき、URLと表示文字列を空白で区切って指定します。正規表現が使えるので、URL中に現れた「(〜)」は、置換文字列中で「\\\\1」のような「\\数字」で利用できます。</p>" unless @conf.mobile_agent?} 
    3535        <p>→<a href="#{h @update}?referer=table" target="referer">既存設定はこちら</a></p> 
    3636        <p><textarea name="referer_table" cols="70" rows="10">#{h @conf.referer_table2.collect{|a|a.join( " " )}.join( "\n" )}</textarea></p> 
    3737        HTML 
  • tdiary/defaultio.rb

    === tdiary/defaultio.rb
    ==================================================================
     
    1313                header, body = data.split( /\r?\n\r?\n/, 2 ) 
    1414                headers = {} 
    1515                if header then 
    16                         header.each do |l| 
     16                        header.each_line do |l| 
    1717                                l.chomp! 
    1818                                key, val = l.scan( /([^:]*):\s*(.*)/ )[0] 
    1919                                headers[key] = val ? val.chomp : nil 
  • tdiary/tdiary_style.rb

    === tdiary/tdiary_style.rb
    ==================================================================
     
    2222                        if lines.size > 1 then 
    2323                                if /^<</ =~ lines[0] 
    2424                                        @subtitle = lines.shift.chomp.sub( /^</, '' ) 
    25                                 elsif /^[  <]/u !~ lines[0] 
     25                                elsif /^[ <]/u !~ lines[0] 
    2626                                        @subtitle = lines.shift.chomp 
    2727                                end 
    2828                        end 
     
    190190                                if /^</ =~ section.body then 
    191191                                        r << %Q[#{section.body}] 
    192192                                elsif section.subtitle 
    193                                         r << %Q[<p>#{section.body.collect{|l|l.chomp.sub( /^[  ]/u, '')}.join( "</p>\n<p>" )}</p>\n] 
     193                                        r << %Q[<p>#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '')}.join( "</p>\n<p>" )}</p>\n] 
    194194                                else 
    195195                                        r << %Q[<p><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>] 
    196                                         r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[  ]/u, '' )}.join( "</p>\n<p>" )}</p>] 
     196                                        r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</p>\n<p>" )}</p>] 
    197197                                end 
    198198                                r << %Q[<%= section_leave_proc( Time::at( #{date.to_i} ) ) %>\n] 
    199199                                r << %Q[</div>] 
     
    211211                                if /^</ =~ section.body then 
    212212                                        r << section.body 
    213213                                elsif section.subtitle 
    214                                         r << %Q[<P>#{section.body.collect{|l|l.chomp.sub( /^[  ]/u, '' )}.join( "</P>\n<P>" )}</P>\n] 
     214                                        r << %Q[<P>#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</P>\n<P>" )}</P>\n] 
    215215                                else 
    216216                                        r << %Q[<P><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>] 
    217                                         r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[  ]/u, '' )}.join( "</P>\n<P>" )}</P>\n] 
     217                                        r << %Q[#{section.body.collect{|l|l.chomp.sub( /^[ ]/u, '' )}.join( "</P>\n<P>" )}</P>\n] 
    218218                                end 
    219219                                r << %Q[<%= section_leave_proc( Time::at( #{date.to_i} ) ) %>\n] 
    220220                        end 
  • tdiary.rb

    === tdiary.rb
    ==================================================================
     
    66You can redistribute it and/or modify it under GPL2. 
    77=end 
    88 
    9 TDIARY_VERSION = '2.3.1' 
     9TDIARY_VERSION = '2.3.1.20081115' 
    1010 
    1111$:.insert( 1, File::dirname( __FILE__ ) + '/misc/lib' ) 
    1212 
     13require 'compatible' 
    1314require 'cgi' 
    1415require 'uri' 
    1516begin 
     
    460461                        load 
    461462 
    462463                        instance_variables.each do |v| 
     464                                v = v.to_s 
    463465                                v.sub!( /@/, '' ) 
    464466                                instance_eval( <<-SRC 
    465467                                        def #{v} 
     
    660662                                cgi_conf.untaint unless @secure 
    661663                                def_vars = "" 
    662664                                variables.each do |var| def_vars << "#{var} = nil\n" end 
    663                                 eval( def_vars ) 
     665                                extend_vars = 'variables.each do |var| eval "@#{ var} = #{var} if #{var} != nil" end' 
    664666                                Safe::safe( @secure ? 4 : 1 ) do 
    665                                         eval( cgi_conf, binding, "(TDiary::Config#cgi_conf)", 1 ) 
     667                                        eval( def_vars + cgi_conf + extend_vars, binding, "(TDiary::Config#cgi_conf)", 1 ) 
    666668                                end 
    667                                 variables.each do |var| eval "@#{var} = #{var} if #{var} != nil" end 
    668669                        rescue IOError, Errno::ENOENT 
    669670                        end 
    670671                end 
     
    776777                        @subtitle_procs.taint 
    777778                        @section_leave_procs.taint 
    778779                        return Safe::safe( secure ? 4 : 1 ) do 
     780                                src.force_encoding('UTF-8') 
    779781                                eval( src, binding, "(TDiary::Plugin#eval_src)", 1 ) 
    780782                        end 
    781783                end 
  • update.rb

    === update.rb
    ==================================================================
     
    11#!/usr/bin/env ruby 
    22# 
    3 # update.rb $Revision: 1.22 $ 
     3# update.rb 
    44# 
    5 # Copyright (C) 2001-2003, TADA Tadashi <sho@spc.gr.jp> 
     5# Copyright (C) 2001-2008, TADA Tadashi <sho@spc.gr.jp> 
    66# You can redistribute it and/or modify it under GPL2. 
    77# 
    8 BEGIN { $defout.binmode } 
     8BEGIN { $stdout.binmode } 
    99$KCODE = 'n' 
    1010 
    1111begin 
     
    5555                                'status' => '200 OK', 
    5656                                'type' => 'text/html', 
    5757                                'charset' => conf.mobile_encoding, 
    58                                 'Content-Length' => body.size.to_s, 
     58                                'Content-Length' => body.bytesize.to_s, 
    5959                                'Vary' => 'User-Agent' 
    6060                        ) 
    6161                else 
     
    6464                                'status' => '200 OK', 
    6565                                'type' => 'text/html', 
    6666                                'charset' => conf.encoding, 
    67                                 'Content-Length' => body.size.to_s, 
     67                                'Content-Length' => body.bytesize.to_s, 
    6868                                'Vary' => 'User-Agent' 
    6969                        ) 
    7070                end 
Note: See TracBrowser for help on using the browser.