Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
Handle saving and compiling the uploaded user code.
Browse files Browse the repository at this point in the history
  • Loading branch information
wmealing committed Oct 29, 2023
1 parent 9e985ed commit adc1efa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion priv/live.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ <h2>LFE Code </h2>
</p>

<p>
<button class="wide-button" hx-get="/livetest"> Test this code </button>
<a href="/go"> Test this code </a>
</p>

</div>
Expand Down
1 change: 1 addition & 0 deletions spawnfest-manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Note:
- No AI was used in the making of this project.
- Github actions run tests !
- Github actions builds (but doesn't publish) a container, thats on my list.
- compiler errors dont make it back to the user, this is a big one.

Barista isnt showing what happens to error 500s! I had to bruteforce error conditions !

Expand Down
12 changes: 8 additions & 4 deletions src/barista-routes.lfe
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,9 @@
(defun write-to-file (filename data)
(file:write_file filename data ))


;;compile a file
(defun compile-file (filename)
(: lfe-shell c filename))
(: lfe_comp file filename))

;; compile it.
(defun compile-data (data)
Expand Down Expand Up @@ -86,14 +85,19 @@

('PUT #"/live-demo/user-lfe"
(progn
(compile-data (barista-request:get-data req))
;; (logger:alert (barista-request:get-data req))
(logger:alert (maps:get "user-lfe" (barista-request:get-data req)))
(write-to-file "/tmp/user-demo.lfe" (maps:get "user-lfe" (barista-request:get-data req)))
(compile-file "/tmp/user-demo.lfe")
(barista-response:ok (erlang:binary_to_list (template:load "template-lfe.html")))))

('GET #"/live-demo"
(progn
(barista-response:ok (erlang:binary_to_list (template:load "live.html")))))


('GET #"/go"
(progn
(barista-response:ok (erlang:binary_to_list (template:load "user/live.html")))))

('GET #"/about"
(progn
Expand Down

0 comments on commit adc1efa

Please sign in to comment.