-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate-site.el
executable file
·112 lines (106 loc) · 6.04 KB
/
create-site.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
(load "~/quicklisp/setup.lisp") ; requires quicklisp installed
;; See instructions here https://www.quicklisp.org/beta/
(ql:quickload 'lquery)
(ql:quickload 'str)
(ql:quickload 'cl-markup)
(use-package 'cl-markup)
;; Source: http://sodaware.sdf.org/notes/cl-read-file-into-string/
(defun file-get-contents (filename)
(with-open-file (stream filename)
(let ((contents (make-string (file-length stream))))
(read-sequence contents stream)
contents)))
(defvar logo
(markup (:br)
(:br)
(:div :class "row"
(:div :class "col-xs-12" :id "asi-logo"
(:a :href "../index.html"
(:img :src "../Meta/asi_logo.png"
:id "asi-logo-img"))))))
(defun create-site (subject-list)
(if (null subject-list)
'done
(let* ((main-files (directory
(str:join "" (list "data/main/"
(car subject-list)
"/*.html"))))
(footer-files (directory
(str:join "" (list "data/footer/"
(car subject-list)
"/*.html"))))
(out-folder (str:join "" (list (car subject-list) "/")))
(page-questions (file-get-contents
(str:join "" (list "data/header/"
(car subject-list)
".html"))))
(pq-dom (lquery:$ (initialize page-questions)))
(pq (lquery:$ ".page-question" (serialize)))
(*auto-escape* nil)
(len (length page-questions)))
(loop for i from 0 to len
for main-file in main-files
for footer-file in footer-files do
(let* ((page-question (aref pq i))
(main (file-get-contents main-file))
(footer (file-get-contents footer-file))
(outfile (str:join "" (list out-folder
(file-namestring main-file))))
(to-write
(html5
(:head
(:meta :charset "utf-8"
:name "viewport"
:content "width=device-width")
(:link :rel "stylesheet"
:href "../bootstrap-3.3.7-dist/css/bootstrap.min.css")
(:link :rel "stylesheet"
:href "../styles-bs.css")
(:link :rel "shortcut icon" :href "../Meta/asi_logo.png")
(:title (file-namestring main-file)))
(:body
(:nav :class "page-details"
(:div :class "container"
(:div :class "row"
(:div :class "col-md-4 col-xs-3"
:id "ahe_level"
(:b :class "hidden-xs" "Level: ")
"Level 0")
(:div :class "col-md-4 col-xs-6"
:id "ahe_topic"
(:b :class "hidden-xs" "Topic: ")
"Social Science")
(:div :class "col-md-4 col-xs-3"
:id "ahe_route"
(:b :class "hidden-xs" "Route Number: ")
(format nil "~2,'0d" (+ i 1))))))
page-question
(:div :class "container"
(:div :class "row"
(:div :class "col-md-8 col-sm-7"
(str:replace-all "</main>"
(str:join "" (list logo "</main>"))
main))
(:div :class "col-md-4 col-sm-5" footer)))
(:div :class "visible-xs container-fluid" :id "bottom-bar"
(:div :class "row"
(:div :id "back-button" :class "col-xs-3" :onclick "goBack()"
(:img :src "../Meta/arrow-circle-left-solid-red.png"
:id "fa-left-solid"))
(:div :id "follow-question-btn" :class "col-xs-6"
(:img :src "../Meta/question-circle-solid-red.png"
:id "fa-question-circle")
"Got any questions?")
(:div :id "map-button" :class "col-xs-3"
(:a :href "../Meta/List for Organized Study.html"
(:img :src "../Meta/map-solid-red.png"
:id "fa-map-solid")))))
(:script :src "../bootstrap-3.3.7-dist/jquery-3.2.1/jquery.min.js" "")
(:script :src "../bootstrap-3.3.7-dist/js/bootstrap.min.js" "")
(:script :src "../js-bs.js" "")))))
(with-open-file (out outfile :direction :output
:if-does-not-exist :create
:if-exists :overwrite)
(format out to-write))))
(create-site (cdr subject-list)))))
(create-site '("Social Science" "Information and Communication Technology" "Science"))