Browse Source

add media content support

main
ghost 9 months ago
parent
commit
850c84b538
  1. 31
      src/server.php

31
src/server.php

@ -128,7 +128,7 @@ foreach ($filesystem->getList() as $path)
if ($uri = $filesystem->getPageUriByPath($path)) if ($uri = $filesystem->getPageUriByPath($path))
{ {
if ($data = $filesystem->getData($path)) if ($data = $filesystem->getDataByPath($path))
{ {
$gemini = $reader->toGemini( $gemini = $reader->toGemini(
$data $data
@ -401,7 +401,7 @@ $server->setHandler(
// Convert // Convert
$gemini = $reader->toGemini( $gemini = $reader->toGemini(
$filesystem->getData( $filesystem->getDataByPath(
$path $path
) )
); );
@ -511,7 +511,7 @@ $server->setHandler(
{ {
$h1[] = $reader->getH1( $h1[] = $reader->getH1(
$reader->toGemini( $reader->toGemini(
$filesystem->getData( $filesystem->getDataByPath(
$file $file
) )
) )
@ -523,7 +523,7 @@ $server->setHandler(
{ {
$h1[] = $reader->getH1( $h1[] = $reader->getH1(
$reader->toGemini( $reader->toGemini(
$filesystem->getData( $filesystem->getDataByPath(
$file $file
) )
) )
@ -616,6 +616,29 @@ $server->setHandler(
return $response; return $response;
} }
// Media request
else if ($path = $filesystem->getMediaPathByUri($_uri))
{
if ($mime = $filesystem->getMimeByPath($path))
{
if ($data = $filesystem->getDataByPath($path))
{
// Set MIME
$response->setMeta(
$mime
);
// Append data
$response->setContent(
$data
);
// Response
return $response;
}
}
}
} }
// Route not found // Route not found

Loading…
Cancel
Save