1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors arrays colors.constants definitions help.markup
4 help.stylesheet io io.styles kernel literals namespaces parser random
10 tips [ V{ } clone ] initialize
12 TUPLE: tip < identity-tuple content loc ;
14 M: tip forget* tips get remove-eq! drop ;
18 M: tip set-where loc<< ;
20 : <tip> ( content -- tip ) f tip boa ;
22 : add-tip ( tip -- ) tips get push ;
25 parse-definition >array <tip>
26 [ save-location ] [ add-tip ] bi ;
28 : a-tip ( -- tip ) tips get random ;
30 SYMBOL: tip-of-the-day-style
33 { page-color COLOR: lavender }
35 { wrap-margin $ wrap-margin-full }
36 } tip-of-the-day-style set-global
38 : $tip-title ( tip -- )
41 [ "Tip of the day" ] dip write-object
45 : $tip-of-the-day ( element -- )
48 tip-of-the-day-style get
51 a-tip [ $tip-title ] [ content>> print-element nl ] bi
52 "— " print-element "all-tips-of-the-day" ($link)
57 : tip-of-the-day. ( -- ) { $tip-of-the-day } print-content nl ;
59 : $tips-of-the-day ( element -- )
60 drop tips get [ nl nl ] [ content>> print-element ] interleave ;
62 INSTANCE: tip definition-mixin