webapps.pastebin: add 'Plain Text' links to see pastes in plain text

db4
Slava Pestov 2009-09-28 17:53:44 -05:00
parent 9b64d206ff
commit a20362cf26
2 changed files with 21 additions and 3 deletions

View File

@ -16,6 +16,7 @@
<pre class="description"><t:code t:name="contents" t:mode="mode" /></pre>
<t:a t:href="$pastebin/paste.txt" t:query="id">Plain Text</t:a> |
<t:button t:action="$pastebin/delete-paste" t:for="id" class="link-button link">Delete Paste</t:button>
<t:bind-each t:name="annotations">
@ -30,6 +31,7 @@
<pre class="description"><t:code t:name="contents" t:mode="mode"/></pre>
<t:a t:href="$pastebin/annotation.txt" t:query="id">Plain Text</t:a> |
<t:button t:action="$pastebin/delete-annotation" t:for="id" class="link-button link">Delete Annotation</t:button>
</t:bind-each>

View File

@ -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
: <annotation> ( parent id -- annotation )
annotation new
\ annotation new
swap >>id
swap >>parent ;
: annotation ( id -- annotation )
[ f ] dip <annotation> select-tuple ;
: paste ( id -- paste )
[ <paste> select-tuple ]
[ f <annotation> select-tuples ]
@ -134,6 +138,11 @@ M: annotation entity-url
{ pastebin "paste" } >>template ;
: <raw-paste-action> ( -- action )
<action>
[ validate-integer-id "id" value paste from-object ] >>init
[ "contents" value "text/plain" <content> ] >>display ;
: <paste-feed-action> ( -- action )
<feed-action>
[ validate-integer-id ] >>init
@ -213,13 +222,18 @@ M: annotation entity-url
tri
] >>submit ;
: <raw-annotation-action> ( -- action )
<action>
[ validate-integer-id "id" value annotation from-object ] >>init
[ "contents" value "text/plain" <content> ] >>display ;
: <delete-annotation-action> ( -- action )
<action>
[ { { "id" [ v-number ] } } validate-params ] >>validate
[
f "id" value <annotation> select-tuple
f "id" value annotation
[ delete-tuples ]
[ parent>> paste-url <redirect> ]
bi
@ -234,10 +248,12 @@ M: annotation entity-url
<pastebin-action> "" add-responder
<pastebin-feed-action> "list.atom" add-responder
<paste-action> "paste" add-responder
<raw-paste-action> "paste.txt" add-responder
<paste-feed-action> "paste.atom" add-responder
<new-paste-action> "new-paste" add-responder
<delete-paste-action> "delete-paste" add-responder
<new-annotation-action> "new-annotation" add-responder
<raw-annotation-action> "annotation.txt" add-responder
<delete-annotation-action> "delete-annotation" add-responder
<boilerplate>
{ pastebin "pastebin-common" } >>template ;