defs.rkt 1.22 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)
Robert Ricci's avatar
Robert Ricci committed
6 7 8

(provide (all-defined-out))

9 10
(define apt-base-url "https://www.aptlab.net/")

11 12
(define apt-version "1.1")

13 14 15 16 17 18
(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
19

20
(define (TODO . what)
21
  (bold "TODO: " (decode-content what)))
22 23 24 25 26 27 28 29

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

31 32 33 34 35 36 37 38
(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)
39 40
  (item (bold (decode-content (list step)))
        (linebreak)
41 42
        (if screenshot-path
          (screenshot  screenshot-path)
43 44
          (void))
        (decode-content body)))
45