]> gitweb.factorcode.org Git - factor.git/blob - basis/help/tips/tips.factor
Add silly 'tip of the day' feature, and 'recently visited' list to UI browser home...
[factor.git] / basis / help / tips / tips.factor
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 kernel io
4 io.styles colors.constants ;
5 IN: help.tips
6
7 SYMBOL: tips
8
9 tips [ V{ } clone ] initialize
10
11 SYNTAX: TIP: parse-definition >array tips get push ;
12
13 : a-tip ( -- tip ) tips get random ;
14
15 SYMBOL: tip-of-the-day-style
16
17 H{
18     { page-color COLOR: lavender }
19     { border-width 5 }
20     { wrap-margin 500 }
21 } tip-of-the-day-style set-global
22
23 : $tip-of-the-day ( element -- )
24     drop
25     [
26         tip-of-the-day-style get
27         [
28             last-element off
29             "Tip of the day" $heading a-tip print-element nl
30             "— " print-element "all-tips-of-the-day" ($link)
31         ]
32         with-nesting
33     ] ($heading) ;
34
35 : tip-of-the-day. ( -- ) { $tip-of-the-day } print-content nl ;
36
37 : $tips-of-the-day ( element -- )
38     drop tips get [ nl nl ] [ print-element ] interleave ;