/usr/share/tdiary/misc/plugin/footnote.rb is in tdiary-plugin 3.2.2-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | # -*- coding: utf-8 -*-
# footnote.rb
#
# fn: 脚注plugin
# パラメタ:
# text: 脚注本文
# mark: 脚注マーク('*')
#
# Copyright (C) 2007 TADA Tadashi <sho@spc.gr.jp>
# Distributed under the GPL.
# initialize variables
@fn_fragment_fm = ''
@fn_fragment_f = ''
@fn_notes = []
@fn_marks = []
add_body_enter_proc do |date|
fn_initialize( date )
''
end
add_section_enter_proc do |date, index|
fn_initialize( date, index ) unless @conf.style =~ /blog/i
''
end
def fn_initialize( date, section = 1 )
@fn_fragment_fm = sprintf( 'fm%s-%02d-%%02d', date.strftime( '%Y%m%d' ), section )
@fn_fragment_f = @fn_fragment_fm.sub( /^fm/, 'f' )
@fn_notes = []
@fn_marks = []
end
def fn( text, mark = '*' )
@fn_notes += [text]
@fn_marks += [mark]
idx = @fn_notes.size
r = %Q|<span class="footnote">|
if feed? then
r << %Q|#{mark}#{idx}|
else
r << %Q|<a |
r << %Q|name="#{@fn_fragment_fm % idx}" |
r << %Q|href="##{@fn_fragment_f % idx}" |
r << %Q|title="#{h text}">|
r << %Q|#{h mark}#{idx}|
r << %Q|</a>|
end
r << %Q|</span>|
end
# print footnotes
add_section_leave_proc do |date, index|
@conf.style =~ /blog/i ? '' : fn_put
end
add_body_leave_proc do |date|
fn_put
end
def fn_put
if @fn_notes.size > 0 then
r = %Q|<div class="footnote">\n|
@fn_notes.each_with_index do |fn, idx|
r << %Q|\t<p class="footnote">|
if feed? then
r << %Q|#{h @fn_marks[idx]}#{idx+1}|
else
r << %Q|<a |
r << %Q|name="#{@fn_fragment_f % (idx+1)}" |
r << %Q|href="##{@fn_fragment_fm % (idx+1)}">|
r << %Q|#{h @fn_marks[idx]}#{idx+1}|
r << %Q|</a>|
end
r << %Q| #{@fn_notes[idx]}</p>\n|
end
@fn_notes.clear
r << %Q|</div>\n|
else
''
end
end
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:
# vim: ts=3
|