-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #962 from nextcloud-libraries/fix/use-preview-cont…
…roller
- Loading branch information
Showing
9 changed files
with
343 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,33 @@ | ||
import { GettextExtractor, JsExtractors } from 'gettext-extractor' | ||
import { GettextExtractor, JsExtractors, HtmlExtractors } from 'gettext-extractor' | ||
|
||
let extractor = new GettextExtractor(); | ||
const extractor = new GettextExtractor() | ||
|
||
extractor | ||
.createJsParser([ | ||
JsExtractors.callExpression('t', { | ||
arguments: { | ||
text: 0, | ||
} | ||
}), | ||
JsExtractors.callExpression('n', { | ||
arguments: { | ||
text: 1, | ||
textPlural: 2, | ||
} | ||
}), | ||
]) | ||
.parseFilesGlob('./lib/**/*.@(ts|js|vue)'); | ||
const jsParser = extractor.createJsParser([ | ||
JsExtractors.callExpression('t', { | ||
arguments: { | ||
text: 0, | ||
}, | ||
}), | ||
JsExtractors.callExpression('n', { | ||
arguments: { | ||
text: 0, | ||
textPlural: 1, | ||
}, | ||
}), | ||
]) | ||
.parseFilesGlob('./lib/**/*.@(ts|js)') | ||
|
||
extractor.savePotFile('./l10n/messages.pot'); | ||
extractor.createHtmlParser([ | ||
HtmlExtractors.embeddedJs('*', jsParser), | ||
HtmlExtractors.embeddedAttributeJs(/:[a-z]+/, jsParser), | ||
]) | ||
.parseFilesGlob('./lib/**/*.vue') | ||
|
||
extractor.printStats(); | ||
// remove references to avoid conflicts | ||
extractor.getMessages().forEach((msg) => { | ||
msg.references = [] | ||
}) | ||
|
||
extractor.savePotFile('./l10n/messages.pot') | ||
|
||
extractor.printStats() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<template> | ||
<div :style="canLoadPreview ? { backgroundImage: `url(${previewURL})`} : undefined" | ||
:aria-label="t('Mime type {mime}', { mime: node.mime || t('unknown') })" | ||
class="file-picker__file-icon"> | ||
<template v-if="!canLoadPreview"> | ||
<IconFile v-if="isFile" :size="20" /> | ||
<IconFolder v-else :size="20" /> | ||
</template> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { FileType, type Node } from '@nextcloud/files' | ||
import { usePreviewURL } from '../../usables/preview' | ||
import { computed, ref, toRef, watch } from 'vue' | ||
import { t } from '../../utils/l10n' | ||
import IconFile from 'vue-material-design-icons/File.vue' | ||
import IconFolder from 'vue-material-design-icons/Folder.vue' | ||
const props = defineProps<{ | ||
node: Node | ||
}>() | ||
const { previewURL } = usePreviewURL(toRef(props, 'node')) | ||
const isFile = computed(() => props.node.type === FileType.File) | ||
const canLoadPreview = ref(false) | ||
watch(previewURL, () => { | ||
canLoadPreview.value = false | ||
if (previewURL.value) { | ||
const loader = document.createElement('img') | ||
loader.src = previewURL.value.href | ||
loader.onerror = () => loader.remove() | ||
loader.onload = () => { canLoadPreview.value = true; loader.remove() } | ||
document.body.appendChild(loader) | ||
} | ||
}, { immediate: true }) | ||
</script> | ||
|
||
<style scoped lang="scss"> | ||
.file-picker__file-icon { | ||
width: 32px; | ||
height: 32px; | ||
min-width: 32px; | ||
min-height: 32px; | ||
background-repeat: no-repeat; | ||
background-size: contain; | ||
// for the fallback | ||
display: flex; | ||
justify-content: center; | ||
} | ||
</style> |
Oops, something went wrong.