dash index displaying recents, css tweaks, added bulma

This commit is contained in:
Ro 2021-04-01 17:37:12 -07:00
parent 5ad1118244
commit c4232a0a01
8 changed files with 109 additions and 16 deletions

View file

@ -21,11 +21,19 @@ class DashControl
default:
//$_SESSION["TEST"] = "TESTERZ";
//session_unset();
$pageOptions = [
"title" => "Fipamo Dashboard",
"status" => Session::active(),
"pages" => (new Book("content/pages"))->getContents(),
];
if (Session::active()) {
$pageOptions = [
"title" => "Welcome to Fipamo",
"status" => Session::active(),
"data" => (new Book("../content/pages"))->getPages(1, 4),
];
} else {
$pageOptions = [
"title" => "Welcome to Fipamo",
"status" => Session::active(),
];
}
break;
}
return $view->render($response, "dash/start.twig", $pageOptions);

View file

@ -1,6 +1,7 @@
<?php
use Mni\FrontYAML\Parser;
use function _\orderBy;
class Book
{
@ -22,13 +23,37 @@ class Book
$this->files[] = $file;
}
}
public function getPages(int $page, int $limit)
{
$content = $this->getContents();
$count = ceil(count($content) / $limit);
$folder = [];
$range = $page * $limit - $limit;
for ($i = 0; $i <= $limit; $i++) {
try {
array_push($folder, $content[$i + $range]);
} catch (Exception $error) {
//echo $error;
}
}
return [
"pages" => $folder,
"total" => $count,
];
}
public function getContents()
{
$parser = new Parser();
$contents = [];
foreach ($this->files as $file) {
$doc = $parser->parse(file_get_contents($file), false);
$meta = $doc->getYAML();
//$date = getdate($meta["created"]);
$newDate = date("Y M D d", $meta["created"]);
$page = [
"id" => $meta["id"],
"uuid" => $meta["uuid"],
@ -38,6 +63,7 @@ class Book
"layout" => $meta["layout"],
"tags" => $meta["tags"],
"author" => $meta["author"],
"prettyDate" => $newDate,
"created" => $meta["created"],
"deleted" => $meta["deleted"],
"menu" => $meta["menu"],
@ -61,7 +87,7 @@ class Book
array_push($contents, $page);
}
}
$contents = orderBy($contents, ["id"], ["desc"]);
return $contents;
}
}

View file

@ -0,0 +1,53 @@
<div id="dash-recent">
<div id="recent-list">
<div class="recent-header">
<h3>Recent</h3>
<div class="index-menu">
<a href='/dashboard/page/list'>View Pages</a>
.
<a href='/dashboard/page/add/new'>Create Page</a>
</div>
</div>
<br/>
{% if data["total"] != 0 %}
{% for page in data['pages'] %}
<a href="/dashboard/page/edit/{{ page.uuid }}" id="{{ page.uuid }}" class="post-link" style="background: url({{ page.feature }}) no-repeat center center / cover">
<div>
<label>
{{ page.title }}
</label>
{% if page.menu == 'true' %}
{% set menu = "true" %}
{% else %}
{% set menu = "false" %}
{% endif %}
{% if page.published == 'true' %}
{% set published = "true" %}
{% else %}
{% set published = "false" %}
{% endif %}
{% if page.featured == 'true' %}
{% set featured = "true" %}
{% else %}
{% set featured = "false" %}
{% endif %}
<div id="options">
<span class="item-options" data-active="{{ menu }}">
Menu Item</span>
<span class="item-options" data-active="{{ published }}">
Published</span>
<span class="item-options" data-active="{{ featured }}">
Featured</span>
</div>
<span>{{ page.prettyDate }}</span>
</div>
</a>
{% endfor %}
{% else %}
There are no pages
{% endif %}
</div>
</div>

View file

@ -5,14 +5,14 @@
{% endblock %}
{% block stylesheets %}
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css">
<link rel="stylesheet" type="text/css" href="/assets/css/dash.css?=wrqrqrewq">
{% endblock %}
{% block mainContent %}
<div id="dash-index">
<div id="dash-index-wrapper">
{% if status %}
DASH INDEX
{{ include("dash/partials/index.twig") }}
{% else %}
{{ include("dash/forms/login.twig") }}
{% endif %}

9
src/package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "codekit-project",
"version": "1.0.0",
"name": "fipamo-dash",
"version": "1.2.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -9,6 +9,11 @@
"resolved": "https://registry.npmjs.org/animejs/-/animejs-3.2.1.tgz",
"integrity": "sha512-sWno3ugFryK5nhiDm/2BKeFCpZv7vzerWUcUPyAZLDhMek3+S/p418ldZJbJXo5ZUOpfm2kP2XRO4NJcULMy9A=="
},
"bulma": {
"version": "0.9.2",
"resolved": "https://registry.npmjs.org/bulma/-/bulma-0.9.2.tgz",
"integrity": "sha512-e14EF+3VSZ488yL/lJH0tR8mFWiEQVCMi/BQUMi2TGMBOk+zrDg4wryuwm/+dRSHJw0gMawp2tsW7X1JYUCE3A=="
},
"caret-pos": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/caret-pos/-/caret-pos-2.0.0.tgz",

View file

@ -9,6 +9,7 @@
"private": true,
"dependencies": {
"animejs": "^3.2.1",
"bulma": "^0.9.2",
"caret-pos": "^2.0.0",
"sortablejs": "^1.13.0"
}

View file

@ -1,8 +1,8 @@
@use "sass:color"
//Bulma
@import '../../node_modules/bulma/sass/utilities/_all'
@import '../../node_modules/bulma/sass/grid/columns'
@import '../node_modules/bulma/sass/utilities/_all'
@import '../node_modules/bulma/sass/grid/columns'
//Colors
@import 'main/_colors'

View file

@ -111,7 +111,7 @@
h3
vertical-align: top
display: inline-block
width: 50%
width: 49%
.index-menu
width: 50%
@ -195,16 +195,16 @@
height: 500px
a:nth-child(4)
width: 49%
width: 48.7%
height: 275px
margin: 0 15px 15px 0
a:nth-child(5)
width: 49%
width: 48.7%
height: 550px
a:nth-child(6)
width: 49%
width: 48.7%
height: 550px
margin :-260px 15px 0 0