From a20362cf267dc402225f65bf1cdcfa6723de8fbe Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Sep 2009 17:53:44 -0500 Subject: [PATCH 1/2] webapps.pastebin: add 'Plain Text' links to see pastes in plain text --- extra/webapps/pastebin/paste.xml | 2 ++ extra/webapps/pastebin/pastebin.factor | 22 +++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/extra/webapps/pastebin/paste.xml b/extra/webapps/pastebin/paste.xml index a48d2ea42d..bec646a4ca 100644 --- a/extra/webapps/pastebin/paste.xml +++ b/extra/webapps/pastebin/paste.xml @@ -16,6 +16,7 @@
+ Plain Text | Delete Paste @@ -30,6 +31,7 @@
+ Plain Text | Delete Annotation
diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor index 2c51d41aa0..48e6ed030b 100644 --- a/extra/webapps/pastebin/pastebin.factor +++ b/extra/webapps/pastebin/pastebin.factor @@ -10,6 +10,7 @@ html.templates.chloe http.server http.server.dispatchers http.server.redirection +http.server.responses furnace furnace.actions furnace.redirection @@ -64,16 +65,19 @@ TUPLE: paste < entity annotations ; TUPLE: annotation < entity parent ; -annotation "ANNOTATIONS" +\ annotation "ANNOTATIONS" { { "parent" "PARENT" INTEGER +not-null+ } } define-persistent : ( parent id -- annotation ) - annotation new + \ annotation new swap >>id swap >>parent ; +: annotation ( id -- annotation ) + [ f ] dip select-tuple ; + : paste ( id -- paste ) [ select-tuple ] [ f select-tuples ] @@ -134,6 +138,11 @@ M: annotation entity-url { pastebin "paste" } >>template ; +: ( -- action ) + + [ validate-integer-id "id" value paste from-object ] >>init + [ "contents" value "text/plain" ] >>display ; + : ( -- action ) [ validate-integer-id ] >>init @@ -213,13 +222,18 @@ M: annotation entity-url tri ] >>submit ; +: ( -- action ) + + [ validate-integer-id "id" value annotation from-object ] >>init + [ "contents" value "text/plain" ] >>display ; + : ( -- action ) [ { { "id" [ v-number ] } } validate-params ] >>validate [ - f "id" value select-tuple + f "id" value annotation [ delete-tuples ] [ parent>> paste-url ] bi @@ -234,10 +248,12 @@ M: annotation entity-url "" add-responder "list.atom" add-responder "paste" add-responder + "paste.txt" add-responder "paste.atom" add-responder "new-paste" add-responder "delete-paste" add-responder "new-annotation" add-responder + "annotation.txt" add-responder "delete-annotation" add-responder { pastebin "pastebin-common" } >>template ; From 628c69685b1e98873dc1644938bb152537539837 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 28 Sep 2009 17:55:42 -0500 Subject: [PATCH 2/2] webapps.pastebin: tweak template --- extra/webapps/pastebin/paste.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/extra/webapps/pastebin/paste.xml b/extra/webapps/pastebin/paste.xml index bec646a4ca..6e1cb53664 100644 --- a/extra/webapps/pastebin/paste.xml +++ b/extra/webapps/pastebin/paste.xml @@ -14,11 +14,11 @@ Date: -
- Plain Text | Delete Paste +
+

Annotation:

@@ -29,11 +29,11 @@ Date: -
- Plain Text | Delete Annotation +
+