slate_algolia 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/PULL_REQUEST_TEMPLATE.md +9 -0
- data/.gitignore +2 -1
- data/.rubocop.yml +5 -0
- data/CONTRIBUTING.md +9 -0
- data/Gemfile +3 -2
- data/README.md +60 -4
- data/Rakefile +5 -12
- data/lib/slate_algolia/extension.rb +94 -69
- data/lib/slate_algolia/index.rb +62 -45
- data/lib/slate_algolia/parser.rb +73 -52
- data/lib/slate_algolia.rb +4 -2
- data/slate_algolia.gemspec +12 -13
- data/spec/extension_spec.rb +64 -0
- data/spec/fixtures/base/build/index.html +309 -0
- data/spec/fixtures/base/config.rb +2 -0
- data/spec/fixtures/base/source/includes/_errors.md +20 -0
- data/spec/fixtures/base/source/index.html.md +188 -0
- data/spec/fixtures/base/source/layouts/layout.html.erb +81 -0
- data/spec/index_spec.rb +131 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/support/fixture.rb +17 -0
- data/spec/support/given.rb +26 -0
- metadata +24 -4
- data/features/support/env.rb +0 -4
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Middleman::SlateAlgolia::Extension do
|
4
|
+
ConfigOptions = Struct.new(
|
5
|
+
:application_id,
|
6
|
+
:api_key,
|
7
|
+
:dry_run,
|
8
|
+
:index_name,
|
9
|
+
:parsers,
|
10
|
+
:before_index
|
11
|
+
)
|
12
|
+
|
13
|
+
default_options = ConfigOptions.new('', '', false, 'API Docs', {}, nil)
|
14
|
+
|
15
|
+
before :each do
|
16
|
+
Given.fixture 'base'
|
17
|
+
@app = Middleman::Fixture.app
|
18
|
+
@extension = @app.extensions[:slate_algolia]
|
19
|
+
stub_request(:any, %r{.*\.algolia(net\.com|\.net)\/*/})
|
20
|
+
.to_return(body: '{"hits":[]}')
|
21
|
+
end
|
22
|
+
|
23
|
+
after :each do
|
24
|
+
WebMock.reset!
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'sets default options' do
|
28
|
+
expect(@extension.options.to_h.keys.length)
|
29
|
+
.to eq(default_options.size)
|
30
|
+
|
31
|
+
@extension.options.to_h.each do |key, value|
|
32
|
+
expect(@extension.options[key]).to(
|
33
|
+
eq(default_options[key]),
|
34
|
+
"#{key} was #{value}, should be #{default_options[key]}"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'after_build' do
|
40
|
+
it 'flushes the queue' do
|
41
|
+
expect_any_instance_of(Middleman::SlateAlgolia::Index)
|
42
|
+
.to receive(:flush_queue)
|
43
|
+
|
44
|
+
@extension.send(:after_build)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'cleans the index' do
|
48
|
+
expect_any_instance_of(Middleman::SlateAlgolia::Index)
|
49
|
+
.to receive(:clean_index)
|
50
|
+
|
51
|
+
@extension.send(:after_build)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'parse_content' do
|
56
|
+
it 'parses pages where slate_algolia is true' do
|
57
|
+
parser_double = double('Content Parser', sections: [])
|
58
|
+
expect(Middleman::SlateAlgolia::Parser)
|
59
|
+
.to receive(:new).and_return(parser_double)
|
60
|
+
|
61
|
+
@extension.send(:parse_content)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,309 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
</head>
|
5
|
+
|
6
|
+
<body class="index" data-languages="["shell","ruby","python","javascript"]">
|
7
|
+
<a href="#" id="nav-button">
|
8
|
+
<span>
|
9
|
+
NAV
|
10
|
+
<img src="/images/navbar.png" />
|
11
|
+
</span>
|
12
|
+
</a>
|
13
|
+
<div class="tocify-wrapper">
|
14
|
+
<img src="/images/logo.png" />
|
15
|
+
<div class="lang-selector">
|
16
|
+
<a href="#" data-language-name="shell">shell</a>
|
17
|
+
<a href="#" data-language-name="ruby">ruby</a>
|
18
|
+
<a href="#" data-language-name="python">python</a>
|
19
|
+
<a href="#" data-language-name="javascript">javascript</a>
|
20
|
+
</div>
|
21
|
+
<div id="toc">
|
22
|
+
</div>
|
23
|
+
<ul class="toc-footer">
|
24
|
+
<li><a href='#'>Sign Up for a Developer Key</a></li>
|
25
|
+
<li><a href='https://github.com/tripit/slate'>Documentation Powered by Slate</a></li>
|
26
|
+
</ul>
|
27
|
+
</div>
|
28
|
+
<div class="page-wrapper">
|
29
|
+
<div class="dark-box"></div>
|
30
|
+
<div class="content">
|
31
|
+
<h1 id="introduction">Introduction</h1>
|
32
|
+
|
33
|
+
<p>Welcome to the Kittn API! You can use our API to access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database.</p>
|
34
|
+
|
35
|
+
<p>We have language bindings in Shell, Ruby, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.</p>
|
36
|
+
|
37
|
+
<p>This example API documentation page was created with <a href="https://github.com/tripit/slate">Slate</a>. Feel free to edit it and use it as a base for your own API's documentation.</p>
|
38
|
+
|
39
|
+
<h1 id="authentication">Authentication</h1>
|
40
|
+
|
41
|
+
<blockquote>
|
42
|
+
<p>To authorize, use this code:</p>
|
43
|
+
</blockquote>
|
44
|
+
|
45
|
+
<p>```ruby
|
46
|
+
require 'kittn'</p>
|
47
|
+
|
48
|
+
<p>api = Kittn::APIClient.authorize!('meowmeowmeow')
|
49
|
+
```</p>
|
50
|
+
|
51
|
+
<p>```python
|
52
|
+
import kittn</p>
|
53
|
+
|
54
|
+
<p>api = kittn.authorize('meowmeowmeow')
|
55
|
+
```</p>
|
56
|
+
|
57
|
+
<p><code>shell
|
58
|
+
# With shell, you can just pass the correct header with each request
|
59
|
+
curl "api_endpoint_here"
|
60
|
+
-H "Authorization: meowmeowmeow"
|
61
|
+
</code></p>
|
62
|
+
|
63
|
+
<p>```javascript
|
64
|
+
const kittn = require('kittn');</p>
|
65
|
+
|
66
|
+
<p>let api = kittn.authorize('meowmeowmeow');
|
67
|
+
```</p>
|
68
|
+
|
69
|
+
<blockquote>
|
70
|
+
<p>Make sure to replace <code>meowmeowmeow</code> with your API key.</p>
|
71
|
+
</blockquote>
|
72
|
+
|
73
|
+
<p>Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our <a href="http://example.com/developers">developer portal</a>.</p>
|
74
|
+
|
75
|
+
<p>Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following:</p>
|
76
|
+
|
77
|
+
<p><code>Authorization: meowmeowmeow</code></p>
|
78
|
+
|
79
|
+
<aside class="notice">
|
80
|
+
You must replace <code>meowmeowmeow</code> with your personal API key.
|
81
|
+
</aside>
|
82
|
+
|
83
|
+
<h1 id="kittens">Kittens</h1>
|
84
|
+
|
85
|
+
<h2 id="get-all-kittens">Get All Kittens</h2>
|
86
|
+
|
87
|
+
<p>```ruby
|
88
|
+
require 'kittn'</p>
|
89
|
+
|
90
|
+
<p>api = Kittn::APIClient.authorize!('meowmeowmeow')
|
91
|
+
api.kittens.get
|
92
|
+
```</p>
|
93
|
+
|
94
|
+
<p>```python
|
95
|
+
import kittn</p>
|
96
|
+
|
97
|
+
<p>api = kittn.authorize('meowmeowmeow')
|
98
|
+
api.kittens.get()
|
99
|
+
```</p>
|
100
|
+
|
101
|
+
<p><code>shell
|
102
|
+
curl "http://example.com/api/kittens"
|
103
|
+
-H "Authorization: meowmeowmeow"
|
104
|
+
</code></p>
|
105
|
+
|
106
|
+
<p>```javascript
|
107
|
+
const kittn = require('kittn');</p>
|
108
|
+
|
109
|
+
<p>let api = kittn.authorize('meowmeowmeow');
|
110
|
+
let kittens = api.kittens.get();
|
111
|
+
```</p>
|
112
|
+
|
113
|
+
<blockquote>
|
114
|
+
<p>The above command returns JSON structured like this:</p>
|
115
|
+
</blockquote>
|
116
|
+
|
117
|
+
<p><code>json
|
118
|
+
[
|
119
|
+
{
|
120
|
+
"id": 1,
|
121
|
+
"name": "Fluffums",
|
122
|
+
"breed": "calico",
|
123
|
+
"fluffiness": 6,
|
124
|
+
"cuteness": 7
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"id": 2,
|
128
|
+
"name": "Max",
|
129
|
+
"breed": "unknown",
|
130
|
+
"fluffiness": 5,
|
131
|
+
"cuteness": 10
|
132
|
+
}
|
133
|
+
]
|
134
|
+
</code></p>
|
135
|
+
|
136
|
+
<p>This endpoint retrieves all kittens.</p>
|
137
|
+
|
138
|
+
<h3 id="http-request">HTTP Request</h3>
|
139
|
+
|
140
|
+
<p><code>GET http://example.com/api/kittens</code></p>
|
141
|
+
|
142
|
+
<h3 id="query-parameters">Query Parameters</h3>
|
143
|
+
|
144
|
+
<table>
|
145
|
+
<thead>
|
146
|
+
<tr>
|
147
|
+
<th>Parameter</th>
|
148
|
+
<th>Default</th>
|
149
|
+
<th>Description</th>
|
150
|
+
</tr>
|
151
|
+
</thead>
|
152
|
+
<tbody>
|
153
|
+
<tr>
|
154
|
+
<td>include_cats</td>
|
155
|
+
<td>false</td>
|
156
|
+
<td>If set to true, the result will also include cats.</td>
|
157
|
+
</tr>
|
158
|
+
<tr>
|
159
|
+
<td>available</td>
|
160
|
+
<td>true</td>
|
161
|
+
<td>If set to false, the result will include kittens that have already been adopted.</td>
|
162
|
+
</tr>
|
163
|
+
</tbody>
|
164
|
+
</table>
|
165
|
+
|
166
|
+
<aside class="success">
|
167
|
+
Remember — a happy kitten is an authenticated kitten!
|
168
|
+
</aside>
|
169
|
+
|
170
|
+
<h2 id="get-a-specific-kitten">Get a Specific Kitten</h2>
|
171
|
+
|
172
|
+
<p>```ruby
|
173
|
+
require 'kittn'</p>
|
174
|
+
|
175
|
+
<p>api = Kittn::APIClient.authorize!('meowmeowmeow')
|
176
|
+
api.kittens.get(2)
|
177
|
+
```</p>
|
178
|
+
|
179
|
+
<p>```python
|
180
|
+
import kittn</p>
|
181
|
+
|
182
|
+
<p>api = kittn.authorize('meowmeowmeow')
|
183
|
+
api.kittens.get(2)
|
184
|
+
```</p>
|
185
|
+
|
186
|
+
<p><code>shell
|
187
|
+
curl "http://example.com/api/kittens/2"
|
188
|
+
-H "Authorization: meowmeowmeow"
|
189
|
+
</code></p>
|
190
|
+
|
191
|
+
<p>```javascript
|
192
|
+
const kittn = require('kittn');</p>
|
193
|
+
|
194
|
+
<p>let api = kittn.authorize('meowmeowmeow');
|
195
|
+
let max = api.kittens.get(2);
|
196
|
+
```</p>
|
197
|
+
|
198
|
+
<blockquote>
|
199
|
+
<p>The above command returns JSON structured like this:</p>
|
200
|
+
</blockquote>
|
201
|
+
|
202
|
+
<p><code>json
|
203
|
+
{
|
204
|
+
"id": 2,
|
205
|
+
"name": "Max",
|
206
|
+
"breed": "unknown",
|
207
|
+
"fluffiness": 5,
|
208
|
+
"cuteness": 10
|
209
|
+
}
|
210
|
+
</code></p>
|
211
|
+
|
212
|
+
<p>This endpoint retrieves a specific kitten.</p>
|
213
|
+
|
214
|
+
<aside class="warning">Inside HTML code blocks like this one, you can't use Markdown, so use <code><code></code> blocks to denote code.</aside>
|
215
|
+
|
216
|
+
<h3 id="http-request-1">HTTP Request</h3>
|
217
|
+
|
218
|
+
<p><code>GET http://example.com/kittens/<ID></code></p>
|
219
|
+
|
220
|
+
<h3 id="url-parameters">URL Parameters</h3>
|
221
|
+
|
222
|
+
<table>
|
223
|
+
<thead>
|
224
|
+
<tr>
|
225
|
+
<th>Parameter</th>
|
226
|
+
<th>Description</th>
|
227
|
+
</tr>
|
228
|
+
</thead>
|
229
|
+
<tbody>
|
230
|
+
<tr>
|
231
|
+
<td>ID</td>
|
232
|
+
<td>The ID of the kitten to retrieve</td>
|
233
|
+
</tr>
|
234
|
+
</tbody>
|
235
|
+
</table>
|
236
|
+
|
237
|
+
<h1 id="errors">Errors</h1>
|
238
|
+
|
239
|
+
<aside class="notice">This error section is stored in a separate file in `includes/_errors.md`. Slate allows you to optionally separate out your docs into many files...just save them to the `includes` folder and add them to the top of your `index.md`'s frontmatter. Files are included in the order listed.</aside>
|
240
|
+
|
241
|
+
<p>The Kittn API uses the following error codes:</p>
|
242
|
+
|
243
|
+
<table>
|
244
|
+
<thead>
|
245
|
+
<tr>
|
246
|
+
<th>Error Code</th>
|
247
|
+
<th>Meaning</th>
|
248
|
+
</tr>
|
249
|
+
</thead>
|
250
|
+
<tbody>
|
251
|
+
<tr>
|
252
|
+
<td>400</td>
|
253
|
+
<td>Bad Request – Your request sucks</td>
|
254
|
+
</tr>
|
255
|
+
<tr>
|
256
|
+
<td>401</td>
|
257
|
+
<td>Unauthorized – Your API key is wrong</td>
|
258
|
+
</tr>
|
259
|
+
<tr>
|
260
|
+
<td>403</td>
|
261
|
+
<td>Forbidden – The kitten requested is hidden for administrators only</td>
|
262
|
+
</tr>
|
263
|
+
<tr>
|
264
|
+
<td>404</td>
|
265
|
+
<td>Not Found – The specified kitten could not be found</td>
|
266
|
+
</tr>
|
267
|
+
<tr>
|
268
|
+
<td>405</td>
|
269
|
+
<td>Method Not Allowed – You tried to access a kitten with an invalid method</td>
|
270
|
+
</tr>
|
271
|
+
<tr>
|
272
|
+
<td>406</td>
|
273
|
+
<td>Not Acceptable – You requested a format that isn't json</td>
|
274
|
+
</tr>
|
275
|
+
<tr>
|
276
|
+
<td>410</td>
|
277
|
+
<td>Gone – The kitten requested has been removed from our servers</td>
|
278
|
+
</tr>
|
279
|
+
<tr>
|
280
|
+
<td>418</td>
|
281
|
+
<td>I'm a teapot</td>
|
282
|
+
</tr>
|
283
|
+
<tr>
|
284
|
+
<td>429</td>
|
285
|
+
<td>Too Many Requests – You're requesting too many kittens! Slow down!</td>
|
286
|
+
</tr>
|
287
|
+
<tr>
|
288
|
+
<td>500</td>
|
289
|
+
<td>Internal Server Error – We had a problem with our server. Try again later.</td>
|
290
|
+
</tr>
|
291
|
+
<tr>
|
292
|
+
<td>503</td>
|
293
|
+
<td>Service Unavailable – We're temporarially offline for maintanance. Please try again later.</td>
|
294
|
+
</tr>
|
295
|
+
</tbody>
|
296
|
+
</table>
|
297
|
+
|
298
|
+
</div>
|
299
|
+
<div class="dark-box">
|
300
|
+
<div class="lang-selector">
|
301
|
+
<a href="#" data-language-name="shell">shell</a>
|
302
|
+
<a href="#" data-language-name="ruby">ruby</a>
|
303
|
+
<a href="#" data-language-name="python">python</a>
|
304
|
+
<a href="#" data-language-name="javascript">javascript</a>
|
305
|
+
</div>
|
306
|
+
</div>
|
307
|
+
</div>
|
308
|
+
</body>
|
309
|
+
</html>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# Errors
|
2
|
+
|
3
|
+
<aside class="notice">This error section is stored in a separate file in `includes/_errors.md`. Slate allows you to optionally separate out your docs into many files...just save them to the `includes` folder and add them to the top of your `index.md`'s frontmatter. Files are included in the order listed.</aside>
|
4
|
+
|
5
|
+
The Kittn API uses the following error codes:
|
6
|
+
|
7
|
+
|
8
|
+
Error Code | Meaning
|
9
|
+
---------- | -------
|
10
|
+
400 | Bad Request -- Your request sucks
|
11
|
+
401 | Unauthorized -- Your API key is wrong
|
12
|
+
403 | Forbidden -- The kitten requested is hidden for administrators only
|
13
|
+
404 | Not Found -- The specified kitten could not be found
|
14
|
+
405 | Method Not Allowed -- You tried to access a kitten with an invalid method
|
15
|
+
406 | Not Acceptable -- You requested a format that isn't json
|
16
|
+
410 | Gone -- The kitten requested has been removed from our servers
|
17
|
+
418 | I'm a teapot
|
18
|
+
429 | Too Many Requests -- You're requesting too many kittens! Slow down!
|
19
|
+
500 | Internal Server Error -- We had a problem with our server. Try again later.
|
20
|
+
503 | Service Unavailable -- We're temporarially offline for maintanance. Please try again later.
|
@@ -0,0 +1,188 @@
|
|
1
|
+
---
|
2
|
+
title: API Reference
|
3
|
+
|
4
|
+
language_tabs:
|
5
|
+
- shell
|
6
|
+
- ruby
|
7
|
+
- python
|
8
|
+
- javascript
|
9
|
+
|
10
|
+
toc_footers:
|
11
|
+
- <a href='#'>Sign Up for a Developer Key</a>
|
12
|
+
- <a href='https://github.com/tripit/slate'>Documentation Powered by Slate</a>
|
13
|
+
|
14
|
+
includes:
|
15
|
+
- errors
|
16
|
+
|
17
|
+
algolia_search: true
|
18
|
+
---
|
19
|
+
|
20
|
+
# Introduction
|
21
|
+
|
22
|
+
Welcome to the Kittn API! You can use our API to access Kittn API endpoints, which can get information on various cats, kittens, and breeds in our database.
|
23
|
+
|
24
|
+
We have language bindings in Shell, Ruby, and Python! You can view code examples in the dark area to the right, and you can switch the programming language of the examples with the tabs in the top right.
|
25
|
+
|
26
|
+
This example API documentation page was created with [Slate](https://github.com/tripit/slate). Feel free to edit it and use it as a base for your own API's documentation.
|
27
|
+
|
28
|
+
# Authentication
|
29
|
+
|
30
|
+
> To authorize, use this code:
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'kittn'
|
34
|
+
|
35
|
+
api = Kittn::APIClient.authorize!('meowmeowmeow')
|
36
|
+
```
|
37
|
+
|
38
|
+
```python
|
39
|
+
import kittn
|
40
|
+
|
41
|
+
api = kittn.authorize('meowmeowmeow')
|
42
|
+
```
|
43
|
+
|
44
|
+
```shell
|
45
|
+
# With shell, you can just pass the correct header with each request
|
46
|
+
curl "api_endpoint_here"
|
47
|
+
-H "Authorization: meowmeowmeow"
|
48
|
+
```
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
const kittn = require('kittn');
|
52
|
+
|
53
|
+
let api = kittn.authorize('meowmeowmeow');
|
54
|
+
```
|
55
|
+
|
56
|
+
> Make sure to replace `meowmeowmeow` with your API key.
|
57
|
+
|
58
|
+
Kittn uses API keys to allow access to the API. You can register a new Kittn API key at our [developer portal](http://example.com/developers).
|
59
|
+
|
60
|
+
Kittn expects for the API key to be included in all API requests to the server in a header that looks like the following:
|
61
|
+
|
62
|
+
`Authorization: meowmeowmeow`
|
63
|
+
|
64
|
+
<aside class="notice">
|
65
|
+
You must replace <code>meowmeowmeow</code> with your personal API key.
|
66
|
+
</aside>
|
67
|
+
|
68
|
+
# Kittens
|
69
|
+
|
70
|
+
## Get All Kittens
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
require 'kittn'
|
74
|
+
|
75
|
+
api = Kittn::APIClient.authorize!('meowmeowmeow')
|
76
|
+
api.kittens.get
|
77
|
+
```
|
78
|
+
|
79
|
+
```python
|
80
|
+
import kittn
|
81
|
+
|
82
|
+
api = kittn.authorize('meowmeowmeow')
|
83
|
+
api.kittens.get()
|
84
|
+
```
|
85
|
+
|
86
|
+
```shell
|
87
|
+
curl "http://example.com/api/kittens"
|
88
|
+
-H "Authorization: meowmeowmeow"
|
89
|
+
```
|
90
|
+
|
91
|
+
```javascript
|
92
|
+
const kittn = require('kittn');
|
93
|
+
|
94
|
+
let api = kittn.authorize('meowmeowmeow');
|
95
|
+
let kittens = api.kittens.get();
|
96
|
+
```
|
97
|
+
|
98
|
+
> The above command returns JSON structured like this:
|
99
|
+
|
100
|
+
```json
|
101
|
+
[
|
102
|
+
{
|
103
|
+
"id": 1,
|
104
|
+
"name": "Fluffums",
|
105
|
+
"breed": "calico",
|
106
|
+
"fluffiness": 6,
|
107
|
+
"cuteness": 7
|
108
|
+
},
|
109
|
+
{
|
110
|
+
"id": 2,
|
111
|
+
"name": "Max",
|
112
|
+
"breed": "unknown",
|
113
|
+
"fluffiness": 5,
|
114
|
+
"cuteness": 10
|
115
|
+
}
|
116
|
+
]
|
117
|
+
```
|
118
|
+
|
119
|
+
This endpoint retrieves all kittens.
|
120
|
+
|
121
|
+
### HTTP Request
|
122
|
+
|
123
|
+
`GET http://example.com/api/kittens`
|
124
|
+
|
125
|
+
### Query Parameters
|
126
|
+
|
127
|
+
Parameter | Default | Description
|
128
|
+
--------- | ------- | -----------
|
129
|
+
include_cats | false | If set to true, the result will also include cats.
|
130
|
+
available | true | If set to false, the result will include kittens that have already been adopted.
|
131
|
+
|
132
|
+
<aside class="success">
|
133
|
+
Remember — a happy kitten is an authenticated kitten!
|
134
|
+
</aside>
|
135
|
+
|
136
|
+
## Get a Specific Kitten
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
require 'kittn'
|
140
|
+
|
141
|
+
api = Kittn::APIClient.authorize!('meowmeowmeow')
|
142
|
+
api.kittens.get(2)
|
143
|
+
```
|
144
|
+
|
145
|
+
```python
|
146
|
+
import kittn
|
147
|
+
|
148
|
+
api = kittn.authorize('meowmeowmeow')
|
149
|
+
api.kittens.get(2)
|
150
|
+
```
|
151
|
+
|
152
|
+
```shell
|
153
|
+
curl "http://example.com/api/kittens/2"
|
154
|
+
-H "Authorization: meowmeowmeow"
|
155
|
+
```
|
156
|
+
|
157
|
+
```javascript
|
158
|
+
const kittn = require('kittn');
|
159
|
+
|
160
|
+
let api = kittn.authorize('meowmeowmeow');
|
161
|
+
let max = api.kittens.get(2);
|
162
|
+
```
|
163
|
+
|
164
|
+
> The above command returns JSON structured like this:
|
165
|
+
|
166
|
+
```json
|
167
|
+
{
|
168
|
+
"id": 2,
|
169
|
+
"name": "Max",
|
170
|
+
"breed": "unknown",
|
171
|
+
"fluffiness": 5,
|
172
|
+
"cuteness": 10
|
173
|
+
}
|
174
|
+
```
|
175
|
+
|
176
|
+
This endpoint retrieves a specific kitten.
|
177
|
+
|
178
|
+
<aside class="warning">Inside HTML code blocks like this one, you can't use Markdown, so use <code><code></code> blocks to denote code.</aside>
|
179
|
+
|
180
|
+
### HTTP Request
|
181
|
+
|
182
|
+
`GET http://example.com/kittens/<ID>`
|
183
|
+
|
184
|
+
### URL Parameters
|
185
|
+
|
186
|
+
Parameter | Description
|
187
|
+
--------- | -----------
|
188
|
+
ID | The ID of the kitten to retrieve
|
@@ -0,0 +1,81 @@
|
|
1
|
+
<%#
|
2
|
+
Copyright 2008-2013 Concur Technologies, Inc.
|
3
|
+
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
5
|
+
not use this file except in compliance with the License. You may obtain
|
6
|
+
a copy of the License at
|
7
|
+
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
12
|
+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
13
|
+
License for the specific language governing permissions and limitations
|
14
|
+
under the License.
|
15
|
+
%>
|
16
|
+
<% language_tabs = current_page.data.language_tabs || [] %>
|
17
|
+
<!doctype html>
|
18
|
+
<html>
|
19
|
+
<head>
|
20
|
+
</head>
|
21
|
+
|
22
|
+
<body class="<%= page_classes %>" data-languages="<%=h language_tabs.map{ |lang| lang.is_a?(Hash) ? lang.keys.first : lang }.to_json %>">
|
23
|
+
<a href="#" id="nav-button">
|
24
|
+
<span>
|
25
|
+
NAV
|
26
|
+
<%= image_tag('navbar.png') %>
|
27
|
+
</span>
|
28
|
+
</a>
|
29
|
+
<div class="tocify-wrapper">
|
30
|
+
<%= image_tag "logo.png" %>
|
31
|
+
<% if language_tabs %>
|
32
|
+
<div class="lang-selector">
|
33
|
+
<% language_tabs.each do |lang| %>
|
34
|
+
<% if lang.is_a? Hash %>
|
35
|
+
<a href="#" data-language-name="<%= lang.keys.first %>"><%= lang.values.first %></a>
|
36
|
+
<% else %>
|
37
|
+
<a href="#" data-language-name="<%= lang %>"><%= lang %></a>
|
38
|
+
<% end %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
<% end %>
|
42
|
+
<% if current_page.data.search %>
|
43
|
+
<div class="search">
|
44
|
+
<input type="text" class="search" id="input-search" placeholder="Search">
|
45
|
+
</div>
|
46
|
+
<ul class="search-results"></ul>
|
47
|
+
<% end %>
|
48
|
+
<div id="toc">
|
49
|
+
</div>
|
50
|
+
<% if current_page.data.toc_footers %>
|
51
|
+
<ul class="toc-footer">
|
52
|
+
<% current_page.data.toc_footers.each do |footer| %>
|
53
|
+
<li><%= footer %></li>
|
54
|
+
<% end %>
|
55
|
+
</ul>
|
56
|
+
<% end %>
|
57
|
+
</div>
|
58
|
+
<div class="page-wrapper">
|
59
|
+
<div class="dark-box"></div>
|
60
|
+
<div class="content">
|
61
|
+
<%= yield %>
|
62
|
+
<% current_page.data.includes && current_page.data.includes.each do |include| %>
|
63
|
+
<%= partial "includes/#{include}" %>
|
64
|
+
<% end %>
|
65
|
+
</div>
|
66
|
+
<div class="dark-box">
|
67
|
+
<% if language_tabs %>
|
68
|
+
<div class="lang-selector">
|
69
|
+
<% language_tabs.each do |lang| %>
|
70
|
+
<% if lang.is_a? Hash %>
|
71
|
+
<a href="#" data-language-name="<%= lang.keys.first %>"><%= lang.values.first %></a>
|
72
|
+
<% else %>
|
73
|
+
<a href="#" data-language-name="<%= lang %>"><%= lang %></a>
|
74
|
+
<% end %>
|
75
|
+
<% end %>
|
76
|
+
</div>
|
77
|
+
<% end %>
|
78
|
+
</div>
|
79
|
+
</div>
|
80
|
+
</body>
|
81
|
+
</html>
|