gdritter repos profile-site / d42b2e8
early testing state Getty Ritter 9 years ago
5 changed file(s) with 133 addition(s) and 0 deletion(s). Collapse all Expand all
1 Copyright (c) 2015, Getty Ritter
2
3 All rights reserved.
4
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7
8 * Redistributions of source code must retain the above copyright
9 notice, this list of conditions and the following disclaimer.
10
11 * Redistributions in binary form must reproduce the above
12 copyright notice, this list of conditions and the following
13 disclaimer in the documentation and/or other materials provided
14 with the distribution.
15
16 * Neither the name of Getty Ritter nor the names of other
17 contributors may be used to endorse or promote products derived
18 from this software without specific prior written permission.
19
20 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 {-# LANGUAGE OverloadedStrings #-}
2 {-# LANGUAGE DataKinds #-}
3
4 module Main where
5
6 import Control.Monad (forM_)
7 import Data.HashMap (toList)
8 -- import qualified Storage as S
9 -- import qualified Templates as T
10 import Web.Spock.Safe
11
12 {- /
13 [ image ] [ project ]
14 [ image ] [ project ]
15 - /project/:blah
16 [ image ] [ text ]
17 [ image ]
18 prev next main
19 [ archives ]
20 - /login
21 [ password ]
22 - /edit
23
24 -}
25
26 projectR :: Path '[Text]
27 projectR = "project" <//> var
28
29 loginR :: Path '[]
30 loginR = "login"
31
32 editR :: Path '[]
33 editR = "edit"
34
35 editProjectR :: Path '[Text]
36 editProjectR = "edit" <//> "project" <//> var
37
38 main :: IO ()
39 main = runSpock 8080 $ spockT id $ do
40 get Root $ do
41 projs <- S.getProjects
42 text "foo"
43 get projectR $ \ p -> do
44 text "whoo"
45 post Root $ do
46 fs <- files
47 forM_ (toList fs) $ \ (k, v) -> do
48 liftIO $ putStrLn $ "name" ++ show k
49 liftIO $ putStrLn $ "uf_name" ++ show (uf_name v)
50 liftIO $ putStrLn $ "uf_tempLocation" ++ show (uf_tempLocation v)
51 text "blah"
1 A simple site for art profiles.
1 {-# LANGUAGE OverloadedStrings #-}
2
3 module Storage where
4
5 import Data.Aeson
6 import Data.FileStore
7 import Data.FileStore.Git
8
9 data Project = Project
10 { projectSlug :: Text
11 , projectName :: Text
12 , projectDescr :: Text
13 , projectImgs :: [Text]
14 } deriving (Eq, Show)
15
16 instance Contents (Maybe Project) where
17 fromByteString = decode
18 toByteString (Just x) = encode x
19 toByteString Nothing = error "should not happen"
20
21 portfolioStore :: FileStore
22 portfolioStore = gitFileStore "portfolio-data"
23
24 getProjectByName :: String -> IO (Maybe Project)
25 getProjectByName name = retrieve (name <> ".json") portfolioStore Nothing
26
27 getImage :: String -> IO (Maybe ByteString)
28 getImage name = retrieve ("images" </> name) portfolioStore Nothing
29
30 newImage :: UploadedFile -> ()
31 newImage = undefined
1 Name: cortana-portfolio
2 Version: 0.0.0
3 Author: Getty Ritter<gdritter@galois.com>
4 Maintainer: Getty Ritter<gdritter@galois.com>
5 License: BSD3
6 License-File: LICENSE
7 -- Synopsis:
8 -- Description:
9 Cabal-Version: >= 1.10
10 Build-Type: Simple
11
12 Executable cortana-portfolio
13 Main-Is: Main.hs
14 Default-Language: Haskell2010
15 GHC-Options: -Wall
16 Build-Depends: base >= 4 && < 5, Spock, containers
17
18 Source-Repository head
19 Type: git
20 -- Location: