     } assoc-union format nl ;
 
 : hacker-news. ( -- )
-    25 hacker-news-items
+    30 hacker-news-recent-items
     banner.
     [ 1 + post. ] each-index ;

! Copyright (C) 2012 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors assocs classes.tuple colors.constants
colors.hex combinators formatting fry hashtables http.client io
io.styles json json.reader kernel make math math.parser
sequences splitting ui urls ;
IN: hacker-news

<PRIVATE

: json-null>f ( obj -- obj/f )
    dup json-null = [ drop f ] when ;

: hacker-news-items ( n -- seq )
    [
        "https://hacker-news.firebaseio.com/v0/topstories.json?print=pretty"
        http-get nip json>
    ] dip head
    [
        number>string
        "https://hacker-news.firebaseio.com/v0/item/" ".json?print=pretty" surround
        http-get nip json>
    ] parallel-map ;

: write-title ( title url -- )
    '[

        [ dup "by" of [ " by " write-text [ "by" of ] [ post>user-url ] bi write-link ] [ drop ] if ]
        ! [ dup postedAgo>> [ " " write-text postedAgo>> write-text ] [ drop ] if ]
        [
            dup "decendants" of [
                " | " write-text
                [ "descendants" of [ "discuss" ] [ "%d comments" sprintf ] if-zero ]
                [ post>comments-url ] bi write-link
            ] [
                drop
            ] if nl nl
        ]
    } cleave ;

