Commit 8171819d authored by Cherie Yang's avatar Cherie Yang

Add functions for including CSS files (basic, WIP)

parent 8980a330
......@@ -14,7 +14,7 @@
;; Location and list of styles
;; *STYLES* should be list of strings representing relative filenames.
;; @TO-DO: replace this with better css preprocessing.
(defparameter *STYLES-DIR* (asdf:system-relative-pathname :cl-site "content/css/"))
(defparameter *STYLES-DIR* (asdf:system-relative-pathname :cl-site "layout/css/"))
(defparameter *STYLES*
(list "main.css"))
......
......@@ -2,8 +2,8 @@
(in-package :cl-site)
; Makes pathname from prefix + page object
(defun make-path (prefix page)
(let ((path (cdr (assoc :content page))))
(defun make-path (prefix suffix &optional page)
(let ((path (if page (cdr (assoc :content suffix)) suffix)))
(if (pathnamep prefix)
(merge-pathnames path prefix)
(pathname (concatenate 'string
......
html, body {
margin: 0;
padding: 0;
height: 100%;
}
* { box-sizing: border-box; }
.header, .main {
width: 70%;
margin-left: auto;
margin-right: auto;
}
.header {
}
\ No newline at end of file
......@@ -2,12 +2,27 @@
<html>
<head>
<title>{{title}}</title>
{{#styles}}
<link href="{{location}}" rel="stylesheet" type="text/css">
{{/styles}}
</head>
<body>
<header>Site Title</header>
<header class="header">
</header>
<main class="main">
<aside class="sidebar">
Sidebar
</aside>
{{page-content}}
<section class="content">
{{page-content}}
</section>
</main>
</body>
</html>
......@@ -2,4 +2,6 @@
(in-package :cl-site)
(defun make-site ()
(process-pages))
\ No newline at end of file
(progn
(process-styles)
(process-pages)))
\ No newline at end of file
......@@ -2,7 +2,15 @@
(in-package :cl-site)
;; Copies/renders stylesheets + adds to global context
(defun process-styles () )
(defun process-styles ()
(let
((styles-list (mapcar
(lambda (s) (progn
(uiop:copy-file (make-path *STYLES-DIR* s)
(make-path *OUTPUT-DIR* s))
(cons :location s)))
*STYLES*)))
(push (cons :styles styles-list) *GLOBAL-CONTEXT*)))
;; Copies/renders static assets (imgs, etc)
(defun process-static () )
......@@ -11,15 +19,16 @@
;; process-pages : Copies/renders pages - called last
(defun render-page (page template-path)
(let*
((page-path (make-path *PAGES-DIR* page))
(output-path (make-path *OUTPUT-DIR* page))
((page-path (make-path *PAGES-DIR* page t))
(output-path (make-path *OUTPUT-DIR* page t))
(page-content (file-to-string page-path))
(page-context (remove-if (lambda (p) (find p *PRIVATE-KEYS*))
(push (cons :page-content page-content) page) :key 'car)))
(with-open-file (output-stream output-path :direction :output
:if-exists :supersede)
(mustache:render template-path page-context output-stream))))
(mustache:render template-path (append page-context *GLOBAL-CONTEXT*)
output-stream))))
(defun process-pages ()
(let
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment