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

4 5
(defparameter *LAYOUT-DIR* (asdf:system-relative-pathname :cl-site "layout/templates/")
  "Pathname for location of template files.")
Cherie Yang's avatar
Cherie Yang committed
6

7 8 9
(defparameter *OUTPUT-DIR* (asdf:system-relative-pathname :cl-site "output/")
  "Pathname where the generated output should be written to.")

10
;; @TO-DO: store layout name as global, generate js/css pathnames from it. 
Cherie Yang's avatar
Cherie Yang committed
11
;; (More template-related variables may go here in the future)
12
(defparameter *DEFAULT-PAGE-TEMPLATE* "layout_2018.html"
13
  "Default template to use unless another is explicitly specified.")
Cherie Yang's avatar
Cherie Yang committed
14 15

;; @TO-DO: replace this with better css preprocessing.
16 17
(defparameter *STYLES-DIR* (asdf:system-relative-pathname :cl-site "layout/css/")
  "Pathname for location and list of styles.")
Cherie Yang's avatar
Cherie Yang committed
18
(defparameter *STYLES* 
19 20 21 22 23 24 25 26 27
  (list "layout_2018.css")
  "A list of strings representing relative filenames.")

;; JS files - separate from static files, because they are processed differently
;; within the template.
(defparameter *SCRIPTS-DIR* (asdf:system-relative-pathname :cl-site "layout/js/")
  "Pathname for location and list of scripts.")
(defparameter *SCRIPTS*
  (list "scripts.js")
28
  "A list of strings representing relative filenames.")
Cherie Yang's avatar
Cherie Yang committed
29

30 31 32 33
;; General static files - images etc
(defparameter *STATIC-DIR* (asdf:system-relative-pathname :cl-site "layout/static/")
  "Pathname for location of static files.")

Cherie Yang's avatar
Cherie Yang committed
34 35
;; The only REQUIRED field is :content which must be the filename of the page content
;; The :content field will NOT be sent to the template.
36
;; @TO-DO: store fields within content files and parse them out.
37 38
(defparameter *PAGES-DIR* (asdf:system-relative-pathname :cl-site "content/")
  "Pathname for location of page content.")
Cherie Yang's avatar
Cherie Yang committed
39
(defparameter *PRIVATE-KEYS* '(:slug :content))
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

;; Extra context for pages
(defparameter *PAGE-CONTEXT*
  `(("about.html" ((:title . "Common-Lisp.net | About")))
    ("index.html" ((:title . "Welcome to Common-Lisp.net!")))
    ("faq.html" ((:title . "Frequently asked questions")))
    ("gitlab-migration-repository-mapping.html" ((:title . "GitLab migration")))
    ("gitlab-migration-status.html" ((:title . "Migration to GitLab")))
    ("independent-lists.html" ((:title . "Independent Mailing Lists")))
    ("orphaned-mailing-lists.html" ((:title . "Orphaned mailing lists")))
    ("orphaned-projects.html" ((:title . "Orphaned projects")))
    ("phub.html" ((:title . "Projects")))
    ("project-intro.html" ((:title . "Project Hosting")))))

(defun page-context (filename)
  (cadr (assoc filename *page-context* :test 'equalp)))

(defun page-title (filename)
  (or (cdr (assoc :title (page-context filename)))
      (format nil "Common-Lisp.net | ~a"
              (string-capitalize
               (pathname-name (pathname filename))))))

Cherie Yang's avatar
Cherie Yang committed
63
(defparameter *PAGES* 
64 65 66 67 68 69 70 71
  (mapcar (lambda (p)
            (let ((context
                   (append (list (cons :content (file-namestring p)))
                           (page-context (file-namestring p)))))
              (when (not (assoc :title context))
                (push (cons :title (page-title (file-namestring p)))
                      context))
              context))                         
72 73 74
	  (directory (make-pathname :defaults *PAGES-DIR*
				    :name :wild
				    :type "html")))
75
  "Each page is an alist containing info to be sent to the template via the context.")
Cherie Yang's avatar
Cherie Yang committed
76 77 78

;; Initialize global context (will be appended to all individual page contexts)
;; Used to store things like stylesheets, etc...
79
(defparameter *GLOBAL-CONTEXT* ())