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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