]> gitweb.factorcode.org Git - factor.git/commitdiff
hacker-news: add christmas color
authorDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Dec 2021 16:18:29 +0000 (10:18 -0600)
committerDoug Coleman <doug.coleman@gmail.com>
Sat, 25 Dec 2021 16:18:50 +0000 (10:18 -0600)
extra/hacker-news/hacker-news.factor

index 734e7bbf5338f04bc5d70f351392118f1ad79710..ec9a204b7f89ea37c4ed56944f728b0447559b3b 100644 (file)
@@ -2,9 +2,9 @@
 ! See http://factorcode.org/license.txt for BSD license.
 
 USING: accessors assocs calendar calendar.format
-colors.constants colors.hex combinators concurrency.combinators
-formatting fry hashtables http.client io io.styles json.reader
-kernel make math math.parser sequences ui urls vocabs ;
+calendar.holidays.us colors.constants colors.hex combinators
+concurrency.combinators formatting hashtables http.client io
+io.styles json.reader kernel make math sequences ui urls ;
 
 IN: hacker-news
 
@@ -83,14 +83,19 @@ PRIVATE>
         ]
     } cleave ;
 
+: background-color ( -- color )
+    now dup christmas-day same-day?
+    HEXCOLOR: bc2c21 HEXCOLOR: ff6600 ? ;
+
 : banner. ( str -- )
     "http://news.ycombinator.com" >url presented associate
     H{
         { font-size 20 }
         { font-style bold }
-        { background HEXCOLOR: ff6600 }
         { foreground COLOR: black }
-    } assoc-union format nl ;
+    } assoc-union
+    background-color background pick set-at
+    format nl ;
 
 : hacker-news-feed. ( seq -- )
     [ 1 + post. ] each-index ;