tdiary 4.0.1 → 4.0.1.20130903
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/misc/plugin/title_tag.rb +15 -13
- data/misc/style/emptdiary/emptdiary_style.rb +95 -93
- data/misc/style/etdiary/etdiary_style.rb +364 -362
- data/misc/style/gfm/gfm_style.rb +129 -127
- data/misc/style/rd/rd_style.rb +158 -157
- data/spec/acceptance_helper.rb +2 -2
- data/spec/core/configuration_spec.rb +32 -0
- data/spec/core/style/emptdiary_style_spec.rb +2 -2
- data/spec/core/style/etdiary_style_spec.rb +2 -2
- data/spec/core/style/gfm_style_spec.rb +2 -2
- data/spec/core/style/rd_style_spec.rb +2 -2
- data/spec/core/style/tdiary_style_spec.rb +2 -2
- data/spec/core/style/wiki_style_spec.rb +2 -2
- data/tdiary.rb +7 -5
- data/tdiary/{config.rb → configuration.rb} +71 -69
- data/tdiary/io/base.rb +1 -1
- data/tdiary/io/pstore.rb +1 -1
- data/tdiary/style.rb +142 -148
- data/tdiary/style/tdiary_style.rb +149 -147
- data/tdiary/style/wiki_style.rb +167 -165
- data/tdiary/tasks/release.rake +40 -27
- data/tdiary/version.rb +1 -1
- metadata +5 -3
data/spec/acceptance_helper.rb
CHANGED
@@ -34,7 +34,7 @@ RSpec.configure do |config|
|
|
34
34
|
end
|
35
35
|
|
36
36
|
config.after(:all) do
|
37
|
-
FileUtils.
|
37
|
+
FileUtils.rm_rf work_conf
|
38
38
|
end
|
39
39
|
|
40
40
|
config.before(:each) do
|
@@ -42,7 +42,7 @@ RSpec.configure do |config|
|
|
42
42
|
end
|
43
43
|
|
44
44
|
config.after(:each) do
|
45
|
-
FileUtils.
|
45
|
+
FileUtils.rm_rf work_data_dir
|
46
46
|
end
|
47
47
|
|
48
48
|
if ENV['TEST_MODE'] == 'rdb'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'tdiary'
|
4
|
+
require 'tdiary/configuration'
|
5
|
+
|
6
|
+
describe TDiary::Configuration do
|
7
|
+
let(:tdiary_conf) { File.expand_path("../../fixtures/tdiary.conf.webrick", __FILE__) }
|
8
|
+
let(:work_conf) { File.expand_path('../../../tdiary.conf', __FILE__) }
|
9
|
+
|
10
|
+
before do
|
11
|
+
FileUtils.cp_r tdiary_conf, work_conf, :verbose => false
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
FileUtils.rm_rf work_conf
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "TDiary.configuration" do
|
19
|
+
before do
|
20
|
+
@obj = TDiary.configuration
|
21
|
+
end
|
22
|
+
|
23
|
+
it { @obj.class.should eq TDiary::Configuration }
|
24
|
+
it "singleton" do
|
25
|
+
@obj.should eq TDiary.configuration
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
it "TDiary.configuration.attribute" do
|
30
|
+
TDiary.configuration.style.should == "Wiki"
|
31
|
+
end
|
32
|
+
end
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'misc/style/emptdiary/emptdiary_style'
|
6
6
|
|
7
|
-
describe TDiary::EmptdiaryDiary do
|
7
|
+
describe TDiary::Style::EmptdiaryDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::EmptdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::EmptdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'misc/style/etdiary/etdiary_style'
|
6
6
|
|
7
|
-
describe TDiary::EtdiaryDiary do
|
7
|
+
describe TDiary::Style::EtdiaryDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::EtdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::EtdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'misc/style/gfm/gfm_style'
|
6
6
|
|
7
|
-
describe TDiary::GfmDiary do
|
7
|
+
describe TDiary::Style::GfmDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::GfmDiary.new(Time.at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::GfmDiary.new(Time.at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'misc/style/rd/rd_style'
|
6
6
|
|
7
|
-
describe TDiary::RdDiary do
|
7
|
+
describe TDiary::Style::RdDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::RdDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::RdDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'tdiary/style/tdiary_style'
|
6
6
|
|
7
|
-
describe TDiary::TdiaryDiary do
|
7
|
+
describe TDiary::Style::TdiaryDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::TdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::TdiaryDiary.new(Time::at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
@@ -4,9 +4,9 @@ require 'spec_helper'
|
|
4
4
|
require 'tdiary'
|
5
5
|
require 'tdiary/style/wiki_style'
|
6
6
|
|
7
|
-
describe TDiary::WikiDiary do
|
7
|
+
describe TDiary::Style::WikiDiary do
|
8
8
|
before do
|
9
|
-
@diary = TDiary::WikiDiary.new(Time.at( 1041346800 ), "TITLE", "")
|
9
|
+
@diary = TDiary::Style::WikiDiary.new(Time.at( 1041346800 ), "TITLE", "")
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '#append' do
|
data/tdiary.rb
CHANGED
@@ -34,7 +34,8 @@ module TDiary
|
|
34
34
|
PATH = File::dirname( __FILE__ ).untaint
|
35
35
|
|
36
36
|
# tDiary configuration class, initialize tdiary.conf and stored configuration.
|
37
|
-
autoload :
|
37
|
+
autoload :Configuration, 'tdiary/configuration'
|
38
|
+
autoload :Config, 'tdiary/configuration'
|
38
39
|
# tDiary plugin class, loading all Plugin and eval plugins in view context.
|
39
40
|
autoload :Plugin, 'tdiary/plugin'
|
40
41
|
# tDiary Filter class, all filters is loaded by in TDiaryView.
|
@@ -46,10 +47,7 @@ module TDiary
|
|
46
47
|
autoload :Application, 'tdiary/application'
|
47
48
|
|
48
49
|
# Diary model class
|
49
|
-
autoload :
|
50
|
-
autoload :SectionBase, 'tdiary/style'
|
51
|
-
autoload :CategorizableDiary, 'tdiary/style'
|
52
|
-
autoload :UncategorizableDiary, 'tdiary/style'
|
50
|
+
autoload :Style, 'tdiary/style'
|
53
51
|
autoload :Comment, 'tdiary/comment'
|
54
52
|
autoload :CommentManager, 'tdiary/comment_manager'
|
55
53
|
autoload :RefererManager, 'tdiary/referer_manager'
|
@@ -130,6 +128,10 @@ module TDiary
|
|
130
128
|
def server_root
|
131
129
|
Dir.pwd
|
132
130
|
end
|
131
|
+
|
132
|
+
def configuration
|
133
|
+
@@configuration ||= Configuration.new
|
134
|
+
end
|
133
135
|
end
|
134
136
|
end
|
135
137
|
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# -*- coding: utf-8
|
1
|
+
# -*- coding: utf-8 -*-
|
2
2
|
#
|
3
|
-
# class
|
3
|
+
# class Configuration
|
4
4
|
# configuration class
|
5
5
|
#
|
6
6
|
module TDiary
|
7
|
-
class
|
7
|
+
class Configuration
|
8
8
|
attr_reader :database_url
|
9
9
|
|
10
10
|
def initialize( cgi = nil, request = nil )
|
@@ -24,6 +24,22 @@ module TDiary
|
|
24
24
|
@io_class.save_cgi_conf(self, result)
|
25
25
|
end
|
26
26
|
|
27
|
+
#
|
28
|
+
# get/set/delete plugin options
|
29
|
+
#
|
30
|
+
def []( key )
|
31
|
+
@options[key]
|
32
|
+
end
|
33
|
+
|
34
|
+
def []=( key, val )
|
35
|
+
@options2[key] = @options[key] = val
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete( key )
|
39
|
+
@options.delete( key )
|
40
|
+
@options2.delete( key )
|
41
|
+
end
|
42
|
+
|
27
43
|
# backword compatibility, you can use @cgi.mobile_agent?
|
28
44
|
def mobile_agent?
|
29
45
|
@request.mobile_agent?
|
@@ -49,22 +65,6 @@ module TDiary
|
|
49
65
|
end
|
50
66
|
end
|
51
67
|
|
52
|
-
#
|
53
|
-
# get/set/delete plugin options
|
54
|
-
#
|
55
|
-
def []( key )
|
56
|
-
@options[key]
|
57
|
-
end
|
58
|
-
|
59
|
-
def []=( key, val )
|
60
|
-
@options2[key] = @options[key] = val
|
61
|
-
end
|
62
|
-
|
63
|
-
def delete( key )
|
64
|
-
@options.delete( key )
|
65
|
-
@options2.delete( key )
|
66
|
-
end
|
67
|
-
|
68
68
|
def to_native( str, charset = nil )
|
69
69
|
str = str.dup
|
70
70
|
if str.encoding == Encoding::ASCII_8BIT
|
@@ -80,6 +80,55 @@ module TDiary
|
|
80
80
|
end
|
81
81
|
|
82
82
|
private
|
83
|
+
|
84
|
+
# loading tdiary.conf in @data_path.
|
85
|
+
def load_cgi_conf
|
86
|
+
def_vars1 = ''
|
87
|
+
def_vars2 = ''
|
88
|
+
[
|
89
|
+
:tdiary_version,
|
90
|
+
:html_title, :author_name, :author_mail, :index_page, :hour_offset,
|
91
|
+
:description, :icon, :banner, :x_frame_options,
|
92
|
+
:header, :footer,
|
93
|
+
:section_anchor, :comment_anchor, :date_format, :latest_limit, :show_nyear,
|
94
|
+
:theme, :css,
|
95
|
+
:show_comment, :comment_limit, :comment_limit_per_day,
|
96
|
+
:mail_on_comment, :mail_header,
|
97
|
+
:show_referer, :no_referer2, :only_volatile2, :referer_table2,
|
98
|
+
:options2,
|
99
|
+
].each do |var|
|
100
|
+
def_vars1 << "#{var} = nil\n"
|
101
|
+
def_vars2 << "@#{var} = #{var} unless #{var} == nil\n"
|
102
|
+
end
|
103
|
+
|
104
|
+
unless @io_class
|
105
|
+
require 'tdiary/io/cache/file'
|
106
|
+
require 'tdiary/io/default'
|
107
|
+
@io_class = DefaultIO
|
108
|
+
end
|
109
|
+
|
110
|
+
cgi_conf = @io_class.load_cgi_conf(self)
|
111
|
+
cgi_conf.untaint unless @secure
|
112
|
+
|
113
|
+
b = binding.taint
|
114
|
+
eval( def_vars1, b )
|
115
|
+
Safe::safe( @secure ? 4 : 1 ) do
|
116
|
+
begin
|
117
|
+
eval( cgi_conf, b, "(TDiary::Config#load_cgi_conf)", 1 )
|
118
|
+
rescue SyntaxError
|
119
|
+
enc = case @lang
|
120
|
+
when 'en'
|
121
|
+
'UTF-8'
|
122
|
+
else
|
123
|
+
'EUC-JP'
|
124
|
+
end
|
125
|
+
cgi_conf.force_encoding( enc )
|
126
|
+
retry
|
127
|
+
end
|
128
|
+
end if cgi_conf
|
129
|
+
eval( def_vars2, b )
|
130
|
+
end
|
131
|
+
|
83
132
|
# loading tdiary.conf in current directory
|
84
133
|
def configure_attrs
|
85
134
|
@secure = true unless @secure
|
@@ -149,56 +198,6 @@ module TDiary
|
|
149
198
|
@section_anchor = @paragraph_anchor unless @section_anchor
|
150
199
|
end
|
151
200
|
|
152
|
-
# loading tdiary.conf in @data_path.
|
153
|
-
def load_cgi_conf
|
154
|
-
def_vars1 = ''
|
155
|
-
def_vars2 = ''
|
156
|
-
[
|
157
|
-
:tdiary_version,
|
158
|
-
:html_title, :author_name, :author_mail, :index_page, :hour_offset,
|
159
|
-
:description, :icon, :banner, :x_frame_options,
|
160
|
-
:header, :footer,
|
161
|
-
:section_anchor, :comment_anchor, :date_format, :latest_limit, :show_nyear,
|
162
|
-
:theme, :css,
|
163
|
-
:show_comment, :comment_limit, :comment_limit_per_day,
|
164
|
-
:mail_on_comment, :mail_header,
|
165
|
-
:show_referer, :no_referer2, :only_volatile2, :referer_table2,
|
166
|
-
:options2,
|
167
|
-
].each do |var|
|
168
|
-
def_vars1 << "#{var} = nil\n"
|
169
|
-
def_vars2 << "@#{var} = #{var} unless #{var} == nil\n"
|
170
|
-
end
|
171
|
-
|
172
|
-
unless @io_class
|
173
|
-
require 'tdiary/io/cache/file'
|
174
|
-
require 'tdiary/io/default'
|
175
|
-
@io_class = DefaultIO
|
176
|
-
end
|
177
|
-
|
178
|
-
cgi_conf = @io_class.load_cgi_conf(self)
|
179
|
-
cgi_conf.untaint unless @secure
|
180
|
-
|
181
|
-
b = binding.taint
|
182
|
-
eval( def_vars1, b )
|
183
|
-
Safe::safe( @secure ? 4 : 1 ) do
|
184
|
-
begin
|
185
|
-
eval( cgi_conf, b, "(TDiary::Config#load_cgi_conf)", 1 )
|
186
|
-
rescue SyntaxError
|
187
|
-
enc = case @lang
|
188
|
-
when 'en'
|
189
|
-
'UTF-8'
|
190
|
-
else
|
191
|
-
'EUC-JP'
|
192
|
-
end
|
193
|
-
cgi_conf.force_encoding( enc )
|
194
|
-
retry
|
195
|
-
end
|
196
|
-
end if cgi_conf
|
197
|
-
eval( def_vars2, b )
|
198
|
-
end
|
199
|
-
|
200
|
-
private
|
201
|
-
|
202
201
|
def setup_attr_accessor_to_all_ivars
|
203
202
|
names = instance_variables().collect {|ivar| ivar.to_s.sub(/@/, '') }
|
204
203
|
(class << self; self; end).class_eval { attr_accessor *names }
|
@@ -227,6 +226,9 @@ module TDiary
|
|
227
226
|
nil
|
228
227
|
end
|
229
228
|
end
|
229
|
+
|
230
|
+
# backword compatibility
|
231
|
+
Config = Configuration
|
230
232
|
end
|
231
233
|
|
232
234
|
# Local Variables:
|
data/tdiary/io/base.rb
CHANGED
@@ -46,7 +46,7 @@ module TDiary
|
|
46
46
|
Dir.glob("#{path}/*_style.rb") do |style_file|
|
47
47
|
require style_file.untaint
|
48
48
|
style = File.basename(style_file).sub(/_style\.rb$/, '')
|
49
|
-
@styles[style] = TDiary.const_get("#{style.capitalize}Diary")
|
49
|
+
@styles[style] = TDiary::Style.const_get("#{style.capitalize}Diary")
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/tdiary/io/pstore.rb
CHANGED
data/tdiary/style.rb
CHANGED
@@ -1,187 +1,181 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
module TDiary
|
3
|
-
|
4
|
-
|
5
|
-
# Base module of Section.
|
6
|
-
#
|
7
|
-
module SectionBase
|
8
|
-
|
9
|
-
attr_reader :subtitle, :author
|
10
|
-
attr_reader :categories, :stripped_subtitle
|
11
|
-
attr_reader :subtitle_to_html, :stripped_subtitle_to_html, :body_to_html
|
12
|
-
|
13
|
-
def body
|
14
|
-
@body.dup
|
15
|
-
end
|
3
|
+
module Style
|
4
|
+
module BaseSection
|
16
5
|
|
17
|
-
|
18
|
-
|
19
|
-
|
6
|
+
attr_reader :subtitle, :author
|
7
|
+
attr_reader :categories, :stripped_subtitle
|
8
|
+
attr_reader :subtitle_to_html, :stripped_subtitle_to_html, :body_to_html
|
20
9
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
r << do_html4( date, idx, opt )
|
25
|
-
r << %Q[<%=section_leave_proc( Time.at( #{date.to_i} ) )%>\n]
|
26
|
-
r << "</div>\n"
|
27
|
-
end
|
10
|
+
def body
|
11
|
+
@body.dup
|
12
|
+
end
|
28
13
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
r << %Q[<%=section_leave_proc( Time.at( #{date.to_i} ) )%>\n]
|
33
|
-
end
|
14
|
+
def body=(str)
|
15
|
+
@body = str
|
16
|
+
end
|
34
17
|
|
35
|
-
|
36
|
-
|
37
|
-
|
18
|
+
def html4(date, idx, opt)
|
19
|
+
r = %Q[<div class="section">\n]
|
20
|
+
r << %Q[<%=section_enter_proc( Time.at( #{date.to_i} ) )%>\n]
|
21
|
+
r << do_html4( date, idx, opt )
|
22
|
+
r << %Q[<%=section_leave_proc( Time.at( #{date.to_i} ) )%>\n]
|
23
|
+
r << "</div>\n"
|
24
|
+
end
|
38
25
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
26
|
+
def chtml(date, idx, opt)
|
27
|
+
r = %Q[<%=section_enter_proc( Time.at( #{date.to_i} ) )%>\n]
|
28
|
+
r << do_html4( date, idx, opt )
|
29
|
+
r << %Q[<%=section_leave_proc( Time.at( #{date.to_i} ) )%>\n]
|
30
|
+
end
|
46
31
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
#
|
51
|
-
module DiaryBase
|
52
|
-
include ERB::Util
|
53
|
-
include CommentManager
|
54
|
-
include RefererManager
|
55
|
-
|
56
|
-
def init_diary
|
57
|
-
init_comments
|
58
|
-
init_referers
|
59
|
-
@show = true
|
60
|
-
end
|
32
|
+
def to_s
|
33
|
+
to_src
|
34
|
+
end
|
61
35
|
|
62
|
-
|
63
|
-
|
36
|
+
def categories_to_string
|
37
|
+
@categories = categories
|
38
|
+
cat_str = ""
|
39
|
+
categories.each {|cat| cat_str << "[#{cat}]"}
|
40
|
+
cat_str << " " unless cat_str.empty?
|
41
|
+
end
|
64
42
|
end
|
65
43
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
44
|
+
module BaseDiary
|
45
|
+
include ERB::Util
|
46
|
+
include CommentManager
|
47
|
+
include RefererManager
|
48
|
+
|
49
|
+
def init_diary
|
50
|
+
init_comments
|
51
|
+
init_referers
|
52
|
+
@show = true
|
73
53
|
end
|
74
|
-
end
|
75
54
|
|
76
|
-
|
77
|
-
|
78
|
-
|
55
|
+
def date
|
56
|
+
@date
|
57
|
+
end
|
79
58
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
59
|
+
def set_date( date )
|
60
|
+
if date.class == String then
|
61
|
+
y, m, d = date.scan( /^(\d{4})(\d\d)(\d\d)$/ )[0]
|
62
|
+
raise ArgumentError::new( 'date string needs YYYYMMDD format.' ) unless y
|
63
|
+
@date = Time::local( y, m, d )
|
64
|
+
else
|
65
|
+
@date = date
|
66
|
+
end
|
67
|
+
end
|
84
68
|
|
85
|
-
|
86
|
-
|
87
|
-
# (PStore 保存前は Time だが, 保存後に String となる)
|
88
|
-
# 暫定的に String だったら Time へ変換する
|
89
|
-
if @last_modified.instance_of? String
|
90
|
-
@last_modified = Time.at(0)
|
91
|
-
elsif @last_modified
|
92
|
-
@last_modified
|
93
|
-
else
|
94
|
-
Time::at( 0 )
|
69
|
+
def title
|
70
|
+
@title || ''
|
95
71
|
end
|
96
|
-
end
|
97
72
|
|
98
|
-
|
99
|
-
|
100
|
-
|
73
|
+
def set_title( title )
|
74
|
+
@title = title
|
75
|
+
@last_modified = Time::now
|
76
|
+
end
|
101
77
|
|
102
|
-
|
103
|
-
|
104
|
-
|
78
|
+
def last_modified
|
79
|
+
# 日本語を含むツッコミを入れると diary.last_modified が String になる (原因不明)
|
80
|
+
# (PStore 保存前は Time だが, 保存後に String となる)
|
81
|
+
# 暫定的に String だったら Time へ変換する
|
82
|
+
if @last_modified.instance_of? String
|
83
|
+
@last_modified = Time.at(0)
|
84
|
+
elsif @last_modified
|
85
|
+
@last_modified
|
86
|
+
else
|
87
|
+
Time::at( 0 )
|
88
|
+
end
|
89
|
+
end
|
105
90
|
|
106
|
-
|
107
|
-
|
108
|
-
|
91
|
+
def last_modified=( lm )
|
92
|
+
@last_modified = lm
|
93
|
+
end
|
109
94
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
@sections = []
|
114
|
-
append( body )
|
115
|
-
end
|
95
|
+
def visible?
|
96
|
+
@show != false;
|
97
|
+
end
|
116
98
|
|
117
|
-
|
118
|
-
|
119
|
-
yield section
|
99
|
+
def show( s )
|
100
|
+
@show = s
|
120
101
|
end
|
121
|
-
end
|
122
102
|
|
123
|
-
|
124
|
-
|
125
|
-
|
103
|
+
def replace(date, title, body)
|
104
|
+
set_date( date )
|
105
|
+
set_title( title )
|
106
|
+
@sections = []
|
107
|
+
append( body )
|
108
|
+
end
|
126
109
|
|
127
|
-
|
128
|
-
|
129
|
-
|
110
|
+
def each_section
|
111
|
+
@sections.each do |section|
|
112
|
+
yield section
|
113
|
+
end
|
114
|
+
end
|
130
115
|
|
131
|
-
|
132
|
-
|
133
|
-
each_section do |section|
|
134
|
-
r << section.to_src
|
116
|
+
def delete_section(index)
|
117
|
+
@sections.delete_at(index - 1)
|
135
118
|
end
|
136
|
-
r
|
137
|
-
end
|
138
119
|
|
139
|
-
|
140
|
-
|
141
|
-
when :CHTML
|
142
|
-
to_chtml( opt )
|
143
|
-
else
|
144
|
-
to_html4( opt )
|
120
|
+
def eval_rhtml( opt, path = '.' )
|
121
|
+
ERB.new(File.read("#{path}/skel/#{opt['prefix']}diary.rhtml").untaint).result(binding)
|
145
122
|
end
|
146
|
-
end
|
147
123
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
124
|
+
def to_src
|
125
|
+
r = ''
|
126
|
+
each_section do |section|
|
127
|
+
r << section.to_src
|
128
|
+
end
|
129
|
+
r
|
154
130
|
end
|
155
|
-
r
|
156
|
-
end
|
157
131
|
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
132
|
+
def to_html( opt = {}, mode = :HTML )
|
133
|
+
case mode
|
134
|
+
when :CHTML
|
135
|
+
to_chtml( opt )
|
136
|
+
else
|
137
|
+
to_html4( opt )
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
def to_html4(opt)
|
142
|
+
r = ''
|
143
|
+
idx = 1
|
144
|
+
each_section do |section|
|
145
|
+
r << section.html4( date, idx, opt )
|
146
|
+
idx += 1
|
147
|
+
end
|
148
|
+
r
|
149
|
+
end
|
150
|
+
|
151
|
+
def to_chtml( opt )
|
152
|
+
r = ''
|
153
|
+
idx = 1
|
154
|
+
each_section do |section|
|
155
|
+
r << section.chtml( date, idx, opt )
|
156
|
+
idx += 1
|
157
|
+
end
|
158
|
+
r
|
164
159
|
end
|
165
|
-
r
|
166
|
-
end
|
167
160
|
|
168
|
-
|
169
|
-
|
161
|
+
def to_s
|
162
|
+
"date=#{date.strftime('%Y%m%d')}, title=#{title}, body=[#{@sections.join('][')}]"
|
163
|
+
end
|
170
164
|
end
|
171
|
-
end
|
172
165
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
166
|
+
#
|
167
|
+
# module CategorizableDiary
|
168
|
+
#
|
169
|
+
module CategorizableDiary
|
170
|
+
def categorizable?; true; end
|
171
|
+
end
|
179
172
|
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
173
|
+
#
|
174
|
+
# module UncategorizableDiary
|
175
|
+
#
|
176
|
+
module UncategorizableDiary
|
177
|
+
def categorizable?; false; end
|
178
|
+
end
|
185
179
|
end
|
186
180
|
end
|
187
181
|
|