rebuilt create/edit page template, added navigation, turned on logout mehthod
This commit is contained in:
parent
b75d045eec
commit
72c9b3f9e6
11 changed files with 234 additions and 7 deletions
|
@ -27,8 +27,8 @@ class APIControl
|
||||||
ResponseInterface $response,
|
ResponseInterface $response,
|
||||||
array $args
|
array $args
|
||||||
): ResponseInterface {
|
): ResponseInterface {
|
||||||
$contentType = $request->getHeaderLine("Content-Type");
|
$contentType = $request->getHeader("Content-Type");
|
||||||
switch ($contentType) {
|
switch ($contentType[0]) {
|
||||||
case "application/json":
|
case "application/json":
|
||||||
$body = json_decode(file_get_contents("php://input"), true);
|
$body = json_decode(file_get_contents("php://input"), true);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -30,11 +30,43 @@ class DashControl
|
||||||
"paginate" => $data["paginate"],
|
"paginate" => $data["paginate"],
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
|
case "page":
|
||||||
|
if (Session::active()) {
|
||||||
|
$template = "dash/page-edit.twig";
|
||||||
|
$mode = $args["third"];
|
||||||
|
if ($mode == "edit") {
|
||||||
|
$uuid = $args["fourth"];
|
||||||
|
|
||||||
|
$pageOptions = [
|
||||||
|
"title" => "Fipamo | Edit Page",
|
||||||
|
"page" => (new Book("../content/pages"))->findPageById($uuid),
|
||||||
|
"mode" => $mode,
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
$pageOptions = [
|
||||||
|
"title" => "Fipamo | Create Page",
|
||||||
|
"mode" => $mode,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$template = "dash/start.twig";
|
||||||
|
$pageOptions = [
|
||||||
|
"title" => "Welcome to Fipamo",
|
||||||
|
"status" => Session::active(),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "logout":
|
||||||
|
Session::kill();
|
||||||
|
header("Location: /dashboard");
|
||||||
|
die();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$template = "dash/start.twig";
|
$template = "dash/start.twig";
|
||||||
if (Session::active()) {
|
if (Session::active()) {
|
||||||
$pageOptions = [
|
$pageOptions = [
|
||||||
"title" => "Welcome to Fipamo",
|
"title" => "Welcome Back",
|
||||||
"status" => Session::active(),
|
"status" => Session::active(),
|
||||||
"data" => (new Book("../content/pages"))->getPages(1, 4),
|
"data" => (new Book("../content/pages"))->getPages(1, 4),
|
||||||
];
|
];
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
use Mni\FrontYAML\Parser;
|
use Mni\FrontYAML\Parser;
|
||||||
use function _\orderBy;
|
use function _\orderBy;
|
||||||
use function _\filter;
|
use function _\filter;
|
||||||
|
use function _\find;
|
||||||
|
|
||||||
class Book
|
class Book
|
||||||
{
|
{
|
||||||
|
@ -25,6 +26,13 @@ class Book
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function findPageById(string $uuid)
|
||||||
|
{
|
||||||
|
$content = $this->getContents();
|
||||||
|
$page = find($content, ["uuid" => $uuid]);
|
||||||
|
return $page;
|
||||||
|
}
|
||||||
|
|
||||||
public function getPages(int $page, int $limit, string $sort = null)
|
public function getPages(int $page, int $limit, string $sort = null)
|
||||||
{
|
{
|
||||||
$content = $this->getContents();
|
$content = $this->getContents();
|
||||||
|
|
|
@ -32,7 +32,13 @@
|
||||||
<a href="/dashboard"><img id="the-logo" src="/assets/images/global/the-logo.svg"/></a>
|
<a href="/dashboard"><img id="the-logo" src="/assets/images/global/the-logo.svg"/></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="right"></div>
|
<div id="right">
|
||||||
|
{% if status %}
|
||||||
|
{% apply spaceless %}
|
||||||
|
{{ include("dash/partials/navigation.twig") }}
|
||||||
|
{% endapply %}
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</header>
|
</header>
|
||||||
|
|
96
brain/views/dash/page-edit.twig
Normal file
96
brain/views/dash/page-edit.twig
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
{% extends "dash/_frame.twig" %}
|
||||||
|
{#
|
||||||
|
if page is in 'edit' mode, set variables
|
||||||
|
if not, just make them empty
|
||||||
|
#}
|
||||||
|
{% if mode == 'edit' %}
|
||||||
|
{% set id = page['id'] %}
|
||||||
|
{% set uuid = page['uuid'] %}
|
||||||
|
{% set slug = page['slug'] %}
|
||||||
|
{% set feature = page['feature'] %}
|
||||||
|
{% set _title = page['title'] %}
|
||||||
|
{% set tags = page['tags'] %}
|
||||||
|
{% set content = page['content'] %}
|
||||||
|
{% else %}
|
||||||
|
{% set id = '' %}
|
||||||
|
{% set uuid = '' %}
|
||||||
|
{% set slug = '' %}
|
||||||
|
{% set feature = '' %}
|
||||||
|
{% set title = '' %}
|
||||||
|
{% set tags = '' %}
|
||||||
|
{% set content = '' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{{ title }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block stylesheets %}
|
||||||
|
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfdf">
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block mainContent %}
|
||||||
|
<div id="post-edit-index" data-index="{{ id }}" data-uuid="{{ uuid }}" data-slug="{{ slug }}">
|
||||||
|
<div id="post-edit-index-wrapper">
|
||||||
|
<div id="post-feature">
|
||||||
|
{% if page['feature'] == null %}
|
||||||
|
<div id="featured-image-drop">
|
||||||
|
DRAG AND DROP IMAGE OR
|
||||||
|
<label for="featured-image-upload"></label>
|
||||||
|
CLICK TO CHOSE
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div id="featured-new-image-btn">
|
||||||
|
<button id="new-feature-upload">
|
||||||
|
<svg id="new-feature-upload" viewbox="0 0 20 20" class="icons"><use xlink:href="/assets/images/global/sprite.svg#entypo-image-inverted"/></svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div id="featured-image-drop">
|
||||||
|
<img id="featured-image" src="{{ feature }}"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div id="post-header">
|
||||||
|
<div id="post-header-wrapper" class="columns">
|
||||||
|
<div id="post-title" class="column">
|
||||||
|
<label>TITLE</label>
|
||||||
|
<textarea id="post_title" type="text" name="post_title" class="post-edit" placeholder="TITLE">
|
||||||
|
{{- _title -}}
|
||||||
|
</textarea>
|
||||||
|
<label>CREATED</label>
|
||||||
|
<br/>
|
||||||
|
<span id="post-date" type="text">
|
||||||
|
PRETTY DATE
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div id="post-meta" class="column">
|
||||||
|
<label>TAGS</label>
|
||||||
|
<textarea id="post_tags" type="text" name="post_tags" class="form-control" placeholder="tags [comma seperated]">
|
||||||
|
{{- tags -}}
|
||||||
|
</textarea>
|
||||||
|
<label>OPTIONS</label>
|
||||||
|
{% apply spaceless %}
|
||||||
|
{{ include("dash/partials/options.twig") }}
|
||||||
|
{% endapply %}
|
||||||
|
<input id="featured-image-upload" type="file" name="featured-image-upload"/>
|
||||||
|
<input id="post-image-upload" type="file" name="post-image-upload"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="edit-post">
|
||||||
|
{% apply spaceless %}
|
||||||
|
{{ include("dash/partials/editor.twig") }}
|
||||||
|
{% endapply %}
|
||||||
|
<div id="edit-post-wrapper">
|
||||||
|
<pre><code id="edit-post-text" contenteditable="true"> {{- content -}}</code></pre>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block javascripts %}
|
||||||
|
<script src="/assets/scripts/dash.min.js" type="text/javascript"></script>
|
||||||
|
{% endblock %}
|
45
brain/views/dash/partials/editor.twig
Normal file
45
brain/views/dash/partials/editor.twig
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<div id="edit-control">
|
||||||
|
<button id="edit-bold" class="content-editor-btn-text editor-button" title="bold">B</button>
|
||||||
|
<button id="edit-italic" class="content-editor-btn-text editor-button" title="italic">I</button>
|
||||||
|
<button id="edit-strikethrough" class="content-editor-btn-text editor-button" title="strikethrough">D</button>
|
||||||
|
<button id="edit-link" class="content-editor-btn-icon editor-button" title="insert link">
|
||||||
|
<svg id="edit-link" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="edit-link" xlink:href="/assets/images/global/sprite.svg#entypo-link"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button id="edit-header1" class="content-editor-btn-text editor-button" title="header 1">H1</button>
|
||||||
|
<button id="edit-header2" class="content-editor-btn-text editor-button" title="header 2">H2</button>
|
||||||
|
<button id="edit-header3" class="content-editor-btn-text editor-button" title="header 3">H3</button>
|
||||||
|
<button id="edit-image" class="content-editor-btn-icon editor-button" title="insert image">
|
||||||
|
<svg id="edit-image" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="edit-image" xlink:href="/assets/images/global/sprite.svg#entypo-image"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{% if mode == "edit" %}
|
||||||
|
<button id="edit-update" class="post-sumbit-btn submit-start editor-button" data-action='blog-update' data-id=page.id type='submit' title="bold">
|
||||||
|
<svg id="submit-update" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="submit-update" xlink:href="/assets/images/global/sprite.svg#entypo-save" data-action='blog-update' data-id="{{ page['uuid'] }}"/>
|
||||||
|
</svg>
|
||||||
|
<svg id="submit-good" class="icon-hide" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use xlink:href="/assets/images/global/sprite.svg#entypo-thumbs-up"/>
|
||||||
|
</svg>
|
||||||
|
<svg id="submit-error" class="icon-hide" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use xlink:href="/assets/images/global/sprite.svg#entypo-thumbs-down"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button id="edit-delete" class="content-editor-btn-icon editor-button submit-delete" for="post-delete" title='delete post'>
|
||||||
|
<svg id="edit-delete" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="edit-delete" xlink:href="/assets/images/global/sprite.svg#entypo-cross"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{% else %}
|
||||||
|
<button id="edit-save" class="post-sumbit-btn submit-start editor-button" data-action='blog-add' type='submit'>
|
||||||
|
<svg id="submit-save" class="icon-hide" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="submit-save" xlink:href="/assets/images/global/sprite.svg#entypo-plus"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
5
brain/views/dash/partials/navigation.twig
Normal file
5
brain/views/dash/partials/navigation.twig
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<div id="dash-menu">
|
||||||
|
<a id="settings" href="/dashboard/settings" >Settings</a> .
|
||||||
|
<a id="navigation" href="/dashboard/navigation" >Navigation</a> .
|
||||||
|
<a id="navigation" href="/dashboard/logout" >Log Out</a>
|
||||||
|
</div>
|
35
brain/views/dash/partials/options.twig
Normal file
35
brain/views/dash/partials/options.twig
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
{% if page['menu'] %}
|
||||||
|
{% set menu = 'true' %}
|
||||||
|
{% else %}
|
||||||
|
{% set menu = 'false' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if page['featured'] %}
|
||||||
|
{% set featured = 'true' %}
|
||||||
|
{% else %}
|
||||||
|
{% set featured = 'false' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if page['published'] %}
|
||||||
|
{% set published = 'true' %}
|
||||||
|
{% else %}
|
||||||
|
{% set published = 'false' %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="post-options">
|
||||||
|
<button id="option-menu-pin" class="option-inactive post-option-btn" data-active="{{ menu }}" title='Pin to Menu'>
|
||||||
|
<svg id="option-page-icon" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="option-page-icon" xlink:href="/assets/images/global/sprite.svg#entypo-pin"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button id="option-feature" class="option-inactive post-option-btn" data-active="{{ featured }}" title='Feature'>
|
||||||
|
<svg id="option-feature-icon" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="option-feature-icon" xlink:href="/assets/images/global/sprite.svg#entypo-star"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<button id="option-published" class="option-inactive post-option-btn" data-active="{{ published }}" title='Published'>
|
||||||
|
<svg id="option-published-icon" viewbox="0 0 20 20" class="icons">
|
||||||
|
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
|
@ -5,7 +5,7 @@
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block stylesheets %}
|
{% block stylesheets %}
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=wrqrqrewq">
|
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=adfafd">
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block mainContent %}
|
{% block mainContent %}
|
||||||
|
|
|
@ -189,7 +189,7 @@
|
||||||
button:nth-child(1)
|
button:nth-child(1)
|
||||||
border-radius: 3px 0 0 3px
|
border-radius: 3px 0 0 3px
|
||||||
|
|
||||||
button:nth-child(4)
|
button:nth-child(3)
|
||||||
border-radius: 0 3px 3px 0
|
border-radius: 0 3px 3px 0
|
||||||
|
|
||||||
button
|
button
|
||||||
|
|
|
@ -104,7 +104,7 @@ svg.icons
|
||||||
padding: 0.75rem
|
padding: 0.75rem
|
||||||
|
|
||||||
#left, #right
|
#left, #right
|
||||||
width: 50%
|
width: 49.7%
|
||||||
display: inline-block
|
display: inline-block
|
||||||
vertical-align: top
|
vertical-align: top
|
||||||
min-height: 60px
|
min-height: 60px
|
||||||
|
|
Loading…
Reference in a new issue