blogue-post.ss
(module blogue-post mzscheme
  (require (lib "time.ss" "srfi" "19")
           (lib "struct.ss"))
  
  (provide (all-defined))
  ; Post structure
  (define-struct Post (Id Title Content Date Category FXexpr))
  
  (define (Post-add-Category p c)
    (copy-struct Post p
                 [Post-Category (cons c (Post-Category p))]))
  (define (Post-Date-tm p)
    (string->date (Post-Date p) "~Y-~m-~dT~H:~M:~S~z"))
  (define (update-Post-Date-tm p n)
    (copy-struct Post p
                 [Post-Date (date->string n "~Y-~m-~dT~H:~M:~S~z")]))
  (define (Post-Date/3339 p)
    (let ([d (Post-Date p)])
      (format "~a:~a"
              (substring d 0 (- (string-length d) 2))
              (substring d (- (string-length d) 2)))))
  
  (define (Post-PageTitle p)
    (append (list (date->string (Post-Date-tm p)
                                "~B ~d, ~Y: "))
            (Post-Title p)))
  
  (define (Post-Id/Date p)
    (date->string (Post-Date-tm p) "~Y/~m/~d/~H~M~S"))
  
  (define (Post-Permapath p)
    (regexp-replace "Post" (Post-Id p) "Archives"))
  
  (define (new-Post title content date category)
    (make-Post (date->string date "/Post/~Y/~m/~d/~H~M~S")
               title content 
               (date->string date "~Y-~m-~dT~H:~M:~S~z")
               category
               'error)))