defs.rkt 1.78 KB
Newer Older
Robert Ricci's avatar
Robert Ricci committed
1
#lang racket/base
Robert Ricci's avatar
Robert Ricci committed
2
(require scribble/base)
3 4 5
(require scribble/decode)
(require racket/class)
(require racket/draw)
6 7
(require racket/system)
(require racket/port)
Robert Ricci's avatar
Robert Ricci committed
8 9 10

(provide (all-defined-out))

11 12
(define apt-base-url "https://www.aptlab.net/")

13 14 15 16
; We want the 'version' to be the date of the most recent commit
(define apt-version
  (with-output-to-string
    (lambda () (system "git show -s --date=short --format='%cd (%h)' HEAD"))))
17

18 19
; Arbitrary width that works reasonably well with the manual class's main
; column width
20 21 22 23 24 25
(define screenshot-width 650)

(define apturl
  (case-lambda
    [() apt-base-url]
    [(page) (string-append apt-base-url page)]))
Robert Ricci's avatar
Robert Ricci committed
26

27
(define (TODO . what)
28
  (bold "TODO: " (decode-content what)))
29 30 31 32 33 34 35 36

(define nodetype
  (lambda (typename howmany . properties)
          (tabular #:style 'boxed #:sep (hspace 3)
                   (cons
                     (list (bold typename)
                           (string-append (number->string howmany) " nodes"))
                     properties))))
37

38 39 40 41 42 43 44 45
(define (screenshot path)
  (let* ([fullpath (string-append "screenshots/" path)]
         [b (make-object bitmap% fullpath)]
         [width (send b get-width)]
         [scale-factor (/ screenshot-width width)])
    (list (image #:scale scale-factor fullpath fullpath) (linebreak))))

(define (instructionstep step #:screenshot [screenshot-path #f] . body)
46 47
  (item (bold (decode-content (list step)))
        (linebreak)
48 49
        (if screenshot-path
          (screenshot  screenshot-path)
50 51
          (void))
        (decode-content body)))
52 53 54

(define (under-construction)
  (bold "This section is under construction"))
55 56 57 58 59

(define (future-work tag)
  (margin-note "There are planned features relating to this section: see \""
               (secref tag)
               "\" for more details."))
60 61 62

(define (ssh)
  (tt "ssh"))