adde page preview feature, updated page edit ui with preview option button

This commit is contained in:
Ro 2021-11-22 14:24:26 -08:00
parent 49e53a9638
commit c867b6c508
7 changed files with 60 additions and 23 deletions

View file

@ -101,24 +101,47 @@ class DashControl
if (Session::active()) {
$template = "dash/page-edit.twig";
$mode = $args["third"];
if ($mode == "edit") {
$uuid = $args["fourth"];
$customPages = (new Themes())->getCustomViews();
$pageOptions = [
"title" => "Fipamo | Edit Page",
"page" => (new Book("../content/pages"))->findPageById($uuid),
"mode" => $mode,
"token" => Session::get("form_token"),
"status" => Session::active(),
"views" => $customPages,
];
} else {
$pageOptions = [
"title" => "Fipamo | Create Page",
"token" => Session::get("form_token"),
"mode" => $mode,
"status" => Session::active(),
];
$uuid = $args["fourth"];
switch ($mode) {
case "edit":
$customPages = (new Themes())->getCustomViews();
$pageOptions = [
"title" => "Fipamo | Edit Page",
"page" => (new Book("../content/pages"))->findPageById($uuid),
"mode" => $mode,
"token" => Session::get("form_token"),
"status" => Session::active(),
"views" => $customPages,
];
break;
case "preview":
$config = new Settings();
$settings = $config->getSettings();
$loader = new \Twig\Loader\FilesystemLoader(
"../content/themes"
);
$display = new \Twig\Environment($loader, []);
$book = new Book("../content/pages");
$page = $book->findPageById($uuid);
$pageOptions = Sorting::page($page);
$preview =
$settings["global"]["theme"] .
"/" .
$page["layout"] .
".twig";
$html = $display->render($preview, $pageOptions);
$response->getBody()->write($html);
return $response;
break;
default:
$pageOptions = [
"title" => "Fipamo | Create Page",
"token" => Session::get("form_token"),
"mode" => $mode,
"status" => Session::active(),
];
break;
}
} else {
header("Location: /dashboard");

View file

@ -63,6 +63,7 @@ class IndexControl
break;
default:
//check layout to see what page should be rendered
$template = $settings["global"]["theme"] . "/page.twig";
$book = new Book("../content/pages");
$page = $book->findPageBySlug($args["third"]);

View file

@ -155,6 +155,7 @@ class Sorting
"ul",
"li",
"i",
"em",
"h1",
"h2",
"h3",

View file

@ -30,7 +30,7 @@
{% endblock %}
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=dfdfd">
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=dfdfdf">
{% endblock %}
{% block mainContent %}

View file

@ -29,9 +29,16 @@
</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"/>
<use id="option-published-icon" xlink:href="/assets/images/global/sprite.svg#entypo-globe"/>
</svg>
</button>
<a href="/dashboard/page/preview/{{ uuid }}" target="_blank">
<button id="option-preview" class="option-inactive post-option-btn" data-active="false" title='preview page'>
<svg id="option-preview-icon" viewbox="0 0 20 20" class="icons">
<use id="option-preview-icon" xlink:href="/assets/images/global/sprite.svg#entypo-eye"/>
</svg>
</button>
</a>
<div id="layouts">
<label>Page Layouts</label>
<select id="page-templates">

File diff suppressed because one or more lines are too long

View file

@ -214,11 +214,16 @@
button:nth-child(1)
border-radius: 3px 0 0 3px
button:nth-child(3)
button:nth-child(4)
border-radius: 0 3px 3px 0
a
button
border-radius: 0 3px 3px 0 !important
button
width: 33.3%
width: 25%
height: 45px
@include object-transitions(0.3s)
margin: 0