# tb-show.rb $Revision: 1.16 $ # # functions: # * show TrackBack ping URL in right of TSUKKOMI label. # * hide TrackBacks in TSUKKOMI. # * show TrackBacks above Today's Links. # # options: # @options['tb.cgi']: # the TrackBack ping URL. './tb.rb' is default. # @options['tb.hide_if_no_tb']: # If true, hide 'TrackBacks(n)' when there is no TrackBacks. Default value is false. # # Copyright (c) 2003 TADA Tadashi # You can distribute this file under the GPL. # # Modified: by Junichiro Kita # # # If you want to show TrackBack Ping URL under comment_new link, try this. # # alias :comment_new_tb_backup :comment_new # def comment_new # cgi = @options['tb.cgi'] || './tb.rb' # url = "#{cgi}/#{@tb_date.strftime( '%Y%m%d' )}" # %Q|#{comment_new_tb_backup }]
[TrackBack to #{@tb_url}| # end # # running on only non mobile mode unless @conf.mobile_agent? then # # show TrackBack ping URL # add_body_enter_proc do |date| cgi = File.basename(@options['tb.cgi'] || './tb.rb') @tb_date = date @tb_id_url = %Q|#{@conf.index}#{anchor @tb_date.strftime('%Y%m%d')}| @tb_id_url[0, 0] = @conf.base_url if %r|^https?://|i !~ @conf.index @tb_id_url.gsub!( %r|/\./|, '/' ) @tb_url = %Q|#{@conf.base_url}#{cgi}/#{@tb_date.strftime('%Y%m%d')}| '' end # # make RDF # if @mode == 'day' and not bot? then add_body_leave_proc do |date| if @tb_url and @diaries[@tb_date.strftime('%Y%m%d')] then <<-TBRDF TBRDF else '' end end end # # hide TrackBacks in TSUKKOMI # eval( <TrackBack#{count > 1 ? 's' : ''}(#{count})| unless count == 0 and @options['tb.hide_if_no_tb'] end r end def trackbacks_of_today_short( diary, limit = @conf['trackback_limit'] || 3 ) # for BlogKit only return if @plugin_files.grep(/blog_style.rb\z/).empty? fragment = 't%02d' today = anchor( diary.date.strftime( '%Y%m%d' ) ) count = 0 diary.each_visible_trackback( limit ) {|t,count|} # count up r = '' r << %Q!\t
\n! r << %Q!\t\t
\n! r << %Q!\t\t\t#{ trackback_today }#{ trackback_total( count ) }\n! if count > 0 r << %Q!\t\t\t[#{ trackback_ping_url }]\n! r << %Q!\t\t
\n! r << %Q!\t\t
\n! r << %Q!\t\t\t

Before...

\n! if count > limit diary.each_visible_trackback_tail( limit ) do |t,i| url, name, title, excerpt = t.body.split( /\n/,4 ) a = name || url a += ':' + title if title &&! title.empty? r << %Q!\t\t\t

\n! r << %Q!\t\t\t\t#{ @conf['trackback_anchor'] }\n! r << %Q!\t\t\t\t#{CGI::escapeHTML( a )}\n! r << %Q!\t\t\t\t[<%= CGI::escapeHTML( @conf.shorten( excerpt, @conf.comment_length ) ) %>]\n! if excerpt r << %Q!\t\t\t

\n! end r << %Q!\t\t
\n! r << %Q!\t
\n! r end def trackbacks_of_today_long( diary, limit = 100 ) count = 0 diary.each_visible_trackback( limit ) {|t,count|} # count up fragment = 't%02d' today = anchor( @date.strftime( '%Y%m%d' ) ) r = '' r << %Q!\t
\n! r << %Q!\t\t
\n! r << %Q!\t\t\t#{ trackback_today }#{ trackback_total( count ) }\n! if count > 0 r << %Q!\t\t\t[#{ trackback_ping_url(true) }]\n! r << %Q!\t\t
\n! r << %Q!\t\t
\n! diary.each_visible_trackback( limit ) do |t,i| url, name, title, excerpt = t.body.split( /\n/,4 ) a = (name and name.length > 0) ? name : url a += ':' + title if title &&! title.empty? f = fragment % i excerpt = excerpt || '' if excerpt.length > 255 excerpt = @conf.shorten( excerpt, 252 ) end r << %Q!\t\t\t
\n! r << %Q!\t\t\t\t#{ @conf['trackback_anchor'] }\n! if bot? then r << %Q!\t\t\t\t#{ CGI::escapeHTML( a )}\n! else r << %Q!\t\t\t\t#{ CGI::escapeHTML( a )}\n! end r << %Q!\t\t\t\t#{ comment_date( t.date ) }\n! r << %Q!\t\t\t
\n! r << %Q!\t\t\t

#{ CGI::escapeHTML( excerpt ).strip.gsub( /\n/,'
') }

\n! if excerpt end r << %Q!\t\t
\n! r << %Q!\t
\n! r end def trackback_ping_url(add_name = false) if @tb_url and not bot? %Q|TrackBack URL: #{@tb_url}| else '' end end # running on only non mobile mode end # unless mobile_agent? # configurations @conf['trackback_anchor'] ||= @conf.comment_anchor @conf['trackback_limit'] ||= @conf.comment_limit add_conf_proc( 'TrackBack', 'TrackBack' ) do if @mode == 'saveconf' then @conf['trackback_anchor'] = @conf.to_native( @cgi.params['trackback_anchor'][0] ) @conf['trackback_limit'] = @cgi.params['trackback_limit'][0].to_i @conf['trackback_limit'] = 3 if @conf['trackback_limit'] < 1 end tb_show_conf_html end