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(request, conf) ⇒ Filter

Returns a new instance of Filter.



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

def initialize( request, conf )
	@request = request
	# filter subclasses read the request through the @cgi facade
	@cgi = request.cgi_compat
	@conf = 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



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

def comment_filter( diary, comment )
	true
end

#debug(msg, level = DEBUG_SPAM) ⇒ Object



34
35
36
37
38
39
# File 'lib/tdiary/filter.rb', line 34

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



30
31
32
# File 'lib/tdiary/filter.rb', line 30

def referer_filter( referer )
	true
end