diff --git a/Olivero Sub-theme commands.md b/Olivero Sub-theme commands.md index 90763d8..03f58fb 100644 --- a/Olivero Sub-theme commands.md +++ b/Olivero Sub-theme commands.md @@ -1,6 +1,6 @@ -#Olivero Sub-theme commands +# Olivero Sub-theme commands -##Clone the old theme +## Clone the old theme Clone the theme and remove the .git file `rm -rf .git` @@ -11,19 +11,19 @@ Swap old themename with new: Replace theme names within the files: `perl -pi -w -e 's/livesimagined/livesvoices/g;' **/*.*` -##Clone the block placement +## Clone the block placement -do a fresh export of the configs with drush +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 +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) -macos: `sed -i '' '1d' *.yml` +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) +macos: `sed -i '' '1d' _.yml` -change the theme defined in each: +change the theme defined in each: `perl -pi -w -e 's/olivero/vre2024/g;' **/*.*` confirm block region for placement and swap if required: @@ -35,54 +35,65 @@ the block ID's need to be unique in these new configs so prepend the old ID's wi 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. +\*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 +\*Manually configure the Display contexts so the viewers are placed in the new theme -#!/bin/bash + +# !/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 +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 +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 +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))}') @@ -92,6 +103,7 @@ 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') @@ -103,16 +115,17 @@ 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 +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" {} \;