Skip to content

Commit

Permalink
Improve display of download distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
stefandesu committed Dec 2, 2024
1 parent be5d920 commit fce69b0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 2 additions & 0 deletions locale.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"loadConceptError": "Konzeptdetails konnten nicht geladen werden. Entweder existiert das Konzept nicht oder es gibt Probleme beim Zugriff auf das Backend.",
"loadUriError": "Diese Anfrage führt leider ins Leere.",
"searchInVocabulary": "in {voc} suchen",
"sizeUnknown": "Größe unbekannt",
"startDate": "Startdatum",
"endDate": "Enddatum",
"startPlace": "Startort",
Expand All @@ -44,6 +45,7 @@
"loadConceptError": "Concept details could not be loaded. Either the concept does not exist, or there are issues with the backend.",
"loadUriError": "Unfortunately, this request was not successful.",
"searchInVocabulary": "search in {voc}",
"sizeUnknown": "size unknown",
"startDate": "Start Date",
"endDate": "End Date",
"startPlace": "Start Place",
Expand Down
9 changes: 9 additions & 0 deletions src/client/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ import formats from "@/formats.json"
formats["http://format.gbv.de/jskos"] = "JSKOS"
export { formats }

export function getFormat(distribution) {
if (formats[distribution?.format]) {
return formats[distribution?.format]
}
// Try to guess format from URL
const [, format] = distribution?.download?.match?.(/(?:download|format)=([^&]*)/) || []
return format ? format.toUpperCase() : "?"
}

export const quickSelection = computed(() => config.quickSelection.map(scheme => schemes.value?.find(s => jskos.compare(s, scheme))).filter(Boolean))

export const publisherSelection = computed(() => {
Expand Down
8 changes: 4 additions & 4 deletions src/client/views/ItemView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import config from "@/config.js"
import * as jskos from "jskos-tools"
import { AutoLink, LicenseInfo } from "jskos-vue"
import { schemes, loadTop, loadNarrower, loadConcept, loadAncestors, saveConcept, formats, getConceptByUri, detailsLoadedKey, detailsLoadedStates } from "@/store.js"
import { schemes, loadTop, loadNarrower, loadConcept, loadAncestors, saveConcept, getFormat, getConceptByUri, detailsLoadedKey, detailsLoadedStates } from "@/store.js"
import { computed, ref, reactive, watch } from "vue"
import { useRoute, useRouter } from "vue-router"
import { utils } from "jskos-vue"
Expand Down Expand Up @@ -299,11 +299,11 @@ const topConcepts = computed(() => {
download>
{{ distribution.created || "Download" }}
</a>
(<a
(<auto-link
:href="distribution.format"
target="_blank">
{{ formats[distribution.format] }}
</a>, {{ distribution.size }}) {{ jskos.languageMapContent(distribution, "definition")?.[0] || "" }}
{{ getFormat(distribution) }}
</auto-link>, {{ distribution.size || $t("sizeUnknown") }}) {{ jskos.languageMapContent(distribution, "definition")?.[0] || "" }}
</li>
</ul>
<p v-if="concept?.[detailsLoadedKey] === detailsLoadedStates.basicData">
Expand Down

0 comments on commit fce69b0

Please sign in to comment.