From 1d6e6e629ee5664a3ba592e2bd48aef5022536bc Mon Sep 17 00:00:00 2001 From: George Cushen Date: Wed, 20 Feb 2019 17:55:45 +0000 Subject: [PATCH] add scripts --- scripts/init_kickstart.sh | 36 +++++++++++++++++++++++++++ update_academic.sh | 51 ++++++++++++++++++++++++++++++++++++--- view.sh | 3 +++ 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 scripts/init_kickstart.sh create mode 100755 view.sh diff --git a/scripts/init_kickstart.sh b/scripts/init_kickstart.sh new file mode 100644 index 0000000..a132021 --- /dev/null +++ b/scripts/init_kickstart.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +# WARNING: this will reset the project to the Kickstart template! + +# Update Academic +source ../update_academic.sh + +################################################# + +# Install demo config +rsync -av ../themes/academic/exampleSite/config/ ../config/ + +# Install demo user +rsync -av ../themes/academic/exampleSite/content/author/ ../content/author/ + +# Install an example instance of each widget type +rsync -av --exclude gallery/ ../themes/academic/exampleSite/content/home/ ../content/home/ + +# Install indices +rsync -av ../themes/academic/exampleSite/content/post/_index.md ../content/post/_index.md +rsync -av ../themes/academic/exampleSite/content/publication/_index.md ../content/publication/_index.md +rsync -av ../themes/academic/exampleSite/content/talk/_index.md ../content/talk/_index.md + +# Skip static dir - do not import the demo's media library + +################################################# + +# Post processing + +# Deactivate Hero +sed -i '' -e 's/active = true/active = false/' ../content/home/hero.md + +# Manual Steps: +# - content/home/project.md: Re-comment out project widget filters +# - content/home/teaching.md: Re-modify title and content & set gradient background instead of image +# - content/home/hero.md: Clear `hero_media` value & set gradient background instead of image diff --git a/update_academic.sh b/update_academic.sh index 8e33b7c..a59f5b6 100644 --- a/update_academic.sh +++ b/update_academic.sh @@ -1,10 +1,55 @@ #!/usr/bin/env bash -# Display available updates to Academic. +# Source Themes Academic: Theme updater +# Checks for available updates and then asks to install any updates. +# https://sourcethemes.com/academic/ +# +# Command: bash ./update_academic.sh + +# Check for prerequisites. +if [ ! -d .git ]; then + echo "ERROR: This tool is for Git repositories only." + exit 1; +fi + +# Function to update Academic +function install_update () { + # Apply any updates + git submodule update --remote --merge + + # - Update Netlify.toml with required Hugo version + if [ -f ./netlify.toml ]; then + version=$(sed -n 's/^min_version = //p' themes/academic/theme.toml) + sed -i '' -e "s/HUGO_VERSION = .*/HUGO_VERSION = $version/g" ./netlify.toml + fi + + echo + echo "View the release notes at: https://sourcethemes.com/academic/updates" + echo "If there are breaking changes, the config and/or front matter of content" \ + "may need upgrading by following the steps in the release notes." +} + +# Display currently installed version (although could be between versions if updated to master rather than tag) +version=$(sed -n 's/^version = "//p' themes/academic/data/academic.toml) +echo -e "Source Themes Academic v$version\n" + +# Display available updates +echo -e "Checking for updates...\n" cd themes/academic git fetch git log --pretty=oneline --abbrev-commit --decorate HEAD..origin/master cd ../../ -# Update Academic. -git submodule update --remote --merge +title="Do you wish to install the above updates?" +prompt="Choose an option and press Enter:" +options=("Yes" "No") + +echo "$title" +PS3="$prompt " +select opt in "${options[@]}"; do + case $opt in + Yes ) install_update; break;; + No ) break;; + * ) break;; + esac +done diff --git a/view.sh b/view.sh new file mode 100755 index 0000000..0757f08 --- /dev/null +++ b/view.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +hugo --i18n-warnings server