Changeset 18137 in project


Ignore:
Timestamp:
05/22/10 00:51:51 (9 years ago)
Author:
Moritz Heidkamp
Message:

add commands "hyde new" for creating new pages and "hyde serve" to serve a site through spiffy with auto-compilation on each request

Location:
release/4/hyde
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • release/4/hyde/hyde-cmd.scm

    r18132 r18137  
    55(match (command-line-arguments)
    66  (("init") (initialize-site))
    7   (... (load-hyde-file)
    8        (compile-pages)))
     7  (("new" ext . args) (load-hyde-file) (generate-page ext args))
     8  (("serve") (load-hyde-file) (serve))
     9  (() (load-hyde-file) (compile-pages)))
  • release/4/hyde/hyde.scm

    r18133 r18137  
    33(load-hyde-file
    44 initialize-site
     5 generate-page
     6 serve
    57 source-dir
    68 output-dir
     
    1517 compile-pages)
    1618
    17 (import chicken scheme files data-structures extras srfi-1 ports)
     19(import chicken scheme files data-structures extras srfi-1 ports srfi-13)
    1820(require-extension regex)
    1921(import irregex)
     
    2527     sxml-fu
    2628     sxml-shortcuts
     29     doctype
    2730     matchable
    2831     scss
    29      scss-plus)
     32     scss-plus
     33     spiffy)
    3034
    3135
     
    4852(define sxml-conversion-rules
    4953  `((inject *preorder* . ,(project 1))
     54    ,@doctype-rules
    5055    ,@universal-conversion-rules))
    5156
     
    7782  (print "creating hyde.scm")
    7883  (with-output-to-file "hyde.scm" (cut write '(use hyde))))
     84
     85(define (generate-page ext title)
     86  (let* ((title (string-intersperse title))
     87         (path  (string-downcase title))
     88         (path  (irregex-replace/all '(or (submatch (+ space)) (submatch (+ (~ alpha)))) path "-" ""))
     89         (path  (string-trim-both path #\-))
     90         (path  (make-pathname (source-dir) path ext)))
     91    (with-output-to-file path (cut write `((title . ,title))))
     92    (print path)))
     93
     94(define (serve)
     95  (root-path (output-dir))
     96  (vhost-map `((".*" . ,(lambda (continue)
     97                          (compile-pages)
     98                          (newline)
     99                          (continue)))))
     100
     101  (print (format "spiffy serving hyde on port ~A" (server-port)))
     102  (start-server))
    79103
    80104(define (cmd name . args)
Note: See TracChangeset for help on using the changeset viewer.