tdiary 4.1.1 → 4.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/ChangeLog +42 -0
- data/Gemfile +2 -11
- data/Gemfile.lock +64 -61
- data/README.md +4 -2
- data/doc/HOWTO-authenticate-in-rack.md +96 -8
- data/doc/HOWTO-testing-tDiary.md +1 -1
- data/doc/INSTALL-paas.md +19 -54
- data/doc/README.en.md +1 -1
- data/doc/README.md +1 -1
- data/js/comment_ajax.js +1 -1
- data/lib/tdiary/application/configuration.rb +5 -9
- data/lib/tdiary/application.rb +59 -36
- data/lib/tdiary/cli.rb +9 -3
- data/lib/tdiary/core_ext.rb +1 -1
- data/lib/tdiary/diary_container.rb +55 -0
- data/lib/tdiary/environment.rb +3 -0
- data/lib/tdiary/plugin/00default.rb +4 -3
- data/lib/tdiary/plugin/05referer.rb +9 -7
- data/lib/tdiary/plugin.rb +13 -2
- data/lib/tdiary/rack/auth/basic.rb +1 -1
- data/lib/tdiary/rack/auth/omniauth/authorization.rb +64 -0
- data/lib/tdiary/rack/auth/omniauth.rb +78 -46
- data/lib/tdiary/rack/auth.rb +20 -0
- data/lib/tdiary/rack/session.rb +35 -0
- data/lib/tdiary/rack.rb +2 -5
- data/lib/tdiary/style.rb +2 -1
- data/lib/tdiary/tasks/assets.rake +1 -1
- data/lib/tdiary/tasks/release.rake +18 -7
- data/lib/tdiary/version.rb +1 -1
- data/lib/tdiary.rb +1 -0
- data/misc/paas/heroku/Gemfile.local +8 -0
- data/misc/paas/heroku/app.json +19 -0
- data/misc/paas/heroku/config.ru +6 -0
- data/misc/paas/heroku/tasks/mongodb.rake +12 -0
- data/misc/paas/heroku/tdiary.conf +14 -14
- data/misc/plugin/amazon.rb +9 -1
- data/misc/plugin/category.rb +1 -19
- data/misc/plugin/category_autocomplete.rb +2 -2
- data/misc/plugin/comment_ajax.rb +2 -0
- data/misc/plugin/comment_emoji_autocomplete.rb +2 -2
- data/misc/plugin/comment_mail-smtp.rb +23 -8
- data/misc/plugin/makerss.rb +5 -1
- data/misc/plugin/recent_comment3.rb +1 -5
- data/misc/plugin/recent_list.rb +1 -5
- data/misc/plugin/theme_online.rb +8 -2
- data/spec/acceptance/save_conf_plugin_spec.rb +2 -2
- data/spec/core/application_spec.rb +65 -0
- data/spec/core/diary_container_spec.rb +71 -0
- data/spec/core/plugin_spec.rb +13 -0
- data/spec/fixtures/tdiary.conf.gem +2 -2
- data/spec/fixtures/tdiary.conf.rack +2 -2
- data/spec/fixtures/tdiary.conf.secure +2 -2
- data/spec/fixtures/tdiary.conf.webrick +2 -2
- data/spec/spec_helper.rb +5 -4
- metadata +15 -6
- data/lib/tdiary/application/extensions/omniauth.rb +0 -22
- data/misc/paas/heroku/Gemfile +0 -20
- data/misc/paas/heroku/Gemfile.lock +0 -74
@@ -34,24 +34,35 @@ def make_tarball( repo, version = nil )
|
|
34
34
|
sh "chmod +x index.rb index.fcgi update.rb update.fcgi"
|
35
35
|
sh 'rake doc'
|
36
36
|
Bundler.with_clean_env do
|
37
|
-
sh "bundle --path .bundle --without coffee:
|
37
|
+
sh "bundle --path .bundle --without coffee:development:test"
|
38
38
|
end
|
39
|
+
|
40
|
+
# reduce filesize
|
41
|
+
Dir.glob('.bundle/ruby/*/cache/*').each do |file|
|
42
|
+
# cached gem file
|
43
|
+
rm_rf file
|
44
|
+
end
|
45
|
+
Dir.glob('.bundle/ruby/*/gems/*/*/').each do |dir|
|
46
|
+
# spec, fixtures etc..
|
47
|
+
rm_rf dir unless File.basename(dir).match(/lib|data/)
|
48
|
+
end
|
49
|
+
|
39
50
|
Dir.chdir '.bundle/ruby' do
|
40
51
|
v = `ls`.chomp
|
41
52
|
case v
|
53
|
+
when '2.2.0'
|
54
|
+
FileUtils.cp_r '2.2.0', '2.0.0'
|
55
|
+
FileUtils.cp_r '2.2.0', '2.1.0'
|
42
56
|
when '2.1.0'
|
43
|
-
FileUtils.cp_r '2.1.0', '1.9.1'
|
44
57
|
FileUtils.cp_r '2.1.0', '2.0.0'
|
58
|
+
FileUtils.cp_r '2.1.0', '2.2.0'
|
45
59
|
when '2.0.0'
|
46
|
-
FileUtils.cp_r '2.0.0', '1.9.1'
|
47
60
|
FileUtils.cp_r '2.0.0', '2.1.0'
|
48
|
-
|
49
|
-
FileUtils.cp_r '1.9.1', '2.0.0'
|
50
|
-
FileUtils.cp_r '1.9.1', '2.1.0'
|
61
|
+
FileUtils.cp_r '2.0.0', '2.2.0'
|
51
62
|
else
|
63
|
+
FileUtils.cp_r v, '2.2.0'
|
52
64
|
FileUtils.cp_r v, '2.1.0'
|
53
65
|
FileUtils.cp_r v, '2.0.0'
|
54
|
-
FileUtils.cp_r v, '1.9.1'
|
55
66
|
FileUtils.rm_rf v
|
56
67
|
end
|
57
68
|
end
|
data/lib/tdiary/version.rb
CHANGED
data/lib/tdiary.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"name": "tDiary",
|
3
|
+
"website": "http://www.tdiary.org/",
|
4
|
+
"repository": "https://github.com/tdiary/tdiary-core/tree/heroku",
|
5
|
+
"addons": [
|
6
|
+
"sendgrid",
|
7
|
+
"memcachier",
|
8
|
+
"mongolab"
|
9
|
+
],
|
10
|
+
"scripts": {
|
11
|
+
"postdeploy": "bundle exec rake mongodb:index"
|
12
|
+
},
|
13
|
+
"env": {
|
14
|
+
"TWITTER_KEY": "",
|
15
|
+
"TWITTER_SECRET": "",
|
16
|
+
"TWITTER_NAME": "",
|
17
|
+
"RACK_ENV": "production"
|
18
|
+
}
|
19
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
namespace :mongodb do
|
2
|
+
desc "make index into mongoDB"
|
3
|
+
task :index do
|
4
|
+
require 'erb'
|
5
|
+
require 'tdiary'
|
6
|
+
conf = TDiary::Config.new
|
7
|
+
TDiary::DiaryContainer.new(conf, '2015', '01')
|
8
|
+
TDiary::IO::MongoDB::Diary.create_indexes
|
9
|
+
TDiary::IO::MongoDB::Comment.create_indexes
|
10
|
+
TDiary::IO::MongoDB::Plugin.create_indexes
|
11
|
+
end
|
12
|
+
end
|
@@ -1,9 +1,13 @@
|
|
1
|
+
#
|
2
|
+
# tdiary.conf for Heroku
|
3
|
+
#
|
1
4
|
require 'tempfile'
|
2
5
|
@data_path = Dir.tmpdir
|
3
6
|
|
4
7
|
@style = 'Wiki'
|
5
8
|
|
6
|
-
@io_class = TDiary::IO::
|
9
|
+
@io_class = TDiary::IO::MongoDB
|
10
|
+
@database_url = ENV['MONGOLAB_URI']
|
7
11
|
|
8
12
|
@index = './'
|
9
13
|
@update = 'update.rb'
|
@@ -21,21 +25,17 @@ require 'tempfile'
|
|
21
25
|
|
22
26
|
@options['apply_plugin'] = true
|
23
27
|
@options['sp.path'] = ['misc/plugin']
|
24
|
-
@options['
|
25
|
-
@options['sp.selected'] =
|
26
|
-
"amazon.rb
|
27
|
-
append-css.rb
|
28
|
-
calendar2.rb
|
29
|
-
dropdown_calendar.rb
|
30
|
-
footnote.rb
|
31
|
-
highlight.rb
|
32
|
-
image.rb
|
33
|
-
jdate.rb
|
34
|
-
kw.rb
|
35
|
-
my-ex.rb
|
36
|
-
"
|
28
|
+
@options['sp.selected'] = %w(amazon.rb append-css.rb calendar2.rb comment_ajax.rb comment_mail-smtp.rb dropdown_calendar.rb footnote.rb highlight.rb html_anchor.rb jdate.rb makerss.rb kw.rb my-ex.rb theme_online.rb ).join("\n")
|
37
29
|
|
38
30
|
@options['dropdown_calendar.label'] = ''
|
31
|
+
|
32
|
+
@options['comment_mail.smtp_host'] = 'smtp.sendgrid.net'
|
33
|
+
@options['comment_mail.smtp_port'] = 587
|
34
|
+
@options['comment_mail.user_name'] = ENV['SENDGRID_USERNAME']
|
35
|
+
@options['comment_mail.password'] = ENV['SENDGRID_PASSWORD']
|
36
|
+
@options['comment_mail.authentication'] = :plain
|
37
|
+
@options['comment_mail.starttls'] = true
|
38
|
+
|
39
39
|
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
40
40
|
@options['spamfilter.bad_ip_addrs'] = ""
|
41
41
|
@options['spamfilter.bad_mail_patts'] = "(mu@alloha\\.info|mumu2004@mail\\.com|zhongleibo|dfd@12\\.com|anonimous|aol\\.|yahoo\\.|google\\.|hotmail\\.|msn\\.|leroy\\.|ablare\\.|gmx\\.|lorazepam|\\.co$)"
|
data/misc/plugin/amazon.rb
CHANGED
@@ -46,6 +46,8 @@ if @conf['amazon.bitly'] and @conf['bitly.login'] and @conf['bitly.key'] then
|
|
46
46
|
add_js_setting( '$tDiary.plugin.bitly.apiKey', "'#{@conf['bitly.key']}'" )
|
47
47
|
end
|
48
48
|
|
49
|
+
class AmazonRedirectError < StandardError; end
|
50
|
+
|
49
51
|
def amazon_fetch( url, limit = 10 )
|
50
52
|
raise ArgumentError, 'HTTP redirect too deep' if limit == 0
|
51
53
|
|
@@ -57,6 +59,8 @@ def amazon_fetch( url, limit = 10 )
|
|
57
59
|
res.body
|
58
60
|
when Net::HTTPRedirection
|
59
61
|
amazon_fetch( res['location'].untaint, limit - 1 )
|
62
|
+
when Net::HTTPForbidden, Net::HTTPServiceUnavailable
|
63
|
+
raise AmazonRedirectError.new( limit.to_s )
|
60
64
|
else
|
61
65
|
raise ArgumentError, res.error!
|
62
66
|
end
|
@@ -78,10 +82,14 @@ def amazon_call_ecs( asin, id_type, country )
|
|
78
82
|
url << "&ResponseGroup=Medium"
|
79
83
|
url << "&Version=#{@amazon_require_version}"
|
80
84
|
|
85
|
+
limit = 10
|
81
86
|
begin
|
82
|
-
Timeout.timeout(
|
87
|
+
Timeout.timeout( limit ) do
|
83
88
|
amazon_fetch( url )
|
84
89
|
end
|
90
|
+
rescue AmazonRedirectError
|
91
|
+
limit = $!.message.to_i
|
92
|
+
retry
|
85
93
|
rescue ArgumentError
|
86
94
|
end
|
87
95
|
end
|
data/misc/plugin/category.rb
CHANGED
@@ -208,20 +208,6 @@ end
|
|
208
208
|
|
209
209
|
module Category
|
210
210
|
|
211
|
-
#
|
212
|
-
# CGI (mock-up CGI class for Cache::recreate)
|
213
|
-
#
|
214
|
-
class CGI
|
215
|
-
attr_reader :params
|
216
|
-
def initialize
|
217
|
-
@params = Hash.new([])
|
218
|
-
end
|
219
|
-
def referer; nil; end
|
220
|
-
def user_agent; nil; end
|
221
|
-
def mobile_agent?; nil; end
|
222
|
-
def request_method; 'GET'; end
|
223
|
-
end
|
224
|
-
|
225
211
|
#
|
226
212
|
# Info
|
227
213
|
#
|
@@ -487,17 +473,13 @@ class Cache
|
|
487
473
|
# (re)create category cache
|
488
474
|
#
|
489
475
|
def recreate(years)
|
490
|
-
cgi = Category::CGI::new
|
491
|
-
|
492
476
|
list = []
|
493
477
|
@plugin.__send__(:transaction, 'category') do |db|
|
494
478
|
db.keys.each {|key|db.delete(key)}
|
495
479
|
|
496
480
|
years.each do |y, ms|
|
497
481
|
ms.each do |m|
|
498
|
-
|
499
|
-
cgi.params['date'] = [ym]
|
500
|
-
m = TDiaryMonthWithoutFilter.new(cgi, '', @conf)
|
482
|
+
m = DiaryContainer::find_by_month(@conf, "#{y}#{m}")
|
501
483
|
m.diaries.each do |ymd, diary|
|
502
484
|
next if !diary.visible? or !diary.categorizable?
|
503
485
|
categorized = categorize_diary(diary)
|
@@ -9,10 +9,10 @@
|
|
9
9
|
|
10
10
|
if !@cgi.mobile_agent? && /\A(?:form|preview|append|edit|update)\z/ =~ @mode
|
11
11
|
add_header_proc do
|
12
|
-
%Q|<link rel="stylesheet" href="
|
12
|
+
%Q|<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"/>|
|
13
13
|
end
|
14
14
|
|
15
|
-
enable_js('
|
15
|
+
enable_js('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js')
|
16
16
|
enable_js('caretposition.js')
|
17
17
|
enable_js('category_autocomplete.js')
|
18
18
|
|
data/misc/plugin/comment_ajax.rb
CHANGED
@@ -9,10 +9,10 @@
|
|
9
9
|
|
10
10
|
if !@cgi.mobile_agent? && /\A(?:day)\z/ =~ @mode
|
11
11
|
add_header_proc do
|
12
|
-
%Q|<link rel="stylesheet" href="
|
12
|
+
%Q|<link rel="stylesheet" href="//ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"/>|
|
13
13
|
end
|
14
14
|
|
15
|
-
enable_js('
|
15
|
+
enable_js('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js')
|
16
16
|
enable_js('caretposition.js')
|
17
17
|
enable_js('comment_emoji_autocomplete.js')
|
18
18
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# comment_mail-smtp.rb
|
3
3
|
#
|
4
4
|
# SMTPプロトコルを使ってツッコミをメールで知らせる
|
5
|
-
#
|
5
|
+
# 同一ホスト内にSMTPサーバがある場合は有効にするだけで動作する
|
6
6
|
#
|
7
7
|
# Options:
|
8
8
|
# 設定画面から指定できるもの(ツッコミメール系プラグイン共通):
|
@@ -25,18 +25,33 @@
|
|
25
25
|
# @options['comment_mail.smtp_port']
|
26
26
|
# それぞれ、メール送信に使うSMTPサーバのホスト名とポート番号。
|
27
27
|
# 無指定時はそれぞれ「'localhost'」と「25」。
|
28
|
+
# 以下は通常は不要。必要に応じて指定する:
|
29
|
+
# @options['comment_mail.user_name']
|
30
|
+
# @options['comment_mail.password']
|
31
|
+
# SMTP認証が必要な場合のユーザ名とパスワード
|
32
|
+
# @options['comment_mail.authentication']
|
33
|
+
# SMTP認証の方式。:plainや:loginなど(Mail gemに指定できるもの)
|
34
|
+
# @options['comment_mail.starttls']
|
35
|
+
# TLSに自動接続する(true/false) (Mail gem)
|
28
36
|
#
|
29
|
-
# Copyright (c)
|
37
|
+
# Copyright (c) 2015 TADA Tadashi <t@tdtds.jp>
|
30
38
|
# You can distribute this file under the GPL2 or any later version.
|
31
39
|
#
|
32
40
|
def comment_mail( text, to )
|
33
41
|
begin
|
34
|
-
require '
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
42
|
+
require 'mail'
|
43
|
+
|
44
|
+
mail = Mail.new( text )
|
45
|
+
delivery_opts = {
|
46
|
+
address: @conf['comment_mail.smtp_host'] || 'localhost',
|
47
|
+
port: @conf['comment_mail.smtp_port'] || 25,
|
48
|
+
authentication: @conf['comment_mail.authentication'],
|
49
|
+
user_name: @conf['comment_mail.user_name'],
|
50
|
+
password: @conf['comment_mail.password'],
|
51
|
+
enable_starttls_auto: @conf['comment_mail.starttls']
|
52
|
+
}.delete_if{|k,v| v == nil}
|
53
|
+
mail.delivery_method( :smtp, delivery_opts )
|
54
|
+
mail.deliver
|
40
55
|
rescue
|
41
56
|
$stderr.puts $!
|
42
57
|
end
|
data/misc/plugin/makerss.rb
CHANGED
@@ -28,7 +28,7 @@
|
|
28
28
|
# Distributed under the GPL2 or any later version.
|
29
29
|
#
|
30
30
|
|
31
|
-
if /^append|replace|comment|showcomment$/ =~ @mode then
|
31
|
+
if /^append|replace|comment|showcomment|startup$/ =~ @mode then
|
32
32
|
unless @conf.description
|
33
33
|
@conf.description = @conf['whatsnew_list.rdf.description']
|
34
34
|
end
|
@@ -486,6 +486,10 @@ add_edit_proc do
|
|
486
486
|
HTML
|
487
487
|
end
|
488
488
|
|
489
|
+
add_startup_proc do
|
490
|
+
makerss_update
|
491
|
+
end
|
492
|
+
|
489
493
|
def replace_entities( text )
|
490
494
|
unless @xml_entity_table then
|
491
495
|
@xml_entity_table = {
|
@@ -95,13 +95,9 @@ def recent_comment3(ob_max = 'OBSOLUTE' ,sep = 'OBSOLUTE',ob_date_format = 'OBSO
|
|
95
95
|
if entries.size == 0
|
96
96
|
notfound_msg
|
97
97
|
else
|
98
|
-
cgi = CGI::new
|
99
|
-
def cgi.referer; nil; end
|
100
|
-
|
101
98
|
tree_order.each do |entry_date|
|
102
99
|
a_entry = @index + anchor(entry_date)
|
103
|
-
|
104
|
-
diary = TDiaryDayWithoutFilter::new(cgi, '', @conf)
|
100
|
+
diary = DiaryContainer::find_by_day(@conf, entry_date)
|
105
101
|
title = diary.diaries[entry_date].title.gsub( /<[^>]*>/, '' ) if diary
|
106
102
|
|
107
103
|
if title.nil? || title.length == 0 || title.strip.delete(' ').delete(' ').length == 0 then
|
data/misc/plugin/recent_list.rb
CHANGED
@@ -28,14 +28,10 @@ def recent_list( days = 30, date_format = nil, title_with_body = nil, show_size
|
|
28
28
|
|
29
29
|
result = %Q|<ul class="recent-list">\n|
|
30
30
|
|
31
|
-
cgi = CGI::new
|
32
|
-
def cgi.referer; nil; end
|
33
|
-
|
34
31
|
catch(:exit) {
|
35
32
|
@years.keys.sort.reverse_each do |year|
|
36
33
|
@years[year].sort.reverse_each do |month|
|
37
|
-
|
38
|
-
m = TDiaryMonthWithoutFilter::new(cgi, '', @conf)
|
34
|
+
m = DiaryContainer::find_by_month(@conf, "#{year}#{month}")
|
39
35
|
m.diaries.keys.sort.reverse_each do |date|
|
40
36
|
next unless m.diaries[date].visible?
|
41
37
|
result << %Q|<li><a href="#{@index}#{anchor date}">#{m.diaries[date].date.strftime(date_format)}</a>\n|
|
data/misc/plugin/theme_online.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# theme_online.rb: choice theme from online repository on tDiary.org
|
2
2
|
#
|
3
|
+
# options:
|
4
|
+
# @options['theme_online.url']: top level URL of another theme site
|
5
|
+
#
|
3
6
|
# Copyright (C) 2014 by TADA Tadashi <t@tdtds.jp>
|
4
7
|
# You can distribute and/or modify it under GPL2 or any later version.
|
5
8
|
#
|
@@ -7,8 +10,10 @@ require 'json'
|
|
7
10
|
require 'open-uri'
|
8
11
|
|
9
12
|
def theme_list_online(list)
|
13
|
+
url = @options['theme_online.url'] || 'http://theme.tdiary.org/'
|
14
|
+
url = "http:#{url}" if url =~ %r|\A//|
|
10
15
|
begin
|
11
|
-
online_list = JSON.load(open('
|
16
|
+
online_list = JSON.load(open(File.join(url, 'themes.json'), &:read))['themes']
|
12
17
|
list + online_list.keys.map do |t|
|
13
18
|
title = online_list[t]['title']
|
14
19
|
label = t == title ? '' : " (#{title})"
|
@@ -21,5 +26,6 @@ def theme_list_online(list)
|
|
21
26
|
end
|
22
27
|
|
23
28
|
def theme_url_online(theme)
|
24
|
-
|
29
|
+
url = @options['theme_online.url'] || 'http://theme.tdiary.org/'
|
30
|
+
File.join(url, "#{h theme}/#{h theme}.css")
|
25
31
|
end
|
@@ -56,8 +56,8 @@ feature 'プラグイン選択設定の利用' do
|
|
56
56
|
|
57
57
|
expect(page.body).to be_include('caretposition.js')
|
58
58
|
expect(page.body).to be_include('category_autocomplete.js')
|
59
|
-
expect(page.body).to be_include('
|
60
|
-
expect(page.body).not_to be_include('
|
59
|
+
expect(page.body).to be_include('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js')
|
60
|
+
expect(page.body).not_to be_include('//ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js?')
|
61
61
|
end
|
62
62
|
end
|
63
63
|
# Local Variables:
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'rack/test'
|
4
|
+
require 'tdiary/application'
|
5
|
+
|
6
|
+
describe TDiary::Application do
|
7
|
+
include Rack::Test::Methods
|
8
|
+
|
9
|
+
before do
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#call' do
|
13
|
+
let(:app) { TDiary::Application.new }
|
14
|
+
|
15
|
+
context "when is accessed to index"
|
16
|
+
it do
|
17
|
+
get '/'
|
18
|
+
expect(last_response.status).to eq 200
|
19
|
+
end
|
20
|
+
|
21
|
+
context "when is accessed to update" do
|
22
|
+
it do
|
23
|
+
get '/update.rb'
|
24
|
+
expect(last_response.status).to eq 401
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
context "with base_dir" do
|
29
|
+
let(:app) { TDiary::Application.new('/diary') }
|
30
|
+
|
31
|
+
it do
|
32
|
+
get '/diary/'
|
33
|
+
expect(last_response.status).to eq 200
|
34
|
+
end
|
35
|
+
|
36
|
+
context "when access to root directory" do
|
37
|
+
it do
|
38
|
+
get '/'
|
39
|
+
expect(last_response.status).to eq 404
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when the application raises exception" do
|
45
|
+
before do
|
46
|
+
allow(TDiary::Dispatcher).to receive_message_chain(:index).and_return(
|
47
|
+
lambda {|env| raise StandardError.new }
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
it do
|
52
|
+
get '/'
|
53
|
+
expect(last_response.status).to eq 500
|
54
|
+
expect(last_response.body).to match(/^StandardError/)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Local Variables:
|
61
|
+
# mode: ruby
|
62
|
+
# indent-tabs-mode: t
|
63
|
+
# tab-width: 3
|
64
|
+
# ruby-indent-level: 3
|
65
|
+
# End:
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'tdiary'
|
4
|
+
require 'tdiary/cache/file'
|
5
|
+
require 'tdiary/io/default'
|
6
|
+
require 'tdiary/diary_container'
|
7
|
+
|
8
|
+
describe TDiary::DiaryContainer do
|
9
|
+
let(:conf) { TDiary::Configuration.new }
|
10
|
+
let(:today) { Time.local(2005, 1, 20, 12, 0, 0) }
|
11
|
+
|
12
|
+
let(:tdiary_conf_org) { File.join(TDiary::root, "spec/fixtures/tdiary.conf.webrick") }
|
13
|
+
let(:tdiary_conf) { File.join(TDiary::root, "tdiary.conf") }
|
14
|
+
|
15
|
+
before do
|
16
|
+
# create sample confing
|
17
|
+
FileUtils.cp_r tdiary_conf_org, tdiary_conf, verbose: false
|
18
|
+
|
19
|
+
# create sample diary
|
20
|
+
tdiary = DummyTDiary.new
|
21
|
+
tdiary.conf = conf
|
22
|
+
io = TDiary::IO::Default.new(tdiary)
|
23
|
+
io.transaction(today) do |diaries|
|
24
|
+
date = today.strftime('%Y%m%d')
|
25
|
+
diary = io.diary_factory(date, "foo", "", "wiki")
|
26
|
+
diaries[date] = diary.append("bar")
|
27
|
+
TDiary::TDiaryBase::DIRTY_DIARY
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
after do
|
32
|
+
FileUtils.rm_f tdiary_conf
|
33
|
+
["/tmp/data/#{today.year}"].each do |dir|
|
34
|
+
FileUtils.rm_rf File.join(TDiary.root, dir)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with find_by_month" do
|
39
|
+
let(:diary) { TDiary::DiaryContainer.find_by_month(conf, "200501") }
|
40
|
+
it { expect(diary).to be_a_kind_of TDiary::DiaryContainer }
|
41
|
+
|
42
|
+
describe "#conf" do
|
43
|
+
subject { diary.conf }
|
44
|
+
it { expect(subject).to be_a_kind_of TDiary::Configuration }
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#diaries" do
|
48
|
+
subject { diary.diaries }
|
49
|
+
it { expect(subject).to be_a_kind_of Hash }
|
50
|
+
it { expect(subject.keys).to include('20050120') }
|
51
|
+
it { expect(subject.values).to include(be_a_kind_of TDiary::Style::WikiDiary) }
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "with find_by_day" do
|
56
|
+
let(:diary) { TDiary::DiaryContainer.find_by_day(conf, "20050120") }
|
57
|
+
it { expect(diary).to be_a_kind_of TDiary::DiaryContainer }
|
58
|
+
|
59
|
+
describe "#conf" do
|
60
|
+
subject { diary.conf }
|
61
|
+
it { expect(subject).to be_a_kind_of TDiary::Configuration }
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "#diaries" do
|
65
|
+
subject { diary.diaries }
|
66
|
+
it { expect(subject).to be_a_kind_of Hash }
|
67
|
+
it { expect(subject.keys).to include('20050120') }
|
68
|
+
it { expect(subject.values).to include(be_a_kind_of TDiary::Style::WikiDiary) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/spec/core/plugin_spec.rb
CHANGED
@@ -379,6 +379,19 @@ describe TDiary::Plugin do
|
|
379
379
|
it { expect { subject }.to raise_error }
|
380
380
|
end
|
381
381
|
end
|
382
|
+
|
383
|
+
describe '#startup_proc' do
|
384
|
+
let (:proc) { lambda { "some plugin" } }
|
385
|
+
let (:app) { lambda { "tdiary application" } }
|
386
|
+
before do
|
387
|
+
@plugin.__send__(:add_startup_proc, &proc)
|
388
|
+
end
|
389
|
+
|
390
|
+
it 'add_startup_procで登録したブロックが実行されること' do
|
391
|
+
expect(proc).to receive(:call).with(app)
|
392
|
+
@plugin.__send__(:startup_proc, app)
|
393
|
+
end
|
394
|
+
end
|
382
395
|
end
|
383
396
|
|
384
397
|
# Local Variables:
|
@@ -38,8 +38,8 @@ recent_list.rb
|
|
38
38
|
"
|
39
39
|
|
40
40
|
@options['dropdown_calendar.label'] = ''
|
41
|
-
@options['makerss.file'] = '
|
42
|
-
@options['makerss.no_comments.file'] = '
|
41
|
+
@options['makerss.file'] = 'index.rdf'
|
42
|
+
@options['makerss.no_comments.file'] = 'no_comments.rdf'
|
43
43
|
|
44
44
|
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
45
45
|
@options['spamfilter.bad_ip_addrs'] = ""
|
@@ -38,8 +38,8 @@ recent_list.rb
|
|
38
38
|
"
|
39
39
|
|
40
40
|
@options['dropdown_calendar.label'] = ''
|
41
|
-
@options['makerss.file'] = '
|
42
|
-
@options['makerss.no_comments.file'] = '
|
41
|
+
@options['makerss.file'] = 'index.rdf'
|
42
|
+
@options['makerss.no_comments.file'] = 'no_comments.rdf'
|
43
43
|
|
44
44
|
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
45
45
|
@options['spamfilter.bad_ip_addrs'] = ""
|
@@ -37,8 +37,8 @@ my-ex.rb
|
|
37
37
|
"
|
38
38
|
|
39
39
|
@options['dropdown_calendar.label'] = ''
|
40
|
-
@options['makerss.file'] = '
|
41
|
-
@options['makerss.no_comments.file'] = '
|
40
|
+
@options['makerss.file'] = 'index.rdf'
|
41
|
+
@options['makerss.no_comments.file'] = 'no_comments.rdf'
|
42
42
|
|
43
43
|
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
44
44
|
@options['spamfilter.bad_ip_addrs'] = ""
|
@@ -39,8 +39,8 @@ recent_list.rb
|
|
39
39
|
"
|
40
40
|
|
41
41
|
@options['dropdown_calendar.label'] = ''
|
42
|
-
@options['makerss.file'] = '
|
43
|
-
@options['makerss.no_comments.file'] = '
|
42
|
+
@options['makerss.file'] = 'index.rdf'
|
43
|
+
@options['makerss.no_comments.file'] = 'no_comments.rdf'
|
44
44
|
|
45
45
|
@options['spamfilter.bad_comment_patts'] = "(href=|casino|gambling|betting|fastsearch\\.eu\\.com|ganzao|poker|holdem|hold.em|roulette|drug|tramadol|viagra|fioricet|oxycontin|biaxin|aldara|business cards|home depot|slot.?machine|insurance|getblog2|video-game|Good site|internet-all\\.com|deai|tdfms|comu2|omaha)\r\n"
|
46
46
|
@options['spamfilter.bad_ip_addrs'] = ""
|
data/spec/spec_helper.rb
CHANGED
@@ -26,10 +26,11 @@ RSpec.configure do |config|
|
|
26
26
|
end
|
27
27
|
|
28
28
|
class DummyTDiary
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
attr_accessor :conf
|
30
|
+
|
31
|
+
def initialize
|
32
|
+
@conf = DummyConf.new
|
33
|
+
@conf.data_path = TDiary.root + "/tmp/"
|
33
34
|
end
|
34
35
|
|
35
36
|
def ignore_parser_cache
|