Sha256: 2435d8d0ca64032b50ecc1b8822ff176c02fc25dba8c0df6aeec430e3d869534

Contents?: true

Size: 919 Bytes

Versions: 18

Compression:

Stored size: 919 Bytes

Contents

# -*- coding: utf-8; -*-
#
# limitdays.rb: 
#
# Copyright (C) SHIBATA Hiroshi <shibata.hiroshi@gmail.com> 2008.
# Distributed under GPL2.
#

module TDiary::Filter
	class LimitdaysFilter < Filter
		def comment_filter( diary, comment )
			if @conf.options.include?('spamfilter.date_limit') &&
					@conf.options['spamfilter.date_limit'] &&
					/\A\d+\z/ =~ @conf.options['spamfilter.date_limit'].to_s
				@date_limit = @conf.options['spamfilter.date_limit'].to_s.to_i
			else
				@date_limit = nil
			end
			
			if @date_limit
				now = Time.now
				today = Time.local(now.year, now.month, now.day)
				limit = today - 24 * 60 * 60 * @date_limit
				if diary.date < limit
					debug( "too old: #{diary.date} (limit >= #{limit})" )
					comment.show = false
					return false
				end
			end
			return true
		end
	end
end

# Local Variables:
# mode: ruby
# indent-tabs-mode: t
# tab-width: 3
# ruby-indent-level: 3
# End:

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
tdiary-4.0.2.20140201 misc/filter/limitdays.rb
tdiary-4.0.2 misc/filter/limitdays.rb
tdiary-4.0.1.20131102 misc/filter/limitdays.rb
tdiary-4.0.1.20130929 misc/filter/limitdays.rb
tdiary-4.0.1.20130903 misc/filter/limitdays.rb
tdiary-4.0.1 misc/filter/limitdays.rb
tdiary-4.0.0.20130826 misc/filter/limitdays.rb
tdiary-4.0.0 misc/filter/limitdays.rb
tdiary-3.2.2.20130727 misc/filter/limitdays.rb
tdiary-3.2.2.20130722 misc/filter/limitdays.rb
tdiary-3.2.2.20130720 misc/filter/limitdays.rb
tdiary-3.2.2.20130617 misc/filter/limitdays.rb
tdiary-3.2.2.20130614 misc/filter/limitdays.rb
tdiary-3.2.2.20130604 misc/filter/limitdays.rb
tdiary-3.2.2.20130527 misc/filter/limitdays.rb
tdiary-3.2.2.20130518 misc/filter/limitdays.rb
tdiary-3.2.2.20130508 misc/filter/limitdays.rb
tdiary-3.2.2.20130507 misc/filter/limitdays.rb