Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9feccf9eaa | |||
| 14ec6b7e7a | |||
| 42a828a778 | |||
| 81c239f043 | |||
| 0d91b61bd0 | |||
| fd9a71c4d6 |
@@ -10,6 +10,8 @@ $config = [
|
||||
'base_url' => 'http://localhost:8000',
|
||||
'secure_key' => '', //64 alphanumeric characters
|
||||
'logfile' => '/logs/novaconium.log',
|
||||
'loglevel' => 'ERROR', // 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'NONE'
|
||||
'loglevel' => 'ERROR', // 'DEBUG', 'INFO', 'WARNING', 'ERROR', 'NONE',
|
||||
'matomo_url' => 'matomo.4lt.ca',
|
||||
'matomo_id' => '0',
|
||||
'fonts' => 'https://fonts.googleapis.com/css2?family=VT323:wght@400&family=Fira+Code:wght@400;500&display=swap&family=Material+Icons:wght@400;500&display=swap'
|
||||
];
|
||||
|
||||
33
skeleton/novaconium/App/controllers/page.php
Normal file
33
skeleton/novaconium/App/controllers/page.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
$slug = $router->parameters['slug'];
|
||||
$query=<<<EOSQL
|
||||
SELECT
|
||||
id,
|
||||
title,
|
||||
heading,
|
||||
description,
|
||||
keywords,
|
||||
author,
|
||||
body,
|
||||
created,
|
||||
updated
|
||||
FROM pages
|
||||
WHERE slug = '$slug'
|
||||
EOSQL;
|
||||
|
||||
//$db->debugGetRow($query);
|
||||
$data = $db->getRow($query);
|
||||
if(!$data) {
|
||||
http_response_code('404');
|
||||
header("Content-Type: text/html");
|
||||
view('404');
|
||||
exit;
|
||||
}
|
||||
|
||||
$data = array_merge($data, [
|
||||
'menuActive' => 'blog',
|
||||
'pageid' => 'page',
|
||||
'permissionsGroup' => $session->get('group')
|
||||
]);
|
||||
|
||||
view('page', $data);
|
||||
@@ -8,5 +8,8 @@ $routes = [
|
||||
],
|
||||
'/humans.txt' => [
|
||||
'get' => 'humans'
|
||||
],
|
||||
'/page/{slug}' => [
|
||||
'get' => 'page'
|
||||
]
|
||||
];
|
||||
11
skeleton/novaconium/App/views/page.html.twig
Normal file
11
skeleton/novaconium/App/views/page.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends '@novaconium/master.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>{{ title }}</h1>
|
||||
<div class="page-meta">
|
||||
{% if updated is not empty %}
|
||||
<span class="page-updated">Last Updated: {{ updated | date("M\\. jS Y \\a\\t g:ia") }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
{{ body | raw}}
|
||||
{% endblock %}
|
||||
185
skeleton/novaconium/public/js/tabs.js
Normal file
185
skeleton/novaconium/public/js/tabs.js
Normal file
@@ -0,0 +1,185 @@
|
||||
// /js/tabs.js
|
||||
|
||||
// Tab switching
|
||||
function switchTab(tabId, button) {
|
||||
const contents = document.querySelectorAll('.tab-content');
|
||||
contents.forEach(content => content.classList.remove('active'));
|
||||
|
||||
const buttons = document.querySelectorAll('.tab-button');
|
||||
buttons.forEach(b => b.classList.remove('active'));
|
||||
|
||||
document.getElementById(tabId).classList.add('active');
|
||||
button.classList.add('active');
|
||||
|
||||
if (tabId === 'content6') {
|
||||
setTimeout(initTags, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Tags Init (with custom dropdown autocomplete)
|
||||
let tagsListeners = [];
|
||||
|
||||
function initTags() {
|
||||
const tagsInput = document.getElementById('tags-input');
|
||||
const tagsField = document.getElementById('tags');
|
||||
const hiddenTags = document.getElementById('tags_json');
|
||||
const dropdown = document.getElementById('tags-dropdown');
|
||||
|
||||
if (!tagsInput || !tagsField || !hiddenTags || !dropdown) {
|
||||
console.warn('Tags elements missing');
|
||||
return;
|
||||
}
|
||||
|
||||
// Remove old listeners
|
||||
tagsListeners.forEach(ls => ls());
|
||||
tagsListeners = [];
|
||||
|
||||
let tags = [];
|
||||
let existingTags = [];
|
||||
try {
|
||||
tags = JSON.parse(tagsInput.dataset.tags || '[]');
|
||||
existingTags = JSON.parse(tagsInput.dataset.existingTags || '[]');
|
||||
} catch (e) {
|
||||
console.warn('JSON error:', e);
|
||||
}
|
||||
|
||||
let selectedIndex = -1;
|
||||
|
||||
function renderTags() {
|
||||
tagsInput.innerHTML = '';
|
||||
tags.forEach((tag, index) => {
|
||||
const chip = document.createElement('span');
|
||||
chip.className = 'tag-chip';
|
||||
chip.innerHTML = `${tag} <button type="button" class="tag-remove">×</button>`;
|
||||
chip.querySelector('.tag-remove').onclick = () => {
|
||||
tags.splice(index, 1);
|
||||
renderTags();
|
||||
hiddenTags.value = JSON.stringify(tags);
|
||||
};
|
||||
tagsInput.appendChild(chip);
|
||||
});
|
||||
tagsInput.appendChild(tagsField);
|
||||
tagsInput.appendChild(dropdown);
|
||||
hiddenTags.value = JSON.stringify(tags);
|
||||
}
|
||||
|
||||
function updateDropdown() {
|
||||
const value = tagsField.value.toLowerCase().trim();
|
||||
dropdown.innerHTML = '';
|
||||
dropdown.setAttribute('aria-expanded', value ? 'true' : 'false');
|
||||
selectedIndex = -1;
|
||||
|
||||
if (!value) return;
|
||||
|
||||
const matches = existingTags
|
||||
.filter(tag => tag.toLowerCase().startsWith(value) && !tags.includes(tag.toLowerCase()))
|
||||
.slice(0, 10);
|
||||
|
||||
matches.forEach((tag, index) => {
|
||||
const li = document.createElement('li');
|
||||
li.textContent = tag;
|
||||
li.setAttribute('role', 'option');
|
||||
li.onclick = () => selectTag(tag);
|
||||
li.onmouseover = () => { selectedIndex = index; updateHighlight(); };
|
||||
dropdown.appendChild(li);
|
||||
});
|
||||
|
||||
if (matches.length) dropdown.parentElement.classList.add('has-dropdown');
|
||||
else dropdown.parentElement.classList.remove('has-dropdown');
|
||||
}
|
||||
|
||||
function updateHighlight() {
|
||||
dropdown.querySelectorAll('li').forEach((li, index) => {
|
||||
li.classList.toggle('selected', index === selectedIndex);
|
||||
});
|
||||
}
|
||||
|
||||
function selectTag(tag) {
|
||||
addTag(tag, true);
|
||||
tagsField.value = '';
|
||||
dropdown.setAttribute('aria-expanded', 'false');
|
||||
}
|
||||
|
||||
function addTag(inputValue, refocus = false) {
|
||||
const tag = inputValue.trim().toLowerCase().replace(/[^\w-]/g, '');
|
||||
if (tag && tag.length > 0 && tag.length <= 50 && !tags.includes(tag)) {
|
||||
tags.push(tag);
|
||||
renderTags();
|
||||
if (refocus) tagsField.focus();
|
||||
}
|
||||
tagsField.value = '';
|
||||
updateDropdown();
|
||||
}
|
||||
|
||||
const keydownListener = (e) => {
|
||||
if (dropdown.getAttribute('aria-expanded') === 'true') {
|
||||
if (e.key === 'ArrowDown') {
|
||||
e.preventDefault();
|
||||
selectedIndex = Math.min(selectedIndex + 1, dropdown.querySelectorAll('li').length - 1);
|
||||
updateHighlight();
|
||||
dropdown.querySelector(`li:nth-child(${selectedIndex + 1})`)?.scrollIntoView({ block: 'nearest' });
|
||||
} else if (e.key === 'ArrowUp') {
|
||||
e.preventDefault();
|
||||
selectedIndex = Math.max(selectedIndex - 1, 0);
|
||||
updateHighlight();
|
||||
dropdown.querySelector(`li:nth-child(${selectedIndex + 1})`)?.scrollIntoView({ block: 'nearest' });
|
||||
} else if ((e.key === 'Enter' || e.key === 'Tab') && selectedIndex >= 0) {
|
||||
e.preventDefault();
|
||||
const selected = dropdown.querySelector(`li:nth-child(${selectedIndex + 1})`)?.textContent;
|
||||
if (selected) selectTag(selected);
|
||||
} else if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
tagsField.blur();
|
||||
}
|
||||
}
|
||||
|
||||
if (!dropdown.getAttribute('aria-expanded') === 'true' || selectedIndex < 0) {
|
||||
if (e.key === 'Enter' || e.key === ',') {
|
||||
e.preventDefault();
|
||||
addTag(tagsField.value, true);
|
||||
} else if (e.key === 'Tab') {
|
||||
e.preventDefault();
|
||||
if (tagsField.value.trim()) addTag(tagsField.value, true);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
tagsField.addEventListener('keydown', keydownListener);
|
||||
tagsListeners.push(() => tagsField.removeEventListener('keydown', keydownListener));
|
||||
|
||||
const inputListener = () => updateDropdown();
|
||||
tagsField.addEventListener('input', inputListener);
|
||||
tagsListeners.push(() => tagsField.removeEventListener('input', inputListener));
|
||||
|
||||
const blurListener = () => {
|
||||
setTimeout(() => dropdown.setAttribute('aria-expanded', 'false'), 150);
|
||||
if (tagsField.value.trim()) addTag(tagsField.value);
|
||||
};
|
||||
tagsField.addEventListener('blur', blurListener);
|
||||
tagsListeners.push(() => tagsField.removeEventListener('blur', blurListener));
|
||||
|
||||
renderTags();
|
||||
}
|
||||
|
||||
// Init on load and observe tab changes
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const tagsTab = document.getElementById('content6');
|
||||
if (tagsTab?.classList.contains('active')) {
|
||||
initTags();
|
||||
}
|
||||
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
||||
const target = mutation.target;
|
||||
if (target.id === 'content6' && target.classList.contains('active')) {
|
||||
initTags();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
observer.observe(document.body, { subtree: true, attributes: true });
|
||||
});
|
||||
|
||||
// Export switchTab for external use if needed
|
||||
window.switchTab = switchTab;
|
||||
@@ -17,6 +17,8 @@ $log = new Logger(\BASEPATH . $config['logfile'], $config['loglevel']);
|
||||
// --- Twig Data Array ---
|
||||
$data = [];
|
||||
$data['fonts'] = $config['fonts'] ?? [];
|
||||
$data['matomo_url'] = $config['matomo_url'] ?? '';
|
||||
$data['matomo_id'] = $config['matomo_id'] ?? '0';
|
||||
|
||||
// --- Session ---
|
||||
use Novaconium\Session;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<html class="no-js" lang="en">
|
||||
|
||||
<head>
|
||||
{% include ['@override/head.html.twig', '@novaconium/head.html.twig'] %}
|
||||
{% include ['@novaconium/cp/head.html.twig'] %}
|
||||
</head>
|
||||
|
||||
<body id="{{ pageid | default('pageid') }}" class="{{ pageclass | default('pageclass') }}" >
|
||||
@@ -27,13 +27,13 @@
|
||||
<footer>
|
||||
<div class="copyright">© {{ 'now' | date('Y') }} Novaconium</div>
|
||||
</footer>
|
||||
|
||||
{% include '@novaconium/javascript/page-edit.html.twig' %}
|
||||
|
||||
{% if editor == 'ace' %}
|
||||
{% include '@novaconium/javascript/ace.html.twig' %}
|
||||
{% include '@novaconium/javascript/page-edit.html.twig' %}
|
||||
{% include '@novaconium/javascript/ace.html.twig' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if debug is not empty %}
|
||||
<div id="debug">
|
||||
<h2>Debugging Information</h2>
|
||||
|
||||
60
twig/cp/head.html.twig
Normal file
60
twig/cp/head.html.twig
Normal file
@@ -0,0 +1,60 @@
|
||||
{# =============================================================================
|
||||
<HEAD>
|
||||
=============================================================================
|
||||
#}
|
||||
|
||||
<meta charset="utf-8">
|
||||
|
||||
<title>{{ title | default('Welcome To Novaconium') }}</title>
|
||||
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{# SEO & METADATA #}
|
||||
<meta name="generator" content="Novaconium" />
|
||||
<meta name="description" content="{{ description | default('No description given') }}">
|
||||
<meta name="keywords" content="{{ keywords | default('website') }}">
|
||||
<meta name="author" content="{{ author | default('anonymous') }}">
|
||||
|
||||
{# DARK MODE & THEME HINTS #}
|
||||
<meta name="color-scheme" content="dark">
|
||||
<meta name="theme-color" content="#000000">
|
||||
|
||||
{# OPEN GRAPH (OG) FOR SOCIAL SHARING #}
|
||||
<meta property="og:title" content="{{ title | default('Welcome') }}">
|
||||
<meta property="og:type" content="website">
|
||||
<meta property="og:url" content="{{ app_url | default(request.scheme ~ '://' ~ request.host) }}">
|
||||
<meta property="og:image" content="{{ og_image | default('/icon.png') }}">
|
||||
|
||||
{# PWA & FAVICONS #}
|
||||
<link rel="manifest" href="site.webmanifest">
|
||||
<link rel="apple-touch-icon" href="/icon.png">
|
||||
<link rel="icon" type="image/x-icon" href="/favicon.ico">
|
||||
|
||||
{# GOOGLE FONTS (CDN VIA PRECONNECT) #}
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link
|
||||
href="{{ fonts | default('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&family=Roboto+Mono&family=Source+Code+Pro&family=Lato&family=Poppins&family=Material+Icons&family=Material+Icons+Outlined&family=VT323:wght@400&family=Fira+Code:wght@400;500&display=swap') }}"
|
||||
rel="stylesheet"
|
||||
>
|
||||
|
||||
{% if editor == 'ace' %}
|
||||
<!-- ACE Editor -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ace.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ace.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/mode-html.min.js"></script> {# HTML syntax #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/theme-tomorrow_night.min.js"></script> {# Dark theme #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ext-language_tools.min.js"></script> {# Autocomplete #}
|
||||
<!-- END ACE Editor -->
|
||||
{% endif %}
|
||||
|
||||
{# highlight.js #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
<script>hljs.highlightAll();</script>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/default.min.css">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/ir-black.min.css">
|
||||
|
||||
<script src="/js/tabs.js"></script>
|
||||
|
||||
{# STYLESHEET #}
|
||||
<link rel="stylesheet" href="/css/novaconium.css">
|
||||
@@ -1,11 +1,5 @@
|
||||
<!--
|
||||
What goes very last on the page.
|
||||
right before the /body
|
||||
like javascript
|
||||
or analytics
|
||||
such as javascript
|
||||
-->
|
||||
{% include '@novaconium/javascript/page-edit.html.twig' %}
|
||||
|
||||
{% if editor == 'ace' %}
|
||||
{% include '@novaconium/javascript/ace.html.twig' %}
|
||||
{% endif %}
|
||||
|
||||
@@ -39,22 +39,7 @@
|
||||
>
|
||||
|
||||
{# STYLESHEET #}
|
||||
{% if pageclass == "novaconium" %}
|
||||
<link rel="stylesheet" href="/css/novaconium.css">
|
||||
{% else %}
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% if editor == 'ace' %}
|
||||
<!-- ACE Editor -->
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ace.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ace.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/mode-html.min.js"></script> {# HTML syntax #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/theme-tomorrow_night.min.js"></script> {# Dark theme #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.35.2/ext-language_tools.min.js"></script> {# Autocomplete #}
|
||||
<!-- END ACE Editor -->
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="/css/main.css">
|
||||
|
||||
{# highlight.js #}
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
|
||||
|
||||
@@ -60,4 +60,32 @@
|
||||
{% endif %}
|
||||
|
||||
{% include ['@override/foot.html.twig', '@novaconium/foot.html.twig'] %}
|
||||
{% if matomo_id > 0 %}
|
||||
<!-- Matomo -->
|
||||
<script>
|
||||
var _paq = window._paq = window._paq || [];
|
||||
|
||||
{% if is_404 %}
|
||||
_paq.push([
|
||||
'setDocumentTitle',
|
||||
'404 / Not Found - ' + document.location.pathname
|
||||
]);
|
||||
{% endif %}
|
||||
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
|
||||
(function() {
|
||||
var u = "//{{ matomo_url|trim('/') }}/";
|
||||
_paq.push(['setTrackerUrl', u + 'matomo.php']);
|
||||
_paq.push(['setSiteId', {{ matomo_id }}]);
|
||||
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
|
||||
g.async = true;
|
||||
g.src = u + 'matomo.js';
|
||||
s.parentNode.insertBefore(g, s);
|
||||
})();
|
||||
</script>
|
||||
<!-- End Matomo Code -->
|
||||
{% endif %}
|
||||
|
||||
</body></html>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{% set is_404 = status_code is defined and status_code == 404 %}
|
||||
{% extends '@novaconium/master.html.twig' %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -13,4 +13,17 @@
|
||||
<textarea id="body" name="body" rows="10" style="display: none;">{{ rows.body|default('')|e('html') }}</textarea>
|
||||
<div id="body-editor" class="ace-editor"></div> {# Ace mounts here #}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="draft">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="draft"
|
||||
name="draft"
|
||||
value="1"
|
||||
{% if rows.draft|default(false) %}checked{% endif %}
|
||||
>
|
||||
Save as draft
|
||||
</label>
|
||||
</div>
|
||||
Reference in New Issue
Block a user