diff --git a/.gitignore b/.gitignore
index e731746..0f521b3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,3 @@
-
/vendor/
-.docker_vols
sftp.json
\ No newline at end of file
diff --git a/Rakefile b/Rakefile
deleted file mode 100644
index e69de29..0000000
diff --git a/docker_dev/Dockerfile b/docker_dev/Dockerfile
index 2060d63..6440854 100644
--- a/docker_dev/Dockerfile
+++ b/docker_dev/Dockerfile
@@ -2,7 +2,7 @@ FROM composer
WORKDIR /app
COPY www/composer.* .
-COPY www/vendor/* vendor/
+RUN composer install
FROM php:apache
WORKDIR /var/www/html
diff --git a/docker_dev/compose.yaml b/docker_dev/compose.yaml
index 5a25529..1b9493d 100644
--- a/docker_dev/compose.yaml
+++ b/docker_dev/compose.yaml
@@ -24,7 +24,7 @@ services:
- ../.git
- mysql_schema.sql
volumes:
- - ../.docker_vols/web:/var/www/html/raw
+ - website_datavolume:/var/www/html/raw
mysql:
build:
@@ -42,4 +42,7 @@ services:
- path: mysql_schema.sql
action: rebuild
volumes:
- - ../.docker_vols/sql:/var/lib/mysql
+ - sqlvolume:/var/lib/mysql
+volumes:
+ sqlvolume: {}
+ website_datavolume: {}
diff --git a/docker_dev/mysql_schema.sql b/docker_dev/mysql_schema.sql
index 97645e6..baf0a58 100644
--- a/docker_dev/mysql_schema.sql
+++ b/docker_dev/mysql_schema.sql
@@ -3,59 +3,35 @@ CREATE DATABASE dragon_fire;
USE dragon_fire;
--- DROP TABLE posts;
--- DROP TABLE path_access_counts;
--- DROP TABLE path_errcodes;
--- DROP TABLE feed_cache;
-
CREATE TABLE posts (
post_id INTEGER AUTO_INCREMENT,
host VARCHAR(64) NOT NULL,
-
post_path VARCHAR(255) NOT NULL,
post_path_depth INTEGER NOT NULL DEFAULT 0,
- post_created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- post_updated_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ post_create_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
+ post_update_time DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
- post_view_count INTEGER DEFAULT 0,
+ post_access_count INTEGER DEFAULT 0,
- post_title VARCHAR(1024),
- post_tags VARCHAR(1024),
- post_brief TEXT(2048),
-
- post_metadata JSON DEFAULT NULL,
+ post_metadata JSON NOT NULL,
post_settings_cache JSON DEFAULT NULL,
+ post_content MEDIUMTEXT,
+
PRIMARY KEY(post_id),
CONSTRAINT unique_post UNIQUE (host, post_path),
INDEX(host, post_path),
- INDEX(host, post_path_depth, post_path),
-
- INDEX(host, post_created_at),
- INDEX(host, post_updated_at),
-
- FULLTEXT(post_tags)
-);
-
-CREATE TABLE post_markdown (
- post_id INTEGER,
-
- post_markdown TEXT,
-
- PRIMARY KEY(post_id),
- FOREIGN KEY(post_id) REFERENCES posts(post_id)
- ON DELETE CASCADE,
-
- FULLTEXT(post_markdown)
+ INDEX(post_path_depth, post_path),
+ INDEX(post_create_time),
+ INDEX(post_update_time)
);
CREATE TABLE path_access_counts (
access_time DATETIME NOT NULL,
host VARCHAR(64) NOT NULL,
-
post_path VARCHAR(255),
agent VARCHAR(255),
referrer VARCHAR(255),
@@ -66,17 +42,6 @@ CREATE TABLE path_access_counts (
PRIMARY KEY(access_time, host, post_path, agent, referrer)
);
-CREATE TABLE path_errcodes (
- access_timestamp DATETIME NOT NULL,
-
- host VARCHAR(64) NOT NULL,
-
- post_path VARCHAR(255),
- agent VARCHAR(255),
- referrer VARCHAR(255),
- error VARCHAR(1024),
-);
-
CREATE TABLE feed_cache (
host VARCHAR(64) NOT NULL,
search_path VARCHAR(255),
diff --git a/www/.htaccess b/www/.htaccess
index d17abcd..eb86f63 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -14,20 +14,21 @@ RewriteRule ^.*\.(flv|gif|ico|jpg|jpeg|mp4|mpeg|png|svg|swf|webp)$ raw/%{HTTP_HO
RewriteRule ^/?raw/(.*)$ raw/%{HTTP_HOST}/$1 [L,END]
-# RewriteCond %{HTTPS} !on
-# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,END]
+RewriteEngine On
+RewriteCond %{HTTPS} !on
+RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,END]
-RewriteCond %{REQUEST_URI} !^/?(src/dbtest\.php|static|raw|robots\.txt).*
-RewriteRule (.*) src/router.php
+RewriteCond %{REQUEST_URI} !^/?(static|raw|robots\.txt).*
+RewriteRule (.*) router.php
Allow from all
Options +Indexes
';
- echo 'Error number: ' . mysqli_connect_errno() . '
';
- echo 'Error message: ' . mysqli_connect_error() . '
';
- die();
-}
-
-$sql_adapter = new MySQLHandler($db_connection, $SERVER_HOST);
-$adapter = new PostHandler($sql_adapter);
+$adapter = new PostHandler($SITE_CONFIG);
$loader = new \Twig\Loader\FilesystemLoader(['./templates', './user_content']);
diff --git a/www/src/db_handler/analytics_interface.php b/www/src/db_handler/analytics_interface.php
deleted file mode 100644
index fbe3400..0000000
--- a/www/src/db_handler/analytics_interface.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
\ No newline at end of file
diff --git a/www/src/db_handler/db_interface.php b/www/src/db_handler/db_interface.php
deleted file mode 100644
index ea72459..0000000
--- a/www/src/db_handler/db_interface.php
+++ /dev/null
@@ -1,86 +0,0 @@
-
-escape_tag($matches[2]) . $matches[3];
-}
-
-interface PostdataInterface {
- /* Postdata format:
- *
- * The Postdata array is a simple intermediate data format
- * for the Post content and metadata.
- * It is slightly abstracted from the SQL format itself but will
- * only reformat keys, *not* do any alteration of the data itself.
- *
- * Any supported fields will be integrated into the database.
- * Other fields will be saved in a JSON structure, and will
- * be restored afterward.
- *
- * The following fields are mandatory for *writing*
- * - path: String, must be sanitized to consist of just alphanumeric
- * characters, `_-./`
- * used to identify the post itself
- *
- * The following fields may be returned by the database:
- * - id
- * - created_at
- * - updated_at
- * - view_count
- *
- * The following fields may be supported by the database:
- * - markdown: String, markdown of the post. May be
- * stored separately and won't be returned by default!
- * - type: String, defining the type of the post
- * - title: String, self-explanatory
- * - tags: Array of strings
- * - settings: Hash, recursively merged settings (calculated by DB!)
- *
- * The following fields are *recommended*, but nothing more:
- * - icon: String, optionally defining
- */
-
- public function stub_postdata($path);
- public function stub_postdata_tree($path);
-
- public function set_postdata($data);
- public function set_post_markdown($id, $markdown);
-
- public function get_postdata($path);
- // Returns a key-value pair of child paths => child data
- public function get_post_children($path,
- $limit = 50, $depth_start = 1, $depth_end = 1,
- $order_by = 'path');
-
- public function get_post_markdown($id);
-}
-
-?>
\ No newline at end of file
diff --git a/www/src/db_handler/mysql_handler.php b/www/src/db_handler/mysql_handler.php
deleted file mode 100644
index def19df..0000000
--- a/www/src/db_handler/mysql_handler.php
+++ /dev/null
@@ -1,348 +0,0 @@
-
-sql_connection = $sql_connection;
- $this->hostname = $hostname;
-
- $this->debugging = false;
- }
-
- private function _dbg($message) {
- if($this->debugging) {
- echo $message;
- }
- }
-
- private function _exec($qery, $argtypes = '', ...$args) {
- $stmt = $this->sql_connection->prepare($qery);
-
- if($argtypes != ""){
- $stmt->bind_param($argtypes, ...$args);
- }
- $stmt->execute();
-
- return $stmt->get_result();
- }
-
- private function clear_post_settings_cache($post_path) {
- $post_path = sanitize_post_path($post_path);
-
- $this->_exec("
- UPDATE posts
- SET post_settings_cache=NULL
- WHERE host = ? AND post_path LIKE ?;
- ", "ss", $this->hostname, $post_path . "%");
- }
-
- public function stub_postdata($path) {
- $post_path = sanitize_post_path($path);
- $path_depth = substr_count($post_path, "/");
-
-
- $qry = "
- INSERT INTO posts
- (host, post_path, post_path_depth)
- VALUES
- ( ?, ?, ?) AS new
- ON DUPLICATE KEY UPDATE post_path=new.post_path;";
-
- $this->_exec($qry, "ssi",
- $this->hostname,
- $post_path,
- $path_depth);
- }
-
- public function stub_postdata_tree($path) {
- $post_path = sanitize_post_path($path);
-
- while(true) {
- if($post_path == '/') {
- $post_path = '';
- }
-
- try {
- $this->stub_postdata($post_path);
- }
- catch(Exception $e) {
- }
-
- $post_path = dirname($post_path);
- if(strlen($post_path) == 0) {
- break;
- }
- }
- }
-
- public function set_postdata($data) {
- $data['path'] = sanitize_post_path($data['path']);
- $post_path = $data['path'];
- unset($data['path']);
-
- $this->stub_postdata_tree($post_path);
-
- $data['title'] ??= basename($post_path);
-
- $post_tags = $data['tags'] ?? [];
- array_push($post_tags,
- 'path:' . $post_path
- );
-
- $sql_args = [
- $this->hostname,
- $post_path,
- substr_count($post_path, "/"),
- $data['title'],
- taglist_to_sql_string($post_tags),
- $data['brief'] ?? null
- ];
-
- unset($data['title']);
- unset($data['brief']);
-
- $post_markdown = $data['markdown'] ?? null;
- unset($data['markdown']);
- unset($data['html']);
-
- array_push($sql_args, json_encode($data));
-
- $qry =
- "INSERT INTO posts
- (host,
- post_path, post_path_depth,
- post_title, post_tags, post_brief,
- post_metadata, post_settings_cache)
- VALUES
- ( ?, ?, ?, ?, ?, ?, ?, null) AS new
- ON DUPLICATE KEY
- UPDATE post_title=new.post_title,
- post_tags=new.post_tags,
- post_brief=new.post_brief,
- post_metadata=new.post_metadata,
- post_updated_at=CURRENT_TIMESTAMP;
- ";
-
- $this->_exec($qry, "ssissss", ...$sql_args);
-
- if(isset($post_markdown)) {
- $this->set_post_markdown($this->sql_connection->insert_id, $post_markdown);
- }
-
- $this->clear_post_settings_cache($post_path);
- }
-
- public function set_post_markdown($id, $markdown) {
- $qry =
- "INSERT INTO post_markdown ( post_id, post_markdown )
- VALUES (?, ?) AS new
- ON DUPLICATE KEY UPDATE post_markdown=new.post_markdown;
- ";
-
- $this->_exec($qry, "is", $id, $markdown);
- }
-
- private function get_post_settings($post_path) {
- $post_path = sanitize_post_path($post_path);
-
- $this->_dbg("-> gps: getting path " . $post_path . "\n");
-
- $post_settings = $this->_exec("
- SELECT post_settings_cache
- FROM posts
- WHERE post_path = ? AND host = ?
- ", "ss", $post_path, $this->hostname)->fetch_assoc();
-
- if(!isset($post_settings)) {
- $this->_dbg("-> gps: Returning because of no result\n");
- return [];
- }
- if(isset($post_settings['post_settings_cache'])) {
- $result = json_decode($post_settings['post_settings_cache'], true);
- if($this->debugging) {
- echo "-> gps: Returning because of cached result:\n";
- echo "--> " . json_encode($result) . "\n";
- }
- return $result;
- }
-
- $parent_settings = [];
- if($post_path != "") {
- $parent_settings = $this->get_post_settings(dirname($post_path));
- }
-
- $post_settings = [];
- $post_metadata = $this->_exec("
- SELECT post_path, post_metadata
- FROM posts
- WHERE post_path = ? AND host = ?
- ", "ss", $post_path, $this->hostname)->fetch_assoc();
-
- if(isset($post_metadata['post_metadata'])) {
- $post_metadata = json_decode($post_metadata['post_metadata'], true);
-
- if(isset($post_metadata['settings'])) {
- $post_settings = $post_metadata['settings'];
- }
- }
-
- $post_settings = array_merge($parent_settings, $post_settings);
-
- $this->_dbg("-> gps: Merged post settings are " . json_encode($post_settings) . ", saving...\n");
-
- $this->_exec("
- UPDATE posts SET post_settings_cache=? WHERE post_path=? AND host=?
- ", "sss",
- json_encode($post_settings), $post_path, $this->hostname);
-
- return $post_settings;
- }
-
- private function process_postdata($data) {
- if(!isset($data)) {
- return null;
- }
-
- if(!isset($data['post_path'])) {
- echo "ERROR, trying to get a post data package without path!";
- die();
- }
-
- $outdata = [];
- foreach($this::SQL_READ_COLUMNS as $key) {
- if(isset($data['post_' . $key])) {
- $outdata[$key] = $data['post_' . $key];
- }
- }
-
- $post_metadata = json_decode($data['post_metadata'] ?? '{}', true);
-
- $post_settings = [];
-
- if(isset($data['post_settings_cache'])) {
- $post_settings = json_decode($data['post_settings_cache'], true);
- }
- else {
- $post_settings = $this->get_post_settings($data['post_path']);
- }
-
- $outdata = array_merge($post_settings, $post_metadata, $outdata);
-
- return $outdata;
- }
-
- public function get_postdata($path) {
- $path = sanitize_post_path($path);
-
- $qry = "
- SELECT *
- FROM posts
- WHERE post_path = ? AND host = ?;
- ";
-
- $data = $this->_exec($qry, "ss", $path, $this->hostname)->fetch_assoc();
-
- return $this->process_postdata($data);
- }
-
- public function get_post_children($path,
- $limit = 50, $depth_start = 1, $depth_end = 1,
- $order_by = 'path') {
-
- $path = sanitize_post_path($path);
-
- $path_depth = substr_count($path, "/");
-
- $allowed_ordering = [
- 'path' => true,
- 'path DESC' => true,
- 'created_at' => true,
- 'created_at DESC' => true,
- 'modified_at' => true,
- 'modified_at DESC' => true
- ];
-
- if(!isset($allowed_ordering[$order_by])) {
- throw new Exception('Children ordering not allowed');
- }
- $order_by = 'post_' . $order_by;
-
- if($this->debugging) {
- echo "-> GPC: Getting children for path " . $path;
- }
-
- $qry = "
- SELECT *
- FROM posts
- WHERE post_path_depth BETWEEN ? AND ?
- AND post_path LIKE ?
- ORDER BY " . $order_by .
- " LIMIT ?";
-
- $data = $this->_exec($qry, "iisi",
- $path_depth + $depth_start, $path_depth + $depth_end,
- $path.'/%', $limit
- )->fetch_all(MYSQLI_ASSOC);
- $outdata = [];
-
- foreach($data AS $post_element) {
- $outdata[$post_element['post_path']] =
- $this->process_postdata($post_element);
- }
-
- return $outdata;
- }
-
- public function get_post_markdown($id) {
- $qry =
- "SELECT post_markdown
- FROM post_markdown
- WHERE post_id = ?
- ";
-
- $data = $this->_exec($qry, "i", $id)->fetch_assoc();
-
- if(!isset($data)) {
- return "";
- }
-
- return $data['post_markdown'];
- }
-}
-
-?>
\ No newline at end of file
diff --git a/www/src/db_handler/post.php b/www/src/db_handler/post.php
deleted file mode 100644
index 4e9494e..0000000
--- a/www/src/db_handler/post.php
+++ /dev/null
@@ -1,213 +0,0 @@
-
- -1,
- 'path' => '/404.md',
- 'title' => '404 Page',
- 'metadata' => [
- 'type' => '404'
- ]
- ];
-
- return $post_data;
- }
-
- public static function _deduce_type($path) {
- $ext = pathinfo($path, PATHINFO_EXTENSION);
-
- if(preg_match("/\.(\w+)\.md$/", $path, $ext_match)) {
- $ext = $ext_match[1];
- }
-
- $ext_mapping = [
- '' => 'directory',
- 'md' => 'text/markdown',
- 'png' => 'image',
- 'jpg' => 'image',
- 'jpeg' => 'image'
- ];
-
- return $ext_mapping[$ext] ?? '?';
- }
-
- public static function _deduce_icon($type) {
- $icon_mapping = [
- '' => 'question',
- 'text/markdown' => 'markdown',
- 'blog' => 'markdown',
- 'blog_list' => 'rectangle-list',
- 'directory' => 'folder',
- 'gallery' => 'images',
- 'image' => 'image'
- ];
-
- return $icon_mapping[$type] ?? 'unknown';
- }
-
- function __construct($post_handler, $post_data, $site_defaults) {
- $this->handler = $post_handler;
-
- $this->content_html = null;
- $this->content_markdown = null;
-
- $this->site_defaults = $site_defaults;
-
- if(!isset($post_data) or !isset($post_data['id'])) {
- $post_data = $this->_generate_404($post_data);
- }
-
- $data = $post_data;
-
- if($data['path'] == '') {
- $data['path'] = '/';
- $data['title'] ??= 'root';
- $data['basename'] ??= 'root';
- }
-
- $post_data['host'] ??= 'localhost:8081';
-
- $data['url'] ??= 'http://' . $post_data['host'] . $post_data['path'];
-
- $data['basename'] ??= basename($data['path']);
-
- $data['title'] ??= basename($data['path']);
-
- $data['tags'] ??= [];
-
- $data['type'] ??= self::_deduce_type($post_data['path']);
-
- $data['icon'] ??= self::_deduce_icon($data['type']);
-
- if(isset($sql_meta['media_url'])) {
- $data['thumb_url'] ??= $data['media_url'];
- }
-
- $data['preview_image'] ??= $data['banners'][0]['src'] ?? null;
-
- $data['brief'] ??= $data['title'];
-
- $this->data = $data;
- }
-
- public function __get($name) {
- if($name == 'html') {
- return $this->get_html();
- }
- if($name == 'markdown') {
- return $this->get_markdown();
- }
- if($name == 'json') {
- return $this->to_json();
- }
- if($name == 'child_posts') {
- return $this->get_child_posts();
- }
- if($name == 'parent') {
- return $this->get_parent_post();
- }
-
- if(isset($this->data[$name])) {
- return $this->data[$name];
- }
-
- if(is_null($this->site_defaults)) {
- throw new RuntimeException("Post site defaults have not been set properly!");
- }
-
- return $this->site_defaults[$name] ?? null;
- }
-
- public function offsetGet($offset) : mixed {
- return $this->__get($offset) ?? null;
- }
- public function offsetExists($offset) : bool {
- if(isset($this->data[$offset])) {
- return true;
- }
- if(isset($this->site_defaults[$offset])) {
- return true;
- }
-
- return !is_null($this->offsetGet($offset));
- }
- public function offsetSet($offset, $value) : void {
- $this->data[$offset] = $value;
- }
- public function offsetUnset($offset) : void {
- unset($this->data[$offset]);
- }
-
- public function get_html() {
- $this->content_html ??= $this->handler->render_post($this);
-
- return $this->content_html;
- }
- public function get_markdown() {
- $this->content_markdown ??=
- $this->handler->get_markdown_for($this);
-
- return $this->content_markdown;
- }
-
- public function get_child_posts(...$search_args) {
- if(count($search_args) == 0) {
- $this->_child_posts ??=
- $this->handler->get_children_for($this);
-
- return $this->_child_posts;
- }
- else {
- return $this->handler->get_children_for($this, ...$search_args);
- }
- }
-
- public function to_array($options = []) {
- $out_data = $this->data;
-
- if(isset($options['markdown'])) {
- $out_data['markdown'] = $this->get_markdown();
- }
- if(isset($options['html'])) {
- $out_data['html'] = $this->get_html();
- }
- if(isset($options['children'])) {
- die();
- }
-
- return $out_data;
- }
- public function to_json($options = []) {
- return json_encode($this->to_array($options));
- }
-
-
- public function get_parent_post() {
- $parent_path = dirname($this->data['path']);
- if($parent_path == '')
- return null;
-
- $this->_parent_post ??= $this->handler->get_post($parent_path);
-
- return $this->_parent_post;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/www/src/db_handler/post_handler.php b/www/src/db_handler/post_handler.php
deleted file mode 100644
index 06fd3fc..0000000
--- a/www/src/db_handler/post_handler.php
+++ /dev/null
@@ -1,61 +0,0 @@
-db = $db_adapter;
- $this->posts = [];
-
- $this->site_defaults = null;
-
- $this->markdown_engine = null;
- }
-
- public function get_post($key) {
- $key = sanitize_post_path($key);
-
- if(isset($this->posts[$key])) {
- return $this->posts[$key];
- }
-
- $post_data = $this->db->get_postdata($key);
- $post = null;
- if(isset($post_data)) {
- $post = new Post($this, $post_data, $this->site_defaults);
- }
-
- $this->posts[$key] = $post;
-
- return $post;
- }
-
- public function get_markdown_for($post) {
- return $this->db->get_post_markdown($post->id);
- }
-
- public function render_post($post) {
- return ($this->markdown_engine)($post);
- }
-
- public function get_children_for($post, ...$search_opts) {
- $child_list = $this->db->get_post_children($post->path, ...$search_opts);
-
- $out_list = [];
- foreach($child_list as $child_data) {
- array_push($out_list, new Post($this, $child_data, $this->site_defaults));
- }
-
- return $out_list;
- }
-}
-
-?>
\ No newline at end of file
diff --git a/www/src/dbtest.php b/www/src/dbtest.php
deleted file mode 100644
index ffbc378..0000000
--- a/www/src/dbtest.php
+++ /dev/null
@@ -1,191 +0,0 @@
-';
- echo 'Error number: ' . mysqli_connect_errno() . '
';
- echo 'Error message: ' . mysqli_connect_error() . '
';
- die();
-}
-
-$db_connection->execute_query("DELETE FROM posts;");
-
-$sql_adapter = new MySQLHandler($db_connection, $SERVER_HOST);
-$adapter = new PostHandler($sql_adapter);
-
-$sql_adapter->debugging = true;
-
-function test_accounce($title) {
- echo "\n\n===========================================
- _______ ______ _____ _______
- |__ __| ____|/ ____|__ __|
- | | | |__ | (___ | | (_)
- | | | __| \___ \ | |
- | | | |____ ____) | | | _
- |_| |______|_____/ |_| (_)
-
-";
- echo "==== " . $title . "\n";
- echo "===========================================\n";
-}
-
-function adapter_fetch($post_path) {
- global $db_connection;
- global $sql_adapter;
-
- echo "-> Fetching path " . $post_path . "\n";
-
- echo json_encode($db_connection->execute_query("SELECT * FROM posts WHERE post_path=?", [
- $post_path
- ])->fetch_assoc(), JSON_PRETTY_PRINT);
-
- echo "\n-> Adapter output:\n";
-
- echo json_encode($sql_adapter->get_postdata($post_path), JSON_PRETTY_PRINT) . "\n";
-}
-
-echo "Starting test...\n";
-
-echo "Trying just a stub...\n";
-$sql_adapter->stub_postdata_tree('/testing/stubtest/1/2/3.md');
-echo "Stubbed~\n\n";
-
-echo "Getting the stub post...\n";
-
-echo json_encode($sql_adapter->get_postdata('/testing'), JSON_PRETTY_PRINT);
-
-echo "\n\n";
-
-test_accounce("Basic postdata setting");
-
-$sql_adapter->set_postdata([
- 'path' => '/testing/settest/test.md',
- 'title' => 'One heck of a test!',
- 'type' => 'text/markdown',
- 'tags' => [
- 'test',
- 'type:text'
- ],
- 'overridetest' => 'metadata'
-]);
-
-echo "\nDone!";
-
-adapter_fetch('/testing/settest/test.md');
-
-echo "Done!\n\n";
-
-test_accounce("Setting post markdown...");
-$sql_adapter->set_postdata([
- 'path' => '/testing/markdowntest',
- 'markdown' => 'Inline markdown test should work...',
- 'title' => "A Markdown Test"
-]);
-$post = $sql_adapter->get_postdata('/testing/markdowntest');
-var_dump($sql_adapter->get_post_markdown($post['id']));
-
-$sql_adapter->set_post_markdown($post['id'],
- '
- This is one hell of a cute test!
-> Just checking in...
- '
-);
-var_dump($sql_adapter->get_post_markdown($post['id']));
-unset($post);
-
-test_accounce("Settings inheritance test...");
-echo "Setting on a parent file...\n";
-
-$sql_adapter->set_postdata([
- 'path' => '/testing/settest',
- 'settings' => [
- 'nom' => true,
- 'type' => 'frame',
- 'overridetest' => 'settings'
- ]
-]);
-
-echo "\nAnd checking if that held!\n";
-
-adapter_fetch('/testing/settest');
-adapter_fetch('/testing/settest/test.md');
-
-test_accounce("Testing getting child posts");
-
-echo json_encode($sql_adapter->get_post_children('/testing'), JSON_PRETTY_PRINT);
-
-echo "\n\n------------------------------------------------------\n";
-
-echo "TEST PHASE: Adapter testing";
-echo "\n------------------------------------------------------\n\n";
-
-$post = $adapter->get_post('/testing/markdowntest');
-echo "Post path is " . $post->path . "\n";
-echo "Post markdown is " . $post->markdown . "\n";
-echo $post->to_json();
-
-echo "\n\n";
-
-echo $post->to_json([
- 'markdown' => true
-]);
-
-test_accounce("Fetching child posts");
-echo "Root children:\n". json_encode(array_map(function($data) {
- return $data->to_array();
-}, $adapter->get_post('/')->child_posts), JSON_PRETTY_PRINT);
-echo "\n\n";
-
-echo "Root children, extended:\n" . json_encode(array_map(function($data) {
- return $data->to_array();
-}, $adapter->get_post('/')->get_child_posts(depth_end: 3)), JSON_PRETTY_PRINT);
-echo "\n\n";
-?>
\ No newline at end of file
diff --git a/www/src/router.php b/www/src/router.php
deleted file mode 100644
index c2f3dc7..0000000
--- a/www/src/router.php
+++ /dev/null
@@ -1,31 +0,0 @@
-
\ No newline at end of file
diff --git a/www/src/serve/ajax.php b/www/src/serve/ajax.php
deleted file mode 100644
index 679afe0..0000000
--- a/www/src/serve/ajax.php
+++ /dev/null
@@ -1,26 +0,0 @@
-get_post($REQUEST_QUERY['page']);
-}
-
-
-$ajax_args['fa'] = $FONT_AWESOME_ARRAY;
-$ajax_args['page'] ??= $SITE_CONFIG['site_defaults'];
-
-echo $twig->render('/ajax/' . $AJAX_REQUEST_TEMPLATE, $ajax_args);
-
-?>
\ No newline at end of file
diff --git a/www/src/serve/post.php b/www/src/serve/post.php
deleted file mode 100644
index 6430550..0000000
--- a/www/src/serve/post.php
+++ /dev/null
@@ -1,48 +0,0 @@
-get_post($REQUEST_PATH);
-
-function render_root_template($template, $args = []) {
- global $twig;
- global $FONT_AWESOME_ARRAY;
- global $SITE_CONFIG;
-
- $args['fa'] = $FONT_AWESOME_ARRAY;
- $args['page'] ??= $SITE_CONFIG['site_defaults'];
-
- $page = $args['page'];
- $page['base'] ??= $page['url'];
-
- $args['opengraph'] = [
- "site_name" => $page['site_name'] ?? 'Nameless Site',
- "title" => $page['title'] ?? 'Titleless',
- "url" => $page['url'] ?? $page['path'] ?? 'No URL set',
- "description" => $page['description'] ?? 'No description set'
- ];
-
- $args['banners'] = json_encode($page['banners'] ?? []);
-
- $args['age_gate'] = (!isset($_COOKIE['AgeConfirmed']))
- && isset($SITE_CONFIG['age_gate']);
-
- echo $twig->render($template, $args);
-}
-
-function render_pathed_content_template($template, $args = []) {
- render_root_template($template, $args);
-}
-
-render_pathed_content_template('post_types/markdown.html', [
- 'page' => $post
-]);
-die();
-
-if(!isset($post)) {
- render_404();
- die();
-}
-
-
-?>
\ No newline at end of file
diff --git a/www/src/setup_db.php b/www/src/setup_db.php
deleted file mode 100644
index 70b3d88..0000000
--- a/www/src/setup_db.php
+++ /dev/null
@@ -1,45 +0,0 @@
-';
- echo 'Error number: ' . mysqli_connect_errno() . '
';
- echo 'Error message: ' . mysqli_connect_error() . '
';
- die();
-}
-
-$sql_adapter = new MySQLHandler($db_connection, $SERVER_HOST);
-$adapter = new PostHandler($sql_adapter);
-
-require_once 'dergdown.php';
-
-function dergdown_to_html($text) {
- $Parsedown = new Dergdown();
-
- return $Parsedown->text($text);
-}
-function post_to_html($post) {
- return dergdown_to_html($post->markdown);
-}
-$adapter->markdown_engine = "post_to_html";
-
-$adapter->site_defaults = $SITE_CONFIG['site_defaults'];
-
-?>
\ No newline at end of file
diff --git a/www/src/setup_site_config.php b/www/src/setup_site_config.php
deleted file mode 100644
index 683cb91..0000000
--- a/www/src/setup_site_config.php
+++ /dev/null
@@ -1,19 +0,0 @@
-
\ No newline at end of file
diff --git a/www/src/setup_twig.php b/www/src/setup_twig.php
deleted file mode 100644
index e674428..0000000
--- a/www/src/setup_twig.php
+++ /dev/null
@@ -1,24 +0,0 @@
- true,
- 'cache' => 'twig_cache'
-]);
-$twig->addExtension(new Twig\Extra\Markdown\MarkdownExtension());
-
-use Twig\Extra\Markdown\DefaultMarkdown;
-use Twig\Extra\Markdown\MarkdownRuntime;
-use Twig\RuntimeLoader\RuntimeLoaderInterface;
-
-$twig->addRuntimeLoader(new class implements RuntimeLoaderInterface {
- public function load($class) {
- if (MarkdownRuntime::class === $class) {
- return new MarkdownRuntime(new DefaultMarkdown());
- }
- }
-});
-
-
-?>
\ No newline at end of file
diff --git a/www/static/dergstyle.css b/www/static/dergstyle.css
index 6ccc0f6..2a4c1f9 100644
--- a/www/static/dergstyle.css
+++ b/www/static/dergstyle.css
@@ -311,21 +311,12 @@ body.htmx-request::before {
.folder-listing input {
display: none;
}
-.folder-listing input ~ ul {
+.folder-listing input + ul {
display: none;
}
-.folder-listing input:checked ~ ul {
+.folder-listing input:checked + ul {
display: block;
}
-.folder-listing label > :nth-child(2) {
- display: none;
-}
-.folder-listing input:checked ~ label > :nth-child(1) {
- display: none;
-}
-.folder-listing input:checked ~ label > :nth-child(2) {
- display: inline-block;
-}
#navbar-expand-label {
cursor: pointer;
diff --git a/www/templates/ajax/closed_folder_listing.html b/www/templates/ajax/closed_folder_listing.html
new file mode 100644
index 0000000..399894f
--- /dev/null
+++ b/www/templates/ajax/closed_folder_listing.html
@@ -0,0 +1,13 @@
+
+