summaryrefslogtreecommitdiff
path: root/tools/copland/scripts/create-demo.sh
diff options
context:
space:
mode:
authorcashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
committercashmere <cashmere@autistici.org>2026-09-04 09:05:24 +0200
commit4f49b16079b27d7ce633619e4cddfdf2bffbc952 (patch)
treec296c1e7f3c3e2f6859c6d3a1b1b208779b89679 /tools/copland/scripts/create-demo.sh
downloadrelic-4f49b16079b27d7ce633619e4cddfdf2bffbc952.tar.gz
initial commitHEADmaster
Diffstat (limited to 'tools/copland/scripts/create-demo.sh')
-rwxr-xr-xtools/copland/scripts/create-demo.sh113
1 files changed, 113 insertions, 0 deletions
diff --git a/tools/copland/scripts/create-demo.sh b/tools/copland/scripts/create-demo.sh
new file mode 100755
index 0000000..7027e48
--- /dev/null
+++ b/tools/copland/scripts/create-demo.sh
@@ -0,0 +1,113 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+root_dir=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
+source "$root_dir/scripts/fossil-env.sh"
+
+if [[ $# -ne 1 ]]; then
+ printf 'Usage: %s TARGET_DIRECTORY\n' "$0" >&2
+ exit 2
+fi
+
+target_dir=$1
+mkdir -p "$target_dir/repositories" "$target_dir/checkouts"
+
+create_repository() {
+ local slug=$1
+ local title=$2
+ local repository="$target_dir/repositories/$slug.fossil"
+ local checkout="$target_dir/checkouts/$slug"
+
+ local is_new=0
+ if [[ ! -f "$repository" ]]; then
+ is_new=1
+ "$FOSSIL" init \
+ --admin-user copland \
+ --date-override 2024-01-01T12:00:00Z \
+ --project-name "$title" \
+ "$repository" >/dev/null
+ fi
+ "$FOSSIL" user default copland -R "$repository"
+ mkdir -p "$checkout"
+ if [[ ! -f "$checkout/.fslckout" && ! -f "$checkout/_FOSSIL_" ]]; then
+ (
+ cd /tmp
+ "$FOSSIL" open --nested --workdir "$checkout" "$repository" >/dev/null
+ )
+ fi
+ (
+ cd "$checkout"
+ "$FOSSIL" user default copland
+ if [[ "$is_new" -eq 1 ]]; then
+ mkdir -p src
+ printf '#+title: %s\n\nA small repository used to preview the Copland Fossil skin.\n\n* Usage\n\nRun the example from a C compiler.\n' "$title" > README.org
+ printf '#include <stdio.h>\n\nint main(void) {\n puts("hello from %s");\n return 0;\n}\n' "$slug" > src/main.c
+ fi
+ if [[ ! -f docs/org-support.org ]]; then
+ mkdir -p docs
+ printf '%s\n' \
+ '#+title: Native Org preview' \
+ '#+author: Copland' \
+ '#+date: 2026-08-21' \
+ '#+options: toc:2' \
+ '' \
+ '* Overview' \
+ '' \
+ 'This public fixture demonstrates *bold*, /italic/, _underlined_,' \
+ '+struck+, ~code~, and =verbatim= text.' \
+ '' \
+ '- Rendered by Fossil' \
+ ' 1. Nested ordered item' \
+ '- [[file:../README.org][Back to the README]]' \
+ '' \
+ '* Data' \
+ '' \
+ '| Format | Native |' \
+ '|--------+--------|' \
+ '| Org | yes |' \
+ '' \
+ '#+begin_src nix' \
+ '{ pkgs ? import <nixpkgs> {} }: pkgs.hello' \
+ '#+end_src' \
+ '' \
+ '#+begin_example' \
+ '<script>alert("escaped")</script>' \
+ '#+end_example' \
+ '' \
+ '** Details' \
+ '' \
+ 'Jump [[*Overview][back to the overview]].' > docs/org-support.org
+ fi
+ "$FOSSIL" addremove >/dev/null
+ if [[ -n $("$FOSSIL" changes) ]]; then
+ "$FOSSIL" commit --no-warnings \
+ --date-override 2024-01-03T12:00:00Z \
+ --user-override copland \
+ -m "Add Org documentation fixture"
+ fi
+ if [[ "$is_new" -eq 1 ]]; then
+ "$FOSSIL" tag add release-0.1 current
+ fi
+ )
+
+ local wiki_fixture="$target_dir/$slug-org-wiki.org"
+ printf '%s\n' \
+ '#+TITLE: This title is intentionally suppressed' \
+ '#+AUTHOR: Copland' \
+ '#+OPTIONS: toc:2' \
+ '' \
+ '* Overview' \
+ '' \
+ 'Open [[wiki:Deployment Guide][the deployment guide]] or the' \
+ '[[file:docs/org-support.org][repository documentation]].' \
+ '' \
+ '** Details' \
+ '' \
+ 'Return [[*Overview][to the overview]].' >"$wiki_fixture"
+ if ! "$FOSSIL" wiki list -R "$repository" | grep -Fxq 'Org Wiki'; then
+ "$FOSSIL" wiki create 'Org Wiki' "$wiki_fixture" -R "$repository" >/dev/null
+ fi
+}
+
+create_repository alpha "Alpha"
+create_repository beta "Beta"