helpers.lisp 604 Bytes
Newer Older
Cherie Yang's avatar
Cherie Yang committed
1 2 3 4
;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10 -*-
(in-package :cl-site)

; Makes pathname from prefix + page object
5 6
(defun make-path (prefix suffix &optional page)
  (let ((path (if page (cdr (assoc :content suffix)) suffix)))
Cherie Yang's avatar
Cherie Yang committed
7 8 9 10 11 12 13 14 15 16
    (if (pathnamep prefix)
        (merge-pathnames path prefix)
        (pathname (concatenate 'string 
                               prefix path)))))

; Slurps file from a string
(defun file-to-string (filepath)
  (with-open-file (stream filepath)
    (let ((data (make-string (file-length stream))))
      (read-sequence data stream)
Cherie Yang's avatar
Cherie Yang committed
17
      data)))