#!/bin/bash

## Copyright (C) 2025 - 2025 ENCRYPTED SUPPORT LLC <adrelanos@whonix.org>
## See the file COPYING for copying conditions.

set -o errexit
set -o nounset
set -o errtrace
set -o pipefail

# shellcheck source=../share/mediawiki-shell/common
source /usr/share/mediawiki-shell/common

log info "START"

usage() {
  printf '%s\n' "Usage: ${0##*/} WIKI
Example:
  ${0##*/} https://www.kicksecure.com/w" >&2
  exit 1
}

if [[ -z "${1-}" || "${1-}" =~ (-h|--help) ]]; then
  usage
fi

WIKI_URL="$1"

# shellcheck source=../share/mediawiki-shell/wiki-config
source /usr/share/mediawiki-shell/wiki-config

log info "TMPFOLDER: $TMPFOLDER"
log info "WIKI_URL : $WIKI_URL"
log info "WIKI_API : $WIKI_API"

mw-process-all-pages "${WIKI_URL}" 'mw-patch-modify-wiki-page' "$TMPFOLDER"
