Slightly better theming support
This commit is contained in:
parent
4a80f51403
commit
2fc2775720
7 changed files with 29 additions and 7 deletions
|
@ -1,2 +1,7 @@
|
|||
RewriteEngine On
|
||||
RewriteRule ^(.*)$ index.php [QSA,L]
|
||||
|
||||
# If the requested file is an asset, serve it directly
|
||||
RewriteCond %{REQUEST_FILENAME} -f
|
||||
RewriteRule ^Theme/[^/]+/Assets/.+$ - [L]
|
||||
|
||||
RewriteRule ^(.+)$ index.php [L,QSA]
|
||||
|
|
|
@ -14,6 +14,7 @@ class AntCMS
|
|||
$start_time = microtime(true);
|
||||
$content = $this->getPage($page);
|
||||
$siteInfo = AntCMS::getSiteInfo();
|
||||
$currentConfig = AntConfig::currentConfig();
|
||||
|
||||
if (!$content || !is_array($content)) {
|
||||
$this->renderException("404");
|
||||
|
@ -31,10 +32,14 @@ class AntCMS
|
|||
$pageTemplate = str_replace('<!--AntCMS-Body-->', $markdown, $pageTemplate);
|
||||
|
||||
$pageTemplate = str_replace('<!--AntCMS-SiteTitle-->', $siteInfo['siteTitle'], $pageTemplate);
|
||||
$pageTemplate = str_replace('<!--AntCMS-SiteLink-->', '//' . $currentConfig['baseURL'], $pageTemplate);
|
||||
|
||||
$end_time = microtime(true);
|
||||
$elapsed_time = round($end_time - $start_time, 4);
|
||||
$pageTemplate = str_replace('<!--AntCMS-Debug-->', '<p>Took ' . $elapsed_time . ' seconds to render the page.', $pageTemplate);
|
||||
|
||||
if($currentConfig['debug']){
|
||||
$pageTemplate = str_replace('<!--AntCMS-Debug-->', '<p>Took ' . $elapsed_time . ' seconds to render the page. </p>', $pageTemplate);
|
||||
}
|
||||
|
||||
echo $pageTemplate;
|
||||
exit;
|
||||
|
@ -79,7 +84,8 @@ class AntCMS
|
|||
|
||||
public function getThemeContent()
|
||||
{
|
||||
$themePath = AntDir . "/Theme/default_layout.html";
|
||||
$currentConfig = AntConfig::currentConfig();
|
||||
$themePath = antThemePath . '/' . $currentConfig['activeTheme'] . "/default_layout.html";
|
||||
$themeContent = file_get_contents($themePath);
|
||||
|
||||
if (!$themeContent) {
|
||||
|
|
|
@ -13,7 +13,7 @@ class AntConfig
|
|||
'siteTitle' => 'AntCMS',
|
||||
),
|
||||
'forceHTTPS' => true,
|
||||
'activeTheme' => 'default',
|
||||
'activeTheme' => 'Default',
|
||||
'generateKeywords' => true,
|
||||
'enableCache' => true,
|
||||
'admin' => array(
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace AntCMS;
|
||||
|
||||
use AntCMS\AntCache;
|
||||
use AntCMS\AntConfig;
|
||||
|
||||
class AntKeywords
|
||||
{
|
||||
|
@ -10,6 +11,11 @@ class AntKeywords
|
|||
{
|
||||
$cache = new AntCache();
|
||||
$cacheKey = hash('sha3-512', $content).'keywords';
|
||||
$currentConfig = AntConfig::currentConfig();
|
||||
|
||||
if(!$currentConfig['generateKeywords']){
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($cache->isCached($cacheKey)) {
|
||||
$cachedKeywords = $cache->getCache($cacheKey);
|
||||
|
|
|
@ -28,6 +28,7 @@ class AntPages
|
|||
'pageTitle' => $pageHeader['title'],
|
||||
'fullPagePath' => $page,
|
||||
'functionalPagePath' => $pageFunctionalPath,
|
||||
'showInNav' => true,
|
||||
);
|
||||
$pageList[] = $currentPage;
|
||||
}
|
||||
|
@ -49,7 +50,10 @@ class AntPages
|
|||
</li>';
|
||||
$navHTML = '';
|
||||
foreach (AntPages::getPages() as $page) {
|
||||
$url = $_SERVER['REQUEST_SCHEME'] . "://" . str_replace('//', '/',$baseURL . $page['functionalPagePath']);
|
||||
if(!$page['showInNav']){
|
||||
continue;
|
||||
}
|
||||
$url = "//" . str_replace('//', '/',$baseURL . $page['functionalPagePath']);
|
||||
$navEntry = str_replace('<!--AntCMS-PageLink-->', $url, $navTemplate);
|
||||
$navEntry = str_replace('<!--AntCMS-PageTitle-->', $page['pageTitle'], $navEntry);
|
||||
$navHTML .= $navEntry;
|
||||
|
|
|
@ -5,9 +5,10 @@ ini_set('display_errors', '1');
|
|||
|
||||
const AntDir = __DIR__;
|
||||
const AntCachePath = __DIR__ . '/Cache';
|
||||
const antConfigFile = __DIR__ . '/config.ymal';
|
||||
const antPagesList = __DIR__ . '/pages.ymal';
|
||||
const antConfigFile = __DIR__ . '/config.yaml';
|
||||
const antPagesList = __DIR__ . '/pages.yaml';
|
||||
const antContentPath = __DIR__ . '/Content';
|
||||
const antThemePath = __DIR__ . '/Themes';
|
||||
require_once __DIR__ . '/Vendor/autoload.php';
|
||||
require_once __DIR__ . '/Autoload.php';
|
||||
|
||||
|
|
Loading…
Reference in a new issue