From ee863768712ad4dd5c654de23f4bf52f1b0976e9 Mon Sep 17 00:00:00 2001 From: mateuswetah Date: Fri, 18 Dec 2020 12:22:24 -0300 Subject: [PATCH] Adds mimetypes as placeholders to items list. #456. --- composer.lock | 178 +++++++++--------- .../class-tainacan-rest-items-controller.php | 1 + .../edition/item-bulk-edition-form.vue | 2 +- .../components/edition/item-edition-form.vue | 12 +- .../filter-types/taginput/Taginput.vue | 4 +- .../admin/components/lists/items-list.vue | 20 +- .../relationship/Relationship.vue | 6 +- src/views/admin/js/utilities.js | 4 +- src/views/admin/pages/singles/item-page.vue | 14 +- .../components/view-mode-cards.vue | 4 +- .../components/view-mode-list.vue | 2 +- .../components/view-mode-masonry.vue | 4 +- .../components/view-mode-records.vue | 2 +- .../components/view-mode-slideshow.vue | 4 +- .../components/view-mode-table.vue | 2 +- 15 files changed, 134 insertions(+), 125 deletions(-) diff --git a/composer.lock b/composer.lock index 55daf5138..281a6c9da 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,51 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "e2a614836d1857e45c4f9be57073c2b2", + "content-hash": "666f5355343e235ef29dd8eaae61ad43", "packages": [ + { + "name": "kornrunner/blurhash", + "version": "v1.1.0", + "source": { + "type": "git", + "url": "https://github.com/kornrunner/php-blurhash.git", + "reference": "5a09325353229c108c8d2ff129ec08b447753f9b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kornrunner/php-blurhash/zipball/5a09325353229c108c8d2ff129ec08b447753f9b", + "reference": "5a09325353229c108c8d2ff129ec08b447753f9b", + "shasum": "" + }, + "require": { + "php": "^7.2" + }, + "require-dev": { + "ocramius/package-versions": "<1.5", + "phpstan/phpstan": "^0.12", + "phpunit/phpunit": "^8.2", + "vimeo/psalm": "^3.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "kornrunner\\Blurhash\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Boris Momčilović", + "email": "boris.momcilovic@gmail.com" + } + ], + "description": "Pure PHP implementation of Blurhash", + "homepage": "https://github.com/kornrunner/php-blurhash", + "time": "2020-04-15T22:06:04+00:00" + }, { "name": "respect/validation", "version": "1.1.31", @@ -71,26 +114,26 @@ }, { "name": "smalot/pdfparser", - "version": "v0.14.0", + "version": "v0.17.1", "source": { "type": "git", "url": "https://github.com/smalot/pdfparser.git", - "reference": "ec72a99028ba5e21a0acad92047b85e128cbf81f" + "reference": "dc1e42293e7774353003b754cce9c64dd9546c2d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/smalot/pdfparser/zipball/ec72a99028ba5e21a0acad92047b85e128cbf81f", - "reference": "ec72a99028ba5e21a0acad92047b85e128cbf81f", + "url": "https://api.github.com/repos/smalot/pdfparser/zipball/dc1e42293e7774353003b754cce9c64dd9546c2d", + "reference": "dc1e42293e7774353003b754cce9c64dd9546c2d", "shasum": "" }, "require": { - "ext-mbstring": "*", "ext-zlib": "*", - "php": ">=5.3.0", - "tecnickcom/tcpdf": "~6.0" + "php": ">=5.6", + "symfony/polyfill-mbstring": "^1.18.1" }, "require-dev": { - "atoum/atoum": "^2.8 | ^3.0" + "friendsofphp/php-cs-fixer": "^2.16.3", + "symfony/phpunit-bridge": "^4.2.3" }, "type": "library", "autoload": { @@ -104,12 +147,12 @@ ], "authors": [ { - "name": "Sebastien Malot", + "name": "Sebastien MALOT", "email": "sebastien@malot.fr" } ], "description": "Pdf parser library. Can read and extract information from pdf file.", - "homepage": "http://www.pdfparser.org", + "homepage": "https://www.pdfparser.org", "keywords": [ "extract", "parse", @@ -117,24 +160,24 @@ "pdf", "text" ], - "time": "2019-01-23T09:14:37+00:00" + "time": "2020-10-29T20:59:50+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.12.0", + "version": "v1.20.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17" + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/b42a2f66e8f1b15ccf25652c3424265923eb4f17", - "reference": "b42a2f66e8f1b15ccf25652c3424265923eb4f17", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/39d483bdf39be819deabf04ec872eb0b2410b531", + "reference": "39d483bdf39be819deabf04ec872eb0b2410b531", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=7.1" }, "suggest": { "ext-mbstring": "For best performance" @@ -142,7 +185,11 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.12-dev" + "dev-main": "1.20-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" } }, "autoload": { @@ -176,84 +223,36 @@ "portable", "shim" ], - "time": "2019-08-06T08:03:45+00:00" - }, - { - "name": "tecnickcom/tcpdf", - "version": "6.2.26", - "source": { - "type": "git", - "url": "https://github.com/tecnickcom/TCPDF.git", - "reference": "367241059ca166e3a76490f4448c284e0a161f15" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/tecnickcom/TCPDF/zipball/367241059ca166e3a76490f4448c284e0a161f15", - "reference": "367241059ca166e3a76490f4448c284e0a161f15", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "config", - "include", - "tcpdf.php", - "tcpdf_parser.php", - "tcpdf_import.php", - "tcpdf_barcodes_1d.php", - "tcpdf_barcodes_2d.php", - "include/tcpdf_colors.php", - "include/tcpdf_filters.php", - "include/tcpdf_font_data.php", - "include/tcpdf_fonts.php", - "include/tcpdf_images.php", - "include/tcpdf_static.php", - "include/barcodes/datamatrix.php", - "include/barcodes/pdf417.php", - "include/barcodes/qrcode.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0" - ], - "authors": [ + "funding": [ { - "name": "Nicola Asuni", - "email": "info@tecnick.com", - "role": "lead" + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" } ], - "description": "TCPDF is a PHP class for generating PDF documents and barcodes.", - "homepage": "http://www.tcpdf.org/", - "keywords": [ - "PDFD32000-2008", - "TCPDF", - "barcodes", - "datamatrix", - "pdf", - "pdf417", - "qrcode" - ], - "time": "2018-10-16T17:24:05+00:00" + "time": "2020-10-23T14:02:19+00:00" } ], "packages-dev": [ { "name": "squizlabs/php_codesniffer", - "version": "3.4.2", + "version": "3.5.8", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8" + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", - "reference": "b8a7362af1cc1aadb5bd36c3defc4dda2cf5f0a8", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9d583721a7157ee997f235f327de038e7ea6dac4", + "reference": "9d583721a7157ee997f235f327de038e7ea6dac4", "shasum": "" }, "require": { @@ -291,20 +290,20 @@ "phpcs", "standards" ], - "time": "2019-04-10T23:49:02+00:00" + "time": "2020-10-23T02:01:07+00:00" }, { "name": "wimg/php-compatibility", - "version": "9.3.1", + "version": "9.3.5", "source": { "type": "git", "url": "https://github.com/PHPCompatibility/PHPCompatibility.git", - "reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196" + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9999344e47e7af6b00e1a898eacc4e4368fb7196", - "reference": "9999344e47e7af6b00e1a898eacc4e4368fb7196", + "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/9fb324479acf6f39452e0655d2429cc0d3914243", + "reference": "9fb324479acf6f39452e0655d2429cc0d3914243", "shasum": "" }, "require": { @@ -350,7 +349,7 @@ "standards" ], "abandoned": "phpcompatibility/php-compatibility", - "time": "2019-09-05T18:36:49+00:00" + "time": "2019-12-27T09:44:58+00:00" } ], "aliases": [], @@ -359,5 +358,6 @@ "prefer-stable": true, "prefer-lowest": false, "platform": [], - "platform-dev": [] + "platform-dev": [], + "plugin-api-version": "1.1.0" } diff --git a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php index 59e41722b..d3018f359 100644 --- a/src/classes/api/endpoints/class-tainacan-rest-items-controller.php +++ b/src/classes/api/endpoints/class-tainacan-rest-items-controller.php @@ -283,6 +283,7 @@ class REST_Items_Controller extends REST_Controller { if( isset($item_arr['thumbnail']) ) { $item_arr['thumbnail_alt'] = get_post_meta( $item->get__thumbnail_id(), '_wp_attachment_image_alt', true ); $item_arr['thumbnail_id'] = $item->get__thumbnail_id(); + $item_arr['document_mimetype'] = $item->get_document_mimetype(); // In case the thumbnail is requested, we need the document mime type to generate proper placeholders } $item_arr['url'] = get_permalink( $item_arr['id'] ); diff --git a/src/views/admin/components/edition/item-bulk-edition-form.vue b/src/views/admin/components/edition/item-bulk-edition-form.vue index 26778afd8..f79980578 100644 --- a/src/views/admin/components/edition/item-bulk-edition-form.vue +++ b/src/views/admin/components/edition/item-bulk-edition-form.vue @@ -89,7 +89,7 @@ v-if="item.document != undefined && item.document != '' && item.document_type != 'empty'" class="document-thumb" :alt="$i18n.get('label_thumbnail') + ': ' + item.title" - :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_type)" > + :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)" > diff --git a/src/views/admin/components/edition/item-edition-form.vue b/src/views/admin/components/edition/item-edition-form.vue index 3bccac724..401424e11 100644 --- a/src/views/admin/components/edition/item-edition-form.vue +++ b/src/views/admin/components/edition/item-edition-form.vue @@ -305,17 +305,21 @@ :size="178" :file="{ media_type: 'image', - thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_type) ] }, + thumbnails: { 'tainacan-medium': [ $thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype) ] }, title: $i18n.get('label_thumbnail'), - description: `` + $i18n.get(` + description: `` + $i18n.get(` }"/>
- {{ $i18n.get('label_empty_thumbnail') }} + + {{ $i18n.get('label_empty_thumbnail') }} + + :src="$thumbHelper.getEmptyThumbnailPlaceholder(item.document_mimetype)">
@@ -1056,14 +1056,14 @@ :width="$thumbHelper.getWidth(item['thumbnail'], 'tainacan-medium-full', 120)" :height="$thumbHelper.getHeight(item['thumbnail'], 'tainacan-medium-full', 120)" :hash="$thumbHelper.getBlurhashString(item['thumbnail'], 'tainacan-medium-full')" - :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_type)" - :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_type)" + :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)" + :srcset="$thumbHelper.getSrcSet(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)" :alt="item.thumbnail_alt ? item.thumbnail_alt : $i18n.get('label_thumbnail')" :transition-duration="500" /> -->
@@ -383,7 +387,7 @@ this.fetchItem({ itemId: this.itemId, contextEdit: true, - fetchOnly: 'title,thumbnail,status,modification_date,document_type,document,comment_status,document_as_html' + fetchOnly: 'title,thumbnail,status,modification_date,document_type,document_mimetype,document,comment_status,document_as_html' }) .then((resp) => { resp.request.then((item) => { diff --git a/src/views/theme-search/components/view-mode-cards.vue b/src/views/theme-search/components/view-mode-cards.vue index 299abed2d..1da9ddae6 100644 --- a/src/views/theme-search/components/view-mode-cards.vue +++ b/src/views/theme-search/components/view-mode-cards.vue @@ -73,12 +73,12 @@
+ :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium', item.document_mimetype)">
diff --git a/src/views/theme-search/components/view-mode-list.vue b/src/views/theme-search/components/view-mode-list.vue index d675212d7..39464ad3c 100644 --- a/src/views/theme-search/components/view-mode-list.vue +++ b/src/views/theme-search/components/view-mode-list.vue @@ -80,7 +80,7 @@ v-if="item.thumbnail != undefined"> + :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-medium-full', item.document_mimetype)">
@@ -452,7 +452,7 @@ export default { ` + (slideItem['thumbnail_alt'] ? slideItem['thumbnail_alt'] : (self.$i18n.get('label_thumbnail') + ': ' + slideItem.title) ) + ` + src="` + self.$thumbHelper.getSrc(slideItem['thumbnail'], 'tainacan-medium', slideItem.document_mimetype) + `">
`; }, addSlidesBefore: 2, diff --git a/src/views/theme-search/components/view-mode-table.vue b/src/views/theme-search/components/view-mode-table.vue index 25ba90761..1320c1798 100644 --- a/src/views/theme-search/components/view-mode-table.vue +++ b/src/views/theme-search/components/view-mode-table.vue @@ -172,7 +172,7 @@ + :src="$thumbHelper.getSrc(item['thumbnail'], 'tainacan-small', item.document_mimetype)">