documentation.phtml
6.4 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo $title ?></title>
<!-- Bootstrap core CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body ng-app="app" ng-controller="AppController as vm">
<div class="container">
<h1><?php echo $title ?></h1>
<p class="lead">Documentation</p>
<h2>Collections</h2>
<div ng-repeat="collection in vm.documentation.collections">
<div class="panel panel-primary">
<div class="panel-heading">
{{ collection.name || collection.prefix }}
</div>
<table class="table table-bordered">
<tr ng-show="collection.description">
<th>Description</th>
<td>{{ collection.description }}</td>
</tr>
<tr>
<th>Base path</th>
<td>{{ collection.prefix }}</td>
</tr>
<tr ng-show="collection.fields">
<th>Fields</th>
<td>
<table class="table table-bordered">
<tr ng-repeat="(field, dataType) in collection.fields">
<th>
{{ field }}
</th>
<td>
<div class="label label-primary">{{ dataType | dataType }}</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
<div class="panel-footer">
<div class="panel panel-primary" ng-repeat="endpoint in collection.endpoints">
<div class="panel-heading">
<span ng-bind-html="endpoint.httpMethod | method"></span> {{ collection.prefix + endpoint.path }}
</div>
<table class="table table-bordered">
<tr ng-show="endpoint.description">
<th>Description</th>
<th>{{ endpoint.description }}</th>
</tr>
<tr>
<th>Full URL</th>
<td>
<a ng-href="{{ vm.documentation.basePath + collection.prefix + endpoint.path }}" target="_blank">
{{ vm.documentation.basePath + collection.prefix + endpoint.path }}
</a>
</td>
</tr>
<tr ng-show="endpoint.exampleRequest">
<th>Example request</th>
<th><pre style="font-weight: normal;">{{ endpoint.exampleRequest | json }}</pre></th>
</tr>
<tr ng-show="endpoint.exampleResponse">
<th>Example response</th>
<th><pre style="font-weight: normal;">{{ endpoint.exampleResponse | json }}</pre></th>
</tr>
<tr>
<th>Allowed roles</th>
<td>
<div class="label label-primary" ng-repeat="role in endpoint.allowedRoles" style="margin-right: 5px">{{ role }}</div>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
<h2>Other routes</h2>
<div class="panel panel-default" ng-repeat="route in vm.documentation.routes">
<div class="panel-heading">
{{ route.pattern }}
</div>
</div>
</div><!-- /.container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://code.angularjs.org/1.4.8/angular-sanitize.min.js"></script>
<script>
var documentationPath = '<?php echo $documentationPath ?>';
var app = angular.module('app', [
'ngSanitize'
]);
app.controller('AppController', AppController);
function AppController($http) {
var vm = this;
$http.get(documentationPath).then(function(response) {
vm.documentation = response.data.documentation;
});
}
app.filter('method', function() {
return function(input) {
switch(input) {
case 'GET':
return '<div class="label label-success">' + input + '</div>';
case 'POST':
return '<div class="label label-warning">' + input + '</div>';
case 'PUT':
return '<div class="label label-info">' + input + '</div>';
case 'DELETE':
return '<div class="label label-danger">' + input + '</div>';
default:
return null;
}
}
});
app.filter('dataType', function() {
return function(input) {
switch(input) {
case 1:
return 'Integer';
case 2:
return 'Float';
case 3:
return 'Double';
case 4:
return 'Boolean';
case 5:
return 'String';
case 6:
return 'Timestamp';
case 7:
return 'JSON';
default:
return 'Unknown';
}
}
});
</script>
</body>
</html>