1
0
mirror of https://github.com/Decicus/DecAPI-Docs.git synced 2024-11-22 08:52:31 +01:00

Add data files and complete layout

This commit is contained in:
Alex Thomassen 2017-01-11 13:50:06 +01:00
parent 6c2bcdd125
commit afcf59eeec
6 changed files with 281 additions and 0 deletions

15
.editorconfig Normal file
View File

@ -0,0 +1,15 @@
# http://editorconfig.org
root = true
[*.{html,js,md}]
end_of_line = lf
indent_style = space
indent_size = 4
charset = utf-8
insert_final_newline = true
[*.{html,js}]
trim_trailing_whitespace = true
[*.md]
trim_trailing_whitespace = false

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
*.html text eol=lf
*.js text eol=lf

1
data/base.json Normal file
View File

@ -0,0 +1 @@
[{"name":"askfm","title":"ASKfm","icon":"question"},{"name":"br","title":"Battle Royale (Arma 3 Mod)"},{"name":"bttv","title":"BetterTTV"},{"name":"dayz","title":"DayZ"},{"name":"lever","title":"Lever"},{"name":"misc","title":"Miscellaneous"},{"name":"random","title":"Random","icon":"random"},{"name":"steam","title":"Steam","icon":"steam"},{"name":"twitch","title":"Twitch","icon":"twitch"},{"name":"twitter","title":"Twitter","icon":"twitter"},{"name":"youtube","title":"YouTube","icon":"youtube"}]

1
data/endpoints.json Normal file

File diff suppressed because one or more lines are too long

120
index.html Normal file
View File

@ -0,0 +1,120 @@
<!DOCTYPE html>
<html>
<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>DecAPI Docs</title>
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/cosmo/bootstrap.min.css" rel="stylesheet" integrity="sha384-h21C2fcDk/eFsW9sC9h0dhokq5pDinLNklTKoxIZRUn3+hvmgQSffLLQ4G4l2eEr" crossorigin="anonymous">
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<a class="navbar-brand" href="#">DecAPI Docs</a>
</div>
<ul class="nav navbar-nav">
<li><a href="https://github.com/Decicus/DecAPI"><i class="fa fa-1x fa-github"></i> GitHub Repo</a></li>
</ul>
</div>
</nav>
<div class="container-fluid" id="content">
<i class="hidden fa fa-1x" id="fa-template"></i>
<div class="hidden" id="base-template">
<div class="page-header">
<h4><i class="fa fa-1x fa-fw"></i> <span></span></h4>
</div>
</div>
<div class="panel panel-default hidden" id="endpoint-template">
<div class="panel-heading">
<h3 class="panel-title" id="title">
<span class="text-muted" id="base"><a href="#"></a></span><span id="route"></span>
</h3>
</div>
<div class="panel-body" id="main-body">
<p class="text-warning">Notes:</p>
<ul id="description" class="list-group text-primary"></ul>
<pre><strong class="text-primary"></strong> <code></code></pre>
<div id="routes" class="hidden">
<p class="text-warning">Route parameters:</p>
<table class="table table-bordered" id="route-body">
<thead>
<tr>
<th>Parameter name:</th>
<th>Description:</th>
<th>Required:</th>
<th>Type:</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
<div id="qs" class="hidden">
<p class="text-warning">Query string parameters:</p>
<table class="table table-bordered" id="qs-body">
<thead>
<tr>
<th>Parameter name:</th>
<th>Description:</th>
<th>Required:</th>
<th>Type:</th>
</tr>
</thead>
<tbody></tbody>
</table>
</div>
</div>
</div>
<div class="page-header">
<h1>DecAPI Docs</h1>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">General information</h3>
</div>
<div class="panel-body">
These pages will house the documentation of endpoints under DecAPI.
<br>
Each page of documentation will contain a list of endpoints as well as some information regarding each of them.
</div>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title">Default options &amp; results</h3>
</div>
<div class="panel-body">
<p>These are options or results that will be the default, <strong>unless the notes about the endpoint mention otherwise</strong>.</p>
<div class="list-group">
<li class="list-group-item">The base URL for all endpoints is <code>https://beta.decapi.me</code> and requires support for SSL.</li>
<li class="list-group-item"><strong>HTTP</strong> requests will receive a <code>301 Moved Permanently</code> to <strong>HTTPS</strong>.</li>
<li class="list-group-item">The default HTTP method supported is <code>GET</code>.</li>
<li class="list-group-item">Responses are <code>Content-Type: text/plain</code>.</li>
<li class="list-group-item">Parameters are <strong>always</strong> required.</li>
<li class="list-group-item">Query strings are <strong>never</strong> required.</li>
</div>
</div>
</div>
<div class="page-header">
<h1>Endpoints:</h1>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha256-U5ZEeKfGNOja007MMD3YBI0A3OSZOQbeG6z2f2Y0hu8=" crossorigin="anonymous"></script>
<script src="./js/main.js" charset="utf-8"></script>
</body>
</html>

142
js/main.js Normal file
View File

@ -0,0 +1,142 @@
$(document).ready(function() {
var content = $('#content'),
baseTemp = $('#base-template', content),
endTemp = $('#endpoint-template', content),
faTemp = $('#fa-template', content),
baseUrl = 'https://beta.decapi.me';
$.get({
url: './data/base.json',
type: 'GET',
dataType: 'json',
success: function(data) {
$.each(data, function(k, base) {
var temp = baseTemp.clone();
temp.attr('id', base.name);
$('.page-header i', temp).addClass('fa-' + (base.icon || 'info'));
$('.page-header span', temp).html(base.title);
temp.removeClass('hidden');
temp.appendTo(content);
});
loadEndpoints();
},
error: function(err) {
$('<div/>')
.addClass('alert alert-warning')
.html('There was an error loading the endpoint data. Try again later.')
.appendTo(content);
}
});
function loadEndpoints()
{
$.get({
url: './data/endpoints.json',
type: 'GET',
dataType: 'json',
success: function(data) {
$.each(data, function(id, info) {
var div = $('#' + id);
$.each(info.endpoints, function(k, end) {
var panel = endTemp.clone(),
title = $('#title', panel),
body = $('#main-body', panel),
description = $('#description', body),
routes = $('#route-body', panel),
qs = $('#qs-body', panel);
$('#base a', title)
.attr('href', '#' + id)
.html(info.base_path + '/');
$('#route', title).html(end.route);
$.each(end.notes, function(k, note) {
$('<li/>')
.addClass('list-group-item')
.html(note)
.appendTo(description);
});
$('pre strong', body).html(end.method || 'GET');
$('pre code', body).html(baseUrl + info.base_path + '/' + end.route);
// Route parameters
if (end.parameters && end.parameters.length > 0) {
$('#routes', panel).removeClass('hidden');
$.each(end.parameters, function(k, param) {
var row = $('<tr/>');
var required = faTemp
.clone()
.addClass(param.optional ? 'fa-times' : 'fa-check')
.removeClass('hidden');
// Parameter name
$('<th/>')
.html(param.name)
.appendTo(row);
// Parameter description
$('<td/>')
.html(param.description)
.appendTo(row);
// Parameter required/optional
$('<td/>')
.html(required)
.appendTo(row);
// Parameter type
$('<td/>')
.html('<code>' + (param.type || 'string') + '</code>')
.appendTo(row);
row.appendTo($('tbody', routes));
});
}
// Query string parameters
if (end.qs && end.qs.length > 0) {
$('#qs', panel).removeClass('hidden');
$.each(end.qs, function(k, param) {
var row = $('<tr/>');
var required = faTemp
.clone()
.addClass(param.required ? 'fa-check' : 'fa-times')
.removeClass('hidden');
// Parameter name
$('<th/>')
.html(param.name)
.appendTo(row);
// Parameter description
$('<td/>')
.html(param.description)
.appendTo(row);
// Parameter required/optional
$('<td/>')
.html(required)
.appendTo(row);
// Parameter type
$('<td/>')
.html('<code>' + (param.type || 'string') + '</code>')
.appendTo(row);
row.appendTo($('tbody', qs));
});
}
panel.removeClass('hidden');
panel.appendTo(div);
});
});
}
});
}
});