element-web-patches/code_patches.sh

57 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
LWD="$PWD"
# TODO: cleanup, generify backup
echo 'Backing up EmojiProvider.tsx...'
if [ ! -f ../node_modules/matrix-react-sdk/src/autocomplete/EmojiProvider_backup.tsx ]; then
cp ../node_modules/matrix-react-sdk/src/autocomplete/EmojiProvider.tsx ../node_modules/matrix-react-sdk/src/autocomplete/EmojiProvider_backup.tsx
else
cp ../node_modules/matrix-react-sdk/src/autocomplete/EmojiProvider_backup.tsx ../node_modules/matrix-react-sdk/src/autocomplete/EmojiProvider.tsx
fi
echo 'Backing up compact.json...'
if [ ! -f ../node_modules/emojibase-data/en/compact_backup.json ]; then
cp ../node_modules/emojibase-data/en/compact.json ../node_modules/emojibase-data/en/compact_backup.json
else
cp ../node_modules/emojibase-data/en/compact_backup.json ../node_modules/emojibase-data/en/compact.json
fi
echo 'Adding custom emoji...'
{
cd ./reactions;
./generate.sh > "./data-injects~.json";
jq -sc '.[0] + .[1]' "../../node_modules/emojibase-data/en/compact_backup.json" "./data-injects~.json" > "../../node_modules/emojibase-data/en/compact.json";
rm "./data-injects~.json";
cd "$LWD";
} || { echo "Failed to inject reactions: Exit code $?" 1>&2; exit $?; }
echo 'Copying custom login background...'
cp -f ./lake.jpg ../res/themes/element/img/backgrounds/lake.jpg
echo 'Copying custom config.json...'
cp -f ./config.json ../config.sample.json
echo 'Backing up _EmojiPicker.pcss...'
if [ ! -f ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss.backup ]; then
cp ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss.backup
else
cp ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss.backup ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss
fi
echo 'Adding custom emoji picker CSS...'
echo "
.mx_EmojiPicker_item_wrapper {
text-overflow: clip;
white-space: nowrap;
overflow: hidden;
}" >> ../node_modules/matrix-react-sdk/res/css/views/emojipicker/_EmojiPicker.pcss
echo 'Adding greentext patch...'
patch "../node_modules/commonmark/dist/commonmark.js" ./greentext.patch
echo 'running kick fix...'
./fix_kick.sh