You are here

create-new-vartheme.sh in Varbase: The Ultimate Drupal CMS Starter Kit (Bootstrap Ready) 8.5

#!//bin/bash
################################################################################
## Create new vartheme subtheme.
################################################################################
##
## Quick tip on how to use this script command file.
##
## Create new Vartheme sub theme for a project.
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "ltr"
##------------------------------------------------------------------------------
##
## For right to left themes.
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME" "rtl"
## -----------------------------------------------------------------------------
##
## To create a new theme in the PROJECT_DIR_NAME/docroot/themes/custom
## By Bash:
## -----------------------------------------------------------------------------
## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
## bash ./create-new-vartheme.sh "THEME_NAME"
## -----------------------------------------------------------------------------
##
################################################################################

# Basic yaml parser.
parse_yaml() {
   local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
   sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
        -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p"  $1 |
   awk -F$fs '{
      indent = length($1)/2;
      vname[indent] = $2;
      for (i in vname) {if (i > indent) {delete vname[i]}}
      if (length($3) > 0) {
         vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])("_")}
         printf("%s%s%s=\"%s\"\n", "",vn, $2, $3);
      }
   }'
}

current_path=$(pwd);
drupal_root="$current_path";

if [[ "${drupal_root: -1}" == "/" ]]; then
  drupal_root="${drupal_root::-1}";
fi

if [[ "${drupal_root: -24}" == "profiles/varbase/scripts" ]]; then
  drupal_root="${drupal_root::-24}";
fi

if [[ "${drupal_root: -16}" == "profiles/varbase" ]]; then
  drupal_root="${drupal_root::-16}";
fi

if [[ "${drupal_root: -8}" == "profiles" ]]; then
  drupal_root="${drupal_root::-8}";
fi

if [[ "${drupal_root: -1}" == "/" ]]; then
  drupal_root="${drupal_root::-1}";
fi

echo "Current path: $current_path";
echo "Drupal root: $drupal_root";

# Read scripts.settings.yml file
eval $(parse_yaml $drupal_root/profiles/varbase/scripts/scripts.settings.yml);

# Default theme name.
theme_name=$default_theme_name;

# Grape the theme name argument.
if [ ! -z "$1" ]; then
  arg1="$1";
  if [[ $arg1 =~ ^[A-Za-z][A-Za-z0-9_]*$ ]]; then
    theme_name="$arg1";
  else
    echo "---------------------------------------------------------------------------";
    echo "   Theme name is not a valid theme name!                                   ";
    echo "---------------------------------------------------------------------------";
    exit 1;
  fi
else
  echo "---------------------------------------------------------------------------";
  echo "   Please add the name of your theme!                                      ";
  echo "---------------------------------------------------------------------------";
  exit 1;
fi

# Default direction.
direction=$default_direction;

# Grape the direction argument. only if we have arg #2.
if [ ! -z "$2" ]; then
  arg2="$2";
  if [[ "$arg2" == "rtl" || "$arg2" == "RTL" ]]; then
    direction=$arg2;
  elif [[ "$arg2" == "ltr" || "$arg2" == "LTR" ]]; then
    direction=$arg2;
  else
    echo "---------------------------------------------------------------------------";
    echo "   Direction of language is not valid!                                     ";
    echo "    ltr - for (left to right) languages.                                   ";
    echo "    rtl - for (right to left) languages.                                   ";
    echo "---------------------------------------------------------------------------";
    exit 1;
  fi
fi

# Default themes creation path.
theme_path=$drupal_root/$default_themes_creation_path;
mkdir -p ${theme_path};
cp ${current_path}/README.md ${theme_path}/README.md


# Create the new Vartheme subtheme if we do not have a folder with that name yet.
if [[ ! -d "$theme_path/$theme_name" ]]; then

  # 1. Copy the VARTHEME_SUBTHEME folder to your custom theme location.
  cp -r ${drupal_root}/themes/contrib/vartheme/VARTHEME_SUBTHEME ${theme_path}/${theme_name};

  # 2. Rename VARTHEME_SUBTHEME.starterkit.yml your_subtheme_name.info.yml
  mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.starterkit.yml ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ;
  mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ${theme_path}/${theme_name}/${theme_name}.info.yml ;

  # 3. Rename VARTHEME_SUBTHEME.libraries.yml your_subtheme_name.libraries.yml
  mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.libraries.yml ${theme_path}/${theme_name}/${theme_name}.libraries.yml ;

  # 4. Rename VARTHEME_SUBTHEME.theme your_subtheme_name.theme
  mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.theme ${theme_path}/${theme_name}/${theme_name}.theme ;

  # 5. Rename VARTHEME_SUBTHEME.settings.yml
  mv ${theme_path}/${theme_name}/config/install/VARTHEME_SUBTHEME.settings.yml ${theme_path}/${theme_name}/config/install/${theme_name}.settings.yml ;

  # 6. Rename VARTHEME_SUBTHEME.schema.yml
  mv ${theme_path}/${theme_name}/config/schema/VARTHEME_SUBTHEME.schema.yml ${theme_path}/${theme_name}/config/schema/${theme_name}.schema.yml ;

  # 7.1 Rename VARTHEME_SUBTHEME optional blocks.
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_branding.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_branding.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_breadcrumbs.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_breadcrumbs.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_content.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_content.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_copyright.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_copyright.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_footer.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_footer.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_help.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_help.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_actions.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_actions.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_tasks.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_tasks.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_main_menu.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_main_menu.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_messages.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_messages.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_page_title.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_page_title.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_socialauthlogin.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_socialauthlogin.yml
  mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_views_block__varbase_heroslider_media_varbase_heroslider_media.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_views_block__varbase_heroslider_media_varbase_heroslider_media.yml

  # 7.2 Rename the extentions of TWIG template files.
  # html.html.twig is very important and needed file for RTL websites.
  mv ${theme_path}/${theme_name}/templates/system/html.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/system/html.html.twig

  # Custom Better Login templates for edit, login, rest password, and register template files.
  mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig
  mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig
  mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig
  mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig
  mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig

  # 8.  Rename VARTHEME_SUBTHEME.base.css files.
  mv ${theme_path}/${theme_name}/css/base/VARTHEME_SUBTHEME.base.css ${theme_path}/${theme_name}/css/base/${theme_name}.base.css

  # 9.  Rename VARTHEME_SUBTHEME-rtl.base.css files.
  mv ${theme_path}/${theme_name}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css ${theme_path}/${theme_name}/css/rtl/base/${theme_name}-rtl.base.css

  # 10. Rename VARTHEME_SUBTHEME.base.less file.
  mv ${theme_path}/${theme_name}/less/base/VARTHEME_SUBTHEME.base.less ${theme_path}/${theme_name}/less/base/${theme_name}.base.less

  # 11.  Rename VARTHEME_SUBTHEME-rtl.base.less file.
  mv ${theme_path}/${theme_name}/less/rtl/base/VARTHEME_SUBTHEME-rtl.base.less ${theme_path}/${theme_name}/less/rtl/base/${theme_name}-rtl.base.less

  # 12. Replace all VARTHEME_SUBTHEME with the machine name of your theme.
  grep -rl 'VARTHEME_SUBTHEME' ${theme_path}/${theme_name} | xargs sed -i "s/VARTHEME_SUBTHEME/${theme_name}/g" ;

  # 13. Replace the name: 'Vartheme Sub-Theme (LESS)' to the name of your theme.
  grep -rl 'Vartheme Sub-Theme (LESS)' ${theme_path}/${theme_name} | xargs sed -i "s/Vartheme Sub-Theme (LESS)/${theme_name}/g" ;


  # 14. If we want to use the RTL (right to left) bootstrap.
  # 15.1 Delete the template folder bootstrap.
  rm -rf ${theme_path}/${theme_name}/bootstrap ;

  # 15.2 Download the bootstrap library. change the version as you need.
  wget -P ${theme_path}/${theme_name} https://github.com/twbs/bootstrap/archive/v${bootstrap_library_version}.tar.gz -vvv

  # 15.3 Extract the bootstrap library.
  mkdir ${theme_path}/${theme_name}/bootstrap
  tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap -vvv

  # 15.4 Delete the archived bootstrap library.
  rm ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz

  # 16. If we want to use the RTL (right to left) bootstrap.
  if [[ $direction == "rtl" || $direction == "RTL" ]]; then
    # 16.1. Delete the template folder bootstrap-rtl.
    rm -rf ${theme_path}/${theme_name}/bootstrap-rtl ;

    # 16.2. Download the bootstrap library. change the version as you need.
    wget -P ${theme_path}/${theme_name} https://github.com/morteza/bootstrap-rtl/archive/v${bootstrap_rtl_library_version}.tar.gz -vvv

    # 16.3. Extract the bootstrap library.
    mkdir ${theme_path}/${theme_name}/bootstrap-rtl
    tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap-rtl -vvv

    # 16.4. Delete the archived bootstrap library.
    rm ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz
  fi

  generated_datetime="$(date '+%Y/%m/%d - %H:%M:%S')";
  generated_log=" Generated by -- create-new-vartheme ${theme_name} ${direction} ${theme_path} -- on ${generated_datetime}";
  echo "${generated_log}"  >> ${theme_path}/${theme_name}/README.md;

  echo "---------------------------------------------------------------------------";
  echo "   The new Vartheme subtheme were created at \"${theme_path}/${theme_name} :)\" ";
  echo "---------------------------------------------------------------------------";
  exit 0;

else
  echo "---------------------------------------------------------------------------";
  echo "   The folder \"${theme_path}/${theme_name}\" is already in the site!";
  echo "---------------------------------------------------------------------------";
  exit 1;
fi

File

scripts/create-new-vartheme.sh
View source
  1. #!//bin/bash
  2. ################################################################################
  3. ## Create new vartheme subtheme.
  4. ################################################################################
  5. ##
  6. ## Quick tip on how to use this script command file.
  7. ##
  8. ## Create new Vartheme sub theme for a project.
  9. ## By Bash:
  10. ## -----------------------------------------------------------------------------
  11. ## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
  12. ## bash ./create-new-vartheme.sh "THEME_NAME" "ltr"
  13. ##------------------------------------------------------------------------------
  14. ##
  15. ## For right to left themes.
  16. ## By Bash:
  17. ## -----------------------------------------------------------------------------
  18. ## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
  19. ## bash ./create-new-vartheme.sh "THEME_NAME" "rtl"
  20. ## -----------------------------------------------------------------------------
  21. ##
  22. ## To create a new theme in the PROJECT_DIR_NAME/docroot/themes/custom
  23. ## By Bash:
  24. ## -----------------------------------------------------------------------------
  25. ## cd PROJECT_DIR_NAME/docroot/profiles/varbase/scripts
  26. ## bash ./create-new-vartheme.sh "THEME_NAME"
  27. ## -----------------------------------------------------------------------------
  28. ##
  29. ################################################################################
  30. # Basic yaml parser.
  31. parse_yaml() {
  32. local s='[[:space:]]*' w='[a-zA-Z0-9_]*' fs=$(echo @|tr @ '\034')
  33. sed -ne "s|^\($s\)\($w\)$s:$s\"\(.*\)\"$s\$|\1$fs\2$fs\3|p" \
  34. -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $1 |
  35. awk -F$fs '{
  36. indent = length($1)/2;
  37. vname[indent] = $2;
  38. for (i in vname) {if (i > indent) {delete vname[i]}}
  39. if (length($3) > 0) {
  40. vn=""; for (i=0; i
  41. printf("%s%s%s=\"%s\"\n", "",vn, $2, $3);
  42. }
  43. }'
  44. }
  45. current_path=$(pwd);
  46. drupal_root="$current_path";
  47. if [[ "${drupal_root: -1}" == "/" ]]; then
  48. drupal_root="${drupal_root::-1}";
  49. fi
  50. if [[ "${drupal_root: -24}" == "profiles/varbase/scripts" ]]; then
  51. drupal_root="${drupal_root::-24}";
  52. fi
  53. if [[ "${drupal_root: -16}" == "profiles/varbase" ]]; then
  54. drupal_root="${drupal_root::-16}";
  55. fi
  56. if [[ "${drupal_root: -8}" == "profiles" ]]; then
  57. drupal_root="${drupal_root::-8}";
  58. fi
  59. if [[ "${drupal_root: -1}" == "/" ]]; then
  60. drupal_root="${drupal_root::-1}";
  61. fi
  62. echo "Current path: $current_path";
  63. echo "Drupal root: $drupal_root";
  64. # Read scripts.settings.yml file
  65. eval $(parse_yaml $drupal_root/profiles/varbase/scripts/scripts.settings.yml);
  66. # Default theme name.
  67. theme_name=$default_theme_name;
  68. # Grape the theme name argument.
  69. if [ ! -z "$1" ]; then
  70. arg1="$1";
  71. if [[ $arg1 =~ ^[A-Za-z][A-Za-z0-9_]*$ ]]; then
  72. theme_name="$arg1";
  73. else
  74. echo "---------------------------------------------------------------------------";
  75. echo " Theme name is not a valid theme name! ";
  76. echo "---------------------------------------------------------------------------";
  77. exit 1;
  78. fi
  79. else
  80. echo "---------------------------------------------------------------------------";
  81. echo " Please add the name of your theme! ";
  82. echo "---------------------------------------------------------------------------";
  83. exit 1;
  84. fi
  85. # Default direction.
  86. direction=$default_direction;
  87. # Grape the direction argument. only if we have arg #2.
  88. if [ ! -z "$2" ]; then
  89. arg2="$2";
  90. if [[ "$arg2" == "rtl" || "$arg2" == "RTL" ]]; then
  91. direction=$arg2;
  92. elif [[ "$arg2" == "ltr" || "$arg2" == "LTR" ]]; then
  93. direction=$arg2;
  94. else
  95. echo "---------------------------------------------------------------------------";
  96. echo " Direction of language is not valid! ";
  97. echo " ltr - for (left to right) languages. ";
  98. echo " rtl - for (right to left) languages. ";
  99. echo "---------------------------------------------------------------------------";
  100. exit 1;
  101. fi
  102. fi
  103. # Default themes creation path.
  104. theme_path=$drupal_root/$default_themes_creation_path;
  105. mkdir -p ${theme_path};
  106. cp ${current_path}/README.md ${theme_path}/README.md
  107. # Create the new Vartheme subtheme if we do not have a folder with that name yet.
  108. if [[ ! -d "$theme_path/$theme_name" ]]; then
  109. # 1. Copy the VARTHEME_SUBTHEME folder to your custom theme location.
  110. cp -r ${drupal_root}/themes/contrib/vartheme/VARTHEME_SUBTHEME ${theme_path}/${theme_name};
  111. # 2. Rename VARTHEME_SUBTHEME.starterkit.yml your_subtheme_name.info.yml
  112. mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.starterkit.yml ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ;
  113. mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.info.yml ${theme_path}/${theme_name}/${theme_name}.info.yml ;
  114. # 3. Rename VARTHEME_SUBTHEME.libraries.yml your_subtheme_name.libraries.yml
  115. mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.libraries.yml ${theme_path}/${theme_name}/${theme_name}.libraries.yml ;
  116. # 4. Rename VARTHEME_SUBTHEME.theme your_subtheme_name.theme
  117. mv ${theme_path}/${theme_name}/VARTHEME_SUBTHEME.theme ${theme_path}/${theme_name}/${theme_name}.theme ;
  118. # 5. Rename VARTHEME_SUBTHEME.settings.yml
  119. mv ${theme_path}/${theme_name}/config/install/VARTHEME_SUBTHEME.settings.yml ${theme_path}/${theme_name}/config/install/${theme_name}.settings.yml ;
  120. # 6. Rename VARTHEME_SUBTHEME.schema.yml
  121. mv ${theme_path}/${theme_name}/config/schema/VARTHEME_SUBTHEME.schema.yml ${theme_path}/${theme_name}/config/schema/${theme_name}.schema.yml ;
  122. # 7.1 Rename VARTHEME_SUBTHEME optional blocks.
  123. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_branding.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_branding.yml
  124. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_breadcrumbs.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_breadcrumbs.yml
  125. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_content.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_content.yml
  126. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_copyright.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_copyright.yml
  127. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_footer.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_footer.yml
  128. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_help.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_help.yml
  129. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_actions.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_actions.yml
  130. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_local_tasks.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_local_tasks.yml
  131. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_main_menu.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_main_menu.yml
  132. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_messages.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_messages.yml
  133. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_page_title.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_page_title.yml
  134. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_socialauthlogin.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_socialauthlogin.yml
  135. mv ${theme_path}/${theme_name}/config/optional/block.block.VARTHEME_SUBTHEME_views_block__varbase_heroslider_media_varbase_heroslider_media.yml ${theme_path}/${theme_name}/config/optional/block.block.${theme_name}_views_block__varbase_heroslider_media_varbase_heroslider_media.yml
  136. # 7.2 Rename the extentions of TWIG template files.
  137. # html.html.twig is very important and needed file for RTL websites.
  138. mv ${theme_path}/${theme_name}/templates/system/html.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/system/html.html.twig
  139. # Custom Better Login templates for edit, login, rest password, and register template files.
  140. mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--edit.html.twig
  141. mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--login.html.twig
  142. mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--password.html.twig
  143. mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--register.html.twig
  144. mv ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig-VARTHEME_SUBTHEME ${theme_path}/${theme_name}/templates/betterlogin/page--user--reset.html.twig
  145. # 8. Rename VARTHEME_SUBTHEME.base.css files.
  146. mv ${theme_path}/${theme_name}/css/base/VARTHEME_SUBTHEME.base.css ${theme_path}/${theme_name}/css/base/${theme_name}.base.css
  147. # 9. Rename VARTHEME_SUBTHEME-rtl.base.css files.
  148. mv ${theme_path}/${theme_name}/css/rtl/base/VARTHEME_SUBTHEME-rtl.base.css ${theme_path}/${theme_name}/css/rtl/base/${theme_name}-rtl.base.css
  149. # 10. Rename VARTHEME_SUBTHEME.base.less file.
  150. mv ${theme_path}/${theme_name}/less/base/VARTHEME_SUBTHEME.base.less ${theme_path}/${theme_name}/less/base/${theme_name}.base.less
  151. # 11. Rename VARTHEME_SUBTHEME-rtl.base.less file.
  152. mv ${theme_path}/${theme_name}/less/rtl/base/VARTHEME_SUBTHEME-rtl.base.less ${theme_path}/${theme_name}/less/rtl/base/${theme_name}-rtl.base.less
  153. # 12. Replace all VARTHEME_SUBTHEME with the machine name of your theme.
  154. grep -rl 'VARTHEME_SUBTHEME' ${theme_path}/${theme_name} | xargs sed -i "s/VARTHEME_SUBTHEME/${theme_name}/g" ;
  155. # 13. Replace the name: 'Vartheme Sub-Theme (LESS)' to the name of your theme.
  156. grep -rl 'Vartheme Sub-Theme (LESS)' ${theme_path}/${theme_name} | xargs sed -i "s/Vartheme Sub-Theme (LESS)/${theme_name}/g" ;
  157. # 14. If we want to use the RTL (right to left) bootstrap.
  158. # 15.1 Delete the template folder bootstrap.
  159. rm -rf ${theme_path}/${theme_name}/bootstrap ;
  160. # 15.2 Download the bootstrap library. change the version as you need.
  161. wget -P ${theme_path}/${theme_name} https://github.com/twbs/bootstrap/archive/v${bootstrap_library_version}.tar.gz -vvv
  162. # 15.3 Extract the bootstrap library.
  163. mkdir ${theme_path}/${theme_name}/bootstrap
  164. tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap -vvv
  165. # 15.4 Delete the archived bootstrap library.
  166. rm ${theme_path}/${theme_name}/v${bootstrap_library_version}.tar.gz
  167. # 16. If we want to use the RTL (right to left) bootstrap.
  168. if [[ $direction == "rtl" || $direction == "RTL" ]]; then
  169. # 16.1. Delete the template folder bootstrap-rtl.
  170. rm -rf ${theme_path}/${theme_name}/bootstrap-rtl ;
  171. # 16.2. Download the bootstrap library. change the version as you need.
  172. wget -P ${theme_path}/${theme_name} https://github.com/morteza/bootstrap-rtl/archive/v${bootstrap_rtl_library_version}.tar.gz -vvv
  173. # 16.3. Extract the bootstrap library.
  174. mkdir ${theme_path}/${theme_name}/bootstrap-rtl
  175. tar -xzvf ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz --strip-components=1 -C ${theme_path}/${theme_name}/bootstrap-rtl -vvv
  176. # 16.4. Delete the archived bootstrap library.
  177. rm ${theme_path}/${theme_name}/v${bootstrap_rtl_library_version}.tar.gz
  178. fi
  179. generated_datetime="$(date '+%Y/%m/%d - %H:%M:%S')";
  180. generated_log=" Generated by -- create-new-vartheme ${theme_name} ${direction} ${theme_path} -- on ${generated_datetime}";
  181. echo "${generated_log}" >> ${theme_path}/${theme_name}/README.md;
  182. echo "---------------------------------------------------------------------------";
  183. echo " The new Vartheme subtheme were created at \"${theme_path}/${theme_name} :)\" ";
  184. echo "---------------------------------------------------------------------------";
  185. exit 0;
  186. else
  187. echo "---------------------------------------------------------------------------";
  188. echo " The folder \"${theme_path}/${theme_name}\" is already in the site!";
  189. echo "---------------------------------------------------------------------------";
  190. exit 1;
  191. fi