mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-12-11 08:55:23 +03:00
Merge branch 'os1-avatar' (#2776)
* origin/os1-avatar: contact-view: redirect upon url case of avatar contact: finish %octt implementation contacts: added "url" avatar support and finished "octet" avatar fetching support Signed-off-by: Matilde Park <matilde@tlon.io>
This commit is contained in:
commit
28c9141f94
@ -5,18 +5,33 @@
|
||||
+$ card card:agent:gall
|
||||
+$ versioned-state
|
||||
$% state-zero
|
||||
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=rolodex-0
|
||||
==
|
||||
+$ diff
|
||||
$% [%contact-update contact-update]
|
||||
+$ state-one
|
||||
$: %1
|
||||
=rolodex
|
||||
==
|
||||
--
|
||||
::
|
||||
=| state-zero
|
||||
=| state-one
|
||||
=* state -
|
||||
%- agent:dbug
|
||||
^- agent:gall
|
||||
@ -30,8 +45,26 @@
|
||||
++ on-init on-init:def
|
||||
++ on-save !>(state)
|
||||
++ on-load
|
||||
|= old=vase
|
||||
`this(state !<(state-zero old))
|
||||
|= old-vase=vase
|
||||
=/ old !<(versioned-state old-vase)
|
||||
?: ?=(%1 -.old)
|
||||
[~ this(state old)]
|
||||
=/ new-rolodex=^rolodex
|
||||
%- ~(run by rolodex.old)
|
||||
|= cons=contacts-0
|
||||
^- contacts
|
||||
%- ~(run by cons)
|
||||
|= con=contact-0
|
||||
^- contact
|
||||
:* nickname.con
|
||||
email.con
|
||||
phone.con
|
||||
website.con
|
||||
notes.con
|
||||
color.con
|
||||
~
|
||||
==
|
||||
[~ this(state [%1 new-rolodex])]
|
||||
::
|
||||
++ on-poke
|
||||
|= [=mark =vase]
|
||||
|
@ -181,21 +181,19 @@
|
||||
::
|
||||
:: 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
|
||||
?- -.u.avatar.u.contact
|
||||
%url [[307 ['location' url.u.avatar.u.contact]~] ~]
|
||||
%octt
|
||||
=/ 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)
|
||||
==
|
||||
|
@ -1,4 +1,5 @@
|
||||
/- *contact-view, *contact-hook
|
||||
/+ base64
|
||||
|%
|
||||
++ nu :: parse number as hex
|
||||
|= jon/json
|
||||
@ -26,38 +27,34 @@
|
||||
|= [pax=^path =contacts]
|
||||
^- [cord json]
|
||||
:- (spat pax)
|
||||
(contacts-to-json contacts)
|
||||
(contacts-to-json pax contacts)
|
||||
::
|
||||
++ contacts-to-json
|
||||
|= con=contacts
|
||||
|= [=path con=contacts]
|
||||
^- json
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
%- pairs:enjs:format
|
||||
%+ turn ~(tap by con)
|
||||
|= [shp=^ship =contact]
|
||||
|= [=ship =contact]
|
||||
^- [cord json]
|
||||
:- (crip (slag 1 (scow %p shp)))
|
||||
(contact-to-json contact)
|
||||
[(crip (slag 1 (scow %p ship))) (contact-to-json path ship contact)]
|
||||
::
|
||||
++ contact-to-json
|
||||
|= con=contact
|
||||
|= [=path =ship con=contact]
|
||||
^- json
|
||||
=, enjs:format
|
||||
%- pairs
|
||||
%- pairs:enjs:format
|
||||
:~ [%nickname s+nickname.con]
|
||||
[%email s+email.con]
|
||||
[%phone s+phone.con]
|
||||
[%website s+website.con]
|
||||
[%notes s+notes.con]
|
||||
[%color s+(scot %ux color.con)]
|
||||
[%avatar s+'TODO']
|
||||
[%avatar (avatar-to-json path ship avatar.con)]
|
||||
==
|
||||
::
|
||||
++ edit-to-json
|
||||
|= edit=edit-field
|
||||
|= [=path =ship edit=edit-field]
|
||||
^- json
|
||||
=, enjs:format
|
||||
%+ frond -.edit
|
||||
%+ frond:enjs:format -.edit
|
||||
?- -.edit
|
||||
%nickname s+nickname.edit
|
||||
%email s+email.edit
|
||||
@ -65,7 +62,25 @@
|
||||
%website s+website.edit
|
||||
%notes s+notes.edit
|
||||
%color s+(scot %ux color.edit)
|
||||
%avatar s+'TODO'
|
||||
%avatar (avatar-to-json path ship avatar.edit)
|
||||
==
|
||||
::
|
||||
++ avatar-to-json
|
||||
|= [=path =ship avat=(unit avatar)]
|
||||
^- json
|
||||
?~ avat ~
|
||||
?- -.u.avat
|
||||
%octt
|
||||
:- %s
|
||||
%- crip
|
||||
%- zing
|
||||
:~ "/~groups/avatar"
|
||||
(trip (spat path))
|
||||
"/"
|
||||
(trip (scot %p ship))
|
||||
==
|
||||
::
|
||||
%url s+url.u.avat
|
||||
==
|
||||
::
|
||||
++ update-to-json
|
||||
@ -84,7 +99,7 @@
|
||||
%- pairs
|
||||
:~ [%path (path path.upd)]
|
||||
[%ship (ship ship.upd)]
|
||||
[%contact (contact-to-json contact.upd)]
|
||||
[%contact (contact-to-json path.upd ship.upd contact.upd)]
|
||||
==
|
||||
?: ?=(%remove -.upd)
|
||||
:- %remove
|
||||
@ -97,7 +112,7 @@
|
||||
%- pairs
|
||||
:~ [%path (path path.upd)]
|
||||
[%ship (ship ship.upd)]
|
||||
[%edit-field (edit-to-json edit-field.upd)]
|
||||
[%edit-field (edit-to-json path.upd ship.upd edit-field.upd)]
|
||||
==
|
||||
[*@t *^json]
|
||||
==
|
||||
@ -190,10 +205,31 @@
|
||||
==
|
||||
::
|
||||
++ avat
|
||||
%- ot:dejs:format
|
||||
:~ [%content-type so:dejs:format]
|
||||
[%octs octet]
|
||||
|= jon=json
|
||||
^- avatar
|
||||
|^
|
||||
=/ =avatar (parse-json jon)
|
||||
?- -.avatar
|
||||
%url avatar
|
||||
%octt
|
||||
=. octs.avatar (need (de:base64 q.octs.avatar))
|
||||
avatar
|
||||
==
|
||||
::
|
||||
++ parse-json
|
||||
%- of:dejs:format
|
||||
:~ [%octt octt]
|
||||
[%url url]
|
||||
==
|
||||
::
|
||||
++ octt
|
||||
%- ot:dejs:format
|
||||
:~ [%content-type so:dejs:format]
|
||||
[%octs octet]
|
||||
==
|
||||
::
|
||||
++ url so:dejs:format
|
||||
--
|
||||
::
|
||||
++ cont
|
||||
%- ot:dejs:format
|
||||
|
@ -1,10 +1,11 @@
|
||||
/- *identity
|
||||
|%
|
||||
+$ rolodex (map path contacts)
|
||||
::
|
||||
+$ contacts (map ship contact)
|
||||
::
|
||||
+$ avatar [content-type=@t octs=[p=@ud q=@t]]
|
||||
+$ rolodex (map path contacts)
|
||||
+$ contacts (map ship contact)
|
||||
+$ avatar
|
||||
$% [%octt content-type=@t octs=[p=@ud q=@t]]
|
||||
[%url url=@t]
|
||||
==
|
||||
::
|
||||
+$ contact
|
||||
$: nickname=@t
|
||||
|
@ -379,15 +379,6 @@ export class ContactCard extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
let removeImage = hasAvatar ? (
|
||||
<div>
|
||||
<button className="f9 black pointer db"
|
||||
onClick={() => this.setField("removeAvatar")}>
|
||||
Remove photo
|
||||
</button>
|
||||
</div>
|
||||
) : "";
|
||||
|
||||
let avatar = (hasAvatar)
|
||||
? <img className="dib h-auto" width={128} src={props.contact.avatar} />
|
||||
: <Sigil
|
||||
@ -401,7 +392,6 @@ export class ContactCard extends Component {
|
||||
<div className="w-100 mw6 tc">
|
||||
{avatar}
|
||||
{sigilColor}
|
||||
{removeImage}
|
||||
<div className="w-100 pt8 pb8 lh-copy tl">
|
||||
<p className="f9 gray2">Ship Name</p>
|
||||
<p className="f8 mono">~{props.ship}</p>
|
||||
|
Loading…
Reference in New Issue
Block a user