contact: finish %octt implementation

This commit is contained in:
Logan Allen 2020-04-21 19:59:03 -04:00
parent 2f7e8fd811
commit f6a2f7f83c
4 changed files with 36 additions and 37 deletions

View File

@ -8,6 +8,19 @@
state-one
==
::
+$ rolodex-0 (map path contacts-0)
+$ contacts-0 (map ship contact-0)
+$ avatar-0 [content-type=@t octs=[p=@ud q=@t]]
+$ contact-0
$: nickname=@t
email=@t
phone=@t
website=@t
notes=@t
color=@ux
avatar=(unit avatar-0)
==
::
+$ state-zero
$: %0
rolodex=rolodex-0

View File

@ -181,21 +181,16 @@
::
:: avatar images
::
:: [%'~groups' %avatar @ *]
:: =/ pax=path `path`t.t.site.url
:: ?~ pax not-found:gen
:: =/ pas `path`(flop pax)
:: ?~ pas not-found:gen
:: =/ pav `path`(flop t.pas)
:: ~& pav+pav
:: ~& name+name
:: =/ contact (contact-scry `path`(weld pav [name]~))
:: ?~ contact not-found:gen
:: ?~ avatar.u.contact not-found:gen
:: =* avatar u.avatar.u.contact
:: =/ decoded (de:base64 q.octs.avatar)
:: ?~ decoded not-found:gen
:: [[200 ['content-type' content-type.avatar]~] `u.decoded]
[%'~groups' %avatar @ *]
=/ =path (flop t.t.site.url)
?~ path not-found:gen
=/ contact (contact-scry `^path`(snoc (flop t.path) name))
?~ contact not-found:gen
?~ avatar.u.contact not-found:gen
?. ?=(%octt -.u.avatar.u.contact) not-found:gen
=/ max-3-days ['cache-control' 'max-age=259200']
=/ content-type ['content-type' content-type.u.avatar.u.contact]
[[200 [content-type max-3-days ~]] `octs.u.avatar.u.contact]
::
[%'~groups' *] (html-response:gen index)
==

View File

@ -1,4 +1,5 @@
/- *contact-view
/+ base64
|%
++ nu :: parse number as hex
|= jon/json
@ -62,12 +63,10 @@
:- %s
%- crip
%- zing
:~ "/~groups/img"
:~ "/~groups/avatar"
(trip (spat path))
"/"
(trip (scot %p ship))
"."
(trip file-extension.u.avat)
==
::
%url s+url.u.avat
@ -197,8 +196,15 @@
++ avat
|= jon=json
^- avatar
=< (parse-json jon)
|%
|^
=/ =avatar (parse-json jon)
?- -.avatar
%url avatar
%octt
=. octs.avatar (need (de:base64 q.octs.avatar))
avatar
==
::
++ parse-json
%- of:dejs:format
:~ [%octt octt]
@ -207,7 +213,7 @@
::
++ octt
%- ot:dejs:format
:~ [%file-extension so:dejs:format]
:~ [%content-type so:dejs:format]
[%octs octet]
==
::

View File

@ -1,27 +1,12 @@
/- *identity
|%
+$ rolodex-0 (map path contacts-0)
+$ rolodex (map path contacts)
::
+$ contacts-0 (map ship contact-0)
+$ contacts (map ship contact)
::
+$ avatar-0 [content-type=@t octs=[p=@ud q=@t]]
+$ avatar
$% [%octt [file-extension=@t octs=[p=@ud q=@t]]]
$% [%octt content-type=@t octs=[p=@ud q=@t]]
[%url url=@t]
==
::
+$ contact-0
$: nickname=@t
email=@t
phone=@t
website=@t
notes=@t
color=@ux
avatar=(unit avatar-0)
==
::
+$ contact
$: nickname=@t
email=@t