Class: TDiary::Filter::Filter

Inherits:
Object
  • Object
show all
Includes:
ViewHelper
Defined in:
lib/tdiary/filter.rb

Direct Known Subclasses

DefaultFilter, SpamFilter

Constant Summary collapse

DEBUG_NONE =
0
DEBUG_SPAM =
1
DEBUG_FULL =
2

Instance Method Summary collapse

Methods included from ViewHelper

#base_url, #bot?

Constructor Details

#initialize(cgi, conf) ⇒ Filter

Returns a new instance of Filter.



13
14
15
16
17
18
19
20
21
# File 'lib/tdiary/filter.rb', line 13

def initialize( cgi, conf )
	@cgi, @conf = cgi, conf

	if @conf.options.include?('filter.debug_mode')
		@debug_mode = @conf.options['filter.debug_mode']
	else
		@debug_mode = DEBUG_NONE
	end
end

Instance Method Details

#comment_filter(diary, comment) ⇒ Object



23
24
25
# File 'lib/tdiary/filter.rb', line 23

def comment_filter( diary, comment )
	true
end

#debug(msg, level = DEBUG_SPAM) ⇒ Object



31
32
33
34
35
36
# File 'lib/tdiary/filter.rb', line 31

def debug( msg, level = DEBUG_SPAM )
	return if @debug_mode == DEBUG_NONE
	return if @debug_mode == DEBUG_SPAM and level == DEBUG_FULL

	TDiary.logger.info("#{@cgi.remote_addr}->#{(@cgi.params['date'][0] || 'no date').dump}: #{msg}")
end

#referer_filter(referer) ⇒ Object



27
28
29
# File 'lib/tdiary/filter.rb', line 27

def referer_filter( referer )
	true
end