added sitemap and docs

This commit is contained in:
Nick Yeoman 2025-11-07 14:45:13 -08:00
parent fb5407a60b
commit a459b86169
6 changed files with 121 additions and 4 deletions

View File

@ -33,3 +33,23 @@ docker compose up -d
* [Novaconiumm Official Repo](https://git.4lt.ca/4lt/novaconium)
* [CORXN Apache and PHP Container for Novaconium](https://git.4lt.ca/4lt/CORXN)
### How it works
#### htaccess
htaccess ensures that all requests are sent to index.php
#### index.php
index.php does two things:
1. Allows you to turn on error reporting (off by default)
2. Loads the novaconium bootstrap file novaconium.php
#### novaconium.php
What happens here:
1. Autoload composer
1. Loads configurations

View File

@ -40,5 +40,8 @@ $framework_routes = [
'/novaconium/logout' => [
'post' => 'NOVACONIUM/logout',
'get' => 'NOVACONIUM/logout'
]
],
'/novaconium/sitemap.xml' => [
'get' => 'NOVACONIUM/sitemap'
],
];

42
controllers/sitemap.php Normal file
View File

@ -0,0 +1,42 @@
<?php
header('Content-Type: text/xml');
// https://www.sitemaps.org/protocol.html
// Check it here: https://www.mysitemapgenerator.com/service/check.html
$query=<<<EOSQL
SELECT draft, slug, updated, changefreq, priority, path
FROM pages
WHERE priority > 0
AND draft = 0
ORDER BY updated DESC;
EOSQL;
$thepages = $db->getRows($query);
// Start the view
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
// Loop through the pages
if ( ! empty($thepages) ) {
foreach( $thepages as $v) {
$date = (new \DateTime($v['updated']))->format('Y-m-d');
echo "<url>";
if ( empty($v['path']) )
echo "<loc>" . $config['base_url'] . '/page/' . $v['slug'] . "</loc>";
else
echo "<loc>" . $config['base_url'] . $v['path'] . "</loc>";
echo "<lastmod>" . $date . "</lastmod>";
echo "<changefreq>" . $v['changefreq'] . "</changefreq>";
echo "<priority>" . sprintf("%.1f", $v['priority']) . "</priority>";
echo "</url>";
}
} else {
echo "no pages added yet";
}
echo "</urlset>";

52
docs/ConfigurationFile.md Normal file
View File

@ -0,0 +1,52 @@
# Configuration File
## App/config.php
The configuration file holds a php multi dimentional array for configuration.
#### database
This is the connection setting for mariadb.
```
'database' => [
'host' => 'ny-db',
'name' => 'nydb',
'user' => 'nydbu',
'pass' => 'as7!d5fLKJ2DLKJS5',
'port' => 3306
],
```
#### base_url
Defines the url to use
```
'base_url' => 'https://www.nickyeoman.com',
```
#### secure_key
The security key is used to verify admin account and salt encrpytion functions.
You can generate a key with ```pwgen -cnsB1v 64```
but if you don't set one, novaconium will generate one for you to use (you have to explicily set it though).
```
'secure_key' => '',
```
#### logfile
sets the path of the log file.
```
'logfile' => '/logs/novaconium.log',
```
#### loglevel
Sets the logging level for the app.
```
'loglevel' => 'ERROR' // 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'NONE'
```

View File

@ -3,7 +3,7 @@
You can use the logging class to output to a file.
use ```$log->info(The Message');```1
use ```$log->info(The Message');```
Logging levels are:
```
@ -16,4 +16,4 @@ Logging levels are:
It's recommended that production is set to ERROR.
You set the log level in /App/config.php under 'loglevel' => 'ERROR'
If you are using CORXN a health check is run every 30 seconds which would fill the log file with info.

View File

@ -7,7 +7,7 @@ require_once(BASEPATH . '/vendor/autoload.php');
if (file_exists(BASEPATH . '/App/config.php')) {
require_once(BASEPATH . '/App/config.php');
} else {
require_once(FRAMEWORKPATH . '/defaults/App/config.php');
require_once(FRAMEWORKPATH . '/skeleton/novaconium/App/config.php');
}
// Logging