feat: ✨ add new file metadata handling (.ext.md instead of .mddesc)
This commit is contained in:
parent
d39595d577
commit
c202b778e0
3 changed files with 37 additions and 32 deletions
|
@ -3,12 +3,17 @@ AddType text/plain .md
|
|||
AddType text/plain .atom
|
||||
AddType text/plain .rss
|
||||
|
||||
php_value upload_max_filesize 40M
|
||||
php_value post_max_size 42M
|
||||
# php_value upload_max_filesize 40M
|
||||
# php_value post_max_size 42M
|
||||
|
||||
RewriteEngine On
|
||||
RewriteBase /
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^/raw/
|
||||
RewriteRule ^.*\.(flv|gif|ico|jpg|jpeg|mp4|mpeg|png|svg|swf|webp)$ raw/%{HTTP_HOST}%{REQUEST_URI} [L,END]
|
||||
|
||||
RewriteRule ^/?raw/(.*)$ raw/%{HTTP_HOST}/$1 [L,END]
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^/?(static|raw|robots\.txt).*
|
||||
RewriteRule (.*) router.php
|
||||
|
||||
|
|
|
@ -30,41 +30,42 @@ class PostHandler extends MySQLAdapter {
|
|||
$post_meta["title"] = "root";
|
||||
}
|
||||
|
||||
if(!isset($post_meta['type'])) {
|
||||
$type = null;
|
||||
|
||||
$ext = pathinfo($post_data['post_basename'], PATHINFO_EXTENSION);
|
||||
$ext = pathinfo($post_data['post_basename'], PATHINFO_EXTENSION);
|
||||
|
||||
$ext_mapping = [
|
||||
'' => 'directory',
|
||||
'md' => 'text/markdown',
|
||||
'png' => 'image',
|
||||
'jpg' => 'image',
|
||||
'jpeg' => 'image'
|
||||
];
|
||||
|
||||
if(isset($ext_mapping[$ext])) {
|
||||
$post_meta['type'] = $ext_mapping[$ext];
|
||||
}
|
||||
else {
|
||||
$post_meta['type'] = '?';
|
||||
}
|
||||
if(preg_match("/\.(\w+)\.md$/", $post_data['post_basename'], $ext_match)) {
|
||||
$ext = $ext_match[1];
|
||||
|
||||
$post_meta['media_file'] ??= "https://" . $this->SITE_CONFIG['HTTP_HOST'] . chop($post_data['post_path'], ".md");
|
||||
}
|
||||
|
||||
$ext_mapping = [
|
||||
'' => 'directory',
|
||||
'md' => 'text/markdown',
|
||||
'png' => 'image',
|
||||
'jpg' => 'image',
|
||||
'jpeg' => 'image'
|
||||
];
|
||||
|
||||
if(isset($ext_mapping[$ext])) {
|
||||
$post_meta['type'] ??= $ext_mapping[$ext];
|
||||
}
|
||||
else {
|
||||
$post_meta['type'] ??= '?';
|
||||
}
|
||||
|
||||
if(!isset($post_meta['icon'])) {
|
||||
$icon_mapping = [
|
||||
'' => 'question',
|
||||
'text/markdown' => 'markdown',
|
||||
'directory' => 'folder',
|
||||
'image' => 'image'
|
||||
];
|
||||
$icon_mapping = [
|
||||
'' => 'question',
|
||||
'text/markdown' => 'markdown',
|
||||
'directory' => 'folder',
|
||||
'image' => 'image'
|
||||
];
|
||||
|
||||
$post_meta['icon'] = $icon_mapping[$post_meta['type']] ?? 'question';
|
||||
}
|
||||
$post_meta['icon'] ??= $icon_mapping[$post_meta['type']] ?? 'question';
|
||||
|
||||
$post_data['post_metadata'] = $post_meta;
|
||||
|
||||
$post_data["post_file_dir"] = '/' . $this->data_directory . $post_data["post_path"];
|
||||
$post_data["post_file_dir"] = '/raw' . $post_data["post_path"];
|
||||
|
||||
return $post_data;
|
||||
}
|
||||
|
@ -83,7 +84,6 @@ class PostHandler extends MySQLAdapter {
|
|||
}
|
||||
|
||||
function save_file($post_path, $file_path) {
|
||||
$this->bump_post($post_path);
|
||||
move_uploaded_file($file_path, $this->data_directory . $post_path);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
|
||||
{%block content_article%}
|
||||
<figure>
|
||||
<a target="_blank" href="{{post['post_file_dir']}}">
|
||||
<img id="gallery_image" src="{{post['post_file_dir']}}"></img>
|
||||
<a target="_blank" href="{{post.post_metadata.media_file}}">
|
||||
<img id="gallery_image" src="{{post.post_metadata.media_file}}"></img>
|
||||
</a>
|
||||
|
||||
<figcaption>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue