summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhorus2021-03-15 22:38:27 +0100
committerhorus2021-03-15 22:38:27 +0100
commit3ee4fc2d67dc3aecdb72ad39f23fb0ec3637cb08 (patch)
tree257476f6b031a7bf88a06a6690b8fecc5a6081ac
parent83fec0b53ae04e23948b981cf845ce0d476ba22a (diff)
downloadmoehring-3ee4fc2d67dc3aecdb72ad39f23fb0ec3637cb08.tar.gz
Changes to trailing slash.
-rw-r--r--functions.php8
-rw-r--r--public/index.php23
-rw-r--r--views/index.html6
-rw-r--r--views/snippets/navbar.html6
-rw-r--r--views/tools.html10
5 files changed, 33 insertions, 20 deletions
diff --git a/functions.php b/functions.php
index 0b7d369..9bd65e4 100644
--- a/functions.php
+++ b/functions.php
@@ -15,3 +15,11 @@ function str_starts_with( $haystack, $needle ) {
$length = strlen( $needle );
return substr( $haystack, 0, $length ) === $needle;
}
+
+function str_ends_with( $haystack, $needle) {
+ $len = strlen($needle);
+ if ($len == 0) {
+ return true;
+ }
+ return substr($haystack, -$len) === $needle;
+}
diff --git a/public/index.php b/public/index.php
index 7e44159..1de542e 100644
--- a/public/index.php
+++ b/public/index.php
@@ -9,24 +9,21 @@ switch( $url ) {
case("/"):
echo $twig->render('index.html');
break;
-case("/about"):
+case("/about/"):
echo $twig->render('about.html');
break;
-case("/projects"):
+case("/projects/"):
echo $twig->render('projects.html');
break;
-case("/tools"):
+case("/tools/"):
echo $twig->render('tools.html');
break;
-case("/tools/faces"):
case("/tools/faces/"):
echo $twig->render('tools/faces/index.html', [ "faces" => get_faces() ]);
break;
-case("/tools/pizza"):
case("/tools/pizza/"):
echo $twig->render('tools/pizza/index.html');
break;
-case("/tools/untrack"):
case("/tools/untrack/"):
$_url = "";
if ( isset($_REQUEST['url']) ) {
@@ -34,11 +31,19 @@ case("/tools/untrack/"):
}
echo $twig->render('tools/untrack/index.html', [ "url" => $_url ]);
break;
-case("/tools/zeitumstellung"):
case("/tools/zeitumstellung/"):
echo $twig->render('tools/zeitumstellung/index.html', [ "tc" => new Zeitumstellung() ]);
break;
+case("/tools/tanz/"):
+ echo $twig->render('tools/bpm/index.html', [ "dances" => get_dances() ]);
+ break;
default:
- http_response_code(404);
- echo $twig->render('404.html');
+ if ( str_ends_with($url, "/") ) {
+ http_response_code(404);
+ echo $twig->render('404.html');
+ } else {
+ $url = $url . "/";
+ header("Location: " . $url);
+ exit;
+ }
}
diff --git a/views/index.html b/views/index.html
index 9e7151a..5b653b7 100644
--- a/views/index.html
+++ b/views/index.html
@@ -42,7 +42,7 @@
<code>
<span class="keyword">while</span> lazy; <span class="keyword">do</span>
<br>
- <a class="tab-over-space" href="/projects" title="uncaught exception">Hobby => Projects()</a>
+ <a class="tab-over-space" href="/projects/" title="uncaught exception">Hobby => Projects()</a>
<br>
<span class="keyword">endwhile</span>
</code>
@@ -54,7 +54,7 @@
<code>
<span class="keyword">while</span> crazy; <span class="keyword">do</span>
<br>
- <span class="tab-over-space">eval(<span class="string">"</span><a href="/tools" title="eval is bad">boot up tools page</a><span class="string">"</span>)</span>
+ <span class="tab-over-space">eval(<span class="string">"</span><a href="/tools/" title="eval is bad">boot up tools page</a><span class="string">"</span>)</span>
<br>
<span class="keyword">endwhile</span>
</code>
@@ -66,7 +66,7 @@
<span class="keyword">if</span> interested; <span class="keyword">do</span>
<br>
<span class="tab-over-space">
- <a href="/about" title="me.about() makes more sense">About.Me()</a>
+ <a href="/about/" title="me.about() makes more sense">About.Me()</a>
<span class="keyword">or</span>
<a href="https://www.fuselkoenig.de/kontakt/" title="don't tell me I forgot the semicolons">Contact.Me()</a></span>
<br>
diff --git a/views/snippets/navbar.html b/views/snippets/navbar.html
index 1b28707..9a63ad9 100644
--- a/views/snippets/navbar.html
+++ b/views/snippets/navbar.html
@@ -13,13 +13,13 @@
<!-- Right Side Of Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
- <a class="nav-link {{ is_active('/projects') }}" href="/projects">/projects</a>
+ <a class="nav-link {{ is_active('/projects') }}" href="/projects/">/projects</a>
</li>
<li class="nav-item">
- <a class="nav-link {{ is_active('/tools') }}" href="/tools">/tools</a>
+ <a class="nav-link {{ is_active('/tools') }}" href="/tools/">/tools</a>
</li>
<li class="nav-item">
- <a class="nav-link {{ is_active('/about') }}" href="/about">/about me</a>
+ <a class="nav-link {{ is_active('/about') }}" href="/about/">/about me</a>
</li>
</ul>
</div>
diff --git a/views/tools.html b/views/tools.html
index 0b3faad..01ac33e 100644
--- a/views/tools.html
+++ b/views/tools.html
@@ -16,19 +16,19 @@
<ul>
<li>
<!--a href="https://faces.iamfabulous.de" title="Best faces on the net" rel="nofollow">Best faces on the net</a-->
- <a href="/tools/faces" title="Best faces on the net">Best faces on the net</a>
+ <a href="/tools/faces/" title="Best faces on the net">Best faces on the net</a>
</li>
<li>
- <a href="/tools/untrack" title="Entfernt Tracking Parameter aus der URL">untrack - Entfernt Tracking Parameter aus der URL</a>
+ <a href="/tools/untrack/" title="Entfernt Tracking Parameter aus der URL">untrack - Entfernt Tracking Parameter aus der URL</a>
</li>
<li>
- <a href="/tools/pizza" title="Pizzarechner">Pizzarechner</a>
+ <a href="/tools/pizza/" title="Pizzarechner">Pizzarechner</a>
</li>
<li>
- <a href="/tools/zeitumstellung" title="Zeitumstellung">Zeitumstellung - Als iCal-Feed für deinen Kalender</a>
+ <a href="/tools/zeitumstellung/" title="Zeitumstellung">Zeitumstellung - Als iCal-Feed für deinen Kalender</a>
</li>
<li>
- <a href="https://bpm.iamfabulous.de" title="BPM / Tanz" rel="nofollow">BPM / Tanz</a>
+ <a href="/tools/tanz/" title="BPM / Tanz">BPM - Tanzbar?</a>
</li>
<li>
<a href="/feed/dilbert/" title="Dilbert RSS Feed">Dilbert RSS Feed. With Images!</a>