diff --git a/8.10/Dockerfile b/8.10/Dockerfile new file mode 100644 index 0000000..11c56fc --- /dev/null +++ b/8.10/Dockerfile @@ -0,0 +1,30 @@ +FROM debian:buster + +RUN apt-get update && \ + apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr && \ + rm -rf /var/lib/apt/lists/* + +ARG GHC=8.10.1 +ARG CABAL_INSTALL=3.2 + +RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 427CB69AAC9D00F2A43CAF1CBA3CBA3FFE22B574 && \ + echo 'deb http://downloads.haskell.org/debian buster main' > /etc/apt/sources.list.d/ghc.list && \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + cabal-install-${CABAL_INSTALL} \ + curl \ + g++ \ + ghc-${GHC} \ + git \ + libsqlite3-dev \ + libtinfo-dev \ + make \ + netbase \ + openssh-client \ + xz-utils \ + zlib1g-dev && \ + rm -rf /var/lib/apt/lists/* + +ENV PATH /root/.cabal/bin:/opt/cabal/${CABAL_INSTALL}/bin:/opt/ghc/${GHC}/bin:$PATH + +CMD ["ghci"] diff --git a/examples/7.10/snap/.dockerignore b/examples/7.10/snap/.dockerignore deleted file mode 100644 index 1521c8b..0000000 --- a/examples/7.10/snap/.dockerignore +++ /dev/null @@ -1 +0,0 @@ -dist diff --git a/examples/7.10/snap/.ghci b/examples/7.10/snap/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.10/snap/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.10/snap/Dockerfile b/examples/7.10/snap/Dockerfile deleted file mode 100644 index ca58d81..0000000 --- a/examples/7.10/snap/Dockerfile +++ /dev/null @@ -1,19 +0,0 @@ -FROM haskell:7.10 - -WORKDIR /opt/server - -RUN cabal update - -# Add just the .cabal file to capture dependencies -COPY ./snap-example.cabal /opt/server/snap-example.cabal - -# Docker will cache this command as a layer, freeing us up to -# modify source code without re-installing dependencies -# (unless the .cabal file changes!) -RUN cabal install --only-dependencies -j4 - -# Add and Install Application Code -COPY . /opt/server -RUN cabal install - -CMD ["snap-example"] diff --git a/examples/7.10/snap/site_key.txt b/examples/7.10/snap/site_key.txt deleted file mode 100644 index 9ea55c0..0000000 Binary files a/examples/7.10/snap/site_key.txt and /dev/null differ diff --git a/examples/7.10/snap/snap-example.cabal b/examples/7.10/snap/snap-example.cabal deleted file mode 100644 index 87af735..0000000 --- a/examples/7.10/snap/snap-example.cabal +++ /dev/null @@ -1,63 +0,0 @@ -Name: snap-example -Version: 0.1 -Synopsis: Project Synopsis Here -Description: Project Description Here -License: AllRightsReserved -Author: Author -Maintainer: maintainer@example.com -Stability: Experimental -Category: Web -Build-type: Simple -Cabal-version: >=1.2 - -Flag development - Description: Whether to build the server in development (interpreted) mode - Default: False - -Flag old-base - default: False - manual: False - -Executable snap-example - hs-source-dirs: src - main-is: Main.hs - - Build-depends: - bytestring >= 0.9.1 && < 0.11, - heist >= 0.14 && < 0.15, - MonadCatchIO-transformers >= 0.2.1 && < 0.4, - mtl >= 2 && < 3, - snap >= 0.13 && < 0.15, - snap-core >= 0.9 && < 0.10, - snap-server >= 0.9 && < 0.10, - snap-loader-static >= 0.9 && < 0.10, - text >= 0.11 && < 1.3, - time >= 1.1 && < 1.6, - xmlhtml >= 0.1 && < 0.3 - - if flag(old-base) - build-depends: - base >= 4 && < 4.4, - lens >= 3.7.6 && < 3.8 - else - build-depends: - base >= 4.4 && < 5, - lens >= 3.7.6 && < 4.13 - - if flag(development) - build-depends: - snap-loader-dynamic == 0.10.* - cpp-options: -DDEVELOPMENT - -- In development mode, speed is already going to suffer, so skip - -- the fancy optimization flags. Additionally, disable all - -- warnings. The hint library doesn't give an option to execute - -- compiled code when there were also warnings, so disabling - -- warnings allows quicker workflow. - ghc-options: -threaded -w - else - if impl(ghc >= 6.12.0) - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans -fno-warn-unused-do-bind - else - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans diff --git a/examples/7.10/snap/snaplets/heist/templates/_login.tpl b/examples/7.10/snap/snaplets/heist/templates/_login.tpl deleted file mode 100644 index b646e7c..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/_login.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

Snap Example App Login

- -

- -/login -Login - - -

Don't have a login yet? Create a new user

diff --git a/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl b/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl deleted file mode 100644 index 5a9a332..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/_new_user.tpl +++ /dev/null @@ -1,5 +0,0 @@ -

Register a new user

- -/new_user -Add User - diff --git a/examples/7.10/snap/snaplets/heist/templates/base.tpl b/examples/7.10/snap/snaplets/heist/templates/base.tpl deleted file mode 100644 index e4e8127..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/base.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - Snap web server - - - -
- - - -
- - diff --git a/examples/7.10/snap/snaplets/heist/templates/index.tpl b/examples/7.10/snap/snaplets/heist/templates/index.tpl deleted file mode 100644 index 370dad5..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/index.tpl +++ /dev/null @@ -1,19 +0,0 @@ - - - -

- This is a simple demo page served using - Heist - and the Snap web framework. -

- -

Congrats! You're logged in as ''

- -

Logout

-
- - - - - -
diff --git a/examples/7.10/snap/snaplets/heist/templates/login.tpl b/examples/7.10/snap/snaplets/heist/templates/login.tpl deleted file mode 100644 index 29dc2fe..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/login.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.10/snap/snaplets/heist/templates/new_user.tpl b/examples/7.10/snap/snaplets/heist/templates/new_user.tpl deleted file mode 100644 index aa0fe53..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/new_user.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.10/snap/snaplets/heist/templates/userform.tpl b/examples/7.10/snap/snaplets/heist/templates/userform.tpl deleted file mode 100644 index 0f8a8fc..0000000 --- a/examples/7.10/snap/snaplets/heist/templates/userform.tpl +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - - - - - - - -
Login:
Password:
-
diff --git a/examples/7.10/snap/src/Application.hs b/examples/7.10/snap/src/Application.hs deleted file mode 100644 index 8378832..0000000 --- a/examples/7.10/snap/src/Application.hs +++ /dev/null @@ -1,31 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - ------------------------------------------------------------------------------- --- | This module defines our application's state type and an alias for its --- handler monad. -module Application where - ------------------------------------------------------------------------------- -import Control.Lens -import Snap.Snaplet -import Snap.Snaplet.Heist -import Snap.Snaplet.Auth -import Snap.Snaplet.Session - ------------------------------------------------------------------------------- -data App = App - { _heist :: Snaplet (Heist App) - , _sess :: Snaplet SessionManager - , _auth :: Snaplet (AuthManager App) - } - -makeLenses ''App - -instance HasHeist App where - heistLens = subSnaplet heist - - ------------------------------------------------------------------------------- -type AppHandler = Handler App App - - diff --git a/examples/7.10/snap/src/Main.hs b/examples/7.10/snap/src/Main.hs deleted file mode 100644 index cad1698..0000000 --- a/examples/7.10/snap/src/Main.hs +++ /dev/null @@ -1,114 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} - -{- - -NOTE: Don't modify this file unless you know what you are doing. If you are -new to snap, start with Site.hs and Application.hs. This file contains -boilerplate needed for dynamic reloading and is not meant for general -consumption. - -Occasionally if we modify the way the dynamic reloader works and you want to -upgrade, you might have to swap out this file for a newer version. But in -most cases you'll never need to modify this code. - --} -module Main where - ------------------------------------------------------------------------------- -import Control.Exception (SomeException, try) -import qualified Data.Text as T -import Snap.Http.Server -import Snap.Snaplet -import Snap.Snaplet.Config -import Snap.Core -import System.IO -import Site - -#ifdef DEVELOPMENT -import Snap.Loader.Dynamic -#else -import Snap.Loader.Static -#endif - - ------------------------------------------------------------------------------- --- | This is the entry point for this web server application. It supports --- easily switching between interpreting source and running statically compiled --- code. --- --- In either mode, the generated program should be run from the root of the --- project tree. When it is run, it locates its templates, static content, and --- source files in development mode, relative to the current working directory. --- --- When compiled with the development flag, only changes to the libraries, your --- cabal file, or this file should require a recompile to be picked up. --- Everything else is interpreted at runtime. There are a few consequences of --- this. --- --- First, this is much slower. Running the interpreter takes a significant --- chunk of time (a couple tenths of a second on the author's machine, at this --- time), regardless of the simplicity of the loaded code. In order to --- recompile and re-load server state as infrequently as possible, the source --- directories are watched for updates, as are any extra directories specified --- below. --- --- Second, the generated server binary is MUCH larger, since it links in the --- GHC API (via the hint library). --- --- Third, and the reason you would ever want to actually compile with --- development mode, is that it enables a faster development cycle. You can --- simply edit a file, save your changes, and hit reload to see your changes --- reflected immediately. --- --- When this is compiled without the development flag, all the actions are --- statically compiled in. This results in faster execution, a smaller binary --- size, and having to recompile the server for any code change. --- -main :: IO () -main = do - -- Depending on the version of loadSnapTH in scope, this either enables - -- dynamic reloading, or compiles it without. The last argument to - -- loadSnapTH is a list of additional directories to watch for changes to - -- trigger reloads in development mode. It doesn't need to include source - -- directories, those are picked up automatically by the splice. - (conf, site, cleanup) <- $(loadSnapTH [| getConf |] - 'getActions - ["snaplets/heist/templates"]) - - _ <- try $ httpServe conf site :: IO (Either SomeException ()) - cleanup - - ------------------------------------------------------------------------------- --- | This action loads the config used by this application. The loaded config --- is returned as the first element of the tuple produced by the loadSnapTH --- Splice. The type is not solidly fixed, though it must be an IO action that --- produces the same type as 'getActions' takes. It also must be an instance of --- Typeable. If the type of this is changed, a full recompile will be needed to --- pick up the change, even in development mode. --- --- This action is only run once, regardless of whether development or --- production mode is in use. -getConf :: IO (Config Snap AppConfig) -getConf = commandLineAppConfig defaultConfig - - ------------------------------------------------------------------------------- --- | This function generates the the site handler and cleanup action from the --- configuration. In production mode, this action is only run once. In --- development mode, this action is run whenever the application is reloaded. --- --- Development mode also makes sure that the cleanup actions are run --- appropriately before shutdown. The cleanup action returned from loadSnapTH --- should still be used after the server has stopped handling requests, as the --- cleanup actions are only automatically run when a reload is triggered. --- --- This sample doesn't actually use the config passed in, but more --- sophisticated code might. -getActions :: Config Snap AppConfig -> IO (Snap (), IO ()) -getActions conf = do - (msgs, site, cleanup) <- runSnaplet - (appEnvironment =<< getOther conf) app - hPutStrLn stderr $ T.unpack msgs - return (site, cleanup) diff --git a/examples/7.10/snap/src/Site.hs b/examples/7.10/snap/src/Site.hs deleted file mode 100644 index 13624f4..0000000 --- a/examples/7.10/snap/src/Site.hs +++ /dev/null @@ -1,89 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - ------------------------------------------------------------------------------- --- | This module is where all the routes and handlers are defined for your --- site. The 'app' function is the initializer that combines everything --- together and is exported by this module. -module Site - ( app - ) where - ------------------------------------------------------------------------------- -import Control.Applicative -import Data.ByteString (ByteString) -import Data.Monoid -import qualified Data.Text as T -import Snap.Core -import Snap.Snaplet -import Snap.Snaplet.Auth -import Snap.Snaplet.Auth.Backends.JsonFile -import Snap.Snaplet.Heist -import Snap.Snaplet.Session.Backends.CookieSession -import Snap.Util.FileServe -import Heist -import qualified Heist.Interpreted as I ------------------------------------------------------------------------------- -import Application - - ------------------------------------------------------------------------------- --- | Render login form -handleLogin :: Maybe T.Text -> Handler App (AuthManager App) () -handleLogin authError = heistLocal (I.bindSplices errs) $ render "login" - where - errs = maybe mempty splice authError - splice err = "loginError" ## I.textSplice err - - ------------------------------------------------------------------------------- --- | Handle login submit -handleLoginSubmit :: Handler App (AuthManager App) () -handleLoginSubmit = - loginUser "login" "password" Nothing - (\_ -> handleLogin err) (redirect "/") - where - err = Just "Unknown user or password" - - ------------------------------------------------------------------------------- --- | Logs out and redirects the user to the site index. -handleLogout :: Handler App (AuthManager App) () -handleLogout = logout >> redirect "/" - - ------------------------------------------------------------------------------- --- | Handle new user form submit -handleNewUser :: Handler App (AuthManager App) () -handleNewUser = method GET handleForm <|> method POST handleFormSubmit - where - handleForm = render "new_user" - handleFormSubmit = registerUser "login" "password" >> redirect "/" - - ------------------------------------------------------------------------------- --- | The application's routes. -routes :: [(ByteString, Handler App App ())] -routes = [ ("/login", with auth handleLoginSubmit) - , ("/logout", with auth handleLogout) - , ("/new_user", with auth handleNewUser) - , ("", serveDirectory "static") - ] - - ------------------------------------------------------------------------------- --- | The application initializer. -app :: SnapletInit App App -app = makeSnaplet "app" "An snaplet example application." Nothing $ do - h <- nestSnaplet "" heist $ heistInit "templates" - s <- nestSnaplet "sess" sess $ - initCookieSessionManager "site_key.txt" "sess" (Just 3600) - - -- NOTE: We're using initJsonFileAuthManager here because it's easy and - -- doesn't require any kind of database server to run. In practice, - -- you'll probably want to change this to a more robust auth backend. - a <- nestSnaplet "auth" auth $ - initJsonFileAuthManager defAuthSettings sess "users.json" - addRoutes routes - addAuthSplices h auth - return $ App h s a - diff --git a/examples/7.10/snap/static/screen.css b/examples/7.10/snap/static/screen.css deleted file mode 100644 index b052609..0000000 --- a/examples/7.10/snap/static/screen.css +++ /dev/null @@ -1,26 +0,0 @@ -html { - padding: 0; - margin: 0; - background-color: #ffffff; - font-family: Verdana, Helvetica, sans-serif; -} -body { - padding: 0; - margin: 0; -} -a { - text-decoration: underline; -} -a :hover { - cursor: pointer; - text-decoration: underline; -} -img { - border: none; -} -#content { - padding-left: 1em; -} -#info { - font-size: 60%; -} diff --git a/examples/7.8/snap/.ghci b/examples/7.8/snap/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.8/snap/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.8/snap/Dockerfile b/examples/7.8/snap/Dockerfile deleted file mode 100644 index cf1ed5f..0000000 --- a/examples/7.8/snap/Dockerfile +++ /dev/null @@ -1,21 +0,0 @@ -FROM haskell:7.8 - -RUN cabal update - -# Add .cabal file -ADD ./server/snap-example.cabal /opt/server/snap-example.cabal - -# Docker will cache this command as a layer, freeing us up to -# modify source code without re-installing dependencies -RUN cd /opt/server && cabal install --only-dependencies -j4 - -# Add and Install Application Code -ADD ./server /opt/server -RUN cd /opt/server && cabal install - -# Add installed cabal executables to PATH -ENV PATH /root/.cabal/bin:$PATH - -# Default Command for Container -WORKDIR /opt/server -CMD ["snap-example"] \ No newline at end of file diff --git a/examples/7.8/snap/README.md b/examples/7.8/snap/README.md deleted file mode 100644 index 7eec9fa..0000000 --- a/examples/7.8/snap/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# docker-library snap-example - -## Build Example: - -``` -docker build -t hsnap . -``` - -## Run Example: - -This command will run the example interactively mapping port 8000 -in the container to 8000 on the host. - -``` -docker run -i -t -p 8000:8000 hsnap -``` \ No newline at end of file diff --git a/examples/7.8/snap/server/.ghci b/examples/7.8/snap/server/.ghci deleted file mode 100644 index a882c32..0000000 --- a/examples/7.8/snap/server/.ghci +++ /dev/null @@ -1,4 +0,0 @@ -:set -isrc -:set -hide-package MonadCatchIO-mtl -:set -hide-package monads-fd -:set -XOverloadedStrings diff --git a/examples/7.8/snap/server/snap-example.cabal b/examples/7.8/snap/server/snap-example.cabal deleted file mode 100644 index 70f24b5..0000000 --- a/examples/7.8/snap/server/snap-example.cabal +++ /dev/null @@ -1,63 +0,0 @@ -Name: snap-example -Version: 0.1 -Synopsis: Project Synopsis Here -Description: Project Description Here -License: AllRightsReserved -Author: Author -Maintainer: maintainer@example.com -Stability: Experimental -Category: Web -Build-type: Simple -Cabal-version: >=1.2 - -Flag development - Description: Whether to build the server in development (interpreted) mode - Default: False - -Flag old-base - default: False - manual: False - -Executable snap-example - hs-source-dirs: src - main-is: Main.hs - - Build-depends: - bytestring >= 0.9.1 && < 0.11, - heist >= 0.14 && < 0.15, - MonadCatchIO-transformers >= 0.2.1 && < 0.4, - mtl >= 2 && < 3, - snap >= 0.13 && < 0.15, - snap-core >= 0.9 && < 0.10, - snap-server >= 0.9 && < 0.10, - snap-loader-static >= 0.9 && < 0.10, - text >= 0.11 && < 1.3, - time >= 1.1 && < 1.6, - xmlhtml >= 0.1 && < 0.3 - - if flag(old-base) - build-depends: - base >= 4 && < 4.4, - lens >= 3.7.6 && < 3.8 - else - build-depends: - base >= 4.4 && < 5, - lens >= 3.7.6 && < 4.10 - - if flag(development) - build-depends: - snap-loader-dynamic == 0.10.* - cpp-options: -DDEVELOPMENT - -- In development mode, speed is already going to suffer, so skip - -- the fancy optimization flags. Additionally, disable all - -- warnings. The hint library doesn't give an option to execute - -- compiled code when there were also warnings, so disabling - -- warnings allows quicker workflow. - ghc-options: -threaded -w - else - if impl(ghc >= 6.12.0) - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans -fno-warn-unused-do-bind - else - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 - -fno-warn-orphans diff --git a/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl b/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl deleted file mode 100644 index b646e7c..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/_login.tpl +++ /dev/null @@ -1,9 +0,0 @@ -

Snap Example App Login

- -

- -/login -Login - - -

Don't have a login yet? Create a new user

diff --git a/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl b/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl deleted file mode 100644 index 5a9a332..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/_new_user.tpl +++ /dev/null @@ -1,5 +0,0 @@ -

Register a new user

- -/new_user -Add User - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/base.tpl b/examples/7.8/snap/server/snaplets/heist/templates/base.tpl deleted file mode 100644 index e4e8127..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/base.tpl +++ /dev/null @@ -1,13 +0,0 @@ - - - Snap web server - - - -
- - - -
- - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/index.tpl b/examples/7.8/snap/server/snaplets/heist/templates/index.tpl deleted file mode 100644 index 370dad5..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/index.tpl +++ /dev/null @@ -1,19 +0,0 @@ - - - -

- This is a simple demo page served using - Heist - and the Snap web framework. -

- -

Congrats! You're logged in as ''

- -

Logout

-
- - - - - -
diff --git a/examples/7.8/snap/server/snaplets/heist/templates/login.tpl b/examples/7.8/snap/server/snaplets/heist/templates/login.tpl deleted file mode 100644 index 29dc2fe..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/login.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl b/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl deleted file mode 100644 index aa0fe53..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/new_user.tpl +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl b/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl deleted file mode 100644 index 0f8a8fc..0000000 --- a/examples/7.8/snap/server/snaplets/heist/templates/userform.tpl +++ /dev/null @@ -1,14 +0,0 @@ -
- - - - - - - - - - - -
Login:
Password:
-
diff --git a/examples/7.8/snap/server/src/Application.hs b/examples/7.8/snap/server/src/Application.hs deleted file mode 100644 index 8378832..0000000 --- a/examples/7.8/snap/server/src/Application.hs +++ /dev/null @@ -1,31 +0,0 @@ -{-# LANGUAGE TemplateHaskell #-} - ------------------------------------------------------------------------------- --- | This module defines our application's state type and an alias for its --- handler monad. -module Application where - ------------------------------------------------------------------------------- -import Control.Lens -import Snap.Snaplet -import Snap.Snaplet.Heist -import Snap.Snaplet.Auth -import Snap.Snaplet.Session - ------------------------------------------------------------------------------- -data App = App - { _heist :: Snaplet (Heist App) - , _sess :: Snaplet SessionManager - , _auth :: Snaplet (AuthManager App) - } - -makeLenses ''App - -instance HasHeist App where - heistLens = subSnaplet heist - - ------------------------------------------------------------------------------- -type AppHandler = Handler App App - - diff --git a/examples/7.8/snap/server/src/Main.hs b/examples/7.8/snap/server/src/Main.hs deleted file mode 100644 index cad1698..0000000 --- a/examples/7.8/snap/server/src/Main.hs +++ /dev/null @@ -1,114 +0,0 @@ -{-# LANGUAGE CPP #-} -{-# LANGUAGE TemplateHaskell #-} - -{- - -NOTE: Don't modify this file unless you know what you are doing. If you are -new to snap, start with Site.hs and Application.hs. This file contains -boilerplate needed for dynamic reloading and is not meant for general -consumption. - -Occasionally if we modify the way the dynamic reloader works and you want to -upgrade, you might have to swap out this file for a newer version. But in -most cases you'll never need to modify this code. - --} -module Main where - ------------------------------------------------------------------------------- -import Control.Exception (SomeException, try) -import qualified Data.Text as T -import Snap.Http.Server -import Snap.Snaplet -import Snap.Snaplet.Config -import Snap.Core -import System.IO -import Site - -#ifdef DEVELOPMENT -import Snap.Loader.Dynamic -#else -import Snap.Loader.Static -#endif - - ------------------------------------------------------------------------------- --- | This is the entry point for this web server application. It supports --- easily switching between interpreting source and running statically compiled --- code. --- --- In either mode, the generated program should be run from the root of the --- project tree. When it is run, it locates its templates, static content, and --- source files in development mode, relative to the current working directory. --- --- When compiled with the development flag, only changes to the libraries, your --- cabal file, or this file should require a recompile to be picked up. --- Everything else is interpreted at runtime. There are a few consequences of --- this. --- --- First, this is much slower. Running the interpreter takes a significant --- chunk of time (a couple tenths of a second on the author's machine, at this --- time), regardless of the simplicity of the loaded code. In order to --- recompile and re-load server state as infrequently as possible, the source --- directories are watched for updates, as are any extra directories specified --- below. --- --- Second, the generated server binary is MUCH larger, since it links in the --- GHC API (via the hint library). --- --- Third, and the reason you would ever want to actually compile with --- development mode, is that it enables a faster development cycle. You can --- simply edit a file, save your changes, and hit reload to see your changes --- reflected immediately. --- --- When this is compiled without the development flag, all the actions are --- statically compiled in. This results in faster execution, a smaller binary --- size, and having to recompile the server for any code change. --- -main :: IO () -main = do - -- Depending on the version of loadSnapTH in scope, this either enables - -- dynamic reloading, or compiles it without. The last argument to - -- loadSnapTH is a list of additional directories to watch for changes to - -- trigger reloads in development mode. It doesn't need to include source - -- directories, those are picked up automatically by the splice. - (conf, site, cleanup) <- $(loadSnapTH [| getConf |] - 'getActions - ["snaplets/heist/templates"]) - - _ <- try $ httpServe conf site :: IO (Either SomeException ()) - cleanup - - ------------------------------------------------------------------------------- --- | This action loads the config used by this application. The loaded config --- is returned as the first element of the tuple produced by the loadSnapTH --- Splice. The type is not solidly fixed, though it must be an IO action that --- produces the same type as 'getActions' takes. It also must be an instance of --- Typeable. If the type of this is changed, a full recompile will be needed to --- pick up the change, even in development mode. --- --- This action is only run once, regardless of whether development or --- production mode is in use. -getConf :: IO (Config Snap AppConfig) -getConf = commandLineAppConfig defaultConfig - - ------------------------------------------------------------------------------- --- | This function generates the the site handler and cleanup action from the --- configuration. In production mode, this action is only run once. In --- development mode, this action is run whenever the application is reloaded. --- --- Development mode also makes sure that the cleanup actions are run --- appropriately before shutdown. The cleanup action returned from loadSnapTH --- should still be used after the server has stopped handling requests, as the --- cleanup actions are only automatically run when a reload is triggered. --- --- This sample doesn't actually use the config passed in, but more --- sophisticated code might. -getActions :: Config Snap AppConfig -> IO (Snap (), IO ()) -getActions conf = do - (msgs, site, cleanup) <- runSnaplet - (appEnvironment =<< getOther conf) app - hPutStrLn stderr $ T.unpack msgs - return (site, cleanup) diff --git a/examples/7.8/snap/server/src/Site.hs b/examples/7.8/snap/server/src/Site.hs deleted file mode 100644 index 13624f4..0000000 --- a/examples/7.8/snap/server/src/Site.hs +++ /dev/null @@ -1,89 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - ------------------------------------------------------------------------------- --- | This module is where all the routes and handlers are defined for your --- site. The 'app' function is the initializer that combines everything --- together and is exported by this module. -module Site - ( app - ) where - ------------------------------------------------------------------------------- -import Control.Applicative -import Data.ByteString (ByteString) -import Data.Monoid -import qualified Data.Text as T -import Snap.Core -import Snap.Snaplet -import Snap.Snaplet.Auth -import Snap.Snaplet.Auth.Backends.JsonFile -import Snap.Snaplet.Heist -import Snap.Snaplet.Session.Backends.CookieSession -import Snap.Util.FileServe -import Heist -import qualified Heist.Interpreted as I ------------------------------------------------------------------------------- -import Application - - ------------------------------------------------------------------------------- --- | Render login form -handleLogin :: Maybe T.Text -> Handler App (AuthManager App) () -handleLogin authError = heistLocal (I.bindSplices errs) $ render "login" - where - errs = maybe mempty splice authError - splice err = "loginError" ## I.textSplice err - - ------------------------------------------------------------------------------- --- | Handle login submit -handleLoginSubmit :: Handler App (AuthManager App) () -handleLoginSubmit = - loginUser "login" "password" Nothing - (\_ -> handleLogin err) (redirect "/") - where - err = Just "Unknown user or password" - - ------------------------------------------------------------------------------- --- | Logs out and redirects the user to the site index. -handleLogout :: Handler App (AuthManager App) () -handleLogout = logout >> redirect "/" - - ------------------------------------------------------------------------------- --- | Handle new user form submit -handleNewUser :: Handler App (AuthManager App) () -handleNewUser = method GET handleForm <|> method POST handleFormSubmit - where - handleForm = render "new_user" - handleFormSubmit = registerUser "login" "password" >> redirect "/" - - ------------------------------------------------------------------------------- --- | The application's routes. -routes :: [(ByteString, Handler App App ())] -routes = [ ("/login", with auth handleLoginSubmit) - , ("/logout", with auth handleLogout) - , ("/new_user", with auth handleNewUser) - , ("", serveDirectory "static") - ] - - ------------------------------------------------------------------------------- --- | The application initializer. -app :: SnapletInit App App -app = makeSnaplet "app" "An snaplet example application." Nothing $ do - h <- nestSnaplet "" heist $ heistInit "templates" - s <- nestSnaplet "sess" sess $ - initCookieSessionManager "site_key.txt" "sess" (Just 3600) - - -- NOTE: We're using initJsonFileAuthManager here because it's easy and - -- doesn't require any kind of database server to run. In practice, - -- you'll probably want to change this to a more robust auth backend. - a <- nestSnaplet "auth" auth $ - initJsonFileAuthManager defAuthSettings sess "users.json" - addRoutes routes - addAuthSplices h auth - return $ App h s a - diff --git a/examples/7.8/snap/server/static/screen.css b/examples/7.8/snap/server/static/screen.css deleted file mode 100644 index b052609..0000000 --- a/examples/7.8/snap/server/static/screen.css +++ /dev/null @@ -1,26 +0,0 @@ -html { - padding: 0; - margin: 0; - background-color: #ffffff; - font-family: Verdana, Helvetica, sans-serif; -} -body { - padding: 0; - margin: 0; -} -a { - text-decoration: underline; -} -a :hover { - cursor: pointer; - text-decoration: underline; -} -img { - border: none; -} -#content { - padding-left: 1em; -} -#info { - font-size: 60%; -} diff --git a/examples/8.0/servant-api/Dockerfile b/examples/8.0/servant-api/Dockerfile deleted file mode 100644 index 26715b2..0000000 --- a/examples/8.0/servant-api/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM haskell:8 - -COPY . /opt/servant-api - -WORKDIR /opt/servant-api - -RUN stack build - -CMD ["stack","exec","servant-api-exe"] diff --git a/examples/8.0/servant-api/LICENSE b/examples/8.0/servant-api/LICENSE deleted file mode 100644 index fc03544..0000000 --- a/examples/8.0/servant-api/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -Copyright Author name here (c) 2016 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above - copyright notice, this list of conditions and the following - disclaimer in the documentation and/or other materials provided - with the distribution. - - * Neither the name of Author name here nor the names of other - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/examples/8.0/servant-api/Setup.hs b/examples/8.0/servant-api/Setup.hs deleted file mode 100644 index 9a994af..0000000 --- a/examples/8.0/servant-api/Setup.hs +++ /dev/null @@ -1,2 +0,0 @@ -import Distribution.Simple -main = defaultMain diff --git a/examples/8.0/servant-api/app/Main.hs b/examples/8.0/servant-api/app/Main.hs deleted file mode 100644 index f66a415..0000000 --- a/examples/8.0/servant-api/app/Main.hs +++ /dev/null @@ -1,6 +0,0 @@ -module Main where - -import Lib - -main :: IO () -main = startApp diff --git a/examples/8.0/servant-api/servant-api.cabal b/examples/8.0/servant-api/servant-api.cabal deleted file mode 100644 index 1e5adaf..0000000 --- a/examples/8.0/servant-api/servant-api.cabal +++ /dev/null @@ -1,45 +0,0 @@ -name: servant-api -version: 0.1.0.0 -synopsis: Initial project template from stack -description: Please see README.md -homepage: https://github.com/githubuser/servant-api#readme -license: BSD3 -license-file: LICENSE -author: Author name here -maintainer: example@example.com -copyright: 2016 Author name here -category: Web -build-type: Simple --- extra-source-files: -cabal-version: >=1.10 - -library - hs-source-dirs: src - exposed-modules: Lib - build-depends: base >= 4.7 && < 5 - , aeson - , servant-server - , wai - , warp - default-language: Haskell2010 - -executable servant-api-exe - hs-source-dirs: app - main-is: Main.hs - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: base - , servant-api - default-language: Haskell2010 - -test-suite servant-api-test - type: exitcode-stdio-1.0 - hs-source-dirs: test - main-is: Spec.hs - build-depends: base - , servant-api - ghc-options: -threaded -rtsopts -with-rtsopts=-N - default-language: Haskell2010 - -source-repository head - type: git - location: https://github.com/githubuser/servant-api diff --git a/examples/8.0/servant-api/src/Lib.hs b/examples/8.0/servant-api/src/Lib.hs deleted file mode 100644 index f985cc0..0000000 --- a/examples/8.0/servant-api/src/Lib.hs +++ /dev/null @@ -1,39 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE TemplateHaskell #-} -{-# LANGUAGE TypeOperators #-} -module Lib - ( startApp - ) where - -import Data.Aeson -import Data.Aeson.TH -import Network.Wai -import Network.Wai.Handler.Warp -import Servant - -data User = User - { userId :: Int - , userFirstName :: String - , userLastName :: String - } deriving (Eq, Show) - -$(deriveJSON defaultOptions ''User) - -type API = "users" :> Get '[JSON] [User] - -startApp :: IO () -startApp = run 8080 app - -app :: Application -app = serve api server - -api :: Proxy API -api = Proxy - -server :: Server API -server = return users - -users :: [User] -users = [ User 1 "Isaac" "Newton" - , User 2 "Albert" "Einstein" - ] diff --git a/examples/8.0/servant-api/stack.yaml b/examples/8.0/servant-api/stack.yaml deleted file mode 100644 index d2ae7e0..0000000 --- a/examples/8.0/servant-api/stack.yaml +++ /dev/null @@ -1,66 +0,0 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# http://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# resolver: ghcjs-0.1.0_ghc-7.10.2 -# resolver: -# name: custom-snapshot -# location: "./custom-snapshot.yaml" -resolver: nightly-2016-06-15 - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# - location: -# git: https://github.com/commercialhaskell/stack.git -# commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a -# extra-dep: true -# subdirs: -# - auto-update -# - wai -# -# A package marked 'extra-dep: true' will only be built if demanded by a -# non-dependency (i.e. a user package), and its test suites and benchmarks -# will not be run. This is useful for tweaking upstream packages. -packages: -- '.' -# Dependency packages to be pulled from upstream that are not in the resolver -# (e.g., acme-missiles-0.3) -extra-deps: [] - -# Override default flag values for local packages and extra-deps -flags: {} - -# Extra package databases containing global packages -extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=1.1" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor \ No newline at end of file diff --git a/examples/8.0/servant-api/test/Spec.hs b/examples/8.0/servant-api/test/Spec.hs deleted file mode 100644 index cd4753f..0000000 --- a/examples/8.0/servant-api/test/Spec.hs +++ /dev/null @@ -1,2 +0,0 @@ -main :: IO () -main = putStrLn "Test suite not yet implemented"