]> gitweb.factorcode.org Git - factor.git/blob - extra/webapps/imagebin/imagebin.factor
Merge branch 'master' into experimental
[factor.git] / extra / webapps / imagebin / imagebin.factor
1 ! Copyright (C) 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors kernel furnace.actions html.forms
4 http.server.dispatchers db db.tuples db.types urls
5 furnace.redirection multiline http namespaces ;
6 IN: webapps.imagebin
7
8 TUPLE: imagebin < dispatcher ;
9
10 TUPLE: image id path ;
11
12 image "IMAGE" {
13     { "id" "ID" INTEGER +db-assigned-id+ }
14     { "path" "PATH" { VARCHAR 256 } +not-null+ }
15 } define-persistent
16
17 : <uploaded-image-action> ( -- action )
18     <page-action>
19         { imagebin "uploaded-image" } >>template ;
20
21 SYMBOL: my-post-data
22 : <upload-image-action> ( -- action )
23     <page-action>
24         { imagebin "upload-image" } >>template
25         [
26             
27             ! request get post-data>> my-post-data set-global
28             ! image new
29             !    "file" value
30                 ! insert-tuple
31             "uploaded-image" <redirect>
32         ] >>submit ;
33
34 : <imagebin> ( -- responder )
35     imagebin new-dispatcher
36         <upload-image-action> "" add-responder
37         <upload-image-action> "upload-image" add-responder
38         <uploaded-image-action> "uploaded-image" add-responder ;
39