better style

This commit is contained in:
dachus 2023-02-16 12:30:59 -06:00
parent e882d40579
commit 64ca1fbd3a

View File

@ -1,13 +1,11 @@
|= [[now=@da eny=@uvJ byk=beak] ~ ~]
|= [authenticated=? =request:http]
^- simple-payload:http
:: TODO this code is ugly. Either:
:: split this into two generators
:: put the logic in a mark
=/ turl=tape (trip url.request)
=/ turl-len (lent turl)
:: TODO all the text parsing here is super ugly, might
:: be a better way to do it, but basically just detect
:: .md or .html, manipulate the scry-path, add
:: proper headers, and that's it.
=/ [content-type=@t scry-path=@t]
=^ content-type=@t url.request
=+ md=(find ".md" turl)
?: &(?=(^ md) =((add u.md 3) turl-len))
:- 'text/plain; charset=utf-8'
@ -18,13 +16,13 @@
(crip (weld "/html" (swag [0 (sub turl-len 5)] turl)))
(crip (weld "/html" turl))
::
^- [response-header:http (unit octs)]
^- simple-payload:http
:- [200 ['Content-Type' content-type]~]
%- some
%- as-octs:mimes:html
.^ @t %gx
;: weld
/(scot %p p.byk)/blog/(scot r.byk)
(rash scry-path stap) /noun
(rash url.request stap) /noun
==
==