4.7 KiB
#Olivero Sub-theme commands
##Clone the old theme
Clone the theme and remove the .git file
rm -rf .git
Swap old themename with new:
rename 's/livesimagined/livesvoices/g' **/*.* -v
Replace theme names within the files:
perl -pi -w -e 's/livesimagined/livesvoices/g;' **/*.*
##Clone the block placement
do a fresh export of the configs with drush
drush config:export
copy all of the block.block.*.yml
files to a temp dir outside of the sync dir and
remove the configs for the ones that are not the islandora related
remove the uuid at the top of each of these files:
sed -i '1d'
* (this removes the first line of each file which is the uuid)
change the theme defined in each:
perl -pi -w -e 's/olivero/vre2024/g;' **/*.*
confirm block region for placement and swap if required:
perl -pi -w -e 's/sidebar/sidebar_second/g;' **/*.*
the block ID's need to be unique in these new configs so prepend the old ID's with the themename:
perl -pi -w -e 's/^id: /id: vre2024_/g;' **/*.*
(there are a number of id's in each file but the one we are looking for is the only one that starts a line with no tabs or indents, this command targets those)
copy these files back into the sync folder and run:
drush config:import
*You should now see the blocks in the block layout for the new theme but don't make it default yet.
*Manually configure the Display contexts so the viewers are placed in the new theme
#!/bin/bash
Prompt for source directory
read -p "Enter the source directory path: " SOURCE_DIR
Check if source directory exists
if [ ! -d "$SOURCE_DIR" ]; then echo "Error: Source directory '$SOURCE_DIR' does not exist." exit 1 fi
Prompt for new directory name
read -p "Enter the new directory name: " NEW_DIR
Prompt for old theme name to replace
read -p "Enter the old theme name to replace: " OLD_THEME
Prompt for new theme name
read -p "Enter the new theme name: " NEW_THEME
Extract the parent directory from SOURCE_DIR to place the new directory there
PARENT_DIR=$(dirname "$SOURCE_DIR") NEW_PATH="$PARENT_DIR/$NEW_DIR"
Check if new directory already exists
if [ -d "$NEW_PATH" ]; then echo "Error: Directory '$NEW_PATH' already exists." exit 1 fi
Copy the source directory to the new directory
echo "Copying '$SOURCE_DIR' to '$NEW_PATH'..." cp -r "$SOURCE_DIR" "$NEW_PATH"
if [ $? -ne 0 ]; then echo "Error: Failed to copy the directory." exit 1 fi
Change to the new directory
cd "$NEW_PATH" || exit 1
Generate case variations of OLD_THEME and NEW_THEME
OLD_THEME_LOWER=$(echo "$OLD_THEME" | tr '[:upper:]' '[:lower:]') OLD_THEME_UPPER=$(echo "$OLD_THEME" | tr '[:lower:]' '[:upper:]') OLD_THEME_FIRSTCAP=$(echo "$OLD_THEME" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
NEW_THEME_LOWER=$(echo "$NEW_THEME" | tr '[:upper:]' '[:lower:]') NEW_THEME_UPPER=$(echo "$NEW_THEME" | tr '[:lower:]' '[:upper:]') NEW_THEME_FIRSTCAP=$(echo "$NEW_THEME" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}')
Escape special characters for sed
OLD_THEME_LOWER_ESC=$(echo "$OLD_THEME_LOWER" | sed 's/[/&]/\&/g') OLD_THEME_UPPER_ESC=$(echo "$OLD_THEME_UPPER" | sed 's/[/&]/\&/g') OLD_THEME_FIRSTCAP_ESC=$(echo "$OLD_THEME_FIRSTCAP" | sed 's/[/&]/\&/g')
NEW_THEME_LOWER_ESC=$(echo "$NEW_THEME_LOWER" | sed 's/[/&]/\&/g') NEW_THEME_UPPER_ESC=$(echo "$NEW_THEME_UPPER" | sed 's/[/&]/\&/g') NEW_THEME_FIRSTCAP_ESC=$(echo "$NEW_THEME_FIRSTCAP" | sed 's/[/&]/\&/g')
echo "Matching: '$OLD_THEME_LOWER' → '$NEW_THEME_LOWER', '$OLD_THEME_UPPER' → '$NEW_THEME_UPPER', '$OLD_THEME_FIRSTCAP' → '$NEW_THEME_FIRSTCAP'"
Rename files by replacing each case variation of OLD_THEME with corresponding NEW_THEME
echo "Renaming files..." find . -type f ( -name "$OLD_THEME_LOWER" -o -name "$OLD_THEME_UPPER" -o -name "$OLD_THEME_FIRSTCAP" ) | while IFS= read -r file; do new_file=$(echo "$file" | sed "s/$OLD_THEME_LOWER_ESC/$NEW_THEME_LOWER_ESC/g; s/$OLD_THEME_UPPER_ESC/$NEW_THEME_UPPER_ESC/g; s/$OLD_THEME_FIRSTCAP_ESC/$NEW_THEME_FIRSTCAP_ESC/g") if [ "$file" != "$new_file" ]; then mv -v "$file" "$new_file" fi done
Replace each case variation of OLD_THEME with corresponding NEW_THEME in file contents
echo "Replacing in file contents..." find . -type f -exec sed -i '' -e "s/$OLD_THEME_LOWER_ESC/$NEW_THEME_LOWER_ESC/g" -e "s/$OLD_THEME_UPPER_ESC/$NEW_THEME_UPPER_ESC/g" -e "s/$OLD_THEME_FIRSTCAP_ESC/$NEW_THEME_FIRSTCAP_ESC/g" {} ;
rm -rf .git git init git add --all git commit -m "1st" echo "Local Git repo created" echo "Directory copied, files renamed, and contents updated successfully!" echo "New directory: '$NEW_PATH'"