Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create dashboard template #27

Merged
merged 28 commits into from
Jun 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7e2f315
Create README.md
caendesilva Jun 12, 2022
75aec77
Create dashboard.blade.php
caendesilva Jun 12, 2022
b4c6f94
Update header
caendesilva Jun 12, 2022
36f0e06
Add BladePage table
caendesilva Jun 13, 2022
9a137ff
Add MarkdownPage table
caendesilva Jun 13, 2022
7222840
Add DocumentationPage table
caendesilva Jun 13, 2022
81068e5
Add MarkdownPost table
caendesilva Jun 13, 2022
408ddae
Link to the compiled pages
caendesilva Jun 13, 2022
303d6e6
Add the source file paths
caendesilva Jun 13, 2022
4188761
Update table headings
caendesilva Jun 13, 2022
1a724f6
Place content overview tables in section
caendesilva Jun 13, 2022
d19e80b
Remove redundant classes
caendesilva Jun 13, 2022
9f5ae73
Add installation details table
caendesilva Jun 13, 2022
f5cf6ac
Add GitHub dashboard integration
caendesilva Jun 13, 2022
45f33b3
Shorten title
caendesilva Jun 13, 2022
d625149
Fix quotes in code block example
caendesilva Jun 13, 2022
775e53e
Replace qualifiers with imports
caendesilva Jun 13, 2022
fb8bf21
Add helper class to generate links to GitHub
caendesilva Jun 13, 2022
3eceb09
Format and reindent code
caendesilva Jun 13, 2022
46fad51
Add the GitHub links
caendesilva Jun 13, 2022
d9c7e4a
Add extra post information
caendesilva Jun 13, 2022
f03b759
Revert "Add extra post information"
caendesilva Jun 13, 2022
d0525d0
Equalize page column widths
caendesilva Jun 13, 2022
65774f3
Add heading IDs
caendesilva Jun 13, 2022
44f8361
Add content quick look table
caendesilva Jun 13, 2022
a0e2b4d
Add heading permalinks
caendesilva Jun 13, 2022
d42dec3
Justify some of the tables
caendesilva Jun 13, 2022
57f1454
Move Dashboard template into templates
caendesilva Jun 13, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions projects/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# HydePHP Page Templates

A collection of page templates for use with HydePHP.

Templates that are whole projects should be in their own repository but may be linked here.

Contributions are very welcome!
313 changes: 313 additions & 0 deletions projects/templates/dashboard.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
@php
use Hyde\Framework\Models\BladePage;
use Hyde\Framework\Models\MarkdownPage;
use Hyde\Framework\Models\DocumentationPage;
use Hyde\Framework\Models\MarkdownPost;
use Hyde\Framework\Services\CollectionService;

$github = new class {
public bool $enabled;

public function __construct() {
$this->enabled = (config('hyde.github_dashboard.enabled', false) === true)
&& (config('hyde.github_dashboard.username') !== null)
&& (config('hyde.github_dashboard.repository') !== null)
&& (config('hyde.github_dashboard.branch') !== null);
}

public function getLink(string $path): string {
$action = config('hyde.github_dashboard.action', 'view') === 'edit' ? 'edit' : 'blob';
return sprintf("https://github.com/%s/%s/%s/%s/%s",
config('hyde.github_dashboard.username'),
config('hyde.github_dashboard.repository'),
$action,
config('hyde.github_dashboard.branch'),
$path
);
}

public function link(string $path): string {
return $this->enabled
? '<a href="'.$this->getLink(e($path)).'">'.e($path).'</a>'
: e($path);
}
};
@endphp

@extends('hyde::layouts.app')
@section('content')
@php($title = "Dashboard")

<style>
.dashboard-table td, .dashboard-table th {
width: 50%;
}
.table-justified td, .table-justified th {
text-align: center;
}
.table-justified td:first-child, .table-justified th:first-child {
text-align: left;
}
.table-justified td:last-child, .table-justified th:last-child {
text-align: right;
}
</style>

<main class="mx-auto max-w-7xl py-16 px-8">
<header class="text-center prose dark:prose-invert mx-auto">
<h1 class="text-3xl font-bold">Project Dashboard</h1>
<p>
<strong>
Here you can get a quick overview of your project.
</strong>
</p>
<p>
While this is useful when developing locally,
you may not want to use it when compiling
for production.
</p>
</header>

<section class="prose dark:prose-invert mx-auto mt-8">
<header>
<h2>Project Details</h2>
</header>

<section class="mt-8">
<h3>Installation Details</h3>
<table class="table-justified">
<thead>
<tr>
<th>Project Name</th>
<th>Project Path</th>
<th>Framework Version</th>
<th>PHP Version</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{ config('hyde.name', Hyde::titleFromSlug(basename(Hyde::path()))) }}</td>
<td>{{ Hyde::path() }}</td>
<td>{{ Hyde::version() }}</td>
<td>{{ PHP_VERSION }} <small>({{ PHP_SAPI }})</small></td>
</tr>
</tbody>
</table>

<h3>GitHub Integration</h3>
<table class="table-justified">
<thead>
<tr>
<th>Username</th>
<th>Repository</th>
<th>Branch</th>
</tr>
</thead>
<tbody>
<tr>
@if (config('hyde.github_dashboard.enabled', false))
<td>
<a href="https://github.com/{{ config('hyde.github_dashboard.username', '<not-set>') }}">
{{ config('hyde.github_dashboard.username', '<not-set>') }}
</a>
</td>
<td>
<a href="https://github.com/{{ config('hyde.github_dashboard.username', '<not-set>') }}/{{ config('hyde.github_dashboard.repository', '<not-set>') }}">
{{ config('hyde.github_dashboard.repository', '<not-set>') }}
</a>
</td>
<td>
<a href="https://github.com/{{ config('hyde.github_dashboard.username', '<not-set>') }}/{{ config('hyde.github_dashboard.repository', '<not-set>') }}/tree/{{ config('hyde.github_dashboard.branch', '<not-set>') }}">
{{ config('hyde.github_dashboard.branch', '<not-set>') }}
</a>
</td>
@else
<td colspan="4">
<p class="text-center mb-0">
<strong>
GitHub Dashboard Integrations is not enabled.
</strong>
</p>
<details class="text-center">
<summary class="cursor-pointer">
Show configuration guide.
</summary>
<p>
The GitHub integration allows you to easily
open dashboard files in your GitHub repository.
<br>
To enable it, you need to let Hyde know where
your GitHub repository is located.<br>
The repository is assumed to be a top level installation of Hyde/Hyde.
<br>
Add the following to your <code>config/hyde.php</code> file:
</p>
<pre class="text-left w-fit py-0 px-4 mx-auto"><code class="my-0"><div style="color: rgb(191, 199, 213); font-family: 'Fira Code Regular', Consolas, 'Courier New', monospace; font-size: 14px; line-height: 18px;"><div style="line-height: 18px;"><div><span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">github_dashboard</span><span style="color: #d9f5dd;">'</span> <span style="color: #89ddff;">=&gt;</span> [</div><div>&nbsp; &nbsp; <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">enabled</span><span style="color: #d9f5dd;">'</span> <span style="color: #89ddff;">=&gt;</span> <span style="color: #82aaff;">true</span>,</div><div>&nbsp; &nbsp; <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">username</span><span style="color: #d9f5dd;">'</span> <span style="color: #89ddff;">=&gt;</span> <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">octocat</span><span style="color: #d9f5dd;">'</span>,</div><div>&nbsp; &nbsp; <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">repository</span><span style="color: #d9f5dd;">'</span> <span style="color: #89ddff;">=&gt;</span> <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">homepage</span><span style="color: #d9f5dd;">'</span>,</div><div>&nbsp; &nbsp; <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">branch</span><span style="color: #d9f5dd;">'</span> <span style="color: #89ddff;">=&gt;</span> <span style="color: #d9f5dd;">'</span><span style="color: #c3e88d;">main</span><span style="color: #d9f5dd;">'</span>,</div><div>]</div></div></div></code></pre>
</details>
</td>
@endif
</tr>
</tbody>
</table>
</section>
</section>

<section class="prose dark:prose-invert mx-auto mt-8">
<header>
<h2>Your Content</h2>
</header>

<h3>Content Overview</h3>
<table class="table-justified">
<thead>
<tr>
<th>Blade Pages</th>
<th>Markdown Pages</th>
<th>Documentation Pages</th>
<th>Blog Posts</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a href="#blade-pages">
<b>{{ count(CollectionService::getBladePageList()) }}</b> pages
</a>
</td>
<td>
<a href="#markdown-pages">
<b>{{ count(CollectionService::getMarkdownPageList()) }}</b> pages
</a>
</td>
<td>
<a href="#documentation-pages">
<b>{{ count(CollectionService::getDocumentationPageList()) }}</b> pages
</a>
</td>
<td>
<a href="#blog-posts">
<b>{{ count(CollectionService::getMarkdownPostList()) }}</b> posts
</a>
</td>
</tr>
</tbody>
</table>

<section class="mt-8">
<h3 id="blade-pages">
Blade Pages
<a href="#blade-pages" title="Heading link">#</a>
</h3>
<table class="dashboard-table">
<thead>
<tr>
<th>Title</th>
<th>Source File</th>
</tr>
</thead>
<tbody>
@foreach (BladePage::all() as $page)
<tr>
<td>
<a href="{{ Hyde::pageLink($page->slug . '.html') }}">
{{ Hyde::titleFromSlug($page->view) }}
</a>
</td>
<td>
{!! $github->link(BladePage::$sourceDirectory .'/'. $page->slug . BladePage::$fileExtension) !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</section>

<section class="mt-8">
<h3 id="markdown-pages">
Markdown Pages
<a href="#markdown-pages" title="Heading link">#</a>
</h3>
<table class="dashboard-table">
<thead>
<tr>
<th>Title</th>
<th>Source File</th>
</tr>
</thead>
<tbody>
@foreach (MarkdownPage::all() as $page)
<tr>
<td>
<a href="{{ Hyde::pageLink($page->slug . '.html') }}">
{{ $page->title }}
</a>
</td>
<td>
{!! $github->link(MarkdownPage::$sourceDirectory .'/'. $page->slug . MarkdownPage::$fileExtension) !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</section>

<section class="mt-8">
<h3 id="documentation-pages">
Documentation Pages
<a href="#documentation-pages" title="Heading link">#</a>
</h3>
<table class="dashboard-table">
<thead>
<tr>
<th>Title</th>
<th>Source File</th>
</tr>
</thead>
<tbody>
@foreach (DocumentationPage::all() as $page)
<tr>
<td>
<a href="{{ Hyde::docsDirectory() .'/'. Hyde::pageLink($page->slug . '.html') }}">
{{ $page->title }}
</a>
</td>
<td>
{!! $github->link(DocumentationPage::$sourceDirectory .'/'. $page->slug . DocumentationPage::$fileExtension) !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</section>

<section class="mt-8">
<h3 id="blog-posts">
Blog Posts
<a href="#blog-posts" title="Heading link">#</a>
</h3>
<table class="dashboard-table">
<thead>
<tr>
<th>Title</th>
<th>Source File</th>
</tr>
</thead>
<tbody>
@foreach (MarkdownPost::all() as $post)
<tr>
<td>
<a href="posts/{{ Hyde::pageLink($post->slug . '.html') }}">
{{ $post->title }}
</a>
</td>
<td>
{!! $github->link(MarkdownPost::$sourceDirectory .'/'. $post->slug . MarkdownPost::$fileExtension) !!}
</td>
</tr>
@endforeach
</tbody>
</table>
</section>
</section>
</main>
@endsection