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()) { if (Session::active()) {
$template = "dash/page-edit.twig"; $template = "dash/page-edit.twig";
$mode = $args["third"]; $mode = $args["third"];
if ($mode == "edit") { $uuid = $args["fourth"];
$uuid = $args["fourth"]; switch ($mode) {
$customPages = (new Themes())->getCustomViews(); case "edit":
$pageOptions = [ $customPages = (new Themes())->getCustomViews();
"title" => "Fipamo | Edit Page", $pageOptions = [
"page" => (new Book("../content/pages"))->findPageById($uuid), "title" => "Fipamo | Edit Page",
"mode" => $mode, "page" => (new Book("../content/pages"))->findPageById($uuid),
"token" => Session::get("form_token"), "mode" => $mode,
"status" => Session::active(), "token" => Session::get("form_token"),
"views" => $customPages, "status" => Session::active(),
]; "views" => $customPages,
} else { ];
$pageOptions = [ break;
"title" => "Fipamo | Create Page", case "preview":
"token" => Session::get("form_token"), $config = new Settings();
"mode" => $mode, $settings = $config->getSettings();
"status" => Session::active(), $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 { } else {
header("Location: /dashboard"); header("Location: /dashboard");

View file

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

View file

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

View file

@ -30,7 +30,7 @@
{% endblock %} {% endblock %}
{% block stylesheets %} {% 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 %} {% endblock %}
{% block mainContent %} {% block mainContent %}

View file

@ -29,9 +29,16 @@
</button> </button>
<button id="option-published" class="option-inactive post-option-btn" data-active="{{ published }}" title='Published'> <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"> <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> </svg>
</button> </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"> <div id="layouts">
<label>Page Layouts</label> <label>Page Layouts</label>
<select id="page-templates"> <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) button:nth-child(1)
border-radius: 3px 0 0 3px border-radius: 3px 0 0 3px
button:nth-child(3) button:nth-child(4)
border-radius: 0 3px 3px 0 border-radius: 0 3px 3px 0
a
button
border-radius: 0 3px 3px 0 !important
button button
width: 33.3% width: 25%
height: 45px height: 45px
@include object-transitions(0.3s) @include object-transitions(0.3s)
margin: 0 margin: 0