PNG  IHDR!@ PLTE>O`jqv 9.tEXtPage
assets.scm - metalympiada
git clone git://metalympiada.org/
Log | Files | README | LICENSE

assets.scm (4571B)


   1 (define-module (assets)
   2   #:export (text-logo logo style archive archive-problems archive-solutions
   3             problems rules-text stagit-sources))
   4 (use-modules (srfi srfi-1)
   5              (srfi srfi-9)
   6              (style)
   7              (sxml simple)
   8              (ice-9 textual-ports)
   9              (ice-9 ftw))
  10 
  11 (define-record-type <archive-round>
  12   (make-archive-round problems solutions)
  13   archive-round?
  14   (problems	archive-problems)
  15   (solutions	archive-solutions))
  16 
  17 (define text-logo "
  18     __  ___     __        __                      _   __      __
  19    /  |/  /__  / /_____  / /_  ______ ___  ____  (_)_/_/ ____/ /___
  20   / /|_/ / _ \\/ __/ __ `/ / / / / __ `__ \\/ __ \\/ / __ `/ __  / __ `/
  21  / /  / /  __/ /_/ /_/ / / /_/ / / / / / / /_/ / / /_/ / /_/ / /_/ /
  22 /_/  /_/\\___/\\__/\\__,_/_/\\__, /_/ /_/ /_/ ,___/_/\\__,_/\\__,_/\\__,_/ 
  23                         /____/         /_/
  24         OLYMPIÁDA O METALYMPIÁDE"
  25 )
  26 
  27 (define (list->css lst delimiter)
  28   (let ((to-string (lambda (v) (cond ((string? v) v)
  29                                      ((number? v) (number->string v))
  30                                      ((list? v) (list->css v delimiter)))))
  31         (first (car lst)))
  32        (if (symbol? first)
  33            (string-append (symbol->string first)
  34                           "("
  35                           (if (null? (cdr lst)) "" (list->css (cdr lst) ","))
  36                           ")")
  37            (fold (lambda (n so-far) (string-append so-far delimiter (to-string n)))
  38                  (to-string first)
  39                  (cdr lst)))))
  40 
  41 (define (prop->css prop so-far)
  42   (string-append so-far (symbol->string (car prop)) ":" (list->css (cdr prop) " ") ";"))
  43 
  44 (define (sexp->css style)
  45   (let* ((style-rule
  46            (lambda (source so-far)
  47                    (let* ((name (car source))
  48                           (rest (cdr source))
  49                           (first-name (caar rest))
  50                           (first-prop (cdar rest)))
  51                          (if (eq? name '@)
  52                              (string-append so-far "@" (symbol->string first-name)
  53                                             " " (list->css first-prop " ") "{"
  54                                             (sexp->css (cdr rest)) "}")
  55                              (if (eq? first-name ':)
  56                                  (string-append so-far (symbol->string name)
  57                                                 ":" (list->css first-prop " ") "{"
  58                                                 (fold prop->css "" (cdr rest)) "}")
  59                                  (string-append so-far (symbol->string name) "{" 
  60                                                 (fold prop->css "" rest) "}")))))))
  61         (fold style-rule "" style)))
  62                    
  63 (define style (sexp->css stylesheet))
  64 
  65 (define (logo-generator height ratio iterations)
  66   (let ((width (* height ratio)))
  67       `(svg (@ (class "logo") (aria-hidden "true")
  68                (viewBox ,(list->css `(0 0 ,width ,height) " ")))
  69             ,@(map (lambda (i) (let* ((r (expt ratio i))
  70                                       (w (* width r))
  71                                       (h (* height r))
  72                                       (x (/ (- width w) 2)))
  73                                      `(rect (@ (x ,x) (y ,x) (width ,w) (height ,h)))))
  74                            (iota iterations)))))
  75 
  76 (define logo (logo-generator 500 logo-ratio 11))
  77 
  78 (define (read-string file) (call-with-input-file file get-string-all))
  79 
  80 (define archive-dir "archive")
  81 
  82 (define (tild-split file) (string-split (read-string file) #\~))
  83 
  84 (define archive
  85   (let ((text-file (lambda (dir name)
  86                      (string-append archive-dir "/" dir "/" name))))
  87        (map (lambda (dir)
  88               (make-archive-round (tild-split (text-file dir "problems"))
  89                                   (tild-split (text-file dir "solutions"))))
  90             (scandir archive-dir (lambda (f) (not (string-every #\. f)))))))
  91 
  92 (define problems (tild-split "texts/problems"))
  93 
  94 (define rules-text (read-string "texts/rules"))
  95 
  96 (define stagit-dir ".stagit")
  97 
  98 (define stagit-sources (make-hash-table))
  99 
 100 (begin (if (not (file-exists? stagit-dir))
 101            (mkdir stagit-dir))
 102        (chdir stagit-dir)
 103        (system "../stagit ..")
 104        (chdir ".."))
 105 
 106 (ftw stagit-dir
 107      (lambda (name statinfo flag)
 108              (if (equal? flag 'regular)
 109                  (hash-set! stagit-sources
 110                             (substring name (+ (string-length stagit-dir) 1))
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