diff --git a/extra/webapps/pastebin/annotate-paste.furnace b/extra/webapps/pastebin/annotate-paste.furnace new file mode 100644 index 0000000000..c963e2f88f --- /dev/null +++ b/extra/webapps/pastebin/annotate-paste.furnace @@ -0,0 +1,28 @@ +<% USING: io math math.parser namespaces ; %> + +

Annotate

+ +
+ + + +string write %>" /> + + + + + + + + + + + + + + + +
Your name:
Summary:
Contents:
+ + +
diff --git a/extra/webapps/pastebin/annotation.furnace b/extra/webapps/pastebin/annotation.furnace new file mode 100644 index 0000000000..ed1bdac845 --- /dev/null +++ b/extra/webapps/pastebin/annotation.furnace @@ -0,0 +1,11 @@ +<% USING: namespaces io ; %> + +

Annotation: <% "summary" get write %>

+ + + + + +
Annotation by:<% "author" get write %>
Channel:<% "channel" get write %>
Created:<% "date" get write %>
+ +
<% "contents" get write %>
diff --git a/extra/webapps/pastebin/new-paste.furnace b/extra/webapps/pastebin/new-paste.furnace new file mode 100644 index 0000000000..8a2544e801 --- /dev/null +++ b/extra/webapps/pastebin/new-paste.furnace @@ -0,0 +1,27 @@ +
+ + + + + + + + + + + + + + + + + + + + + + +
Your name:
Summary:
Channel:
Contents:
+ + +
diff --git a/extra/webapps/pastebin/paste-list.furnace b/extra/webapps/pastebin/paste-list.furnace new file mode 100644 index 0000000000..7a25ae2f50 --- /dev/null +++ b/extra/webapps/pastebin/paste-list.furnace @@ -0,0 +1,7 @@ +<% USING: namespaces furnace sequences ; %> + + +<% "new-paste-quot" get "New paste" render-link %> + +<% "pastes" get [ "paste-summary" render-template ] each %>
 Summary:Paste by:LinkDate
+ diff --git a/extra/webapps/pastebin/paste-summary.furnace b/extra/webapps/pastebin/paste-summary.furnace new file mode 100644 index 0000000000..f5c156a27e --- /dev/null +++ b/extra/webapps/pastebin/paste-summary.furnace @@ -0,0 +1,9 @@ +<% USING: continuations namespaces io kernel math math.parser furnace ; %> + + +<% "n" get number>string write %> +<% "summary" get write %> +<% "author" get write %> +<% "n" get number>string "show-paste-quot" get curry "Show" render-link %> +<% "date" get print %> + diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor new file mode 100644 index 0000000000..f592f96448 --- /dev/null +++ b/extra/webapps/pastebin/pastebin.factor @@ -0,0 +1,93 @@ +USING: calendar furnace furnace.validator io.files kernel namespaces +sequences store ; +IN: webapps.pastebin + +TUPLE: pastebin pastes ; + +: ( -- pastebin ) + V{ } clone pastebin construct-boa ; + +TUPLE: paste n summary article author channel contents date annotations ; + +: ( summary author channel contents -- paste ) + V{ } clone + { + set-paste-summary + set-paste-author + set-paste-channel + set-paste-contents + set-paste-annotations + } paste construct ; + +TUPLE: annotation summary author contents ; + +C: annotation + + +SYMBOL: store + +"pastebin.store" resource-path load-store store set-global + + \ pastebin store get store-variable + +: get-paste ( n -- paste ) + pastebin get pastebin-pastes nth ; + +: show-paste ( n -- ) + get-paste "show-paste" "Paste" render-page ; + +\ show-paste { { "n" v-number } } define-action + +: new-paste ( -- ) + f "new-paste" "New paste" render-page ; + +\ new-paste { } define-action + +: paste-list ( -- ) + [ + [ show-paste ] "show-paste-quot" set + [ new-paste ] "new-paste-quot" set + pastebin get "paste-list" "Pastebin" render-page + ] with-scope ; + +\ 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> + pastebin-pastes + [ length over set-paste-n ] keep push ; + +: submit-paste ( summary author channel contents -- ) + + \ pastebin get-global add-paste + save-pastebin-store ; + +\ submit-paste { + { "summary" v-required } + { "author" v-required } + { "channel" "#concatenative" v-default } + { "contents" v-required } +} define-action + +\ submit-paste [ paste-list ] define-redirect + +: annotate-paste ( n summary author contents -- ) + swap get-paste + paste-annotations push + save-pastebin-store ; + +\ 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 + +"pastebin" "paste-list" "extra/webapps/pastebin" web-app diff --git a/extra/webapps/pastebin/show-paste.furnace b/extra/webapps/pastebin/show-paste.furnace new file mode 100644 index 0000000000..b3b4e99b6e --- /dev/null +++ b/extra/webapps/pastebin/show-paste.furnace @@ -0,0 +1,15 @@ +<% USING: namespaces io furnace sequences ; %> + +

Paste: <% "summary" get write %>

+ + + + + +
Paste by:<% "author" get write %>
Channel:<% "channel" get write %>
Created:<% "date" get write %>
+ +
<% "contents" get write %>
+ +<% "annotations" get [ "annotation" render-template ] each %> + +<% model get "annotate-paste" render-template %>