#!/usr/bin/env bash # Use this script to automate building the website. You'll need a fresh copy of the repository and a fresh fakezod booted with the static-site-dev branch of Arvo. The site is built in two steps because Urbit typically runs out of memory before finishing a full build. One fakezod is usually good for only a single build. # Strip trailing slashes on input parameters site=${1%/} ship=${2%/} # Copy static_site to ship copy_static_site () { echo -e "Copying source files from $site to $ship" rm -rf $ship/home/web cp -r $site/static-site $ship/home/web cp $site/static-site/index.hoon $ship/home/web.hoon rm -rf $ship/home/ren/partials cp -r $site/partials $ship/home/ren/partials cp $site/urb.hoon $ship/home/ren } # Print instructions if both parameters aren't provided if [[ $# -lt 2 ]] ; then printf 'This command needs two arguments:\n(1) the path to your urbit.org repository\n(2) the path to your pier\n' exit 0 fi # Print instructions read -n1 -s -r -p $'Boot your fake ~zod and run |mount %, then press any key to continue\n' # Create dist folder dist="dist-$(date -u '+%Y.%-m.%-d...%H.%M.%S')" mkdir $dist # Render Posts copy_static_site $site $ship rm -rf $ship/home/web/docs read -n1 -s -r -p $'Wait for sync, then run |static in your urbit, wait for it to finish, then press any key to continue\n' # Copy results of first render (posts) to dist folder echo -e "Copying posts from $site to $ship" cp -r $ship/.urb/put/web/* $dist # Render docs copy_static_site $site $ship rm -rf $ship/home/web/posts read -n1 -s -r -p $'Wait for sync, then run |static in your urbit again, wait for it to finish, then press any key to continue\n' # Copy results of second render (docs) to distj folder cp -rn $ship/.urb/put/web/* $dist # cp -n prevents overwriting exist folders # Remove unecessary files rm -rf $dist/posts/update rm -rf $dist/index rm -rf $dist/js/* # Copy JavaScript cp -r $site/static-site/js $dist echo -e "Find your website in $dist"