first commit
This commit is contained in:
@@ -0,0 +1,185 @@
|
||||
@php
|
||||
use Knuckles\Scribe\Tools\Utils as u;
|
||||
/** @var Knuckles\Camel\Output\OutputEndpointData $endpoint */
|
||||
@endphp
|
||||
|
||||
<h2 id="{!! $endpoint->fullSlug() !!}">{{ $endpoint->name() }}</h2>
|
||||
|
||||
<p>
|
||||
@component('scribe::components.badges.auth', ['authenticated' => $endpoint->isAuthed()])
|
||||
@endcomponent
|
||||
</p>
|
||||
|
||||
{!! Parsedown::instance()->text($endpoint->metadata->description ?: '') !!}
|
||||
|
||||
<span id="example-requests-{!! $endpoint->endpointId() !!}">
|
||||
<blockquote>{{ u::trans("scribe::endpoint.example_request") }}:</blockquote>
|
||||
|
||||
@foreach($metadata['example_languages'] as $language)
|
||||
|
||||
<div class="{{ $language }}-example">
|
||||
@include("scribe::partials.example-requests.$language")
|
||||
</div>
|
||||
|
||||
@endforeach
|
||||
</span>
|
||||
|
||||
<span id="example-responses-{!! $endpoint->endpointId() !!}">
|
||||
@if($endpoint->isGet() || $endpoint->hasResponses())
|
||||
@foreach($endpoint->responses as $response)
|
||||
<blockquote>
|
||||
<p>{{ u::trans("scribe::endpoint.example_response") }} ({{ $response->fullDescription() }}):</p>
|
||||
</blockquote>
|
||||
@if(count($response->headers))
|
||||
<details class="annotation">
|
||||
<summary style="cursor: pointer;">
|
||||
<small onclick="textContent = parentElement.parentElement.open ? 'Show headers' : 'Hide headers'">Show headers</small>
|
||||
</summary>
|
||||
<pre><code class="language-http">@foreach($response->headers as $header => $value)
|
||||
{{ $header }}: {{ is_array($value) ? implode('; ', $value) : $value }}
|
||||
@endforeach </code></pre></details> @endif
|
||||
<pre>
|
||||
@if(is_string($response->content) && Str::startsWith($response->content, "<<binary>>"))
|
||||
<code>{!! u::trans("scribe::endpoint.responses.binary") !!} - {{ htmlentities(str_replace("<<binary>>", "", $response->content)) }}</code>
|
||||
@elseif($response->status == 204)
|
||||
<code>{!! u::trans("scribe::endpoint.responses.empty") !!}</code>
|
||||
@else
|
||||
@php($parsed = json_decode($response->content))
|
||||
{{-- If response is a JSON string, prettify it. Otherwise, just print it --}}
|
||||
<code class="language-json" style="max-height: 300px;">{!! htmlentities($parsed != null ? json_encode($parsed, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES) : $response->content) !!}</code>
|
||||
@endif </pre>
|
||||
@endforeach
|
||||
@endif
|
||||
</span>
|
||||
<span id="execution-results-{{ $endpoint->endpointId() }}" hidden>
|
||||
<blockquote>{{ u::trans("scribe::try_it_out.received_response") }}<span
|
||||
id="execution-response-status-{{ $endpoint->endpointId() }}"></span>:
|
||||
</blockquote>
|
||||
<pre class="json"><code id="execution-response-content-{{ $endpoint->endpointId() }}"
|
||||
data-empty-response-text="<{{ u::trans("scribe::endpoint.responses.empty") }}>" style="max-height: 400px;"></code></pre>
|
||||
</span>
|
||||
<span id="execution-error-{{ $endpoint->endpointId() }}" hidden>
|
||||
<blockquote>{{ u::trans("scribe::try_it_out.request_failed") }}:</blockquote>
|
||||
<pre><code id="execution-error-message-{{ $endpoint->endpointId() }}">{{ "\n\n".u::trans("scribe::try_it_out.error_help") }}</code></pre>
|
||||
</span>
|
||||
<form id="form-{{ $endpoint->endpointId() }}" data-method="{{ $endpoint->httpMethods[0] }}"
|
||||
data-path="{{ $endpoint->uri }}"
|
||||
data-authed="{{ $endpoint->isAuthed() ? 1 : 0 }}"
|
||||
data-hasfiles="{{ $endpoint->hasFiles() ? 1 : 0 }}"
|
||||
data-isarraybody="{{ $endpoint->isArrayBody() ? 1 : 0 }}"
|
||||
autocomplete="off"
|
||||
onsubmit="event.preventDefault(); executeTryOut('{{ $endpoint->endpointId() }}', this);">
|
||||
<h3>
|
||||
{{ u::trans("scribe::endpoint.request") }}
|
||||
@if($metadata['try_it_out']['enabled'] ?? false)
|
||||
<button type="button"
|
||||
style="background-color: #8fbcd4; padding: 5px 10px; border-radius: 5px; border-width: thin;"
|
||||
id="btn-tryout-{{ $endpoint->endpointId() }}"
|
||||
onclick="tryItOut('{{ $endpoint->endpointId() }}');">{{ u::trans("scribe::try_it_out.open") }}
|
||||
</button>
|
||||
<button type="button"
|
||||
style="background-color: #c97a7e; padding: 5px 10px; border-radius: 5px; border-width: thin;"
|
||||
id="btn-canceltryout-{{ $endpoint->endpointId() }}"
|
||||
onclick="cancelTryOut('{{ $endpoint->endpointId() }}');" hidden>{{ u::trans("scribe::try_it_out.cancel") }}
|
||||
</button>
|
||||
<button type="submit"
|
||||
style="background-color: #6ac174; padding: 5px 10px; border-radius: 5px; border-width: thin;"
|
||||
id="btn-executetryout-{{ $endpoint->endpointId() }}"
|
||||
data-initial-text="{{ u::trans("scribe::try_it_out.send") }}"
|
||||
data-loading-text="{{ u::trans("scribe::try_it_out.loading") }}"
|
||||
hidden>{{ u::trans("scribe::try_it_out.send") }}
|
||||
</button>
|
||||
@endif
|
||||
</h3>
|
||||
@foreach($endpoint->httpMethods as $method)
|
||||
<p>
|
||||
@component('scribe::components.badges.http-method', ['method' => $method])@endcomponent
|
||||
<b><code>{{$endpoint->uri}}</code></b>
|
||||
</p>
|
||||
@endforeach
|
||||
@if(count($endpoint->headers))
|
||||
<h4 class="fancy-heading-panel"><b>{{ u::trans("scribe::endpoint.headers") }}</b></h4>
|
||||
@foreach($endpoint->headers as $name => $example)
|
||||
<?php
|
||||
$htmlOptions = [];
|
||||
if ($endpoint->isAuthed() && $metadata['auth']['location'] == 'header' && $metadata['auth']['name'] == $name) {
|
||||
$htmlOptions = [ 'class' => 'auth-value', ];
|
||||
}
|
||||
?>
|
||||
<div style="padding-left: 28px; clear: unset;">
|
||||
@component('scribe::components.field-details', [
|
||||
'name' => $name,
|
||||
'type' => null,
|
||||
'required' => true,
|
||||
'description' => null,
|
||||
'example' => $example,
|
||||
'endpointId' => $endpoint->endpointId(),
|
||||
'component' => 'header',
|
||||
'isInput' => true,
|
||||
'html' => $htmlOptions,
|
||||
])
|
||||
@endcomponent
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@if(count($endpoint->urlParameters))
|
||||
<h4 class="fancy-heading-panel"><b>{{ u::trans("scribe::endpoint.url_parameters") }}</b></h4>
|
||||
@foreach($endpoint->urlParameters as $attribute => $parameter)
|
||||
<div style="padding-left: 28px; clear: unset;">
|
||||
@component('scribe::components.field-details', [
|
||||
'name' => $parameter->name,
|
||||
'type' => $parameter->type ?? 'string',
|
||||
'required' => $parameter->required,
|
||||
'description' => $parameter->description,
|
||||
'example' => $parameter->example ?? '',
|
||||
'enumValues' => $parameter->enumValues,
|
||||
'endpointId' => $endpoint->endpointId(),
|
||||
'component' => 'url',
|
||||
'isInput' => true,
|
||||
])
|
||||
@endcomponent
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@if(count($endpoint->queryParameters))
|
||||
<h4 class="fancy-heading-panel"><b>{{ u::trans("scribe::endpoint.query_parameters") }}</b></h4>
|
||||
@foreach($endpoint->queryParameters as $attribute => $parameter)
|
||||
<?php
|
||||
$htmlOptions = [];
|
||||
if ($endpoint->isAuthed() && $metadata['auth']['location'] == 'query' && $metadata['auth']['name'] == $attribute) {
|
||||
$htmlOptions = [ 'class' => 'auth-value', ];
|
||||
}
|
||||
?>
|
||||
<div style="padding-left: 28px; clear: unset;">
|
||||
@component('scribe::components.field-details', [
|
||||
'name' => $parameter->name,
|
||||
'type' => $parameter->type,
|
||||
'required' => $parameter->required,
|
||||
'description' => $parameter->description,
|
||||
'example' => $parameter->example ?? '',
|
||||
'enumValues' => $parameter->enumValues,
|
||||
'endpointId' => $endpoint->endpointId(),
|
||||
'component' => 'query',
|
||||
'isInput' => true,
|
||||
'html' => $htmlOptions,
|
||||
])
|
||||
@endcomponent
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@if(count($endpoint->nestedBodyParameters))
|
||||
<h4 class="fancy-heading-panel"><b>{{ u::trans("scribe::endpoint.body_parameters") }}</b></h4>
|
||||
<x-scribe::nested-fields
|
||||
:fields="$endpoint->nestedBodyParameters" :endpointId="$endpoint->endpointId()"
|
||||
/>
|
||||
@endif
|
||||
</form>
|
||||
|
||||
@if(count($endpoint->responseFields))
|
||||
<h3>{{ u::trans("scribe::endpoint.response") }}</h3>
|
||||
<h4 class="fancy-heading-panel"><b>{{ u::trans("scribe::endpoint.response_fields") }}</b></h4>
|
||||
<x-scribe::nested-fields
|
||||
:fields="$endpoint->nestedResponseFields" :endpointId="$endpoint->endpointId()"
|
||||
:isInput="false"
|
||||
/>
|
||||
@endif
|
||||
@@ -0,0 +1,21 @@
|
||||
@foreach($groupedEndpoints as $group)
|
||||
<h1 id="{!! Str::slug($group['name']) !!}">{!! $group['name'] !!}</h1>
|
||||
|
||||
{!! Parsedown::instance()->text($group['description']) !!}
|
||||
|
||||
@foreach($group['subgroups'] as $subgroupName => $subgroup)
|
||||
@if($subgroupName !== "")
|
||||
<h2 id="{!! Str::slug($group['name']) !!}-{!! Str::slug($subgroupName) !!}">{{ $subgroupName }}</h2>
|
||||
@php($subgroupDescription = collect($subgroup)->first(fn ($e) => $e->metadata->subgroupDescription)?->metadata?->subgroupDescription)
|
||||
@if($subgroupDescription)
|
||||
<p>
|
||||
{!! Parsedown::instance()->text($subgroupDescription) !!}
|
||||
</p>
|
||||
@endif
|
||||
@endif
|
||||
@foreach($subgroup as $endpoint)
|
||||
@include("scribe::themes.default.endpoint")
|
||||
@endforeach
|
||||
@endforeach
|
||||
@endforeach
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
@php
|
||||
use Knuckles\Scribe\Tools\WritingUtils as u;
|
||||
@endphp
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>{!! $metadata['title'] !!}</title>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Open+Sans&display=swap" rel="stylesheet">
|
||||
|
||||
<link rel="stylesheet" href="{!! $assetPathPrefix !!}css/theme-default.style.css" media="screen">
|
||||
<link rel="stylesheet" href="{!! $assetPathPrefix !!}css/theme-default.print.css" media="print">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/lodash@4.17.10/lodash.min.js"></script>
|
||||
|
||||
<link rel="stylesheet"
|
||||
href="https://unpkg.com/@highlightjs/cdn-assets@11.6.0/styles/obsidian.min.css">
|
||||
<script src="https://unpkg.com/@highlightjs/cdn-assets@11.6.0/highlight.min.js"></script>
|
||||
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jets/0.14.1/jets.min.js"></script>
|
||||
|
||||
@if(isset($metadata['example_languages']))
|
||||
<style id="language-style">
|
||||
/* starts out as display none and is replaced with js later */
|
||||
@foreach($metadata['example_languages'] as $lang)
|
||||
body .content .{{ $lang }}-example code { display: none; }
|
||||
@endforeach
|
||||
</style>
|
||||
@endif
|
||||
|
||||
@if($tryItOut['enabled'] ?? true)
|
||||
<script>
|
||||
var tryItOutBaseUrl = "{!! $tryItOut['base_url'] ?? config('app.url') !!}";
|
||||
var useCsrf = Boolean({!! $tryItOut['use_csrf'] ?? null !!});
|
||||
var csrfUrl = "{!! $tryItOut['csrf_url'] ?? null !!}";
|
||||
</script>
|
||||
<script src="{{ u::getVersionedAsset($assetPathPrefix.'js/tryitout.js') }}"></script>
|
||||
@endif
|
||||
|
||||
<script src="{{ u::getVersionedAsset($assetPathPrefix.'js/theme-default.js') }}"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body data-languages="{{ json_encode($metadata['example_languages'] ?? []) }}">
|
||||
|
||||
@include("scribe::themes.default.sidebar")
|
||||
|
||||
<div class="page-wrapper">
|
||||
<div class="dark-box"></div>
|
||||
<div class="content">
|
||||
{!! $intro !!}
|
||||
|
||||
{!! $auth !!}
|
||||
|
||||
@include("scribe::themes.default.groups")
|
||||
|
||||
{!! $append !!}
|
||||
</div>
|
||||
<div class="dark-box">
|
||||
@if(isset($metadata['example_languages']))
|
||||
<div class="lang-selector">
|
||||
@foreach($metadata['example_languages'] as $name => $lang)
|
||||
@php if (is_numeric($name)) $name = $lang; @endphp
|
||||
<button type="button" class="lang-button" data-language-name="{{$lang}}">{{$name}}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,69 @@
|
||||
@php
|
||||
use Knuckles\Scribe\Tools\Utils as u;
|
||||
@endphp
|
||||
<a href="#" id="nav-button">
|
||||
<span>
|
||||
MENU
|
||||
<img src="{!! $assetPathPrefix !!}images/navbar.png" alt="navbar-image"/>
|
||||
</span>
|
||||
</a>
|
||||
<div class="tocify-wrapper">
|
||||
@if($metadata['logo'] != false)
|
||||
<img src="{{ $metadata['logo'] }}" alt="logo" class="logo" style="padding-top: 10px;" width="100%"/>
|
||||
@endif
|
||||
|
||||
@isset($metadata['example_languages'])
|
||||
<div class="lang-selector">
|
||||
@foreach($metadata['example_languages'] as $name => $lang)
|
||||
@php if (is_numeric($name)) $name = $lang; @endphp
|
||||
<button type="button" class="lang-button" data-language-name="{{ $lang }}">{{ $name }}</button>
|
||||
@endforeach
|
||||
</div>
|
||||
@endisset
|
||||
|
||||
<div class="search">
|
||||
<input type="text" class="search" id="input-search" placeholder="{{ u::trans("scribe::labels.search") }}">
|
||||
</div>
|
||||
|
||||
<div id="toc">
|
||||
@foreach($headings as $h1)
|
||||
<ul id="tocify-header-{{ $h1['slug'] }}" class="tocify-header">
|
||||
<li class="tocify-item level-1" data-unique="{!! $h1['slug'] !!}">
|
||||
<a href="#{!! $h1['slug'] !!}">{!! $h1['name'] !!}</a>
|
||||
</li>
|
||||
@if(count($h1['subheadings']) > 0)
|
||||
<ul id="tocify-subheader-{!! $h1['slug'] !!}" class="tocify-subheader">
|
||||
@foreach($h1['subheadings'] as $h2)
|
||||
<li class="tocify-item level-2" data-unique="{!! $h2['slug'] !!}">
|
||||
<a href="#{!! $h2['slug'] !!}">{!! $h2['name'] !!}</a>
|
||||
</li>
|
||||
@if(count($h2['subheadings']) > 0)
|
||||
<ul id="tocify-subheader-{!! $h2['slug'] !!}" class="tocify-subheader">
|
||||
@foreach($h2['subheadings'] as $h3)
|
||||
<li class="tocify-item level-3" data-unique="{!! $h3['slug'] !!}">
|
||||
<a href="#{!! $h3['slug'] !!}">{!! $h3['name'] !!}</a>
|
||||
</li>
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
@endforeach
|
||||
</ul>
|
||||
@endif
|
||||
</ul>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<ul class="toc-footer" id="toc-footer">
|
||||
@if($metadata['postman_collection_url'])
|
||||
<li style="padding-bottom: 5px;"><a href="{!! $metadata['postman_collection_url'] !!}">{!! u::trans("scribe::links.postman") !!}</a></li>
|
||||
@endif
|
||||
@if($metadata['openapi_spec_url'])
|
||||
<li style="padding-bottom: 5px;"><a href="{!! $metadata['openapi_spec_url'] !!}">{!! u::trans("scribe::links.openapi") !!}</a></li>
|
||||
@endif
|
||||
<li><a href="http://github.com/knuckleswtf/scribe">Documentation powered by Scribe ✍</a></li>
|
||||
</ul>
|
||||
|
||||
<ul class="toc-footer" id="last-updated">
|
||||
<li>{{ $metadata['last_updated'] }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
Reference in New Issue
Block a user