#!/usr/bin/env bash

die()
{
  echo >&2 "!!! ERROR: $*"
  exit 1
}

cd "$(dirname "$0")"
rm -f small.zim
zimwriterfs -w main.html \
            -n "Test" \
            -I favicon.png \
            -l eng \
            -t "Test ZIM file" \
            -d "Description" \
            -L "Long Description" \
            -c "Creator" \
            -p "Publisher" \
            --tags "_category:Category" \
            small_zimfile_data \
            small.zim \
&& echo 'small.zim was successfully created' \
|| die 'Failed to create small.zim'

printf "BEGINZIM" > small.zim.embedded \
&& cat small.zim >> small.zim.embedded \
&& printf "ENDZIM" >> small.zim.embedded \
&& echo 'small.zim.embedded was successfully created' \
|| die 'Failed to create small.zim.embedded'
