Browse Source

[nb] Edit: Olivero Sub-theme commands.md

master
rdrew 3 weeks ago
parent
commit
7703aa313d
  1. 25
      Olivero Sub-theme commands.md

25
Olivero Sub-theme commands.md

@ -20,8 +20,8 @@ copy all of the `block.block.*.yml` files to a temp dir outside of the sync dir
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`
`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:
`perl -pi -w -e 's/olivero/vre2024/g;' **/*.*`
@ -35,42 +35,51 @@ 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
<!--Below is a bask script that will copy a theme dir and rename all files in and out:-->
# !/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"
@ -80,9 +89,11 @@ if [ $? -ne 0 ]; then
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
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" {} \;

Loading…
Cancel
Save