Minor Admin API tweaks, added theme render flag check for one pagers

beta
Ro 3 years ago
commit 85a7eab8be

@ -13,15 +13,39 @@ class SettingsAPI
$task = $args["fourth"]; $task = $args["fourth"];
switch ($task) { switch ($task) {
case "publish": case "publish":
//check settings to see if site is a one pager
$config = new Settings();
$settings = $config->getSettings();
$theme = $settings["global"]["theme"];
$themeConfig = json_decode(
file_get_contents("../content/themes/" . $theme . "/theme.json"),
true
);
//if render flag is set and false, just render index page for one page sites
//otherwise, render all pages according to theme template files
$render = new Render(); $render = new Render();
if (isset($themeConfig["render"])) {
if (!$themeConfig["render"] || $themeConfig["render"] === "false") {
$render->renderIndex();
$result = [
"message" => "Index Rendered. HAND CLAPS",
"type" => "TASK_NONE",
];
} else {
$result = [
"message" => "Site Rendered. GOOD EFFORT",
"type" => "TASK_NONE",
];
}
} else {
$render->renderTags(); $render->renderTags();
$render->renderArchive(); $render->renderArchive();
$render->renderPages(); $render->renderPages();
$result = [ $result = [
"message" => "Site Rendered. GOOD EFFORT", "message" => "Site Rendered. GOOD EFFORT",
"type" => "TASK_NONE", "type" => "TASK_NONE",
]; ];
}
break; break;
case "add-avatar": case "add-avatar":

@ -1,5 +1,6 @@
<?php <?php
use Mni\FrontYAML\Parser; use Mni\FrontYAML\Parser;
use function _\find;
class Render class Render
{ {
@ -212,4 +213,27 @@ class Render
} }
} }
} }
public function renderIndex()
{
$pages = (new Book("../content/pages"))->getContents();
$index = find($pages, ["layout" => "index"]);
$template = $this->theme . "/index.twig";
$location = "../public/index.html";
$dir = null;
$meta = [
"who" => $index["author"],
"when" => $index["created"],
];
$pageOptions = [
"title" => $index["title"],
"background" => $index["feature"],
"meta" => $meta,
];
$html = $this->twig->render($template, $pageOptions);
DocTools::writeHTML($location, $html, $dir);
}
} }

File diff suppressed because one or more lines are too long

@ -150,9 +150,7 @@ class FipamoAdminAPI {
break; break;
} }
this._request( this._request(
this.baseURL this.baseURL ? this.baseURL + url : url,
? this.baseURL + url + "?key=" + this.key
: url + "?key=" + this.key,
TASK_SETTINGS_WRITE, TASK_SETTINGS_WRITE,
REQUEST_TYPE_POST, REQUEST_TYPE_POST,
CONTENT_TYPE_JSON, CONTENT_TYPE_JSON,

Loading…
Cancel
Save