1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: parser arrays namespaces sequences random help.markup help.stylesheet
4 kernel io io.styles colors.constants definitions accessors ;
9 tips [ V{ } clone ] initialize
11 TUPLE: tip < identity-tuple content loc ;
13 M: tip forget* tips get remove-eq! drop ;
17 M: tip set-where loc<< ;
19 : <tip> ( content -- tip ) f tip boa ;
21 : add-tip ( tip -- ) tips get push ;
24 parse-definition >array <tip>
25 [ save-location ] [ add-tip ] bi ;
27 : a-tip ( -- tip ) tips get random ;
29 SYMBOL: tip-of-the-day-style
32 { page-color COLOR: lavender }
35 } tip-of-the-day-style set-global
37 : $tip-title ( tip -- )
40 [ "Tip of the day" ] dip write-object
44 : $tip-of-the-day ( element -- )
47 tip-of-the-day-style get
50 a-tip [ $tip-title ] [ content>> print-element nl ] bi
51 "— " print-element "all-tips-of-the-day" ($link)
56 : tip-of-the-day. ( -- ) { $tip-of-the-day } print-content nl ;
58 : $tips-of-the-day ( element -- )
59 drop tips get [ nl nl ] [ content>> print-element ] interleave ;
61 INSTANCE: tip definition