diff --git a/globals.lisp b/globals.lisp index 1ac885be18c7aab5fbb37e971960acd36c6faeb8..54b7d6c9a4817fe413bef41e68f0d08666bdfb6a 100644 --- a/globals.lisp +++ b/globals.lisp @@ -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")) diff --git a/helpers.lisp b/helpers.lisp index a7289df46eb8e3154d3fd719b0583d3979753122..044727a5576403450ca6de0f6318c5ee7ed9b8bf 100644 --- a/helpers.lisp +++ b/helpers.lisp @@ -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 diff --git a/layout/css/main.css b/layout/css/main.css new file mode 100644 index 0000000000000000000000000000000000000000..c6b3413b00f938b32556263a79fe16604c102344 --- /dev/null +++ b/layout/css/main.css @@ -0,0 +1,16 @@ +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 diff --git a/layout/templates/primary.html b/layout/templates/primary.html index bbe293c3c2a189aeb7913a18236ffa598a3bd1e9..bb30d11704ea7fca4007b6bd95116c6b292e860b 100644 --- a/layout/templates/primary.html +++ b/layout/templates/primary.html @@ -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> diff --git a/main.lisp b/main.lisp index 964877fdc290830b7a0a4740071a4a3a6c39995e..2a6d4a970a5ee5f150ec4141af0f354aa3e9f3d8 100644 --- a/main.lisp +++ b/main.lisp @@ -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 diff --git a/process.lisp b/process.lisp index 670c24be3176ee5c644dad4a704a292c14ab575d..6aed170df3f885918d462a6e0770cafd9cf46559 100644 --- a/process.lisp +++ b/process.lisp @@ -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