misc/plugin/disp_referrer.rb in tdiary-4.2.1 vs misc/plugin/disp_referrer.rb in tdiary-5.0.0
- old
+ new
@@ -73,11 +73,10 @@
=end
# to be visible from inside classes
Dispref2plugin = self
Dispref2plugin_cache_path = @cache_path
Dispref2plugin_cache_dir = @cache_dir
-Dispref2plugin_secure = @conf.secure
# cache format
Root_DispRef2URL = 'dispref2url' # root for DispRef2URLs
=begin
@@ -138,94 +137,17 @@
--- DispRef2PSTore#real?
本物のPSToreが使える時はtrue、そうでない時はfalseを返します。
=end
-unless @conf and @conf.secure then
- class DispRef2CachePath
- def initialize( setup )
- @setup = setup
- end
- def cache( date )
- return File.join( @setup['cache_dir'], 'volatile.tdr2.cache' ) unless date
- begin
- Dir.mkdir( @setup['cache_dir'].untaint )
- rescue Errno::EEXIST
- end
- File.join( @setup['cache_dir'], date.strftime( '%Y%m.tdr2.cache' ) )
- end
- def caches( include_backup = true )
- if include_backup then
- r = Dir.glob( File.join( @setup['cache_dir'], '??????.tdr2.cache*' ) )
- else
- r = Dir.glob( File.join( @setup['cache_dir'], '??????.tdr2.cache' ) )
- end
- r.collect{ |p| p.untaint }
- end
- def size
- r = 0
- caches.each do |path|
- r += File.size( path )
- end
- r
- end
- def clear
- # current version
- caches.each do |path|
- begin
- File.unlink( path )
- rescue Errno::ENOENT
- end
- end
- # older version
- if @setup['cache_path'] then
- [ @setup['cache_path'], @setup['cache_path']+'~' ].each do |f|
- File.unlink( f ) if FileTest::exist?( f )
- end
- end
- end
- def shrink
- return if @setup['cache_max_size'] <= 0
- size = 0
- begin
- caches.sort{ |a,b| File.atime( b ) <=> File.atime( a ) }.each do |path|
- if size < @setup['cache_max_size'] then
- size += File.size( path )
- else
- File.unlink( path )
- end
- end
- rescue Errno::ENOENT
- end
- end
+class DispRef2PStore < DispRef2DummyPStore
+ def real?
+ false
end
-
- require 'pstore'
- class DispRef2PStore < PStore
- def real?
- true
- end
- def transaction( read_only = false )
- begin
- super
- rescue TypeError
- File.unlink( self.path )
- super
- rescue ArgumentError
- super()
- end
- end
- end
-else
- class DispRef2PStore < DispRef2DummyPStore
- def real?
- false
- end
- end
- class DispRef2CachePath < DispRef2CachePathDummy
- end
end
+class DispRef2CachePath < DispRef2CachePathDummy
+end
=begin
=== Tdiary::Plugin::DispRef2String
文字コードの変換、URL、HTMLでの取り扱いに関するメソッド群です。インスタ
ンスは作りません。Uconvライブラリがあればそれを使い、無ければ無いなりに処理します。
@@ -478,22 +400,22 @@
# このプラグインで使うキャッシュファイルのディレクトリです。
'cache_max_size' => 10485760, # 10MB
# キャッシュの合計量の制限(バイト)です。時々越えます。
# 0未満なら制限しません。
'no_cache' => false,
- # trueの場合、@secure=falseな日記でもキャッシュを使いません。
+ # trueの場合キャッシュを使いません。
'normal-unknown.title' => '\Ahttps?:\/\/',
# 置換された「その他」のリンク元のタイトル、あるいは置換されていな
# いリンク元のタイトルにマッチします。
'configure.use_link' => true,
# リンク元置換リストの編集画面で、リンク元へのリンクを作ります。
'reflist.ignore_urls' => '',
# 置換リストのリストアップの際に無視するURLの正規表現の文字列
# \n区切で並べます
}
- attr_reader :is_long, :referer_table, :no_referer, :secure, :years, :conf
+ attr_reader :is_long, :referer_table, :no_referer, :years, :conf
def initialize( conf, limit = 100, is_long = true, years = nil, mode = nil )
super()
@conf = conf
@years = years
@@ -506,13 +428,10 @@
# URL tables
@referer_table = conf.referer_table
@no_referer = conf.no_referer
- # security
- @secure = Dispref2plugin_secure
-
# options from tDiary
update!
end
def to_native( str )
@@ -785,11 +704,11 @@
if title.gsub!( /#{url}/iu, name ) then
matched = true
break
end
else
- name.untaint unless setup.secure
+ name.untaint
if title.gsub!( /#{url}/iu ) { eval name } then
matched = true
break
end
end
@@ -1161,11 +1080,11 @@
@current_mode = Options
end
else
@current_mode = Options
end
- if not @setup.secure and not @setup['no_cache'] then
+ unless @setup['no_cache'] then
@cache = @setup.cache_path
else
@cache = nil
end
end
@@ -1181,11 +1100,11 @@
update_tables
end
end
# clear cache
- if @mode == 'saveconf' and not @setup.secure then
+ if @mode == 'saveconf' then
if not @setup['no_cache'] then
unless @cache then
@need_cache_update = true
@cache = @setup.cache_path
end
@@ -1414,30 +1333,11 @@
r << DispRef2Refs.new( @referer_volatile, setup ).to_long_html( volatile_referer ) if @referer_volatile and latest_day?( diary )
setup.cache_path.shrink
r
end
-# for newest diary
-#alias dispref2_original_referer_of_today_short referer_of_today_short
-#def referer_of_today_short( diary, limit = 10 )
-# return '' if bot?
-# return dispref2_original_referer_of_today_short( diary, limit ) if @options.has_key?( 'disp_referrer2.short.only_normal' ) and not @options['disp_referrer2.short.only_normal']
-# setup = DispRef2Setup.new( @conf, limit, false, nil, @mode )
-# DispRef2Refs.new( diary, setup ).to_short_html
-#end
-
# we have to know the unknown urls at this moment in a secure diary
-if @conf.secure and (\
- ( @cgi.params['dr2.change_mode'] \
- and DispRef2SetupIF::RefList == @cgi.params['dr2.new_mode'][0] ) \
- or ( @cgi.params['dr2.current_mode'] \
- and DispRef2SetupIF::RefList == @cgi.params['dr2.current_mode'][0] ) )
-then
- setup = DispRef2Setup.new( @conf, 100, true, @mode )
- DispRef2Latest_cache = DispRef2Latest.new( @cgi, 'latest.rhtml', @conf, setup )
-else
- DispRef2Latest_cache = nil
-end
+DispRef2Latest_cache = nil
# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3