Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

New image details page (#682)

Krystle Salazarbd51a93abc64
diff --git a/src/components/CopyButton.vue b/src/components/CopyButton.vue
index 8b143244d..378ef615a 100644
--- a/src/components/CopyButton.vue
+++ b/src/components/CopyButton.vue
@@ -1,17 +1,17 @@
<template>
- <button
+ <VButton
:id="id"
type="button"
- class="button tiny donate"
+ variant="secondary"
:data-clipboard-target="el"
>
<span v-if="!success">
- {{ $t('photo-details.copy.copy') }}
+ {{ $t('media-details.reuse.copy-license.copy-text') }}
</span>
<span v-else>
- {{ $t('photo-details.copy.copied') }}
+ {{ $t('media-details.reuse.copy-license.copied') }}
</span>
- </button>
+ </VButton>
</template>
<script>
@@ -59,8 +59,7 @@ export default {
</script>
<style lang="scss" scoped>
-.button {
- @apply py-0 px-3 mt-4;
- font-size: 15px;
+button {
+ @apply py-2 px-3 text-sr;
}
</style>
diff --git a/src/components/ImageDetails/ImageAttribution.vue b/src/components/ImageDetails/ImageAttribution.vue
deleted file mode 100644
index 0690dad73..000000000
--- a/src/components/ImageDetails/ImageAttribution.vue
+++ /dev/null
@@ -1,50 +0,0 @@
-<template>
- <section class="sidebar_section">
- <MediaLicense
- :full-license-name="fullLicenseName"
- :license="image.license"
- :license-url="licenseUrlRichText"
- />
- <CopyLicense
- :media="image"
- :full-license-name="fullLicenseName"
- :license-url="licenseUrlRichText"
- :attribution-html="attributionHtml"
- class="my-6"
- />
- </section>
-</template>
-
-<script>
-import attributionHtml from '~/utils/attribution-html'
-import CopyLicense from '~/components/MediaInfo/CopyLicense.vue'
-import MediaLicense from '~/components/MediaInfo/MediaLicense.vue'
-
-export default {
- name: 'ImageAttribution',
- components: {
- CopyLicense,
- MediaLicense,
- },
- props: {
- image: {
- type: Object,
- },
- licenseUrl: {
- type: String,
- },
- fullLicenseName: {
- type: String,
- },
- },
- computed: {
- licenseUrlRichText() {
- return `${this.licenseUrl}&atype=rich`
- },
- attributionHtml() {
- const licenseUrl = `${this.licenseUrl}&atype=html`
- return attributionHtml(this.image, licenseUrl, this.fullLicenseName)
- },
- },
-}
-</script>
diff --git a/src/components/ImageDetails/ImageInfo.vue b/src/components/ImageDetails/ImageInfo.vue
deleted file mode 100644
index 4248fec70..000000000
--- a/src/components/ImageDetails/ImageInfo.vue
+++ /dev/null
@@ -1,112 +0,0 @@
-<template>
- <section class="sidebar_section">
- <div class="mb-6">
- <dl>
- <dt class="mb-2">
- {{ $t('photo-details.information.type') }}
- </dt>
- <dd>{{ prettyImageType }}</dd>
- <dt class="mb-2">
- {{ $t('photo-details.information.dimensions') }}
- </dt>
- <dd>
- <!-- eslint-disable @intlify/vue-i18n/no-raw-text -->
- {{ imageWidth }} &times; {{ imageHeight }}
- <!-- eslint-enable -->
- {{ $t('photo-details.information.pixels') }}
- </dd>
- <dt v-if="providerName != sourceName" class="mb-2">
- {{ $t('photo-details.information.provider') }}
- </dt>
- <dd v-if="providerName != sourceName">
- {{ providerName }}
- </dd>
- <dt class="mb-2">
- {{ $t('photo-details.information.source') }}
- </dt>
- <dd>
- <a
- :href="image.foreign_landing_url"
- target="blank"
- rel="noopener noreferrer"
- @click="onPhotoSourceLinkClicked"
- @keyup.enter="onPhotoSourceLinkClicked"
- >
- {{ sourceName }}
- </a>
- </dd>
- </dl>
- </div>
- <div class="mb-6">
- <h5 class="mb-2 b-header">
- {{ $t('photo-details.information.tags') }}
- </h5>
- <PhotoTags :tags="image.tags" :show-header="false" />
- </div>
- </section>
-</template>
-
-<script>
-import {
- SEND_DETAIL_PAGE_EVENT,
- DETAIL_PAGE_EVENTS,
-} from '~/constants/usage-data-analytics-types'
-import PhotoTags from '~/components/PhotoTags'
-import getProviderName from '~/utils/get-provider-name'
-import { PROVIDER, USAGE_DATA } from '~/constants/store-modules'
-import { mapActions, mapState } from 'vuex'
-
-export default {
- name: 'ImageInfo',
- components: {
- PhotoTags,
- },
- props: [
- 'image',
- 'licenseUrl',
- 'fullLicenseName',
- 'imageWidth',
- 'imageHeight',
- 'imageType',
- ],
- computed: {
- ...mapState(PROVIDER, ['imageProviders']),
- providerName() {
- return getProviderName(this.imageProviders, this.$props.image.provider)
- },
- prettyImageType() {
- if (this.imageType && this.imageType.split('/').length > 1) {
- return this.imageType.split('/')[1].toUpperCase()
- }
- return 'Unknown'
- },
- sourceName() {
- return getProviderName(this.imageProviders, this.$props.image.source)
- },
- },
- methods: {
- ...mapActions(USAGE_DATA, { sendEvent: SEND_DETAIL_PAGE_EVENT }),
- onPhotoSourceLinkClicked() {
- this.sendEvent({
- eventType: DETAIL_PAGE_EVENTS.SOURCE_CLICKED,
- resultUuid: this.$props.image.id,
- })
- },
- },
-}
-</script>
-
-<style lang="scss" scoped>
-dl {
- display: flex;
- flex-wrap: wrap;
-}
-
-dt {
- @apply font-bold inline-block me-6 w-24;
-}
-
-dd {
- width: calc(100% - 92px - 28px);
-}
-</style>
diff --git a/src/components/ImageDetails/VPhotoDetails.vue b/src/components/ImageDetails/VPhotoDetails.vue
deleted file mode 100644
index 49e9df73c..000000000
--- a/src/components/ImageDetails/VPhotoDetails.vue
+++ /dev/null
@@ -1,321 +0,0 @@
-<template>
- <div class="photo columns is-desktop px-6 md:px-14 pb-16">
- <div class="column is-three-fifths photo_image-ctr mt-4">
- <a
- v-if="shouldShowBreadcrumb"
- class="flex photo_breadcrumb text-left mb-4 lg:ms-0 text-dark-gray font-semibold caption"
- :href="breadCrumbURL"
- @click.prevent="goBackToSearchResults"
- >
- <VIcon :icon-path="icons.chevronLeft" class="me-2" />
- {{ $t('photo-details.back') }}
- </a>
-
- <img
- v-show="!sketchFabUid"
- :class="{ photo_image: true, loading: !isLoaded }"
- :src="imgUrl"
- :alt="image.title"
- @load="onImageLoad"
- />
-
- <SketchFabViewer
- v-if="sketchFabUid"
- :uid="sketchFabUid"
- @failure="sketchFabfailure = true"
- />
-
- <p class="caption text-left text-dark-gray mt-4 mb-2 ms-4 lg:ms-0">
- {{ $t('photo-details.legal-disclaimer') }}
- </p>
-
- <VPopover
- :z-index="20"
- :aria-label="$t('photo-details.content-report.title')"
- >
- <template #trigger="{ a11yProps }">
- <VButton v-bind="a11yProps" variant="plain" class="mt-2">
- {{ $t('photo-details.content-report.title') }}
- <VIcon
- :icon-path="icons.flag"
- class="text-trans-blue ms-2 text-sm"
- />
- </VButton>
- </template>
- <template #default="{ close }">
- <VContentReportForm
- :image="image"
- :provider-name="providerName"
- data-testid="content-report-form"
- class="mt-2 text-left w-80 whitespace-normal"
- @close-form="close"
- />
- </template>
- </VPopover>
- </div>
- <div
- role="region"
- :aria-label="$t('photo-details.aria.details')"
- class="column image-info md:ms-10"
- >
- <div class="my-4">
- <h1 v-if="isLoaded" class="text-6xl">{{ image.title }}</h1>
- <i18n
- v-if="image.creator"
- class="caption"
- path="photo-details.creator"
- tag="span"
- >
- <template #name>
- <a
- v-if="image.creator_url"
- :aria-label="
- $t('photo-details.aria.creator-url', { creator: image.creator })
- "
- :href="image.creator_url"
- @click="linkClicked.creatorLink"
- >
- {{ image.creator }}
- </a>
- <span v-else>{{ image.creator }}</span>
- </template>
- </i18n>
- </div>
- <section class="tabs">
- <div role="tablist" :aria-label="$t('photo-details.aria.details')">
- <button
- id="reuse"
- role="tab"
- type="button"
- aria-controls="tab-reuse"
- :aria-selected="activeTab === 0"
- :class="tabClass(0, 'tab')"
- @click.prevent="setActiveTab(0)"
- >
- {{ $t('photo-details.reuse.title') }}
- </button>
- <button
- id="information"
- role="tab"
- type="button"
- aria-controls="tab-information"
- :aria-selected="activeTab === 1"
- :class="tabClass(1, 'tab')"
- @click.prevent="setActiveTab(1)"
- >
- {{ $t('photo-details.information.title') }}
- </button>
- </div>
- <div
- id="tab-reuse"
- role="tabpanel"
- aria-labelledby="reuse"
- tabindex="0"
- :class="tabClass(0, 'tabs-panel')"
- >
- <ImageAttribution
- data-testid="image-attribution"
- :image="image"
- :license-url="license.url"
- :full-license-name="license.fullName"
- />
- </div>
- <div
- id="tab-information"
- role="tabpanel"
- aria-labelledby="information"
- tabindex="0"
- :class="tabClass(1, 'tabs-panel')"
- >
- <ImageInfo
- data-testid="image-info"
- :image="image"
- :license-url="license.url"
- :full-license-name="license.fullName"
- :image-width="imageWidth"
- :image-height="imageHeight"
- :image-type="imageType"
- />
- </div>
- </section>
-
- <a
- data-testid="source-button"
- :href="image.foreign_landing_url"
- target="_blank"
- rel="noopener"
- class="button is-success mb-2 mt-4"
- @click="linkClicked.photoSource"
- >
- {{ $t('photo-details.weblink') }}
- <VIcon
- class="inline ms-4 pt-1 text-base text-light-gray"
- :icon-path="icons.externalLink"
- rtl-flip
- />
- </a>
-
- <ReuseSurvey :image="image" />
- </div>
- </div>
-</template>
-
-<script>
-import { computed, ref, useContext, useRouter } from '@nuxtjs/composition-api'
-
-import { USAGE_DATA } from '~/constants/store-modules'
-import {
- SEND_DETAIL_PAGE_EVENT,
- DETAIL_PAGE_EVENTS,
-} from '~/constants/usage-data-analytics-types'
-
-import { getFullLicenseName } from '~/utils/license'
-
-import chevronLeft from '~/assets/icons/chevron-left.svg'
-import flag from '~/assets/icons/flag.svg'
-import externalLink from '~/assets/icons/external-link.svg'
-
-import ReuseSurvey from '~/components/ImageDetails/ReuseSurvey.vue'
-import VButton from '~/components/VButton.vue'
-import VIcon from '~/components/VIcon/VIcon.vue'
-import VContentReportForm from '~/components/VContentReport/VContentReportForm.vue'
-import SketchFabViewer from '~/components/SketchFabViewer.vue'
-import ImageInfo from '~/components/ImageDetails/ImageInfo.vue'
-import ImageAttribution from '~/components/ImageDetails/ImageAttribution.vue'
-import VPopover from '~/components/VPopover/VPopover.vue'
-
-export default {
- name: 'VPhotoDetails',
- components: {
- ImageAttribution,
- ImageInfo,
- ReuseSurvey,
- SketchFabViewer,
- VButton,
- VIcon,
- VContentReportForm,
- VPopover,
- },
- props: [
- 'image',
- 'breadCrumbURL',
- 'shouldShowBreadcrumb',
- 'imageWidth',
- 'imageHeight',
- 'imageType',
- 'thumbnail',
- ],
- setup(props, { emit }) {
- const { store } = useContext()
- const router = useRouter()
- const sketchFabfailure = ref(false)
- const activeTab = ref(0)
-
- const imgUrl = computed(() => {
- return isLoaded.value ? props.image.url : props.thumbnail
- })
- const isLoaded = computed(() => props.image && !!props.image.url)
- const providerName = computed(() => {
- return props.image
- ? store.getters['provider/getProviderName'](props.image.provider)
- : ''
- })
- /** @type {ComputedRef<null|string>} */
- const sketchFabUid = computed(() => {
- if (props.image.source !== 'sketchfab' || this.sketchFabfailure) {
- return null
- }
-
- return props.image.url
- .split('https://media.sketchfab.com/models/')[1]
- .split('/')[0]
- })
-
- const fullLicenseName = computed(() => {
- return props.image
- ? getFullLicenseName(props.image.license, props.image.license_version)
- : ''
- })
- const licenseUrl = computed(
- () => `${props.image.license_url}?ref=openverse`
- )
-
- const goBackToSearchResults = () => {
- router.back()
- }
- const onImageLoad = (event) => emit('onImageLoaded', event)
-
- const tabClass = (tabIdx, tabClass) => {
- return {
- [tabClass]: true,
- 'is-active': tabIdx === activeTab.value,
- }
- }
- const setActiveTab = (tabIdx) => (activeTab.value = tabIdx)
-
- const sendEvent = (eventType) => {
- const eventData = {
- eventType,
- resultUuid: props.image.id,
- }
- store.dispatch(`${USAGE_DATA}/${SEND_DETAIL_PAGE_EVENT}`, eventData)
- }
- const onPhotoSourceLinkClicked = () =>
- sendEvent(DETAIL_PAGE_EVENTS.SOURCE_CLICKED)
- const onPhotoCreatorLinkClicked = () =>
- sendEvent(DETAIL_PAGE_EVENTS.CREATOR_CLICKED)
-
- return {
- imgUrl,
- onImageLoad,
- isLoaded,
- sketchFabUid,
- sketchFabfailure,
- goBackToSearchResults,
- linkClicked: {
- photoSource: onPhotoSourceLinkClicked,
- creatorLink: onPhotoCreatorLinkClicked,
- },
- license: {
- url: licenseUrl.value,
- fullName: fullLicenseName.value,
- },
- icons: {
- chevronLeft,
- externalLink,
- flag,
- },
-
- activeTab,
- tabClass,
- setActiveTab,
-
- providerName,
- }
- },
-}
-</script>
-
-<style lang="scss" scoped>
-.photo_image.loading {
- width: 100%;
-}
-
-.photo_image-ctr {
- overflow: hidden;
- text-align: center;
-
- img {
- position: relative;
- width: 100%;
- height: auto;
- max-height: 44rem;
- max-width: 100%;
- object-fit: contain;
- }
-}
-
-.tab:first-child {
- margin-inline-start: 0;
-}
-</style>
diff --git a/src/components/LicenseElements.vue b/src/components/LicenseElements.vue
index 4e1fb5159..508dfee3d 100644
--- a/src/components/LicenseElements.vue
+++ b/src/components/LicenseElements.vue
@@ -1,6 +1,6 @@
<template>
<div v-if="license">
- <ul class="my-2">
+ <ul>
<li
v-for="(li, index) in splitLicenses"
:key="index"
@@ -8,12 +8,12 @@
>
<i
aria-hidden="true"
- class="icon me-2 text-black bg-white"
+ class="icon me-2 text-black text-3xl bg-white"
:class="`cc-${getLicenseIcon(li)}`"
:title="`${li.toUpperCase()}`"
/>
<span class="sr-only">{{ li.toUpperCase() }}</span>
- <p class="leading-5">
+ <p class="text-sm">
{{ $t(`browse-page.license-description.${li}`) }}
</p>
</li>
@@ -53,9 +53,3 @@ const LicenseElements = {
export default LicenseElements
</script>
-
-<style lang="scss" scoped>
-i {
- font-size: 1.43rem;
-}
-</style>
diff --git a/src/components/MediaInfo/CopyLicense.vue b/src/components/MediaInfo/CopyLicense.vue
deleted file mode 100644
index 23260e45c..000000000
--- a/src/components/MediaInfo/CopyLicense.vue
+++ /dev/null
@@ -1,260 +0,0 @@
-<template>
- <div class="copy-license">
- <h5 class="b-header mb-6">
- {{ $t('media-details.reuse.copy-license.title') }}
- </h5>
- <section class="tabs boxed">
- <div
- role="tablist"
- :aria-label="$t('media-details.reuse.copy-license.title')"
- >
- <button
- v-for="tab in tabs"
- :id="tab.id"
- :key="tab.id"
- role="tab"
- :aria-selected="activeTab === tab.id"
- :aria-controls="`tab-${tab.name}`"
- :class="tabClass(tab.id, 'tab')"
- @click.prevent="setActiveTab(tab.id)"
- @keyup.enter.prevent="setActiveTab(tab.id)"
- >
- {{ $t(`media-details.reuse.copy-license.${tab.name}`) }}
- </button>
- </div>
- <div
- id="tab-rich"
- aria-labelledby="rich"
- role="tabpanel"
- :class="tabClass(0, 'tabs-panel')"
- tabindex="0"
- >
- <i18n
- id="attribution"
- path="media-details.reuse.credit.text"
- tag="span"
- class="photo_usage-attribution block"
- >
- <template #title>
- <a
- :href="media.foreign_landing_url"
- target="_blank"
- rel="noopener"
- @click="onPhotoSourceLinkClicked"
- @keyup.enter="onPhotoSourceLinkClicked"
- >{{ mediaTitle }}</a
- ></template
- >
- <template #creator>
- <i18n
- v-if="media.creator"
- path="media-details.reuse.credit.creator-text"
- tag="span"
- >
- <template #creator-name>
- <a
- v-if="media.creator_url"
- :href="media.creator_url"
- target="_blank"
- rel="noopener"
- @click="onPhotoCreatorLinkClicked"
- @keyup.enter="onPhotoCreatorLinkClicked"
- >{{ media.creator }}</a
- >
- <span v-else>{{ media.creator }}</span>
- </template>
- </i18n>
- </template>
- <template #marked-licensed>
- {{
- isPublicDomain
- ? $t('media-details.reuse.credit.marked')
- : $t('media-details.reuse.credit.licensed')
- }}
- </template>
- <template #license>
- <a
- class="uppercase"
- :href="licenseUrl"
- target="_blank"
- rel="noopener"
- >
- {{ fullLicenseName.toUpperCase() }}
- </a>
- </template>
- </i18n>
-
- <CopyButton
- id="copyattr-rich"
- el="#attribution"
- @copied="(e) => onCopyAttribution('Rich Text', e)"
- />
- </div>
- <div
- id="tab-html"
- aria-labelledby="html"
- role="tabpanel"
- :class="tabClass(1, 'tabs-panel')"
- tabindex="0"
- >
- <label for="attribution-html">
- <textarea
- id="attribution-html"
- class="textarea font-mono p-0"
- :value="attributionHtml"
- cols="30"
- rows="4"
- dir="ltr"
- />
- </label>
- <CopyButton
- id="copyattr-html"
- el="#attribution-html"
- @copied="(e) => onCopyAttribution('HTML Embed', e)"
- />
- </div>
- <div
- id="tab-text"
- aria-labelledby="text"
- role="tabpanel"
- :class="tabClass(2, 'tabs-panel')"
- tabindex="0"
- >
- <i18n
- id="attribution-text"
- path="media-details.reuse.credit.text"
- tag="p"
- >
- <template #title>
- {{ mediaTitle }}
- </template>
- <template #creator>
- <i18n
- v-if="media.creator"
- path="media-details.reuse.credit.creator-text"
- >
- <template #creator-name>
- {{ media.creator }}
- </template>
- </i18n>
- </template>
- <template #marked-licensed>
- {{
- isPublicDomain
- ? $t('media-details.reuse.credit.marked')
- : $t('media-details.reuse.credit.licensed')
- }}
- </template>
- <template #license> {{ fullLicenseName.toUpperCase() }}</template>
- <template #view-legal>
- <i18n path="media-details.reuse.credit.view-legal-text">
- <template #terms-copy>
- {{
- isPublicDomain
- ? $t('media-details.reuse.credit.terms-text')
- : $t('media-details.reuse.credit.copy-text')
- }}
- </template>
- <template v-if="licenseUrl" #URL>
- {{ licenseUrl }}
- </template>
- </i18n>
- </template>
- </i18n>
- <CopyButton
- id="copyattr-plain"
- el="#attribution-text"
- @copied="(e) => onCopyAttribution('Plain Text', e)"
- />
- </div>
- </section>
- </div>
-</template>
-
-<script>
-import { COPY_ATTRIBUTION } from '~/constants/action-types'
-import {
- SEND_DETAIL_PAGE_EVENT,
- DETAIL_PAGE_EVENTS,
-} from '~/constants/usage-data-analytics-types'
-import { isPublicDomain } from '~/utils/license'
-import { ATTRIBUTION, USAGE_DATA } from '~/constants/store-modules'
-import CopyButton from '~/components/CopyButton.vue'
-
-export default {
- name: 'CopyLicense',
- components: {
- CopyButton,
- },
- props: {
- media: {},
- fullLicenseName: String,
- attributionHtml: String,
- licenseUrl: String,
- },
- data() {
- return {
- activeTab: 0,
- tabs: [
- { id: 0, name: 'rich' },
- { id: 1, name: 'html' },
- { id: 2, name: 'plain' },
- ],
- }
- },
- computed: {
- isPublicDomain() {
- return isPublicDomain(this.$props.fullLicenseName)
- },
- mediaTitle() {
- const title = this.$props.media.title
- return !['Audio', 'Image'].includes(title)
- ? `"${title}"`
- : this.$t('media-details.reuse.image')
- },
- },
- methods: {
- tabClass(tabIdx, tabClass) {
- return {
- [tabClass]: true,
- 'is-active': tabIdx === this.activeTab,
- }
- },
- setActiveTab(tabIdx) {
- this.activeTab = tabIdx
- },
- sendDetailPageEvent(eventType) {
- this.$store.dispatch(`${USAGE_DATA}/${SEND_DETAIL_PAGE_EVENT}`, {
- eventType,
- resultUuid: this.$props.media.id,
- })
- },
- onCopyAttribution(type, event) {
- this.$store.dispatch(`${ATTRIBUTION}/${COPY_ATTRIBUTION}`, {
- type,
- content: event.content,
- })
- this.sendDetailPageEvent(DETAIL_PAGE_EVENTS.ATTRIBUTION_CLICKED)
- },
- onPhotoSourceLinkClicked() {
- this.sendDetailPageEvent({
- eventType: DETAIL_PAGE_EVENTS.SOURCE_CLICKED,
- resultUuid: this.$props.media.id,
- })
- },
- onPhotoCreatorLinkClicked() {
- this.sendDetailPageEvent({
- eventType: DETAIL_PAGE_EVENTS.CREATOR_CLICKED,
- resultUuid: this.$props.media.id,
- })
- },
- },
-}
-</script>
-
-<style lang="scss" scoped>
-textarea {
- border: none;
- resize: none;
-}
-</style>
diff --git a/src/components/MediaInfo/MediaReuse.vue b/src/components/MediaInfo/MediaReuse.vue
deleted file mode 100644
index e3853fdec..000000000
--- a/src/components/MediaInfo/MediaReuse.vue
+++ /dev/null
@@ -1,32 +0,0 @@
-<template>
- <section class="media-reuse">
- <h4 class="b-header mb-6">{{ $t('media-details.reuse.title') }}</h4>
- <div class="columns">
- <MediaLicense
- :license="media.license"
- :full-license-name="fullLicenseName"
- :license-url="licenseUrl"
- class="column"
- />
- <CopyLicense
- :media="media"
- :full-license-name="fullLicenseName"
- :license-url="licenseUrl"
- :attribution-html="attributionHtml"
- class="column"
- />
- </div>
- </section>
-</template>
-
-<script>
-export default {
- name: 'MediaReuse',
- props: {
- media: {},
- licenseUrl: String,
- fullLicenseName: String,
- attributionHtml: String,
- },
-}
-</script>
diff --git a/src/components/SketchFabViewer.vue b/src/components/SketchFabViewer.vue
index 29f90a893..38ef9d440 100644
--- a/src/components/SketchFabViewer.vue
+++ b/src/components/SketchFabViewer.vue
@@ -74,6 +74,7 @@ export default {
}
.is-16by9 {
padding-top: 56.25%;
+ max-width: 1000px;
}
.has-ratio {
position: absolute;
diff --git a/src/components/VImageDetails/VImageDetails.vue b/src/components/VImageDetails/VImageDetails.vue
new file mode 100644
index 000000000..000ea5648
--- /dev/null
+++ b/src/components/VImageDetails/VImageDetails.vue
@@ -0,0 +1,115 @@
+<template>
+ <section class="w-full">
+ <div class="flex flex-row justify-between items-center mb-6">
+ <h3 class="text-2xl md:text-3xl">
+ {{ $t('image-details.information.title') }}
+ </h3>
+ <span
+ class="flex flex-row justify-end items-center text-sr text-dark-charcoal-70 font-semibold"
+ >
+ <span class="hidden md:inline">{{
+ $t('image-details.report.large')
+ }}</span>
+ <span class="md:hidden">{{ $t('image-details.report.short') }}</span>
+ <FlagSvg class="ms-2"
+ /></span>
+ </div>
+ <dl>
+ <div>
+ <dt>{{ $t('image-details.information.type') }}</dt>
+ <dd class="uppercase">{{ imgType }}</dd>
+ </div>
+ <div v-if="providerName !== sourceName">
+ <dt>{{ $t('image-details.information.provider') }}</dt>
+ <dd>{{ providerName }}</dd>
+ </div>
+ <div>
+ <dt>{{ $t('image-details.information.source') }}</dt>
+ <dd>
+ <a
+ :href="image.foreign_landing_url"
+ target="blank"
+ rel="noopener noreferrer"
+ class="text-pink"
+ >{{ sourceName }}</a
+ >
+ </dd>
+ </div>
+ <div>
+ <dt>{{ $t('image-details.information.dimensions') }}</dt>
+ <dd>
+ <!-- eslint-disable @intlify/vue-i18n/no-raw-text -->
+ {{ imageWidth }} &times; {{ imageHeight }}
+ {{ $t('image-details.information.pixels') }}
+ </dd>
+ </div>
+ </dl>
+ </section>
+</template>
+
+<script>
+import { computed, defineComponent, useContext } from '@nuxtjs/composition-api'
+
+import FlagSvg from '~/assets/icons/flag.svg?inline'
+
+const VImageDetails = defineComponent({
+ name: 'VImageDetails',
+ components: { FlagSvg },
+ props: {
+ image: {
+ type: Object,
+ required: true,
+ },
+ imageWidth: {
+ type: Number,
+ },
+ imageHeight: {
+ type: Number,
+ },
+ imageType: {
+ type: String,
+ },
+ },
+ setup(props) {
+ const { store, i18n } = useContext()
+
+ const imgType = computed(() => {
+ if (props.imageType) {
+ if (props.imageType.split('/').length > 1) {
+ return props.imageType.split('/')[1].toUpperCase()
+ }
+ return props.imageType
+ }
+ return i18n.t('image-details.information.unknown')
+ })
+
+ function getProviderName(nameCode) {
+ return nameCode ? store.getters['provider/getProviderName'](nameCode) : ''
+ }
+
+ const providerName = computed(() => getProviderName(props.image.provider))
+
+ const sourceName = computed(() => getProviderName(props.image.source))
+
+ return { imgType, providerName, sourceName }
+ },
+})
+export default VImageDetails
+</script>
+
+<style scoped>
+dl {
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
+ grid-gap: 1rem;
+}
+
+dt,
+dd {
+ @apply text-sm md:text-base;
+}
+
+dd {
+ @apply font-bold mt-2;
+}
+</style>
diff --git a/src/components/ImageDetails/RelatedImages.vue b/src/components/VImageDetails/VRelatedImages.vue
similarity index 65%
rename from src/components/ImageDetails/RelatedImages.vue
rename to src/components/VImageDetails/VRelatedImages.vue
index 736064c07..73e4cc6b2 100644
--- a/src/components/ImageDetails/RelatedImages.vue
+++ b/src/components/VImageDetails/VRelatedImages.vue
@@ -1,11 +1,9 @@
<template>
- <aside
- :aria-label="$t('photo-details.aria.related')"
- class="m-6 md:mx-14 md:mb-14 photo_related-images"
- >
- <h3 class="text-3xl">
- {{ $t('photo-details.related-images') }}
+ <aside>
+ <h3 class="text-2xl md:text-3xl mb-6">
+ {{ $t('image-details.related-images') }}
</h3>
+ <!-- TODO: use a image grid with correct margins and items gaps -->
<ImageGrid
:images="images"
:can-load-more="false"
@@ -21,10 +19,10 @@
import { ref } from '@nuxtjs/composition-api'
import useRelated from '~/composables/use-related'
import { IMAGE } from '~/constants/media'
-import ImageGrid from '~/components/ImageGrid/ImageGrid'
+import ImageGrid from '~/components/ImageGrid/ImageGrid.vue'
export default {
- name: 'RelatedImages',
+ name: 'VRelatedImages',
components: { ImageGrid },
props: {
imageId: {
@@ -33,13 +31,6 @@ export default {
},
service: {},
},
- /**
- * Fetches related images on `imageId` change
- * @param {object} props
- * @param {string} props.imageId
- * @param {any} props.service
- * @return {{ images: Ref<ImageDetail[]> }}
- */
setup(props) {
const mainImageId = ref(props.imageId)
const relatedOptions = {
@@ -50,6 +41,9 @@ export default {
if (props.service) {
relatedOptions.service = props.service
}
+ /**
+ * Fetches related images on `imageId` change.
+ */
const { media: images } = useRelated(relatedOptions)
return { images }
diff --git a/src/components/VMediaInfo/VCopyLicense.vue b/src/components/VMediaInfo/VCopyLicense.vue
new file mode 100644
index 000000000..a4f312de3
--- /dev/null
+++ b/src/components/VMediaInfo/VCopyLicense.vue
@@ -0,0 +1,235 @@
+<template>
+ <div>
+ <h5 class="mb-4 text-base md:text-2xl font-semibold">
+ {{ $t('media-details.reuse.copy-license.title') }}
+ </h5>
+
+ <nav class="flex borber-b-none" role="tablist">
+ <button
+ v-for="(tab, idx) in tabs"
+ :key="idx"
+ role="tab"
+ :aria-controls="`tab-${tab}`"
+ :aria-selected="activeTab === tab"
+ class="py-3 md:py-4 px-4 md:px-6 border-t border-x rounded-t-sm bg-white text-sm md:text-base font-semibold relative focus:border-tx focus:outline-none focus:shadow-[0_0_0_1.5px_#c52b9b_inset]"
+ :class="[
+ activeTab === tab
+ ? 'border-t-dark-charcoal-20 border-x-dark-charcoal-20 -mb-[1px]'
+ : 'border-tx',
+ ]"
+ @click.prevent="setActiveTab(tab)"
+ @keyup.enter.prevent="setActiveTab(tab)"
+ >
+ {{ $t(`media-details.reuse.copy-license.${tab}`) }}
+ </button>
+ </nav>
+
+ <div
+ v-for="(tab, idx) in tabs"
+ :id="`tab-${tab}`"
+ :key="idx"
+ :aria-labelledby="tab"
+ role="tabpanel"
+ tabindex="0"
+ class="border border-dark-charcoal-20 p-4 md:p-6 text-sm md:text-base foxus:border-tx focus:outline-none focus:shadow-[0_0_0_1.5px_#c52b9b_inset]"
+ :class="{ hidden: activeTab !== tab }"
+ >
+ <i18n
+ v-if="tab === 'rich'"
+ id="attribution-rich"
+ path="media-details.reuse.credit.text"
+ tag="p"
+ >
+ <template #title>
+ <a
+ :href="media.foreign_landing_url"
+ target="_blank"
+ rel="noopener"
+ @click="onSourceLinkClicked"
+ @keyup.enter="onSourceLinkClicked"
+ >{{ media.title }}</a
+ ></template
+ >
+ <template #creator>
+ <i18n
+ v-if="media.creator"
+ path="media-details.reuse.credit.creator-text"
+ tag="span"
+ >
+ <template #creator-name>
+ <a
+ v-if="media.creator_url"
+ :href="media.creator_url"
+ target="_blank"
+ rel="noopener"
+ @click="onCreatorLinkClicked"
+ @keyup.enter="onCreatorLinkClicked"
+ >{{ media.creator }}</a
+ >
+ <span v-else>{{ media.creator }}</span>
+ </template>
+ </i18n>
+ </template>
+ <template #marked-licensed>
+ {{
+ isPDM
+ ? $t('media-details.reuse.credit.marked')
+ : $t('media-details.reuse.credit.licensed')
+ }}
+ </template>
+ <template #license>
+ <a
+ class="uppercase"
+ :href="licenseUrl"
+ target="_blank"
+ rel="noopener"
+ >{{ fullLicenseName }}</a
+ >
+ </template>
+ </i18n>
+
+ <label v-if="tab === 'html'" for="attribution-html">
+ <textarea
+ id="attribution-html"
+ class="w-full font-mono h-auto resize-none"
+ :value="attributionHtml"
+ rows="4"
+ dir="ltr"
+ readonly
+ />
+ </label>
+
+ <i18n
+ v-if="tab === 'plain'"
+ id="attribution-plain"
+ path="media-details.reuse.credit.text"
+ tag="p"
+ >
+ <template #title>{{ media.title }}</template>
+ <template #creator>
+ <i18n
+ v-if="media.creator"
+ path="media-details.reuse.credit.creator-text"
+ >
+ <template #creator-name>{{ media.creator }}</template>
+ </i18n>
+ </template>
+ <template #marked-licensed>
+ {{
+ isPDM
+ ? $t('media-details.reuse.credit.marked')
+ : $t('media-details.reuse.credit.licensed')
+ }}
+ </template>
+ <template #license> {{ fullLicenseName }}</template>
+ <template #view-legal>
+ <i18n path="media-details.reuse.credit.view-legal-text">
+ <template #terms-copy>
+ {{
+ isPDM
+ ? $t('media-details.reuse.credit.terms-text')
+ : $t('media-details.reuse.credit.copy-text')
+ }}
+ </template>
+ <template v-if="licenseUrl" #URL>
+ {{ licenseUrl }}
+ </template>
+ </i18n>
+ </template>
+ </i18n>
+
+ <CopyButton
+ :id="`copyattr-${tab}`"
+ :el="`#attribution-${tab}`"
+ class="mt-6 md:mt-10"
+ @copied="(e) => onCopyAttribution(tab, e)"
+ />
+ </div>
+ </div>
+</template>
+
+<script>
+import {
+ computed,
+ defineComponent,
+ ref,
+ useContext,
+} from '@nuxtjs/composition-api'
+import CopyButton from '~/components/CopyButton.vue'
+import { COPY_ATTRIBUTION } from '~/constants/action-types'
+import { ATTRIBUTION, USAGE_DATA } from '~/constants/store-modules'
+import {
+ SEND_DETAIL_PAGE_EVENT,
+ DETAIL_PAGE_EVENTS,
+} from '~/constants/usage-data-analytics-types'
+import getAttributionHtml from '~/utils/attribution-html'
+import { isPublicDomain } from '~/utils/license'
+
+const VCopyLicense = defineComponent({
+ name: 'VCopyLicense',
+ components: { CopyButton },
+ props: {
+ media: {
+ type: Object,
+ },
+ fullLicenseName: {
+ type: String,
+ },
+ },
+ setup(props) {
+ const { store } = useContext()
+
+ const activeTab = ref('rich')
+ const tabs = ['rich', 'html', 'plain']
+
+ const setActiveTab = (tabIdx) => (activeTab.value = tabIdx)
+
+ const licenseUrl = computed(
+ () => `${props.media.license_url}?ref=openverse`
+ )
+
+ const isPDM = () => isPublicDomain(props.fullLicenseName)
+
+ const attributionHtml = computed(() => {
+ const licenseUrl = `${props.media.license_url}&atype=html`
+ return getAttributionHtml(props.media, licenseUrl, props.fullLicenseName)
+ })
+
+ const sendDetailPageEvent = (eventType) => {
+ const eventData = {
+ eventType,
+ resultUuid: props.media.id,
+ }
+ store.dispatch(`${USAGE_DATA}/${SEND_DETAIL_PAGE_EVENT}`, eventData)
+ }
+
+ const onCreatorLinkClicked = () => {
+ sendDetailPageEvent(DETAIL_PAGE_EVENTS.CREATOR_CLICKED)
+ }
+
+ const onSourceLinkClicked = () =>
+ sendDetailPageEvent(DETAIL_PAGE_EVENTS.SOURCE_CLICKED)
+
+ const onCopyAttribution = (type, event) => {
+ store.dispatch(`${ATTRIBUTION}/${COPY_ATTRIBUTION}`, {
+ type,
+ content: event.content,
+ })
+ sendDetailPageEvent(DETAIL_PAGE_EVENTS.ATTRIBUTION_CLICKED)
+ }
+
+ return {
+ activeTab,
+ attributionHtml,
+ isPDM,
+ licenseUrl,
+ onCreatorLinkClicked,
+ onSourceLinkClicked,
+ onCopyAttribution,
+ tabs,
+ setActiveTab,
+ }
+ },
+})
+export default VCopyLicense
+</script>
diff --git a/src/components/MediaInfo/MediaLicense.vue b/src/components/VMediaInfo/VMediaLicense.vue
similarity index 76%
rename from src/components/MediaInfo/MediaLicense.vue
rename to src/components/VMediaInfo/VMediaLicense.vue
index f462cf709..b353a593c 100644
--- a/src/components/MediaInfo/MediaLicense.vue
+++ b/src/components/VMediaInfo/VMediaLicense.vue
@@ -1,17 +1,17 @@
<template>
<div class="media-attribution">
- <h5 class="b-header mb-6">
+ <h5 class="mb-4 text-base md:text-2xl font-semibold">
{{ headerText }}
</h5>
<template v-if="isLicense">
<i18n
- path="media-details.reuse.attribution.main"
+ path="media-details.reuse.attribution"
tag="span"
- class="block"
+ class="block text-sm md:text-base"
>
<template #link>
<a
- class="uppercase"
+ class="uppercase text-pink"
:href="licenseUrl"
target="_blank"
rel="noopener"
@@ -20,7 +20,7 @@
</a>
</template>
</i18n>
- <LicenseElements :license="license" />
+ <LicenseElements :license="license" class="md:py-4" />
<i18n
v-if="!isLicense"
path="media-details.reuse.license.content"
@@ -33,14 +33,14 @@
:href="licenseUrl"
target="_blank"
rel="noopener"
+ class="text-pink"
+ >{{ $t('media-details.reuse.license.link') }}</a
>
- {{ $t('media-details.reuse.license.link') }}
- </a>
</template>
</i18n>
</template>
<template v-else>
- <LicenseElements :license="license" />
+ <LicenseElements :license="license" class="md:py-4" />
<i18n
path="media-details.reuse.tool.content"
tag="span"
@@ -52,9 +52,9 @@
:href="licenseUrl"
target="_blank"
rel="noopener"
+ class="text-pink"
+ >{{ $t('media-details.reuse.tool.link') }}</a
>
- {{ $t('media-details.reuse.tool.link') }}
- </a>
</template>
</i18n>
</template>
@@ -67,9 +67,7 @@ import LicenseElements from '~/components/LicenseElements.vue'
export default {
name: 'MediaLicense',
- components: {
- LicenseElements,
- },
+ components: { LicenseElements },
props: {
fullLicenseName: String,
license: String,
diff --git a/src/components/VMediaInfo/VMediaReuse.vue b/src/components/VMediaInfo/VMediaReuse.vue
new file mode 100644
index 000000000..2989c0c04
--- /dev/null
+++ b/src/components/VMediaInfo/VMediaReuse.vue
@@ -0,0 +1,46 @@
+<template>
+ <section :aria-label="$t('media-details.reuse.title')">
+ <h3 class="text-2xl md:text-3xl mb-6">
+ {{ $t('media-details.reuse.title') }}
+ </h3>
+ <div class="columns">
+ <VMediaLicense
+ :license="media.license"
+ :license-url="media.license_url"
+ :full-license-name="fullLicenseName"
+ class="column"
+ />
+ <VCopyLicense
+ :media="media"
+ :full-license-name="fullLicenseName"
+ class="column"
+ />
+ </div>
+ </section>
+</template>
+
+<script>
+import { computed, defineComponent } from '@nuxtjs/composition-api'
+import { getFullLicenseName } from '~/utils/license'
+import VCopyLicense from '~/components/VMediaInfo/VCopyLicense.vue'
+import VMediaLicense from '~/components/VMediaInfo/VMediaLicense.vue'
+
+const VMediaReuse = defineComponent({
+ name: 'VMediaReuse',
+ components: { VCopyLicense, VMediaLicense },
+ props: {
+ media: {
+ type: Object,
+ required: true,
+ },
+ },
+ setup(props) {
+ const fullLicenseName = computed(() =>
+ getFullLicenseName(props.media.license, props.media.license_version)
+ )
+
+ return { fullLicenseName }
+ },
+})
+export default VMediaReuse
+</script>
diff --git a/src/locales/en.json b/src/locales/en.json
index f2ba8c0f5..9f536f762 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -387,8 +387,8 @@
"creator": "Creator"
},
"license-explanation": {
- "tool": "Read more about the tool {link}",
- "license": "Read more about the license {link}",
+ "tool": "Read more about the tool {link}.",
+ "license": "Read more about the license {link}.",
"link": "here"
},
"aria": {
@@ -457,11 +457,11 @@
"link": "here"
},
"tool": {
- "content": "Read more about the tool {link}",
+ "content": "Read more about the tool {link}.",
"link": "here"
},
"credit": {
- "text": "{title}{creator}{marked-licensed}{license}{view-legal}",
+ "text": "\"{title}\"{creator}{marked-licensed}{license}{view-legal}",
"creator-text": " by {creator-name}",
"marked": "is marked with",
"licensed": "is licensed under",
@@ -470,15 +470,14 @@
"copy-text": "a copy of this license,"
},
"copy-license": {
- "title": "Credit the Creator",
+ "title": "Credit the creator",
"rich": "Rich Text",
"html": "HTML",
- "plain": "Plain text"
+ "plain": "Plain text",
+ "copy-text": "Copy text",
+ "copied": "Copied!"
},
- "attribution": {
- "main": "This image was marked with a {link} license.",
- "license": "license."
- }
+ "attribution": "This image was marked with a {link} license:"
},
"provider-label": "Provider",
"source-label": "Source",
@@ -488,72 +487,36 @@
"attribution": {
"license": "read more about the license",
"tool": "read more about the tool"
- }
+ },
+ "creator-url": "author {name}"
+ },
+ "image-info": "Image information",
+ "audio-info": "Audio information",
+ "content-report": {
+ "report": "Report",
+ "title": "Report this content"
}
},
- "photo-details": {
+ "image-details": {
"back": "Back to search results",
"creator": "by {name}",
- "reuse": {
- "title": "Reuse"
- },
- "information": {
- "title": "Information",
- "type": "Type:",
- "provider": "Provider:",
- "dimensions": "Dimensions:",
- "source": "Source:",
- "license": "License",
- "tags": "Tags",
- "pixels": "pixels"
- },
- "survey": {
- "content": "How are you using this image?",
- "link": "Let us know",
- "answer": "by answering a few questions."
- },
"weblink": "Go to image's website",
- "legal-disclaimer": "Openverse aggregates data from publicly available repositories of open content. Openverse does not host the content and does not verify that the content is properly CC-licensed or that the attribution information is accurate or complete. Please follow the link to the source of the content to independently verify before reuse.",
- "related-images": "Related Images",
- "copy": {
- "copy": "Copy",
- "copied": "Copied!"
+ "information": {
+ "title": "Image information",
+ "type": "Type",
+ "provider": "Provider",
+ "dimensions": "Dimensions",
+ "source": "Source",
+ "pixels": "pixels",
+ "unknown": "Unknown"
},
- "content-report": {
- "title": "Report this content",
- "issue": "What's the issue?",
- "issue-description": "Please describe the issue for us",
- "reasons": {
- "dmca": "Infringes Copyright",
- "mature": "Contains mature content",
- "other": "Other"
- },
- "dmca": {
- "link": "DMCA form",
- "content": "You must fill out this {link} to report copyright infringement. No action will be taken until the form is filled out and submitted."
- },
- "caption": "For security purposes, Openverse collects and retains anonymized IP addresses of those who complete and submit this form.",
- "next": "Next",
- "back": "Back",
- "submit": "Submit",
- "thanks": "Thank you for reporting an issue with the results of Openverse!",
- "provider": "We recommend doing the same at the source, {link}.",
- "aria-form": "{provider} form",
- "submission-error": "There was an error with the report submission. Please try again.",
- "placeholder": "Issue description required (with at least 20 characters)"
+ "report": {
+ "short": "Report",
+ "large": "Report this content"
},
+ "related-images": "Related images",
"aria": {
- "close-form": "close form",
- "dmca": "dmca form",
- "attribution": {
- "license": "read more about the license",
- "tool": "read more about the tool"
- },
- "details": "image details",
- "main": "main content",
- "related": "related images",
- "provider-report-form": "{provider} form",
- "creator-url": "author {creator}"
+ "creator-url": "Author {creator}"
}
},
"audio-details": {
diff --git a/src/locales/po-files/openverse.pot b/src/locales/po-files/openverse.pot
index be4660474..f525c3837 100644
--- a/src/locales/po-files/openverse.pot
+++ b/src/locales/po-files/openverse.pot
@@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Openverse \n"
"Report-Msgid-Bugs-To: https://github.com/wordpress/openverse/issues \n"
-"POT-Creation-Date: 2022-01-28T12:35:42+00:00\n"
+"POT-Creation-Date: 2022-02-01T19:06:38+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
@@ -57,7 +57,7 @@ msgctxt "search-type.see-audio"
msgid "See all audio"
msgstr ""
-#: src/components/VModal/VMobileModalContent.vue:30
+#: src/components/VModal/VMobileModalContent.vue:28
msgctxt "modal.close"
msgid "Close"
msgstr ""
@@ -358,228 +358,75 @@ msgctxt "audio-details.table.genre"
msgid "Genre"
msgstr ""
-#: src/components/ImageDetails/VPhotoDetails.vue:11
-msgctxt "photo-details.back"
+#: src/pages/image/_id.vue:10
+msgctxt "image-details.back"
msgid "Back to search results"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/ImageDetails/VPhotoDetails.vue:63
-msgctxt "photo-details.creator"
+#: src/pages/image/_id.vue:49
+msgctxt "image-details.creator"
msgid "by ###name###"
msgstr ""
-#: src/components/ImageDetails/VPhotoDetails.vue:150
-msgctxt "photo-details.weblink"
+#: src/pages/image/_id.vue:43
+msgctxt "image-details.weblink"
msgid "Go to image's website"
msgstr ""
-#: src/components/ImageDetails/VPhotoDetails.vue:29
-msgctxt "photo-details.legal-disclaimer"
-msgid "Openverse aggregates data from publicly available repositories of open content. Openverse does not host the content and does not verify that the content is properly CC-licensed or that the attribution information is accurate or complete. Please follow the link to the source of the content to independently verify before reuse."
-msgstr ""
-
-#: src/components/ImageDetails/RelatedImages.vue:7
-msgctxt "photo-details.related-images"
-msgid "Related Images"
-msgstr ""
-
-#: src/components/VContentReport/VContentReportForm.vue:4
-msgctxt "photo-details.aria.close-form"
-msgid "close form"
-msgstr ""
-
-#: src/components/VContentReport/VDmcaNotice.vue:10
-msgctxt "photo-details.aria.dmca"
-msgid "dmca form"
-msgstr ""
-
-#: src/components/ImageDetails/VPhotoDetails.vue:58
-msgctxt "photo-details.aria.details"
-msgid "image details"
-msgstr ""
-
-#: src/pages/audio/_id.vue:2
-msgctxt "photo-details.aria.main"
-msgid "main content"
-msgstr ""
-
-#: src/components/AudioDetails/VRelatedAudio.vue:2
-msgctxt "photo-details.aria.related"
-msgid "related images"
+#: src/components/VImageDetails/VRelatedImages.vue:4
+msgctxt "image-details.related-images"
+msgid "Related images"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/VContentReport/VDmcaNotice.vue:27
-msgctxt "photo-details.aria.provider-report-form"
-msgid "###provider### form"
+msgctxt "image-details.aria.creator-url"
+msgid "Author ###creator###"
msgstr ""
-#. Do not translate words between ### ###.
-#: src/components/ImageDetails/VPhotoDetails.vue:73
-msgctxt "photo-details.aria.creator-url"
-msgid "author ###creator###"
+#: src/components/VImageDetails/VImageDetails.vue:13
+msgctxt "image-details.report.short"
+msgid "Report"
msgstr ""
-msgctxt "photo-details.aria.attribution.license"
-msgid "read more about the license"
-msgstr ""
-
-msgctxt "photo-details.aria.attribution.tool"
-msgid "read more about the tool"
-msgstr ""
-
-#: src/components/ImageDetails/VPhotoDetails.vue:34
-msgctxt "photo-details.content-report.title"
+#: src/components/VImageDetails/VImageDetails.vue:11
+msgctxt "image-details.report.large"
msgid "Report this content"
msgstr ""
-#: src/components/VContentReport/VContentReportForm.vue:36
-msgctxt "photo-details.content-report.issue"
-msgid "What's the issue?"
-msgstr ""
-
-#: src/components/VContentReport/VOtherIssueForm.vue:7
-msgctxt "photo-details.content-report.issue-description"
-msgid "Please describe the issue for us"
-msgstr ""
-
-#: src/components/VContentReport/VContentReportForm.vue:56
-msgctxt "photo-details.content-report.caption"
-msgid "For security purposes, Openverse collects and retains anonymized IP addresses of those who complete and submit this form."
-msgstr ""
-
-#: src/components/VContentReport/VContentReportForm.vue:65
-msgctxt "photo-details.content-report.next"
-msgid "Next"
+#: src/components/VImageDetails/VImageDetails.vue:5
+msgctxt "image-details.information.title"
+msgid "Image information"
msgstr ""
-#: src/components/VContentReport/VDmcaNotice.vue:44
-msgctxt "photo-details.content-report.back"
-msgid "Back"
-msgstr ""
-
-#: src/components/VContentReport/VOtherIssueForm.vue:33
-msgctxt "photo-details.content-report.submit"
-msgid "Submit"
-msgstr ""
-
-#: src/components/VContentReport/VDoneMessage.vue:4
-msgctxt "photo-details.content-report.thanks"
-msgid "Thank you for reporting an issue with the results of Openverse!"
-msgstr ""
-
-#. Do not translate words between ### ###.
-#: src/components/VContentReport/VDmcaNotice.vue:19
-msgctxt "photo-details.content-report.provider"
-msgid "We recommend doing the same at the source, ###link###."
-msgstr ""
-
-#. Do not translate words between ### ###.
-msgctxt "photo-details.content-report.aria-form"
-msgid "###provider### form"
-msgstr ""
-
-#: src/components/VContentReport/VReportError.vue:4
-msgctxt "photo-details.content-report.submission-error"
-msgid "There was an error with the report submission. Please try again."
-msgstr ""
-
-#: src/components/VContentReport/VOtherIssueForm.vue:12
-msgctxt "photo-details.content-report.placeholder"
-msgid "Issue description required (with at least 20 characters)"
-msgstr ""
-
-#: src/components/VContentReport/VDmcaNotice.vue:14
-msgctxt "photo-details.content-report.dmca.link"
-msgid "DMCA form"
-msgstr ""
-
-#. Do not translate words between ### ###.
-#: src/components/VContentReport/VDmcaNotice.vue:3
-msgctxt "photo-details.content-report.dmca.content"
-msgid "You must fill out this ###link### to report copyright infringement. No action will be taken until the form is filled out and submitted."
-msgstr ""
-
-msgctxt "photo-details.content-report.reasons.dmca"
-msgid "Infringes Copyright"
-msgstr ""
-
-msgctxt "photo-details.content-report.reasons.mature"
-msgid "Contains mature content"
-msgstr ""
-
-msgctxt "photo-details.content-report.reasons.other"
-msgid "Other"
-msgstr ""
-
-#: src/components/CopyButton.vue:9
-msgctxt "photo-details.copy.copy"
-msgid "Copy"
-msgstr ""
-
-#: src/components/CopyButton.vue:12
-msgctxt "photo-details.copy.copied"
-msgid "Copied!"
-msgstr ""
-
-#: src/components/ImageDetails/ReuseSurvey.vue:3
-msgctxt "photo-details.survey.content"
-msgid "How are you using this image?"
-msgstr ""
-
-#: src/components/ImageDetails/ReuseSurvey.vue:11
-msgctxt "photo-details.survey.link"
-msgid "Let us know"
-msgstr ""
-
-#: src/components/ImageDetails/ReuseSurvey.vue:13
-msgctxt "photo-details.survey.answer"
-msgid "by answering a few questions."
-msgstr ""
-
-#: src/components/ImageDetails/VPhotoDetails.vue:106
-msgctxt "photo-details.information.title"
-msgid "Information"
-msgstr ""
-
-#: src/components/ImageDetails/ImageInfo.vue:6
-msgctxt "photo-details.information.type"
-msgid "Type:"
-msgstr ""
-
-#: src/components/ImageDetails/ImageInfo.vue:19
-msgctxt "photo-details.information.provider"
-msgid "Provider:"
-msgstr ""
-
-#: src/components/ImageDetails/ImageInfo.vue:10
-msgctxt "photo-details.information.dimensions"
-msgid "Dimensions:"
+#: src/components/VImageDetails/VImageDetails.vue:19
+msgctxt "image-details.information.type"
+msgid "Type"
msgstr ""
-#: src/components/ImageDetails/ImageInfo.vue:25
-msgctxt "photo-details.information.source"
-msgid "Source:"
+#: src/components/VImageDetails/VImageDetails.vue:23
+msgctxt "image-details.information.provider"
+msgid "Provider"
msgstr ""
-msgctxt "photo-details.information.license"
-msgid "License"
+#: src/components/VImageDetails/VImageDetails.vue:39
+msgctxt "image-details.information.dimensions"
+msgid "Dimensions"
msgstr ""
-#: src/components/ImageDetails/ImageInfo.vue:42
-msgctxt "photo-details.information.tags"
-msgid "Tags"
+#: src/components/VImageDetails/VImageDetails.vue:27
+msgctxt "image-details.information.source"
+msgid "Source"
msgstr ""
-#: src/components/ImageDetails/ImageInfo.vue:16
-msgctxt "photo-details.information.pixels"
+#: src/components/VImageDetails/VImageDetails.vue:43
+msgctxt "image-details.information.pixels"
msgid "pixels"
msgstr ""
-#: src/components/ImageDetails/VPhotoDetails.vue:95
-msgctxt "photo-details.reuse.title"
-msgid "Reuse"
+#: src/components/VImageDetails/VImageDetails.vue:83
+msgctxt "image-details.information.unknown"
+msgid "Unknown"
msgstr ""
msgctxt "media-details.provider-label"
@@ -599,17 +446,39 @@ msgctxt "media-details.related-error"
msgid "Error fetching related media"
msgstr ""
-#: src/components/MediaInfo/MediaLicense.vue:32
+msgctxt "media-details.image-info"
+msgid "Image information"
+msgstr ""
+
+msgctxt "media-details.audio-info"
+msgid "Audio information"
+msgstr ""
+
+msgctxt "media-details.content-report.report"
+msgid "Report"
+msgstr ""
+
+msgctxt "media-details.content-report.title"
+msgid "Report this content"
+msgstr ""
+
+#. Do not translate words between ### ###.
+#: src/pages/image/_id.vue:59
+msgctxt "media-details.aria.creator-url"
+msgid "author ###name###"
+msgstr ""
+
+#: src/components/VMediaInfo/VMediaLicense.vue:32
msgctxt "media-details.aria.attribution.license"
msgid "read more about the license"
msgstr ""
-#: src/components/MediaInfo/MediaLicense.vue:51
+#: src/components/VMediaInfo/VMediaLicense.vue:51
msgctxt "media-details.aria.attribution.tool"
msgid "read more about the tool"
msgstr ""
-#: src/components/MediaInfo/MediaReuse.vue:3
+#: src/components/VMediaInfo/VMediaReuse.vue:2
msgctxt "media-details.reuse.title"
msgid "Reuse content"
msgstr ""
@@ -626,24 +495,19 @@ msgctxt "media-details.reuse.audio"
msgid "Audio"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:213
msgctxt "media-details.reuse.image"
msgid "Image"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/MediaLicense.vue:7
-msgctxt "media-details.reuse.attribution.main"
-msgid "This image was marked with a ###link### license."
-msgstr ""
-
-msgctxt "media-details.reuse.attribution.license"
-msgid "license."
+#: src/components/VMediaInfo/VMediaLicense.vue:7
+msgctxt "media-details.reuse.attribution"
+msgid "This image was marked with a ###link### license:"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:4
+#: src/components/VMediaInfo/VCopyLicense.vue:4
msgctxt "media-details.reuse.copy-license.title"
-msgid "Credit the Creator"
+msgid "Credit the creator"
msgstr ""
msgctxt "media-details.reuse.copy-license.rich"
@@ -658,62 +522,72 @@ msgctxt "media-details.reuse.copy-license.plain"
msgid "Plain text"
msgstr ""
+#: src/components/CopyButton.vue:9
+msgctxt "media-details.reuse.copy-license.copy-text"
+msgid "Copy text"
+msgstr ""
+
+#: src/components/CopyButton.vue:12
+msgctxt "media-details.reuse.copy-license.copied"
+msgid "Copied!"
+msgstr ""
+
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/CopyLicense.vue:32
+#: src/components/VMediaInfo/VCopyLicense.vue:37
msgctxt "media-details.reuse.credit.text"
-msgid "###title######creator######marked-licensed######license######view-legal###"
+msgid "\"###title###\"###creator######marked-licensed######license######view-legal###"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/CopyLicense.vue:49
+#: src/components/VMediaInfo/VCopyLicense.vue:54
msgctxt "media-details.reuse.credit.creator-text"
msgid " by ###creator-name###"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:71
+#: src/components/VMediaInfo/VCopyLicense.vue:76
msgctxt "media-details.reuse.credit.marked"
msgid "is marked with"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:72
+#: src/components/VMediaInfo/VCopyLicense.vue:77
msgctxt "media-details.reuse.credit.licensed"
msgid "is licensed under"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/CopyLicense.vue:150
+#: src/components/VMediaInfo/VCopyLicense.vue:126
msgctxt "media-details.reuse.credit.view-legal-text"
msgid ". To view ###terms-copy###visit ###URL###"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:154
+#: src/components/VMediaInfo/VCopyLicense.vue:130
msgctxt "media-details.reuse.credit.terms-text"
msgid "the terms,"
msgstr ""
-#: src/components/MediaInfo/CopyLicense.vue:155
+#: src/components/VMediaInfo/VCopyLicense.vue:131
msgctxt "media-details.reuse.credit.copy-text"
msgid "a copy of this license,"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/MediaLicense.vue:44
+#: src/components/VMediaInfo/VMediaLicense.vue:44
msgctxt "media-details.reuse.tool.content"
-msgid "Read more about the tool ###link###"
+msgid "Read more about the tool ###link###."
msgstr ""
-#: src/components/MediaInfo/MediaLicense.vue:56
+#: src/components/VMediaInfo/VMediaLicense.vue:56
msgctxt "media-details.reuse.tool.link"
msgid "here"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/MediaInfo/MediaLicense.vue:24
+#: src/components/VMediaInfo/VMediaLicense.vue:24
msgctxt "media-details.reuse.license.content"
msgid "Read more about the license ###link###"
msgstr ""
-#: src/components/MediaInfo/MediaLicense.vue:37
+#: src/components/VMediaInfo/VMediaLicense.vue:37
msgctxt "media-details.reuse.license.link"
msgid "here"
msgstr ""
@@ -731,7 +605,7 @@ msgstr[1] ""
#. Do not translate words between ### ###.
msgctxt "browse-page.all-result-count-more"
-msgid "Over###localeCount### result"
+msgid "Over ###localeCount### result"
msgid_plural "Over ###localeCount### results"
msgstr[0] ""
msgstr[1] ""
@@ -863,7 +737,7 @@ msgctxt "browse-page.search-rating.feedback-thanks"
msgid "Thank you for the feedback!"
msgstr ""
-#: src/components/VFilters/VSearchGridFilter.vue:14
+#: src/components/VFilters/VSearchGridFilter.vue:11
msgctxt "filter-list.filter-by"
msgid "Filter by"
msgstr ""
@@ -872,12 +746,12 @@ msgctxt "filter-list.hide"
msgid "Hide filters"
msgstr ""
-#: src/components/VFilters/VSearchGridFilter.vue:23
+#: src/components/VFilters/VSearchGridFilter.vue:20
msgctxt "filter-list.clear"
msgid "Clear filters"
msgstr ""
-#: src/components/VFilters/VSearchGridFilter.vue:42
+#: src/components/VFilters/VSearchGridFilter.vue:39
msgctxt "filter-list.show"
msgid "Show results"
msgstr ""
@@ -904,13 +778,13 @@ msgstr ""
#. Do not translate words between ### ###.
#: src/components/VFilters/VLicenseExplanationTooltip.vue:12
msgctxt "filters.license-explanation.tool"
-msgid "Read more about the tool ###link###"
+msgid "Read more about the tool ###link###."
msgstr ""
#. Do not translate words between ### ###.
#: src/components/VFilters/VLicenseExplanationTooltip.vue:24
msgctxt "filters.license-explanation.license"
-msgid "Read more about the license ###link###"
+msgid "Read more about the license ###link###."
msgstr ""
#: src/components/VFilters/VLicenseExplanationTooltip.vue:20
@@ -1116,13 +990,13 @@ msgid "An error occurred"
msgstr ""
#. Do not translate words between ### ###.
-#: src/pages/image/_id.vue:53
+#: src/pages/image/_id.vue:148
msgctxt "error.image-not-found"
msgid "Couldn't find image with id ###id###"
msgstr ""
#. Do not translate words between ### ###.
-#: src/pages/audio/_id.vue:69
+#: src/pages/audio/_id.vue:66
msgctxt "error.media-not-found"
msgid "Couldn't find ###mediaType### with id ###id###"
msgstr ""
@@ -1973,18 +1847,18 @@ msgctxt "header.api-nav-item"
msgid "API"
msgstr ""
-#: src/components/VHeader/VHeader.vue:182
+#: src/components/VHeader/VHeader.vue:163
msgctxt "header.loading"
msgid "Loading..."
msgstr ""
-#: src/components/VContentSwitcher/VMobileMenuModal.vue:17
+#: src/components/VContentSwitcher/VMobileMenuModal.vue:13
msgctxt "header.filter-button.simple"
msgid "Filters"
msgstr ""
#. Do not translate words between ### ###.
-#: src/components/VHeader/VFilterButton.vue:78
+#: src/components/VHeader/VFilterButton.vue:81
msgctxt "header.filter-button.with-count"
msgid "###count### Filter"
msgid_plural "###count### Filters"
@@ -2007,7 +1881,7 @@ msgctxt "header.aria.primary"
msgid "primary"
msgstr ""
-#: src/components/VHeader/VPageMenu/VDesktopPageMenu.vue:2
+#: src/components/VHeader/VPageMenu/VDesktopPageMenu.vue:5
msgctxt "header.aria.menu"
msgid "menu"
msgstr ""
@@ -2064,17 +1938,17 @@ msgid "I want something I can"
msgstr ""
#. Do not translate words between ### ###.
-#: src/pages/index.vue:41
+#: src/pages/index.vue:51
msgctxt "hero.disclaimer.content"
msgid "All Openverse content is under a ###license### or is in the public domain."
msgstr ""
-#: src/pages/index.vue:50
+#: src/pages/index.vue:60
msgctxt "hero.disclaimer.license"
msgid "Creative Commons license"
msgstr ""
-#: src/pages/index.vue:26
+#: src/pages/index.vue:36
msgctxt "hero.search.placeholder"
msgid "Search for content"
msgstr ""
diff --git a/src/pages/audio/_id.vue b/src/pages/audio/_id.vue
index 5f86afbbd..b822837f9 100644
--- a/src/pages/audio/_id.vue
+++ b/src/pages/audio/_id.vue
@@ -1,12 +1,9 @@
<template>
<div :aria-label="$t('photo-details.aria.main')" class="audio-page">
<VAudioTrack :audio="audio" class="main-track" />
- <MediaReuse
+ <VMediaReuse
data-testid="audio-attribution"
:media="audio"
- :license-url="licenseUrl"
- :full-license-name="fullLicenseName"
- :attribution-html="attributionHtml()"
class="my-16 px-4 md:px-0"
/>
<VAudioDetails
@@ -27,7 +24,7 @@ import { mapState } from 'vuex'
import { FETCH_AUDIO } from '~/constants/action-types'
import iframeHeight from '~/mixins/iframe-height'
import { AUDIO } from '~/constants/media'
-import attributionHtml from '~/utils/attribution-html'
+import getAttributionHtml from '~/utils/attribution-html'
import { getFullLicenseName } from '~/utils/license'
import { MEDIA } from '~/constants/store-modules'
@@ -87,7 +84,7 @@ const AudioDetailPage = {
methods: {
attributionHtml() {
const licenseUrl = `${this.licenseUrl}&atype=html`
- return attributionHtml(this.audio, licenseUrl, this.fullLicenseName)
+ return getAttributionHtml(this.audio, licenseUrl, this.fullLicenseName)
},
},
head() {
diff --git a/src/pages/image/_id.vue b/src/pages/image/_id.vue
index bc018c40c..2308599a3 100644
--- a/src/pages/image/_id.vue
+++ b/src/pages/image/_id.vue
@@ -1,16 +1,86 @@
<template>
- <div :aria-label="$t('photo-details.aria.main')">
- <VPhotoDetails
+ <div>
+ <a
+ v-if="shouldShowBreadcrumb"
+ class="px-6 pt-4 flex flex-row items-center bg-dark-charcoal-06 font-semibold text-dark-charcoal text-xs md:text-sr"
+ :href="breadcrumbUrl"
+ @click.prevent="$router.back()"
+ >
+ <Chevron class="-ms-2" />
+ {{ $t('image-details.back') }}
+ </a>
+
+ <figure class="w-full mb-4 pt-4 md:pt-8 px-6 bg-dark-charcoal-06">
+ <img
+ v-if="!sketchFabUid"
+ id="main-image"
+ :src="image.url"
+ :alt="image.title"
+ class="h-full max-h-[500px] mx-auto rounded-t-sm"
+ @load="onImageLoaded"
+ />
+ <SketchFabViewer
+ v-if="sketchFabUid"
+ :uid="sketchFabUid"
+ class="mx-auto rounded-t-sm"
+ @failure="sketchFabfailure = true"
+ />
+ </figure>
+
+ <section
+ id="title-button"
+ class="flex flex-row md:flex-row-reverse flex-wrap justify-between md:mt-6"
+ >
+ <VButton
+ as="a"
+ :href="image.foreign_landing_url"
+ target="blank"
+ rel="noopener noreferrer"
+ class="btn-main flex-initial w-full md:w-max mb-4 md:mb-0"
+ size="large"
+ @click="onSourceLinkClicked"
+ @keyup.enter="onSourceLinkClicked"
+ >{{ $t('image-details.weblink') }}</VButton
+ >
+ <span class="flex-1">
+ <h1 class="text-base md:text-3xl font-semibold leading-[130%]">
+ {{ image.title }}
+ </h1>
+ <i18n
+ v-if="image.creator"
+ path="image-details.creator"
+ tag="span"
+ class="font-semibold leading-[130%]"
+ >
+ <template #name>
+ <a
+ v-if="image.creator_url"
+ :aria-label="
+ $t('media-details.aria.creator-url', {
+ creator: image.creator,
+ })
+ "
+ :href="image.creator_url"
+ target="blank"
+ rel="noopener noreferrer"
+ @click="onCreatorLinkClicked"
+ @keyup.enter="onCreatorLinkClicked"
+ >{{ image.creator }}</a
+ >
+ <span v-else>{{ image.creator }}</span>
+ </template>
+ </i18n>
+ </span>
+ </section>
+
+ <VMediaReuse :media="image" />
+ <VImageDetails
:image="image"
- :thumbnail="thumbnailURL"
- :bread-crumb-u-r-l="breadCrumbURL"
- :should-show-breadcrumb="shouldShowBreadcrumb"
:image-width="imageWidth"
:image-height="imageHeight"
:image-type="imageType"
- @onImageLoaded="onImageLoaded"
/>
- <RelatedImages :image-id="imageId" />
+ <VRelatedImages :image-id="imageId" />
</div>
</template>
@@ -18,31 +88,56 @@
import axios from 'axios'
import { mapActions, mapState } from 'vuex'
import { FETCH_IMAGE } from '~/constants/action-types'
-import { MEDIA } from '~/constants/store-modules'
-import RelatedImages from '~/components/ImageDetails/RelatedImages.vue'
-import VPhotoDetails from '~/components/ImageDetails/VPhotoDetails.vue'
+import { MEDIA, USAGE_DATA } from '~/constants/store-modules'
+import {
+ DETAIL_PAGE_EVENTS,
+ SEND_DETAIL_PAGE_EVENT,
+} from '~/constants/usage-data-analytics-types'
+
+import VButton from '~/components/VButton.vue'
+import VIcon from '~/components/VIcon/VIcon.vue'
+import VImageDetails from '~/components/VImageDetails/VImageDetails.vue'
+import VMediaReuse from '~/components/VMediaInfo/VMediaReuse.vue'
+import VRelatedImages from '~/components/VImageDetails/VRelatedImages.vue'
+import SketchFabViewer from '~/components/SketchFabViewer.vue'
-const PhotoDetailPage = {
- name: 'PhotoDetailPage',
- components: { RelatedImages, VPhotoDetails },
+import Chevron from '~/assets/icons/chevron-left.svg?inline'
+
+const VImageDetailsPage = {
+ name: 'VImageDetailsPage',
+ components: {
+ Chevron,
+ VButton,
+ VIcon,
+ VImageDetails,
+ VMediaReuse,
+ VRelatedImages,
+ SketchFabViewer,
+ },
data() {
return {
- breadCrumbURL: '',
- isPrimaryImageLoaded: false,
+ breadcrumbUrl: '',
shouldShowBreadcrumb: false,
imageWidth: 0,
imageHeight: 0,
imageType: 'Unknown',
- thumbnailURL: '',
imageId: null,
+ sketchFabfailure: false,
}
},
computed: {
...mapState(MEDIA, ['image']),
+ sketchFabUid() {
+ if (this.image.source !== 'sketchfab' || this.sketchFabfailure) {
+ return null
+ }
+ return this.image.url
+ .split('https://media.sketchfab.com/models/')[1]
+ .split('/')[0]
+ },
},
- async asyncData({ env, route }) {
+ async asyncData({ route }) {
return {
- thumbnailURL: `${env.apiUrl}images/${route.params.id}/thumb/`,
imageId: route.params.id,
}
},
@@ -66,18 +161,34 @@ const PhotoDetailPage = {
from.name === _this.localeRoute({ path: '/search/image' }).name
) {
_this.shouldShowBreadcrumb = true
- _this.breadCrumbURL = from.fullPath
+ _this.breadcrumbUrl = from.fullPath
}
})
},
methods: {
...mapActions(MEDIA, { fetchImage: FETCH_IMAGE }),
+ ...mapActions(USAGE_DATA, { sendEvent: SEND_DETAIL_PAGE_EVENT }),
onImageLoaded(event) {
- this.imageWidth = event.target.naturalWidth
- this.imageHeight = event.target.naturalHeight
- this.isPrimaryImageLoaded = true
- axios.head(event.target.src).then((res) => {
- this.imageType = res.headers['content-type']
+ this.imageWidth = this.image.width || event.target.naturalWidth
+ this.imageHeight = this.image.height || event.target.naturalHeight
+ if (this.image.filetype) {
+ this.imageType = this.image.filetype
+ } else {
+ axios.head(event.target.src).then((res) => {
+ this.imageType = res.headers['content-type']
+ })
+ }
+ },
+ onSourceLinkClicked() {
+ this.sendEvent({
+ eventType: DETAIL_PAGE_EVENTS.SOURCE_CLICKED,
+ resultUuid: this.imageId,
+ })
+ },
+ onCreatorLinkClicked() {
+ this.sendEvent({
+ eventType: DETAIL_PAGE_EVENTS.CREATOR_CLICKED,
+ resultUuid: this.imageId,
})
},
},
@@ -89,5 +200,16 @@ const PhotoDetailPage = {
},
}
-export default PhotoDetailPage
+export default VImageDetailsPage
</script>
+
+<style scoped>
+section,
+aside {
+ @apply px-6 md:px-16 mb-10 md:mb-16 md:max-w-screen-lg lg:mx-auto;
+}
+
+.btn-main {
+ @apply py-3 md:py-4 md:px-6 text-sr md:text-2xl font-semibold;
+}
+</style>
diff --git a/src/styles/components/tabs.scss b/src/styles/components/tabs.scss
deleted file mode 100644
index f90d957b1..000000000
--- a/src/styles/components/tabs.scss
+++ /dev/null
@@ -1,84 +0,0 @@
-$tabs-border-bottom-color: $color-light-gray;
-$tabs-border-bottom-width: 0.125rem;
-$tabs-font-size: 1rem;
-
-.tabs {
- display: flex;
- flex-direction: column;
-
- justify-content: space-between;
- overflow: hidden;
- overflow-x: auto;
- font-family: $family-inter;
- [role='tablist'] {
- display: flex;
- border-bottom: $tabs-border-bottom-width solid $tabs-border-bottom-color;
- font-size: 1rem;
- }
- .tabs-panel {
- display: none;
- padding: 2rem 0 0;
- &.is-active {
- display: block;
- }
- }
-
- .tab {
- appearance: none;
- border-image-source: unset;
- border-image-outset: unset;
- border-image-repeat: unset;
- font-weight: 700;
- margin: 0 1rem -0.125rem 1rem;
- padding: 0.5rem 0 1rem;
- position: relative;
- border-width: 0;
- background: transparent;
- border-bottom: 0.25rem solid transparent;
- color: #333;
- cursor: pointer;
- user-select: none;
- text-decoration: none;
-
- &.is-active,
- &:hover {
- border-bottom-color: #333;
- text-decoration: none;
- }
- &:focus {
- outline: none;
- }
- &:focus-visible {
- outline: none;
- box-shadow: 0 0 0 0.125rem #d8d8d8;
- }
- }
-}
-.boxed {
- [role='tablist'] {
- display: flex;
- align-self: flex-start;
- border-bottom: none;
- }
- .tabs-panel {
- padding: 1rem;
- background-color: white;
- border: 1px solid $color-light-gray;
- }
- .tab {
- font-size: 1rem;
- margin: 0 0 -0.125rem;
- border: 1px solid $color-light-gray;
- padding: 0.5rem 1rem;
-
- &.is-active,
- &:hover {
- background-color: white;
- border-bottom: 0;
- padding-bottom: 0.625rem;
- }
- &:focus-visible {
- box-shadow: 0 0 0 0.125rem #d8d8d8;
- }
- }
-}
diff --git a/src/styles/vocabulary.scss b/src/styles/vocabulary.scss
index f192f4e08..0f465307e 100644
--- a/src/styles/vocabulary.scss
+++ b/src/styles/vocabulary.scss
@@ -21,6 +21,5 @@
@import 'components/navbar';
@import 'components/footer';
@import 'components/card';
-@import 'components/tabs';
@import 'components/table';
@import 'components/content';
diff --git a/src/utils/attribution-html.js b/src/utils/attribution-html.js
index 8a2ca63fc..bcd0290df 100644
--- a/src/utils/attribution-html.js
+++ b/src/utils/attribution-html.js
@@ -1,24 +1,24 @@
-function attributionHtml(image, licenseUrl, fullLicenseName) {
- if (!image) {
+function getAttributionHtml(media, licenseUrl, fullLicenseName) {
+ if (!media) {
return ''
}
const baseAssetsPath = 'https://search.creativecommons.org/static/img'
- const imgLink = `<a href="${image.foreign_landing_url}">"${image.title}"</a>`
+ const imgLink = `<a href="${media.foreign_landing_url}">"${media.title}"</a>`
let creator = ''
- let imageTag = ''
- if (image.url && image.title) {
- imageTag = `<img style="display: block;" src="${image.url}" alt="${image.title}">`
+ let mediaTag = ''
+ if (media.url && media.title) {
+ mediaTag = `<img style="display: block;" src="${media.url}" alt="${media.title}">`
}
- if (image.creator && image.creator_url) {
- creator = `<span> by <a href="${image.creator_url}">${image.creator}</a></span>`
- } else if (image.creator && !image.creator_url) {
- creator = `<span> by <span>${image.creator}</span></span>`
+ if (media.creator && media.creator_url) {
+ creator = `<span> by <a href="${media.creator_url}">${media.creator}</a></span>`
+ } else if (media.creator && !media.creator_url) {
+ creator = `<span> by <span>${media.creator}</span></span>`
}
const licenseLink = ` is licensed under <a href="${licenseUrl}" style="margin-right: 5px;">${fullLicenseName.toUpperCase()}</a>`
- let licenseIcons = `<img style="height: inherit;margin-right: 3px;display: inline-block;" src="${baseAssetsPath}/cc_icon.svg?image_id=${image.id}" />`
- if (image.license) {
- licenseIcons += image.license
+ let licenseIcons = `<img style="height: inherit;margin-right: 3px;display: inline-block;" src="${baseAssetsPath}/cc_icon.svg?media_id=${media.id}" />`
+ if (media.license) {
+ licenseIcons += media.license
.split('-')
.map(
(license) =>
@@ -28,7 +28,7 @@ function attributionHtml(image, licenseUrl, fullLicenseName) {
}
const licenseImgLink = `<a href="${licenseUrl}" target="_blank" rel="noopener noreferrer" style="display: inline-block;white-space: none;margin-top: 2px;margin-left: 3px;height: 22px !important;">${licenseIcons}</a>`
- return `<p style="font-size: 0.9rem;font-style: italic;">${imageTag}${imgLink}${creator}${licenseLink}${licenseImgLink}</p>`
+ return `<p style="font-size: 0.9rem;font-style: italic;">${mediaTag}${imgLink}${creator}${licenseLink}${licenseImgLink}</p>`
}
-export default attributionHtml
+export default getAttributionHtml
diff --git a/test/e2e/image-detail.spec.js b/test/e2e/image-detail.spec.js
index 640e5a486..a0a5886fe 100644
--- a/test/e2e/image-detail.spec.js
+++ b/test/e2e/image-detail.spec.js
@@ -18,7 +18,7 @@ test('shows the author and title of the image', async ({ page }) => {
test('shows the main image with its title as alt text', async ({ page }) => {
const imgTitle = await page.locator('h1').innerText()
- const img = page.locator('img[class="photo_image"]')
+ const img = page.locator('id=main-image')
await expect(img).toBeVisible()
await expect(img).toHaveAttribute('alt', imgTitle)
})
diff --git a/test/e2e/search.spec.js b/test/e2e/search.spec.js
index 81978d50d..6cbdbef36 100644
--- a/test/e2e/search.spec.js
+++ b/test/e2e/search.spec.js
@@ -7,6 +7,7 @@
* On error: shows error message
*/
const { expect, test } = require('@playwright/test')
+
test.beforeEach(async ({ context }) => {
// Block any image or audio (jamendo.com) requests for each test in this file.
await context.route(/\.(png|jpeg|jpg|svg)$/, (route) => route.abort())
@@ -51,6 +52,7 @@ test('navigates to the image detail page correctly', async ({ page }) => {
await page.locator('figure a').first().click()
// Until the image is loaded, the heading is 'Image' instead of the actual title
+ await page.locator('#main-image').waitFor()
const headingText = await page.locator('h1').textContent()
expect(headingText.trim().toLowerCase()).toEqual(imgTitle.toLowerCase())
diff --git a/test/unit/specs/components/ImageDetails/image-attribution.spec.js b/test/unit/specs/components/ImageDetails/image-attribution.spec.js
deleted file mode 100644
index 447b7bcfd..000000000
--- a/test/unit/specs/components/ImageDetails/image-attribution.spec.js
+++ /dev/null
@@ -1,44 +0,0 @@
-import ImageAttribution from '~/components/ImageDetails/ImageAttribution'
-import render from '../../../test-utils/render'
-import i18n from '../../../test-utils/i18n'
-
-describe('ImageAttribution', () => {
- let options = null
- let props = null
- const $t = (key) => i18n.messages[key]
-
- beforeEach(() => {
- props = {
- image: {
- id: 0,
- title: 'foo',
- provider: 'flickr',
- url: 'foo.bar',
- thumbnail: 'http://foo.bar',
- foreign_landing_url: 'http://foo.bar',
- license: 'BY',
- license_version: '1.0',
- creator: 'John',
- creator_url: 'http://creator.com',
- },
- licenseUrl: 'http://license.com',
- fullLicenseName: 'LICENSE',
- attributionHtml: '<div>attribution</div>',
- }
- options = {
- propsData: props,
- mocks: {
- $t,
- },
- stubs: {
- MediaLicense: true,
- CopyLicense: true,
- },
- }
- })
-
- it('should contain the correct contents', () => {
- const wrapper = render(ImageAttribution, options)
- expect(wrapper.find('.sidebar_section')).toBeDefined()
- })
-})
diff --git a/test/unit/specs/components/ImageDetails/image-info.spec.js b/test/unit/specs/components/ImageDetails/image-info.spec.js
deleted file mode 100644
index 28732adf6..000000000
--- a/test/unit/specs/components/ImageDetails/image-info.spec.js
+++ /dev/null
@@ -1,68 +0,0 @@
-import ImageInfo from '~/components/ImageDetails/ImageInfo'
-import render from '../../../test-utils/render'
-import i18n from '../../../test-utils/i18n'
-import { createLocalVue } from '@vue/test-utils'
-import Vuex from 'vuex'
-
-describe('Image Info', () => {
- let props = null
- let options = {}
- let localVue = null
- let storeMock = null
- const $t = (key) => i18n.messages[key]
- beforeEach(() => {
- localVue = createLocalVue()
- localVue.use(Vuex)
- storeMock = new Vuex.Store({
- modules: {
- provider: {
- namespaced: true,
- state: {
- provider: 'flickr',
- source: 'flickr',
- },
- },
- },
- })
- props = {
- image: {
- id: 0,
- title: 'foo',
- source: 'flickr',
- provider: 'flickr',
- url: 'foo.bar',
- thumbnail: 'http://foo.bar',
- foreign_landing_url: 'http://foo.bar',
- license: 'BY',
- license_version: '1.0',
- creator: 'John',
- creator_url: 'http://creator.com',
- },
- licenseUrl: 'http://license.com',
- fullLicenseName: 'LICENSE',
- imageHeight: 1000,
- imageWidth: 500,
- }
-
- options = {
- localVue,
- propsData: props,
- store: storeMock,
- mocks: {
- $t,
- },
- }
- })
-
- it('should contain the correct contents', () => {
- const wrapper = render(ImageInfo, options)
- expect(wrapper.find('.sidebar_section').element).toBeDefined()
- })
-
- it('should display image dimensions', () => {
- const wrapper = render(ImageInfo, options)
-
- expect(wrapper.html()).toContain(`${props.imageWidth}`)
- expect(wrapper.html()).toContain(`${props.imageHeight}`)
- })
-})
diff --git a/test/unit/specs/components/ImageDetails/copy-license.spec.js b/test/unit/specs/components/ImageDetails/v-copy-license.spec.js
similarity index 77%
rename from test/unit/specs/components/ImageDetails/copy-license.spec.js
rename to test/unit/specs/components/ImageDetails/v-copy-license.spec.js
index b7ecd662f..0c103c3bb 100644
--- a/test/unit/specs/components/ImageDetails/copy-license.spec.js
+++ b/test/unit/specs/components/ImageDetails/v-copy-license.spec.js
@@ -1,4 +1,4 @@
-import CopyLicense from '~/components/MediaInfo/CopyLicense'
+import VCopyLicense from '~/components/VMediaInfo/VCopyLicense.vue'
import { COPY_ATTRIBUTION } from '~/constants/action-types'
import {
DETAIL_PAGE_EVENTS,
@@ -6,13 +6,13 @@ import {
} from '~/constants/usage-data-analytics-types'
import render from '../../../test-utils/render'
-import i18n from '../../../test-utils/i18n'
import { ATTRIBUTION, USAGE_DATA } from '~/constants/store-modules'
-describe('CopyLicense', () => {
+describe('VCopyLicense', () => {
let options = null
let props = null
- const $t = (key) => i18n.messages[key]
+ let dispatchMock = null
+
const copyData = {
type: 'Bar',
event: {
@@ -20,8 +20,6 @@ describe('CopyLicense', () => {
},
}
- let dispatchMock = null
-
beforeEach(() => {
dispatchMock = jest.fn()
props = {
@@ -34,32 +32,33 @@ describe('CopyLicense', () => {
foreign_landing_url: 'http://foo.bar',
license: 'BY',
license_version: '1.0',
+ license_url: 'http://license.com',
creator: 'John',
creator_url: 'http://creator.com',
},
- licenseUrl: 'http://license.com',
fullLicenseName: 'LICENSE',
- attributionHtml: '<div>attribution</div>',
}
options = {
- stubs: { CopyButton: true },
propsData: props,
mocks: {
- $store: {
- dispatch: dispatchMock,
+ $nuxt: {
+ context: {
+ store: {
+ dispatch: dispatchMock,
+ },
+ },
},
- $t,
},
}
})
it('should contain the correct contents', () => {
- const wrapper = render(CopyLicense, options)
+ const wrapper = render(VCopyLicense, options)
expect(wrapper.find('.copy-license')).toBeDefined()
})
it('should dispatch COPY_ATTRIBUTION', () => {
- const wrapper = render(CopyLicense, options)
+ const wrapper = render(VCopyLicense, options)
wrapper.vm.onCopyAttribution(copyData.type, copyData.event)
expect(dispatchMock).toHaveBeenCalledWith(
`${ATTRIBUTION}/${COPY_ATTRIBUTION}`,
@@ -71,7 +70,7 @@ describe('CopyLicense', () => {
})
it('should dispatch SEND_DETAIL_PAGE_EVENT on copy attribution', () => {
- const wrapper = render(CopyLicense, options)
+ const wrapper = render(VCopyLicense, options)
wrapper.vm.onCopyAttribution(copyData.type, copyData.event)
expect(dispatchMock).toHaveBeenCalledWith(
`${USAGE_DATA}/${SEND_DETAIL_PAGE_EVENT}`,
diff --git a/test/unit/specs/components/ImageDetails/v-photo-details.spec.js b/test/unit/specs/components/ImageDetails/v-photo-details.spec.js
deleted file mode 100644
index d19038933..000000000
--- a/test/unit/specs/components/ImageDetails/v-photo-details.spec.js
+++ /dev/null
@@ -1,163 +0,0 @@
-import VPhotoDetails from '~/components/ImageDetails/VPhotoDetails.vue'
-import {
- DETAIL_PAGE_EVENTS,
- SEND_DETAIL_PAGE_EVENT,
-} from '~/constants/usage-data-analytics-types'
-import { fireEvent, render, screen } from '@testing-library/vue'
-import { USAGE_DATA } from '~/constants/store-modules'
-import { createLocalVue } from '@vue/test-utils'
-import Vuex from 'vuex'
-import VueI18n from 'vue-i18n'
-import messages from '~/locales/en.json'
-
-const i18n = new VueI18n({
- locale: 'en',
- fallbackLocale: 'en',
- messages: { en: messages },
-})
-
-describe('PhotoDetails', () => {
- let options = null
- let props = null
- let dispatchMock
- const localVue = createLocalVue()
- localVue.use(Vuex)
- localVue.use(VueI18n)
-
- beforeEach(() => {
- props = {
- image: {
- id: 0,
- title: 'Title foo',
- provider: 'flickr',
- url: 'foo.bar',
- thumbnail: 'http://foo.bar',
- foreign_landing_url: 'http://foo.bar',
- license: 'BY',
- license_version: '1.0',
- creator: 'John',
- creator_url: 'http://creator.com',
- },
- shouldShowBreadcrumb: true,
- query: {
- q: 'foo',
- },
- }
-
- dispatchMock = jest.fn()
- const routerMock = {
- push: jest.fn(),
- back: jest.fn(),
- }
- const routeMock = {
- params: {
- location: window.scrollY,
- },
- }
- const storeMock = new Vuex.Store({
- modules: {
- search: { namespaced: true, state: {} },
- provider: {
- namespaced: true,
- state: {},
- getters: { getProviderName: (val) => () => val },
- },
- 'usage-data': {
- namespaced: true,
- actions: { SEND_DETAIL_PAGE_EVENT: jest.fn() },
- },
- },
- })
- options = {
- localVue,
- propsData: props,
- mocks: {
- $nuxt: {
- context: {
- route: routeMock,
- store: storeMock,
- },
- },
- $router: routerMock,
- },
- store: storeMock,
- i18n,
- }
- })
-
- it('should render correct contents', () => {
- render(VPhotoDetails, options)
- expect(screen.findByAltText(props.image.title)).toBeTruthy()
- expect(screen.queryAllByText(props.image.title)).toHaveLength(1)
- })
-
- it('should generate license name', () => {
- render(VPhotoDetails, options)
- const licenseName = screen.queryAllByText(/CC BY 1.0/)
-
- expect(licenseName.length).toEqual(3)
- })
-
- it('should generate CC-0 license name', () => {
- options.propsData.image.license = 'cc0'
- render(VPhotoDetails, options)
- const licenseElements = screen.queryAllByText(/CC0/i)
-
- expect(licenseElements.length).toEqual(4)
- })
-
- it('should generate CC-0 license name when license is CC0 uppercase', () => {
- options.propsData.image.license = 'CC0'
- render(VPhotoDetails, options)
- const licenseElements = screen.queryAllByText(/CC0/i)
- expect(licenseElements.length).toEqual(4)
- })
-
- it('renders link back to search results if enabled', () => {
- options.propsData.shouldShowBreadcrumb = true
- render(VPhotoDetails, options)
-
- expect(screen.queryByText(/back/i)).toBeVisible()
- })
-
- it('doesnt render link back to search results if disabled', async () => {
- options.propsData.shouldShowBreadcrumb = false
- render(VPhotoDetails, options)
-
- expect(screen.queryByText(/back/i)).toBeNull()
- })
-
- it('renders image title', () => {
- render(VPhotoDetails, options)
-
- expect(screen.queryAllByText(props.image.title).length).toEqual(1)
- })
-
- it('should toggle visibility of report form on report button click', async () => {
- render(VPhotoDetails, options)
- await fireEvent.click(screen.queryByRole('button', { name: /report/i }))
-
- expect(screen.queryAllByRole('radio').length).toBe(3)
- })
-
- it('report form should be invisible by default', () => {
- render(VPhotoDetails, options)
-
- expect(screen.queryAllByRole('radio').length).toEqual(0)
- })
-
- it('should dispatch SOURCE_CLICKED on source link clicked', async () => {
- options.store.dispatch = dispatchMock
- render(VPhotoDetails, options)
- const sourceLink = screen.queryByTestId('source-button')
- await fireEvent.click(sourceLink)
-
- expect(dispatchMock).toHaveBeenCalledWith(
- `${USAGE_DATA}/${SEND_DETAIL_PAGE_EVENT}`,
- {
- eventType: DETAIL_PAGE_EVENTS.SOURCE_CLICKED,
- resultUuid: props.image.id,
- }
- )
- })
-})
diff --git a/test/unit/specs/components/copy-button.spec.js b/test/unit/specs/components/copy-button.spec.js
index b02609dfa..cdc69169b 100644
--- a/test/unit/specs/components/copy-button.spec.js
+++ b/test/unit/specs/components/copy-button.spec.js
@@ -15,12 +15,12 @@ describe('CopyButton', () => {
el: '#foo',
id: 'foo',
}
- options = { propsData: props }
+ options = { propsData: props, stubs: ['VButton'] }
})
it('should render correct contents', () => {
const wrapper = render(CopyButton, options)
- expect(wrapper.find('button').vm).toBeDefined()
+ expect(wrapper.find('button')).toBeDefined()
})
it('data.success should be false by default', () => {
diff --git a/test/unit/specs/components/related-images.spec.js b/test/unit/specs/components/related-images.spec.js
index 8adf730db..da7936e17 100644
--- a/test/unit/specs/components/related-images.spec.js
+++ b/test/unit/specs/components/related-images.spec.js
@@ -2,7 +2,7 @@ import Vuex from 'vuex'
import VueI18n from 'vue-i18n'
import { createLocalVue } from '@vue/test-utils'
import { render, screen } from '@testing-library/vue'
-import RelatedImages from '~/components/ImageDetails/RelatedImages'
+import VRelatedImages from '~/components/VImageDetails/VRelatedImages'
const serviceMock = jest.fn(() =>
Promise.resolve({
@@ -42,9 +42,10 @@ describe('RelatedImage', () => {
})
it('should render an image grid', async () => {
// await `render` to get the component after Nuxt's `fetch` call
- await render(RelatedImages, options)
+ await render(VRelatedImages, options)
+
expect(screen.getByRole('heading').textContent).toContain(
- 'photo-details.related-images'
+ 'image-details.related-images'
)
expect(screen.queryAllByRole('img').length).toEqual(2)
expect(screen.queryAllByRole('figure').length).toEqual(2)
@@ -53,9 +54,9 @@ describe('RelatedImage', () => {
it('should not render data service rejects with an error', async () => {
options.propsData.service.getRelatedMedia = failedMock
// await `render` to get the component after Nuxt's `fetch` call
- await render(RelatedImages, options)
+ await render(VRelatedImages, options)
expect(screen.getByRole('heading').textContent).toContain(
- 'photo-details.related-images'
+ 'image-details.related-images'
)
expect(screen.queryAllByRole('img').length).toEqual(0)
})