From 21fc813a081bcbae7a6e5924d359ffa876b3bb78 Mon Sep 17 00:00:00 2001 From: casjay Date: Wed, 22 Oct 2025 16:15:54 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=97=83=EF=B8=8F=20Update=20codebase=20?= =?UTF-8?q?=F0=9F=97=83=EF=B8=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rootfs/root/docker/setup/06-post.sh --- rootfs/root/docker/setup/06-post.sh | 219 +++++++++++----------------- 1 file changed, 85 insertions(+), 134 deletions(-) diff --git a/rootfs/root/docker/setup/06-post.sh b/rootfs/root/docker/setup/06-post.sh index 8a57d86..82d8d11 100755 --- a/rootfs/root/docker/setup/06-post.sh +++ b/rootfs/root/docker/setup/06-post.sh @@ -26,141 +26,26 @@ set -o pipefail exitCode=0 LIST_INDEX_FILE="/usr/share/httpd/default/list.html" RAW_URL="https://raw.githubusercontent.com/alecmuffett/real-world-onion-sites/refs/heads/master/README.md" - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Predefined actions -md2html() { - # Emit a lightweight container; you can remove the outer
if you donโ€™t want it. - emit_open() { - cat <<'EOF' -
-EOF - } - emit_close() { - cat <<'EOF' -
-EOF +__build_onions_html() { + # temp file (POSIX-safe mktemp use) + tmp_md="$(mktemp 2>/dev/null || printf '/tmp/rwos.%s' "$$")" || { + printf '%s\n' "mktemp failed" >&2 + return 1 } + trap 'rm -f "$tmp_md"' 0 1 2 3 15 - # AWK Markdown -> HTML (body only). Designed to handle the READMEโ€™s structure. - awk_prog=' -BEGIN{ - in_code=0; in_ul=0; in_ol=0; in_blockquote=0; in_table=0; table_open=0; - last_nonblank=""; - FS=""; -} -function htmlesc(s){ gsub(/&/,"&",s); gsub(//,">",s); return s } + # 1) Fetch README (UTF-8) + if ! curl -fsSL "$RAW_URL" >"$tmp_md"; then + printf '%s\n' "curl failed to fetch README" >&2 + return 2 + fi -function linkify(s){ - # Images: ![alt](src) - s = gensub(/!\[([^[\]]+)\]\(([^) \t]+)\)/, "\"\\1\"", "g", s) - # Links: [text](url) - s = gensub(/\[([^[\]]+)\]\(([^) \t]+)\)/, "\\1<\\/a>", "g", s) - # Inline code - s = gensub(/`([^`]+)`/, "\\1<\\/code>", "g", s) - # Bold / italic (simple) - s = gensub(/\*\*([^*]+)\*\*/, "\\1<\\/strong>", "g", s) - s = gensub(/\*([^*]+)\*/, "\\1<\\/em>", "g", s) - # Autolink http(s) - s = gensub(/(https?:\/\/[A-Za-z0-9._~:\/?#\\[\\]@!$&'\''()*+,;=%-]+)/, "\\1<\\/a>", "g", s) - # Bare .onion (with optional path/query) - s = gensub(/([A-Za-z2-7]{16,56}\\.onion([A-Za-z0-9._~:\/?#\\[\\]@!$&'\''()*+,;=%-]*)?)/, "\\1<\\/a>", "g", s) - return s -} - -function flush_p(){ if(pbuf!=""){ printf("

%s

\n", pbuf); pbuf="" } } -function close_lists(){ if(in_ul){ print ""; in_ul=0 } if(in_ol){ print ""; in_ol=0 } } -function close_blockquote(){ if(in_blockquote){ print ""; in_blockquote=0 } } - -function table_close_fn(){ if(table_open){ print ""; table_open=0 } in_table=0 } -function split_cells(line, n,i){ - sub(/^ *\|/,"",line); sub(/\| *$/,"",line); - n=split(line, C, /\|/); - for(i=1;i<=n;i++){ gsub(/^ +| +$/,"",C[i]) } - return n -} - -{ - raw=$0 - if(raw ~ /[^[:space:]]/){ last_nonblank=raw } - - # Fenced code - if(!in_code && raw ~ /^```/){ flush_p(); close_lists(); close_blockquote(); print "
"; in_code=1; next }
-  if(in_code){
-    if(raw ~ /^```/){ print "
"; in_code=0; next } - print htmlesc(raw); next - } - - # Blank line - if(raw ~ /^[[:space:]]*$/){ - if(in_table==0){ flush_p(); close_lists(); close_blockquote() } - next - } - - # HR - if(raw ~ /^ *(-{3,}|\*{3,}|_{3,}) *$/){ flush_p(); close_lists(); close_blockquote(); print "
"; next } - - # Table separator row -> open table with the previous header line - if(raw ~ /^ *\|? *:?-{3,}:? *(?:\| *:?-{3,}:? *)+\|? *$/){ - hdr=last_nonblank - split_cells(hdr); print ""; - for(i=1;i in C;i++){ printf("", linkify(htmlesc(C[i]))) } - print ""; in_table=1; table_open=1; next - } - if(in_table && raw ~ /\|/){ - split_cells(raw); printf(""); - for(i=1;i in C;i++){ printf("", linkify(htmlesc(C[i]))) } - print ""; next - } - if(in_table){ table_close_fn() } - - # Blockquotes - if(raw ~ /^ *> */){ - flush_p(); close_lists(); - if(!in_blockquote){ print "
"; in_blockquote=1 } - gsub(/^ *> */,"",raw); print "

" linkify(htmlesc(raw)) "

"; next - } else if(in_blockquote){ close_blockquote() } - - # Headings - if(raw ~ /^#{1,6} /){ - flush_p(); close_lists(); close_blockquote(); - m=match(raw,/^#{1,6}/); level=RLENGTH; text=substr(raw, level+2); - printf("%s\n", level, linkify(htmlesc(text)), level); next - } - - # Lists - if(raw ~ /^ *([-*]) +/){ - flush_p(); if(!in_ul){ print "
%s
%s