Changeset 29166 in project


Ignore:
Timestamp:
06/25/13 00:32:43 (8 years ago)
Author:
Moritz Heidkamp
Message:

hyde: Add template facility to hyde new (thanks to Alexander Shendi for the patch)

Location:
release/4/hyde/trunk
Files:
2 edited

Legend:

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

    r27179 r29166  
    1818    Initializes a site in the current directory.
    1919
    20 hyde new <page-type> [<title> ...]
    21     Creates a new page with the given page type and title. The page's
    22     filename will be inferred from the given title by downcasing it and
    23     replacing spaces with dashes.
     20hyde new [<template>]
     21    Creates a new page from the template. The page's filename
     22    and extension will be inferred from the title given in the template
     23    by downcasing it and replacing spaces with dashes.
    2424
    2525hyde serve
     
    5252  (("init")
    5353   (initialize-site))
    54   (("new" ext . title)
     54  (("new" template-file)
    5555   (load-hyde-file)
    56    (generate-page ext title))
     56   (generate-page template-file))
    5757  (("serve")
    5858   (load-hyde-file)
  • release/4/hyde/trunk/hyde.scm

    r28611 r29166  
    215215    (string-trim-both path #\-)))
    216216
    217 (define (generate-page ext title)
    218   (let* ((title (string-intersperse title))
    219          (path (pathify title))
    220          (path (make-pathname (source-dir) path ext)))
    221     (with-output-to-file path (cut write `((title . ,title))))
     217(define (generate-page template-file)
     218  (let* ((new-template (with-input-from-file template-file
     219                         (lambda ()
     220                            (eval (read)))))
     221         (title (assq 'title new-template))
     222         (title (if title (cdr title) "Default Title"))
     223         (ext (assq 'ext new-template))
     224         (ext (if ext (cdr ext) ".wiki"))
     225         (res (assq 'source-dir new-template))
     226         (path (if res
     227                   (make-pathname (source-dir) (cdr res))
     228                   (source-dir)))
     229         (path (make-pathname path (pathify title) ext)))
     230    (with-output-to-file path (cut write new-template))
    222231    (print path)))
    223232
Note: See TracChangeset for help on using the changeset viewer.