1 USING: accessors continuations fry http.client images.loader
2 images.loader.private images.viewer io io.styles kernel memoize
3 prettyprint sequences twitter assocs ;
4 IN: twitter.prettyprint
6 MEMO: load-http-image ( url -- image/f )
8 [ http-get nip ] [ image-class ] bi load-image*
11 : user-image ( user -- image/f )
12 profile-image-url>> load-http-image ;
14 CONSTANT: tweet-table-style
15 H{ { table-gap { 5 5 } } }
17 CONSTANT: tweet-username-style
22 CONSTANT: tweet-text-style
24 { font-name "sans-serif" }
29 CONSTANT: tweet-metadata-style
34 : profile. ( user -- )
37 [ dup "profile_image_url" of load-http-image image. ] with-cell
39 tweet-username-style [
40 dup "name" of write nl
41 dup "screen_name" of write
48 : tweet. ( status -- )
51 [ dup user>> user-image [ image. ] when* ] with-cell
53 H{ { wrap-margin 600 } } [
55 tweet-username-style [
56 dup user>> screen-name>> write
60 tweet-metadata-style [
61 dup created-at>> write
72 : user-profile. ( user -- ) user-profile profile. ;
73 : friends-timeline. ( -- ) friends-timeline [ tweet. ] each ;
74 : public-timeline. ( -- ) public-timeline [ tweet. ] each ;
75 : user-timeline. ( user -- ) user-timeline [ tweet. ] each ;
76 : home-timeline. ( -- ) home-timeline [ tweet. ] each ;
77 : mentions-timeline. ( -- ) mentions-timeline [ tweet. ] each ;