Created
January 30, 2011 00:54
-
-
Save kdmsnr/802385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/plugin/00default.rb b/plugin/00default.rb | |
index d52ee62..c04a912 100644 | |
--- a/plugin/00default.rb | |
+++ b/plugin/00default.rb | |
@@ -447,7 +447,7 @@ end | |
# make anchor string | |
# | |
def anchor( s ) | |
- if /^([\-\d]+)#?([pct]\d*)?$/ =~ s then | |
+ if /^([\-_\d]+)#?([pct]\d*)?$/ =~ s then | |
if $2 then | |
"?date=#$1##$2" | |
else | |
@@ -461,8 +461,8 @@ end | |
# | |
# subtitle | |
# | |
-add_subtitle_proc do |date, index, subtitle| | |
- subtitle_link( date, index, subtitle ) | |
+add_subtitle_proc do |date, index, subtitle, permalink| | |
+ subtitle_link( date, index, subtitle, permalink ) | |
end | |
def make_category_link( subtitle ) | |
@@ -483,7 +483,7 @@ def make_category_link( subtitle ) | |
r | |
end | |
-def subtitle_link( date, index, subtitle ) | |
+def subtitle_link( date, index, subtitle, permalink = false) | |
r = '' | |
if @conf.mobile_agent? then | |
@@ -493,7 +493,11 @@ def subtitle_link( date, index, subtitle ) | |
if date then | |
r << "<a " | |
r << %Q[name="p#{'%02d' % index}" ] if @anchor_name | |
- param = "#{date.strftime( '%Y%m%d' )}#p#{'%02d' % index}" | |
+ if permalink | |
+ param = "#{date.strftime( '%Y%m%d' )}_#{'%02d' % index}" | |
+ else | |
+ param = "#{date.strftime( '%Y%m%d' )}#p#{'%02d' % index}" | |
+ end | |
titleattr = (not subtitle or subtitle.empty?) ? '' : %Q[ title="#{remove_tag( subtitle ).gsub( /"/, """ )}"] | |
r << %Q[href="#{h @index}#{anchor param}"#{titleattr}>#{@conf.section_anchor}</a> ] | |
end | |
diff --git a/skel/day.rhtml b/skel/day.rhtml | |
index 441762a..46e928d 100644 | |
--- a/skel/day.rhtml | |
+++ b/skel/day.rhtml | |
@@ -22,6 +22,7 @@ if @diary then | |
'hide_comment_form' => @conf.hide_comment_form, | |
'show_nyear' => @conf.show_nyear, | |
'bot' => @conf.bot?, | |
+ 'section_no' => @diary.section_no | |
} %> | |
<%= @diary.eval_rhtml( param, PATH ) %><% | |
else %> | |
diff --git a/tdiary.rb b/tdiary.rb | |
index fa638b5..4b59934 100644 | |
--- a/tdiary.rb | |
+++ b/tdiary.rb | |
@@ -354,6 +354,7 @@ module TDiary | |
include ERB::Util | |
include CommentManager | |
include RefererManager | |
+ attr_accessor :section_no | |
def init_diary | |
init_comments | |
@@ -901,9 +902,13 @@ module TDiary | |
@subtitle_procs << block | |
end | |
- def subtitle_proc( date, subtitle ) | |
+ def subtitle_proc( date, subtitle, idx = nil) | |
@subtitle_procs.each do |proc| | |
- subtitle = proc.call( date, @section_index[date], subtitle ) | |
+ if idx | |
+ subtitle = proc.call( date, idx, subtitle, true ) | |
+ else | |
+ subtitle = proc.call( date, @section_index[date], subtitle, false ) | |
+ end | |
end | |
apply_plugin( subtitle ) | |
end | |
@@ -1802,8 +1807,9 @@ EOS | |
super | |
begin | |
# time is noon for easy to calc leap second. | |
- @date = Time::local( *@cgi.params['date'][0].scan( /^(\d{4})(\d\d)(\d\d)$/ )[0] ) + 12*60*60 | |
+ @date = Time::local( *@cgi.params['date'][0].scan( /^(\d{4})(\d\d)(\d\d).*$/ )[0] ) + 12*60*60 | |
load( @date ) | |
+ @diary.section_no = @cgi.params['date'][0][9..-1] | |
rescue ArgumentError, NameError | |
raise TDiaryError, 'bad date' | |
end | |
diff --git a/tdiary/dispatcher.rb b/tdiary/dispatcher.rb | |
index 59e69ac..e604128 100644 | |
--- a/tdiary/dispatcher.rb | |
+++ b/tdiary/dispatcher.rb | |
@@ -59,6 +59,8 @@ module TDiary | |
date = @cgi.params['date'][0] | |
if /^\d{8}-\d+$/ =~ date then | |
tdiary = TDiary::TDiaryLatest::new( @cgi, "latest.rhtml", conf ) | |
+ elsif /^\d{8}_\d+$/ =~ date then | |
+ tdiary = TDiary::TDiaryDay::new( @cgi, "day.rhtml", conf ) | |
elsif /^\d{8}$/ =~ date then | |
tdiary = TDiary::TDiaryDay::new( @cgi, "day.rhtml", conf ) | |
elsif /^\d{6}$/ =~ date then | |
diff --git a/tdiary/wiki_style.rb b/tdiary/wiki_style.rb | |
index 807a6c9..a2f0b88 100644 | |
--- a/tdiary/wiki_style.rb | |
+++ b/tdiary/wiki_style.rb | |
@@ -89,10 +89,10 @@ module TDiary | |
r = @html.lstrip | |
r.sub!( %r!<h3>(.+?)</h3>!m ) do | |
subtitle = true | |
- "<h3><%= subtitle_proc( Time::at( #{date.to_i} ), #{$1.dump.gsub( /%/, '\\\\045' )} ) %></h3>" | |
+ "<h3><%= subtitle_proc( Time::at( #{date.to_i} ), #{$1.dump.gsub( /%/, '\\\\045' )}, #{idx} ) %></h3>" | |
end | |
- r.sub!( %r!^<p>(.+?)</p>$!m ) do | |
- "<p><%= subtitle_proc( Time::at( #{date.to_i} ), #{$1.dump.gsub( /%/, '\\\\045' )} ) %></p>" | |
+ r.sub!( %r!^<p>(.+?)</p$!m ) do | |
+ "<p><%= subtitle_proc( Time::at( #{date.to_i} ), #{$1.dump.gsub( /%/, '\\\\045' )}, #{idx} ) %></p>" | |
end unless subtitle | |
r.gsub( /<(\/)?tdiary-section>/, '<\\1p>' ) | |
end | |
@@ -279,6 +279,11 @@ module TDiary | |
end | |
def to_html4( opt ) | |
+ if !opt['section_no'].nil? and !opt['section_no'].empty? | |
+ idx = opt['section_no'].to_i | |
+ return @sections[idx - 1].html4( date, idx, opt ) | |
+ end | |
+ | |
r = '' | |
idx = 1 | |
each_section do |section| | |
@@ -289,6 +294,11 @@ module TDiary | |
end | |
def to_chtml( opt ) | |
+ if !opt['section_no'].nil? and !opt['section_no'].empty? | |
+ idx = opt['section_no'].to_i | |
+ return @sections[idx - 1].chtml( date, idx, opt ) | |
+ end | |
+ | |
r = '' | |
idx = 1 | |
each_section do |section| |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment