unfortunately this is the change to the new zola based website
This commit is contained in:
parent
308c4fb9c5
commit
fa74bbe4b3
866 changed files with 3737 additions and 118270 deletions
69
src/css/main.css
Normal file
69
src/css/main.css
Normal file
|
@ -0,0 +1,69 @@
|
|||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
|
||||
@layer base {
|
||||
h1 {
|
||||
@apply text-2xl;
|
||||
}
|
||||
h2 {
|
||||
@apply text-xl;
|
||||
}
|
||||
|
||||
p {
|
||||
@apply pb-4;
|
||||
}
|
||||
|
||||
ul, ol {
|
||||
@apply list-outside;
|
||||
@apply pl-6; /* Indent the list elements. */
|
||||
@apply mb-4; /* The bottom of the list should have a margin, like the paragraphs. */
|
||||
|
||||
/* Lists within a list, however, should not have a bottom margin. */
|
||||
ul, ol {
|
||||
@apply mb-0;
|
||||
}
|
||||
}
|
||||
|
||||
ul {
|
||||
@apply list-disc;
|
||||
}
|
||||
|
||||
ol {
|
||||
@apply list-decimal;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
p {
|
||||
@apply py-0;
|
||||
}
|
||||
|
||||
@apply italic;
|
||||
@apply border-l-2;
|
||||
@apply border-neutral-500;
|
||||
@apply pl-4;
|
||||
@apply mb-4;
|
||||
@apply text-neutral-600;
|
||||
@apply dark:text-neutral-400;
|
||||
}
|
||||
}
|
||||
|
||||
/* Global default styles */
|
||||
html {
|
||||
scroll-behavior: smooth;
|
||||
}
|
||||
|
||||
/* Default Pages content styles */
|
||||
#page-content a {
|
||||
@apply underline;
|
||||
}
|
||||
#page-content p, h2 {
|
||||
@apply py-4;
|
||||
}
|
||||
#page-content :is(h1, h2, h3, h4, h5, h6) {
|
||||
@apply underline;
|
||||
}
|
||||
#page-content pre {
|
||||
@apply p-4 my-4 overflow-x-auto;
|
||||
}
|
7
src/js/lang.js
Normal file
7
src/js/lang.js
Normal file
|
@ -0,0 +1,7 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
document.getElementById('switch-lang')?.addEventListener('click', switchLang);
|
||||
})
|
||||
|
||||
function switchLang(event) {
|
||||
document.getElementById('switch-lang-panel').classList.toggle('hidden')
|
||||
}
|
78
src/js/main.js
Normal file
78
src/js/main.js
Normal file
|
@ -0,0 +1,78 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// ---------------- Selected Navbar Link -------------------------
|
||||
let navbar_links = document.querySelectorAll('.nav-links a');
|
||||
let trim_last_slash = window.location.href.replace(/\/$/, '');
|
||||
let selected_navbar_link = [...navbar_links].filter((item) => {
|
||||
return ((item.href === trim_last_slash) || (item.href === window.location.href))
|
||||
})
|
||||
if (selected_navbar_link.length !== 0) {
|
||||
for (let element of selected_navbar_link) {
|
||||
element.className = "bg-gray-900 text-white px-3 py-2 rounded-md text-sm font-medium"
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------- Switch Theme -------------------------
|
||||
// On page load or when changing themes, best to add inline in `head` to avoid FOUC
|
||||
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
|
||||
document.documentElement.classList.add('dark')
|
||||
document.getElementById('dark').classList.add('hidden');
|
||||
document.getElementById("syntax_highlight").href = "/syntax-dark.css";
|
||||
} else {
|
||||
document.documentElement.classList.remove('dark')
|
||||
document.getElementById('light').classList.add('hidden');
|
||||
document.getElementById("syntax_highlight").href = "/syntax-light.css";
|
||||
}
|
||||
// Switch theme action
|
||||
document.getElementById('switch-theme')?.addEventListener('click', switchTheme);
|
||||
|
||||
// ---------------- Toggle Sidebar -------------------------
|
||||
document.getElementById('toggle-sidebar')?.addEventListener('click', toggleSidebar);
|
||||
|
||||
// ---------------- Toggle Mobile menu -------------------------
|
||||
document.getElementById('toggle-mobile-menu')?.addEventListener('click', toggleMobileMenu);
|
||||
});
|
||||
|
||||
function switchTheme() {
|
||||
let current_theme = ([...document.documentElement.classList].includes('dark')) ? 'dark' : 'light';
|
||||
if (current_theme === 'dark') {
|
||||
localStorage.theme = 'light';
|
||||
document.documentElement.classList.remove('dark');
|
||||
document.getElementById('light').classList.add('hidden');
|
||||
document.getElementById('dark').classList.remove('hidden');
|
||||
document.getElementById("syntax_highlight").href = "/syntax-light.css";
|
||||
} else {
|
||||
localStorage.theme = 'dark';
|
||||
document.documentElement.classList.add('dark');
|
||||
document.getElementById('dark').classList.add('hidden');
|
||||
document.getElementById('light').classList.remove('hidden');
|
||||
document.getElementById("syntax_highlight").href = "/syntax-dark.css";
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSidebar() {
|
||||
let sidebar = document.getElementById('sidebar');
|
||||
if ([...sidebar.classList].includes('translate-x-0')) {
|
||||
document.body.style.removeProperty("overflow")
|
||||
sidebar.classList.remove('translate-x-0')
|
||||
sidebar.classList.add('-translate-x-full')
|
||||
} else {
|
||||
document.body.style.setProperty("overflow", "hidden")
|
||||
sidebar.classList.remove('-translate-x-full')
|
||||
sidebar.classList.add('translate-x-0')
|
||||
}
|
||||
}
|
||||
|
||||
function toggleMobileMenu() {
|
||||
let menu = document.querySelector('#mobile-menu div.nav-links');
|
||||
if ([...menu.classList].includes('h-screen')) {
|
||||
document.body.classList.remove("overflow-hidden", "relative")
|
||||
document.documentElement.classList.remove("overscroll-none",)
|
||||
menu.classList.remove('h-screen')
|
||||
menu.classList.add('h-0')
|
||||
} else {
|
||||
document.body.classList.add("overflow-hidden", "relative")
|
||||
document.documentElement.classList.add("overscroll-none",)
|
||||
menu.classList.remove('h-0')
|
||||
menu.classList.add('h-screen')
|
||||
}
|
||||
}
|
38
src/js/page.js
Normal file
38
src/js/page.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// ---------------- TOC Scrollspy --------------------
|
||||
if (document.getElementById('toc') !== null) {
|
||||
|
||||
const table_of_content_links = document.querySelectorAll('#toc li a')
|
||||
|
||||
let page_titles_ids = [];
|
||||
[...table_of_content_links].forEach((item)=> {
|
||||
page_titles_ids.push(item.href.substring(item.href.indexOf("#")))
|
||||
})
|
||||
const page_titles_elements = document.querySelectorAll(page_titles_ids.join(','));
|
||||
|
||||
let reversed_title_elements = [...page_titles_elements].reverse();
|
||||
let elem = getActiveTocElement(reversed_title_elements) || page_titles_elements[0]; //If no element has gone outside of viewport on y axis
|
||||
findCorrespondingTocTitle(elem).classList.add('bg-blue-700') //page load
|
||||
var previous_elem = elem
|
||||
|
||||
window.addEventListener('scroll', () => {
|
||||
let element = getActiveTocElement(reversed_title_elements) || page_titles_elements[0];
|
||||
|
||||
if (element !== previous_elem) {
|
||||
findCorrespondingTocTitle(previous_elem).classList.remove('bg-blue-700')
|
||||
findCorrespondingTocTitle(element).classList.add('bg-blue-700')
|
||||
previous_elem = element
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
function getActiveTocElement(elements) {
|
||||
return [...elements].find((item) => {
|
||||
return (item.getBoundingClientRect().y <= 0)
|
||||
})
|
||||
}
|
||||
function findCorrespondingTocTitle(element) {
|
||||
return [...document.querySelectorAll('#toc li a')].find((item) => {
|
||||
return item.href.substring(item.href.indexOf("#")) === `#${element.id}`
|
||||
})
|
||||
}
|
121
src/js/search.js
Normal file
121
src/js/search.js
Normal file
|
@ -0,0 +1,121 @@
|
|||
document.addEventListener("DOMContentLoaded", function() {
|
||||
// let search_input = document.getElementById('search').addEventListener('click', openSearch)
|
||||
|
||||
// var openmodal = document.querySelectorAll('.modal-open')
|
||||
// for (var i = 0; i < openmodal.length; i++) {
|
||||
// openmodal[i].addEventListener('click', function(event){
|
||||
// event.preventDefault()
|
||||
// toggleSearchModal()
|
||||
// })
|
||||
// }
|
||||
let nav_search_input = document.getElementById('search');
|
||||
nav_search_input.addEventListener('click', function(event){
|
||||
event.preventDefault()
|
||||
toggleSearchModal()
|
||||
})
|
||||
|
||||
const overlay = document.querySelector('.modal-overlay')
|
||||
overlay.addEventListener('click', toggleSearchModal)
|
||||
|
||||
let closemodal = document.querySelectorAll('.modal-close')
|
||||
// closemodal.addEventListener('click', toggleSearchModal)
|
||||
for (var i = 0; i < closemodal.length; i++) {
|
||||
closemodal[i].addEventListener('click', toggleSearchModal)
|
||||
}
|
||||
|
||||
document.onkeydown = function(evt) {
|
||||
evt = evt || window.event
|
||||
let isEscape = false
|
||||
let isCmdK = false
|
||||
if ("key" in evt) {
|
||||
isEscape = (evt.key === "Escape" || evt.key === "Esc")
|
||||
isCmdK = (evt.key === "k" && evt.metaKey === true)
|
||||
} else {
|
||||
isCmdK = (evt.keyCode === 75 && evt.metaKey)
|
||||
isEscape = (evt.keyCode === 27)
|
||||
}
|
||||
if (isCmdK) { evt.preventDefault() }
|
||||
if ((isEscape && document.body.classList.contains('search-active')) || isCmdK) {
|
||||
toggleSearchModal();
|
||||
}
|
||||
};
|
||||
|
||||
let search_index = elasticlunr.Index.load(window.searchIndex);
|
||||
let elasticlunr_options = {
|
||||
bool: "AND",
|
||||
fields: {
|
||||
title: {boost: 2},
|
||||
body: {boost: 1},
|
||||
}
|
||||
};
|
||||
let search_term = "";
|
||||
let search_results = "";
|
||||
let search_input = document.getElementById('search-input');
|
||||
let search_results_container = document.getElementById('search-results');
|
||||
search_input.addEventListener('keyup', function(event) {
|
||||
// Trigger search
|
||||
if ([...document.body.classList].includes('search-active') && search_input.value.trim().length > 3) {
|
||||
// console.log('search')
|
||||
search_term = search_input.value.trim();
|
||||
// console.log(search_term)
|
||||
search_results = search_index.search(search_term, elasticlunr_options);
|
||||
// console.log(search_results)
|
||||
if (Array.isArray(search_results) && search_results.length > 0) {
|
||||
let result_list = document.getElementById('results-list');
|
||||
result_list.replaceChildren();
|
||||
let item = "";
|
||||
for (i = 0; i < search_results.length; i++) {
|
||||
let item = formatResultItem(search_results[i]);
|
||||
result_list.appendChild(item);
|
||||
}
|
||||
}
|
||||
// if (results.length === 0) {
|
||||
// $searchResults.style.display = "none";
|
||||
// return;
|
||||
// }
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function toggleSearchModal () {
|
||||
const modal = document.getElementById('search-modal')
|
||||
modal.classList.toggle('opacity-0')
|
||||
modal.classList.toggle('pointer-events-none')
|
||||
document.body.classList.toggle('search-active')
|
||||
if ([...document.body.classList].includes('search-active')) {
|
||||
// window.setTimeout(function() {
|
||||
document.getElementById('search-input').value = ""
|
||||
document.getElementById('search-input').focus()
|
||||
// }, 500);
|
||||
}
|
||||
}
|
||||
|
||||
function formatResultItem(search_result) {
|
||||
console.log(search_result)
|
||||
let formatted_result = `<li class="flex hover:bg-gray-200 dark:hover:bg-gray-600 text-black dark:text-gray-200 p-2 rounded-lg border border-black dark:border-gray-200 bg-gray-200 dark:bg-gray-500 rounded-lg hover:shadow-xl mb-2">
|
||||
<a href="${search_result.doc.path}">
|
||||
<span class="text-xl text-bold">${search_result.doc.title}</span>
|
||||
<span class="text-lg">${search_result.doc.description}</span>
|
||||
</a>
|
||||
</li>`
|
||||
return htmlToElement(formatted_result)
|
||||
}
|
||||
|
||||
// Credits : https://stackoverflow.com/a/35385518/7098666
|
||||
function htmlToElement(html) {
|
||||
let template = document.createElement('template');
|
||||
html = html.trim();
|
||||
template.innerHTML = html;
|
||||
return template.content.firstChild;
|
||||
}
|
||||
|
||||
// function openSearch() {
|
||||
// console.log("open modal");
|
||||
// let search_modal = document.getElementById('search-modal');
|
||||
// search_modal.classList.remove('hidden');
|
||||
// console.log(search_modal);
|
||||
// }
|
||||
|
||||
// function search() {
|
||||
// let index = elasticlunr.Index.load(window.searchIndex);
|
||||
// }
|
568
src/main.lisp
568
src/main.lisp
|
@ -1,568 +0,0 @@
|
|||
(asdf:load-system 'hunchentoot)
|
||||
(asdf:load-system 'dexador)
|
||||
(asdf:load-system 'com.inuoe.jzon)
|
||||
(asdf:load-system 'serapeum)
|
||||
(asdf:load-system 'bordeaux-threads)
|
||||
(asdf:load-system 'spinneret)
|
||||
(asdf:load-system 'lass)
|
||||
(asdf:load-system 'cl-smtp)
|
||||
(asdf:load-system 'log4cl)
|
||||
(asdf:load-system 'fiveam)
|
||||
|
||||
(defpackage tfcserver
|
||||
(:use :cl :com.inuoe.jzon :spinneret :serapeum))
|
||||
|
||||
(in-package :tfcserver)
|
||||
|
||||
(log:config :daily "/tmp/tfc-%Y%m%d.log")
|
||||
|
||||
(defvar *server*)
|
||||
(defun start-server (port)
|
||||
(setq *server*
|
||||
(hunchentoot:start
|
||||
(make-instance 'hunchentoot:easy-acceptor
|
||||
:port port))))
|
||||
|
||||
(defparameter *mail-css*
|
||||
'((table :border-collapse "collapse" :width "100%")
|
||||
(("th," td) :padding "8px")
|
||||
(td :text-align "left" :width "70%")
|
||||
(th :text-align "right" :border-right "1px solid #ddd")
|
||||
(tr :border-bottom "1px solid #ddd")
|
||||
(h1 :text-align "center")))
|
||||
|
||||
(defun post-health-form (data-list)
|
||||
"Takes the health form as an alist and posts it to nocodb"
|
||||
(let* ((student-name
|
||||
(concatenate 'string
|
||||
(serapeum:trim-whitespace
|
||||
(cdr (assoc "firstname" data-list
|
||||
:test 'string=)))
|
||||
" "
|
||||
(serapeum:trim-whitespace
|
||||
(cdr (assoc "lastname" data-list
|
||||
:test 'string=)))))
|
||||
(parent-name
|
||||
(concatenate 'string
|
||||
(serapeum:trim-whitespace
|
||||
(cdr (assoc "parentfirstname" data-list
|
||||
:test 'string=)))
|
||||
" "
|
||||
(serapeum:trim-whitespace
|
||||
(cdr (assoc "parentlastname" data-list
|
||||
:test 'string=)))))
|
||||
(image (assoc "image" data-list))
|
||||
(headers (list (cons "Authorization" *auth-token*)
|
||||
(cons "Content-Type" "application/json")))
|
||||
(rows (parse (dex:get
|
||||
"https://staff.tfcconnection.org/apps/tables/api/1/tables/5/rows"
|
||||
:basic-auth '("chris" . "2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b")
|
||||
:verbose t)))
|
||||
(lowid 0)
|
||||
(highest-id (loop for i in
|
||||
(loop for row across rows collect (gethash "id" row))
|
||||
maximizing i)))
|
||||
|
||||
(setq data-list (remove
|
||||
(assoc "lastname" *last-list-data* :test 'string=)
|
||||
data-list))
|
||||
(setq data-list (remove
|
||||
(assoc "parentlastname" *last-list-data* :test 'string=)
|
||||
data-list))
|
||||
(setq data-list (remove
|
||||
(assoc "image" *last-list-data* :test 'string=)
|
||||
data-list))
|
||||
(setf (cdr
|
||||
(assoc "firstname" data-list :test 'string=))
|
||||
student-name)
|
||||
(setf (car
|
||||
(assoc "firstname" data-list :test 'string=))
|
||||
"Student Name")
|
||||
(setf (cdr
|
||||
(assoc "parentfirstname" data-list :test 'string=))
|
||||
parent-name)
|
||||
(setf (car
|
||||
(assoc "parentfirstname" data-list :test 'string=))
|
||||
"Parent Name")
|
||||
(setf (car
|
||||
(assoc "add-emergency-contact" data-list :test 'string=))
|
||||
"emergency-contact")
|
||||
(setf (car
|
||||
(assoc "doctorname" data-list :test 'string=))
|
||||
"doctor")
|
||||
(setf (car
|
||||
(assoc "doctorphone" data-list :test 'string=))
|
||||
"doctor-phone")
|
||||
(setf (car
|
||||
(assoc "doctorcity" data-list :test 'string=))
|
||||
"doctor-city")
|
||||
(setf (car
|
||||
(assoc "allergic-treatment" data-list :test 'string=))
|
||||
"allergy-treatments")
|
||||
(setf (car (assoc "tetanus-shot" data-list :test 'string=))
|
||||
"tetanus-shot-date")
|
||||
(loop :for entry :in data-list
|
||||
:do (format t "~&~A" entry))
|
||||
(format t "~&~A" "Let's print out the data")
|
||||
(format t "~&~A" data-list)
|
||||
(uiop:println *last-list-data*)
|
||||
|
||||
(setf data `#(("columnId" 37 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"Student Name"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 38 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"Parent Name"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 39 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"birthdate"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 40 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"street"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 41 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"city"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 42 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"state"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 43 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"zip"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 44 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"cellphone"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 45 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"homephone"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 46 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"emergency-contact"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 47 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"doctor"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 48 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"doctor-city"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 49 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"doctor-phone"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 50 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"medical-coverage"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 51 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"insurance-name"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 52 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"policy-number"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 53 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"insurance-card"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 54 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"agreement"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 55 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"allergies"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 56 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"specific-allergies"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 57 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"allergy-treatment"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 58 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"conditions"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 59 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"tetanus-shot-date"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 60 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"medication-schedule"
|
||||
*last-list-data* :test 'string=))))
|
||||
("columnId" 61 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"other-notes"
|
||||
*last-list-data*
|
||||
:test 'string=))))
|
||||
("columnId" 62 "value" ,(serapeum:trim-whitespace
|
||||
(cdr (assoc
|
||||
"swimming-ability"
|
||||
*last-list-data*
|
||||
:test 'string=))))))
|
||||
|
||||
(dex:post "https://staff.tfcconnection.org/apps/tables/api/1/tables/4/rows"
|
||||
:basic-auth '("chris" . "2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b")
|
||||
:content `(("data" . ,(stringify special-data)))
|
||||
:verbose t)
|
||||
))
|
||||
|
||||
(defun post-camp-data (data)
|
||||
"Takes the camp data as an alist and sends it to nextcloud tables to be input"
|
||||
(let ((new-data `((63 . ,(concat
|
||||
(cdr
|
||||
(assoc "first-name"
|
||||
data :test 'string=))
|
||||
" "
|
||||
(cdr
|
||||
(assoc "last-name"
|
||||
data :test 'string=))))
|
||||
(64 . ,(concat
|
||||
(cdr
|
||||
(assoc "parent-first-name"
|
||||
data :test 'string=))
|
||||
" "
|
||||
(cdr
|
||||
(assoc "parent-last-name"
|
||||
data :test 'string=))))
|
||||
(65 . ,(cdr
|
||||
(assoc "parent-phone"
|
||||
data :test 'string=)))
|
||||
(66 . ,(cdr
|
||||
(assoc "parent-email"
|
||||
data :test 'string=)))
|
||||
(67 . ,(cdr
|
||||
(assoc "birth-date"
|
||||
data :test 'string=)))
|
||||
(69 . ,(cdr
|
||||
(assoc "gender"
|
||||
data :test 'string=)))
|
||||
(70 . ,(cdr
|
||||
(assoc "street"
|
||||
data :test 'string=)))
|
||||
(71 . ,(cdr
|
||||
(assoc "city"
|
||||
data :test 'string=)))
|
||||
(72 . ,(cdr
|
||||
(assoc "state"
|
||||
data :test 'string=)))
|
||||
(73 . ,(cdr
|
||||
(assoc "zip"
|
||||
data :test 'string=)))
|
||||
(74 . ,(cdr
|
||||
(assoc "grade"
|
||||
data :test 'string=)))
|
||||
(75 . ,(cdr
|
||||
(assoc "week"
|
||||
data :test 'string=)))
|
||||
(76 . ,(cdr
|
||||
(assoc "shirt"
|
||||
data :test 'string=)))
|
||||
(77 . ,(cdr
|
||||
(assoc "registration"
|
||||
data :test 'string=))))))
|
||||
(log:info new-data)
|
||||
(bt:make-thread
|
||||
(lambda ()
|
||||
(dex:post "https://staff.tfcconnection.org/apps/tables/api/1/tables/5/rows"
|
||||
:basic-auth '("chris" . "2VHeGxeC^Zf9KqFK^G@Pt!zu2q^6@b")
|
||||
:content `(("data" . ,(stringify new-data)))
|
||||
:verbose t)))))
|
||||
|
||||
(defun mail-mt-form (form attachment)
|
||||
"Takes the form as an alist and sends a table formatted email
|
||||
with the image attached to us"
|
||||
(log:info form)
|
||||
(let ((first-name (cdr (assoc "firstname" form :test 'string=)))
|
||||
(last-name (cdr (assoc "lastname" form :test 'string=)))
|
||||
(form (reverse form)))
|
||||
(not (cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
'("chris@cochrun.xyz" "chris@tfcconnection.org")
|
||||
(format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
|
||||
(format nil "Mission Trip Form for ~a ~a" first-name last-name)
|
||||
:display-name "TFC ADMIN"
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
:attachments attachment
|
||||
:html-message
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Mission Trip Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Mission Trip Form for ~a ~a" first-name last-name))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (trim-whitespace (car row)))
|
||||
(:td (trim-whitespace
|
||||
(cdr row)))))))))))))
|
||||
|
||||
(defun mail-camp-form (form attachment)
|
||||
"Takes the form as an alist and sends a table formatted email
|
||||
with the image attached"
|
||||
(let* ((first-name (trim-whitespace
|
||||
(cdr (assoc "first-name" form
|
||||
:test 'string=))))
|
||||
(last-name (trim-whitespace
|
||||
(cdr (assoc "last-name" form
|
||||
:test 'string=))))
|
||||
(parent-name (concatenate 'string
|
||||
(trim-whitespace
|
||||
(cdr (assoc "parent-first-name" form
|
||||
:test 'string=)))
|
||||
" "
|
||||
(trim-whitespace
|
||||
(cdr (assoc "parent-last-name" form
|
||||
:test 'string=))))))
|
||||
(log:info (format nil "Mailing out the camp form for ~a"
|
||||
(concat first-name " " last-name)))
|
||||
(not (cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
'("chris@tfcconnection.org" "ethan@tfcconnection.org")
|
||||
(format nil "~a ~a filled out a Camp Form!" first-name last-name)
|
||||
(format nil "Camp Form for ~a ~a" first-name last-name)
|
||||
:display-name "TFC ADMIN"
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
:attachments attachment
|
||||
:html-message
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Health Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Camp Form for ~a ~a" first-name last-name))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (string-capitalize
|
||||
(string-replace-all
|
||||
"-" (car row) " ")))
|
||||
(:td (cdr row))))))))))))
|
||||
|
||||
(defun mail-health-form (form attachment)
|
||||
"Takes the form as an alist and sends a table formatted email
|
||||
with the image attached"
|
||||
(let* ((first-name (trim-whitespace
|
||||
(cdr (assoc "first-name" form
|
||||
:test 'string=))))
|
||||
(last-name (trim-whitespace
|
||||
(cdr (assoc "last-name" form
|
||||
:test 'string=))))
|
||||
(parent-name (concatenate 'string
|
||||
(trim-whitespace
|
||||
(cdr (assoc "parent-first-name" form
|
||||
:test 'string=)))
|
||||
" "
|
||||
(trim-whitespace
|
||||
(cdr (assoc "parent-last-name" form
|
||||
:test 'string=))))))
|
||||
(log:info (format nil "Mailing out the health form for ~a"
|
||||
(concat first-name " " last-name)))
|
||||
(not (cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
'("chris@tfcconnection.org" "ethan@tfcconnection.org")
|
||||
(format nil "~a ~a filled out a Health Form!" first-name last-name)
|
||||
(format nil "Health Form for ~a ~a" first-name last-name)
|
||||
:display-name "TFC ADMIN"
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
:attachments attachment
|
||||
:html-message
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Health Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Health Form for ~a ~a" first-name last-name))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (string-capitalize
|
||||
(string-replace-all
|
||||
"-" (car row) " ")))
|
||||
(:td (cdr row))))))))))))
|
||||
|
||||
(tbnl:define-easy-handler (health-form :uri "/health-form") ()
|
||||
(setf (tbnl:header-out :access-control-expose-headers) "*")
|
||||
(let* ((data (tbnl:post-parameters* tbnl:*request*))
|
||||
(registration (cdr (assoc "registration" data :test 'string=)))
|
||||
(image (cdr (assoc "image" data :test 'string=)))
|
||||
(first-name (cdr (assoc "first-name" data :test 'string=)))
|
||||
(last-name (cdr (assoc "last-name" data :test 'string=)))
|
||||
(image (cdr (assoc "image" data :test 'string=)))
|
||||
(attachment nil))
|
||||
(loop :for d :in data
|
||||
:do (progn
|
||||
(if (string= "first-name" (car d))
|
||||
(progn
|
||||
(setf first-name (cdr d))))
|
||||
(if (string= "last-name" (car d))
|
||||
(progn
|
||||
(setf last-name (cdr d))))
|
||||
(if (string= "image" (car d))
|
||||
(let ((path (path-join
|
||||
hunchentoot:*tmp-directory*
|
||||
(format nil "~a_~a.~a" first-name last-name
|
||||
(cadr (uiop:split-string
|
||||
(car (last d 2)) :separator "."))))))
|
||||
(uiop:copy-file
|
||||
(cadr d)
|
||||
(path-join
|
||||
hunchentoot:*tmp-directory*
|
||||
(format nil "~a_~a.~a" first-name last-name
|
||||
(cadr (uiop:split-string
|
||||
(car (last d 2)) :separator ".")))))
|
||||
(setf attachment path)
|
||||
(log:info attachment)))))
|
||||
(log:info data)
|
||||
(when data
|
||||
(mail-health-form data attachment)
|
||||
(cond ((string= registration "now")
|
||||
(log:info "Sending them to pay now")
|
||||
(setf (hunchentoot:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JPJ"))
|
||||
((string= registration "full")
|
||||
(log:info "Sending them to pay full amount")
|
||||
(setf (tbnl:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JQE"))
|
||||
((string= registration "later")
|
||||
(log:info "Sending the health form thank you snippet")
|
||||
(with-html-string
|
||||
(:div
|
||||
:class "mt-8"
|
||||
(:h2 (format nil
|
||||
"Thank You ~A!"
|
||||
(concat
|
||||
first-name " " last-name)))
|
||||
(:p :class "text-md"
|
||||
"If you'd like to pay for your registration go to the donate tab in the top right when you are ready and find the camp registration option."))))))))
|
||||
|
||||
(hunchentoot:define-easy-handler (camp-form :uri "/camp-form") ()
|
||||
(let* ((request-type (hunchentoot:request-method hunchentoot:*request*))
|
||||
(data (hunchentoot:post-parameters* hunchentoot:*request*)))
|
||||
(camp-form data)))
|
||||
|
||||
(defun camp-form (data)
|
||||
"Process the camp form"
|
||||
(log:info data)
|
||||
;; This is extremely necessary so that cors is right
|
||||
(let ((registration (cdr (assoc "registration" data :test 'string=)))
|
||||
(health (cdr (assoc "health-form" data :test 'string=))))
|
||||
(when (boundp 'hunchentoot:*reply*)
|
||||
(setf (tbnl:header-out :access-control-expose-headers) "*"))
|
||||
(when data
|
||||
(post-camp-data data)
|
||||
(mail-camp-form data nil))
|
||||
(if (string= health "later")
|
||||
(progn (uiop:println "Selected health later")
|
||||
(cond ((string= registration "now")
|
||||
(when (boundp 'tbnl:*reply*)
|
||||
(setf (hunchentoot:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JPJ")
|
||||
(log:info (tbnl:headers-out*)))
|
||||
(log:info "Sending them to pay now")
|
||||
"Redirecting to paying now")
|
||||
((string= registration "full")
|
||||
(when (boundp 'tbnl:*reply*)
|
||||
(setf (tbnl:header-out :HX-Redirect) "https://secure.myvanco.com/L-Z772/campaign/C-13JQE")
|
||||
(log:info (tbnl:headers-out*)))
|
||||
(log:info "Sending them to pay full amount")
|
||||
"Redirecting to paying full amount")
|
||||
((string= registration "later")
|
||||
(let ((first-name (cdr (assoc "first-name" data :test 'string=)))
|
||||
(last-name (cdr (assoc "last-name" data :test 'string=))))
|
||||
(log:info "Sending the camp thank you snippet")
|
||||
(with-html-string
|
||||
(:div
|
||||
:class "mt-8"
|
||||
(:h2 (format nil
|
||||
"Thank You ~A!"
|
||||
(concat
|
||||
first-name " " last-name)))
|
||||
(:p "Can't wait to see you at camp!!")
|
||||
(:p :class "text-md"
|
||||
"If you'd like to pay for your registration go to the donate tab in the top right when you are ready and find the camp registration option.")))))))
|
||||
(when (string= health "now")
|
||||
(when (boundp 'tbnl:*reply*)
|
||||
(setf (tbnl:header-out :HX-Redirect) (format nil "/camp-health-form/?registration=~A" registration))
|
||||
(log:info (tbnl:headers-out*)))
|
||||
(log:info "Sending them to the health form for camp")
|
||||
"Redirecting to the health form"))))
|
||||
|
||||
(defun main ()
|
||||
(start-server 4242)
|
||||
(log:info "Server has started on port 4242~&")
|
||||
(handler-case
|
||||
(bt:join-thread (find-if (lambda (th)
|
||||
(search "hunchentoot" (bt:thread-name th)))
|
||||
(bt:all-threads)))
|
||||
(#+sbcl sb-sys:interactive-interrupt
|
||||
#+ccl ccl:interrupt-signal-condition
|
||||
#+clisp system::simple-interrupt-condition
|
||||
#+ecl ext:interactive-interrupt
|
||||
#+allegro excl:interrupt-signal
|
||||
() (progn
|
||||
(format *error-output* "Aborting.~&")
|
||||
(hunchentoot:stop *server*)
|
||||
(uiop:quit)))
|
||||
(error (c) (format t "Woops, an unknown error occured:~&~a~&" c))))
|
||||
|
||||
(fiveam:test test-camp-form
|
||||
(fiveam:is (string= "Redirecting to the health form" (camp-form test-data))))
|
||||
|
||||
(setf test-data '(("first-name" . "Frodo") ("last-name" . "Braggins")
|
||||
("parent-first-name" . "Bilbo")
|
||||
("parent-last-name" . "Braggins")
|
||||
("birth-date" . "1857-04-06") ("gender" . "Male")
|
||||
("street" . "341 West Hobbiton") ("city" . "The Shire")
|
||||
("state" . "Middle Earth") ("zip" . "88888") ("grade" . "freshman")
|
||||
("parent-phone" . "9998887777")
|
||||
("parent-email" . "bilbosmells@theshire.com")
|
||||
("allergies" . "No") ("week" . "week1")
|
||||
("shirt" . "medium") ("final-agreement" . "yes")
|
||||
("health-form" . "now") ("registration" . "now")))
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue