Sha256: 6e15ecdc118811b4eaa4aec61601ba0e82150167cacb4c1b8da00a8c2276b97d

Contents?: true

Size: 911 Bytes

Versions: 38

Compression:

Stored size: 911 Bytes

Contents

#
# limitdays.rb:
#
# Copyright (C) SHIBATA Hiroshi <shibata.hiroshi@gmail.com> 2008.
# Distributed under GPL2 or any later version.
#

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

38 entries across 28 versions & 1 rubygems

Version Path
tdiary-5.3.0 misc/filter/limitdays.rb
tdiary-5.2.4 misc/filter/limitdays.rb
tdiary-5.2.3 misc/filter/limitdays.rb
tdiary-5.2.2 misc/filter/limitdays.rb
tdiary-5.2.1 misc/filter/limitdays.rb
tdiary-5.2.0 misc/filter/limitdays.rb
tdiary-5.1.7 misc/filter/limitdays.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/misc/filter/limitdays.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/misc/filter/limitdays.rb
tdiary-5.1.6 misc/filter/limitdays.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/misc/filter/limitdays.rb
tdiary-5.1.5 misc/filter/limitdays.rb
tdiary-5.1.4 misc/filter/limitdays.rb
tdiary-5.1.3 misc/filter/limitdays.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/filter/limitdays.rb
tdiary-5.1.2 misc/filter/limitdays.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/filter/limitdays.rb
tdiary-5.1.1 misc/filter/limitdays.rb
tdiary-5.1.0 misc/filter/limitdays.rb
tdiary-5.0.14 misc/filter/limitdays.rb