Sha256: 8b2ce2aa11169b68385b85c8ef9b2deb84b70b72b24066d84baef01601faa37a

Contents?: true

Size: 1.55 KB

Versions: 52

Compression:

Stored size: 1.55 KB

Contents

#
# comment_key.rb: Comment-key plugin  Ver.0.5.0
#
# functions:
#   * add "comment_key" key in comment form.
#
# caution:
#   * This plugin must use together filter 'comment_key.rb'.
#
# see:
#   http://www20.big.or.jp/~rin_ne/soft/tdiary/commentkey.htm
#
# Copyright (c) 2005 Hahahaha <rin_ne@big.or.jp>
# Distributed under the GPL
#

alias :orig_comment_name_label :comment_name_label
alias :orig_comment_name_label_short :comment_name_label_short

def comment_name_label
	comment_key( orig_comment_name_label )
end

def comment_name_label_short
	comment_key( orig_comment_name_label_short )
end

def comment_key( label )
	return label unless @conf['comment_key.enable']

	require 'digest/md5'
	keyprefix = @conf['comment_key.prefix'] || 'tdiary'
	vkey = Digest::MD5.hexdigest(keyprefix + (@conf['comment_key.nodate'] == 'true' ? "" : @date.strftime( '%Y%m%d' )))
	%Q!<input type="hidden" name="comment_key" value="#{vkey}">\n#{label}!
end

# configuration

if TDIARY_VERSION >= '2.1.2.20050826' then
	add_conf_proc( 'comment_key', @comment_key_label_conf, 'security' ) do
		comment_key_conf
	end
else
	add_conf_proc( 'comment_key', @comment_key_label_conf ) do
		comment_key_conf
	end
end

def comment_key_conf
	if @mode == 'saveconf' then
		@conf['comment_key.enable'] = 'true' == @cgi.params['comment_key_enable'][0] ? true : false
		@conf['comment_key.prefix'] = @cgi.params['comment_key_prefix'][0]
		@conf['comment_key.nodate'] = @cgi.params['comment_key_nodate'][0]
	end
	@conf['comment_key.prefix'] = 'tdiary' unless @conf['comment_key.prefix']

	comment_key_conf_html
end

Version data entries

52 entries across 46 versions & 2 rubygems

Version Path
tdiary-contrib-5.3.0 filter/plugin/commentkey.rb
tdiary-contrib-5.2.4 filter/plugin/commentkey.rb
tdiary-contrib-5.2.3 filter/plugin/commentkey.rb
tdiary-contrib-5.2.2 filter/plugin/commentkey.rb
tdiary-contrib-5.2.1 filter/plugin/commentkey.rb
tdiary-contrib-5.2.0 filter/plugin/commentkey.rb
tdiary-contrib-5.1.7 filter/plugin/commentkey.rb
tdiary-contrib-5.1.6 filter/plugin/commentkey.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/filter/plugin/commentkey.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/bundler/gems/tdiary-contrib-d1e41204db13/filter/plugin/commentkey.rb
tdiary-contrib-5.1.5 filter/plugin/commentkey.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-contrib-5.1.4/filter/plugin/commentkey.rb
tdiary-contrib-5.1.4 filter/plugin/commentkey.rb
tdiary-contrib-5.1.3 filter/plugin/commentkey.rb
tdiary-contrib-5.1.2 filter/plugin/commentkey.rb
tdiary-contrib-5.1.1 filter/plugin/commentkey.rb
tdiary-contrib-5.1.0 filter/plugin/commentkey.rb
tdiary-contrib-5.0.13 filter/plugin/commentkey.rb
tdiary-contrib-5.0.12 filter/plugin/commentkey.rb
tdiary-contrib-5.0.11 filter/plugin/commentkey.rb