rsteamshot 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +118 -0
- data/Rakefile +14 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/docs/README_md.html +233 -0
- data/docs/Rsteamshot/App/BadAppsFile.html +106 -0
- data/docs/Rsteamshot/App.html +466 -0
- data/docs/Rsteamshot/Screenshot.html +562 -0
- data/docs/Rsteamshot/ScreenshotPage.html +347 -0
- data/docs/Rsteamshot/ScreenshotPaginator.html +307 -0
- data/docs/Rsteamshot/User.html +309 -0
- data/docs/Rsteamshot.html +147 -0
- data/docs/created.rid +9 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +590 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +242 -0
- data/docs/js/darkfish.js +161 -0
- data/docs/js/jquery.js +4 -0
- data/docs/js/navigation.js +142 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +109 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +179 -0
- data/lib/rsteamshot/app.rb +213 -0
- data/lib/rsteamshot/screenshot.rb +224 -0
- data/lib/rsteamshot/screenshot_page.rb +62 -0
- data/lib/rsteamshot/screenshot_paginator.rb +77 -0
- data/lib/rsteamshot/user.rb +77 -0
- data/lib/rsteamshot/version.rb +4 -0
- data/lib/rsteamshot.rb +15 -0
- data/rsteamshot.gemspec +32 -0
- metadata +215 -0
data/docs/index.html
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/jquery.js"></script>
|
15
|
+
<script src="./js/darkfish.js"></script>
|
16
|
+
|
17
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
18
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
<body id="top" role="document" class="file">
|
23
|
+
<nav role="navigation">
|
24
|
+
<div id="project-navigation">
|
25
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
26
|
+
<h2>
|
27
|
+
<a href="./index.html" rel="home">Home</a>
|
28
|
+
</h2>
|
29
|
+
|
30
|
+
<div id="table-of-contents-navigation">
|
31
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
32
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
33
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
|
38
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
39
|
+
<form action="#" method="get" accept-charset="utf-8">
|
40
|
+
<div id="search-field-wrapper">
|
41
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
42
|
+
aria-autocomplete="list" aria-controls="search-results"
|
43
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
44
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
45
|
+
</div>
|
46
|
+
|
47
|
+
<ul id="search-results" aria-label="Search Results"
|
48
|
+
aria-busy="false" aria-expanded="false"
|
49
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
50
|
+
</form>
|
51
|
+
</div>
|
52
|
+
|
53
|
+
</div>
|
54
|
+
|
55
|
+
<div id="project-metadata">
|
56
|
+
<div id="fileindex-section" class="nav-section">
|
57
|
+
<h3>Pages</h3>
|
58
|
+
|
59
|
+
<ul class="link-list">
|
60
|
+
|
61
|
+
<li><a href="./README_md.html">README</a>
|
62
|
+
|
63
|
+
</ul>
|
64
|
+
</div>
|
65
|
+
|
66
|
+
<div id="classindex-section" class="nav-section">
|
67
|
+
<h3>Class and Module Index</h3>
|
68
|
+
|
69
|
+
<ul class="link-list">
|
70
|
+
|
71
|
+
<li><a href="./Rsteamshot.html">Rsteamshot</a>
|
72
|
+
|
73
|
+
<li><a href="./Rsteamshot/App.html">Rsteamshot::App</a>
|
74
|
+
|
75
|
+
<li><a href="./Rsteamshot/App/BadAppsFile.html">Rsteamshot::App::BadAppsFile</a>
|
76
|
+
|
77
|
+
<li><a href="./Rsteamshot/Screenshot.html">Rsteamshot::Screenshot</a>
|
78
|
+
|
79
|
+
<li><a href="./Rsteamshot/ScreenshotPage.html">Rsteamshot::ScreenshotPage</a>
|
80
|
+
|
81
|
+
<li><a href="./Rsteamshot/ScreenshotPaginator.html">Rsteamshot::ScreenshotPaginator</a>
|
82
|
+
|
83
|
+
<li><a href="./Rsteamshot/User.html">Rsteamshot::User</a>
|
84
|
+
|
85
|
+
</ul>
|
86
|
+
</div>
|
87
|
+
|
88
|
+
</div>
|
89
|
+
</nav>
|
90
|
+
|
91
|
+
<main role="main">
|
92
|
+
|
93
|
+
|
94
|
+
<h1 id="label-Rsteamshot"><a href="Rsteamshot.html">Rsteamshot</a><span><a href="#label-Rsteamshot">¶</a> <a href="#top">↑</a></span></h1>
|
95
|
+
|
96
|
+
<p><a href="https://travis-ci.org/cheshire137/rsteamshot"><img
|
97
|
+
src="https://travis-ci.org/cheshire137/rsteamshot.svg?branch=master"></a></p>
|
98
|
+
|
99
|
+
<p><a href="Rsteamshot.html">Rsteamshot</a> is a Ruby gem for getting
|
100
|
+
screenshots a user has uploaded to their Steam profile, as well as
|
101
|
+
screenshots uploaded for a particular game. You can find the newest
|
102
|
+
screenshots as well as the most popular screenshots. Screenshots can be
|
103
|
+
paginated.</p>
|
104
|
+
|
105
|
+
<p>There's no Steam API that I know of that provides this screenshot data,
|
106
|
+
so this gem works by using <a
|
107
|
+
href="https://github.com/sparklemotion/mechanize">Mechanize</a> to do web
|
108
|
+
scraping on <a href="http://steamcommunity.com/">steamcommunity.com</a>.</p>
|
109
|
+
|
110
|
+
<p><a href="https://github.com/cheshire137/rsteamshot">View source on
|
111
|
+
GitHub</a></p>
|
112
|
+
|
113
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#top">↑</a></span></h2>
|
114
|
+
|
115
|
+
<p>Add this line to your application's Gemfile:</p>
|
116
|
+
|
117
|
+
<pre class="ruby"><span class="ruby-identifier">gem</span> <span class="ruby-string">'rsteamshot'</span>
|
118
|
+
</pre>
|
119
|
+
|
120
|
+
<p>And then execute:</p>
|
121
|
+
|
122
|
+
<pre>$ bundle</pre>
|
123
|
+
|
124
|
+
<p>Or install it yourself as:</p>
|
125
|
+
|
126
|
+
<pre>$ gem install rsteamshot</pre>
|
127
|
+
|
128
|
+
<h2 id="label-Usage">Usage<span><a href="#label-Usage">¶</a> <a href="#top">↑</a></span></h2>
|
129
|
+
|
130
|
+
<pre class="ruby"><span class="ruby-comment"># Get screenshots uploaded by a Steam user:</span>
|
131
|
+
<span class="ruby-identifier">steam_user_name</span> = <span class="ruby-string">'cheshire137'</span>
|
132
|
+
<span class="ruby-identifier">user</span> = <span class="ruby-constant">Rsteamshot</span><span class="ruby-operator">::</span><span class="ruby-constant">User</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">steam_user_name</span>, <span class="ruby-identifier">per_page</span><span class="ruby-operator">:</span> <span class="ruby-value">10</span>)
|
133
|
+
<span class="ruby-identifier">order</span> = <span class="ruby-string">'newestfirst'</span> <span class="ruby-comment"># also: score, oldestfirst</span>
|
134
|
+
<span class="ruby-identifier">screenshots</span> = <span class="ruby-identifier">user</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">order</span><span class="ruby-operator">:</span> <span class="ruby-identifier">order</span>)
|
135
|
+
<span class="ruby-identifier">screenshots</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">user</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">order</span><span class="ruby-operator">:</span> <span class="ruby-identifier">order</span>, <span class="ruby-identifier">page</span><span class="ruby-operator">:</span> <span class="ruby-value">2</span>)
|
136
|
+
|
137
|
+
<span class="ruby-comment"># Find a Steam app by name:</span>
|
138
|
+
<span class="ruby-identifier">apps_path</span> = <span class="ruby-string">'apps-list.json'</span>
|
139
|
+
<span class="ruby-constant">Rsteamshot</span><span class="ruby-operator">::</span><span class="ruby-constant">App</span>.<span class="ruby-identifier">download_apps_list</span>(<span class="ruby-identifier">apps_path</span>)
|
140
|
+
<span class="ruby-identifier">apps</span> = <span class="ruby-constant">Rsteamshot</span><span class="ruby-operator">::</span><span class="ruby-constant">App</span>.<span class="ruby-identifier">search</span>(<span class="ruby-string">'witcher 3'</span>, <span class="ruby-identifier">apps_path</span>)
|
141
|
+
<span class="ruby-identifier">app</span> = <span class="ruby-identifier">apps</span>.<span class="ruby-identifier">first</span>
|
142
|
+
|
143
|
+
<span class="ruby-comment"># Filter a user's screenshots to those for a particular app:</span>
|
144
|
+
<span class="ruby-identifier">alice_screenshots</span> = <span class="ruby-identifier">user</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">app_id</span><span class="ruby-operator">:</span> <span class="ruby-string">'19680'</span>)
|
145
|
+
|
146
|
+
<span class="ruby-comment"># Initialize an app directly if you know its ID:</span>
|
147
|
+
<span class="ruby-identifier">app_id</span> = <span class="ruby-string">'377160'</span>
|
148
|
+
<span class="ruby-identifier">app</span> = <span class="ruby-constant">Rsteamshot</span><span class="ruby-operator">::</span><span class="ruby-constant">App</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">id</span><span class="ruby-operator">:</span> <span class="ruby-identifier">app_id</span>, <span class="ruby-identifier">per_page</span><span class="ruby-operator">:</span> <span class="ruby-value">10</span>)
|
149
|
+
|
150
|
+
<span class="ruby-comment"># Get screenshots uploaded for a Steam game:</span>
|
151
|
+
<span class="ruby-identifier">order</span> = <span class="ruby-string">'mostrecent'</span> <span class="ruby-comment"># also: toprated, trendday, trendweek, trendthreemonths, trendsixmonths,</span>
|
152
|
+
<span class="ruby-comment"># trendyear</span>
|
153
|
+
<span class="ruby-identifier">screenshots</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">order</span><span class="ruby-operator">:</span> <span class="ruby-identifier">order</span>)
|
154
|
+
<span class="ruby-identifier">screenshots</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">app</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">order</span><span class="ruby-operator">:</span> <span class="ruby-identifier">order</span>, <span class="ruby-identifier">page</span><span class="ruby-operator">:</span> <span class="ruby-value">2</span>)
|
155
|
+
|
156
|
+
<span class="ruby-comment"># Search an app's screenshots:</span>
|
157
|
+
<span class="ruby-identifier">dog_screenshots</span> = <span class="ruby-identifier">app</span>.<span class="ruby-identifier">screenshots</span>(<span class="ruby-identifier">query</span><span class="ruby-operator">:</span> <span class="ruby-string">'dog'</span>, <span class="ruby-identifier">order</span><span class="ruby-operator">:</span> <span class="ruby-string">'trendweek'</span>)
|
158
|
+
|
159
|
+
<span class="ruby-comment"># Data available for each screenshot:</span>
|
160
|
+
<span class="ruby-identifier">screenshots</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">screenshot</span><span class="ruby-operator">|</span>
|
161
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">title</span>
|
162
|
+
<span class="ruby-comment"># => "Lovely sunset in Toussaint"</span>
|
163
|
+
|
164
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">details_url</span>
|
165
|
+
<span class="ruby-comment"># => "http://steamcommunity.com/sharedfiles/filedetails/?id=737284878"</span>
|
166
|
+
|
167
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">full_size_url</span>
|
168
|
+
<span class="ruby-comment"># => "https://steamuserimages-a.akamaihd.net/ugc/1621679306978373648/FACBF0285AFB413467E0E76371E8796D8E8C263D/"</span>
|
169
|
+
|
170
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">medium_url</span>
|
171
|
+
<span class="ruby-comment"># => "https://steamuserimages-a.akamaihd.net/ugc/1621679306978373648/FACBF0285AFB413467E0E76371E8796D8E8C263D/?interpolation=lanczos-none&output-format=jpeg&output-quality=95&fit=inside|1024:576&composite-to%3D%2A%2C%2A%7C1024%3A576&background-color=black"</span>
|
172
|
+
|
173
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">user_name</span>
|
174
|
+
<span class="ruby-comment"># => "cheshire137"</span>
|
175
|
+
|
176
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">user_url</span>
|
177
|
+
<span class="ruby-comment"># => "http://steamcommunity.com/id/cheshire137"</span>
|
178
|
+
|
179
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">date</span>
|
180
|
+
<span class="ruby-comment"># => #<DateTime: 2016-08-03T20:54:00+00:00 ((2457604j,75240s,0n),+0s,2299161j)></span>
|
181
|
+
|
182
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">file_size</span>
|
183
|
+
<span class="ruby-comment"># => "0.367 MB"</span>
|
184
|
+
|
185
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">width</span>
|
186
|
+
<span class="ruby-comment"># => 1920</span>
|
187
|
+
|
188
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">height</span>
|
189
|
+
<span class="ruby-comment"># => 1080</span>
|
190
|
+
|
191
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">like_count</span>
|
192
|
+
<span class="ruby-comment"># => 0</span>
|
193
|
+
|
194
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">comment_count</span>
|
195
|
+
<span class="ruby-comment"># => 0</span>
|
196
|
+
|
197
|
+
<span class="ruby-comment"># Utility methods:</span>
|
198
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">to_h</span>
|
199
|
+
<span class="ruby-comment"># => {:details_url=>"http://steamcommunity.com/sharedfiles/filedetails/?id=737284878", :title=>...</span>
|
200
|
+
|
201
|
+
<span class="ruby-identifier">screenshot</span>.<span class="ruby-identifier">to_json</span>
|
202
|
+
<span class="ruby-comment"># => "{\n \"details_url\": \"http://steamcommunity.com/sharedfiles/filedetails/?id=737284878\",</span>
|
203
|
+
<span class="ruby-keyword">end</span>
|
204
|
+
</pre>
|
205
|
+
|
206
|
+
<h2 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#top">↑</a></span></h2>
|
207
|
+
|
208
|
+
<p>After checking out <a href="https://github.com/cheshire137/rsteamshot">the
|
209
|
+
repo</a>, run <code>bin/setup</code> to install dependencies. Then, run
|
210
|
+
<code>rake spec</code> to run the tests. You can also run
|
211
|
+
<code>bin/console</code> for an interactive prompt that will allow you to
|
212
|
+
experiment.</p>
|
213
|
+
|
214
|
+
<p>To install this gem onto your local machine, run <code>bundle exec rake
|
215
|
+
install</code>. To release a new version, update the version number in
|
216
|
+
<code>version.rb</code>, and then run <code>bundle exec rake
|
217
|
+
release</code>, which will create a git tag for the version, push git
|
218
|
+
commits and tags, and push the <code>.gem</code> file to <a
|
219
|
+
href="https://rubygems.org">rubygems.org</a>.</p>
|
220
|
+
|
221
|
+
<h2 id="label-Contributing">Contributing<span><a href="#label-Contributing">¶</a> <a href="#top">↑</a></span></h2>
|
222
|
+
|
223
|
+
<p><a href="https://github.com/cheshire137/rsteamshot/issues">Bug reports</a>
|
224
|
+
and pull requests are welcome. This project is intended to be a safe,
|
225
|
+
welcoming space for collaboration, and contributors are expected to adhere
|
226
|
+
to the <a href="http://contributor-covenant.org">Contributor Covenant</a>
|
227
|
+
code of conduct.</p>
|
228
|
+
|
229
|
+
<h2 id="label-License">License<span><a href="#label-License">¶</a> <a href="#top">↑</a></span></h2>
|
230
|
+
|
231
|
+
<p>The gem is available as open source under the terms of the <a
|
232
|
+
href="http://opensource.org/licenses/MIT">MIT License</a>.</p>
|
233
|
+
</main>
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
<footer id="validator-badges" role="contentinfo">
|
238
|
+
<p><a href="http://validator.w3.org/check/referer">Validate</a>
|
239
|
+
<p>Generated by <a href="https://rdoc.github.io/rdoc">RDoc</a> 5.1.0.
|
240
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
241
|
+
</footer>
|
242
|
+
|
data/docs/js/darkfish.js
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Darkfish Page Functions
|
4
|
+
* $Id: darkfish.js 53 2009-01-07 02:52:03Z deveiant $
|
5
|
+
*
|
6
|
+
* Author: Michael Granger <mgranger@laika.com>
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
/* Provide console simulation for firebug-less environments */
|
11
|
+
if (!("console" in window) || !("firebug" in console)) {
|
12
|
+
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
|
13
|
+
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
|
14
|
+
|
15
|
+
window.console = {};
|
16
|
+
for (var i = 0; i < names.length; ++i)
|
17
|
+
window.console[names[i]] = function() {};
|
18
|
+
};
|
19
|
+
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Unwrap the first element that matches the given @expr@ from the targets and return them.
|
23
|
+
*/
|
24
|
+
$.fn.unwrap = function( expr ) {
|
25
|
+
return this.each( function() {
|
26
|
+
$(this).parents( expr ).eq( 0 ).after( this ).remove();
|
27
|
+
});
|
28
|
+
};
|
29
|
+
|
30
|
+
|
31
|
+
function showSource( e ) {
|
32
|
+
var target = e.target;
|
33
|
+
var codeSections = $(target).
|
34
|
+
parents('.method-detail').
|
35
|
+
find('.method-source-code');
|
36
|
+
|
37
|
+
$(target).
|
38
|
+
parents('.method-detail').
|
39
|
+
find('.method-source-code').
|
40
|
+
slideToggle();
|
41
|
+
};
|
42
|
+
|
43
|
+
function hookSourceViews() {
|
44
|
+
$('.method-heading').click( showSource );
|
45
|
+
};
|
46
|
+
|
47
|
+
function hookSearch() {
|
48
|
+
var input = $('#search-field').eq(0);
|
49
|
+
var result = $('#search-results').eq(0);
|
50
|
+
$(result).show();
|
51
|
+
|
52
|
+
var search_section = $('#search-section').get(0);
|
53
|
+
$(search_section).show();
|
54
|
+
|
55
|
+
var search = new Search(search_data, input, result);
|
56
|
+
|
57
|
+
search.renderItem = function(result) {
|
58
|
+
var li = document.createElement('li');
|
59
|
+
var html = '';
|
60
|
+
|
61
|
+
// TODO add relative path to <script> per-page
|
62
|
+
html += '<p class="search-match"><a href="' + index_rel_prefix + result.path + '">' + this.hlt(result.title);
|
63
|
+
if (result.params)
|
64
|
+
html += '<span class="params">' + result.params + '</span>';
|
65
|
+
html += '</a>';
|
66
|
+
|
67
|
+
|
68
|
+
if (result.namespace)
|
69
|
+
html += '<p class="search-namespace">' + this.hlt(result.namespace);
|
70
|
+
|
71
|
+
if (result.snippet)
|
72
|
+
html += '<div class="search-snippet">' + result.snippet + '</div>';
|
73
|
+
|
74
|
+
li.innerHTML = html;
|
75
|
+
|
76
|
+
return li;
|
77
|
+
}
|
78
|
+
|
79
|
+
search.select = function(result) {
|
80
|
+
var result_element = result.get(0);
|
81
|
+
window.location.href = result_element.firstChild.firstChild.href;
|
82
|
+
}
|
83
|
+
|
84
|
+
search.scrollIntoView = search.scrollInWindow;
|
85
|
+
};
|
86
|
+
|
87
|
+
function highlightTarget( anchor ) {
|
88
|
+
console.debug( "Highlighting target '%s'.", anchor );
|
89
|
+
|
90
|
+
$("a[name]").each( function() {
|
91
|
+
if ( $(this).attr("name") == anchor ) {
|
92
|
+
if ( !$(this).parent().parent().hasClass('target-section') ) {
|
93
|
+
console.debug( "Wrapping the target-section" );
|
94
|
+
$('div.method-detail').unwrap( 'div.target-section' );
|
95
|
+
$(this).parent().wrap( '<div class="target-section"></div>' );
|
96
|
+
} else {
|
97
|
+
console.debug( "Already wrapped." );
|
98
|
+
}
|
99
|
+
}
|
100
|
+
});
|
101
|
+
};
|
102
|
+
|
103
|
+
function highlightLocationTarget() {
|
104
|
+
console.debug( "Location hash: %s", window.location.hash );
|
105
|
+
if ( ! window.location.hash || window.location.hash.length == 0 ) return;
|
106
|
+
|
107
|
+
var anchor = window.location.hash.substring(1);
|
108
|
+
console.debug( "Found anchor: %s; matching %s", anchor, "a[name=" + anchor + "]" );
|
109
|
+
|
110
|
+
highlightTarget( anchor );
|
111
|
+
};
|
112
|
+
|
113
|
+
function highlightClickTarget( event ) {
|
114
|
+
console.debug( "Highlighting click target for event %o", event.target );
|
115
|
+
try {
|
116
|
+
var anchor = $(event.target).attr( 'href' ).substring(1);
|
117
|
+
console.debug( "Found target anchor: %s", anchor );
|
118
|
+
highlightTarget( anchor );
|
119
|
+
} catch ( err ) {
|
120
|
+
console.error( "Exception while highlighting: %o", err );
|
121
|
+
};
|
122
|
+
};
|
123
|
+
|
124
|
+
function loadAsync(path, success, prefix) {
|
125
|
+
$.ajax({
|
126
|
+
url: prefix + path,
|
127
|
+
dataType: 'script',
|
128
|
+
success: success,
|
129
|
+
cache: true
|
130
|
+
});
|
131
|
+
};
|
132
|
+
|
133
|
+
$(document).ready( function() {
|
134
|
+
hookSourceViews();
|
135
|
+
highlightLocationTarget();
|
136
|
+
$('ul.link-list a').bind( "click", highlightClickTarget );
|
137
|
+
|
138
|
+
var search_scripts_loaded = {
|
139
|
+
navigation_loaded: false,
|
140
|
+
search_loaded: false,
|
141
|
+
search_index_loaded: false,
|
142
|
+
searcher_loaded: false,
|
143
|
+
}
|
144
|
+
|
145
|
+
var search_success_function = function(variable) {
|
146
|
+
return (function (data, status, xhr) {
|
147
|
+
search_scripts_loaded[variable] = true;
|
148
|
+
|
149
|
+
if (search_scripts_loaded['navigation_loaded'] == true &&
|
150
|
+
search_scripts_loaded['search_loaded'] == true &&
|
151
|
+
search_scripts_loaded['search_index_loaded'] == true &&
|
152
|
+
search_scripts_loaded['searcher_loaded'] == true)
|
153
|
+
hookSearch();
|
154
|
+
});
|
155
|
+
}
|
156
|
+
|
157
|
+
loadAsync('js/navigation.js', search_success_function('navigation_loaded'), rdoc_rel_prefix);
|
158
|
+
loadAsync('js/search.js', search_success_function('search_loaded'), rdoc_rel_prefix);
|
159
|
+
loadAsync('js/search_index.js', search_success_function('search_index_loaded'), index_rel_prefix);
|
160
|
+
loadAsync('js/searcher.js', search_success_function('searcher_loaded'), rdoc_rel_prefix);
|
161
|
+
});
|