mislav-hanna 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Manifest +2 -0
- data/README.markdown +46 -56
- data/Rakefile +3 -7
- data/bin/hanna +9 -3
- data/hanna.gemspec +40 -127
- data/lib/hanna/template_files/file_index.haml +13 -1
- data/lib/hanna/template_files/index.haml +1 -1
- data/lib/hanna/template_files/layout.haml +1 -1
- data/lib/hanna/template_files/method_search.js +55 -0
- data/lib/hanna/template_files/prototype-1.6.0.3.js +4320 -0
- data/lib/hanna/template_files/styles.sass +17 -0
- data/lib/hanna/template_helpers.rb +28 -0
- metadata +11 -10
data/Manifest
CHANGED
|
@@ -11,6 +11,8 @@ lib/hanna/template_files/method_list.haml
|
|
|
11
11
|
lib/hanna/template_files/page.haml
|
|
12
12
|
lib/hanna/template_files/sections.haml
|
|
13
13
|
lib/hanna/template_files/styles.sass
|
|
14
|
+
lib/hanna/template_files/prototype-1.6.0.3.js
|
|
15
|
+
lib/hanna/template_files/method_search.js
|
|
14
16
|
lib/hanna/template_helpers.rb
|
|
15
17
|
lib/hanna/template_page_patch.rb
|
|
16
18
|
lib/hanna.rb
|
data/README.markdown
CHANGED
|
@@ -1,41 +1,51 @@
|
|
|
1
1
|
# Hanna -- a better RDoc template
|
|
2
2
|
|
|
3
|
-
Hanna is an RDoc template that scales. It's implemented in Haml, making the
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Hanna is an RDoc template that scales. It's implemented in Haml, making the sources clean
|
|
4
|
+
and readable. It's built with simplicity, beauty and ease of browsing in mind. (See more
|
|
5
|
+
in [the wiki][wiki].)
|
|
6
6
|
|
|
7
|
-
Hanna
|
|
7
|
+
Hanna gem is available from [GitHub][]:
|
|
8
8
|
|
|
9
9
|
gem install mislav-hanna
|
|
10
10
|
|
|
11
|
+
The template was created by [Mislav][] and since then has seen contributions from:
|
|
12
|
+
|
|
13
|
+
1. [Tony Strauss](http://github.com/DesigningPatterns), who participated from the early
|
|
14
|
+
start and made tons of fixes and enhancements to the template;
|
|
15
|
+
2. [Hongli Lai](http://blog.phusion.nl/) with the search filter for methods.
|
|
11
16
|
|
|
12
17
|
## Usage
|
|
13
18
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
The most basic usage is to specify Hanna as a template when invoking RDoc on the
|
|
20
|
+
command-line:
|
|
21
|
+
|
|
22
|
+
rdoc -o doc --inline-sorce -T hanna lib/*.rb
|
|
23
|
+
|
|
24
|
+
Hanna requires the `--inline-sorce` (or `-S`) flag.
|
|
25
|
+
|
|
26
|
+
An alternative is to set the `RDOCOPT` environment variable:
|
|
27
|
+
|
|
28
|
+
RDOCOPT="-S -T hanna"
|
|
29
|
+
|
|
30
|
+
This will make RDoc always use Hanna unless it is explicitly overridden.
|
|
31
|
+
|
|
32
|
+
You can also use the command-line tool included in the Hanna gem:
|
|
22
33
|
|
|
23
34
|
hanna -h
|
|
24
35
|
|
|
25
|
-
This is a wrapper over
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
you need to change is this:
|
|
36
|
+
This is a wrapper over rdoc and it forwards all the parameters to it.
|
|
37
|
+
|
|
38
|
+
### Rake task
|
|
39
|
+
|
|
40
|
+
For repeated generation of API docs, it's better to set up a Rake task. If you already
|
|
41
|
+
have an `RDocTask` set up in your Rakefile, the only thing you need to change is this:
|
|
31
42
|
|
|
32
43
|
# replace this:
|
|
33
44
|
require 'rake/rdoctask'
|
|
34
45
|
# with this:
|
|
35
46
|
require 'hanna/rdoctask'
|
|
36
47
|
|
|
37
|
-
Tip: you can do this in the Rakefile of your Rails project before running `rake
|
|
38
|
-
doc:rails`.
|
|
48
|
+
Tip: you can do this in the Rakefile of your Rails project before running `rake doc:rails`.
|
|
39
49
|
|
|
40
50
|
Here is an example of a task for the [will_paginate library][wp]:
|
|
41
51
|
|
|
@@ -56,51 +66,31 @@ Here is an example of a task for the [will_paginate library][wp]:
|
|
|
56
66
|
rdoc.rdoc_dir = 'doc' # rdoc output folder
|
|
57
67
|
rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
|
|
58
68
|
end
|
|
59
|
-
|
|
60
|
-
Alternatively, you can use the the standard RDocTask and simply set the
|
|
61
|
-
task's +template+ attribute to +hanna+ and append +--inline-source+ to its
|
|
62
|
-
options attribute.
|
|
63
69
|
|
|
64
|
-
|
|
70
|
+
### Generating documentation for installed gems
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
You can generate documentation for installed gems, which might be more convenient than the
|
|
73
|
+
`gem rdoc` command with the +RDOCOPT+ environment variable set as described. For instance,
|
|
74
|
+
to generate docs for "actionpack" and "activerecord" type:
|
|
67
75
|
|
|
68
|
-
|
|
69
|
-
command-line.
|
|
70
|
-
--
|
|
71
|
-
You also can generate documentation for installed gems, which might be more
|
|
72
|
-
convenient than the
|
|
73
|
-
|
|
74
|
-
gem rdoc
|
|
75
|
-
|
|
76
|
-
command (with the +RDOCOPT+ environment variable set as above). For this, do:
|
|
77
|
-
|
|
78
|
-
[sudo] hanna --gems haml will_paginate
|
|
79
|
-
|
|
80
|
-
## A work in progress
|
|
81
|
-
|
|
82
|
-
Hanna is far from done, but it is the first RDoc template that's actually
|
|
83
|
-
_maintainable_. First thing I have done is converted the original HTML
|
|
84
|
-
template to Haml and Sass, cleaning up and removing the (ridiculous amount of)
|
|
85
|
-
duplication.
|
|
86
|
-
|
|
87
|
-
Also, the template fragments are now in _separate files_. You would have
|
|
88
|
-
fainted if you seen how it was before. (It's really no wonder why there are no
|
|
89
|
-
other RDoc templates around ... save one: [Allison][].)
|
|
90
|
-
|
|
91
|
-
Ultimately, I'd like to lose the frameset. Currently that is far from possible
|
|
92
|
-
because the whole RDoc HTML Generator is built for frames. Still, that is my
|
|
93
|
-
goal.
|
|
76
|
+
[sudo] hanna --gems actionpack activerecord
|
|
94
77
|
|
|
95
78
|
## You can help
|
|
96
79
|
|
|
97
80
|
Don't like something? Think you can design better? (You probably can.)
|
|
98
81
|
|
|
99
|
-
|
|
82
|
+
I think of Hanna as the first RDoc template that's actually _maintainable_. First thing I
|
|
83
|
+
have done is converted the original HTML template to Haml and Sass, cleaning up and
|
|
84
|
+
removing the (ridiculous amount of) duplication. Also, the template fragments are now in
|
|
85
|
+
_separate files_.
|
|
86
|
+
|
|
87
|
+
Ultimately, I'd like to lose the frameset. Currently that is far from possible because the
|
|
88
|
+
whole RDoc HTML Generator is built for frames. Still, that is my goal.
|
|
89
|
+
|
|
90
|
+
This is git. Fork it, hack away, tell me about it!
|
|
100
91
|
|
|
101
92
|
|
|
102
93
|
[wiki]: http://github.com/mislav/hanna/wikis/home "Hanna wiki"
|
|
103
|
-
[GitHub]: http://gems.github.com/ "GitHub gem
|
|
104
|
-
[wp]: http://github.com/mislav/will_paginate
|
|
94
|
+
[GitHub]: http://gems.github.com/ "GitHub gem server"
|
|
95
|
+
[wp]: http://github.com/mislav/will_paginate/tree/master/Rakefile
|
|
105
96
|
[Mislav]: http://mislav.caboo.se/ "Mislav Marohnić"
|
|
106
|
-
[Allison]: http://blog.evanweaver.com/files/doc/fauna/allison/ "A modern, pretty RDoc template"
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
#
|
|
2
|
-
# This can be made cleaner by using the relative gem.
|
|
3
|
-
#
|
|
4
|
-
require File.join(File.dirname(__FILE__), "lib/hanna/rdoc_version")
|
|
5
|
-
|
|
6
1
|
require 'echoe'
|
|
2
|
+
require 'lib/hanna/rdoc_version'
|
|
7
3
|
|
|
8
4
|
Echoe.new('hanna') do |p|
|
|
9
|
-
p.version = '0.1.
|
|
5
|
+
p.version = '0.1.5'
|
|
10
6
|
|
|
11
7
|
p.summary = "An RDoc template that rocks"
|
|
12
8
|
p.description = "Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind."
|
|
@@ -19,6 +15,6 @@ Echoe.new('hanna') do |p|
|
|
|
19
15
|
p.has_rdoc = false
|
|
20
16
|
p.runtime_dependencies = []
|
|
21
17
|
p.runtime_dependencies << ['rdoc', Hanna::RDOC_VERSION_REQUIREMENT]
|
|
22
|
-
p.runtime_dependencies << ['haml', '~> 2.0']
|
|
18
|
+
p.runtime_dependencies << ['haml', '~> 2.0.4']
|
|
23
19
|
p.runtime_dependencies << ['rake', '~> 0.8.2']
|
|
24
20
|
end
|
data/bin/hanna
CHANGED
|
@@ -24,11 +24,17 @@ HELP
|
|
|
24
24
|
exit 0
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
unless RUBY_PLATFORM =~ /(:?mswin|mingw)/
|
|
28
|
+
require 'pathname'
|
|
29
|
+
hanna_dir = Pathname.new(__FILE__).realpath.dirname + '../lib'
|
|
30
|
+
else
|
|
31
|
+
# windows
|
|
32
|
+
hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
33
|
+
end
|
|
28
34
|
|
|
29
|
-
hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
30
35
|
$:.unshift(hanna_dir) unless $:.include?(hanna_dir)
|
|
31
36
|
|
|
37
|
+
require 'rubygems'
|
|
32
38
|
require 'hanna/rdoc_version'
|
|
33
39
|
Hanna::require_rdoc
|
|
34
40
|
require 'rdoc/rdoc'
|
|
@@ -47,7 +53,7 @@ if ARGV.first == '--gems'
|
|
|
47
53
|
|
|
48
54
|
unless gem_names.empty?
|
|
49
55
|
specs = gem_names.inject([]) do |arr, name|
|
|
50
|
-
found = Gem::SourceIndex.from_installed_gems.
|
|
56
|
+
found = Gem::SourceIndex.from_installed_gems.find_name(name)
|
|
51
57
|
spec = found.sort_by {|s| s.version }.last
|
|
52
58
|
arr << spec if spec
|
|
53
59
|
arr
|
data/hanna.gemspec
CHANGED
|
@@ -1,131 +1,44 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
1
2
|
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
Gem::Specification.new do |s|
|
|
4
|
+
s.name = %q{hanna}
|
|
5
|
+
s.version = "0.1.5"
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
|
8
|
+
s.authors = ["Mislav Marohni\304\207"]
|
|
9
|
+
s.date = %q{2008-11-24}
|
|
10
|
+
s.default_executable = %q{hanna}
|
|
11
|
+
s.description = %q{Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind.}
|
|
12
|
+
s.email = %q{mislav.marohnic@gmail.com}
|
|
13
|
+
s.executables = ["hanna"]
|
|
14
|
+
s.extra_rdoc_files = ["bin/hanna", "lib/hanna/hanna.rb", "lib/hanna/rdoc_version.rb", "lib/hanna/rdoctask.rb", "lib/hanna/template_files/class_index.haml", "lib/hanna/template_files/file_index.haml", "lib/hanna/template_files/index.haml", "lib/hanna/template_files/layout.haml", "lib/hanna/template_files/method_list.haml", "lib/hanna/template_files/page.haml", "lib/hanna/template_files/sections.haml", "lib/hanna/template_files/styles.sass", "lib/hanna/template_files/prototype-1.6.0.3.js", "lib/hanna/template_files/method_search.js", "lib/hanna/template_helpers.rb", "lib/hanna/template_page_patch.rb", "lib/hanna.rb", "README.markdown"]
|
|
15
|
+
s.files = ["bin/hanna", "hanna.gemspec", "lib/hanna/hanna.rb", "lib/hanna/rdoc_version.rb", "lib/hanna/rdoctask.rb", "lib/hanna/template_files/class_index.haml", "lib/hanna/template_files/file_index.haml", "lib/hanna/template_files/index.haml", "lib/hanna/template_files/layout.haml", "lib/hanna/template_files/method_list.haml", "lib/hanna/template_files/page.haml", "lib/hanna/template_files/sections.haml", "lib/hanna/template_files/styles.sass", "lib/hanna/template_files/prototype-1.6.0.3.js", "lib/hanna/template_files/method_search.js", "lib/hanna/template_helpers.rb", "lib/hanna/template_page_patch.rb", "lib/hanna.rb", "Manifest", "Rakefile", "README.markdown"]
|
|
16
|
+
s.homepage = %q{http://github.com/mislav/hanna}
|
|
17
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Hanna", "--main", "README.markdown"]
|
|
18
|
+
s.require_paths = ["lib"]
|
|
19
|
+
s.rubyforge_project = %q{hanna}
|
|
20
|
+
s.rubygems_version = %q{1.3.1}
|
|
21
|
+
s.summary = %q{An RDoc template that rocks}
|
|
14
22
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
- !ruby/object:Gem::Dependency
|
|
19
|
-
name: rdoc
|
|
20
|
-
type: :runtime
|
|
21
|
-
version_requirement:
|
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
-
requirements:
|
|
24
|
-
- - ~>
|
|
25
|
-
- !ruby/object:Gem::Version
|
|
26
|
-
version: 2.2.0
|
|
27
|
-
version:
|
|
28
|
-
- !ruby/object:Gem::Dependency
|
|
29
|
-
name: haml
|
|
30
|
-
type: :runtime
|
|
31
|
-
version_requirement:
|
|
32
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
33
|
-
requirements:
|
|
34
|
-
- - ~>
|
|
35
|
-
- !ruby/object:Gem::Version
|
|
36
|
-
version: "2.0"
|
|
37
|
-
version:
|
|
38
|
-
- !ruby/object:Gem::Dependency
|
|
39
|
-
name: rake
|
|
40
|
-
type: :runtime
|
|
41
|
-
version_requirement:
|
|
42
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ~>
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: 0.8.2
|
|
47
|
-
version:
|
|
48
|
-
- !ruby/object:Gem::Dependency
|
|
49
|
-
name: echoe
|
|
50
|
-
type: :development
|
|
51
|
-
version_requirement:
|
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
53
|
-
requirements:
|
|
54
|
-
- - ">="
|
|
55
|
-
- !ruby/object:Gem::Version
|
|
56
|
-
version: "0"
|
|
57
|
-
version:
|
|
58
|
-
description: Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind.
|
|
59
|
-
email: mislav.marohnic@gmail.com
|
|
60
|
-
executables:
|
|
61
|
-
- hanna
|
|
62
|
-
extensions: []
|
|
23
|
+
if s.respond_to? :specification_version then
|
|
24
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
25
|
+
s.specification_version = 2
|
|
63
26
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
- bin/hanna
|
|
83
|
-
- hanna.gemspec
|
|
84
|
-
- lib/hanna/hanna.rb
|
|
85
|
-
- lib/hanna/rdoc_version.rb
|
|
86
|
-
- lib/hanna/rdoctask.rb
|
|
87
|
-
- lib/hanna/template_files/class_index.haml
|
|
88
|
-
- lib/hanna/template_files/file_index.haml
|
|
89
|
-
- lib/hanna/template_files/index.haml
|
|
90
|
-
- lib/hanna/template_files/layout.haml
|
|
91
|
-
- lib/hanna/template_files/method_list.haml
|
|
92
|
-
- lib/hanna/template_files/page.haml
|
|
93
|
-
- lib/hanna/template_files/sections.haml
|
|
94
|
-
- lib/hanna/template_files/styles.sass
|
|
95
|
-
- lib/hanna/template_helpers.rb
|
|
96
|
-
- lib/hanna/template_page_patch.rb
|
|
97
|
-
- lib/hanna.rb
|
|
98
|
-
- Manifest
|
|
99
|
-
- Rakefile
|
|
100
|
-
- README.markdown
|
|
101
|
-
has_rdoc: false
|
|
102
|
-
homepage: http://github.com/mislav/hanna
|
|
103
|
-
post_install_message:
|
|
104
|
-
rdoc_options:
|
|
105
|
-
- --line-numbers
|
|
106
|
-
- --inline-source
|
|
107
|
-
- --title
|
|
108
|
-
- Hanna
|
|
109
|
-
- --main
|
|
110
|
-
- README.markdown
|
|
111
|
-
require_paths:
|
|
112
|
-
- lib
|
|
113
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
|
-
requirements:
|
|
115
|
-
- - ">="
|
|
116
|
-
- !ruby/object:Gem::Version
|
|
117
|
-
version: "0"
|
|
118
|
-
version:
|
|
119
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
|
-
requirements:
|
|
121
|
-
- - "="
|
|
122
|
-
- !ruby/object:Gem::Version
|
|
123
|
-
version: "1.2"
|
|
124
|
-
version:
|
|
125
|
-
requirements: []
|
|
126
|
-
|
|
127
|
-
rubyforge_project: hanna
|
|
128
|
-
rubygems_version: 1.2.0
|
|
129
|
-
specification_version: 2
|
|
130
|
-
summary: An RDoc template that rocks
|
|
131
|
-
test_files: []
|
|
27
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
28
|
+
s.add_runtime_dependency(%q<rdoc>, ["~> 2.2.0"])
|
|
29
|
+
s.add_runtime_dependency(%q<haml>, ["~> 2.0.4"])
|
|
30
|
+
s.add_runtime_dependency(%q<rake>, ["~> 0.8.2"])
|
|
31
|
+
s.add_development_dependency(%q<echoe>, [">= 0"])
|
|
32
|
+
else
|
|
33
|
+
s.add_dependency(%q<rdoc>, ["~> 2.2.0"])
|
|
34
|
+
s.add_dependency(%q<haml>, ["~> 2.0.4"])
|
|
35
|
+
s.add_dependency(%q<rake>, ["~> 0.8.2"])
|
|
36
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
|
37
|
+
end
|
|
38
|
+
else
|
|
39
|
+
s.add_dependency(%q<rdoc>, ["~> 2.2.0"])
|
|
40
|
+
s.add_dependency(%q<haml>, ["~> 2.0.4"])
|
|
41
|
+
s.add_dependency(%q<rake>, ["~> 0.8.2"])
|
|
42
|
+
s.add_dependency(%q<echoe>, [">= 0"])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -2,11 +2,23 @@
|
|
|
2
2
|
- type = values["list_title"].downcase
|
|
3
3
|
- any_hidden = false
|
|
4
4
|
|
|
5
|
+
- if type == 'methods'
|
|
6
|
+
%script{:type => 'text/javascript'}
|
|
7
|
+
= read("prototype-1.6.0.3.js")
|
|
8
|
+
= build_javascript_search_index(values["entries"])
|
|
9
|
+
= read("method_search.js")
|
|
10
|
+
%form{:onsubmit => 'return performSearch()'}
|
|
11
|
+
%input{:type => 'text', :id => 'search', :class => 'untouched', :value => 'Enter search terms...'}
|
|
12
|
+
%ol#search-results{ :class => type, :style => 'display: none' }
|
|
13
|
+
|
|
5
14
|
%ol#index-entries{ :class => type }
|
|
6
15
|
- for entry in values["entries"]
|
|
7
16
|
- hide = type == 'files' && entry['name'] =~ /\.rb$/
|
|
8
17
|
- any_hidden = true if hide
|
|
9
|
-
|
|
18
|
+
- if type == 'methods'
|
|
19
|
+
%li{ :class => hide ? 'other' : nil }= link_to_method entry['name'], entry['href']
|
|
20
|
+
- else
|
|
21
|
+
%li{ :class => hide ? 'other' : nil }= link_to entry['name'], entry['href']
|
|
10
22
|
|
|
11
23
|
- if any_hidden
|
|
12
24
|
%li
|
|
@@ -8,4 +8,4 @@
|
|
|
8
8
|
%frame{ :name => "Files", :title => "Files", :src => "fr_file_index.html" }
|
|
9
9
|
%frame{ :name => "Classes", :src => "fr_class_index.html" }
|
|
10
10
|
%frame{ :name => "Methods", :src => "fr_method_index.html" }
|
|
11
|
-
%frame{ :name => "docwin", :src => values['initial_page'] }=""
|
|
11
|
+
%frame{ :name => "docwin", :src => values['initial_page'] }=""
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
$(document).observe('dom:loaded', function() {
|
|
2
|
+
// Setup search-during-typing.
|
|
3
|
+
new Form.Element.Observer('search', 0.3, function(element, value) {
|
|
4
|
+
performSearch();
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
// Remove the default search box value when the user puts the focus on
|
|
8
|
+
// the search box for the first time.
|
|
9
|
+
var search_box = $('search');
|
|
10
|
+
if ($F('search') == 'Enter search terms...') {
|
|
11
|
+
search_box.observe('focus', function() {
|
|
12
|
+
if (search_box.hasClassName('untouched')) {
|
|
13
|
+
search_box.removeClassName('untouched');
|
|
14
|
+
search_box.value = '';
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
} else {
|
|
18
|
+
search_box.removeClassName('untouched');
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
function searchInIndex(query) {
|
|
23
|
+
var i;
|
|
24
|
+
var results = [];
|
|
25
|
+
query = query.toLowerCase();
|
|
26
|
+
for (i = 0; i < search_index.length; i++) {
|
|
27
|
+
if (search_index[i].method.indexOf(query) != -1) {
|
|
28
|
+
results.push(search_index[i]);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return results;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function buildHtmlForResults(results) {
|
|
35
|
+
var html = "";
|
|
36
|
+
var i;
|
|
37
|
+
for (i = 0; i < results.length; i++) {
|
|
38
|
+
html += '<li>' + results[i].html + '</li>';
|
|
39
|
+
}
|
|
40
|
+
return html;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function performSearch() {
|
|
44
|
+
var query = $F('search');
|
|
45
|
+
if (query == '') {
|
|
46
|
+
$('index-entries').show();
|
|
47
|
+
$('search-results').hide();
|
|
48
|
+
} else {
|
|
49
|
+
var results = searchInIndex(query);
|
|
50
|
+
$('search-results').update(buildHtmlForResults(results));
|
|
51
|
+
$('index-entries').hide();
|
|
52
|
+
$('search-results').show();
|
|
53
|
+
}
|
|
54
|
+
return false;
|
|
55
|
+
}
|