trying to switch to using lisp but need to build it first

This commit is contained in:
Chris Cochrun 2024-03-26 14:30:37 -05:00
parent 09b9e8fb5b
commit ae37869c9f
8 changed files with 248 additions and 102 deletions

View file

@ -1,37 +1,42 @@
{
stdenv,
lib,
hugo,
go,
cargo,
rustc,
clippy,
rust-analyzer,
rustfmt,
# hugo,
# go,
# cargo,
# rustc,
# clippy,
# rust-analyzer,
# rustfmt,
pkg-config,
# sbcl,
# sbclPackages,
gcc,
gnumake,
sbcl,
sbclPackages,
makeWrapper,
openssl,
rustPlatform
build-asdf-system,
pkgs,
...
}:
# let
# sbcl' = sbcl.withPackages (ps: with ps; [
# hunchentoot
# dexador
# jzon
# serapeum
# deploy
# spinneret
# lass
# cl-smtp
# # pkgs.openssl
# # pkgs.openssl.out
# # pkgs.openssl.dev
# ]);
# in
rustPlatform.buildRustPackage rec {
let
sbcl' = sbcl.withPackages (ps: with ps; [
hunchentoot
dexador
jzon
serapeum
deploy
spinneret
lass
cl-smtp
log4cl
pkgs.openssl
pkgs.openssl.out
pkgs.openssl.dev
]);
in
build-asdf-system {
name = "tfcconnection";
pname = "tfcconnection";
version = "0.0.1";
@ -39,52 +44,67 @@ rustPlatform.buildRustPackage rec {
src = ./.;
# cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
cargoLock = {
lockFile = ./Cargo.lock;
};
# cargoLock = {
# lockFile = ./Cargo.lock;
# };
nativeBuildInputs = [
makeWrapper
gcc
stdenv
gnumake
pkg-config
rustc
cargo
];
buildInputs = [
# rustPlatform
# clippy
# rustfmt
openssl
# openssl.out
# openssl.dev
];
# nativeLibs = [
makeWrapper
# openssl
# openssl.out
# openssl.dev
];
# buildInputs = [
# # rustPlatform
# # clippy
# # rustfmt
# # openssl
# # openssl.out
# # openssl.dev
# sbcl'
# ];
# lispLibs = with sbclPackages; [
# hunchentoot
# dexador
# jzon
# serapeum
# deploy
# spinneret
# lass
# cl-smtp
# ];
nativeLibs = [
openssl
openssl.out
openssl.dev
];
buildPhase = ''
export HOME=$(pwd)
${cargo}/bin/cargo build
'';
lispLibs = with sbclPackages; [
hunchentoot
dexador
jzon
serapeum
deploy
spinneret
lass
cl-smtp
log4cl
];
# ${cargo}/bin/cargo build
# buildPhase = ''
# export HOME=$(pwd)
# ${sbcl'}/bin/sbcl --load build.lisp
# '';
systems = "tfcserver";
buildScript = ./build.lisp;
# cp target/debug/tfcapi $out/bin
installPhase = ''
mkdir -pv $out
cp -r * $out
rm -fv $out/tfcserver
mkdir -p $out/bin
cp target/debug/tfcapi $out/bin
wrapProgram $out/bin/tfcapi \
cp -v tfcserver $out/bin
wrapProgram $out/bin/tfcserver \
--prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \
'';

View file

@ -15,7 +15,7 @@
in
{
devShell = import ./shell.nix { inherit pkgs; };
defaultPackage = pkgs.callPackage ./default.nix { };
defaultPackage = import ./default.nix { };
}
);
}

View file

@ -22,9 +22,59 @@
document.getElementById('warning-email').style.height = '0';
document.getElementById('warning-email').style.margin = '0';
}
if (data.get("firstname") == "") {
document.getElementById('warning-name').style.visibility = 'visible';
document.getElementById('warning-name').style.height = '';
document.getElementById('warning-name').style.margin = '';
return false;
} else {
document.getElementById('warning-name').style.visibility = 'hidden';
document.getElementById('warning-name').style.height = '0';
document.getElementById('warning-name').style.margin = '0';
}
if (data.get("lastname") == "") {
document.getElementById('warning-name').style.visibility = 'visible';
document.getElementById('warning-name').style.height = '';
document.getElementById('warning-name').style.margin = '';
return false;
} else {
document.getElementById('warning-name').style.visibility = 'hidden';
document.getElementById('warning-name').style.height = '0';
document.getElementById('warning-name').style.margin = '0';
}
if (data.get("parentfirstname") == "") {
document.getElementById('warning-name').style.visibility = 'visible';
document.getElementById('warning-name').style.height = '';
document.getElementById('warning-name').style.margin = '';
return false;
} else {
document.getElementById('warning-name').style.visibility = 'hidden';
document.getElementById('warning-name').style.height = '0';
document.getElementById('warning-name').style.margin = '0';
}
if (data.get("parentlastname") == "") {
document.getElementById('warning-name').style.visibility = 'visible';
document.getElementById('warning-name').style.height = '';
document.getElementById('warning-name').style.margin = '';
return false;
} else {
document.getElementById('warning-name').style.visibility = 'hidden';
document.getElementById('warning-name').style.height = '0';
document.getElementById('warning-name').style.margin = '0';
}
if (data.get("final-agreement") == "") {
document.getElementById('warning-agreement').style.visibility = 'visible';
document.getElementById('warning-agreement').style.height = '';
document.getElementById('warning-agreement').style.margin = '';
return false;
} else {
document.getElementById('warning-agreement').style.visibility = 'hidden';
document.getElementById('warning-agreement').style.height = '0';
document.getElementById('warning-agreement').style.margin = '0';
}
/* let base = "http://localhost:4242/camp-form"; */
let base = "https://api.tfcconnection.org/camp-form";
let base = "http://localhost:4242/camp-form";
/* let base = "https://api.tfcconnection.org/camp-form"; */
fetch(base, {
method: "POST",
@ -61,6 +111,15 @@
document.getElementById('warning-email').style.visibility = 'hidden';
document.getElementById('warning-email').style.height = '0';
document.getElementById('warning-email').style.margin = '0';
document.getElementById('warning-name').style.visibility = 'hidden';
document.getElementById('warning-name').style.height = '0';
document.getElementById('warning-name').style.margin = '0';
document.getElementById('warning-agreement').style.visibility = 'hidden';
document.getElementById('warning-agreement').style.height = '0';
document.getElementById('warning-agreement').style.margin = '0';
document.getElementById('warning-other').style.visibility = 'hidden';
document.getElementById('warning-other').style.height = '0';
document.getElementById('warning-other').style.margin = '0';
}
document.addEventListener('DOMContentLoaded', process);
</script>
@ -243,5 +302,26 @@
</span>
</div>
<div id="warning-name" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
<span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
{{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
Make sure that all names are filled out
</span>
</div>
<div id="warning-agreement" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
<span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
{{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
You have to agree to the registration information.
</span>
</div>
<div id="warning-other" class="basis-full mt-10 flex px-4 py-3 rounded-lg bg-[#ef4444] dark:bg-[#ef4444]">
<span class="text-[#fca5a5] ltr:pr-3 rtl:pl-3 content-right float-right">
{{ partial "icon.html" (.Get 0 | default "triangle-exclamation") }}
Have you checked to make sure all required fields are filled out?
</span>
</div>
</form>
</div>

View file

@ -77,8 +77,8 @@
// For use in dev
// Can now start using this in production IF,
// I get the server running on the server
let base = "https://api.tfcconnection.org/health-form";
/* let base = "http://localhost:4242/health-form"; */
/* let base = "https://api.tfcconnection.org/health-form"; */
let base = "http://localhost:4242/health-form";
fetch(base, {
method: "POST",
body: data

View file

@ -10,6 +10,7 @@ let
spinneret
lass
cl-smtp
log4cl
pkgs.openssl
pkgs.openssl.out
pkgs.openssl.dev

View file

@ -261,7 +261,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
.unwrap(),
)
.to("Chris Cochrun <chris@tfcconnection.org>".parse().unwrap())
.to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
// .to("Ethan Rose <ethan@tfcconnection.org>".parse().unwrap())
.subject(email_subject)
.multipart(multi)
{

View file

@ -7,6 +7,7 @@
(require "spinneret")
(require "lass")
(require "cl-smtp")
(require "log4cl")
(defpackage tfcserver
(:use :cl :com.inuoe.jzon :spinneret :serapeum))
@ -297,6 +298,48 @@ with the image attached to us"
(: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 "firstname" form
:test 'string=))))
(last-name (trim-whitespace
(cdr (assoc "lastname" form
:test 'string=))))
(parent-name (concatenate 'string
(trim-whitespace
(cdr (assoc "parentfirstname" form
:test 'string=)))
" "
(trim-whitespace
(cdr (assoc "parentlastname" form
:test 'string=))))))
(not (cl-smtp:send-email
"mail.tfcconnection.org"
"no-reply@mail.tfcconnection.org"
'("chris@tfcconnection.org" "chris@cochrun.xyz")
(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 (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"
@ -342,7 +385,7 @@ with the image attached"
(defun define-post-form-handler (uri mail-function)
"Take a uri and a mailer function and define a handler in hunchentoot
for forms to POST to."
(hunchentoot:define-easy-handler (respond :uri uri) ()
(hunchentoot:define-easy-handler (respond :uri uri) ()
(setf (hunchentoot:content-type*) "plain/text")
(let* ((request-type (hunchentoot:request-method hunchentoot:*request*))
(post-data (hunchentoot:post-parameters* hunchentoot:*request*))
@ -382,6 +425,7 @@ for forms to POST to."
(define-post-form-handler "/mt-form" 'mail-mt-form)
(define-post-form-handler "/health-form" 'mail-health-form)
(define-post-form-handler "/camp-form" 'mail-camp-form)
(defun main ()
(start-server 4242)

View file

@ -12,6 +12,7 @@
"bordeaux-threads"
"spinneret"
"lass"
"log4cl"
"cl-smtp") ;; <== list of Quicklisp dependencies
:components ((:module "src"
:components