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

pull/84/head
Ro 3 years ago
parent 183a620b1e
commit 734c6d36f1

@ -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();
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