diff --git a/.env.example b/.env.example index 985be729a4..c7f28f4848 100644 --- a/.env.example +++ b/.env.example @@ -326,6 +326,20 @@ GOOGLE_PHOTOS_ENABLED=false CANVA_ENABLED=true CANVA_CLIENT_ID= CANVA_CLIENT_SECRET= + +# WebDAV share as a read-only media source (Nextcloud, ownCloud, ...). +# WEBDAV_URL is the share's WebDAV endpoint, e.g. +# https://cloud.example.com/remote.php/dav/files/; WEBDAV_ROOT narrows +# it to one folder. Use a dedicated account with read access only - an app +# password in Nextcloud. Credentials stay on the server. A share on a private +# network also needs TRYPOST_ALLOW_PRIVATE_NETWORK=true. +WEBDAV_ENABLED=false +WEBDAV_URL= +WEBDAV_USERNAME= +WEBDAV_PASSWORD= +WEBDAV_ROOT= +WEBDAV_LABEL=WebDAV + # Optional host overrides (defaults shown) # UNSPLASH_API_URL=https://api.unsplash.com # UNSPLASH_WEBSITE_URL=https://unsplash.com diff --git a/app/Enums/Media/Source.php b/app/Enums/Media/Source.php index 2239e7a853..47e577a673 100644 --- a/app/Enums/Media/Source.php +++ b/app/Enums/Media/Source.php @@ -19,11 +19,12 @@ enum Source: string case GoogleDrive = 'google_drive'; case GooglePhotos = 'google_photos'; case Canva = 'canva'; + case Webdav = 'webdav'; /** @return list */ public static function pickerSources(): array { - return [self::Canva, self::Giphy, self::GoogleDrive, self::GooglePhotos, self::Unsplash]; + return [self::Canva, self::Giphy, self::GoogleDrive, self::GooglePhotos, self::Unsplash, self::Webdav]; } public function isEnabled(): bool @@ -40,6 +41,10 @@ public function isEnabled(): bool self::Canva => (bool) config('trypost.media_sources.canva.enabled') && filled(config('services.canva.client_id')) && filled(config('services.canva.client_secret')), + self::Webdav => (bool) config('trypost.media_sources.webdav.enabled') + && filled(config('trypost.media_sources.webdav.url')) + && filled(config('trypost.media_sources.webdav.username')) + && filled(config('trypost.media_sources.webdav.password')), self::Ai => false, }; } @@ -64,6 +69,7 @@ public function label(): string self::GoogleDrive => 'Google Drive', self::GooglePhotos => 'Google Photos', self::Canva => 'Canva', + self::Webdav => (string) config('trypost.media_sources.webdav.label') ?: 'WebDAV', }; } @@ -72,6 +78,8 @@ public function downloadHosts(): array { $hosts = match ($this) { self::Unsplash, self::Giphy, self::GoogleDrive, self::GooglePhotos, self::Canva => config("trypost.media_sources.{$this->value}.download_hosts"), + // Exactly the configured share, nothing else. + self::Webdav => (string) parse_url((string) config('trypost.media_sources.webdav.url'), PHP_URL_HOST), default => '', }; diff --git a/app/Http/Controllers/App/WebdavMediaController.php b/app/Http/Controllers/App/WebdavMediaController.php new file mode 100644 index 0000000000..8c9a297d13 --- /dev/null +++ b/app/Http/Controllers/App/WebdavMediaController.php @@ -0,0 +1,34 @@ +isEnabled(), Response::HTTP_NOT_FOUND); + + try { + return response()->json(WebdavFiles::browse((string) $request->validated('path', ''))); + } catch (InvalidArgumentException) { + return response()->json(['message' => __('posts.composer.media_sources.webdav.load_failed')], Response::HTTP_UNPROCESSABLE_ENTITY); + } catch (RuntimeException $exception) { + // The share's address and answer help the operator; the user gets + // a plain message. + Log::warning('WebDAV listing failed', ['message' => $exception->getMessage()]); + + return response()->json(['message' => __('posts.composer.media_sources.webdav.load_failed')], Response::HTTP_BAD_GATEWAY); + } + } +} diff --git a/app/Http/Requests/App/Media/BrowseWebdavRequest.php b/app/Http/Requests/App/Media/BrowseWebdavRequest.php new file mode 100644 index 0000000000..ea5268683c --- /dev/null +++ b/app/Http/Requests/App/Media/BrowseWebdavRequest.php @@ -0,0 +1,26 @@ +user()->can('createPost', $this->user()->currentWorkspace); + } + + /** + * @return array> + */ + public function rules(): array + { + return [ + 'path' => ['sometimes', 'nullable', 'string', 'max:'.WebdavFiles::MAX_PATH_LENGTH], + ]; + } +} diff --git a/app/Http/Requests/App/Media/StoreMediaImportRequest.php b/app/Http/Requests/App/Media/StoreMediaImportRequest.php index 60473c1f7e..0c5ff8fef2 100644 --- a/app/Http/Requests/App/Media/StoreMediaImportRequest.php +++ b/app/Http/Requests/App/Media/StoreMediaImportRequest.php @@ -10,10 +10,12 @@ use App\Services\Media\RemoteMediaImporter; use App\Services\Media\Sources\GoogleDriveFiles; use App\Services\Media\Sources\GooglePhotosPicker; +use App\Services\Media\Sources\WebdavFiles; use Closure; use Illuminate\Foundation\Http\FormRequest; use Illuminate\Support\Uri; use Illuminate\Validation\Rule; +use InvalidArgumentException; use LogicException; /** @@ -153,6 +155,32 @@ function (string $attribute, mixed $value, Closure $fail): void { 'payload' => fn (): string => (string) $this->validated('session_id'), 'types' => MediaType::cases(), ], + Source::Webdav->value => [ + 'rules' => fn (): array => [ + 'file' => ['required', 'array:path'], + 'file.path' => [ + 'bail', + 'required', + 'string', + 'max:'.WebdavFiles::MAX_PATH_LENGTH, + function (string $attribute, mixed $value, Closure $fail): void { + try { + $path = WebdavFiles::normalize((string) $value); + } catch (InvalidArgumentException) { + $path = ''; + } + + if ($path === '') { + $fail(__('validation.invalid', ['attribute' => $attribute])); + } + }, + ], + ], + 'payload' => fn (): RemoteFile => WebdavFiles::toRemoteFile((string) $this->validated('file.path')), + // The browser only lists images and videos; a document on the + // share is refused even when its path is posted by hand. + 'types' => [MediaType::Image, MediaType::Video], + ], ]; } diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index af36682266..879e7b101c 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -216,6 +216,12 @@ protected function configureRateLimiting(): void ->by("user:{$request->user()?->id}"), ); + RateLimiter::for( + 'webdav', + fn (Request $request): Limit => Limit::perMinute((int) config('trypost.media_sources.webdav.requests_per_user_per_minute')) + ->by("user:{$request->user()?->id}"), + ); + RateLimiter::for( 'unsplash', fn (Request $request): Limit => Limit::perMinute((int) config('trypost.media_sources.unsplash.requests_per_user_per_minute')) diff --git a/app/Services/Media/Sources/WebdavFiles.php b/app/Services/Media/Sources/WebdavFiles.php new file mode 100644 index 0000000000..4d0ad12e81 --- /dev/null +++ b/app/Services/Media/Sources/WebdavFiles.php @@ -0,0 +1,253 @@ + + + + + + + + + + XML; + + /** + * One folder level: sub-folders first, then images and videos, each sorted + * by name. Hidden entries and other file types are left out. + * + * @return array{path: string, entries: list} + */ + public static function browse(string $path): array + { + $path = self::normalize($path); + + try { + $response = Http::withBasicAuth(self::username(), self::password()) + ->timeout(self::TIMEOUT_SECONDS) + ->withoutRedirecting() + ->withHeaders(['Depth' => '1']) + ->withBody(self::PROPFIND_BODY, 'application/xml; charset=utf-8') + ->send('PROPFIND', self::url($path, folder: true)); + } catch (ConnectionException $exception) { + throw new RuntimeException('The WebDAV share could not be reached.', previous: $exception); + } + + if ($response->status() !== Response::HTTP_MULTI_STATUS) { + throw new RuntimeException("The WebDAV share answered {$response->status()}."); + } + + $entries = self::parse($response->body(), $path); + + usort($entries, fn (array $a, array $b): int => [$a['type'] === 'file', mb_strtolower($a['name'])] <=> [$b['type'] === 'file', mb_strtolower($b['name'])]); + + return ['path' => $path, 'entries' => $entries]; + } + + /** + * The download the import job runs, with the share credentials attached. + */ + public static function toRemoteFile(string $path): RemoteFile + { + $path = self::normalize($path); + + if ($path === '') { + throw new InvalidArgumentException('A file path is required.'); + } + + return new RemoteFile( + self::url($path), + basename($path), + ['Authorization' => 'Basic '.base64_encode(self::username().':'.self::password())], + Source::Webdav->downloadHosts(), + Source::Webdav, + ['path' => $path], + ); + } + + /** + * A path below the root, as segments joined by "/". Empty, "." and ".." + * segments are rejected outright rather than resolved, so a path can + * never climb out of the configured root. + */ + public static function normalize(string $path): string + { + if (mb_strlen($path) > self::MAX_PATH_LENGTH || preg_match('/[\x00-\x1F\x7F\\\\]/u', $path) === 1) { + throw new InvalidArgumentException('Invalid WebDAV path.'); + } + + $path = trim($path, '/'); + + if ($path === '') { + return ''; + } + + foreach (explode('/', $path) as $segment) { + if ($segment === '' || $segment === '.' || $segment === '..') { + throw new InvalidArgumentException('Invalid WebDAV path.'); + } + } + + return $path; + } + + /** + * @return list + */ + private static function parse(string $xml, string $currentPath): array + { + $document = new DOMDocument; + + // LIBXML_NONET: never fetch anything the response refers to. + if ($xml === '' || ! @$document->loadXML($xml, LIBXML_NONET)) { + throw new RuntimeException('The WebDAV share sent an unreadable listing.'); + } + + // Anything else is not a WebDAV listing - a login page, say - and + // must not read as an empty folder. + if ($document->documentElement?->namespaceURI !== 'DAV:' || $document->documentElement->localName !== 'multistatus') { + throw new RuntimeException('The WebDAV share did not answer with a listing.'); + } + + $xpath = new DOMXPath($document); + $xpath->registerNamespace('d', 'DAV:'); + + $basePath = self::basePath(); + $entries = []; + + foreach ($xpath->query('/d:multistatus/d:response') ?: [] as $response) { + if (! $response instanceof DOMElement) { + continue; + } + + $href = rawurldecode((string) parse_url(trim((string) $xpath->evaluate('string(d:href)', $response)), PHP_URL_PATH)); + + if (! str_starts_with(rtrim($href, '/').'/', $basePath.'/') && rtrim($href, '/') !== $basePath) { + continue; + } + + $relative = trim(substr(rtrim($href, '/'), strlen($basePath)), '/'); + + // The folder itself is part of every Depth: 1 answer. + if ($relative === $currentPath) { + continue; + } + + $name = basename($relative); + + if ($name === '' || str_starts_with($name, '.')) { + continue; + } + + $prop = 'd:propstat[contains(d:status, " 200 ")]/d:prop'; + + if ($xpath->evaluate("count({$prop}/d:resourcetype/d:collection)", $response) > 0) { + $entries[] = ['type' => 'folder', 'name' => $name, 'path' => $relative]; + + continue; + } + + $mime = self::mimeType(trim((string) $xpath->evaluate("string({$prop}/d:getcontenttype)", $response)), $name); + + if ($mime === null) { + continue; + } + + $modified = trim((string) $xpath->evaluate("string({$prop}/d:getlastmodified)", $response)); + $timestamp = $modified === '' ? false : strtotime($modified); + + $entries[] = [ + 'type' => 'file', + 'name' => $name, + 'path' => $relative, + 'mime' => $mime, + 'size' => (int) $xpath->evaluate("string({$prop}/d:getcontentlength)", $response), + 'modified' => $timestamp === false ? null : gmdate('c', $timestamp), + ]; + } + + return $entries; + } + + /** + * The reported type, or one guessed from the extension for servers that + * leave it out. Only images and videos are offered. + */ + private static function mimeType(string $reported, string $name): ?string + { + $mime = strtolower(trim(explode(';', $reported)[0])); + + if ($mime === '' || $mime === 'application/octet-stream') { + $mime = MimeTypes::getDefault()->getMimeTypes(strtolower(pathinfo($name, PATHINFO_EXTENSION)))[0] ?? ''; + } + + return str_starts_with($mime, 'image/') || str_starts_with($mime, 'video/') ? $mime : null; + } + + private static function url(string $path, bool $folder = false): string + { + $segments = array_filter([...self::rootSegments(), ...($path === '' ? [] : explode('/', $path))], fn (string $segment): bool => $segment !== ''); + $url = rtrim((string) config('trypost.media_sources.webdav.url'), '/').'/'.implode('/', array_map('rawurlencode', $segments)); + + return $folder ? rtrim($url, '/').'/' : $url; + } + + /** + * The decoded URL path of the root folder, without a trailing slash, which + * is what every href in a listing starts with. + */ + private static function basePath(): string + { + $sharePath = rawurldecode(rtrim((string) parse_url((string) config('trypost.media_sources.webdav.url'), PHP_URL_PATH), '/')); + + return rtrim($sharePath.'/'.implode('/', self::rootSegments()), '/'); + } + + /** + * @return list + */ + private static function rootSegments(): array + { + return array_values(array_filter(explode('/', trim((string) config('trypost.media_sources.webdav.root'), '/')), fn (string $segment): bool => $segment !== '')); + } + + private static function username(): string + { + return (string) config('trypost.media_sources.webdav.username'); + } + + private static function password(): string + { + return (string) config('trypost.media_sources.webdav.password'); + } +} diff --git a/config/trypost.php b/config/trypost.php index fee505ece0..965b9e8b19 100644 --- a/config/trypost.php +++ b/config/trypost.php @@ -255,6 +255,20 @@ 'export_timeout_seconds' => (int) env('CANVA_EXPORT_TIMEOUT_SECONDS', 120), 'export_poll_seconds' => (int) env('CANVA_EXPORT_POLL_SECONDS', 2), ], + // A WebDAV share (Nextcloud, ownCloud, ...) as a read-only source. + // The URL is the share's WebDAV endpoint; the root narrows it to one + // folder. Credentials never reach the browser. The share is fetched + // like any remote file, so a host on a private network also needs + // TRYPOST_ALLOW_PRIVATE_NETWORK. + 'webdav' => [ + 'enabled' => (bool) env('WEBDAV_ENABLED', false), + 'url' => env('WEBDAV_URL'), + 'username' => env('WEBDAV_USERNAME'), + 'password' => env('WEBDAV_PASSWORD'), + 'root' => env('WEBDAV_ROOT', ''), + 'label' => env('WEBDAV_LABEL', 'WebDAV'), + 'requests_per_user_per_minute' => (int) env('WEBDAV_REQUESTS_PER_MINUTE', 60), + ], 'import_timeout_seconds' => (int) env('MEDIA_IMPORT_TIMEOUT_SECONDS', 600), 'imports_per_user_per_minute' => (int) env('MEDIA_IMPORTS_PER_MINUTE', 30), ], diff --git a/docker/.env.docker.example b/docker/.env.docker.example index 6cfa90543a..d97b1b0302 100644 --- a/docker/.env.docker.example +++ b/docker/.env.docker.example @@ -219,6 +219,20 @@ GOOGLE_PHOTOS_ENABLED=false CANVA_ENABLED=true CANVA_CLIENT_ID= CANVA_CLIENT_SECRET= + +# WebDAV share as a read-only media source (Nextcloud, ownCloud, ...). +# WEBDAV_URL is the share's WebDAV endpoint, e.g. +# https://cloud.example.com/remote.php/dav/files/; WEBDAV_ROOT narrows +# it to one folder. Use a dedicated account with read access only - an app +# password in Nextcloud. Credentials stay on the server. A share on a private +# network also needs TRYPOST_ALLOW_PRIVATE_NETWORK=true. +WEBDAV_ENABLED=false +WEBDAV_URL= +WEBDAV_USERNAME= +WEBDAV_PASSWORD= +WEBDAV_ROOT= +WEBDAV_LABEL=WebDAV + # Optional host overrides (defaults shown) # UNSPLASH_API_URL=https://api.unsplash.com # UNSPLASH_WEBSITE_URL=https://unsplash.com diff --git a/lang/ar/posts.php b/lang/ar/posts.php index 3dc10bcca8..1614806bc7 100644 --- a/lang/ar/posts.php +++ b/lang/ar/posts.php @@ -78,6 +78,14 @@ 'more' => 'مزيد من مصادر الوسائط', 'select_from' => 'اختر من :source', 'importing' => 'جارٍ الاستيراد…', + 'webdav' => [ + 'root' => 'كل الملفات', + 'up' => 'رجوع', + 'loading' => 'جارٍ التحميل…', + 'empty' => 'لا توجد صور أو مقاطع فيديو في هذا المجلد.', + 'load_failed' => 'تعذّر فتح هذا المجلد.', + 'add' => 'إضافة (:count)', + ], 'canva_presets' => [ 'square' => 'مربع 1:1', 'portrait_4_5' => 'عمودي 4:5', diff --git a/lang/de/posts.php b/lang/de/posts.php index 34f8340ff5..b3568e57af 100644 --- a/lang/de/posts.php +++ b/lang/de/posts.php @@ -78,6 +78,14 @@ 'more' => 'Weitere Medienquellen', 'select_from' => 'Aus :source auswählen', 'importing' => 'Wird importiert…', + 'webdav' => [ + 'root' => 'Alle Dateien', + 'up' => 'Zurück', + 'loading' => 'Wird geladen…', + 'empty' => 'In diesem Ordner gibt es keine Bilder oder Videos.', + 'load_failed' => 'Dieser Ordner konnte nicht geöffnet werden.', + 'add' => 'Hinzufügen (:count)', + ], 'canva_presets' => [ 'square' => 'Quadrat 1:1', 'portrait_4_5' => 'Hochformat 4:5', diff --git a/lang/el/posts.php b/lang/el/posts.php index ca75240f9e..3f52c161a8 100644 --- a/lang/el/posts.php +++ b/lang/el/posts.php @@ -78,6 +78,14 @@ 'more' => 'Περισσότερες πηγές πολυμέσων', 'select_from' => 'Επιλογή από :source', 'importing' => 'Εισαγωγή…', + 'webdav' => [ + 'root' => 'Όλα τα αρχεία', + 'up' => 'Πίσω', + 'loading' => 'Φόρτωση…', + 'empty' => 'Δεν υπάρχουν εικόνες ή βίντεο σε αυτόν τον φάκελο.', + 'load_failed' => 'Δεν ήταν δυνατό το άνοιγμα αυτού του φακέλου.', + 'add' => 'Προσθήκη (:count)', + ], 'canva_presets' => [ 'square' => 'Τετράγωνο 1:1', 'portrait_4_5' => 'Κάθετο 4:5', diff --git a/lang/en/posts.php b/lang/en/posts.php index a0a5b2ad33..aa9dd6aa29 100644 --- a/lang/en/posts.php +++ b/lang/en/posts.php @@ -78,6 +78,14 @@ 'more' => 'More media sources', 'select_from' => 'Select from :source', 'importing' => 'Importing…', + 'webdav' => [ + 'root' => 'All files', + 'up' => 'Back', + 'loading' => 'Loading…', + 'empty' => 'No images or videos in this folder.', + 'load_failed' => 'This folder could not be opened.', + 'add' => 'Add (:count)', + ], 'canva_presets' => [ 'square' => 'Square 1:1', 'portrait_4_5' => 'Portrait 4:5', diff --git a/lang/es/posts.php b/lang/es/posts.php index cef0d686a2..3219c0c2f9 100644 --- a/lang/es/posts.php +++ b/lang/es/posts.php @@ -78,6 +78,14 @@ 'more' => 'Más fuentes de medios', 'select_from' => 'Seleccionar de :source', 'importing' => 'Importando…', + 'webdav' => [ + 'root' => 'Todos los archivos', + 'up' => 'Atrás', + 'loading' => 'Cargando…', + 'empty' => 'No hay imágenes ni vídeos en esta carpeta.', + 'load_failed' => 'No se pudo abrir esta carpeta.', + 'add' => 'Añadir (:count)', + ], 'canva_presets' => [ 'square' => 'Cuadrado 1:1', 'portrait_4_5' => 'Vertical 4:5', diff --git a/lang/fr/posts.php b/lang/fr/posts.php index 1891f413f1..ab10c376f8 100644 --- a/lang/fr/posts.php +++ b/lang/fr/posts.php @@ -78,6 +78,14 @@ 'more' => 'Plus de sources de médias', 'select_from' => 'Sélectionner depuis :source', 'importing' => 'Importation…', + 'webdav' => [ + 'root' => 'Tous les fichiers', + 'up' => 'Retour', + 'loading' => 'Chargement…', + 'empty' => 'Aucune image ni vidéo dans ce dossier.', + 'load_failed' => 'Impossible d\'ouvrir ce dossier.', + 'add' => 'Ajouter (:count)', + ], 'canva_presets' => [ 'square' => 'Carré 1:1', 'portrait_4_5' => 'Portrait 4:5', diff --git a/lang/id/posts.php b/lang/id/posts.php index 3c1204d29b..0f0c534bc4 100644 --- a/lang/id/posts.php +++ b/lang/id/posts.php @@ -78,6 +78,14 @@ 'more' => 'Sumber media lainnya', 'select_from' => 'Pilih dari :source', 'importing' => 'Mengimpor…', + 'webdav' => [ + 'root' => 'Semua file', + 'up' => 'Kembali', + 'loading' => 'Memuat…', + 'empty' => 'Tidak ada gambar atau video di folder ini.', + 'load_failed' => 'Folder ini tidak bisa dibuka.', + 'add' => 'Tambahkan (:count)', + ], 'canva_presets' => [ 'square' => 'Persegi 1:1', 'portrait_4_5' => 'Potret 4:5', diff --git a/lang/it/posts.php b/lang/it/posts.php index 10333e4082..22761f2502 100644 --- a/lang/it/posts.php +++ b/lang/it/posts.php @@ -78,6 +78,14 @@ 'more' => 'Altre fonti multimediali', 'select_from' => 'Seleziona da :source', 'importing' => 'Importazione…', + 'webdav' => [ + 'root' => 'Tutti i file', + 'up' => 'Indietro', + 'loading' => 'Caricamento…', + 'empty' => 'Nessuna immagine o video in questa cartella.', + 'load_failed' => 'Impossibile aprire questa cartella.', + 'add' => 'Aggiungi (:count)', + ], 'canva_presets' => [ 'square' => 'Quadrato 1:1', 'portrait_4_5' => 'Verticale 4:5', diff --git a/lang/ja/posts.php b/lang/ja/posts.php index 410f3995af..2b75eeb320 100644 --- a/lang/ja/posts.php +++ b/lang/ja/posts.php @@ -78,6 +78,14 @@ 'more' => 'その他のメディアソース', 'select_from' => ':source から選択', 'importing' => 'インポート中…', + 'webdav' => [ + 'root' => 'すべてのファイル', + 'up' => '戻る', + 'loading' => '読み込み中…', + 'empty' => 'このフォルダには画像や動画がありません。', + 'load_failed' => 'このフォルダを開けませんでした。', + 'add' => '追加 (:count)', + ], 'canva_presets' => [ 'square' => '正方形 1:1', 'portrait_4_5' => '縦長 4:5', diff --git a/lang/ko/posts.php b/lang/ko/posts.php index a77ae82b4f..f07f6566fb 100644 --- a/lang/ko/posts.php +++ b/lang/ko/posts.php @@ -78,6 +78,14 @@ 'more' => '더 많은 미디어 소스', 'select_from' => ':source에서 선택', 'importing' => '가져오는 중…', + 'webdav' => [ + 'root' => '모든 파일', + 'up' => '뒤로', + 'loading' => '불러오는 중…', + 'empty' => '이 폴더에 이미지나 동영상이 없습니다.', + 'load_failed' => '이 폴더를 열 수 없습니다.', + 'add' => '추가 (:count)', + ], 'canva_presets' => [ 'square' => '정사각형 1:1', 'portrait_4_5' => '세로 4:5', diff --git a/lang/nl/posts.php b/lang/nl/posts.php index d44eb6dc69..37f45e2c58 100644 --- a/lang/nl/posts.php +++ b/lang/nl/posts.php @@ -78,6 +78,14 @@ 'more' => 'Meer mediabronnen', 'select_from' => 'Selecteren uit :source', 'importing' => 'Importeren…', + 'webdav' => [ + 'root' => 'Alle bestanden', + 'up' => 'Terug', + 'loading' => 'Laden…', + 'empty' => 'Geen afbeeldingen of video\'s in deze map.', + 'load_failed' => 'Deze map kon niet worden geopend.', + 'add' => 'Toevoegen (:count)', + ], 'canva_presets' => [ 'square' => 'Vierkant 1:1', 'portrait_4_5' => 'Staand 4:5', diff --git a/lang/pl/posts.php b/lang/pl/posts.php index 902bbb392a..b45f28b6c8 100644 --- a/lang/pl/posts.php +++ b/lang/pl/posts.php @@ -78,6 +78,14 @@ 'more' => 'Więcej źródeł multimediów', 'select_from' => 'Wybierz z :source', 'importing' => 'Importowanie…', + 'webdav' => [ + 'root' => 'Wszystkie pliki', + 'up' => 'Wstecz', + 'loading' => 'Ładowanie…', + 'empty' => 'W tym folderze nie ma obrazów ani filmów.', + 'load_failed' => 'Nie udało się otworzyć tego folderu.', + 'add' => 'Dodaj (:count)', + ], 'canva_presets' => [ 'square' => 'Kwadrat 1:1', 'portrait_4_5' => 'Pionowy 4:5', diff --git a/lang/pt-BR/posts.php b/lang/pt-BR/posts.php index c509b4948e..37e63bb29b 100644 --- a/lang/pt-BR/posts.php +++ b/lang/pt-BR/posts.php @@ -78,6 +78,14 @@ 'more' => 'Mais fontes de mídia', 'select_from' => 'Selecionar de :source', 'importing' => 'Importando…', + 'webdav' => [ + 'root' => 'Todos os arquivos', + 'up' => 'Voltar', + 'loading' => 'Carregando…', + 'empty' => 'Não há imagens nem vídeos nesta pasta.', + 'load_failed' => 'Não foi possível abrir esta pasta.', + 'add' => 'Adicionar (:count)', + ], 'canva_presets' => [ 'square' => 'Quadrado 1:1', 'portrait_4_5' => 'Retrato 4:5', diff --git a/lang/ru/posts.php b/lang/ru/posts.php index 4734305993..8de7243ca6 100644 --- a/lang/ru/posts.php +++ b/lang/ru/posts.php @@ -78,6 +78,14 @@ 'more' => 'Другие источники медиа', 'select_from' => 'Выбрать из :source', 'importing' => 'Импорт…', + 'webdav' => [ + 'root' => 'Все файлы', + 'up' => 'Назад', + 'loading' => 'Загрузка…', + 'empty' => 'В этой папке нет изображений или видео.', + 'load_failed' => 'Не удалось открыть эту папку.', + 'add' => 'Добавить (:count)', + ], 'canva_presets' => [ 'square' => 'Квадрат 1:1', 'portrait_4_5' => 'Портрет 4:5', diff --git a/lang/tr/posts.php b/lang/tr/posts.php index df4fee9ed0..7ee76026cd 100644 --- a/lang/tr/posts.php +++ b/lang/tr/posts.php @@ -78,6 +78,14 @@ 'more' => 'Daha fazla medya kaynağı', 'select_from' => ':source kaynağından seç', 'importing' => 'İçe aktarılıyor…', + 'webdav' => [ + 'root' => 'Tüm dosyalar', + 'up' => 'Geri', + 'loading' => 'Yükleniyor…', + 'empty' => 'Bu klasörde görsel veya video yok.', + 'load_failed' => 'Bu klasör açılamadı.', + 'add' => 'Ekle (:count)', + ], 'canva_presets' => [ 'square' => 'Kare 1:1', 'portrait_4_5' => 'Dikey 4:5', diff --git a/lang/uk/posts.php b/lang/uk/posts.php index 100bf78f69..731f20250e 100644 --- a/lang/uk/posts.php +++ b/lang/uk/posts.php @@ -78,6 +78,14 @@ 'more' => 'Інші джерела медіа', 'select_from' => 'Вибрати з :source', 'importing' => 'Імпорт…', + 'webdav' => [ + 'root' => 'Усі файли', + 'up' => 'Назад', + 'loading' => 'Завантаження…', + 'empty' => 'У цій папці немає зображень або відео.', + 'load_failed' => 'Не вдалося відкрити цю папку.', + 'add' => 'Додати (:count)', + ], 'canva_presets' => [ 'square' => 'Квадрат 1:1', 'portrait_4_5' => 'Портрет 4:5', diff --git a/lang/zh/posts.php b/lang/zh/posts.php index be9f9a31de..a8360ec04d 100644 --- a/lang/zh/posts.php +++ b/lang/zh/posts.php @@ -78,6 +78,14 @@ 'more' => '更多媒体来源', 'select_from' => '从 :source 选择', 'importing' => '正在导入…', + 'webdav' => [ + 'root' => '所有文件', + 'up' => '返回', + 'loading' => '加载中…', + 'empty' => '此文件夹中没有图片或视频。', + 'load_failed' => '无法打开此文件夹。', + 'add' => '添加 (:count)', + ], 'canva_presets' => [ 'square' => '方形 1:1', 'portrait_4_5' => '竖版 4:5', diff --git a/resources/js/components/media/WebdavBrowserDialog.vue b/resources/js/components/media/WebdavBrowserDialog.vue new file mode 100644 index 0000000000..30c4a75be5 --- /dev/null +++ b/resources/js/components/media/WebdavBrowserDialog.vue @@ -0,0 +1,263 @@ + + + diff --git a/resources/js/components/posts/composer/MediaSourceMenu.vue b/resources/js/components/posts/composer/MediaSourceMenu.vue index f9b57baf3f..01cb8bb013 100644 --- a/resources/js/components/posts/composer/MediaSourceMenu.vue +++ b/resources/js/components/posts/composer/MediaSourceMenu.vue @@ -1,6 +1,6 @@