reddit: adding colors to subreddit-top.
parent
988e2ee4a9
commit
2c0ff7473d
|
@ -1,9 +1,9 @@
|
||||||
! Copyright (C) 2011-2012 John Benediktsson
|
! Copyright (C) 2011-2012 John Benediktsson
|
||||||
! See http://factorcode.org/license.txt for BSD license
|
! See http://factorcode.org/license.txt for BSD license
|
||||||
|
|
||||||
USING: accessors assocs calendar classes.tuple combinators
|
USING: accessors assocs calendar classes.tuple colors.constants
|
||||||
formatting http.client json json.reader kernel make math
|
colors.hex combinators formatting http.client io io.styles json
|
||||||
math.statistics sequences urls ;
|
json.reader kernel make math math.statistics sequences urls ;
|
||||||
|
|
||||||
IN: reddit
|
IN: reddit
|
||||||
|
|
||||||
|
@ -93,11 +93,27 @@ PRIVATE>
|
||||||
: subreddit-links ( subreddit -- links )
|
: subreddit-links ( subreddit -- links )
|
||||||
(subreddit) data>> [ url>> ] map ;
|
(subreddit) data>> [ url>> ] map ;
|
||||||
|
|
||||||
|
<PRIVATE
|
||||||
|
|
||||||
|
: write-title ( str -- )
|
||||||
|
H{ { foreground COLOR: blue } } format ;
|
||||||
|
|
||||||
|
: write-text ( str -- )
|
||||||
|
H{ { foreground HEXCOLOR: 888888 } } format ;
|
||||||
|
|
||||||
|
: write-url ( str -- )
|
||||||
|
dup >url H{
|
||||||
|
{ font-name "monospace" }
|
||||||
|
{ foreground COLOR: dark-green }
|
||||||
|
} [ write-object ] with-style nl ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
: subreddit-top ( subreddit -- )
|
: subreddit-top ( subreddit -- )
|
||||||
(subreddit) data>> [
|
(subreddit) data>> [
|
||||||
1 + "%2d. " printf {
|
1 + "%2d. " sprintf write-text {
|
||||||
[ title>> ]
|
[ title>> write-title nl ]
|
||||||
[ url>> ]
|
[ " " write url>> write-url ]
|
||||||
[ score>> ]
|
[ score>> ]
|
||||||
[ num_comments>> ]
|
[ num_comments>> ]
|
||||||
[
|
[
|
||||||
|
@ -106,8 +122,8 @@ PRIVATE>
|
||||||
]
|
]
|
||||||
[ author>> ]
|
[ author>> ]
|
||||||
} cleave
|
} cleave
|
||||||
"%s\n %s\n %d points, %d comments, posted %s by %s\n\n"
|
" %d points, %d comments, posted %s by %s\n\n"
|
||||||
printf
|
sprintf write-text
|
||||||
] each-index ;
|
] each-index ;
|
||||||
|
|
||||||
: domain-stats ( domain -- stats )
|
: domain-stats ( domain -- stats )
|
||||||
|
|
Loading…
Reference in New Issue