UNPKG

@europeana/portal

Version:
618 lines (498 loc) 18.9 kB
exports.ids = [84,1]; exports.modules = { /***/ 209: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* WEBPACK VAR INJECTION */(function(URL) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return urlIsContentfulAsset; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return optimisedSrcForContentfulAsset; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return responsiveImageSrcset; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return responsiveBackgroundImageCSSVars; }); function urlIsContentfulAsset(url) { return new URL(url).host === 'images.ctfassets.net'; } function optimisedSrcForContentfulAsset(asset, params = {}) { if (!(asset !== null && asset !== void 0 && asset.url)) { return null; } const imageUrl = new URL(asset.url); // TODO: are optimisations possible on any other content types? if (asset.contentType === 'image/jpeg') { params['fm'] = 'jpg'; params['fl'] = 'progressive'; if (!params.q) { params.q = 80; } } for (const key in params) { imageUrl.searchParams.set(key, params[key]); } return imageUrl.toString(); } function responsiveImageSrcset(image, params) { if (image !== null && image !== void 0 && image.url && urlIsContentfulAsset(image.url) && params) { return [`${optimisedSrcForContentfulAsset(image, params.small)} ${params.small.w}w`, `${optimisedSrcForContentfulAsset(image, params.medium)} ${params.medium.w}w`, `${optimisedSrcForContentfulAsset(image, params.large)} ${params.large.w}w`, `${optimisedSrcForContentfulAsset(image, params.xl)} ${params.xl.w}w`, `${optimisedSrcForContentfulAsset(image, params.xxl)} ${params.xxl.w}w`, `${optimisedSrcForContentfulAsset(image, params.xxxl)} ${params.xxxl.w}w`, `${optimisedSrcForContentfulAsset(image, params.wqhd)} ${params.wqhd.w}w`, `${optimisedSrcForContentfulAsset(image, params['4k'])} ${params['4k'].w}w`].join(','); } else if (image !== null && image !== void 0 && image.url) { return image.url; } else { return null; } } function responsiveBackgroundImageCSSVars(image, params) { if (image.url && urlIsContentfulAsset(image.url) && params) { return { '--bg-img-small': `url('${optimisedSrcForContentfulAsset(image, params.small)}')`, '--bg-img-medium': `url('${optimisedSrcForContentfulAsset(image, params.medium)}')`, '--bg-img-large': `url('${optimisedSrcForContentfulAsset(image, params.large)}')`, '--bg-img-xl': `url('${optimisedSrcForContentfulAsset(image, params.xl)}')`, '--bg-img-xxl': `url('${optimisedSrcForContentfulAsset(image, params.xxl)}')`, '--bg-img-xxxl': `url('${optimisedSrcForContentfulAsset(image, params.xxxl)}')`, '--bg-img-wqhd': `url('${optimisedSrcForContentfulAsset(image, params.wqhd)}')`, '--bg-img-4k': `url('${optimisedSrcForContentfulAsset(image, params['4k'])}')` }; } else if (image.url) { return { '--bg-img-small': `url('${image.url}')` }; } else { return null; } } /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(9)["URL"])) /***/ }), /***/ 219: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; const ENGLISH_LOCALE_CODE = 'en'; /* harmony default export */ __webpack_exports__["a"] = ({ methods: { isNamedOrganizationEntity(entity) { return (entity === null || entity === void 0 ? void 0 : entity.type) === 'Organization' && !!entity.prefLabel; }, organizationEntityNativeName(entity) { if (!this.isNamedOrganizationEntity(entity)) { return null; } const nativeLocale = Object.keys(entity.prefLabel).find(locale => locale !== ENGLISH_LOCALE_CODE) || ENGLISH_LOCALE_CODE; return { [nativeLocale]: entity.prefLabel[nativeLocale] }; }, organizationEntityNonNativeEnglishName(entity) { if (!this.isNamedOrganizationEntity(entity) || Object.keys(entity.prefLabel).length < 2) { return null; } return { [ENGLISH_LOCALE_CODE]: entity.prefLabel[ENGLISH_LOCALE_CODE] }; } } }); /***/ }), /***/ 226: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; /* harmony import */ var _plugins_europeana_entity__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(52); /* harmony import */ var _plugins_europeana_utils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2); /* harmony import */ var _plugins_europeana_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10); /* harmony default export */ __webpack_exports__["a"] = ({ methods: { collectionLinkGen(collection) { var _collection$id; const uriMatch = (_collection$id = collection.id) === null || _collection$id === void 0 ? void 0 : _collection$id.match(`^${_plugins_europeana_data__WEBPACK_IMPORTED_MODULE_2__[/* BASE_URL */ "a"]}/([^/]+)/(.+)$`); if (!uriMatch) { return null; } return this.$path({ name: 'collections-type-all', params: { type: Object(_plugins_europeana_entity__WEBPACK_IMPORTED_MODULE_0__[/* getEntityTypeHumanReadable */ "e"])(uriMatch[1]), pathMatch: Object(_plugins_europeana_utils__WEBPACK_IMPORTED_MODULE_1__[/* getLabelledSlug */ "f"])(collection.id, collection.prefLabel.en) } }); } } }); /***/ }), /***/ 229: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/components/generic/LinkBadge.vue?vue&type=template&id=858decb0& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-badge',{class:{ 'img-chip': _vm.imageUrl },attrs:{"to":_vm.$link.to(_vm.linkTo),"href":_vm.$link.href(_vm.linkTo),"pill":"","variant":_vm.badgeVariant,"data-qa":_vm.localisedTitle.values[0] + ' related chip',"lang":_vm.localisedTitle.code},nativeOn:{"click":function($event){return _vm.handleClickEvent.apply(null, arguments)}}},[(_vm.imageUrl && _vm.type === 'Organization')?_c('div',{staticClass:"organisation-logo mr-2",style:(("background-image: url(" + _vm.imageUrl + ")")),attrs:{"data-qa":"entity logo"}}):(_vm.imageUrl)?_c('b-img',{staticClass:"mr-2",attrs:{"src":_vm.imageUrl,"srcset":_vm.imageSrcSet,"sizes":"(max-width 1920px) 28w,\n (max-width 2560) 45w,\n (min-width 2561) 67w","alt":"","rounded":"circle"},on:{"error":_vm.imageNotFound}}):_vm._e(),_vm._v(" "),_c('span',[_vm._v(_vm._s(_vm.localisedTitle.values[0]))]),_vm._v(" "),_vm._t("default")],2)} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/generic/LinkBadge.vue?vue&type=template&id=858decb0& // EXTERNAL MODULE: ./src/plugins/europeana/utils.js var utils = __webpack_require__(2); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/generic/LinkBadge.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var LinkBadgevue_type_script_lang_js_ = ({ name: 'LinkBadge', props: { linkTo: { type: [String, Object], default: null }, title: { type: [String, Object], required: true }, id: { type: String, default: '' }, img: { type: String, default: '' }, type: { type: String, default: '' }, badgeVariant: { type: String, default: 'secondary' }, clickEventHandler: { type: Function, default: null }, imageSrcSet: { type: String, default: null } }, data() { return { imageUrl: this.img }; }, computed: { localisedTitle() { if (typeof this.title === 'string') { return { values: [this.title], code: null }; } return Object(utils["h" /* langMapValueForLocale */])(this.title, this.$i18n.locale); } }, methods: { handleClickEvent() { if (this.clickEventHandler) { this.clickEventHandler(); } else if (this.$matomo) { this.$matomo.trackEvent('Related_collections', 'Click related collection', this.linkTo); } }, imageNotFound() { this.imageUrl = ''; } } }); // CONCATENATED MODULE: ./src/components/generic/LinkBadge.vue?vue&type=script&lang=js& /* harmony default export */ var generic_LinkBadgevue_type_script_lang_js_ = (LinkBadgevue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(3); // CONCATENATED MODULE: ./src/components/generic/LinkBadge.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( generic_LinkBadgevue_type_script_lang_js_, render, staticRenderFns, false, null, null, "0b804530" ) /* harmony default export */ var LinkBadge = __webpack_exports__["a"] = (component.exports); /***/ }), /***/ 234: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/components/related/RelatedCollections.vue?vue&type=template&id=1370c9a3& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('b-container',{directives:[{name:"show",rawName:"v-show",value:(_vm.collections.length > 0),expression:"collections.length > 0"}],staticClass:"related-collections",attrs:{"data-qa":"related collections"}},[_c('h2',{staticClass:"related-heading text-uppercase mb-2"},[_vm._v("\n "+_vm._s(_vm.title)+"\n ")]),_vm._v(" "),_c('div',{staticClass:"badges-wrapper d-flex",class:{ 'flex-wrap': _vm.wrap }},_vm._l((_vm.collections),function(relatedCollection){return _c('LinkBadge',{key:relatedCollection.id,ref:"options",refInFor:true,attrs:{"id":relatedCollection.id,"link-to":_vm.collectionLinkGen(relatedCollection),"title":_vm.collectionTitle(relatedCollection),"img":_vm.imageUrl(relatedCollection),"type":relatedCollection.type,"badge-variant":_vm.badgeVariant,"image-src-set":_vm.imageSrcSet(relatedCollection)}})}),1)])} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/related/RelatedCollections.vue?vue&type=template&id=1370c9a3& // EXTERNAL MODULE: external "lodash/pick" var pick_ = __webpack_require__(21); var pick_default = /*#__PURE__*/__webpack_require__.n(pick_); // EXTERNAL MODULE: ./src/plugins/contentful-utils.js var contentful_utils = __webpack_require__(209); // EXTERNAL MODULE: ./src/plugins/europeana/themes.js var themes = __webpack_require__(27); // EXTERNAL MODULE: ./src/mixins/collectionLinkGen.js var collectionLinkGen = __webpack_require__(226); // EXTERNAL MODULE: ./src/mixins/europeana/entities/organizations.js var organizations = __webpack_require__(219); // EXTERNAL MODULE: ./src/components/generic/LinkBadge.vue + 4 modules var LinkBadge = __webpack_require__(229); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/related/RelatedCollections.vue?vue&type=script&lang=js& // // // // // // // // // // // // // // // // // // // // // // // // // // // // // /* harmony default export */ var RelatedCollectionsvue_type_script_lang_js_ = ({ name: 'RelatedCollections', components: { LinkBadge: LinkBadge["a" /* default */] }, mixins: [collectionLinkGen["a" /* default */], organizations["a" /* default */]], props: { title: { type: String, default: '' }, relatedCollections: { type: Array, default: () => [] }, entityUris: { type: Array, default: () => [] }, badgeVariant: { type: String, default: 'secondary' }, wrap: { type: Boolean, default: true } }, data() { return { collections: this.relatedCollections }; }, async fetch() { var _this$entityUris, _this$relatedCollecti; if ((((_this$entityUris = this.entityUris) === null || _this$entityUris === void 0 ? void 0 : _this$entityUris.length) || 0) === 0 || (((_this$relatedCollecti = this.relatedCollections) === null || _this$relatedCollecti === void 0 ? void 0 : _this$relatedCollecti.length) || 0) > 0) { return; } let entities = await this.$apis.entity.find(this.entityUris); entities = entities.map(entity => pick_default()(entity, ['id', 'prefLabel', 'isShownBy', 'logo', 'type'])); this.collections = await Object(themes["b" /* withEditorialContent */])(this, entities); }, mounted() { this.draw(); }, updated() { this.draw(); }, beforeDestroy() { this.draw('hide'); }, methods: { draw(showOrHide) { this.$emit(showOrHide || (this.collections.length > 0 ? 'show' : 'hide')); this.$nextTick(() => { this.$redrawVueMasonry && this.$redrawVueMasonry(); }); }, collectionTitle(collection) { let title; const organizationNativePrefLabel = this.organizationEntityNativeName(collection); if (organizationNativePrefLabel) { title = organizationNativePrefLabel; } else if (collection.prefLabel) { title = collection.prefLabel; } else { title = collection.name; } return title; }, imageUrl(collection) { if (collection.contentfulImage && Object(contentful_utils["d" /* urlIsContentfulAsset */])(collection.contentfulImage.url)) { return Object(contentful_utils["a" /* optimisedSrcForContentfulAsset */])(collection.contentfulImage, { w: 28, h: 28, fit: 'thumb' }); } return this.$apis.entity.imageUrl(collection); }, imageSrcSet(collection) { if (collection.contentfulImage && Object(contentful_utils["d" /* urlIsContentfulAsset */])(collection.contentfulImage.url)) { const smallImage = Object(contentful_utils["a" /* optimisedSrcForContentfulAsset */])(collection.contentfulImage, { w: 28, h: 28, fit: 'thumb' }); const wqhdImage = Object(contentful_utils["a" /* optimisedSrcForContentfulAsset */])(collection.contentfulImage, { w: 45, h: 45, fit: 'thumb' }); const fourKImage = Object(contentful_utils["a" /* optimisedSrcForContentfulAsset */])(collection.contentfulImage, { w: 67, h: 67, fit: 'thumb' }); return `${smallImage} 28w, ${wqhdImage} 45w, ${fourKImage} 67w`; } return null; } } }); // CONCATENATED MODULE: ./src/components/related/RelatedCollections.vue?vue&type=script&lang=js& /* harmony default export */ var related_RelatedCollectionsvue_type_script_lang_js_ = (RelatedCollectionsvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(3); // CONCATENATED MODULE: ./src/components/related/RelatedCollections.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( related_RelatedCollectionsvue_type_script_lang_js_, render, staticRenderFns, false, null, null, "bec5a4f2" ) /* harmony default export */ var RelatedCollections = __webpack_exports__["default"] = (component.exports); /***/ }), /***/ 569: /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; // ESM COMPAT FLAG __webpack_require__.r(__webpack_exports__); // CONCATENATED MODULE: ./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vue-loader/lib??vue-loader-options!./src/components/search/RelatedSection.vue?vue&type=template&id=891af32c& var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return (!_vm.$fetchState.pending && (_vm.relatedCollections.length > 0))?_c('RelatedCollections',{attrs:{"title":_vm.$t('collectionsYouMightLike'),"related-collections":_vm.relatedCollections,"badge-variant":_vm.badgeVariant},on:{"show":function($event){return _vm.$emit('show')},"hide":function($event){return _vm.$emit('hide')}}}):_vm._e()} var staticRenderFns = [] // CONCATENATED MODULE: ./src/components/search/RelatedSection.vue?vue&type=template&id=891af32c& // EXTERNAL MODULE: ./src/components/related/RelatedCollections.vue + 4 modules var RelatedCollections = __webpack_require__(234); // EXTERNAL MODULE: ./src/plugins/europeana/themes.js var themes = __webpack_require__(27); // CONCATENATED MODULE: ./node_modules/babel-loader/lib??ref--2-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/search/RelatedSection.vue?vue&type=script&lang=js& // // // // // // // // // // // /* harmony default export */ var RelatedSectionvue_type_script_lang_js_ = ({ name: 'RelatedSection', components: { RelatedCollections: RelatedCollections["default"] }, props: { query: { type: String, default: null }, badgeVariant: { type: String, default: 'secondary' } }, data() { return { relatedCollections: [] }; }, fetch() { return this.getSearchSuggestions(this.query).then(response => { this.relatedCollections = response; }); }, watch: { query: '$fetch' }, methods: { getSearchSuggestions(query) { if (!query) { return Promise.resolve([]); } return this.$apis.entity.suggest(query, { language: this.$i18n.locale, rows: 4 }).then(related => { return Object(themes["b" /* withEditorialContent */])(this, related); }); } } }); // CONCATENATED MODULE: ./src/components/search/RelatedSection.vue?vue&type=script&lang=js& /* harmony default export */ var search_RelatedSectionvue_type_script_lang_js_ = (RelatedSectionvue_type_script_lang_js_); // EXTERNAL MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js var componentNormalizer = __webpack_require__(3); // CONCATENATED MODULE: ./src/components/search/RelatedSection.vue /* normalize component */ var component = Object(componentNormalizer["a" /* default */])( search_RelatedSectionvue_type_script_lang_js_, render, staticRenderFns, false, null, null, "062a1fd0" ) /* harmony default export */ var RelatedSection = __webpack_exports__["default"] = (component.exports); /***/ }) };; //# sourceMappingURL=84.js.map