4 Commits

Author SHA1 Message Date
b189753c1e feat: add ServeFileController to serve files dynamically 2024-12-21 14:49:27 +01:00
5fcc7c78bb Merge pull request 'center files table' (#3) from sites/file-explorer:main into main
Reviewed-on: jank1619/file-explorer#3
2024-12-21 13:25:57 +00:00
c1e1ab081f style(home.html.twig): adjust centering of container element (#2)
All checks were successful
build / build (pull_request) Successful in 5m19s
Co-authored-by: Jan Klattenhoff <j.klattenhoff@neusta.de>
Reviewed-on: jank1619/file-explorer#2
2024-12-20 07:03:38 +00:00
4826805f57 Merge pull request 'main' (#1) from sites/file-explorer:main into main
Reviewed-on: jank1619/file-explorer#1
2024-12-20 06:54:18 +00:00
5 changed files with 15 additions and 23 deletions

View File

@ -9,12 +9,15 @@ jobs:
build:
runs-on: remote
steps:
- uses: https://git.simonis.lol/actions/checkout@v4
- uses: https://git.simonis.lol/actions/login@v1
with:
registry: git.simonis.lol
username: ${{ vars.DOCKER_USER }}
password: ${{ vars.DOCKER_PW }}
- name: Checkout
uses: https://git.simonis.lol/actions/checkout@v2
- name: build
run: docker build -t git.simonis.lol/sites/file-explorer:latest .
- name: Build
run: docker buildx build -t git.simonis.lol/projects/file-explorer:latest .
- name: Push
run: docker push git.simonis.lol/projects/file-explorer:latest
- name: push
run: docker push git.simonis.lol/sites/file-explorer:latest

View File

@ -23,8 +23,7 @@
"symfony/yaml": "7.1.*",
"symfonycasts/tailwind-bundle": "^0.6.1",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0",
"ext-fileinfo": "*"
"twig/twig": "^2.12|^3.0"
},
"config": {
"allow-plugins": {

View File

@ -5,6 +5,7 @@ namespace App\Controller;
use App\Service\FileSystemService;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Symfony\Component\Routing\Attribute\Route;
@ -14,7 +15,7 @@ class ServeFileController extends AbstractController
{
}
#[Route("/serve/{filePath}", name: "serve_file")]
#[Route("/serve-file/{filePath}", name: "serve_file")]
public function __invoke(string $filePath): BinaryFileResponse
{
$file = $this->fileSystemService->getFile($filePath);

View File

@ -14,7 +14,6 @@ readonly class DirContent
private string $type,
private string $path,
private string $content,
private string $mimeType,
) {
}
@ -25,8 +24,7 @@ readonly class DirContent
$fileInfo->getSize() ?? 0,
$fileInfo->getType() ?? 'N/A',
$fileInfo->getPath(),
$content,
mime_content_type($fileInfo->getPath() . '/' . $fileInfo->getFilename()),
$content
);
}
@ -59,11 +57,6 @@ readonly class DirContent
return $this->content;
}
public function getMimeType(): string
{
return $this->mimeType;
}
private function getHumanReadableSize(): string
{
$bytes = $this->size;

View File

@ -15,11 +15,7 @@
</a>
<div class="mt-6 text-gray-700 overflow-auto max-h-96">
{% if file.mimeType starts with 'image' %}
<img src="{{ path('serve_file', {filePath: file.name}) }}" alt="">
{% else %}
<p class="whitespace-pre-wrap leading-relaxed break-all text-balance">{{ file.content|raw }}</p>
{% endif %}
<p class="whitespace-pre-wrap leading-relaxed break-all text-balance">{{ file.content|raw }}</p>
</div>
</div>
{% endblock %}