From dbc25daecb12cc8b9addd170dd35652cb125e65e Mon Sep 17 00:00:00 2001 From: Ciprian Stavovei Date: Fri, 17 Jun 2022 15:29:50 +0300 Subject: [PATCH] DEV-1953: Add init-media-icons script and pel library patch. --- composer.json | 6 +++++- phapp.yml | 3 +++ scripts/init-media-icons.sh | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100755 scripts/init-media-icons.sh diff --git a/composer.json b/composer.json index 6cbbfd40f7..2c0d988e2d 100644 --- a/composer.json +++ b/composer.json @@ -144,7 +144,11 @@ }, "enable-patching": true, "composer-exit-on-patch-failure": true, - "patches": {} + "patches": { + "lsolesen/pel": { + "#183: PelIllegalFormatException: Unknown format: 0x0": "https://patch-diff.githubusercontent.com/raw/pel/pel/pull/199.patch" + } + } }, "config": { "platform": { diff --git a/phapp.yml b/phapp.yml index fc2434d86c..3cc5d999c4 100644 --- a/phapp.yml +++ b/phapp.yml @@ -25,6 +25,7 @@ commands: status: | drush status --fields=bootstrap | grep 'bootstrap' -q init: | + ./scripts/init-media-icons.sh && drush sql-create -y && zcat dumps/init.sql.gz | drush sql:cli && drush updatedb -y && @@ -34,12 +35,14 @@ commands: fi && drush locale:check && drush locale:update install: | + ./scripts/init-media-icons.sh && chmod +w web/sites/default && drush sql-create -y && SITE=${SITE:-default} && drush site-install -y --sites-subdir=$SITE --config-dir=../config/sync ${INSTALL_PROFILE:-minimal} && drush en admin_toolbar_tools dsk_config_split services_env_parameter -y update: | + ./scripts/init-media-icons.sh && drush updatedb -y && # Skip config-import when there is no config. if [ -f config/sync/core.extension.yml ]; then diff --git a/scripts/init-media-icons.sh b/scripts/init-media-icons.sh new file mode 100755 index 0000000000..f75248c506 --- /dev/null +++ b/scripts/init-media-icons.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# Script that moves media icons from core to public files so that +# "File at public://something.png does not exist" error to be removed on setup. +# Be sure files directories are setup. +cd `dirname $0`/.. +for SITE in `ls -d web/sites/*/`; do + SITE=`basename $SITE` + + if [[ $SITE == 'all' ]] || [[ $SITE == 'default' ]]; then + continue; + fi + + if [ ! -w web/sites/$SITE/files/public ]; then + echo "Public files cannot be added (no write permission)." 1>&2 + continue; + fi + echo "Copying public files..." + mkdir -p web/sites/$SITE/files/public/media-icons/generic \ + # Public files: Prepare media icon files (originally from web/core/modules/media/images/icons/*). + if [[ -d web/core/modules/media/images/icons ]]; then + cp -r web/core/modules/media/images/icons/. web/sites/$SITE/files/public/media-icons/generic + fi + + if [[ -d web/modules/contrib/media_entity_instagram/images/icons ]]; then + cp -r web/modules/contrib/media_entity_instagram/images/icons/. web/sites/$SITE/files/public/media-icons/generic + fi + + if [[ -d web/modules/contrib/media_entity_pinterest/images/icons ]]; then + cp -r web/modules/contrib/media_entity_pinterest/images/icons/. web/sites/$SITE/files/public/media-icons/generic + fi + if [[ -d web/modules/contrib/media_entity_twitter/images/icons ]]; then + cp -r web/modules/contrib/media_entity_twitter/images/icons/. web/sites/$SITE/files/public/media-icons/generic + fi + +done