namespaces added and documentation

This commit is contained in:
2026-08-15 15:01:50 +02:00
parent b9e081b13d
commit 8997f7f94a
20 changed files with 696 additions and 158 deletions
+12 -2
View File
@@ -1,5 +1,9 @@
#lang racket/base
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Tracking current and historical references to uploaded files.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(require db
racket/string)
@@ -14,7 +18,7 @@
(define (attachment-rows db)
(query-rows db
#<<SQL
SELECT a.id, p.slug, a.stored_name
SELECT a.id, p.slug, a.stored_name, p.namespace
FROM attachments a
JOIN pages p ON p.id = a.page_id
ORDER BY a.id
@@ -29,7 +33,13 @@ SQL
(define attachment-id (vector-ref row 0))
(define slug (vector-ref row 1))
(define stored-name (vector-ref row 2))
(when (string-contains? markdown (attachment-url slug stored-name))
(define namespace (vector-ref row 3))
(define reference (if (string=? namespace "") slug (string-append namespace ":" slug)))
(define current-url (attachment-url reference stored-name))
(define legacy-url (attachment-url slug stored-name))
(when (or (string-contains? markdown current-url)
(and (not (string=? namespace ""))
(string-contains? markdown legacy-url)))
(query-exec db
#<<SQL
INSERT INTO attachment_references