forked from projects/fipamo
Admin API tweaks, added check for theme render flag for one pagers
This commit is contained in:
parent
183a620b1e
commit
734c6d36f1
4 changed files with 59 additions and 13 deletions
|
@ -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();
|
||||||
$render->renderTags();
|
if (isset($themeConfig["render"])) {
|
||||||
$render->renderArchive();
|
if (!$themeConfig["render"] || $themeConfig["render"] === "false") {
|
||||||
$render->renderPages();
|
$render->renderIndex();
|
||||||
|
$result = [
|
||||||
|
"message" => "Index Rendered. HAND CLAPS",
|
||||||
|
"type" => "TASK_NONE",
|
||||||
|
];
|
||||||
|
} else {
|
||||||
$result = [
|
$result = [
|
||||||
"message" => "Site Rendered. GOOD EFFORT",
|
"message" => "Site Rendered. GOOD EFFORT",
|
||||||
"type" => "TASK_NONE",
|
"type" => "TASK_NONE",
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$render->renderTags();
|
||||||
|
$render->renderArchive();
|
||||||
|
$render->renderPages();
|
||||||
|
$result = [
|
||||||
|
"message" => "Site Rendered. GOOD EFFORT",
|
||||||
|
"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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
4
public/assets/scripts/dash.min.js
vendored
4
public/assets/scripts/dash.min.js
vendored
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…
Reference in a new issue