feat: add function to get raw Database output, for debugging

This commit is contained in:
David Bailey 2025-01-06 22:45:01 +01:00
parent fc0d38e118
commit 95e3fc0b00

View file

@ -19,6 +19,9 @@ switch($API_FUNCTION) {
echo $post->to_json($REQUEST_QUERY);
}
break;
case 'db_post':
echo json_encode($sql_adapter->get_postdata($match[2]));
break;
case 'upload':
if(!access_can_upload()) {
@ -69,10 +72,17 @@ switch($API_FUNCTION) {
$post_data['path'] = $file_path;
$post_data['markdown'] = $post_matter->body();
// TODO: This should be moved to an appropriately abstracted prep function
if($is_directory) {
$post_data['base'] ??= $original_file_path;
$post_data['type'] ??= 'directory';
}
$post_data['tags'] ??= [];
$post_data['tags'] []= "type:" . ($post_data['type'] ?? Post::deduce_type($file_path));
$post_data['tags'] []= "path:" . $file_path;
$sql_adapter->set_postdata($post_data);
}