diff --git a/brain/controller/DashControl.inc.php b/brain/controller/DashControl.inc.php index 10a6b00..e109cc8 100644 --- a/brain/controller/DashControl.inc.php +++ b/brain/controller/DashControl.inc.php @@ -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); diff --git a/brain/data/Book.inc.php b/brain/data/Book.inc.php index ca62c1f..c32011b 100644 --- a/brain/data/Book.inc.php +++ b/brain/data/Book.inc.php @@ -1,6 +1,7 @@ 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; } } diff --git a/brain/views/dash/partials/index.twig b/brain/views/dash/partials/index.twig new file mode 100644 index 0000000..b7af1d2 --- /dev/null +++ b/brain/views/dash/partials/index.twig @@ -0,0 +1,53 @@ +
+
+
+

Recent

+ +
+
+ {% if data["total"] != 0 %} + {% for page in data['pages'] %} + +
+ + + {% 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 %} +
+ + Menu Item + + Published + + Featured +
+ {{ page.prettyDate }} + +
+
+ {% endfor %} + {% else %} + There are no pages + {% endif %} + +
+
\ No newline at end of file diff --git a/brain/views/dash/start.twig b/brain/views/dash/start.twig index 6ddd994..d453d61 100644 --- a/brain/views/dash/start.twig +++ b/brain/views/dash/start.twig @@ -5,14 +5,14 @@ {% endblock %} {% block stylesheets %} - + {% endblock %} {% block mainContent %}
{% if status %} - DASH INDEX + {{ include("dash/partials/index.twig") }} {% else %} {{ include("dash/forms/login.twig") }} {% endif %} diff --git a/src/package-lock.json b/src/package-lock.json index 397733c..348a909 100644 --- a/src/package-lock.json +++ b/src/package-lock.json @@ -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", diff --git a/src/package.json b/src/package.json index f99247f..9fa74e5 100644 --- a/src/package.json +++ b/src/package.json @@ -9,6 +9,7 @@ "private": true, "dependencies": { "animejs": "^3.2.1", + "bulma": "^0.9.2", "caret-pos": "^2.0.0", "sortablejs": "^1.13.0" } diff --git a/src/styles/dash.sass b/src/styles/dash.sass index d007988..b25c119 100644 --- a/src/styles/dash.sass +++ b/src/styles/dash.sass @@ -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' diff --git a/src/styles/main/_index.sass b/src/styles/main/_index.sass index fd7bcd6..691e167 100644 --- a/src/styles/main/_index.sass +++ b/src/styles/main/_index.sass @@ -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