factor/apps/furnace-pastebin/pastebin.factor

76 lines
1.9 KiB
Factor
Raw Normal View History

2006-09-13 00:48:04 -04:00
IN: furnace:pastebin
USING: calendar kernel namespaces sequences furnace hashtables
math ;
2006-10-15 23:59:04 -04:00
TUPLE: paste n summary author channel contents date annotations ;
2006-09-13 00:48:04 -04:00
2006-10-15 23:59:04 -04:00
TUPLE: annotation summary author contents ;
C: paste ( summary author channel contents -- paste )
V{ } clone over set-paste-annotations
2006-09-13 00:48:04 -04:00
[ set-paste-contents ] keep
[ set-paste-author ] keep
2006-10-15 23:59:04 -04:00
[ set-paste-channel ] keep
2006-09-13 00:48:04 -04:00
[ set-paste-summary ] keep ;
TUPLE: pastebin pastes ;
C: pastebin ( -- pastebin )
V{ } clone over set-pastebin-pastes ;
: add-paste ( paste pastebin -- )
now timestamp>http-string pick set-paste-date
dup pastebin-pastes length pick set-paste-n
pastebin-pastes push ;
2006-10-15 23:59:04 -04:00
<pastebin> pastebin set-global
2006-09-13 00:48:04 -04:00
: get-paste ( n -- paste )
2006-10-15 23:59:04 -04:00
pastebin get pastebin-pastes nth ;
2006-09-13 00:48:04 -04:00
: show-paste ( n -- )
2006-10-19 18:09:43 -04:00
get-paste "show-paste" "Paste" render-page ;
2006-09-13 00:48:04 -04:00
2006-10-15 23:59:04 -04:00
\ show-paste { { "n" v-number } } define-action
2006-09-13 00:48:04 -04:00
: new-paste ( -- )
2006-10-19 18:09:43 -04:00
f "new-paste" "New paste" render-page ;
2006-09-13 00:48:04 -04:00
\ new-paste { } define-action
2006-10-15 23:59:04 -04:00
: submit-paste ( summary author channel contents -- )
<paste> pastebin get-global add-paste ;
2006-09-13 00:48:04 -04:00
\ submit-paste {
2006-10-15 23:59:04 -04:00
{ "summary" v-required }
{ "author" v-required }
{ "channel" "#concatenative" v-default }
{ "contents" v-required }
2006-09-13 00:48:04 -04:00
} define-action
: paste-list ( -- )
[
[ show-paste ] "show-paste-quot" set
[ new-paste ] "new-paste-quot" set
2006-10-19 18:09:43 -04:00
pastebin get "paste-list" "Pastebin" render-page
2006-09-13 00:48:04 -04:00
] with-scope ;
\ paste-list { } define-action
\ submit-paste [ paste-list ] define-redirect
2006-10-15 23:59:04 -04:00
: annotate-paste ( paste# summary author contents -- )
<annotation> swap get-paste paste-annotations push ;
\ annotate-paste {
{ "n" v-required v-number }
{ "summary" v-required }
{ "author" v-required }
{ "contents" v-required }
} define-action
\ annotate-paste [ "n" show-paste ] define-redirect
2006-11-28 21:57:29 -05:00
"pastebin" "paste-list" "apps/furnace-pastebin" web-app