Permalink
Browse files

More improvements. Added haddock docs, a style guide, a heist

tutorial, etc.
  • Loading branch information...
1 parent cbe9338 commit a5b008edf34f5313a9bbb1c2fa7e084772bf83e2 @mightybyte mightybyte committed Apr 22, 2010
Showing with 31,409 additions and 23 deletions.
  1. +1 −0 .gitignore
  2. +6 −3 snap-website.cabal
  3. +38 −7 src/Main.hs
  4. +1,880 −0 static/docs/heist/Text-Templating-Heist.html
  5. +264 −0 static/docs/heist/doc-index.html
  6. BIN static/docs/heist/fonts/DroidSerif-Bold.eot
  7. +223 −0 static/docs/heist/fonts/DroidSerif-Bold.svg
  8. BIN static/docs/heist/fonts/DroidSerif-Bold.ttf
  9. BIN static/docs/heist/fonts/DroidSerif-Bold.woff
  10. BIN static/docs/heist/fonts/DroidSerif-BoldItalic.eot
  11. +223 −0 static/docs/heist/fonts/DroidSerif-BoldItalic.svg
  12. BIN static/docs/heist/fonts/DroidSerif-BoldItalic.ttf
  13. BIN static/docs/heist/fonts/DroidSerif-BoldItalic.woff
  14. BIN static/docs/heist/fonts/DroidSerif-Italic.eot
  15. +223 −0 static/docs/heist/fonts/DroidSerif-Italic.svg
  16. BIN static/docs/heist/fonts/DroidSerif-Italic.ttf
  17. BIN static/docs/heist/fonts/DroidSerif-Italic.woff
  18. BIN static/docs/heist/fonts/DroidSerif-Regular.eot
  19. +223 −0 static/docs/heist/fonts/DroidSerif-Regular.svg
  20. BIN static/docs/heist/fonts/DroidSerif-Regular.ttf
  21. BIN static/docs/heist/fonts/DroidSerif-Regular.woff
  22. +27 −0 static/docs/heist/frames.html
  23. +139 −0 static/docs/heist/haddock-util.js
  24. +478 −0 static/docs/heist/haddock.css
  25. BIN static/docs/heist/haskell_icon.gif
  26. BIN static/docs/heist/heist.haddock
  27. +22 −0 static/docs/heist/index-frames.html
  28. +107 −0 static/docs/heist/index.html
  29. +137 −0 static/docs/heist/mini_Text-Templating-Heist.html
  30. BIN static/docs/heist/minus.gif
  31. BIN static/docs/heist/plus.gif
  32. +267 −0 static/docs/heist/src/Text-Templating-Heist-Constants.html
  33. +452 −0 static/docs/heist/src/Text-Templating-Heist.html
  34. +15 −0 static/docs/heist/src/hscolour.css
  35. +332 −0 static/docs/snap-core/Data-CIByteString.html
  36. +191 −0 static/docs/snap-core/Snap-Internal-Debug.html
  37. +3,648 −0 static/docs/snap-core/Snap-Internal-Http-Types.html
  38. +129 −0 static/docs/snap-core/Snap-Internal-Iteratee-Debug.html
  39. +792 −0 static/docs/snap-core/Snap-Iteratee.html
  40. +5,508 −0 static/docs/snap-core/Snap-Types.html
  41. +592 −0 static/docs/snap-core/Snap-Util-FileServe.html
  42. +324 −0 static/docs/snap-core/Snap-Util-GZip.html
  43. +148 −0 static/docs/snap-core/doc-index-62.html
  44. +150 −0 static/docs/snap-core/doc-index-95.html
  45. +170 −0 static/docs/snap-core/doc-index-A.html
  46. +156 −0 static/docs/snap-core/doc-index-B.html
  47. +290 −0 static/docs/snap-core/doc-index-C.html
  48. +210 −0 static/docs/snap-core/doc-index-D.html
  49. +280 −0 static/docs/snap-core/doc-index-E.html
  50. +258 −0 static/docs/snap-core/doc-index-F.html
  51. +204 −0 static/docs/snap-core/doc-index-G.html
  52. +212 −0 static/docs/snap-core/doc-index-H.html
  53. +200 −0 static/docs/snap-core/doc-index-I.html
  54. +154 −0 static/docs/snap-core/doc-index-J.html
  55. +192 −0 static/docs/snap-core/doc-index-L.html
  56. +206 −0 static/docs/snap-core/doc-index-M.html
  57. +162 −0 static/docs/snap-core/doc-index-N.html
  58. +152 −0 static/docs/snap-core/doc-index-O.html
  59. +242 −0 static/docs/snap-core/doc-index-P.html
  60. +502 −0 static/docs/snap-core/doc-index-R.html
  61. +276 −0 static/docs/snap-core/doc-index-S.html
  62. +202 −0 static/docs/snap-core/doc-index-T.html
  63. +188 −0 static/docs/snap-core/doc-index-U.html
  64. +174 −0 static/docs/snap-core/doc-index-W.html
  65. +138 −0 static/docs/snap-core/doc-index.html
  66. BIN static/docs/snap-core/fonts/DroidSerif-Bold.eot
  67. +223 −0 static/docs/snap-core/fonts/DroidSerif-Bold.svg
  68. BIN static/docs/snap-core/fonts/DroidSerif-Bold.ttf
  69. BIN static/docs/snap-core/fonts/DroidSerif-Bold.woff
  70. BIN static/docs/snap-core/fonts/DroidSerif-BoldItalic.eot
  71. +223 −0 static/docs/snap-core/fonts/DroidSerif-BoldItalic.svg
  72. BIN static/docs/snap-core/fonts/DroidSerif-BoldItalic.ttf
  73. BIN static/docs/snap-core/fonts/DroidSerif-BoldItalic.woff
  74. BIN static/docs/snap-core/fonts/DroidSerif-Italic.eot
  75. +223 −0 static/docs/snap-core/fonts/DroidSerif-Italic.svg
  76. BIN static/docs/snap-core/fonts/DroidSerif-Italic.ttf
  77. BIN static/docs/snap-core/fonts/DroidSerif-Italic.woff
  78. BIN static/docs/snap-core/fonts/DroidSerif-Regular.eot
  79. +223 −0 static/docs/snap-core/fonts/DroidSerif-Regular.svg
  80. BIN static/docs/snap-core/fonts/DroidSerif-Regular.ttf
  81. BIN static/docs/snap-core/fonts/DroidSerif-Regular.woff
  82. +27 −0 static/docs/snap-core/frames.html
  83. +139 −0 static/docs/snap-core/haddock-util.js
  84. +478 −0 static/docs/snap-core/haddock.css
  85. BIN static/docs/snap-core/haskell_icon.gif
  86. +43 −0 static/docs/snap-core/index-frames.html
  87. +286 −0 static/docs/snap-core/index.html
  88. +35 −0 static/docs/snap-core/mini_Data-CIByteString.html
  89. +33 −0 static/docs/snap-core/mini_Snap-Internal-Debug.html
  90. +189 −0 static/docs/snap-core/mini_Snap-Internal-Http-Types.html
  91. +25 −0 static/docs/snap-core/mini_Snap-Internal-Iteratee-Debug.html
  92. +97 −0 static/docs/snap-core/mini_Snap-Iteratee.html
  93. +355 −0 static/docs/snap-core/mini_Snap-Types.html
  94. +47 −0 static/docs/snap-core/mini_Snap-Util-FileServe.html
  95. +29 −0 static/docs/snap-core/mini_Snap-Util-GZip.html
  96. BIN static/docs/snap-core/minus.gif
  97. BIN static/docs/snap-core/plus.gif
  98. BIN static/docs/snap-core/snap-core.haddock
  99. +66 −0 static/docs/snap-core/src/Data-CIByteString.html
  100. +49 −0 static/docs/snap-core/src/Snap-Internal-Debug.html
  101. +572 −0 static/docs/snap-core/src/Snap-Internal-Http-Types.html
  102. +44 −0 static/docs/snap-core/src/Snap-Internal-Iteratee-Debug.html
  103. +169 −0 static/docs/snap-core/src/Snap-Internal-Routing.html
  104. +401 −0 static/docs/snap-core/src/Snap-Internal-Types.html
  105. +203 −0 static/docs/snap-core/src/Snap-Iteratee.html
  106. +122 −0 static/docs/snap-core/src/Snap-Types.html
  107. +285 −0 static/docs/snap-core/src/Snap-Util-FileServe.html
  108. +326 −0 static/docs/snap-core/src/Snap-Util-GZip.html
  109. +15 −0 static/docs/snap-core/src/hscolour.css
  110. +289 −0 static/docs/snap-server/Snap-Http-Server-Config.html
  111. +225 −0 static/docs/snap-server/Snap-Http-Server.html
  112. +510 −0 static/docs/snap-server/System-FastLogger.html
  113. +168 −0 static/docs/snap-server/doc-index.html
  114. BIN static/docs/snap-server/fonts/DroidSerif-Bold.eot
  115. +223 −0 static/docs/snap-server/fonts/DroidSerif-Bold.svg
  116. BIN static/docs/snap-server/fonts/DroidSerif-Bold.ttf
  117. BIN static/docs/snap-server/fonts/DroidSerif-Bold.woff
  118. BIN static/docs/snap-server/fonts/DroidSerif-BoldItalic.eot
  119. +223 −0 static/docs/snap-server/fonts/DroidSerif-BoldItalic.svg
  120. BIN static/docs/snap-server/fonts/DroidSerif-BoldItalic.ttf
  121. BIN static/docs/snap-server/fonts/DroidSerif-BoldItalic.woff
  122. BIN static/docs/snap-server/fonts/DroidSerif-Italic.eot
  123. +223 −0 static/docs/snap-server/fonts/DroidSerif-Italic.svg
  124. BIN static/docs/snap-server/fonts/DroidSerif-Italic.ttf
  125. BIN static/docs/snap-server/fonts/DroidSerif-Italic.woff
  126. BIN static/docs/snap-server/fonts/DroidSerif-Regular.eot
  127. +223 −0 static/docs/snap-server/fonts/DroidSerif-Regular.svg
  128. BIN static/docs/snap-server/fonts/DroidSerif-Regular.ttf
  129. BIN static/docs/snap-server/fonts/DroidSerif-Regular.woff
  130. +27 −0 static/docs/snap-server/frames.html
  131. +139 −0 static/docs/snap-server/haddock-util.js
  132. +478 −0 static/docs/snap-server/haddock.css
  133. BIN static/docs/snap-server/haskell_icon.gif
  134. +28 −0 static/docs/snap-server/index-frames.html
  135. +149 −0 static/docs/snap-server/index.html
  136. +31 −0 static/docs/snap-server/mini_Snap-Http-Server-Config.html
  137. +25 −0 static/docs/snap-server/mini_Snap-Http-Server.html
  138. +47 −0 static/docs/snap-server/mini_System-FastLogger.html
  139. BIN static/docs/snap-server/minus.gif
  140. BIN static/docs/snap-server/plus.gif
  141. BIN static/docs/snap-server/snap-server.haddock
  142. +133 −0 static/docs/snap-server/src/Snap-Http-Server-Config.html
  143. +32 −0 static/docs/snap-server/src/Snap-Http-Server.html
  144. +409 −0 static/docs/snap-server/src/Snap-Internal-Http-Parser.html
  145. +111 −0 static/docs/snap-server/src/Snap-Internal-Http-Server-Date.html
  146. +261 −0 static/docs/snap-server/src/Snap-Internal-Http-Server-SimpleBackend.html
  147. +515 −0 static/docs/snap-server/src/Snap-Internal-Http-Server.html
  148. +282 −0 static/docs/snap-server/src/System-FastLogger.html
  149. +15 −0 static/docs/snap-server/src/hscolour.css
  150. +7 −2 templates/contribute.tpl
  151. +2 −2 templates/docs.tpl
  152. +5 −5 templates/nav.tpl
  153. +4 −4 templates/page.tpl
  154. +274 −0 templates/style-guide.tpl
  155. +317 −0 templates/tutorials/heist.tpl
View
@@ -7,6 +7,7 @@ w2/builder
w2/builder.hi
w2/builder.o
*.swp
+*.log
.hpc
Setup.hs
dist
View
@@ -21,7 +21,8 @@ Executable snap-website
transformers,
snap-core,
snap-server,
- heist
+ heist,
+ filepath
-- Modules not exported by this package.
-- Other-modules:
@@ -30,9 +31,11 @@ Executable snap-website
-- Build-tools:
if impl(ghc >= 6.12.0)
- ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields
+ ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields
-threaded -fno-warn-unused-do-bind
else
- ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields
+ ghc-options: -O2 -Wall -fwarn-tabs -funbox-strict-fields
-threaded
+ Extensions: OverloadedStrings
+
View
@@ -1,4 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
module Main where
import Directory
@@ -9,25 +8,57 @@ import Control.Monad.Trans
import Snap.Http.Server
import Snap.Types
import Snap.Util.FileServe
+import System.FilePath
import Text.Templating.Heist
+--templateServe :: TemplateState IO
+-- -> Snap ()
+--templateServe ts = do
+-- req <- getRequest
+-- let pInfo = S.unpack $ rqPathInfo req
+-- fp <- resolvePath pInfo
+-- let fn = takeFileName fp
+-- where
+-- resolvePath p = do
+-- -- relative paths only!
+-- when (not $ isRelative p) pass
+--
+-- -- check that we don't have any sneaky .. paths
+-- let dirs = splitDirectories p
+-- when (elem ".." dirs) pass
+--
+-- let f = root </> p
+--
+-- -- check that the file exists
+-- liftIO (doesFileExist f) >>= flip unless pass
+--
+-- return f
+
site :: TemplateState IO -> Snap ()
site ts =
- ifTop (writeBS =<< liftIO (renderTemplate ts "index")) <|>
+ ifTop (maybe pass writeBS =<< liftIO (renderTemplate ts "index")) <|>
template "about" <|>
template "download" <|>
template "docs" <|>
template "contribute" <|>
template "news" <|>
+ template "heist-tutorial" <|>
+ template "style-guide" <|>
+ template "tutorials/heist" <|>
fileServe "static"
where
- template n = dir n (writeBS =<< liftIO (renderTemplate ts n))
+ template n = path n (maybe pass writeBS =<< liftIO (renderTemplate' "templates" n))
main :: IO ()
main = do
args <- getArgs
+ port <- case args of
+ [] -> error "You must specify a port!" >> exitFailure
+ port:_ -> return $ read port
+
templateState <- loadTemplates "templates"
- httpServe "*" (read $ head args) "achilles"
- (Just "access.log")
- (Just "error.log")
- (site templateState)
+ httpServe "*" port "achilles"
+ (Just "access.log")
+ (Just "error.log")
+ (site templateState)
+
Oops, something went wrong.

0 comments on commit a5b008e

Please sign in to comment.