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"];
switch ($task) {
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->renderTags();
$render->renderArchive();
$render->renderPages();
$result = [
"message" => "Site Rendered. GOOD EFFORT",
"type" => "TASK_NONE",
];
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->renderArchive();
$render->renderPages();
$result = [
"message" => "Site Rendered. GOOD EFFORT",
"type" => "TASK_NONE",
];
}
break;
case "add-avatar":

@ -1,5 +1,6 @@
<?php
use Mni\FrontYAML\Parser;
use function _\find;
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;
}
this._request(
this.baseURL
? this.baseURL + url + "?key=" + this.key
: url + "?key=" + this.key,
this.baseURL ? this.baseURL + url : url,
TASK_SETTINGS_WRITE,
REQUEST_TYPE_POST,
CONTENT_TYPE_JSON,

Loading…
Cancel
Save