2007-12-06 00:06:34 -05:00
|
|
|
USING: calendar furnace furnace.validator io.files kernel
|
2007-12-06 00:22:35 -05:00
|
|
|
namespaces sequences store http.server.responders html ;
|
2007-11-07 15:01:42 -05:00
|
|
|
IN: webapps.pastebin
|
|
|
|
|
|
|
|
TUPLE: pastebin pastes ;
|
|
|
|
|
|
|
|
: <pastebin> ( -- pastebin )
|
|
|
|
V{ } clone pastebin construct-boa ;
|
|
|
|
|
2007-12-06 00:06:34 -05:00
|
|
|
TUPLE: paste
|
|
|
|
summary author channel mode contents date
|
|
|
|
annotations n ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
2007-12-06 00:06:34 -05:00
|
|
|
: <paste> ( summary author channel mode contents -- paste )
|
|
|
|
f V{ } clone f paste construct-boa ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
2007-12-06 00:06:34 -05:00
|
|
|
TUPLE: annotation summary author mode contents ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
|
|
|
C: <annotation> annotation
|
|
|
|
|
|
|
|
SYMBOL: store
|
|
|
|
|
|
|
|
"pastebin.store" resource-path load-store store set-global
|
|
|
|
|
|
|
|
<pastebin> \ pastebin store get store-variable
|
|
|
|
|
|
|
|
: get-paste ( n -- paste )
|
|
|
|
pastebin get pastebin-pastes nth ;
|
|
|
|
|
|
|
|
: show-paste ( n -- )
|
2007-12-06 00:22:35 -05:00
|
|
|
serving-html
|
|
|
|
get-paste
|
|
|
|
[ "show-paste" render-component ] with-html-stream ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
|
|
|
\ show-paste { { "n" v-number } } define-action
|
|
|
|
|
|
|
|
: new-paste ( -- )
|
2007-12-06 00:22:35 -05:00
|
|
|
serving-html
|
|
|
|
[ "new-paste" render-template ] with-html-stream ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
|
|
|
\ new-paste { } define-action
|
|
|
|
|
|
|
|
: paste-list ( -- )
|
2007-12-06 00:22:35 -05:00
|
|
|
serving-html
|
2007-11-07 15:01:42 -05:00
|
|
|
[
|
|
|
|
[ show-paste ] "show-paste-quot" set
|
|
|
|
[ new-paste ] "new-paste-quot" set
|
2007-12-06 00:06:34 -05:00
|
|
|
pastebin get "paste-list" render-component
|
2007-12-06 00:22:35 -05:00
|
|
|
] with-html-stream ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
|
|
|
\ paste-list { } define-action
|
|
|
|
|
|
|
|
: save-pastebin-store ( -- )
|
|
|
|
store get-global save-store ;
|
|
|
|
|
|
|
|
: add-paste ( paste pastebin -- )
|
|
|
|
>r now timestamp>http-string over set-paste-date r>
|
2007-12-06 00:06:34 -05:00
|
|
|
pastebin-pastes 2dup length swap set-paste-n push ;
|
2007-11-07 15:01:42 -05:00
|
|
|
|
2007-12-06 00:06:34 -05:00
|
|
|
: submit-paste ( summary author channel mode contents -- )
|
2007-11-07 15:01:42 -05:00
|
|
|
<paste>
|
|
|
|
\ pastebin get-global add-paste
|
|
|
|
save-pastebin-store ;
|
|
|
|
|
|
|
|
\ submit-paste {
|
|
|
|
{ "summary" v-required }
|
|
|
|
{ "author" v-required }
|
|
|
|
{ "channel" "#concatenative" v-default }
|
2007-12-06 00:06:34 -05:00
|
|
|
{ "mode" "factor" v-default }
|
2007-11-07 15:01:42 -05:00
|
|
|
{ "contents" v-required }
|
|
|
|
} define-action
|
|
|
|
|
|
|
|
\ submit-paste [ paste-list ] define-redirect
|
|
|
|
|
2007-12-06 00:22:35 -05:00
|
|
|
: annotate-paste ( n summary author mode contents -- )
|
2007-11-07 15:01:42 -05:00
|
|
|
<annotation> swap get-paste
|
|
|
|
paste-annotations push
|
|
|
|
save-pastebin-store ;
|
|
|
|
|
|
|
|
\ annotate-paste {
|
|
|
|
{ "n" v-required v-number }
|
|
|
|
{ "summary" v-required }
|
|
|
|
{ "author" v-required }
|
2007-12-06 00:06:34 -05:00
|
|
|
{ "mode" "factor" v-default }
|
2007-11-07 15:01:42 -05:00
|
|
|
{ "contents" v-required }
|
|
|
|
} define-action
|
|
|
|
|
|
|
|
\ annotate-paste [ "n" show-paste ] define-redirect
|
|
|
|
|
|
|
|
"pastebin" "paste-list" "extra/webapps/pastebin" web-app
|