Compare commits

..

No commits in common. "e84c665e7cf1f6920f89ed3eff9131e9c7507539" and "ccad83b8ec5ee8a760115b04365632596c80cf52" have entirely different histories.

4 changed files with 30 additions and 17 deletions

View File

@ -91,7 +91,8 @@
} }
.headermain, .headermain,
.menu, .menu,
.rename-button { .rename-button,
.suggest-gallery {
display: none !important; display: none !important;
} }
.breadcrumb > a { .breadcrumb > a {

View File

@ -37,24 +37,21 @@ export class Doc {
return this.url.replace(/^\/#/, '') return this.url.replace(/^\/#/, '')
} }
get img(): boolean { get img(): boolean {
// Folders cannot be images const ext = this.name.split('.').pop()?.toLowerCase() || ''
if (this.dir) return false return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'heic', 'heif', 'svg'].includes(ext)
return ['jpg', 'jpeg', 'png', 'gif', 'webp', 'avif', 'heic', 'heif', 'svg'].includes(this.ext)
} }
get previewable(): boolean { get previewable(): boolean {
// Folders cannot be previewable
if (this.dir) return false
if (this.img) return true if (this.img) return true
const ext = this.name.split('.').pop()?.toLowerCase() || ''
// Not a comprehensive list, but good enough for now // Not a comprehensive list, but good enough for now
return ['mp4', 'mkv', 'webm', 'ogg', 'mp3', 'flac', 'aac', 'pdf'].includes(this.ext) return ['mp4', 'mkv', 'webm', 'ogg', 'mp3', 'flac', 'aac', 'pdf'].includes(ext)
} }
get previewurl(): string { get previewurl(): string {
return this.url.replace(/^\/files/, '/preview') return this.url.replace(/^\/files/, '/preview')
} }
get ext(): string { get ext(): string {
const dotIndex = this.name.lastIndexOf('.') const ext = this.name.split('.').pop()
if (dotIndex === -1 || dotIndex === this.name.length - 1) return '' return ext ? ext.toLowerCase() : ''
return this.name.slice(dotIndex + 1).toLowerCase()
} }
} }
export type errorEvent = { export type errorEvent = {

View File

@ -50,11 +50,12 @@ export function formatUnixDate(t: number) {
} }
export function getFileExtension(filename: string) { export function getFileExtension(filename: string) {
const dotIndex = filename.lastIndexOf('.') const parts = filename.split('.')
if (dotIndex === -1 || dotIndex === filename.length - 1) { if (parts.length > 1) {
return '' // No extension return parts[parts.length - 1]
} else {
return '' // No hay extensión
} }
return filename.slice(dotIndex + 1)
} }
interface FileTypes { interface FileTypes {
[key: string]: string[] [key: string]: string[]
@ -67,9 +68,8 @@ const filetypes: FileTypes = {
} }
export function getFileType(name: string): string { export function getFileType(name: string): string {
const dotIndex = name.lastIndexOf('.') const ext = name.split('.').pop()?.toLowerCase()
if (dotIndex === -1 || dotIndex === name.length - 1) return 'unknown' if (!ext || ext.length === name.length) return 'unknown'
const ext = name.slice(dotIndex + 1).toLowerCase()
return Object.keys(filetypes).find(type => filetypes[type].includes(ext)) || 'unknown' return Object.keys(filetypes).find(type => filetypes[type].includes(ext)) || 'unknown'
} }

View File

@ -13,6 +13,10 @@
:path="props.path" :path="props.path"
:documents="documents" :documents="documents"
/> />
<div v-if="!store.prefs.gallery && documents.some(doc => doc.previewable)" class="suggest-gallery">
<SvgButton name="eye" taborder=0 @click="() => { store.prefs.gallery = true }"></SvgButton>
Gallery View
</div>
<EmptyFolder :documents=documents :path=props.path /> <EmptyFolder :documents=documents :path=props.path />
</template> </template>
@ -89,4 +93,15 @@ watch(documents, (docs) => {
text-shadow: 0 0 .3rem #000, 0 0 2rem #0008; text-shadow: 0 0 .3rem #000, 0 0 2rem #0008;
color: var(--accent-color); color: var(--accent-color);
} }
.suggest-gallery p {
font-size: 2rem;
color: var(--accent-color);
}
.suggest-gallery {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style> </style>