tag html rendering implemented

beta
Ro 3 years ago
parent c78772e2c0
commit 9283a7f5b3

1
.gitignore vendored

@ -17,6 +17,7 @@ public/assets/images/*
content/
vendor/
cache/
_temp
.ftpconfig
.vscode/
*.swp

@ -13,31 +13,8 @@ class SettingsAPI
$task = $args["fourth"];
switch ($task) {
case "publish":
$view = Twig::fromRequest($request);
//$sortTags = Sorting::tags();
//var_dump($sortTags);
$sortArchive = Sorting::archive();
var_dump($sortArchive);
/*
$template = "dash/start.twig";
$pageOptions = [
"title" => "Welcome to Fucking Fipamo",
"status" => false,
];
$html = $view->fetch($template, $pageOptions);
$location = "../content/test.html";
if (!is_file($location)) {
file_put_contents($location, $html);
} else {
($new = fopen($location, "w")) or die("Unable to open file!");
fwrite($new, $html);
fclose($new);
}
*/
$render = new Render();
$render->renderTags();
$result = [
"message" => "Items sorted. GOOD EFFORT",

@ -12,11 +12,18 @@ class IndexControl
): ResponseInterface {
//unset($_SESSION);
$view = Twig::fromRequest($request);
$html = file_get_contents("../public/index.html");
$response->getBody()->write($html);
return $response;
/*
return $view->render($response, "front/start.twig", [
"title" => "Fipamo Dash",
"status" => false,
"pages" => [],
"totalPages" => 0,
]);
*/
}
}

@ -150,6 +150,7 @@ class Book
//once saved, update menu
$body["path"] = $path;
Settings::updateMenu($body);
Settings::updateTags();
} else {
$response = [
"message" => "Uh oh. File save problem. Don't panic",

@ -2,7 +2,48 @@
class Render
{
public $loader;
public $twig;
public $pageInfo;
public $menu;
public $background;
public function __construct()
{
$config = new Settings();
$this->loader = new \Twig\Loader\FilesystemLoader("../content/themes");
$this->twig = new \Twig\Environment($this->loader, []);
$settings = $config->getSettings();
$this->menu = $settings["menu"];
$this->pageInfo = [
"keywords" => $settings["global"]["keywords"],
"description" => $settings["global"]["descriptions"],
"image" => $settings["global"]["background"],
];
}
public function renderTags()
{
$list = Sorting::tags();
foreach ($list as $item) {
$template = "fipamo-default/tags.twig";
$pageOptions = [
"title" => "Pages Tagged as " . $item["tag_name"],
"background" => $this->pageInfo["image"],
"tag_list" => $item["pages"],
"info" => $this->pageInfo,
"menu" => $this->menu,
];
$html = $this->twig->render($template, $pageOptions);
$location = "../public/tags/" . $item["slug"] . ".html";
if (!is_file($location)) {
file_put_contents($location, $html);
} else {
($new = fopen($location, "w")) or die("Unable to open file!");
fwrite($new, $html);
fclose($new);
}
}
}
}

@ -164,4 +164,10 @@ class Settings
}
DocTools::writeSettings("../config/settings.json", $settings);
}
public static function updateTags()
{
$tags = Sorting::tags();
DocTools::writeSettings("../config/tags.json", $tags);
}
}

@ -13,7 +13,6 @@ class Sorting
public static function tags()
{
$pages = (new Book("../content/pages"))->getContents();
foreach ($pages as $page) {
$temp = [];
$temp = explode(",", $page["tags"]);
@ -23,13 +22,8 @@ class Sorting
array_push(self::$_tags, [
"tag_name" => $label,
"slug" => StringTools::safeString($label),
"count" => 1,
"pages" => self::tagPages($label, $pages),
]);
} else {
$item = find(self::$_tags, ["tag_name" => $label]);
//echo "TAG: " . $item["tag_name"] . "\n";
$count = $item["count"];
self::$_tags[$label]["count"] = $count + 1;
}
}
}
@ -37,18 +31,38 @@ class Sorting
return self::$_tags;
}
private static function tagPages($tag, $pages)
{
$tagged = [];
foreach ($pages as $page) {
if (strpos($page["tags"], $tag) !== false) {
array_push($tagged, [
"title" => $page["title"],
"slug" => $page["slug"],
"path" => $page["path"],
]);
}
}
return $tagged;
}
public static function archive()
{
$pages = (new Book("../content/pages"))->getContents();
$years = [];
$archive = [];
foreach ($pages as $page) {
$year = date("Y", date($page["rawCreated"]));
//$year = date("Y", date($page["rawCreated"]));
$date = explode("/", $page["path"]);
//echo $page["title"] . " : " . $year . "\n";
if (!find($years, ["year" => $year])) {
$findPages = filter($pages, ["createdYear" => $year]);
if (!find($years, ["year" => trim($date[0])])) {
$findPages = filter($pages, ["createdYear" => trim($date[0])]);
//var_dump($findPages);
array_push($years, ["year" => $year, "count" => count($findPages)]);
array_push($years, [
"year" => trim($date[0]),
"count" => count($findPages),
]);
}
}
foreach ($years as $year) {
@ -59,8 +73,7 @@ class Sorting
$month = date("m", date($obj["rawCreated"]));
if (!find($sorted, ["month" => $month])) {
$perMonth = filter($pages, [
"createdYear" => $year["year"],
"createdMonth" => $month,
"path" => $year["year"] . "/" . $month,
"deleted" => false,
"published" => true,
"layout" => "page",

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

@ -12,6 +12,7 @@ include "../brain/data/Settings.inc.php";
include "../brain/data/Session.inc.php";
include "../brain/data/Member.inc.php";
include "../brain/data/Auth.inc.php";
include "../brain/data/Render.inc.php";
include "../brain/utility/StringTools.inc.php";
include "../brain/utility/FileUploader.inc.php";
include "../brain/utility/DocTools.inc.php";

Loading…
Cancel
Save