Sha256: 9e27aa7184aa50b38df21d1b6c245592c928bac170d3cd279e55007d82dbaaa5

Contents?: true

Size: 1.28 KB

Versions: 69

Compression:

Stored size: 1.28 KB

Contents

# search_form.rb
#
# Show a form for search engines.
#
# Copyright (c) 2002 MUTOH Masao <mutoh@highway.ne.jp>
# Distributed under the same license terms as tDiary.
#

add_header_proc do
	@extract_search_keyword = ''
	if @cgi.referer then
		begin
			setup = DispRef2Setup::new( @conf, 1, true, nil, @mode )
			disp_url = DispRef2URL::new( @cgi.referer )
			disp_url.parse( setup )
			if disp_url.category == :search then
				@extract_search_keyword = disp_url.key
			end
		rescue NameError
		end
	end
	''
end

def extract_search_keyword
	h @extract_search_keyword
end


def search_form(url, query, button_name = "Search", size = 20, default_text = "", first_form = "", last_form = "")
	default_text = @extract_search_keyword if default_text.empty?
	%Q[
		<form class="search" method="GET" action="#{h( url )}">
		<div class="search">
		#{first_form}
			<input class="search" type="text" name="#{h( query )}" size="#{h( size )}" value="#{h( default_text )}">
			<input class="search" type="submit" value="#{h button_name}">
		#{last_form}
		</div>
		</form>
	]
end

def namazu_form( url, button_name = "Search", size = 20, default_text = "" )
	search_form( url, "query", button_name, size, default_text )
end

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

Version data entries

69 entries across 58 versions & 1 rubygems

Version Path
tdiary-5.3.0 misc/plugin/search_form.rb
tdiary-5.2.4 misc/plugin/search_form.rb
tdiary-5.2.3 misc/plugin/search_form.rb
tdiary-5.2.2 misc/plugin/search_form.rb
tdiary-5.2.1 misc/plugin/search_form.rb
tdiary-5.2.0 misc/plugin/search_form.rb
tdiary-5.1.7 misc/plugin/search_form.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/plugin/search_form.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/misc/plugin/search_form.rb
tdiary-5.1.6 misc/plugin/search_form.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/tdiary-5.1.4/misc/plugin/search_form.rb
tdiary-5.1.5 misc/plugin/search_form.rb
tdiary-5.1.4 misc/plugin/search_form.rb
tdiary-5.1.3 misc/plugin/search_form.rb
tdiary-5.1.2 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/plugin/search_form.rb
tdiary-5.1.2 misc/plugin/search_form.rb
tdiary-5.1.1 vendor/bundle/ruby/2.6.0/gems/tdiary-5.0.14/misc/plugin/search_form.rb
tdiary-5.1.1 misc/plugin/search_form.rb
tdiary-5.1.0 misc/plugin/search_form.rb
tdiary-5.0.14 misc/plugin/search_form.rb