Started creating templates for the admin plugin

Also, replaced the old <!--AntCMS-SiteLink--> with a new filter called absUrl, which can be used to convert any link to an absolute URL by adding the base site URL
This commit is contained in:
Belle Aerni 2023-02-12 17:02:07 -08:00
parent 94f251fc3f
commit 25e1ef9434
8 changed files with 66 additions and 26 deletions

View file

@ -58,9 +58,7 @@ class AntCMS
$pageTemplate = self::getThemeTemplate('default_layout', $theme);
$pageTemplate = str_replace('<!--AntCMS-Navigation-->', AntPages::generateNavigation(self::getThemeTemplate('nav_layout', $theme), $currentPage), $pageTemplate);
$pageTemplate = str_replace('<!--AntCMS-SiteTitle-->', $siteInfo['siteTitle'], $pageTemplate);
return str_replace('<!--AntCMS-SiteLink-->', '//' . AntConfig::currentConfig('baseURL'), $pageTemplate);
return $pageTemplate = str_replace('<!--AntCMS-SiteTitle-->', $siteInfo['siteTitle'], $pageTemplate);
}
/**

View file

@ -3,6 +3,7 @@
namespace AntCMS;
use AntCMS\AntConfig;
use AntCMS\AntTwigFilters;
class AntTwig
{
@ -30,6 +31,8 @@ class AntTwig
'debug' => AntConfig::currentConfig('debug'),
]);
$twigEnvironment->addExtension(new \AntCMS\AntTwigFilters);
return $twigEnvironment->render($content, $params);
}
}

View file

@ -0,0 +1,23 @@
<?php
namespace AntCMS;
use Twig\Extension\AbstractExtension;
use Twig\TwigFilter;
use AntCMS\AntTools;
use AntCMS\AntConfig;
class AntTwigFilters extends AbstractExtension
{
public function getFilters()
{
return [
new TwigFilter('absUrl', [$this, 'absUrl']),
];
}
public function absUrl(string $relative): string
{
return '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . '/' . $relative);
}
}

View file

@ -16,7 +16,7 @@ AntCMS simplifies the often complex and tedious task of SEO, making it effortles
AntCMS streamlines SEO with the following features:
- Automated generation of a sitemap, allowing search engines to easily index all of your content.
- Automated management of the sitemap.txt file, linking to the generated sitemap and specifying which content should not be crawled.
- Automated management of the robots.txt file, linking to the generated sitemap and specifying which content should not be crawled.
- Exceptional speed and minimal file size.
- Default themes that are optimized for both desktop and mobile devices.
- Simple customization of important metadata such as the title, description, author, and keywords for your content.
@ -126,7 +126,7 @@ Task lists:
Emoji support! :joy:
And finally.. emeded content, by putting a URL on a line of it's own, the content will automatically be embeded in the page.
And finally.. embedded content, by putting a URL on a line of it's own, the content will automatically be embeded in the page.
Note: support depends on what site the content is on, but AntCMS will always fallback to a regular link
https://www.youtube.com/watch?v=dQw4w9WgXcQ

View file

@ -204,7 +204,7 @@ class AdminPlugin extends AntPlugin
if (file_exists($pagePath) && unlink($pagePath)) {
AntYaml::saveFile(antPagesList, $pages);
}
header('Location: //' . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/");
break;
@ -223,24 +223,15 @@ class AdminPlugin extends AntPlugin
break;
default:
$HTMLTemplate = "<h1>Page Management</h1>\n";
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/regenerate'>Click here to regenerate the page list</a><br>\n";
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/create'>Click here to create a new page</a><br>\n";
$HTMLTemplate .= "<ul>\n";
foreach ($pages as $page) {
$HTMLTemplate .= "<li>\n";
$HTMLTemplate .= "<h2>" . $page['pageTitle'] . "</h2>\n";
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/edit" . $page['functionalPagePath'] . "'>Edit this page</a><br>\n";
$HTMLTemplate .= "<a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/delete" . $page['functionalPagePath'] . "'>Delete this page</a><br>\n";
$HTMLTemplate .= "<ul>\n";
$HTMLTemplate .= "<li>Full page path: " . $page['fullPagePath'] . "</li>\n";
$HTMLTemplate .= "<li>Functional page path: " . $page['functionalPagePath'] . "</li>\n";
$HTMLTemplate .= "<li>Show in navbar: <a href='//" . AntConfig::currentConfig('baseURL') . "plugin/admin/pages/togglevisibility" . $page['functionalPagePath'] . "'>" . $this->boolToWord($page['showInNav']) . "</a></li><br>\n";
$HTMLTemplate .= "</ul>\n";
$HTMLTemplate .= "</li>\n";
$HTMLTemplate = $antCMS->getThemeTemplate('admin_manage_pages_layout');
foreach ($pages as $key => $page) {
$pages[$key]['editurl'] = '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . "/plugin/admin/pages/edit/" . $page['functionalPagePath']);
$pages[$key]['deleteurl'] = '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . "/plugin/admin/pages/delete/" . $page['functionalPagePath']);
$pages[$key]['togglevisibility'] = '//' . AntTools::repairURL(AntConfig::currentConfig('baseURL') . "/plugin/admin/pages/togglevisibility/" . $page['functionalPagePath']);
$pages[$key]['isvisable'] = $this->boolToWord($page['showInNav']);
}
$HTMLTemplate .= "</ul>\n";
$params['pages'] = $pages;
$HTMLTemplate = AntTwig::renderWithTiwg($HTMLTemplate, $params);
}
$params['AntCMSBody'] = $HTMLTemplate;

View file

@ -21,7 +21,7 @@
<!-- Navigation -->
<nav class="navbar navbar-expand-lg">
<div class="container-fluid">
<a class="navbar-brand" href="<!--AntCMS-SiteLink-->"><!--AntCMS-SiteTitle--></a>
<a class="navbar-brand" href="{{ ""|absUrl }}"><!--AntCMS-SiteTitle--></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

View file

@ -0,0 +1,25 @@
<h1>Page Management</h1>
<a href="{{ "plugin/admin/"|absUrl }}">Back</a> |
<a href="{{ "plugin/admin/pages/regenerate/"|absUrl }}">Regenerate Page List</a> |
<a href="{{ "plugin/admin/pages/create/"|absUrl }}">Create New Page</a>
<table>
<tr>
<th>Page Title</th>
<th>Full Page Path</th>
<th>Functional Page Path</th>
<th>Show in Navbar</th>
<th>Actions</th>
</tr>
{% for page in pages %}
<tr>
<td>{{ page.pageTitle }}</td>
<td>{{ page.fullPagePath }}</td>
<td>{{ page.functionalPagePath }}</td>
<td><a href='{{ page.togglevisibility }}'>{{ page.isvisable }}</a></td>
<td>
<a href="{{ page.editurl }}">Edit Page</a> |
<a href="{{ page.deleteurl }}">Delete Page</a>
</td>
</tr>
{% endfor %}
</table>

View file

@ -8,7 +8,7 @@
<meta name="author" content="{{ AntCMSAuthor }}">
<meta name="keywords" content="{{ AntCMSKeywords }}">
<link href="<!--AntCMS-SiteLink-->Themes/Default/Assets/Dist/tailwind.css" rel="stylesheet">
<link href="{{ "Themes/Default/Assets/Dist/tailwind.css"|absUrl }}" rel="stylesheet">
<title>{{ AntCMSTitle }}</title>
</head>
@ -17,7 +17,7 @@
<!-- Navigation -->
<nav class="p-3 border-gray-200 bg-gray-100 dark:bg-zinc-900 dark:border-gray-700">
<div class="container flex flex-wrap items-center justify-between mx-auto">
<a href="<!--AntCMS-SiteLink-->" class="flex items-center">
<a href="{{ ""|absUrl }}" class="flex items-center">
<span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white"><!--AntCMS-SiteTitle--></span>
</a>
<button data-collapse-toggle="navbar-solid-bg" type="button"