2 USING: calendar kernel namespaces sequences furnace hashtables
5 TUPLE: paste n summary author channel contents date annotations ;
7 TUPLE: annotation summary author contents ;
9 C: paste ( summary author channel contents -- paste )
10 V{ } clone over set-paste-annotations
11 [ set-paste-contents ] keep
12 [ set-paste-author ] keep
13 [ set-paste-channel ] keep
14 [ set-paste-summary ] keep ;
16 TUPLE: pastebin pastes ;
18 C: pastebin ( -- pastebin )
19 V{ } clone over set-pastebin-pastes ;
21 : add-paste ( paste pastebin -- )
22 now timestamp>http-string pick set-paste-date
23 dup pastebin-pastes length pick set-paste-n
24 pastebin-pastes push ;
26 <pastebin> pastebin set-global
28 : get-paste ( n -- paste )
29 pastebin get pastebin-pastes nth ;
32 get-paste "show-paste" "Paste" render-page ;
34 \ show-paste { { "n" v-number } } define-action
37 f "new-paste" "New paste" render-page ;
39 \ new-paste { } define-action
41 : submit-paste ( summary author channel contents -- )
42 <paste> pastebin get-global add-paste ;
45 { "summary" v-required }
46 { "author" v-required }
47 { "channel" "#concatenative" v-default }
48 { "contents" v-required }
53 [ show-paste ] "show-paste-quot" set
54 [ new-paste ] "new-paste-quot" set
56 pastebin get "paste-list" "Pastebin" render-page
59 \ paste-list { } define-action
61 \ submit-paste [ paste-list ] define-redirect
63 : annotate-paste ( paste# summary author contents -- )
64 <annotation> swap get-paste paste-annotations push ;
67 { "n" v-required v-number }
68 { "summary" v-required }
69 { "author" v-required }
70 { "contents" v-required }
73 \ annotate-paste [ "n" show-paste ] define-redirect
75 "pastebin" "paste-list" "apps/furnace-pastebin" web-app