# tb-show.rb # # 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 GPL2 or any later version. # # 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 # # # 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|#{@index}#{anchor( @tb_date.strftime('%Y%m%d') )}| @tb_id_url[0, 0] = base_url if %r|^https?://|i !~ @conf.index @tb_id_url.gsub!( %r|/\./|, '/' ) @tb_url = %Q|#{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#{'s' if count > 1}(#{count})| unless count == 0 and @conf['tb.hide_if_no_tb'] end r end def trackbacks_of_today_short( diary, limit = @conf['trackback_limit'] || 3 ) is_blog_style = !@plugin_files.grep(/blog_style.rb\z/).empty? return unless is_blog_style || !diary.nil? && (@conf['trackback_shortview_mode'] == "shortlist" || @conf['trackback_disp_pingurl']) fragment = 't%02d' today = anchor( diary.date.strftime( '%Y%m%d' ) ) count = 0 diary.each_visible_trackback( -1 ) {|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 && (is_blog_style || @conf['trackback_shortview_mode'] == "shortlist") r << %Q!\t\t
\n! return r << %Q!\t
\n! unless is_blog_style || @conf['trackback_shortview_mode'] == "shortlist" 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#{h a}\n! r << %Q!\t\t\t\t#{h @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 = -1 ) 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
\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#{h a}\n! else r << %Q!\t\t\t\t#{h 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

#{h( excerpt ).strip.gsub( /\n/,'
')}

\n! if excerpt end r << %Q!\t\t
\n! r << %Q!\t
\n! r end # configurations @conf['trackback_anchor'] ||= @conf.comment_anchor @conf['trackback_limit'] ||= @conf.comment_limit add_conf_proc( 'tb-show', 'TrackBack', 'tsukkomi' ) do if @mode == 'saveconf' then @conf['trackback_anchor'] = @conf.to_native( @cgi.params['trackback_anchor'][0] ) @conf['trackback_shortview_mode'] = @cgi.params['trackback_shortview_mode'][0] if @conf['trackback_shortview_mode'] == "num_in_reflist_if_exists" @conf['tb.hide_if_no_tb'] = true @conf['trackback_shortview_mode'] = "num_in_reflist" elsif @conf['trackback_shortview_mode'] == "num_in_reflist" @conf['tb.hide_if_no_tb'] = false end @conf['trackback_limit'] = @cgi.params['trackback_limit'][0].to_i @conf['trackback_limit'] = 3 if @conf['trackback_limit'] < 1 @conf['trackback_disp_pingurl'] = @cgi.params['trackback_disp_pingurl'][0] == "true" ? true : false end tb_show_conf_html end # Local Variables: # mode: ruby # indent-tabs-mode: t # tab-width: 3 # ruby-indent-level: 3 # End: