Initial commit

This commit is contained in:
Keannu Christian Bernasol 2023-10-23 21:09:46 +08:00
commit c92d80c7fd
637 changed files with 73212 additions and 0 deletions

View file

@ -0,0 +1,359 @@
h1 {
font-size: 45px;
}
.intro-code {
margin-top: 20px;
}
pre.highlight code * {
white-space: nowrap; /* this sets all children inside to nowrap */
}
pre.highlight {
overflow-x: auto; /* this sets the scrolling in x */
}
pre.highlight code {
white-space: pre; /* forces <code> to respect <pre> formatting */
}
.main-container {
padding-left: 30px;
padding-right: 30px;
}
.btn:focus,
.btn:focus:active {
outline: none;
}
.sidebar {
overflow: auto;
font-family: verdana, sans-serif;
font-size: 12px;
font-weight: 200;
background-color: #2e353d;
position: fixed;
top: 0px;
width: 225px;
height: 100%;
color: #FFF;
}
.sidebar .brand {
background-color: #23282e;
display: block;
text-align: center;
padding: 25px 0;
margin-top: 0;
margin-bottom: 0;
}
.sidebar .brand a {
color: #FFF;
}
.sidebar .brand a:hover,
.sidebar .brand a:active,
.sidebar .brand a:focus {
text-decoration: none;
}
.sidebar .toggle-btn {
display: none;
}
.sidebar .menu-list {
width: inherit;
}
.sidebar .menu-list ul,
.sidebar .menu-list li {
background: #2e353d;
list-style: none;
padding: 0px;
margin: 0px;
line-height: 35px;
cursor: pointer;
}
.sidebar .menu-list ul :not(collapsed) .arrow:before,
.sidebar .menu-list li :not(collapsed) .arrow:before {
font-family: FontAwesome;
content: "\f078";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
float: right;
}
.sidebar .menu-list ul .active,
.sidebar .menu-list li .active {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
}
.sidebar .menu-list ul .sub-menu li.active,
.sidebar .menu-list li .sub-menu li.active {
color: #d19b3d;
}
.sidebar .menu-list ul .sub-menu li.active a,
.sidebar .menu-list li .sub-menu li.active a {
color: #d19b3d;
}
.sidebar .menu-list ul .sub-menu li,
.sidebar .menu-list li .sub-menu li {
background-color: #181c20;
border: none;
border-bottom: 1px solid #23282e;
margin-left: 0px;
line-height: 1.4;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 10px;
padding-left: 25px;
}
.sidebar .menu-list ul .sub-menu li:hover,
.sidebar .menu-list li .sub-menu li:hover {
background-color: #020203;
}
.sidebar .menu-list ul .sub-menu li a,
.sidebar .menu-list li .sub-menu li a {
display: block;
}
.sidebar .menu-list ul .sub-menu li a:before,
.sidebar .menu-list li .sub-menu li a:before {
font-family: FontAwesome;
font-size: 14px;
font-weight: bold;
content: "\f105";
display: inline;
vertical-align: middle;
padding-left: 0;
padding-right: 7px;
margin-left: -12px;
}
.sidebar .menu-list li {
padding-left: 0px;
border-left: 3px solid #2e353d;
border-bottom: 1px solid #23282e;
}
.sidebar .menu-list li a {
text-decoration: none;
color: white;
}
.sidebar .menu-list li a i {
padding-left: 10px;
width: 20px;
padding-right: 20px;
}
.sidebar .menu-list li:hover {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.sidebar #menu-content {
padding-bottom: 70px;
}
body {
margin: 0px;
padding: 0px;
}
.coredocs-section-title {
margin-top: 20px;
padding-bottom: 10px;
border-bottom: 1px solid lightgrey;
}
.coredocs-link-title a,
.coredocs-section-title a {
display: none;
}
.coredocs-link-title a,
.coredocs-section-title a {
text-decoration: none;
}
.coredocs-link-title:hover a,
.coredocs-section-title:hover a {
display: inline;
font-size: 20px;
}
.coredocs-section-title:last-child {
margin-top: 0;
}
/* @group Language Switcher */
.sidebar .menu-list.menu-list-bottom {
margin-bottom: 0;
position: fixed;
width: inherit;
bottom: 0;
left: 0;
right: 0;
border-top: 1px solid #23282e;
}
.sidebar .menu-list-bottom li span {
float: right;
margin-right: 20px;
color: #d19b3d;
}
/* @end Language Switcher */
/* @group Docs Content */
.docs-content .meta .label {
vertical-align: middle;
font-size: 14px;
font-weight: normal;
}
.docs-content .meta code {
vertical-align: middle;
padding: .2em .6em .3em;
font-size: 14px;
}
.docs-content .btn {
font-size: inherit;
}
.code-samples pre {
margin-top: 20px;
}
/* @end Docs Content */
@media (max-width: 767px) {
.main-container {
padding-left: 15px;
padding-right: 15px;
}
.sidebar {
position: relative;
width: 100%;
margin-bottom: 10px;
overflow: visible;
}
.sidebar .toggle-btn {
display: block;
cursor: pointer;
position: absolute;
right: 10px;
top: 10px;
z-index: 10 !important;
padding: 3px;
width: 40px;
text-align: center;
}
.sidebar .menu-list.menu-list-bottom {
position: static;
}
.sidebar .brand {
margin-top: 0;
margin-bottom: 0;
text-align: left !important;
font-size: 22px;
padding: 0;
padding-left: 20px;
line-height: 50px !important;
}
}
@media (min-width: 767px) {
.sidebar .menu-list .menu-content {
display: block;
}
#main {
width:calc(100% - 225px);
float: right;
}
}
@media (min-width: 992px) {
.modal-lg {
width: 980px;
}
}
.api-modal .modal-title .fa {
color: #93c54b;
}
.api-modal .modal-body .request-awaiting {
padding: 35px 10px;
color: #7F8177;
text-align: center;
}
.api-modal .modal-body .meta {
margin-bottom: 20px;
}
.api-modal .modal-body .meta .label {
vertical-align: middle;
font-size: 14px;
font-weight: normal;
}
.api-modal .modal-body .meta code {
vertical-align: middle;
padding: .2em .6em .3em;
font-size: 14px;
}
.api-modal .modal-content .toggle-view {
text-align: right;
float: right;
}
.api-modal .modal-content .response .well {
margin: 0;
max-height: 550px;
}
.highlight {
background-color: #f7f7f9
}
.checkbox label.control-label {
font-weight: bold
}
@media (min-width: 768px) {
.navbar-nav.navbar-right:last-child {
margin-right: 0 !important;
}
}

View file

@ -0,0 +1,359 @@
h1 {
font-size: 45px;
}
.intro-code {
margin-top: 20px;
}
pre.highlight code * {
white-space: nowrap; /* this sets all children inside to nowrap */
}
pre.highlight {
overflow-x: auto; /* this sets the scrolling in x */
}
pre.highlight code {
white-space: pre; /* forces <code> to respect <pre> formatting */
}
.main-container {
padding-left: 30px;
padding-right: 30px;
}
.btn:focus,
.btn:focus:active {
outline: none;
}
.sidebar {
overflow: auto;
font-family: verdana, sans-serif;
font-size: 12px;
font-weight: 200;
background-color: #2e353d;
position: fixed;
top: 0px;
width: 225px;
height: 100%;
color: #FFF;
}
.sidebar .brand {
background-color: #23282e;
display: block;
text-align: center;
padding: 25px 0;
margin-top: 0;
margin-bottom: 0;
}
.sidebar .brand a {
color: #FFF;
}
.sidebar .brand a:hover,
.sidebar .brand a:active,
.sidebar .brand a:focus {
text-decoration: none;
}
.sidebar .toggle-btn {
display: none;
}
.sidebar .menu-list {
width: inherit;
}
.sidebar .menu-list ul,
.sidebar .menu-list li {
background: #2e353d;
list-style: none;
padding: 0px;
margin: 0px;
line-height: 35px;
cursor: pointer;
}
.sidebar .menu-list ul :not(collapsed) .arrow:before,
.sidebar .menu-list li :not(collapsed) .arrow:before {
font-family: FontAwesome;
content: "\f078";
display: inline-block;
padding-left: 10px;
padding-right: 10px;
vertical-align: middle;
float: right;
}
.sidebar .menu-list ul .active,
.sidebar .menu-list li .active {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
}
.sidebar .menu-list ul .sub-menu li.active,
.sidebar .menu-list li .sub-menu li.active {
color: #d19b3d;
}
.sidebar .menu-list ul .sub-menu li.active a,
.sidebar .menu-list li .sub-menu li.active a {
color: #d19b3d;
}
.sidebar .menu-list ul .sub-menu li,
.sidebar .menu-list li .sub-menu li {
background-color: #181c20;
border: none;
border-bottom: 1px solid #23282e;
margin-left: 0px;
line-height: 1.4;
padding-top: 10px;
padding-bottom: 10px;
padding-right: 10px;
padding-left: 25px;
}
.sidebar .menu-list ul .sub-menu li:hover,
.sidebar .menu-list li .sub-menu li:hover {
background-color: #020203;
}
.sidebar .menu-list ul .sub-menu li a,
.sidebar .menu-list li .sub-menu li a {
display: block;
}
.sidebar .menu-list ul .sub-menu li a:before,
.sidebar .menu-list li .sub-menu li a:before {
font-family: FontAwesome;
font-size: 14px;
font-weight: bold;
content: "\f105";
display: inline;
vertical-align: middle;
padding-left: 0;
padding-right: 7px;
margin-left: -12px;
}
.sidebar .menu-list li {
padding-left: 0px;
border-left: 3px solid #2e353d;
border-bottom: 1px solid #23282e;
}
.sidebar .menu-list li a {
text-decoration: none;
color: white;
}
.sidebar .menu-list li a i {
padding-left: 10px;
width: 20px;
padding-right: 20px;
}
.sidebar .menu-list li:hover {
border-left: 3px solid #d19b3d;
background-color: #4f5b69;
-webkit-transition: all 1s ease;
-moz-transition: all 1s ease;
-o-transition: all 1s ease;
-ms-transition: all 1s ease;
transition: all 1s ease;
}
.sidebar #menu-content {
padding-bottom: 70px;
}
body {
margin: 0px;
padding: 0px;
}
.coredocs-section-title {
margin-top: 20px;
padding-bottom: 10px;
border-bottom: 1px solid lightgrey;
}
.coredocs-link-title a,
.coredocs-section-title a {
display: none;
}
.coredocs-link-title a,
.coredocs-section-title a {
text-decoration: none;
}
.coredocs-link-title:hover a,
.coredocs-section-title:hover a {
display: inline;
font-size: 20px;
}
.coredocs-section-title:last-child {
margin-top: 0;
}
/* @group Language Switcher */
.sidebar .menu-list.menu-list-bottom {
margin-bottom: 0;
position: fixed;
width: inherit;
bottom: 0;
left: 0;
right: 0;
border-top: 1px solid #23282e;
}
.sidebar .menu-list-bottom li span {
float: right;
margin-right: 20px;
color: #d19b3d;
}
/* @end Language Switcher */
/* @group Docs Content */
.docs-content .meta .label {
vertical-align: middle;
font-size: 14px;
font-weight: normal;
}
.docs-content .meta code {
vertical-align: middle;
padding: .2em .6em .3em;
font-size: 14px;
}
.docs-content .btn {
font-size: inherit;
}
.code-samples pre {
margin-top: 20px;
}
/* @end Docs Content */
@media (max-width: 767px) {
.main-container {
padding-left: 15px;
padding-right: 15px;
}
.sidebar {
position: relative;
width: 100%;
margin-bottom: 10px;
overflow: visible;
}
.sidebar .toggle-btn {
display: block;
cursor: pointer;
position: absolute;
right: 10px;
top: 10px;
z-index: 10 !important;
padding: 3px;
width: 40px;
text-align: center;
}
.sidebar .menu-list.menu-list-bottom {
position: static;
}
.sidebar .brand {
margin-top: 0;
margin-bottom: 0;
text-align: left !important;
font-size: 22px;
padding: 0;
padding-left: 20px;
line-height: 50px !important;
}
}
@media (min-width: 767px) {
.sidebar .menu-list .menu-content {
display: block;
}
#main {
width:calc(100% - 225px);
float: right;
}
}
@media (min-width: 992px) {
.modal-lg {
width: 980px;
}
}
.api-modal .modal-title .fa {
color: #93c54b;
}
.api-modal .modal-body .request-awaiting {
padding: 35px 10px;
color: #7F8177;
text-align: center;
}
.api-modal .modal-body .meta {
margin-bottom: 20px;
}
.api-modal .modal-body .meta .label {
vertical-align: middle;
font-size: 14px;
font-weight: normal;
}
.api-modal .modal-body .meta code {
vertical-align: middle;
padding: .2em .6em .3em;
font-size: 14px;
}
.api-modal .modal-content .toggle-view {
text-align: right;
float: right;
}
.api-modal .modal-content .response .well {
margin: 0;
max-height: 550px;
}
.highlight {
background-color: #f7f7f9
}
.checkbox label.control-label {
font-weight: bold
}
@media (min-width: 768px) {
.navbar-nav.navbar-right:last-child {
margin-right: 0 !important;
}
}

View file

@ -0,0 +1,125 @@
/*
This is the GitHub theme for highlight.js
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #333;
-webkit-text-size-adjust: none;
}
.hljs-comment,
.diff .hljs-header,
.hljs-javadoc {
color: #998;
font-style: italic;
}
.hljs-keyword,
.css .rule .hljs-keyword,
.hljs-winutils,
.nginx .hljs-title,
.hljs-subst,
.hljs-request,
.hljs-status {
color: #333;
font-weight: bold;
}
.hljs-number,
.hljs-hexcolor,
.ruby .hljs-constant {
color: #008080;
}
.hljs-string,
.hljs-tag .hljs-value,
.hljs-phpdoc,
.hljs-dartdoc,
.tex .hljs-formula {
color: #d14;
}
.hljs-title,
.hljs-id,
.scss .hljs-preprocessor {
color: #900;
font-weight: bold;
}
.hljs-list .hljs-keyword,
.hljs-subst {
font-weight: normal;
}
.hljs-class .hljs-title,
.hljs-type,
.vhdl .hljs-literal,
.tex .hljs-command {
color: #458;
font-weight: bold;
}
.hljs-tag,
.hljs-tag .hljs-title,
.hljs-rule .hljs-property,
.django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal;
}
.hljs-attribute,
.hljs-variable,
.lisp .hljs-body,
.hljs-name {
color: #008080;
}
.hljs-regexp {
color: #009926;
}
.hljs-symbol,
.ruby .hljs-symbol .hljs-string,
.lisp .hljs-keyword,
.clojure .hljs-keyword,
.scheme .hljs-keyword,
.tex .hljs-special,
.hljs-prompt {
color: #990073;
}
.hljs-built_in {
color: #0086b3;
}
.hljs-preprocessor,
.hljs-pragma,
.hljs-pi,
.hljs-doctype,
.hljs-shebang,
.hljs-cdata {
color: #999;
font-weight: bold;
}
.hljs-deletion {
background: #fdd;
}
.hljs-addition {
background: #dfd;
}
.diff .hljs-change {
background: #0086b3;
}
.hljs-chunk {
color: #aaa;
}

View file

@ -0,0 +1,125 @@
/*
This is the GitHub theme for highlight.js
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
*/
.hljs {
display: block;
overflow-x: auto;
padding: 0.5em;
color: #333;
-webkit-text-size-adjust: none;
}
.hljs-comment,
.diff .hljs-header,
.hljs-javadoc {
color: #998;
font-style: italic;
}
.hljs-keyword,
.css .rule .hljs-keyword,
.hljs-winutils,
.nginx .hljs-title,
.hljs-subst,
.hljs-request,
.hljs-status {
color: #333;
font-weight: bold;
}
.hljs-number,
.hljs-hexcolor,
.ruby .hljs-constant {
color: #008080;
}
.hljs-string,
.hljs-tag .hljs-value,
.hljs-phpdoc,
.hljs-dartdoc,
.tex .hljs-formula {
color: #d14;
}
.hljs-title,
.hljs-id,
.scss .hljs-preprocessor {
color: #900;
font-weight: bold;
}
.hljs-list .hljs-keyword,
.hljs-subst {
font-weight: normal;
}
.hljs-class .hljs-title,
.hljs-type,
.vhdl .hljs-literal,
.tex .hljs-command {
color: #458;
font-weight: bold;
}
.hljs-tag,
.hljs-tag .hljs-title,
.hljs-rule .hljs-property,
.django .hljs-tag .hljs-keyword {
color: #000080;
font-weight: normal;
}
.hljs-attribute,
.hljs-variable,
.lisp .hljs-body,
.hljs-name {
color: #008080;
}
.hljs-regexp {
color: #009926;
}
.hljs-symbol,
.ruby .hljs-symbol .hljs-string,
.lisp .hljs-keyword,
.clojure .hljs-keyword,
.scheme .hljs-keyword,
.tex .hljs-special,
.hljs-prompt {
color: #990073;
}
.hljs-built_in {
color: #0086b3;
}
.hljs-preprocessor,
.hljs-pragma,
.hljs-pi,
.hljs-doctype,
.hljs-shebang,
.hljs-cdata {
color: #999;
font-weight: bold;
}
.hljs-deletion {
background: #fdd;
}
.hljs-addition {
background: #dfd;
}
.diff .hljs-change {
background: #0086b3;
}
.hljs-chunk {
color: #aaa;
}

View file

@ -0,0 +1,11 @@
.json-view{position:relative}
.json-view .collapser{width:20px;height:18px;display:block;position:absolute;left:-1.7em;top:-.2em;z-index:5;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpiYGBgOADE%2F3Hgw0DM4IRHgSsDFOzFInmMAQnY49ONzZRjDFiADT7dMLALiE8y4AGW6LoBAgwAuIkf%2F%2FB7O9sAAAAASUVORK5CYII%3D);background-repeat:no-repeat;background-position:center center;opacity:.5;cursor:pointer}
.json-view .collapsed{-ms-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-khtml-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)}
.json-view .bl{display:block;padding-left:20px;margin-left:-20px;position:relative}
.json-view{font-family:monospace}
.json-view ul{list-style-type:none;padding-left:2em;border-left:1px dotted;margin:.3em}
.json-view ul li{position:relative}
.json-view .comments,.json-view .dots{display:none;-moz-user-select:none;-ms-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none}
.json-view .comments{padding-left:.8em;font-style:italic;color:#888}
.json-view .bool,.json-view .null,.json-view .num,.json-view .undef{font-weight:700;color:#1A01CC}
.json-view .str{color:#800}

View file

@ -0,0 +1,11 @@
.json-view{position:relative}
.json-view .collapser{width:20px;height:18px;display:block;position:absolute;left:-1.7em;top:-.2em;z-index:5;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpiYGBgOADE%2F3Hgw0DM4IRHgSsDFOzFInmMAQnY49ONzZRjDFiADT7dMLALiE8y4AGW6LoBAgwAuIkf%2F%2FB7O9sAAAAASUVORK5CYII%3D);background-repeat:no-repeat;background-position:center center;opacity:.5;cursor:pointer}
.json-view .collapsed{-ms-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-khtml-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)}
.json-view .bl{display:block;padding-left:20px;margin-left:-20px;position:relative}
.json-view{font-family:monospace}
.json-view ul{list-style-type:none;padding-left:2em;border-left:1px dotted;margin:.3em}
.json-view ul li{position:relative}
.json-view .comments,.json-view .dots{display:none;-moz-user-select:none;-ms-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none}
.json-view .comments{padding-left:.8em;font-style:italic;color:#888}
.json-view .bool,.json-view .null,.json-view .num,.json-view .undef{font-weight:700;color:#1A01CC}
.json-view .str{color:#800}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,315 @@
var responseDisplay = 'data'
var coreapi = window.coreapi
var schema = window.schema
function normalizeKeys (arr) {
var _normarr = [];
for (var i = 0; i < arr.length; i++) {
_normarr = _normarr.concat(arr[i].split(' > '));
}
return _normarr;
}
function normalizeHTTPHeader (str) {
// Capitalize HTTP headers for display.
return (str.charAt(0).toUpperCase() + str.substring(1))
.replace(/-(.)/g, function ($1) {
return $1.toUpperCase()
})
.replace(/(Www)/g, function ($1) {
return 'WWW'
})
.replace(/(Xss)/g, function ($1) {
return 'XSS'
})
.replace(/(Md5)/g, function ($1) {
return 'MD5'
})
}
function formEntries (form) {
// Polyfill for new FormData(form).entries()
var formData = new FormData(form)
if (formData.entries !== undefined) {
return Array.from(formData.entries())
}
var entries = []
for (var i = 0; i < form.elements.length; i++) {
var element = form.elements[i]
if (!element.name) {
continue
}
if (element.type === 'file') {
for (var j = 0; j < element.files.length; j++) {
entries.push([element.name, element.files[j]])
}
} else if (element.type === 'select-multiple' || element.type === 'select-one') {
for (var j = 0; j < element.selectedOptions.length; j++) {
entries.push([element.name, element.selectedOptions[j].value])
}
} else if (element.type === 'checkbox') {
if (element.checked) {
entries.push([element.name, element.value])
}
} else {
entries.push([element.name, element.value])
}
}
return entries
}
$(function () {
var $selectedAuthentication = $('#selected-authentication')
var $authControl = $('#auth-control')
var $authTokenModal = $('#auth_token_modal')
var $authBasicModal = $('#auth_basic_modal')
var $authSessionModal = $('#auth_session_modal')
// Language Control
$('#language-control li').click(function (event) {
event.preventDefault()
var $languageMenuItem = $(this).find('a')
var $languageControls = $(this).closest('ul').find('li')
var $languageControlLinks = $languageControls.find('a')
var language = $languageMenuItem.data('language')
$languageControlLinks.not('[data-language="' + language + '"]').parent().removeClass('active')
$languageControlLinks.filter('[data-language="' + language + '"]').parent().addClass('active')
$('#selected-language').text(language)
var $codeBlocks = $('pre.highlight')
$codeBlocks.not('[data-language="' + language + '"]').addClass('hide')
$codeBlocks.filter('[data-language="' + language + '"]').removeClass('hide')
})
// API Explorer
$('form.api-interaction').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var $requestMethod = $form.find('.request-method')
var $requestUrl = $form.find('.request-url')
var $toggleView = $form.closest('.modal-content').find('.toggle-view')
var $responseStatusCode = $form.find('.response-status-code')
var $meta = $form.find('.meta')
var $responseRawResponse = $form.find('.response-raw-response')
var $requestAwaiting = $form.find('.request-awaiting')
var $responseRaw = $form.find('.response-raw')
var $responseData = $form.find('.response-data')
var key = normalizeKeys($form.data('key'))
var params = {}
var entries = formEntries($form.get()[0])
for (var i = 0; i < entries.length; i++) {
var entry = entries[i]
var paramKey = entry[0]
var paramValue = entry[1]
var $elem = $form.find('[name="' + paramKey + '"]')
var dataType = $elem.data('type') || 'string'
if (dataType === 'integer' && paramValue) {
var value = parseInt(paramValue)
if (!isNaN(value)) {
params[paramKey] = value
}
} else if (dataType === 'number' && paramValue) {
var value = parseFloat(paramValue)
if (!isNaN(value)) {
params[paramKey] = value
}
} else if (dataType === 'boolean' && paramValue) {
var value = {
'true': true,
'false': false
}[paramValue.toLowerCase()]
if (value !== undefined) {
params[paramKey] = value
}
} else if ((dataType === 'array' && paramValue) || (dataType === 'object' && paramValue)) {
try {
params[paramKey] = JSON.parse(paramValue)
} catch (err) {
// Ignore malformed JSON
}
} else if (dataType === 'string' && paramValue) {
params[paramKey] = paramValue
}
}
$form.find(':checkbox').each(function (index) {
// Handle unselected checkboxes
var name = $(this).attr('name')
if (!params.hasOwnProperty(name)) {
params[name] = false
}
})
function requestCallback (request) {
// Fill in the "GET /foo/" display.
var parser = document.createElement('a')
parser.href = request.url
var method = request.options.method
var path = parser.pathname + parser.hash + parser.search
$requestMethod.text(method)
$requestUrl.text(path)
}
function responseCallback (response, responseText) {
// Display the 'Data'/'Raw' control.
$toggleView.removeClass('hide')
// Fill in the "200 OK" display.
$responseStatusCode.removeClass('label-success').removeClass('label-danger')
if (response.ok) {
$responseStatusCode.addClass('label-success')
} else {
$responseStatusCode.addClass('label-danger')
}
$responseStatusCode.text(response.status)
$meta.removeClass('hide')
// Fill in the Raw HTTP response display.
var panelText = 'HTTP/1.1 ' + response.status + ' ' + response.statusText + '\n'
response.headers.forEach(function (header, key) {
panelText += normalizeHTTPHeader(key) + ': ' + header + '\n'
})
if (responseText) {
panelText += '\n' + responseText
}
$responseRawResponse.text(panelText)
}
// Instantiate a client to make the outgoing request.
var options = {
requestCallback: requestCallback,
responseCallback: responseCallback
}
// Setup authentication options.
if (window.auth && window.auth.type === 'token') {
// Header authentication
options.auth = new coreapi.auth.TokenAuthentication({
scheme: window.auth.scheme,
token: window.auth.token
})
} else if (window.auth && window.auth.type === 'basic') {
// Basic authentication
options.auth = new coreapi.auth.BasicAuthentication({
username: window.auth.username,
password: window.auth.password
})
} else if (window.auth && window.auth.type === 'session') {
// Session authentication
options.auth = new coreapi.auth.SessionAuthentication({
csrfCookieName: 'csrftoken',
csrfHeaderName: 'X-CSRFToken'
})
}
var client = new coreapi.Client(options)
client.action(schema, key, params).then(function (data) {
var response = JSON.stringify(data, null, 2)
$requestAwaiting.addClass('hide')
$responseRaw.addClass('hide')
$responseData.addClass('hide').text('').jsonView(response)
if (responseDisplay === 'data') {
$responseData.removeClass('hide')
} else {
$responseRaw.removeClass('hide')
}
}).catch(function (error) {
var response = JSON.stringify(error.content, null, 2)
$requestAwaiting.addClass('hide')
$responseRaw.addClass('hide')
$responseData.addClass('hide').text('').jsonView(response)
if (responseDisplay === 'data') {
$responseData.removeClass('hide')
} else {
$responseRaw.removeClass('hide')
}
})
})
// 'Data'/'Raw' control
$('.toggle-view button').click(function () {
var $modalContent = $(this).closest('.modal-content')
var $modalResponseRaw = $modalContent.find('.response-raw')
var $modalResponseData = $modalContent.find('.response-data')
responseDisplay = $(this).data('display-toggle')
$(this).removeClass('btn-default').addClass('btn-info').siblings().removeClass('btn-info')
if (responseDisplay === 'raw') {
$modalResponseRaw.removeClass('hide')
$modalResponseData.addClass('hide')
} else {
$modalResponseData.removeClass('hide')
$modalResponseRaw.addClass('hide')
}
})
// Authentication: none
$authControl.find("[data-auth='none']").click(function (event) {
event.preventDefault()
window.auth = null
$selectedAuthentication.text('none')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='none']").closest('li').addClass('active')
})
// Authentication: token
$('form.authentication-token-form').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var scheme = $form.find('input#scheme').val()
var token = $form.find('input#token').val()
window.auth = {
'type': 'token',
'scheme': scheme,
'token': token
}
$selectedAuthentication.text('token')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='token']").closest('li').addClass('active')
$authTokenModal.modal('hide')
})
// Authentication: basic
$('form.authentication-basic-form').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var username = $form.find('input#username').val()
var password = $form.find('input#password').val()
window.auth = {
'type': 'basic',
'username': username,
'password': password
}
$selectedAuthentication.text('basic')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='basic']").closest('li').addClass('active')
$authBasicModal.modal('hide')
})
// Authentication: session
$('form.authentication-session-form').submit(function (event) {
event.preventDefault()
window.auth = {
'type': 'session'
}
$selectedAuthentication.text('session')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='session']").closest('li').addClass('active')
$authSessionModal.modal('hide')
})
})

View file

@ -0,0 +1,315 @@
var responseDisplay = 'data'
var coreapi = window.coreapi
var schema = window.schema
function normalizeKeys (arr) {
var _normarr = [];
for (var i = 0; i < arr.length; i++) {
_normarr = _normarr.concat(arr[i].split(' > '));
}
return _normarr;
}
function normalizeHTTPHeader (str) {
// Capitalize HTTP headers for display.
return (str.charAt(0).toUpperCase() + str.substring(1))
.replace(/-(.)/g, function ($1) {
return $1.toUpperCase()
})
.replace(/(Www)/g, function ($1) {
return 'WWW'
})
.replace(/(Xss)/g, function ($1) {
return 'XSS'
})
.replace(/(Md5)/g, function ($1) {
return 'MD5'
})
}
function formEntries (form) {
// Polyfill for new FormData(form).entries()
var formData = new FormData(form)
if (formData.entries !== undefined) {
return Array.from(formData.entries())
}
var entries = []
for (var i = 0; i < form.elements.length; i++) {
var element = form.elements[i]
if (!element.name) {
continue
}
if (element.type === 'file') {
for (var j = 0; j < element.files.length; j++) {
entries.push([element.name, element.files[j]])
}
} else if (element.type === 'select-multiple' || element.type === 'select-one') {
for (var j = 0; j < element.selectedOptions.length; j++) {
entries.push([element.name, element.selectedOptions[j].value])
}
} else if (element.type === 'checkbox') {
if (element.checked) {
entries.push([element.name, element.value])
}
} else {
entries.push([element.name, element.value])
}
}
return entries
}
$(function () {
var $selectedAuthentication = $('#selected-authentication')
var $authControl = $('#auth-control')
var $authTokenModal = $('#auth_token_modal')
var $authBasicModal = $('#auth_basic_modal')
var $authSessionModal = $('#auth_session_modal')
// Language Control
$('#language-control li').click(function (event) {
event.preventDefault()
var $languageMenuItem = $(this).find('a')
var $languageControls = $(this).closest('ul').find('li')
var $languageControlLinks = $languageControls.find('a')
var language = $languageMenuItem.data('language')
$languageControlLinks.not('[data-language="' + language + '"]').parent().removeClass('active')
$languageControlLinks.filter('[data-language="' + language + '"]').parent().addClass('active')
$('#selected-language').text(language)
var $codeBlocks = $('pre.highlight')
$codeBlocks.not('[data-language="' + language + '"]').addClass('hide')
$codeBlocks.filter('[data-language="' + language + '"]').removeClass('hide')
})
// API Explorer
$('form.api-interaction').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var $requestMethod = $form.find('.request-method')
var $requestUrl = $form.find('.request-url')
var $toggleView = $form.closest('.modal-content').find('.toggle-view')
var $responseStatusCode = $form.find('.response-status-code')
var $meta = $form.find('.meta')
var $responseRawResponse = $form.find('.response-raw-response')
var $requestAwaiting = $form.find('.request-awaiting')
var $responseRaw = $form.find('.response-raw')
var $responseData = $form.find('.response-data')
var key = normalizeKeys($form.data('key'))
var params = {}
var entries = formEntries($form.get()[0])
for (var i = 0; i < entries.length; i++) {
var entry = entries[i]
var paramKey = entry[0]
var paramValue = entry[1]
var $elem = $form.find('[name="' + paramKey + '"]')
var dataType = $elem.data('type') || 'string'
if (dataType === 'integer' && paramValue) {
var value = parseInt(paramValue)
if (!isNaN(value)) {
params[paramKey] = value
}
} else if (dataType === 'number' && paramValue) {
var value = parseFloat(paramValue)
if (!isNaN(value)) {
params[paramKey] = value
}
} else if (dataType === 'boolean' && paramValue) {
var value = {
'true': true,
'false': false
}[paramValue.toLowerCase()]
if (value !== undefined) {
params[paramKey] = value
}
} else if ((dataType === 'array' && paramValue) || (dataType === 'object' && paramValue)) {
try {
params[paramKey] = JSON.parse(paramValue)
} catch (err) {
// Ignore malformed JSON
}
} else if (dataType === 'string' && paramValue) {
params[paramKey] = paramValue
}
}
$form.find(':checkbox').each(function (index) {
// Handle unselected checkboxes
var name = $(this).attr('name')
if (!params.hasOwnProperty(name)) {
params[name] = false
}
})
function requestCallback (request) {
// Fill in the "GET /foo/" display.
var parser = document.createElement('a')
parser.href = request.url
var method = request.options.method
var path = parser.pathname + parser.hash + parser.search
$requestMethod.text(method)
$requestUrl.text(path)
}
function responseCallback (response, responseText) {
// Display the 'Data'/'Raw' control.
$toggleView.removeClass('hide')
// Fill in the "200 OK" display.
$responseStatusCode.removeClass('label-success').removeClass('label-danger')
if (response.ok) {
$responseStatusCode.addClass('label-success')
} else {
$responseStatusCode.addClass('label-danger')
}
$responseStatusCode.text(response.status)
$meta.removeClass('hide')
// Fill in the Raw HTTP response display.
var panelText = 'HTTP/1.1 ' + response.status + ' ' + response.statusText + '\n'
response.headers.forEach(function (header, key) {
panelText += normalizeHTTPHeader(key) + ': ' + header + '\n'
})
if (responseText) {
panelText += '\n' + responseText
}
$responseRawResponse.text(panelText)
}
// Instantiate a client to make the outgoing request.
var options = {
requestCallback: requestCallback,
responseCallback: responseCallback
}
// Setup authentication options.
if (window.auth && window.auth.type === 'token') {
// Header authentication
options.auth = new coreapi.auth.TokenAuthentication({
scheme: window.auth.scheme,
token: window.auth.token
})
} else if (window.auth && window.auth.type === 'basic') {
// Basic authentication
options.auth = new coreapi.auth.BasicAuthentication({
username: window.auth.username,
password: window.auth.password
})
} else if (window.auth && window.auth.type === 'session') {
// Session authentication
options.auth = new coreapi.auth.SessionAuthentication({
csrfCookieName: 'csrftoken',
csrfHeaderName: 'X-CSRFToken'
})
}
var client = new coreapi.Client(options)
client.action(schema, key, params).then(function (data) {
var response = JSON.stringify(data, null, 2)
$requestAwaiting.addClass('hide')
$responseRaw.addClass('hide')
$responseData.addClass('hide').text('').jsonView(response)
if (responseDisplay === 'data') {
$responseData.removeClass('hide')
} else {
$responseRaw.removeClass('hide')
}
}).catch(function (error) {
var response = JSON.stringify(error.content, null, 2)
$requestAwaiting.addClass('hide')
$responseRaw.addClass('hide')
$responseData.addClass('hide').text('').jsonView(response)
if (responseDisplay === 'data') {
$responseData.removeClass('hide')
} else {
$responseRaw.removeClass('hide')
}
})
})
// 'Data'/'Raw' control
$('.toggle-view button').click(function () {
var $modalContent = $(this).closest('.modal-content')
var $modalResponseRaw = $modalContent.find('.response-raw')
var $modalResponseData = $modalContent.find('.response-data')
responseDisplay = $(this).data('display-toggle')
$(this).removeClass('btn-default').addClass('btn-info').siblings().removeClass('btn-info')
if (responseDisplay === 'raw') {
$modalResponseRaw.removeClass('hide')
$modalResponseData.addClass('hide')
} else {
$modalResponseData.removeClass('hide')
$modalResponseRaw.addClass('hide')
}
})
// Authentication: none
$authControl.find("[data-auth='none']").click(function (event) {
event.preventDefault()
window.auth = null
$selectedAuthentication.text('none')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='none']").closest('li').addClass('active')
})
// Authentication: token
$('form.authentication-token-form').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var scheme = $form.find('input#scheme').val()
var token = $form.find('input#token').val()
window.auth = {
'type': 'token',
'scheme': scheme,
'token': token
}
$selectedAuthentication.text('token')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='token']").closest('li').addClass('active')
$authTokenModal.modal('hide')
})
// Authentication: basic
$('form.authentication-basic-form').submit(function (event) {
event.preventDefault()
var $form = $(this).closest('form')
var username = $form.find('input#username').val()
var password = $form.find('input#password').val()
window.auth = {
'type': 'basic',
'username': username,
'password': password
}
$selectedAuthentication.text('basic')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='basic']").closest('li').addClass('active')
$authBasicModal.modal('hide')
})
// Authentication: session
$('form.authentication-session-form').submit(function (event) {
event.preventDefault()
window.auth = {
'type': 'session'
}
$selectedAuthentication.text('session')
$authControl.find("[data-auth]").closest('li').removeClass('active')
$authControl.find("[data-auth='session']").closest('li').addClass('active')
$authSessionModal.modal('hide')
})
})

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
/**
* jquery.json-view - jQuery collapsible JSON plugin
* @version v1.0.0
* @link http://github.com/bazh/jquery.json-view
* @license MIT
*/
!function(e){"use strict";var n=function(n){var a=e("<span />",{"class":"collapser",on:{click:function(){var n=e(this);n.toggleClass("collapsed");var a=n.parent().children(".block"),p=a.children("ul");n.hasClass("collapsed")?(p.hide(),a.children(".dots, .comments").show()):(p.show(),a.children(".dots, .comments").hide())}}});return n&&a.addClass("collapsed"),a},a=function(a,p){var t=e.extend({},{nl2br:!0},p),r=function(e){return e.toString()?e.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""},s=function(n,a){return e("<span />",{"class":a,html:r(n)})},l=function(a,p){switch(e.type(a)){case"object":p||(p=0);var c=e("<span />",{"class":"block"}),d=Object.keys(a).length;if(!d)return c.append(s("{","b")).append(" ").append(s("}","b"));c.append(s("{","b"));var i=e("<ul />",{"class":"obj collapsible level"+p});return e.each(a,function(a,t){d--;var r=e("<li />").append(s('"',"q")).append(a).append(s('"',"q")).append(": ").append(l(t,p+1));-1===["object","array"].indexOf(e.type(t))||e.isEmptyObject(t)||r.prepend(n()),d>0&&r.append(","),i.append(r)}),c.append(i),c.append(s("...","dots")),c.append(s("}","b")),c.append(1===Object.keys(a).length?s("// 1 item","comments"):s("// "+Object.keys(a).length+" items","comments")),c;case"array":p||(p=0);var d=a.length,c=e("<span />",{"class":"block"});if(!d)return c.append(s("[","b")).append(" ").append(s("]","b"));c.append(s("[","b"));var i=e("<ul />",{"class":"obj collapsible level"+p});return e.each(a,function(a,t){d--;var r=e("<li />").append(l(t,p+1));-1===["object","array"].indexOf(e.type(t))||e.isEmptyObject(t)||r.prepend(n()),d>0&&r.append(","),i.append(r)}),c.append(i),c.append(s("...","dots")),c.append(s("]","b")),c.append(1===a.length?s("// 1 item","comments"):s("// "+a.length+" items","comments")),c;case"string":if(a=r(a),/^(http|https|file):\/\/[^\s]+$/i.test(a))return e("<span />").append(s('"',"q")).append(e("<a />",{href:a,text:a})).append(s('"',"q"));if(t.nl2br){var o=/\n/g;o.test(a)&&(a=(a+"").replace(o,"<br />"))}var u=e("<span />",{"class":"str"}).html(a);return e("<span />").append(s('"',"q")).append(u).append(s('"',"q"));case"number":return s(a.toString(),"num");case"undefined":return s("undefined","undef");case"null":return s("null","null");case"boolean":return s(a?"true":"false","bool")}};return l(a)};return e.fn.jsonView=function(n,p){var t=e(this);if(p=e.extend({},{nl2br:!0},p),"string"==typeof n)try{n=JSON.parse(n)}catch(r){}return t.append(e("<div />",{"class":"json-view"}).append(a(n,p))),t}}(jQuery);

View file

@ -0,0 +1,7 @@
/**
* jquery.json-view - jQuery collapsible JSON plugin
* @version v1.0.0
* @link http://github.com/bazh/jquery.json-view
* @license MIT
*/
!function(e){"use strict";var n=function(n){var a=e("<span />",{"class":"collapser",on:{click:function(){var n=e(this);n.toggleClass("collapsed");var a=n.parent().children(".block"),p=a.children("ul");n.hasClass("collapsed")?(p.hide(),a.children(".dots, .comments").show()):(p.show(),a.children(".dots, .comments").hide())}}});return n&&a.addClass("collapsed"),a},a=function(a,p){var t=e.extend({},{nl2br:!0},p),r=function(e){return e.toString()?e.toString().replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;"):""},s=function(n,a){return e("<span />",{"class":a,html:r(n)})},l=function(a,p){switch(e.type(a)){case"object":p||(p=0);var c=e("<span />",{"class":"block"}),d=Object.keys(a).length;if(!d)return c.append(s("{","b")).append(" ").append(s("}","b"));c.append(s("{","b"));var i=e("<ul />",{"class":"obj collapsible level"+p});return e.each(a,function(a,t){d--;var r=e("<li />").append(s('"',"q")).append(a).append(s('"',"q")).append(": ").append(l(t,p+1));-1===["object","array"].indexOf(e.type(t))||e.isEmptyObject(t)||r.prepend(n()),d>0&&r.append(","),i.append(r)}),c.append(i),c.append(s("...","dots")),c.append(s("}","b")),c.append(1===Object.keys(a).length?s("// 1 item","comments"):s("// "+Object.keys(a).length+" items","comments")),c;case"array":p||(p=0);var d=a.length,c=e("<span />",{"class":"block"});if(!d)return c.append(s("[","b")).append(" ").append(s("]","b"));c.append(s("[","b"));var i=e("<ul />",{"class":"obj collapsible level"+p});return e.each(a,function(a,t){d--;var r=e("<li />").append(l(t,p+1));-1===["object","array"].indexOf(e.type(t))||e.isEmptyObject(t)||r.prepend(n()),d>0&&r.append(","),i.append(r)}),c.append(i),c.append(s("...","dots")),c.append(s("]","b")),c.append(1===a.length?s("// 1 item","comments"):s("// "+a.length+" items","comments")),c;case"string":if(a=r(a),/^(http|https|file):\/\/[^\s]+$/i.test(a))return e("<span />").append(s('"',"q")).append(e("<a />",{href:a,text:a})).append(s('"',"q"));if(t.nl2br){var o=/\n/g;o.test(a)&&(a=(a+"").replace(o,"<br />"))}var u=e("<span />",{"class":"str"}).html(a);return e("<span />").append(s('"',"q")).append(u).append(s('"',"q"));case"number":return s(a.toString(),"num");case"undefined":return s("undefined","undef");case"null":return s("null","null");case"boolean":return s(a?"true":"false","bool")}};return l(a)};return e.fn.jsonView=function(n,p){var t=e(this);if(p=e.extend({},{nl2br:!0},p),"string"==typeof n)try{n=JSON.parse(n)}catch(r){}return t.append(e("<div />",{"class":"json-view"}).append(a(n,p))),t}}(jQuery);