clone

a personal forge on plain git: static pages, stacked-diff reviews, signed local ci, repo sites and releases

main
forge / test / scenarios / diagram-svg.sh
diagram-svg.sh 1.7K
1# A ```mermaid fence in markdown is drawn at build time: the page has the2# diagram as inline SVG with its labels as text, and no script draws it.3# One wider than a phone has a second drawing, laid out for one, after it.4. "$(dirname "$0")/../lib.sh"5user dami6repo dami/greet7clone dami dami/greet "$T/w/d"8cat >"$T/w/d/README.md" <<'EOF'9# greet1011```mermaid12flowchart LR13 push[git push] --> pre{pre-receive} -->|ok| post[post-receive] --> build[forge build] --> pages[pages]14```1516Pushes become pages.1718```mermaid19flowchart LR20 a --> b21```22EOF23at "$T/w/d" commit "first" greet.sh24push_as dami "$T/w/d" origin main25build26p=$FORGE_WWW/dami/greet/index.html27has "$p" '<figure class="diagram"><svg xmlns="http://www\.w3\.org/2000/svg" class="pele pele-flowchart" viewBox="0 0 [0-9.]+ [0-9.]+"'28has "$p" '<text class="pele-label"[^>]*>git push</text>'29has "$p" '>post-receive</text>'30# Coloured by the stylesheet's --pele-* variables, not colours of its own.31has "$p" 'style="max-width:100%;height:auto;--_bg:var\(--pele-bg,'32has "$FORGE_WWW/assets/$(cd "$FORGE_WWW/assets" && ls style.*.css)" '--pele-fg: var\(--fg\)'33# The wide one drawn twice, the small one once.34eq "$(grep '<figure class="diagram">' "$p" | awk -F '<svg xmlns' '{ print NF - 1 }' | tr '\n' ' ')" '2 1 '35# A link preview's text skips the labels.36has "$p" '<meta property="og:description" content="greet Pushes become pages\.">'37# The scripts are the ones every page has; none is for diagrams.38eq "$(grep -o '<script[^>]*>' "$p" | sed -E 's/\.[A-Za-z0-9_-]{10}\.js//')" "$(grep -o '<script[^>]*>' "$FORGE_WWW/dami/greet/log/main/index.html" | sed -E 's/\.[A-Za-z0-9_-]{10}\.js//')"39lacks "$p" 'mermaid'40eq "$(ls "$FORGE_WWW/assets" | grep -ci -e mermaid -e pele)" 0