trying to switch to using lisp but need to build it first
This commit is contained in:
parent
09b9e8fb5b
commit
ae37869c9f
138
default.nix
138
default.nix
|
@ -1,37 +1,42 @@
|
||||||
{
|
{
|
||||||
stdenv,
|
stdenv,
|
||||||
lib,
|
lib,
|
||||||
hugo,
|
# hugo,
|
||||||
go,
|
# go,
|
||||||
cargo,
|
# cargo,
|
||||||
rustc,
|
# rustc,
|
||||||
clippy,
|
# clippy,
|
||||||
rust-analyzer,
|
# rust-analyzer,
|
||||||
rustfmt,
|
# rustfmt,
|
||||||
pkg-config,
|
pkg-config,
|
||||||
# sbcl,
|
gcc,
|
||||||
# sbclPackages,
|
gnumake,
|
||||||
|
sbcl,
|
||||||
|
sbclPackages,
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
openssl,
|
openssl,
|
||||||
rustPlatform
|
build-asdf-system,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
# let
|
let
|
||||||
# sbcl' = sbcl.withPackages (ps: with ps; [
|
sbcl' = sbcl.withPackages (ps: with ps; [
|
||||||
# hunchentoot
|
hunchentoot
|
||||||
# dexador
|
dexador
|
||||||
# jzon
|
jzon
|
||||||
# serapeum
|
serapeum
|
||||||
# deploy
|
deploy
|
||||||
# spinneret
|
spinneret
|
||||||
# lass
|
lass
|
||||||
# cl-smtp
|
cl-smtp
|
||||||
# # pkgs.openssl
|
log4cl
|
||||||
# # pkgs.openssl.out
|
pkgs.openssl
|
||||||
# # pkgs.openssl.dev
|
pkgs.openssl.out
|
||||||
# ]);
|
pkgs.openssl.dev
|
||||||
# in
|
]);
|
||||||
rustPlatform.buildRustPackage rec {
|
in
|
||||||
|
build-asdf-system {
|
||||||
name = "tfcconnection";
|
name = "tfcconnection";
|
||||||
pname = "tfcconnection";
|
pname = "tfcconnection";
|
||||||
version = "0.0.1";
|
version = "0.0.1";
|
||||||
|
@ -39,52 +44,67 @@ rustPlatform.buildRustPackage rec {
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
# cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
|
# cargoHash = "sha256-jtBw4ahSl88L0iuCXxQgZVm1EcboWRJMNtjxLVTtzts=";
|
||||||
cargoLock = {
|
# cargoLock = {
|
||||||
lockFile = ./Cargo.lock;
|
# lockFile = ./Cargo.lock;
|
||||||
};
|
# };
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
makeWrapper
|
gcc
|
||||||
|
stdenv
|
||||||
|
gnumake
|
||||||
pkg-config
|
pkg-config
|
||||||
rustc
|
makeWrapper
|
||||||
cargo
|
# openssl
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = [
|
|
||||||
# rustPlatform
|
|
||||||
# clippy
|
|
||||||
# rustfmt
|
|
||||||
openssl
|
|
||||||
# openssl.out
|
# openssl.out
|
||||||
# openssl.dev
|
# openssl.dev
|
||||||
];
|
];
|
||||||
|
|
||||||
# nativeLibs = [
|
# buildInputs = [
|
||||||
# openssl
|
# # rustPlatform
|
||||||
# openssl.out
|
# # clippy
|
||||||
# openssl.dev
|
# # rustfmt
|
||||||
|
# # openssl
|
||||||
|
# # openssl.out
|
||||||
|
# # openssl.dev
|
||||||
|
# sbcl'
|
||||||
# ];
|
# ];
|
||||||
|
|
||||||
# lispLibs = with sbclPackages; [
|
nativeLibs = [
|
||||||
# hunchentoot
|
openssl
|
||||||
# dexador
|
openssl.out
|
||||||
# jzon
|
openssl.dev
|
||||||
# serapeum
|
];
|
||||||
# deploy
|
|
||||||
# spinneret
|
|
||||||
# lass
|
|
||||||
# cl-smtp
|
|
||||||
# ];
|
|
||||||
|
|
||||||
buildPhase = ''
|
lispLibs = with sbclPackages; [
|
||||||
export HOME=$(pwd)
|
hunchentoot
|
||||||
${cargo}/bin/cargo build
|
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 = ''
|
installPhase = ''
|
||||||
|
mkdir -pv $out
|
||||||
|
cp -r * $out
|
||||||
|
rm -fv $out/tfcserver
|
||||||
mkdir -p $out/bin
|
mkdir -p $out/bin
|
||||||
cp target/debug/tfcapi $out/bin
|
cp -v tfcserver $out/bin
|
||||||
wrapProgram $out/bin/tfcapi \
|
wrapProgram $out/bin/tfcserver \
|
||||||
--prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \
|
--prefix LD_LIBRARY_PATH : $LD_LIBRARY_PATH \
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShell = import ./shell.nix { inherit pkgs; };
|
devShell = import ./shell.nix { inherit pkgs; };
|
||||||
defaultPackage = pkgs.callPackage ./default.nix { };
|
defaultPackage = import ./default.nix { };
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,59 @@
|
||||||
document.getElementById('warning-email').style.height = '0';
|
document.getElementById('warning-email').style.height = '0';
|
||||||
document.getElementById('warning-email').style.margin = '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 = "http://localhost:4242/camp-form";
|
||||||
let base = "https://api.tfcconnection.org/camp-form";
|
/* let base = "https://api.tfcconnection.org/camp-form"; */
|
||||||
|
|
||||||
fetch(base, {
|
fetch(base, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
@ -61,6 +111,15 @@
|
||||||
document.getElementById('warning-email').style.visibility = 'hidden';
|
document.getElementById('warning-email').style.visibility = 'hidden';
|
||||||
document.getElementById('warning-email').style.height = '0';
|
document.getElementById('warning-email').style.height = '0';
|
||||||
document.getElementById('warning-email').style.margin = '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);
|
document.addEventListener('DOMContentLoaded', process);
|
||||||
</script>
|
</script>
|
||||||
|
@ -243,5 +302,26 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</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>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -77,8 +77,8 @@
|
||||||
// For use in dev
|
// For use in dev
|
||||||
// Can now start using this in production IF,
|
// Can now start using this in production IF,
|
||||||
// I get the server running on the server
|
// I get the server running on the server
|
||||||
let base = "https://api.tfcconnection.org/health-form";
|
/* let base = "https://api.tfcconnection.org/health-form"; */
|
||||||
/* let base = "http://localhost:4242/health-form"; */
|
let base = "http://localhost:4242/health-form";
|
||||||
fetch(base, {
|
fetch(base, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: data
|
body: data
|
||||||
|
|
|
@ -10,6 +10,7 @@ let
|
||||||
spinneret
|
spinneret
|
||||||
lass
|
lass
|
||||||
cl-smtp
|
cl-smtp
|
||||||
|
log4cl
|
||||||
pkgs.openssl
|
pkgs.openssl
|
||||||
pkgs.openssl.out
|
pkgs.openssl.out
|
||||||
pkgs.openssl.dev
|
pkgs.openssl.dev
|
||||||
|
|
|
@ -261,7 +261,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.to("Chris Cochrun <chris@tfcconnection.org>".parse().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)
|
.subject(email_subject)
|
||||||
.multipart(multi)
|
.multipart(multi)
|
||||||
{
|
{
|
||||||
|
|
118
src/main.lisp
118
src/main.lisp
|
@ -7,6 +7,7 @@
|
||||||
(require "spinneret")
|
(require "spinneret")
|
||||||
(require "lass")
|
(require "lass")
|
||||||
(require "cl-smtp")
|
(require "cl-smtp")
|
||||||
|
(require "log4cl")
|
||||||
|
|
||||||
(defpackage tfcserver
|
(defpackage tfcserver
|
||||||
(:use :cl :com.inuoe.jzon :spinneret :serapeum))
|
(:use :cl :com.inuoe.jzon :spinneret :serapeum))
|
||||||
|
@ -297,6 +298,48 @@ with the image attached to us"
|
||||||
(:td (trim-whitespace
|
(:td (trim-whitespace
|
||||||
(cdr row)))))))))))))
|
(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)
|
(defun mail-health-form (form attachment)
|
||||||
"Takes the form as an alist and sends a table formatted email
|
"Takes the form as an alist and sends a table formatted email
|
||||||
with the image attached"
|
with the image attached"
|
||||||
|
@ -342,46 +385,47 @@ with the image attached"
|
||||||
(defun define-post-form-handler (uri mail-function)
|
(defun define-post-form-handler (uri mail-function)
|
||||||
"Take a uri and a mailer function and define a handler in hunchentoot
|
"Take a uri and a mailer function and define a handler in hunchentoot
|
||||||
for forms to POST to."
|
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")
|
(setf (hunchentoot:content-type*) "plain/text")
|
||||||
(let* ((request-type (hunchentoot:request-method hunchentoot:*request*))
|
(let* ((request-type (hunchentoot:request-method hunchentoot:*request*))
|
||||||
(post-data (hunchentoot:post-parameters* hunchentoot:*request*))
|
(post-data (hunchentoot:post-parameters* hunchentoot:*request*))
|
||||||
(attachment nil)
|
(attachment nil)
|
||||||
(first-name nil)
|
(first-name nil)
|
||||||
(last-name nil))
|
(last-name nil))
|
||||||
(cond ((eq request-type :get) nil)
|
(cond ((eq request-type :get) nil)
|
||||||
((eq request-type :post)
|
((eq request-type :post)
|
||||||
(loop :for d :in post-data
|
(loop :for d :in post-data
|
||||||
:do (progn
|
:do (progn
|
||||||
(uiop:println d)
|
(uiop:println d)
|
||||||
(if (string= "firstname" (car d))
|
(if (string= "firstname" (car d))
|
||||||
(progn
|
(progn
|
||||||
(uiop:println (cdr d))
|
(uiop:println (cdr d))
|
||||||
(setf first-name (cdr d))))
|
(setf first-name (cdr d))))
|
||||||
(if (string= "lastname" (car d))
|
(if (string= "lastname" (car d))
|
||||||
(progn
|
(progn
|
||||||
(uiop:println (cdr d))
|
(uiop:println (cdr d))
|
||||||
(setf last-name (cdr d))))
|
(setf last-name (cdr d))))
|
||||||
(if (string= "image" (car d))
|
(if (string= "image" (car d))
|
||||||
(let ((path (path-join
|
(let ((path (path-join
|
||||||
hunchentoot:*tmp-directory*
|
hunchentoot:*tmp-directory*
|
||||||
(format nil "~a_~a.~a" first-name last-name
|
(format nil "~a_~a.~a" first-name last-name
|
||||||
(cadr (uiop:split-string
|
(cadr (uiop:split-string
|
||||||
(car (last d 2)) :separator "."))))))
|
(car (last d 2)) :separator "."))))))
|
||||||
(uiop:copy-file
|
(uiop:copy-file
|
||||||
(cadr d)
|
(cadr d)
|
||||||
(path-join
|
(path-join
|
||||||
hunchentoot:*tmp-directory*
|
hunchentoot:*tmp-directory*
|
||||||
(format nil "~a_~a.~a" first-name last-name
|
(format nil "~a_~a.~a" first-name last-name
|
||||||
(cadr (uiop:split-string
|
(cadr (uiop:split-string
|
||||||
(car (last d 2)) :separator ".")))))
|
(car (last d 2)) :separator ".")))))
|
||||||
(setf attachment path)
|
(setf attachment path)
|
||||||
(uiop:println attachment)))))
|
(uiop:println attachment)))))
|
||||||
(if (funcall mail-function post-data attachment)
|
(if (funcall mail-function post-data attachment)
|
||||||
(format nil "thankyou")))))))
|
(format nil "thankyou")))))))
|
||||||
|
|
||||||
(define-post-form-handler "/mt-form" 'mail-mt-form)
|
(define-post-form-handler "/mt-form" 'mail-mt-form)
|
||||||
(define-post-form-handler "/health-form" 'mail-health-form)
|
(define-post-form-handler "/health-form" 'mail-health-form)
|
||||||
|
(define-post-form-handler "/camp-form" 'mail-camp-form)
|
||||||
|
|
||||||
(defun main ()
|
(defun main ()
|
||||||
(start-server 4242)
|
(start-server 4242)
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
"bordeaux-threads"
|
"bordeaux-threads"
|
||||||
"spinneret"
|
"spinneret"
|
||||||
"lass"
|
"lass"
|
||||||
|
"log4cl"
|
||||||
"cl-smtp") ;; <== list of Quicklisp dependencies
|
"cl-smtp") ;; <== list of Quicklisp dependencies
|
||||||
:components ((:module "src"
|
:components ((:module "src"
|
||||||
:components
|
:components
|
||||||
|
|
Loading…
Reference in a new issue