feat: ✨ use new adapter upload function
This commit is contained in:
parent
b6b8c587a1
commit
d54d3077cb
1 changed files with 27 additions and 7 deletions
|
@ -49,21 +49,41 @@ if($SURI == '/') {
|
|||
} 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'];
|
||||
|
||||
$adapter->save_markdown_post($upload_path, $upload_content);
|
||||
|
||||
$adapter->handle_upload($_POST['post_path'], $_FILES['post_data']['tmp_name']);
|
||||
}
|
||||
|
||||
echo $twig->render('upload.html');
|
||||
}
|
||||
} elseif($_SERVER['HTTP_SEC_FETCH_DEST'] == 'image') {
|
||||
header('Location: /raw' . $SURI);
|
||||
exit(0);
|
||||
} elseif(true) {
|
||||
$post = $adapter->get_post_by_path($SURI);
|
||||
|
||||
if($post['post_metadata']['type'] == 'directory') {
|
||||
if(preg_match('/^(.*[^\/])((?:#.*)?)$/', $SURI, $match)) {
|
||||
header('Location: ' . $match[1] . '/' . $match[2]);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
echo $twig->render('directory.html', [
|
||||
"post" => $post,
|
||||
"subposts" => $post['subposts']
|
||||
]);
|
||||
}
|
||||
elseif($post['post_metadata']['type'] == 'text/markdown') {
|
||||
echo $twig->render('about.html', [
|
||||
"post" => $post,
|
||||
"subposts" => $post['subposts']
|
||||
]);
|
||||
}
|
||||
elseif($post['post_metadata']['type'] == 'file') {
|
||||
echo $twig->render('image.html', [
|
||||
"post" => $post
|
||||
]);
|
||||
}
|
||||
|
||||
} elseif(preg_match('/^\/about(.html)?$/', $SURI)) {
|
||||
echo $twig->render('about.html');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue