404 fixes and added pure twig

This commit is contained in:
Nick Yeoman 2025-11-13 11:05:55 -08:00
parent 1cdf4f1fe8
commit 6d7a7a5e9d
8 changed files with 324 additions and 16 deletions

View File

@ -44,4 +44,7 @@ $framework_routes = [
'/novaconium/sitemap.xml' => [ '/novaconium/sitemap.xml' => [
'get' => 'NOVACONIUM/sitemap' 'get' => 'NOVACONIUM/sitemap'
], ],
'/novaconium/sample/{slug}' => [
'get' => 'NOVACONIUM/samples'
],
]; ];

4
controllers/404.php Normal file
View File

@ -0,0 +1,4 @@
<?php
http_response_code('404');
header("Content-Type: text/html");
view('@novacore/404');

34
controllers/samples.php Normal file
View File

@ -0,0 +1,34 @@
<?php
/**
* Pure Twig, no db example
*
* Replicate Hugo but with html and twig (not markdown)
**/
// Variables
$pt = '@novacore/samples'; //Define the view directory
//$pt = 'samples'; //drop the core for your project
//Grab the slug
$slug = $router->parameters['slug'];
//build path
$tmpl = $pt . '/' . $slug;
//Check if file exits
$baseDir = (strpos($pt, 'novacore') !== false) ? FRAMEWORKPATH : BASEPATH;
if (strpos($pt, '@novacore') !== false) {
$baseDir = str_replace('@novacore', FRAMEWORKPATH . '/views', $pt);
} else {
$baseDir = str_replace('@novacore', BASEPATH . '/views', $pt);
}
$possibleFile = $baseDir . '/' . $slug . '.html.twig'; // add .twig extension if needed
if (is_file($possibleFile) && is_readable($possibleFile)) {
view($tmpl, $data);
} else {
http_response_code('404');
header("Content-Type: text/html");
view('@novacore/404');
}

6
docs/404.md Normal file
View File

@ -0,0 +1,6 @@
# 404 Page
404 page is created like any other page.
Create a 404.php in your controllers and a 404.html.twig in your views.
anytime a resource is not found by the router, it will default to this controller.
if you do not have this controller in your app, it will default to the novaconium 404 page.

View File

@ -1,15 +0,0 @@
<?php
// Define our status code and message
$status_code = 404;
$status_message = 'The requested resource could not be found.';
// Set the HTTP response code and message
http_response_code($status_code);
header("Content-Type: text/html");
?>
<h1>Error 404 Resource Not found</h1>
<p><?php echo $status_message; ?></p>
<p style="font-size:10px; margin-top:60px">Novaconium Default 404 page.</p>

View File

@ -121,7 +121,7 @@ class Router {
if (file_exists(BASEPATH . '/App/controllers/404.php')) { if (file_exists(BASEPATH . '/App/controllers/404.php')) {
return BASEPATH . '/App/controllers/404.php'; return BASEPATH . '/App/controllers/404.php';
} else { } else {
return FRAMEWORKPATH . '/defaults/App/controllers/404.php'; return FRAMEWORKPATH . '/controllers/404.php';
} }
} }
} }

7
views/404.html.twig Normal file
View File

@ -0,0 +1,7 @@
{% extends '@novaconium/master.html.twig' %}
{% block content %}
<h1>404 File Not Found</h1>
<p style="font-size:10px; margin-top:60px">Novaconium Default 404 page.</p>
<p><a href="/">Return Home</a></p>
{% endblock %}

View File

@ -0,0 +1,269 @@
{% extends '@novaconium/master.html.twig' %}
{% set title = "Basic HTML Elements" %}
{% set description = "This is the basic html page from hugo" %}
{% set keywords = "my,keywords,go,here" %}
{% set author = "Mike Hunt" %}
{% block content %}
<article class="post">
<header class="post__header">
<h1 class="post__title">{{ title }}</h1>
<div class="post__meta meta">
<div class="meta__item-datetime meta__item">
<svg class="meta__icon icon icon-time" width="16" height="14" viewBox="0 0 30 28"><path d="M15 0a14 14 0 1 1 0 28 1 1 0 0 1 0-28m0 3a3 3 0 1 0 0 22 3 3 0 0 0 0-22m1 4h-2v8.4l6.8 4.4L22 18l-6-3.8z"></path></svg><time class="meta__text" datetime="2018-04-16T00:00:00Z">April 16, 2018</time></div><div class="meta__item-categories meta__item"><svg class="meta__icon icon icon-category" width="16" height="16" viewBox="0 0 16 16"><path d="m7 2 1 2h8v11H0V2z"></path></svg><span class="meta__text"><a class="meta__link" href="/categories/development/" rel="category">Development</a>
</span>
</div></div>
</header>
<div class="content post__content clearfix">
<p>The main purpose of this article is to make sure that all basic HTML Elements are decorated with CSS so as to not miss any possible elements when creating new themes for Hugo.</p>
<h2 id="headings">Headings</h2>
<p>Lets start with all possible headings. The HTML <code>&lt;h1&gt;</code>—<code>&lt;h6&gt;</code> elements represent six levels of section headings. <code>&lt;h1&gt;</code> is the highest section level and <code>&lt;h6&gt;</code> is the lowest.</p>
<h1 id="heading-1">Heading 1</h1>
<h2 id="heading-2">Heading 2</h2>
<h3 id="heading-3">Heading 3</h3>
<h4 id="heading-4">Heading 4</h4>
<h5 id="heading-5">Heading 5</h5>
<h6 id="heading-6">Heading 6</h6>
<hr>
<h2 id="paragraph">Paragraph</h2>
<p>According to the <a href="https://www.w3.org/TR/html5/dom.html#elements">HTML5 specification</a> by <a href="https://www.w3.org/">W3C</a>, <strong>HTML documents consist of a tree of elements and text</strong>. Each element is denoted in the source by a <a href="https://www.w3.org/TR/html5/syntax.html#syntax-start-tags">start tag</a>, such as <code>&lt;body&gt;</code>, and an <a href="https://www.w3.org/TR/html5/syntax.html#syntax-end-tags">end tag</a>, such as <code>&lt;/body&gt;</code>. (<em>Certain start tags and end tags can in certain cases be omitted and are implied by other tags.</em>)</p>
<p>Elements can have attributes, which control how the elements work. For example, hyperlink are formed using the <code>a</code> element and its <code>href</code> attribute.</p>
<h2 id="list-types">List Types</h2>
<h3 id="ordered-list">Ordered List</h3>
<ol>
<li>First item</li>
<li>Second item</li>
<li>Third item</li>
</ol>
<h3 id="unordered-list">Unordered List</h3>
<ul>
<li>List item</li>
<li>Another item</li>
<li>And another item</li>
</ul>
<h3 id="nested-list">Nested list</h3>
<ul>
<li>First item</li>
<li>Second item
<ul>
<li>Second item First subitem</li>
<li>Second item second subitem
<ul>
<li>Second item Second subitem First sub-subitem</li>
<li>Second item Second subitem Second sub-subitem</li>
<li>Second item Second subitem Third sub-subitem</li>
</ul>
</li>
<li>Second item Third subitem
<ol>
<li>Second item Third subitem First sub-subitem</li>
<li>Second item Third subitem Second sub-subitem</li>
<li>Second item Third subitem Third sub-subitem</li>
</ol>
</li></ul>
</li>
<li>Third item</li>
</ul>
<h3 id="definition-list">Definition List</h3>
<p>HTML also supports definition lists.</p>
<dl>
<dt>Blanco tequila</dt>
<dd>The purest form of the blue agave spirit...</dd>
<dt>Reposado tequila</dt>
<dd>Typically aged in wooden barrels for between two and eleven months...</dd>
</dl>
<h2 id="blockquotes">Blockquotes</h2>
<p>The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a <code>footer</code> or <code>cite</code> element, and optionally with in-line changes such as annotations and abbreviations.</p>
<blockquote>
<p>Quoted text.
This line is part of the same quote.
Also you can <em>put</em> <strong>Markdown</strong> into a blockquote.</p>
</blockquote>
<p>Blockquote with a citation.</p>
<blockquote>
<p>My goal wasn't to make a ton of money. It was to build good computers. I only started the company when I realized I could be an engineer forever.</p>
<footer>— <cite>Steve Wozniak</cite></footer>
</blockquote>
<p>According to Mozillas website, <q cite="https://www.mozilla.org/en-US/about/history/details/">Firefox 1.0 was released in 2004 and became a big success.</q></p>
<h2 id="tables">Tables</h2>
<p>Tables arent part of the core Markdown spec, but Hugo supports them.</p>
<table>
<thead>
<tr>
<th>ID</th>
<th>Make</th>
<th>Model</th>
<th>Year</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Honda</td>
<td>Accord</td>
<td>2009</td>
</tr>
<tr>
<td>2</td>
<td>Toyota</td>
<td>Camry</td>
<td>2012</td>
</tr>
<tr>
<td>3</td>
<td>Hyundai</td>
<td>Elantra</td>
<td>2010</td>
</tr>
</tbody>
</table>
<p>Colons can be used to align columns.</p>
<table>
<thead>
<tr>
<th align="left">Tables</th>
<th align="center">Are</th>
<th align="right">Cool</th>
</tr>
</thead>
<tbody>
<tr>
<td align="left">align: left</td>
<td align="center">align: center</td>
<td align="right">align: right</td>
</tr>
<tr>
<td align="left">align: left</td>
<td align="center">align: center</td>
<td align="right">align: right</td>
</tr>
<tr>
<td align="left">align: left</td>
<td align="center">align: center</td>
<td align="right">align: right</td>
</tr>
</tbody>
</table>
<p>You can also use inline Markdown.</p>
<table>
<thead>
<tr>
<th>Inline</th>
<th>Markdown</th>
<th>In</th>
<th>Table</th>
</tr>
</thead>
<tbody>
<tr>
<td><em>italics</em></td>
<td><strong>bold</strong></td>
<td><del>strikethrough</del></td>
<td><code>code</code></td>
</tr>
</tbody>
</table>
<h2 id="code">Code</h2>
<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html lang="en"&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;Example HTML5 Document&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Test&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">"en"</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">"UTF-8"</span>&gt;
&lt;<span style="color:#f92672">title</span>&gt;Example HTML5 Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">body</span>&gt;
&lt;<span style="color:#f92672">p</span>&gt;Test&lt;/<span style="color:#f92672">p</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;</code></pre></div>
<h2 id="other-stuff-abbr-sub-sup-kbd-etc">Other stuff — abbr, sub, sup, kbd, etc.</h2>
<p><abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.</p>
<p>H<sub>2</sub>O</p>
<p>C<sub>6</sub>H<sub>12</sub>O<sub>6</sub></p>
<p>X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup></p>
<p>Press <kbd>X</kbd> to win. Or press <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>F</kbd></kbd> to show FPS counter.</p>
<p><mark>As a unit of information in information theory, the bit has alternatively been called a shannon</mark>, named after Claude Shannon, the founder of field of information theory.</p>
</div>
<footer class="post__footer">
<div class="post__tags tags clearfix">
<svg class="tags__badge icon icon-tag" width="16" height="16" viewBox="0 0 32 32"><path d="M4 0h8s2 0 4 2l15 15s2 2 0 4L21 31s-2 2-4 0L2 16s-2-2-2-4V3s0-3 4-3m3 10a3 3 0 0 0 0-6 3 3 0 0 0 0 6"></path></svg>
<ul class="tags__list">
<li class="tags__item">
<a class="tags__link btn" href="/tags/html/" rel="tag">HTML</a>
</li>
<li class="tags__item">
<a class="tags__link btn" href="/tags/css/" rel="tag">CSS</a>
</li>
<li class="tags__item">
<a class="tags__link btn" href="/tags/basic-elements/" rel="tag">Basic Elements</a>
</li>
</ul>
</div>
</footer>
</article>
{% endblock %}