File: my-ex.rb

package info (click to toggle)
tdiary 2.0.1-1sarge1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,220 kB
  • ctags: 1,667
  • sloc: ruby: 20,044; lisp: 476; makefile: 91; sql: 32; sh: 31
file content (56 lines) | stat: -rw-r--r-- 1,671 bytes parent folder | download | duplicates (3)
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
# my-ex.rb $Revision: 1.12 $
#
# my(ĥ): myץ饰ĥtitle°˻Ƥޤ
#             褬ξ()֥ȥ
#             ĥåߤξϥĥåͤ̾ƤΰȤޤ
# ѥ᥿:
#   a:   ʬΥ('YYYYMMDD#pNN' ޤ 'YYYYMMDD#cNN')
#   str: 󥯤ˤʸ
#
# Copyright (c) 2002 TADA Tadashi <sho@spc.gr.jp>
# Distributed under the GPL

unless @conf.mobile_agent?

def my( a, str, title = nil )
	date, noise, frag = a.scan( /^(\d{4}|\d{6}|\d{8})([^\d]*)?#?([pct]\d\d)?$/ )[0]
	anc = frag ? "#{date}#{frag}" : date
	place, frag = frag.scan( /([cpt])(\d\d)/ )[0] if frag
	if date and frag and @diaries[date] then
		case place
		when 'p'
			section = nil
			idx = 1
			@diaries[date].each_section do |s|
				section = s
				break if idx == frag.to_i 
				idx += 1
			end
			if section and section.subtitle then
				title = CGI::escapeHTML( "#{apply_plugin(section.subtitle_to_html, true)}" )
			end
		when 'c'
			com = nil
			@diaries[date].each_comment( frag.to_i ) {|c| com = c}
			if com then
				title = CGI::escapeHTML( "[#{com.name}] #{com.shorten( @conf.comment_length )}" )
			end
		when 't'
			if @plugin_files.grep(/tb-show.rb\z/)
				tb = nil
				@diaries[date].each_visible_trackback( frag.to_i ) {|t, idx| tb = t}
				if tb then
					url, name, tbtitle, excerpt = tb.body.split( /\n/,4 )
					title = CGI::escapeHTML( "[#{name}] #{@conf.shorten( excerpt, @conf.comment_length )}" )
				end
			end
		end
	end
	if title then
		%Q[<a href="#{@index}#{anchor anc}" title="#{title}">#{str}</a>]
	else
		%Q[<a href="#{@index}#{anchor anc}">#{str}</a>]
	end
end

end