This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_bootstrap-mixins.jade
236 lines (215 loc) · 10.2 KB
/
_bootstrap-mixins.jade
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
//- Common mixins that templates can share
mixin Nav(multipage)
div.col-md-3
nav#nav.nav
if multipage
.list-group
a.list-group-item.heading(href="#") Home
each resourceGroup in api.resourceGroups
.list-group
a.list-group-item.heading(href="##{(multipage ? 'page:' : '') + slug(resourceGroup.name)}")
= resourceGroup.name || 'Resource Group'
each resource in resourceGroup.resources
if !condenseNav || (resource.actions.length != 1)
a.list-group-item(href="##{multipage ? 'page:' + slug(resourceGroup.name) + ',header:' : ''}#{slug(resourceGroup.name)}-#{slug(resource.name)}")
i.fa.fa-bars
|
= resource.name || 'Resource'
each action in resource.actions
a.list-group-item(href="##{multipage ? 'page:' + slug(resourceGroup.name) + ',header:' : ''}#{slug(resourceGroup.name)}-#{slug(resource.name)}-#{slug(action.method)}", style="padding-left: 32px")
+Icon(action.method)
|
= action.name || action.method + ' ' + resource.uriTemplate
else
a.list-group-item(href="##{multipage ? 'page:' + slug(resourceGroup.name) + ',header:' : ''}#{slug(resourceGroup.name)}-#{slug(resource.name)}")
- var action = resource.actions[0]
+Icon(action.method)
|
= resource.name || action.name || action.method + ' ' + resource.uriTemplate
if api.metadata && api.metadata.HOST
p(style="text-align: center")
a(href=api.metadata.HOST.value)= api.metadata.HOST.value
mixin Parameters(params)
ul.list-group
li.list-group-item.bg-default: strong Parameters
li.list-group-item
dl.dl-horizontal
each name in Object.keys(params)
- var param = params[name]
dd
if param.required
dt
!= name
span required
else
dt
!= name
span optional
|
code= param.type
|
if param.default
span.text-info.default
strong Default:
span= param.default
|
if param.example
span.text-muted.example
strong Example:
span= param.example
!= markdown(param.description)
if param.values.length
p
strong Choices:
!= '<code>' + param.values.join('</code>, <code>') + '</code>'
mixin RequestResponse(title, request)
- var id = Math.round(Math.random() * 1000000)
- var content = Object.keys(request.headers).length || request.body || request.schema
li.list-group-item
strong
= title
if request.name
|
code= request.name
if content
a.pull-right(data-toggle="collapse", data-target="##{id}") See Example
if content
li.list-group-item.collapse(id=id)
if Object.keys(request.headers).length
.description!= markdown(request.description)
h5 Headers
pre
code
each name in Object.keys(request.headers)
!= highlight(name + ': ' + request.headers[name].value, 'http')
br
if request.body
h5 Body
pre
code!= highlight(request.body)
if request.schema
h5 Schema
pre
code!= highlight(request.schema)
mixin Examples(examples)
ul.list-group
each example in examples
each request in example.requests
+RequestResponse('Request', request)
each response in example.responses
+RequestResponse('Response', response)
mixin ResourceGroup(resourceGroup, getButtonClass, multipage)
.panel.panel-default
.panel-heading
h3(id="#{slug(resourceGroup.name)}")
= resourceGroup.name || 'Resource Group'
|
a(href="##{multipage ? 'page:' : ''}#{slug(resourceGroup.name)}")
i.fa.fa-link
.panel-body
if resourceGroup.description
!= markdown(resourceGroup.description)
each resource in resourceGroup.resources
h4(id="#{slug(resourceGroup.name)}-#{slug(resource.name)}")
= resource.name || 'Resources'
|
a(href="##{(multipage ? 'page:' + slug(resourceGroup.name) + ',header:' : '')}#{slug(resourceGroup.name)}-#{slug(resource.name)}")
i.fa.fa-link
if resource.description
!= markdown(resource.description)
each action in resource.actions
case action.method
when 'POST': - var panelClass = 'panel-success'
when 'GET': - var panelClass = 'panel-info'
when 'PUT': - var panelClass = 'panel-warning'
when 'PATCH': - var panelClass = 'panel-warning'
when 'DELETE': - var panelClass = 'panel-danger'
default: - var panelClass = 'panel-default'
section.panel(class=panelClass, id="#{slug(resourceGroup.name)}-#{slug(resource.name)}-#{slug(action.method)}")
.panel-heading
if action.name
span.pull-right(style="text-transform: lowercase")= action.name
case action.method
when 'POST': - var btnClass = 'btn-success'
when 'GET': - var btnClass = 'btn-' + getButtonClass
when 'PUT': - var btnClass = 'btn-warning'
when 'PATCH': - var btnClass = 'btn-warning'
when 'DELETE': - var btnClass = 'btn-danger'
default: - var btnClass = 'btn-default'
a.btn.btn-xs(class=btnClass, href="##{(multipage ? 'page:' + slug(resourceGroup.name) + ',header:' : '')}#{slug(resourceGroup.name)}-#{slug(resource.name)}-#{slug(action.method)}")= action.method
|
code= resource.uriTemplate
if action.description
.panel-body!= markdown(action.description)
- var params = Object.keys(action.parameters).length ? action.parameters : resource.parameters
if Object.keys(params).length
+Parameters(params)
if action.examples
+Examples(action.examples)
mixin Paginate(resourceGroups, index)
if index < resourceGroups.length - 1
a.btn.btn-default.pull-right(href="#page:#{slug(resourceGroups[index + 1].name)}")
| Next
i.fa.fa-arrow-circle-right
if index > 0
a.btn.btn-default(href="#page:#{slug(resourceGroups[index - 1].name)}")
i.fa.fa-arrow-circle-left
| Previous
else
a.btn.btn-default(href="#")
i.fa.fa-arrow-circle-left
| Previous
.clearfix
hr
mixin Icon(method)
case method
when 'GET'
i.fa.fa-arrow-circle-down
when 'POST'
i.fa.fa-plus-square
when 'PUT'
i.fa.fa-pencil
when 'PATCH'
i.fa.fa-pencil
when 'DELETE'
i.fa.fa-warning
default
i.fa.fa-dot-circle-o
mixin Content(getButtonClass, multipage)
div(data-bind=multipage ? "visible: page() == 'home'" : undefined)
.description!= markdown(api.description)
if multipage
a.btn.btn-default.pull-right(href="#page:#{slug(api.resourceGroups[0].name)}")
| Next
i.fa.fa-arrow-circle-right
.clearfix
hr
each resourceGroup, index in api.resourceGroups
div(data-bind=multipage ? "visible: page() == '#{slug(resourceGroup.name)}', style: {marginTop: page() == '#{slug(resourceGroup.name)}' ? '38px' : ''}" : undefined)
+ResourceGroup(resourceGroup, getButtonClass, multipage)
if multipage
+Paginate(api.resourceGroups, index)
mixin Multipage()
//- Multi-page support through Knockout.js
script(src="//cdnjs.cloudflare.com/ajax/libs/knockout/3.0.0/knockout-min.js")
script
:coffee
class App
constructor: ->
@page = ko.observable 'home'
window.app = new App()
window.onhashchange = ->
vars = {}
for v in location.hash.substr(1).split(',')
parts = v.split ':'
vars[parts[0]] = parts[1]
# Set the page
window.app.page vars.page or 'home'
# Scroll to a header if Set
if vars.header
$("##{vars.header}")[0].scrollIntoView true
else
window.scrollTo 0, 0
ko.applyBindings window.app
# Load the correct page
window.onhashchange()