diff --git a/test_entries/about/neira.md b/test_entries/about/neira.md deleted file mode 100644 index aedd371..0000000 --- a/test_entries/about/neira.md +++ /dev/null @@ -1,8 +0,0 @@ ---- ---- - -# About her - - -This is some test content, to simulate a little markdown page for... Well, our website. -I wouldn't worry too much about it. Just know it's here :) \ No newline at end of file diff --git a/test_entries/about/neira/subtest.md b/test_entries/about/neira/subtest.md deleted file mode 100644 index 51f4c64..0000000 --- a/test_entries/about/neira/subtest.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -tags: - - neira - - comfy - - testing -title: Subtest, it's nice :> ---- - -## Subtests, because it's nice \ No newline at end of file diff --git a/www/mysql_adapter.php b/www/mysql_adapter.php index 74b990d..1a4402a 100644 --- a/www/mysql_adapter.php +++ b/www/mysql_adapter.php @@ -1,7 +1,5 @@ body(); - $post_metadata = $frontmatter_post->matter(); - - $post_metadata['type'] = 'text/markdown'; - - var_dump($post_path, $post_content, $post_metadata); - - $qry = " - INSERT INTO posts - (post_path, post_path_depth, post_metadata, post_content) - VALUES - ( ?, ?, ?, ?) AS new - ON DUPLICATE KEY UPDATE post_metadata=new.post_metadata, post_content=new.post_content;"; - - $this->_exec($qry, "siss", - $post_path, - $path_depth, - json_encode($post_metadata), - $post_content); - } - function get_post_by_path($post_path, $with_subposts = true) { $qry = "SELECT * FROM posts WHERE post_path = ?"; @@ -94,7 +65,7 @@ class MySQLAdapter { ORDER BY post_create_time DESC LIMIT 10"; - $post_data = $this->_exec($qry, "si", $path, $path_depth+1)->fetch_all(MYSQLI_ASSOC); + $post_data = $this->_exec($qry, "si", $path, $path_depth)->fetch_all(MYSQLI_ASSOC); $fn = function($data) { return $this->_prepare_post_data($data); diff --git a/www/router.php b/www/router.php index faf57d2..38fb670 100644 --- a/www/router.php +++ b/www/router.php @@ -32,42 +32,29 @@ $twig->addRuntimeLoader(new class implements RuntimeLoaderInterface { } }); -$SURI = $_SERVER['REQUEST_URI']; - -if($SURI == '/') { +if($_SERVER['REQUEST_URI'] == '/') { echo $twig->render('root.html'); -} elseif(preg_match('/^\/api/', $SURI)) { - if(preg_match('/^\/api\/posts(.*)$/', $SURI, $match)) { +} elseif(preg_match('/^\/api\/posts(.*)$/', $_SERVER['REQUEST_URI'], $match)) { - header('Content-Type: application/json'); - echo json_encode($adapter->get_post_by_path($match[1])); + header('Content-Type: application/json'); + echo json_encode(get_post_by_path($match[1])); - } elseif(preg_match('/^\/api\/subposts(.*)$/', $SURI, $match)) { +} elseif(preg_match('/^\/api\/subposts(.*)$/', $_SERVER['REQUEST_URI'], $match)) { - header('Content-Type: application/json'); - echo json_encode(get_subposts($match[1])); - } elseif($SURI == '/api/upload') { - - if(array_key_exists('post_data', $_FILES)) { - $upload_content = file_get_contents($_FILES['post_data']['tmp_name']); - $upload_path = $_POST['post_path']; + header('Content-Type: application/json'); + echo json_encode(get_subposts($match[1])); - $adapter->save_markdown_post($upload_path, $upload_content); - } - - echo $twig->render('upload.html'); - } } elseif(true) { - $post = $adapter->get_post_by_path($SURI); + $post = $adapter->get_post_by_path($_SERVER['REQUEST_URI']); echo $twig->render('about.html', [ "post" => $post, "subposts" => $post['subposts'] ]); -} elseif(preg_match('/^\/about(.html)?$/', $SURI)) { +} elseif(preg_match('/^\/about(.html)?$/', $_SERVER['REQUEST_URI'])) { echo $twig->render('about.html'); -} elseif(preg_match('/^\/gallery\/([^\?]+)/', $SURI)) { +} elseif(preg_match('/^\/gallery\/([^\?]+)/', $_SERVER['REQUEST_URI'])) { echo $twig->render('/gallery/gallery_entry.html', [ 'image_url' => '/static/banner/0.png', 'image_title' => 'Test!', @@ -79,7 +66,7 @@ if($SURI == '/') { echo $twig->render('rrror.html',[ "error_code" => '404 Hoard not found!', "error_description" => "Well, we searched - far and wide for `" . $SURI . "` but + far and wide for `" . $_SERVER['REQUEST_URI'] . "` but somehow it must have gotten lost... Sorry!" ]); } diff --git a/www/templates/upload.html b/www/templates/upload.html deleted file mode 100644 index 6e4ad19..0000000 --- a/www/templates/upload.html +++ /dev/null @@ -1,18 +0,0 @@ - - -{% extends "root.html" %} - -{% block second_title %} -