#!/bin/sh set -euo pipefail export MM_SERVER=zeus.mattermost.gent mattermost_name="Zeus Mattermost" team_name="zeus" dir="$(dirname "$0")" out="$dir/dist/channels/index.html" mkdir -p "$(dirname "$out")" cp go_to_channel.png dist/ cp main.css dist/ custom_emoji_file="$(mktemp --tmpdir custom_emoji.XXXXXXXXXX.json)" mmcli listcustomemoji | jq -s > "$custom_emoji_file" jqo() { json="$1" shift 1 printf '%s' "$json" | jq -cr "$@" || { printf 'jq errored performing %s on this input: %s\n' "$*" "$json" >&2; } } htmlescape() { sed 's/&/\&/g; s/\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g' } emoji() { env --chdir "$dir" \ python3 "$dir/emoji.py" "$custom_emoji_file" } markdown() { htmlescape | \ { pandoc --from=markdown+autolink_bare_uris+emoji --to=html || printf "Markdown conversion failed\n" >&2; } | \ sed -E ' s|<(h[0-6])[^>]*>|