tdiary 4.0.1.20130903 → 4.0.1.20130929

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f04df177eb9cdb1da5cdf4c260a2ce21acf5adca
4
- data.tar.gz: fb82eb586136566043abcc0bd178b4265233c329
3
+ metadata.gz: 3cb15a291ccf22c9e26d5007c81a8a0d7872217d
4
+ data.tar.gz: e1967f9cf308aaf0dffa1ccd5cd04e4ca3ee63a2
5
5
  SHA512:
6
- metadata.gz: 9a0fcf194925de5285c50782ee68d6deb455df5ec924a944199648995589bdeca8765f7e6327dec8541d7beec486058d30ca95c03b79bbb3a2ccf0a2daedd8eb
7
- data.tar.gz: 06a7c5e731b231804d917a37f0b057ab444fd8d13f8daecbc1344378ec1d797f7278a10c8167f0c42e003b41bc067440fb587935865759f1176065feed156f45
6
+ metadata.gz: 3eebdfd11165028ff3b35fd9731b5f6b5e3c5712c2b96dc8b91666d5f59a3dee08bd0d2134988ec1a8bed70e062f99849293f76e5b77608a598f58cd6584b8d7
7
+ data.tar.gz: c78628a2c55c3f0a0c9cb87cc46072aa7439fb8be24cc5bdc35757923fd87e3e65ca6cb81764488582f5149004cfed4b623a17838240a42d143af520c44a9eac
data/Gemfile CHANGED
@@ -3,7 +3,6 @@ source 'https://rubygems.org'
3
3
  gem 'rack'
4
4
  gem 'sprockets'
5
5
  gem 'hikidoc'
6
- gem 'rdtool'
7
6
  gem 'fastimage'
8
7
 
9
8
  group :coffee do
@@ -20,12 +19,6 @@ group :redis do
20
19
  gem 'redis-namespace'
21
20
  end
22
21
 
23
- group :gfm do
24
- gem 'redcarpet'
25
- gem 'pygments.rb'
26
- gem 'twitter-text', :require => false
27
- end
28
-
29
22
  group :server do
30
23
  platforms :mri do
31
24
  gem 'thin'
data/Gemfile.lock CHANGED
@@ -15,19 +15,18 @@ GEM
15
15
  coffee-script-source
16
16
  execjs
17
17
  coffee-script-source (1.6.3)
18
- colorize (0.5.8)
19
- coveralls (0.6.7)
20
- colorize
18
+ coveralls (0.7.0)
21
19
  multi_json (~> 1.3)
22
20
  rest-client
23
21
  simplecov (>= 0.7)
22
+ term-ansicolor
24
23
  thor
25
24
  daemons (1.1.9)
26
25
  dalli (2.6.4)
27
26
  diff-lcs (1.2.4)
28
27
  eventmachine (1.0.3)
29
- execjs (2.0.0)
30
- fastimage (1.5.0)
28
+ execjs (2.0.1)
29
+ fastimage (1.5.2)
31
30
  ffi (1.9.0)
32
31
  hike (1.2.3)
33
32
  hikidoc (0.0.6)
@@ -41,20 +40,16 @@ GEM
41
40
  addressable (~> 2.3)
42
41
  libv8 (3.16.14.3)
43
42
  method_source (0.8.2)
44
- mime-types (1.24)
43
+ mime-types (1.25)
45
44
  mini_portile (0.5.1)
46
- multi_json (1.7.9)
45
+ multi_json (1.8.0)
47
46
  nokogiri (1.6.0)
48
47
  mini_portile (~> 0.5.0)
49
48
  pit (0.0.7)
50
- posix-spawn (0.3.6)
51
49
  pry (0.9.12.2)
52
50
  coderay (~> 1.0.5)
53
51
  method_source (~> 0.8)
54
52
  slop (~> 3.4)
55
- pygments.rb (0.5.2)
56
- posix-spawn (~> 0.3.6)
57
- yajl-ruby (~> 1.1.0)
58
53
  rack (1.5.2)
59
54
  rack-test (0.6.2)
60
55
  rack (>= 1.0)
@@ -62,8 +57,6 @@ GEM
62
57
  rack (>= 1.0)
63
58
  rack-test (>= 0.5)
64
59
  rake (10.1.0)
65
- rdtool (0.6.38)
66
- redcarpet (3.0.0)
67
60
  redis (3.0.4)
68
61
  redis-namespace (1.3.1)
69
62
  redis (~> 3.0.0)
@@ -75,16 +68,16 @@ GEM
75
68
  rspec-expectations (~> 2.14.0)
76
69
  rspec-mocks (~> 2.14.0)
77
70
  rspec-core (2.14.5)
78
- rspec-expectations (2.14.2)
71
+ rspec-expectations (2.14.3)
79
72
  diff-lcs (>= 1.1.3, < 2.0)
80
73
  rspec-mocks (2.14.3)
81
74
  rubyzip (0.9.9)
82
- selenium-webdriver (2.35.0)
75
+ selenium-webdriver (2.35.1)
83
76
  childprocess (>= 0.2.5)
84
77
  multi_json (~> 1.0)
85
- rubyzip
78
+ rubyzip (< 1.0.0)
86
79
  websocket (~> 1.0.4)
87
- sequel (4.1.1)
80
+ sequel (4.2.0)
88
81
  simplecov (0.7.1)
89
82
  multi_json (~> 1.0)
90
83
  simplecov-html (~> 0.7.1)
@@ -98,6 +91,8 @@ GEM
98
91
  sqlite3 (1.3.8)
99
92
  tapp (1.4.0)
100
93
  thor
94
+ term-ansicolor (1.2.2)
95
+ tins (~> 0.8)
101
96
  test-unit (2.5.5)
102
97
  therubyracer (0.12.0)
103
98
  libv8 (~> 3.16.14.0)
@@ -108,15 +103,10 @@ GEM
108
103
  rack (>= 1.0.0)
109
104
  thor (0.18.1)
110
105
  tilt (1.4.1)
111
- twitter-text (1.6.1)
112
- unf (~> 0.0.5)
113
- unf (0.0.5)
114
- unf_ext
115
- unf_ext (0.0.6)
106
+ tins (0.11.0)
116
107
  websocket (1.0.7)
117
108
  xpath (2.0.0)
118
109
  nokogiri (~> 1.3)
119
- yajl-ruby (1.1.0)
120
110
 
121
111
  PLATFORMS
122
112
  ruby
@@ -132,12 +122,9 @@ DEPENDENCIES
132
122
  launchy
133
123
  pit
134
124
  pry
135
- pygments.rb
136
125
  rack
137
126
  racksh
138
127
  rake
139
- rdtool
140
- redcarpet
141
128
  redis
142
129
  redis-namespace
143
130
  rspec
@@ -151,4 +138,3 @@ DEPENDENCIES
151
138
  therubyracer
152
139
  thin
153
140
  trinidad
154
- twitter-text
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  require 'tdiary'
5
- require 'tdiary/style/tdiary_style'
5
+ require 'tdiary/style/tdiary'
6
6
 
7
7
  describe TDiary::Style::TdiaryDiary do
8
8
  before do
@@ -2,7 +2,7 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  require 'tdiary'
5
- require 'tdiary/style/wiki_style'
5
+ require 'tdiary/style/wiki'
6
6
 
7
7
  describe TDiary::Style::WikiDiary do
8
8
  before do
data/tdiary/io/base.rb CHANGED
@@ -4,6 +4,7 @@
4
4
  # base of IO class
5
5
  #
6
6
  require 'fileutils'
7
+ require 'tdiary/style' # XXX can't auto loading TDiary::Style subclasses
7
8
 
8
9
  module TDiary
9
10
  class BaseIO
@@ -38,16 +39,19 @@ module TDiary
38
39
  def load_styles
39
40
  @styles = {}
40
41
  paths = @tdiary.conf.options['style.path'] ||
41
- [TDiary::PATH, TDiary.server_root].map {|base|
42
- ["#{base}/tdiary/style", "#{base}/tdiary"]
43
- }
42
+ [TDiary::PATH, TDiary.server_root].map {|base| "#{base}/tdiary/style" }
44
43
  [paths].flatten.uniq.each do |path|
45
44
  path = path.sub(/\/+$/, '').untaint
46
- Dir.glob("#{path}/*_style.rb") do |style_file|
47
- require style_file.untaint
48
- style = File.basename(style_file).sub(/_style\.rb$/, '')
49
- @styles[style] = TDiary::Style.const_get("#{style.capitalize}Diary")
45
+ Dir.glob("#{path}/*.rb") {|style_file| require style_file.untaint }
46
+ end
47
+ (["tdiary", "wiki"] + [@tdiary.conf.style].map(&:downcase)).flatten.uniq.each do |style|
48
+ klass = TDiary::Style.const_get("#{style.capitalize}Diary")
49
+ klass.send(:include, TDiary::Style::BaseDiary)
50
+ klass.send(:include, TDiary::Style::CategorizableDiary)
51
+ if TDiary::Style.const_defined? ("#{style.capitalize}Section")
52
+ TDiary::Style.const_get("#{style.capitalize}Section").send(:include, TDiary::Style::BaseSection)
50
53
  end
54
+ @styles[style] = klass
51
55
  end
52
56
  end
53
57
 
@@ -117,9 +117,6 @@ module TDiary
117
117
  end
118
118
 
119
119
  class TdiaryDiary
120
- include BaseDiary
121
- include CategorizableDiary
122
-
123
120
  def initialize( date, title, body, modified = Time::now )
124
121
  init_diary
125
122
  replace( date, title, body )
@@ -15,8 +15,6 @@ require 'hikidoc'
15
15
  module TDiary
16
16
  module Style
17
17
  class WikiSection
18
- include BaseSection
19
-
20
18
  def initialize( fragment, author = nil )
21
19
  @author = author
22
20
  if fragment[0] == ?! then
@@ -154,9 +152,6 @@ module TDiary
154
152
  end
155
153
 
156
154
  class WikiDiary
157
- include BaseDiary
158
- include CategorizableDiary
159
-
160
155
  def initialize( date, title, body, modified = Time.now )
161
156
  init_diary
162
157
  replace( date, title, body )
data/tdiary/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module TDiary
2
- VERSION = '4.0.1.20130903'
2
+ VERSION = '4.0.1.20130929'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tdiary
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1.20130903
4
+ version: 4.0.1.20130929
5
5
  platform: ruby
6
6
  authors:
7
7
  - TADA Tadashi
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-09-03 00:00:00.000000000 Z
13
+ date: 2013-09-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: thor
@@ -239,18 +239,6 @@ files:
239
239
  - misc/plugin/xmlrpc.rb
240
240
  - misc/plugin/xmlrpc/README
241
241
  - misc/plugin/xmlrpc/xmlrpc.rb
242
- - misc/style/emptdiary/README.rd
243
- - misc/style/emptdiary/README.rd.en
244
- - misc/style/emptdiary/emptdiary_style.rb
245
- - misc/style/etdiary/README.rd
246
- - misc/style/etdiary/etdiary_style.rb
247
- - misc/style/gfm/gfm_style.rb
248
- - misc/style/rd/README.rd
249
- - misc/style/rd/rd_style.rb
250
- - misc/style/wiki/README
251
- - misc/style/wiki/README.en
252
- - misc/style/wiki/wiki_parser.rb
253
- - misc/style/wiki/wiki_style.rb
254
242
  - misc/templates/Gemfile.local.erb
255
243
  - misc/theme_convert/Readme.rd
256
244
  - misc/theme_convert/append.rcss
@@ -327,10 +315,6 @@ files:
327
315
  - spec/core/rack/html_anchor_spec.rb
328
316
  - spec/core/rack/static_spec.rb
329
317
  - spec/core/rack/valid_request_path_spec.rb
330
- - spec/core/style/emptdiary_style_spec.rb
331
- - spec/core/style/etdiary_style_spec.rb
332
- - spec/core/style/gfm_style_spec.rb
333
- - spec/core/style/rd_style_spec.rb
334
318
  - spec/core/style/tdiary_style_spec.rb
335
319
  - spec/core/style/wiki_style_spec.rb
336
320
  - spec/fixtures/ascii8bit-pstore.db
@@ -398,8 +382,8 @@ files:
398
382
  - tdiary/response.rb
399
383
  - tdiary/server.rb
400
384
  - tdiary/style.rb
401
- - tdiary/style/tdiary_style.rb
402
- - tdiary/style/wiki_style.rb
385
+ - tdiary/style/tdiary.rb
386
+ - tdiary/style/wiki.rb
403
387
  - tdiary/tasks.rb
404
388
  - tdiary/tasks/assets.rake
405
389
  - tdiary/tasks/auth.rake
@@ -456,7 +440,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
456
440
  version: '0'
457
441
  requirements: []
458
442
  rubyforge_project:
459
- rubygems_version: 2.0.7
443
+ rubygems_version: 2.1.3
460
444
  signing_key:
461
445
  specification_version: 4
462
446
  summary: a TSUKKOMI-able Web-log
@@ -487,10 +471,6 @@ test_files:
487
471
  - spec/core/rack/html_anchor_spec.rb
488
472
  - spec/core/rack/static_spec.rb
489
473
  - spec/core/rack/valid_request_path_spec.rb
490
- - spec/core/style/emptdiary_style_spec.rb
491
- - spec/core/style/etdiary_style_spec.rb
492
- - spec/core/style/gfm_style_spec.rb
493
- - spec/core/style/rd_style_spec.rb
494
474
  - spec/core/style/tdiary_style_spec.rb
495
475
  - spec/core/style/wiki_style_spec.rb
496
476
  - spec/fixtures/ascii8bit-pstore.db
@@ -1,83 +0,0 @@
1
- =begin
2
- = emptDiaryスタイル((-$Id: README.rd,v 1.6 2008-03-02 09:01:20 kazuhiko Exp $-))
3
-
4
- == 概要
5
- ((:emptDiaryスタイル:))((-emptDiaryは'empty line permitted tDiary style'
6
- を省略したものです。長いねぇ。-))は、((:tDiaryス タイル:))に加えて、プラ
7
- グインの引数に空白行を許すスタイルです。このスタイルを使うと、日記をセク
8
- ションに分ける際に、<%と%>の間の空白行を無視してもらえます。
9
-
10
- 日記にプログラムリストなどを書く場合に、リストが空白行を含むと、
11
- ((:tDiaryス タイル:))ではリストの途中から次のセクションになってしまいま
12
- す。((:emptDiaryスタイル:))では、プラグインの引数の中の空白を無視するの
13
- で、例えばpre.rbプラグインのヒアドキュメントとしてプログラムリストを記述
14
- することで、プログラムリストに何の変更もなく、日記にリストを書くことがで
15
- きます。
16
-
17
- ((:emptDiaryスタイル:))の最新版は、
18
- ((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb>))から、
19
- このファイルの最新版は、
20
- ((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/README.rd>))か
21
- ら、 入手できるでしょう。
22
-
23
- また、pre.rbの最新版は、
24
- ((<URL:http://zunda.freeshell.org/d/plugin/pre.rb>))から入手できるはずで
25
- す。
26
-
27
- == Usage
28
- このスタイルを使うには、
29
- (1) emptdiary_style.rb ファイルを、tdiary/ ディレクトリにコピーしてくだ
30
- さい。tdiary/ ディレクトリは、tdiary.rb ファイルのあるトップディレク
31
- トリの下にあります。
32
- (2) tdiary.confに以下の行を書いてください。
33
- @style = 'emptDiary'
34
-
35
- 日記は、((:tDiaryスタイル:))とほとんど同じように書くことができます。
36
- HOWTO-write-tDiary.htmlに書かれている通り、
37
- * 空白無しで始まる行は、((:セクションタイトル:))になります。この行には、
38
- ((:セクションアンカー:))が付きます。
39
- * ((:セクションタイトル:))に続く行は、その((:セクション:))の内容になりま
40
- す。
41
- * 空白行によって、次の((:セクション:))と分かれます。
42
- * ((:セクション:))の最初の行を空白や<で始めることによって、
43
- ((:セクションタイトル:))の無い((:セクション:))を作ることができます。
44
-
45
- ((:emptDiaryスタイル:))では、上記のルールに加えて、
46
- * <%と%>に囲まれた空白行は、セクションを分割する際に無視されます。つまり、
47
- あるセクションに、<%と%>に囲まれた空白行を含めることができます。
48
- * 副作用として、日記には、<%と%>が同数、それぞれペアになって含まれていな
49
- いといけません。
50
-
51
- つまり、pre.rbを使って、
52
- セクションタイトル
53
- <p>セクションの内容</p>
54
- <%=pre <<'_PRE'
55
- #include <stdio.h>
56
-
57
- /* 上記は空白行 */
58
- int
59
- main (int argc, char *argv[])
60
- {
61
- puts ("Hello world.");
62
- }
63
- _PRE
64
- %>
65
- などというセクションを作ることができます。不等号やアンパーサンドの実体参
66
- 照への変換は、pre.rbで行われることに注意してください。
67
-
68
- == 謝辞
69
- このスタイルは、((:tDiaryスタイル:))のTdiarySectionとTdiaryDiaryをsuper
70
- classとして実装されています。このようなフレキシブルなクラスを提供されて
71
- いる、tdiary_style.rbの著者の方々に感謝します。
72
-
73
- == 著作権
74
- Copyright 2003 zunda <zunda at freeshell.org>
75
-
76
- Permission is granted for use, copying, modification, distribution,
77
- and distribution of modified versions of this work under the terms
78
- of GPL version 2 or later.
79
- =end
80
- =begin ChangeLog
81
- * Mon Feb 17, 2003 zunda <zunda at freeshell.org>
82
- - first draft
83
- =end
@@ -1,78 +0,0 @@
1
- =begin
2
- = emptDiary style((-$Id: README.rd.en,v 1.5 2003-11-06 09:43:46 zunda Exp $-))
3
-
4
- == Summary
5
- ((:emptDiary style:))((-emptDiary is an abbreviation for 'empty line
6
- permitted tDiary style'. Very long, isn't it?-)) is an extension to the
7
- ((:tDiary style:)) which allows plug-in arguments to have empty lines.
8
- In short, this style preserves empty lines between <% and %> when
9
- splltting the input into sections.
10
-
11
- Sometimes, you would want to include your program list in your diary. In
12
- the case, the ((:tDiary style:)) rule gets in the way: an empty line in
13
- the program list makes a second section. ((:emptDiary style:)) permits
14
- empty lines in the arguments of plug-ins. Thus, using e.g. pre.rb
15
- plugin, you can show your program list without modifying your it.
16
-
17
-
18
- The latest version of this style can be downloaded from
19
- ((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb>)),
20
- and the latest version of this document can be downloaded from
21
- ((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/README.rd.en>)).
22
-
23
- == Usage
24
- If you want to use this style
25
- (1) copy the file emptdiary_style.rb into the tdiary/ directory under
26
- the top directory where tdiary.rb sits.
27
- (2) add the following line into tdiary.conf:
28
- @style = 'emptDiary'
29
-
30
- You can write your diaries in almost the same manner as you have done
31
- with the tDiary style as described in the file HOWTO-write-tDiary.html.
32
- In short:
33
- * A line beginning without a space becomes a ((:section title:)) with a
34
- ((:section anchor:)),
35
- * Lines following the ((:section title:)) become the body of the
36
- ((:section:)),
37
- * An empty line changes ((:section:))s, but
38
- * You can create a ((:section:)) with a ((:section anchor:)) but a
39
- ((:section title:)) with the first line beginning with a space.
40
-
41
- ((:emptDiary style:)) adds the follwing rules:
42
- * Empty lines between <% and %> are ignored when parsing your text into
43
- sections. Thus, you can include empty lines between <% and %>.
44
- As a side effect
45
- * You have to keep <% and %>'s in the pairs.
46
-
47
- Thus, using pre.rb plugin, you can write ((*A*)) section like:
48
- title of the section
49
- <p>Descriptino of the program</p>
50
- <%=pre <<'_PRE'
51
- #include <stdio.h>
52
-
53
- /* above is an empty line */
54
- int
55
- main (int argc, char *argv[])
56
- {
57
- puts ("Hello world.");
58
- }
59
- _PRE
60
- %>
61
- Please note that the <, >, and & charactors are escaped by the pre plugin.
62
-
63
- == Acknowledgements
64
- This style is realized using TdiarySection and TdiaryDiary as
65
- super-classes. I thank the authors of tdiary_style.rb for providing such
66
- flexible classes.
67
-
68
- == Copyright
69
- Copyright 2003 zunda <zunda at freeshell.org>
70
-
71
- Permission is granted for use, copying, modification, distribution,
72
- and distribution of modified versions of this work under the terms
73
- of GPL version 2 or later.
74
- =end
75
- =begin ChangeLog
76
- * Mon Feb 17, 2003 zunda <zunda at freeshell.org>
77
- - first draft
78
- =end
@@ -1,201 +0,0 @@
1
- # -*- coding: utf-8; -*-
2
- =begin
3
- = emptDiary style((-$Id: emptdiary_style.rb,v 1.11 2008-03-02 09:01:20 kazuhiko Exp $-))
4
-
5
- == Summary
6
- This style is an extension to the tDiary style which allows plug-in
7
- arguments to have empty lines. In short, this style preserves empty
8
- lines between <% and %> when splltting the input into sections.
9
-
10
- The latest version of this file can be downloaded from
11
- ((<URL:http://zunda.freeshell.org/d/misc/style/emptdiary/emptdiary_style.rb>)).
12
-
13
- == Usage
14
- if you want to use this style, add the following line into tdiary.conf:
15
- @style = 'emptdiary'
16
- Please see README.rd or README.rd.en for further explanation.
17
-
18
- == Acknowledgements
19
- This style is realized using TdiarySection and TdiaryDiary as
20
- super-classes. I thank the authors of tdiary_style.rb for providing such
21
- flexible classes.
22
-
23
- EmptdiaryDiary::to_html4 and EmptdiaryDiary::to_chtml are copied from
24
- tdiary_style.rb and slightly edited as follows:
25
- * split_unless_plugin() is inserted before each collect()
26
- * Regexp is chanegd from ^ to \A
27
-
28
- == Copyright
29
- Copyright 2003 zunda <zunda at freeshell.org>
30
-
31
- Permission is granted for use, copying, modification, distribution,
32
- and distribution of modified versions of this work under the terms
33
- of GPL version 2 or later.
34
- =end
35
- =begin ChangeLog
36
- * Mon Feb 17, 2003 zunda <zunda at freeshell.org>
37
- - copied from zunda_style.rb, with which I used for preliminary tests.
38
- * Wed Feb 26, 2003 zunda <zunda at freeshell.org>
39
- - TDiary::Emptdiary::String class to handle strings better
40
- (Thanks to Mitsuru Shimamura <mitsuru at diana.dti.ne.jp> for the
41
- error report)
42
- * Wed Dec 22, 2004 zunda <zunda at freeshell.org>
43
- - override body_to_html
44
- =end
45
-
46
- require 'tdiary/style/tdiary_style'
47
-
48
- =begin
49
- == Classes and methods defined in this style
50
- Please note that not all are documented.
51
- =end
52
-
53
- module TDiary
54
- module Style
55
- =begin
56
- === TDiary::Emptdiary::EmptdiaryString < String
57
- Extended String class not to divide things between <% and %>.
58
-
59
- --- TDiary::Emptdiary::EmptdiaryString.split_unless_plugin ( delimiter = "\n\n" )
60
- Returns an array of EmptdiaryString splitted at ((|delimiter|))
61
- which is outside of <% and %> pairs. Specify ((|delimiter|)) as a
62
- String showing a fragment of Regexp. This will be combined in a
63
- Regexp like: /(#{delimiter)|<%|%>)/.
64
- =end
65
- class Emptdiary
66
- class EmptdiaryString < String
67
- def split_unless_plugin( delimiter = "\n\n+" )
68
- result = Array.new
69
- fragment = ''
70
- nest = 0
71
- remain = self.gsub(/.*?(#{delimiter}|<%|%>)/m) do
72
- fragment += $&
73
- case $1
74
- when '<%'
75
- nest += 1
76
- when '%>'
77
- nest -= 1
78
- else
79
- if nest == 0 then
80
- fragment.sub!( /#{delimiter}\z/, '' )
81
- result << Emptdiary::EmptdiaryString.new( fragment ) unless fragment.empty?
82
- fragment = ''
83
- end
84
- end
85
- ''
86
- end
87
- fragment += remain
88
- fragment.sub!( /#{delimiter}\z/, '' )
89
- result << Emptdiary::EmptdiaryString.new( fragment ) unless fragment.empty?
90
- result
91
- end
92
- end
93
- end
94
-
95
- =begin
96
- === TDiary::EmptdiartySection < TdiarySection
97
- Almost the same as TdiarySection but usess split_unless_plugin instead
98
- of split. initialize method is overrideen.
99
- =end
100
- class EmptdiarySection < TdiarySection
101
- def initialize( fragment, author = nil )
102
- @author = author
103
- lines = fragment.split_unless_plugin( "\n+" )
104
- if lines.size > 1 then
105
- if /\A<</ =~ lines[0]
106
- @subtitle = lines.shift.chomp.sub( /\A</, '' )
107
- elsif /\A[  <]/u !~ lines[0]
108
- @subtitle = lines.shift.chomp
109
- end
110
- end
111
- @body = Emptdiary::EmptdiaryString.new( lines.join( "\n" ) )
112
- @categories = get_categories
113
- @stripped_subtitle = strip_subtitle
114
- end
115
-
116
- def body_to_html
117
- html = ""
118
- @body.split_unless_plugin( "\n" ).each do |p|
119
- if /\A</ =~ p then
120
- html << p
121
- else
122
- html << "<p>#{p}</p>"
123
- end
124
- end
125
- html
126
- end
127
- end
128
-
129
- =begin
130
- === TDiary::EmptdiaryDiary < TdiaryDiary
131
- Almost the same as TdiarySection but usess split_unless_plugin instead
132
- of split. append method is overriden and makes EmptdiarySection with
133
- body being an EmptdiaryString. Also, to_html4 and to_chtml methods are
134
- overridden to split_unless_plugin before collect'ing the body of the
135
- sections.
136
- =end
137
- class EmptdiaryDiary < TdiaryDiary
138
- def style
139
- 'emptdiary'
140
- end
141
-
142
- def append( body, author = nil )
143
- Emptdiary::EmptdiaryString.new(body.gsub( /\r/, '' )).split_unless_plugin( "\n\n+" ).each do |fragment|
144
- section = EmptdiarySection::new( fragment, author )
145
- @sections << section if section
146
- end
147
- @last_modified = Time::now
148
- self
149
- end
150
-
151
- def to_html4( opt )
152
- r = ''
153
- each_section do |section|
154
- r << %Q[<div class="section">\n]
155
- r << %Q[<%=section_enter_proc( Time::at( #{date.to_i} ) )%>\n]
156
- if section.subtitle then
157
- r << %Q[<h3><%= subtitle_proc( Time::at( #{date.to_i} ), #{section.subtitle.dump.gsub( /%/, '\\\\045' )} ) %></h3>\n]
158
- end
159
- if /\A</ =~ section.body then
160
- r << %Q[#{section.body}]
161
- elsif section.subtitle
162
- r << %Q[<p>#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[  ]/u, '')}.join( "</p>\n<p>" )}</p>]
163
- else
164
- r << %Q[<p><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
165
- r << %Q[#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[  ]/u, '' )}.join( "</p>\n<p>" )}</p>]
166
- end
167
- r << %Q[<%=section_leave_proc( Time::at( #{date.to_i} ) )%>\n]
168
- r << %Q[</div>]
169
- end
170
- r
171
- end
172
-
173
- def to_chtml( opt )
174
- r = ''
175
- each_section do |section|
176
- r << %Q[<%=section_enter_proc( Time::at( #{date.to_i} ) )%>\n]
177
- if section.subtitle then
178
- r << %Q[<H3><%= subtitle_proc( Time::at( #{date.to_i} ), #{section.subtitle.dump.gsub( /%/, '\\\\045' )} ) %></H3>\n]
179
- end
180
- if /\A</ =~ section.body then
181
- r << section.body
182
- elsif section.subtitle
183
- r << %Q[<P>#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[  ]/u, '' )}.join( "</P>\n<P>" )}</P>]
184
- else
185
- r << %Q[<P><%= subtitle_proc( Time::at( #{date.to_i} ), nil ) %>]
186
- r << %Q[#{section.body.split_unless_plugin( "\n+" ).collect{|l|l.chomp.sub( /\A[  ]/u, '' )}.join( "</P>\n<P>" )}</P>]
187
- end
188
- r << %Q[<%=section_leave_proc( Time::at( #{date.to_i} ) )%>\n]
189
- end
190
- r
191
- end
192
- end
193
- end
194
- end
195
-
196
- # Local Variables:
197
- # mode: ruby
198
- # indent-tabs-mode: t
199
- # tab-width: 3
200
- # ruby-indent-level: 3
201
- # End: