--- /srv/rebuilderd/tmp/rebuilderdwyXbNH/inputs/snap-templates_1.0.0.2-5+b1_i386.deb +++ /srv/rebuilderd/tmp/rebuilderdwyXbNH/out/snap-templates_1.0.0.2-5+b1_i386.deb ├── file list │ @@ -1,3 +1,3 @@ │ -rw-r--r-- 0 0 0 4 2025-02-14 06:38:41.000000 debian-binary │ --rw-r--r-- 0 0 0 896 2025-02-14 06:38:41.000000 control.tar.xz │ --rw-r--r-- 0 0 0 3154872 2025-02-14 06:38:41.000000 data.tar.xz │ +-rw-r--r-- 0 0 0 900 2025-02-14 06:38:41.000000 control.tar.xz │ +-rw-r--r-- 0 0 0 3156260 2025-02-14 06:38:41.000000 data.tar.xz ├── control.tar.xz │ ├── control.tar │ │ ├── ./md5sums │ │ │ ├── ./md5sums │ │ │ │┄ Files differ ├── data.tar.xz │ ├── data.tar │ │ ├── file list │ │ │ @@ -1,11 +1,11 @@ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./usr/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./usr/bin/ │ │ │ --rwxr-xr-x 0 root (0) root (0) 25438600 2025-02-14 06:38:41.000000 ./usr/bin/snap-framework │ │ │ +-rwxr-xr-x 0 root (0) root (0) 25438632 2025-02-14 06:38:41.000000 ./usr/bin/snap-framework │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./usr/share/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./usr/share/doc/ │ │ │ drwxr-xr-x 0 root (0) root (0) 0 2025-02-14 06:38:41.000000 ./usr/share/doc/snap-templates/ │ │ │ -rw-r--r-- 0 root (0) root (0) 273 2018-07-29 21:49:08.000000 ./usr/share/doc/snap-templates/CONTRIBUTORS │ │ │ -rw-r--r-- 0 root (0) root (0) 478 2025-02-14 06:38:41.000000 ./usr/share/doc/snap-templates/changelog.Debian.gz │ │ │ -rw-r--r-- 0 root (0) root (0) 245 2025-02-14 06:38:41.000000 ./usr/share/doc/snap-templates/changelog.Debian.i386.gz │ │ │ -rw-r--r-- 0 root (0) root (0) 1876 2022-04-21 23:09:50.000000 ./usr/share/doc/snap-templates/copyright │ │ ├── ./usr/bin/snap-framework │ │ │┄ File has been modified after NT_GNU_BUILD_ID has been applied. │ │ │ ├── readelf --wide --file-header {} │ │ │ │ @@ -6,15 +6,15 @@ │ │ │ │ OS/ABI: UNIX - System V │ │ │ │ ABI Version: 0 │ │ │ │ Type: EXEC (Executable file) │ │ │ │ Machine: Intel 80386 │ │ │ │ Version: 0x1 │ │ │ │ Entry point address: 0x8051050 │ │ │ │ Start of program headers: 52 (bytes into file) │ │ │ │ - Start of section headers: 25437520 (bytes into file) │ │ │ │ + Start of section headers: 25437552 (bytes into file) │ │ │ │ Flags: 0x0 │ │ │ │ Size of this header: 52 (bytes) │ │ │ │ Size of program headers: 32 (bytes) │ │ │ │ Number of program headers: 12 │ │ │ │ Size of section headers: 40 (bytes) │ │ │ │ Number of section headers: 27 │ │ │ │ Section header string table index: 26 │ │ │ ├── readelf --wide --program-header {} │ │ │ │ @@ -7,15 +7,15 @@ │ │ │ │ Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align │ │ │ │ PHDR 0x000034 0x08048034 0x08048034 0x00180 0x00180 R 0x4 │ │ │ │ INTERP 0x0001d8 0x080481d8 0x080481d8 0x00013 0x00013 R 0x1 │ │ │ │ [Requesting program interpreter: /lib/ld-linux.so.2] │ │ │ │ LOAD 0x000000 0x08048000 0x08048000 0x03090 0x03090 R 0x1000 │ │ │ │ LOAD 0x004000 0x0804c000 0x0804c000 0xf4478c 0xf4478c R E 0x1000 │ │ │ │ LOAD 0xf49000 0x08f91000 0x08f91000 0x7f64f0 0x7f64f0 R 0x1000 │ │ │ │ - LOAD 0x173fec8 0x09788ec8 0x09788ec8 0x102590 0x1063ec RW 0x1000 │ │ │ │ + LOAD 0x173fec8 0x09788ec8 0x09788ec8 0x1025b0 0x1063ec RW 0x1000 │ │ │ │ DYNAMIC 0x173fedc 0x09788edc 0x09788edc 0x00108 0x00108 RW 0x4 │ │ │ │ NOTE 0x0001b4 0x080481b4 0x080481b4 0x00024 0x00024 R 0x4 │ │ │ │ NOTE 0x173f4d0 0x097874d0 0x097874d0 0x00020 0x00020 R 0x4 │ │ │ │ GNU_EH_FRAME 0x12a42c0 0x092ec2c0 0x092ec2c0 0x11678c 0x11678c R 0x4 │ │ │ │ GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x10 │ │ │ │ GNU_RELRO 0x173fec8 0x09788ec8 0x09788ec8 0x00138 0x00138 R 0x1 │ │ │ ├── readelf --wide --sections {} │ │ │ │ @@ -1,8 +1,8 @@ │ │ │ │ -There are 27 section headers, starting at offset 0x1842550: │ │ │ │ +There are 27 section headers, starting at offset 0x1842570: │ │ │ │ │ │ │ │ Section Headers: │ │ │ │ [Nr] Name Type Addr Off Size ES Flg Lk Inf Al │ │ │ │ [ 0] NULL 00000000 000000 000000 00 0 0 0 │ │ │ │ [ 1] .note.gnu.build-id NOTE 080481b4 0001b4 000024 00 A 0 0 4 │ │ │ │ [ 2] .interp PROGBITS 080481d8 0001d8 000013 00 A 0 0 1 │ │ │ │ [ 3] .gnu.hash GNU_HASH 080481ec 0001ec 000050 04 A 4 0 4 │ │ │ │ @@ -22,15 +22,15 @@ │ │ │ │ [17] .note.ABI-tag NOTE 097874d0 173f4d0 000020 00 A 0 0 4 │ │ │ │ [18] .init_array INIT_ARRAY 09788ec8 173fec8 000004 04 WA 0 0 4 │ │ │ │ [19] .fini_array FINI_ARRAY 09788ecc 173fecc 000004 04 WA 0 0 4 │ │ │ │ [20] .data.rel.ro PROGBITS 09788ed0 173fed0 00000c 00 WA 0 0 16 │ │ │ │ [21] .dynamic DYNAMIC 09788edc 173fedc 000108 08 WA 5 0 4 │ │ │ │ [22] .got PROGBITS 09788fe4 173ffe4 000004 04 WA 0 0 4 │ │ │ │ [23] .got.plt PROGBITS 09788ff4 173fff4 0004a4 04 WA 0 0 4 │ │ │ │ - [24] .data PROGBITS 097894a0 17404a0 101fb8 00 WA 0 0 32 │ │ │ │ - [25] .bss NOBITS 0988b480 1842458 003e34 00 WA 0 0 64 │ │ │ │ - [26] .shstrtab STRTAB 00000000 1842458 0000f5 00 0 0 1 │ │ │ │ + [24] .data PROGBITS 097894a0 17404a0 101fd8 00 WA 0 0 32 │ │ │ │ + [25] .bss NOBITS 0988b480 1842478 003e34 00 WA 0 0 64 │ │ │ │ + [26] .shstrtab STRTAB 00000000 1842478 0000f5 00 0 0 1 │ │ │ │ Key to Flags: │ │ │ │ W (write), A (alloc), X (execute), M (merge), S (strings), I (info), │ │ │ │ L (link order), O (extra OS processing required), G (group), T (TLS), │ │ │ │ C (compressed), x (unknown), o (OS specific), E (exclude), │ │ │ │ D (mbind), p (processor specific) │ │ │ ├── readelf --wide --relocs {} │ │ │ │ @@ -1,23 +1,23 @@ │ │ │ │ │ │ │ │ Relocation section '.rel.dyn' at offset 0x26d8 contains 17 entries: │ │ │ │ Offset Info Type Sym. Value Symbol's Name │ │ │ │ 09788fe4 0000c606 R_386_GLOB_DAT 00000000 __gmon_start__ │ │ │ │ -0988b324 0000c001 R_386_32 00000000 ffi_prep_cif@LIBFFI_BASE_8.0 │ │ │ │ -0988b354 00009901 R_386_32 00000000 ffi_type_float@LIBFFI_BASE_8.0 │ │ │ │ -0988b364 00008201 R_386_32 00000000 ffi_type_double@LIBFFI_BASE_8.0 │ │ │ │ -0988b374 0000ca01 R_386_32 00000000 ffi_type_sint64@LIBFFI_BASE_8.0 │ │ │ │ -0988b384 0000ed01 R_386_32 00000000 ffi_type_uint64@LIBFFI_BASE_8.0 │ │ │ │ -0988b394 00008e01 R_386_32 00000000 ffi_type_sint32@LIBFFI_BASE_8.0 │ │ │ │ -0988b3a4 0000f401 R_386_32 00000000 ffi_type_uint32@LIBFFI_BASE_8.0 │ │ │ │ -0988b3b4 0000bf01 R_386_32 00000000 ffi_type_sint16@LIBFFI_BASE_8.0 │ │ │ │ -0988b3c4 0000b601 R_386_32 00000000 ffi_type_uint16@LIBFFI_BASE_8.0 │ │ │ │ -0988b3d4 00012e01 R_386_32 00000000 ffi_type_sint8@LIBFFI_BASE_8.0 │ │ │ │ -0988b3e4 0000cc01 R_386_32 00000000 ffi_type_uint8@LIBFFI_BASE_8.0 │ │ │ │ -0988b3f4 00004101 R_386_32 00000000 ffi_type_pointer@LIBFFI_BASE_8.0 │ │ │ │ +0988b344 0000c001 R_386_32 00000000 ffi_prep_cif@LIBFFI_BASE_8.0 │ │ │ │ +0988b374 00009901 R_386_32 00000000 ffi_type_float@LIBFFI_BASE_8.0 │ │ │ │ +0988b384 00008201 R_386_32 00000000 ffi_type_double@LIBFFI_BASE_8.0 │ │ │ │ +0988b394 0000ca01 R_386_32 00000000 ffi_type_sint64@LIBFFI_BASE_8.0 │ │ │ │ +0988b3a4 0000ed01 R_386_32 00000000 ffi_type_uint64@LIBFFI_BASE_8.0 │ │ │ │ +0988b3b4 00008e01 R_386_32 00000000 ffi_type_sint32@LIBFFI_BASE_8.0 │ │ │ │ +0988b3c4 0000f401 R_386_32 00000000 ffi_type_uint32@LIBFFI_BASE_8.0 │ │ │ │ +0988b3d4 0000bf01 R_386_32 00000000 ffi_type_sint16@LIBFFI_BASE_8.0 │ │ │ │ +0988b3e4 0000b601 R_386_32 00000000 ffi_type_uint16@LIBFFI_BASE_8.0 │ │ │ │ +0988b3f4 00012e01 R_386_32 00000000 ffi_type_sint8@LIBFFI_BASE_8.0 │ │ │ │ +0988b404 0000cc01 R_386_32 00000000 ffi_type_uint8@LIBFFI_BASE_8.0 │ │ │ │ +0988b414 00004101 R_386_32 00000000 ffi_type_pointer@LIBFFI_BASE_8.0 │ │ │ │ 09788ed0 00013705 R_386_COPY 09788ed0 ffi_type_void@LIBFFI_BASE_8.0 │ │ │ │ 0988b480 00013305 R_386_COPY 0988b480 __environ@GLIBC_2.0 │ │ │ │ 0988b488 00013605 R_386_COPY 0988b488 stderr@GLIBC_2.0 │ │ │ │ 0988b48c 00013205 R_386_COPY 0988b48c stdout@GLIBC_2.0 │ │ │ │ │ │ │ │ Relocation section '.rel.plt' at offset 0x2760 contains 294 entries: │ │ │ │ Offset Info Type Sym. Value Symbol's Name │ │ │ ├── readelf --wide --notes {} │ │ │ │ @@ -1,8 +1,8 @@ │ │ │ │ │ │ │ │ Displaying notes found in: .note.gnu.build-id │ │ │ │ Owner Data size Description │ │ │ │ - GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring) Build ID: 12f3d1fff13a2b99b22c5321bad96e4af8859e82 │ │ │ │ + GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring) Build ID: be736909ed613e6ac79ebd2ffc1e9a25a0cc17ec │ │ │ │ │ │ │ │ Displaying notes found in: .note.ABI-tag │ │ │ │ Owner Data size Description │ │ │ │ GNU 0x00000010 NT_GNU_ABI_TAG (ABI version tag) OS: Linux, ABI: 3.2.0 │ │ │ ├── strings --all --bytes=8 {} │ │ │ │ @@ -244,14 +244,45 @@ │ │ │ │ t$@Ph4/+ │ │ │ │ \$$ShT0+ │ │ │ │ RRPhh1+ │ │ │ │ PPSh,2+ │ │ │ │ QQRhh1+ │ │ │ │ ZYPhb3, │ │ │ │ main:Main.Help │ │ │ │ +:set -isrc │ │ │ │ +:set -hide-package MonadCatchIO-mtl │ │ │ │ +:set -hide-package monads-fd │ │ │ │ +:set -XOverloadedStrings │ │ │ │ +./log/placeholder │ │ │ │ +placeholder │ │ │ │ +./foo.cabal │ │ │ │ +Name: projname │ │ │ │ +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 │ │ │ │ +Executable projname │ │ │ │ + hs-source-dirs: src │ │ │ │ + main-is: Main.hs │ │ │ │ + Build-depends: │ │ │ │ + base >= 4 && < 5, │ │ │ │ + bytestring >= 0.9.1 && < 0.11, │ │ │ │ + mtl >= 2 && < 3, │ │ │ │ + snap-core >= 1.0 && < 1.1, │ │ │ │ + snap-server >= 1.0 && < 1.2 │ │ │ │ + if impl(ghc >= 6.12.0) │ │ │ │ + ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 │ │ │ │ + -fno-warn-unused-do-bind │ │ │ │ + ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 │ │ │ │ ./src/Main.hs │ │ │ │ {-# LANGUAGE OverloadedStrings #-} │ │ │ │ module Main where │ │ │ │ import Control.Applicative │ │ │ │ import Snap.Core │ │ │ │ import Snap.Util.FileServe │ │ │ │ import Snap.Http.Server │ │ │ │ @@ -264,49 +295,138 @@ │ │ │ │ ] <|> │ │ │ │ dir "static" (serveDirectory ".") │ │ │ │ echoHandler :: Snap () │ │ │ │ echoHandler = do │ │ │ │ param <- getParam "echoparam" │ │ │ │ maybe (writeBS "must specify echo/param in URL") │ │ │ │ writeBS param │ │ │ │ -./log/placeholder │ │ │ │ -placeholder │ │ │ │ -./foo.cabal │ │ │ │ +./snaplets │ │ │ │ +./snaplets/heist │ │ │ │ +./snaplets/heist/templates │ │ │ │ +./static │ │ │ │ Name: projname │ │ │ │ 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 projname │ │ │ │ hs-source-dirs: src │ │ │ │ main-is: Main.hs │ │ │ │ Build-depends: │ │ │ │ - base >= 4 && < 5, │ │ │ │ - bytestring >= 0.9.1 && < 0.11, │ │ │ │ - mtl >= 2 && < 3, │ │ │ │ - snap-core >= 1.0 && < 1.1, │ │ │ │ - snap-server >= 1.0 && < 1.2 │ │ │ │ - if impl(ghc >= 6.12.0) │ │ │ │ - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 │ │ │ │ - -fno-warn-unused-do-bind │ │ │ │ - ghc-options: -threaded -Wall -fwarn-tabs -funbox-strict-fields -O2 │ │ │ │ -:set -isrc │ │ │ │ -:set -hide-package MonadCatchIO-mtl │ │ │ │ -:set -hide-package monads-fd │ │ │ │ -:set -XOverloadedStrings │ │ │ │ -./static │ │ │ │ -./snaplets │ │ │ │ -./snaplets/heist │ │ │ │ -./snaplets/heist/templates │ │ │ │ + base >= 4.4 && < 5, │ │ │ │ + bytestring >= 0.9.1 && < 0.11, │ │ │ │ + heist >= 1.0 && < 1.2, │ │ │ │ + lens >= 3.7.6 && < 4.18, │ │ │ │ + map-syntax >= 0.2 && < 0.4, │ │ │ │ + monad-control >= 1.0 && < 1.1, │ │ │ │ + mtl >= 2 && < 2.3, │ │ │ │ + snap >= 1.0 && < 1.2, │ │ │ │ + snap-core >= 1.0 && < 1.1, │ │ │ │ + snap-server >= 1.0 && < 1.2, │ │ │ │ + snap-loader-static >= 1.0 && < 1.1, │ │ │ │ + text >= 0.11 && < 1.3, │ │ │ │ + time >= 1.1 && < 1.9, │ │ │ │ + xmlhtml >= 0.1 && < 0.3 │ │ │ │ + if flag(development) │ │ │ │ + build-depends: │ │ │ │ + snap-loader-dynamic >= 1.0 && < 1.1 │ │ │ │ + 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 │ │ │ │ + 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 │ │ │ │ +./src/Site.hs │ │ │ │ +{-# 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 │ │ │ │ + ) where │ │ │ │ +------------------------------------------------------------------------------ │ │ │ │ +import Control.Applicative │ │ │ │ +import Data.ByteString (ByteString) │ │ │ │ +import Data.Map.Syntax ((##)) │ │ │ │ +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 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" │ │ │ │ + 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 "/") │ │ │ │ + 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 │ │ │ │ + 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" Nothing (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 │ │ │ │ {-# 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 │ │ │ │ @@ -408,115 +528,54 @@ │ │ │ │ , _sess :: Snaplet SessionManager │ │ │ │ , _auth :: Snaplet (AuthManager App) │ │ │ │ makeLenses ''App │ │ │ │ instance HasHeist App where │ │ │ │ heistLens = subSnaplet heist │ │ │ │ ------------------------------------------------------------------------------ │ │ │ │ type AppHandler = Handler App App │ │ │ │ -./src/Site.hs │ │ │ │ -{-# 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 │ │ │ │ - ) where │ │ │ │ ------------------------------------------------------------------------------- │ │ │ │ -import Control.Applicative │ │ │ │ -import Data.ByteString (ByteString) │ │ │ │ -import Data.Map.Syntax ((##)) │ │ │ │ -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 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" │ │ │ │ - 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 "/") │ │ │ │ - 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 │ │ │ │ - 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" Nothing (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 │ │ │ │ -./static/screen.css │ │ │ │ - padding: 0; │ │ │ │ - margin: 0; │ │ │ │ - background-color: #ffffff; │ │ │ │ - font-family: Verdana, Helvetica, sans-serif; │ │ │ │ - padding: 0; │ │ │ │ - margin: 0; │ │ │ │ - text-decoration: underline; │ │ │ │ -a :hover { │ │ │ │ - cursor: pointer; │ │ │ │ - text-decoration: underline; │ │ │ │ - border: none; │ │ │ │ -#content { │ │ │ │ - padding-left: 1em; │ │ │ │ - font-size: 60%; │ │ │ │ -./snaplets/heist/templates/_login.tpl │ │ │ │ -
Don't have a login yet? Create a new user
│ │ │ │ ./snaplets/heist/templates/base.tpl │ │ │ │ │ │ │ │Congrats! You're logged in as '
Don't have a login yet? Create a new user
│ │ │ │ ./snaplets/heist/templates/userform.tpl │ │ │ │