Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 95802d8b5dd761b98a6371b7f4b9a390a5c6dc7e @Palmik committed Mar 20, 2011
0 README
No changes.
@@ -0,0 +1,29 @@
+module Paths_pastie (
+ version,
+ getBinDir, getLibDir, getDataDir, getLibexecDir,
+ getDataFileName
+ ) where
+
+import Data.Version (Version(..))
+import System.Environment (getEnv)
+
+version :: Version
+version = Version {versionBranch = [0,1], versionTags = []}
+
+bindir, libdir, datadir, libexecdir :: FilePath
+
+bindir = "/home/palmik/.cabal/bin"
+libdir = "/home/palmik/.cabal/lib/pastie-0.1/ghc-7.0.2"
+datadir = "/home/palmik/.cabal/share/pastie-0.1"
+libexecdir = "/home/palmik/.cabal/libexec"
+
+getBinDir, getLibDir, getDataDir, getLibexecDir :: IO FilePath
+getBinDir = catch (getEnv "pastie_bindir") (\_ -> return bindir)
+getLibDir = catch (getEnv "pastie_libdir") (\_ -> return libdir)
+getDataDir = catch (getEnv "pastie_datadir") (\_ -> return datadir)
+getLibexecDir = catch (getEnv "pastie_libexecdir") (\_ -> return libexecdir)
+
+getDataFileName :: FilePath -> IO FilePath
+getDataFileName name = do
+ dir <- getDataDir
+ return (dir ++ "/" ++ name)
@@ -0,0 +1,107 @@
+/* DO NOT EDIT: This file is automatically generated by Cabal */
+
+/* package MonadCatchIO-transformers-0.2.2.2 */
+#define VERSION_MonadCatchIO_transformers "0.2.2.2"
+#define MIN_VERSION_MonadCatchIO_transformers(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 2 || \
+ (major1) == 0 && (major2) == 2 && (minor) <= 2)
+
+/* package base-4.3.1.0 */
+#define VERSION_base "4.3.1.0"
+#define MIN_VERSION_base(major1,major2,minor) (\
+ (major1) < 4 || \
+ (major1) == 4 && (major2) < 3 || \
+ (major1) == 4 && (major2) == 3 && (minor) <= 1)
+
+/* package bson-0.1.3 */
+#define VERSION_bson "0.1.3"
+#define MIN_VERSION_bson(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 1 || \
+ (major1) == 0 && (major2) == 1 && (minor) <= 3)
+
+/* package bytestring-0.9.1.10 */
+#define VERSION_bytestring "0.9.1.10"
+#define MIN_VERSION_bytestring(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 9 || \
+ (major1) == 0 && (major2) == 9 && (minor) <= 1)
+
+/* package compact-string-fix-0.3.1 */
+#define VERSION_compact_string_fix "0.3.1"
+#define MIN_VERSION_compact_string_fix(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 3 || \
+ (major1) == 0 && (major2) == 3 && (minor) <= 1)
+
+/* package heist-0.5.1.0 */
+#define VERSION_heist "0.5.1.0"
+#define MIN_VERSION_heist(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 5 || \
+ (major1) == 0 && (major2) == 5 && (minor) <= 1)
+
+/* package mongoDB-0.9 */
+#define VERSION_mongoDB "0.9"
+#define MIN_VERSION_mongoDB(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 9 || \
+ (major1) == 0 && (major2) == 9 && (minor) <= 0)
+
+/* package mtl-2.0.1.0 */
+#define VERSION_mtl "2.0.1.0"
+#define MIN_VERSION_mtl(major1,major2,minor) (\
+ (major1) < 2 || \
+ (major1) == 2 && (major2) < 0 || \
+ (major1) == 2 && (major2) == 0 && (minor) <= 1)
+
+/* package snap-0.4.1 */
+#define VERSION_snap "0.4.1"
+#define MIN_VERSION_snap(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 4 || \
+ (major1) == 0 && (major2) == 4 && (minor) <= 1)
+
+/* package snap-core-0.4.1 */
+#define VERSION_snap_core "0.4.1"
+#define MIN_VERSION_snap_core(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 4 || \
+ (major1) == 0 && (major2) == 4 && (minor) <= 1)
+
+/* package snap-extension-mongodb-0.3.2.0 */
+#define VERSION_snap_extension_mongodb "0.3.2.0"
+#define MIN_VERSION_snap_extension_mongodb(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 3 || \
+ (major1) == 0 && (major2) == 3 && (minor) <= 2)
+
+/* package snap-server-0.4.1 */
+#define VERSION_snap_server "0.4.1"
+#define MIN_VERSION_snap_server(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 4 || \
+ (major1) == 0 && (major2) == 4 && (minor) <= 1)
+
+/* package text-0.11.0.5 */
+#define VERSION_text "0.11.0.5"
+#define MIN_VERSION_text(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 11 || \
+ (major1) == 0 && (major2) == 11 && (minor) <= 0)
+
+/* package time-1.2.0.3 */
+#define VERSION_time "1.2.0.3"
+#define MIN_VERSION_time(major1,major2,minor) (\
+ (major1) < 1 || \
+ (major1) == 1 && (major2) < 2 || \
+ (major1) == 1 && (major2) == 2 && (minor) <= 0)
+
+/* package xmlhtml-0.1.3 */
+#define VERSION_xmlhtml "0.1.3"
+#define MIN_VERSION_xmlhtml(major1,major2,minor) (\
+ (major1) < 0 || \
+ (major1) == 0 && (major2) < 1 || \
+ (major1) == 0 && (major2) == 1 && (minor) <= 3)
+
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
+[]

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,12 @@
+127.0.0.1 - - [18/Mar/2011:16:25:45 +0100] "GET / HTTP/1.1" 200 - - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:45 +0100] "GET /screen.css HTTP/1.1" 200 - "http://0.0.0.0:8000/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:45 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:45 +0100] "GET /echo/cats HTTP/1.1" 200 - "http://0.0.0.0:8000/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:45 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:49 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:49 +0100] "GET /echo/dogs HTTP/1.1" 200 - "http://0.0.0.0:8000/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:49 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:51 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:51 +0100] "GET /echo/fish HTTP/1.1" 200 - "http://0.0.0.0:8000/" "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:51 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
+127.0.0.1 - - [18/Mar/2011:16:25:51 +0100] "GET /favicon.ico HTTP/1.1" 404 3 - "Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.133 Safari/534.16"
@@ -0,0 +1,6 @@
+[18/Mar/2011:16:25:37 +0100] Server.httpServe: START (EventLoopSimple)
+[18/Mar/2011:16:35:12 +0100] Server.httpServe: SHUTDOWN
+[18/Mar/2011:16:35:12 +0100] Server.httpServe: BACKEND STOPPED
+[18/Mar/2011:17:12:23 +0100] Server.httpServe: START (EventLoopSimple)
+[18/Mar/2011:17:24:56 +0100] Server.httpServe: SHUTDOWN
+[18/Mar/2011:17:24:56 +0100] Server.httpServe: BACKEND STOPPED
@@ -0,0 +1,56 @@
+Name: pastie
+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
+
+Executable pastie
+ hs-source-dirs: src
+ main-is: Main.hs
+
+ Build-depends:
+ base >= 4 && < 5,
+ bytestring >= 0.9.1 && < 0.10,
+ heist >= 0.5.1,
+ MonadCatchIO-transformers >= 0.2.1 && < 0.3,
+ mtl >= 2 && < 3,
+ snap == 0.4.*,
+ snap-core == 0.4.*,
+ snap-server == 0.4.*,
+ text >= 0.11 && < 0.12,
+ time >= 1.1 && < 1.3,
+ xmlhtml == 0.1.*,
+ snap-extension-mongodb,
+ bson,
+ compact-string-fix,
+ mongoDB
+
+ extensions: TypeSynonymInstances MultiParamTypeClasses
+
+ if flag(development)
+ cpp-options: -DDEVELOPMENT
+ build-depends: hint >= 0.3.2 && < 0.4
+ -- 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
+
@@ -0,0 +1,26 @@
+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%;
+}
@@ -0,0 +1,13 @@
+<html>
+ <head>
+ <title>Echo Page</title>
+ </head>
+ <body>
+ <div id="content">
+ <h1>Is there an echo in here?</h1>
+ </div>
+ <p>You wanted me to say this?</p>
+ <p>"<message/>"</p>
+ <p><a href="/">Return</a></p>
+ </body>
+</html>
@@ -0,0 +1,32 @@
+<html>
+ <head>
+ <title>Snap web server</title>
+ <link rel="stylesheet" type="text/css" href="screen.css"/>
+ </head>
+ <body>
+ <div id="content">
+ <h1>It works!</h1>
+ <p>
+ This is a simple demo page served using
+ <a href="http://snapframework.com/docs/tutorials/heist">Heist</a>
+ and the <a href="http://snapframework.com/">Snap</a> web framework.
+ </p>
+ <p>
+ Echo test:
+ <a href="/echo/cats">cats</a>
+ <a href="/echo/dogs">dogs</a>
+ <a href="/echo/fish">fish</a>
+ </p>
+ <table id="info">
+ <tr>
+ <td>Config generated at:</td>
+ <td><start-time/></td>
+ </tr>
+ <tr>
+ <td>Page generated at:</td>
+ <td><current-time/></td>
+ </tr>
+ </table>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,5 @@
+<div class="post">
+ <h3 class="title"><h3>
+ <div class="content"></div>
+ <div class="description"></div>
+</div>
@@ -0,0 +1,67 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+{-
+
+This module defines our application's monad and any application-specific
+information it requires.
+
+-}
+
+module Application
+( Application
+, applicationInitializer
+) where
+
+import Snap.Extension
+import Snap.Extension.Heist.Impl
+import Snap.Extension.Timer.Impl
+import Snap.Extension.DB.MongoDB
+
+
+------------------------------------------------------------------------------
+-- | 'Application' is our application's monad. It uses 'SnapExtend' from
+-- 'Snap.Extension' to provide us with an extended 'MonadSnap' making use of
+-- the Heist and Timer Snap extensions.
+type Application = SnapExtend ApplicationState
+
+
+------------------------------------------------------------------------------
+-- | 'ApplicationState' is a record which contains the state needed by the Snap
+-- extensions we're using. We're using Heist so we can easily render Heist
+-- templates, and Timer simply to illustrate the config loading differences
+-- between development and production modes.
+data ApplicationState = ApplicationState
+ { templateState :: HeistState Application
+ , timerState :: TimerState
+ , databaseState :: MongoDBState
+ }
+
+
+------------------------------------------------------------------------------
+instance HasHeistState Application ApplicationState where
+ getHeistState = templateState
+ setHeistState s a = a { templateState = s }
+
+
+------------------------------------------------------------------------------
+instance HasTimerState ApplicationState where
+ getTimerState = timerState
+ setTimerState s a = a { timerState = s }
+
+------------------------------------------------------------------------------
+instance HasMongoDBState ApplicationState where
+ getMongoDBState = databaseState
+ setMongoDBState s a = a { databaseState = s }
+
+------------------------------------------------------------------------------
+-- | The 'Initializer' for ApplicationState. For more on 'Initializer's, see
+-- the documentation from the snap package. Briefly, this is used to
+-- generate the 'ApplicationState' needed for our application and will
+-- automatically generate reload\/cleanup actions for us which we don't need
+-- to worry about.
+applicationInitializer :: Initializer ApplicationState
+applicationInitializer = do
+ heist <- heistInitializer "resources/templates"
+ timer <- timerInitializer
+ database <- mongoDBInitializer (Host "127.0.0.1" $ PortNumber 1234) 1 "pastie"
+ return $ ApplicationState heist timer database
@@ -0,0 +1,26 @@
+{-# LANGUAGE FlexibleContexts #-}
+
+module Controller.Paste
+( recentPastesSplice
+) where
+
+import qualified Data.Text as T
+
+import Text.Templating.Heist
+
+import Application
+import Model.Paste
+
+
+pasteParts :: Paste -> [(T.Text, T.Text)]
+pasteParts paste = map applyAndPack [ ("title", pasteTitle)
+ , ("content", pasteContent)
+ , ("description", pasteDescription)
+ , ("language", pasteLanguage) ]
+ where applyAndPack (x, f) = (T.pack x, T.pack $ f paste)
+
+-- recentPastesSplice :: Splice Application
+recentPastesSplice :: (Monad m, DbAccess (TemplateMonad m), MonadMongoDB (TemplateMonad m)) => Splice m
+recentPastesSplice = do
+ pastes <- getRecentPastes
+ mapSplices (runChildrenWithText . pasteParts) pastes
Oops, something went wrong.

0 comments on commit 95802d8

Please sign in to comment.