File: opensearch_ad.rb

package info (click to toggle)
tdiary-contrib 5.0.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,576 kB
  • ctags: 1,957
  • sloc: ruby: 16,900; lisp: 514; xml: 451; php: 61; sql: 40; sh: 35; makefile: 33
file content (33 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# opensearch_ad.rb $Revision: 1.1 $
#
# Copyright (c) 2008 SHIBATA Hiroshi <h-sbt@nifty.com>
# Distributed under the GPL
#

if /\A(?:latest|day)\z/ =~ @mode then
	if @conf['opensearch.xml'] and @conf['opensearch.title'] then
		opensearch_xml = @conf['opensearch.xml']
		opensearch_title = @conf['opensearch.title']

		add_header_proc do
			result = <<-HTML
			<link type="application/opensearchdescription+xml" rel="search" title="#{h(opensearch_title)}" href="#{h(opensearch_xml)}">
			HTML
			result.gsub( /^\t\t/, '' )
		end
	end
end

add_conf_proc( 'opensearch_ad', 'OpenSearch Auto-Discovery' ) do
	if @mode == 'saveconf'
		@conf['opensearch.xml'] = @cgi.params['opensearch.xml'][0]
		@conf['opensearch.title'] = @cgi.params['opensearch.title'][0]
	end

	<<-HTML
	<h3 class="subtitle">Tilte for OpenSearch</h3>
	<p><input name="opensearch.title" value="#{h(@conf['opensearch.title'])}" size="80"></p>
	<h3 class="subtitle">URI for OpenSearch description XML</h3>
	<p><input name="opensearch.xml" value="#{h(@conf['opensearch.xml'])}" size="80"></p>
	HTML
end