Browse files

Cleanup imports/exports/warnings

  • Loading branch information...
1 parent 1fa756f commit 72a0bf12d8ed820879a72d75f1ff4f1296bc273a @gregorycollins committed Jul 24, 2009
View
31 blaaargh.cabal
@@ -1,7 +1,7 @@
Name: Blaaargh
Version: 0.2
Synopsis: A simple content-management system for Happstack,
- suitable for small-to-medium-sized websites
+ suitable for small-to-medium-sized websites
License: BSD3
License-file: LICENSE
Author: Gregory Collins
@@ -15,20 +15,20 @@ Cabal-Version: >= 1.6
Library
hs-source-dirs:
src
- exposed-modules: Blaaargh.Exception,
- Blaaargh.Post,
- Blaaargh.Types,
- Blaaargh.Handlers,
- Blaaargh.Templates,
- Blaaargh.Time,
- Blaaargh.Util.ExcludeList
- Blaaargh.Util.Templates,
- Blaaargh
+ exposed-modules: Blaaargh
+ , Blaaargh.Time
+ , Blaaargh.Exception
+ , Blaaargh.Util.ExcludeList
+ , Blaaargh.Util.Templates
+ , Blaaargh.Types
+ , Blaaargh.Post
+ , Blaaargh.Templates
+ , Blaaargh.Handlers
+
ghc-options: -Wall -funbox-strict-fields -O2 -fvia-C -optc-O3 -funfolding-use-threshold=16
Build-Depends: base >= 4 && <5,
HStringTemplate,
- HTTP,
bytestring,
ConfigFile,
containers,
@@ -39,7 +39,6 @@ Library
hslogger,
mtl,
old-locale,
- old-time,
pandoc,
split,
time,
@@ -48,26 +47,24 @@ Library
-Executable blaaargh-test
- Main-is: Test/TestBlaaargh.hs
+Executable blaaargh
+ Main-is: Standalone/BlaaarghStandalone.hs
hs-source-dirs: src
ghc-options: -Wall -funbox-strict-fields -fglasgow-exts -O2 -fvia-C -optc-O3 -threaded
ghc-prof-options: -Wall -funbox-strict-fields -fglasgow-exts -O2 -fvia-C -optc-O3 -threaded -prof -auto-all
Build-Depends: base >= 4 && <5,
HStringTemplate,
- HStringTemplateHelpers,
- HTTP,
bytestring,
ConfigFile,
containers,
directory,
feed,
filepath,
happstack-server >= 0.3,
+ hslogger,
mtl,
old-locale,
- old-time,
pandoc,
split,
time,
View
16 src/Blaaargh.hs
@@ -1,27 +1,31 @@
module Blaaargh
+ ( initBlaaargh
+ , serveBlaaargh
+ , runBlaaarghHandler
+ , addExtraTemplateArguments
+ , BlaaarghException
+ , BlaaarghMonad
+ , BlaaarghHandler
+ , BlaaarghState
+ )
where
------------------------------------------------------------------------------
import Control.Exception
import Control.Monad
import qualified Data.ByteString.Char8 as B
-import Data.ByteString.Char8 (ByteString)
import Data.Char
import qualified Data.ConfigFile as Cfg
import Data.Either
import Data.List
-import Data.List.Split
import System.Directory
import System.FilePath
import qualified Text.Atom.Feed as Atom
import Text.Printf
-import Text.StringTemplate
------------------------------------------------------------------------------
-import Blaaargh.Exception
import Blaaargh.Handlers
import Blaaargh.Post
-import Blaaargh.Templates
import Blaaargh.Types
import qualified Blaaargh.Util.ExcludeList as EL
import Blaaargh.Util.ExcludeList (ExcludeList)
@@ -36,7 +40,7 @@ initBlaaargh path = do
(feed, siteURL, baseURL, excludeList) <- readConfig configFilePath
- cmap <- buildContentMap siteURL baseURL contentDir
+ cmap <- buildContentMap baseURL contentDir
templates <- readTemplateDir templateDir
return BlaaarghState {
View
12 src/Blaaargh/Handlers.hs
@@ -2,13 +2,11 @@
module Blaaargh.Handlers where
-import Control.Monad (mzero)
import Control.Monad.State
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as L
import Data.ByteString.Char8 (ByteString)
import Data.List
-import Data.Map (Map)
import qualified Data.Map as Map
import Data.Maybe
import Data.Monoid
@@ -79,7 +77,7 @@ serveBlaaargh = do
(\f -> case f of
(ContentStatic fp) -> serveStatic fp
(ContentPost post) -> lift $ servePost (soFar ++ [a]) post
- (ContentDirectory p d) -> serveIndex (soFar ++ [a]) d)
+ (ContentDirectory _ d) -> serveIndex (soFar ++ [a]) d)
(Map.lookup a content)
@@ -192,8 +190,8 @@ serveIndex soFar content = do
let mbPost = Map.lookup "index" content
let baseURL = B.pack $ blaaarghBaseURL state
- let path = B.concat $ intersperse "/" $ soFar ++ ["feed.xml"]
- let feedURL = B.unpack $ B.concat [baseURL, "/", path]
+ let fdPath = B.concat $ intersperse "/" $ soFar ++ ["feed.xml"]
+ let feedURL = B.unpack $ B.concat [baseURL, "/", fdPath]
let title = concat
@@ -247,9 +245,9 @@ serveFeed soFar content = do
else do
let siteURL = B.pack siteURL'
let baseURL = B.pack $ blaaarghBaseURL state
- let path = B.concat $ intersperse "/" $ soFar ++ ["feed.xml"]
+ let fdPath = B.concat $ intersperse "/" $ soFar ++ ["feed.xml"]
let feedURL = B.unpack $ B.concat
- $ [siteURL, baseURL, "/", path]
+ $ [siteURL, baseURL, "/", fdPath]
let baseFeed = blaaarghFeedInfo state
let feed = baseFeed {
View
9 src/Blaaargh/Post.hs
@@ -90,11 +90,6 @@ parsePersons = map mkPerson . endBy ","
-mkPost :: String -> String -> TimeZone -> UTCTime -> Post
-mkPost pId title tz tm =
- Post $ nullEntry pId (TextString title) (formatAtomTime tz tm)
-
-
parseHeaders :: String -> (Either Cfg.CPError Cfg.ConfigParser)
parseHeaders = Cfg.readstring Cfg.emptyCP
@@ -210,8 +205,8 @@ alphabeticalPosts sl m = sortBy cmp $ collectPosts sl m
cmp (Post a) (Post b) = entryId a `compare` entryId b
-buildContentMap :: String -> String -> FilePath -> IO ContentMap
-buildContentMap siteURL baseURL basedir = build [] "."
+buildContentMap :: String -> FilePath -> IO ContentMap
+buildContentMap baseURL basedir = build [] "."
where
build :: [String] -> FilePath -> IO ContentMap
build prefixes path = do
View
3 src/Blaaargh/Templates.hs
@@ -13,7 +13,6 @@ import Control.Monad.State
import qualified Data.ByteString.Char8 as B
import Data.ByteString.Char8 (ByteString)
import Data.List
-import Data.Maybe
import Data.Monoid
import Happstack.Server
import Prelude hiding (catch)
@@ -26,7 +25,6 @@ import Blaaargh.Util.Templates
------------------------------------------------------------------------------
findFourOhFourTemplate :: ServerPartT BlaaarghMonad (Maybe Template)
findFourOhFourTemplate = do
- templates <- lift $ liftM blaaarghTemplates get
pathList <- askRq >>= return . map B.pack . rqPaths
lift $ cascadingTemplateFind pathList "404"
@@ -107,7 +105,6 @@ cascadingTemplateFind :: [ByteString]
-> ByteString
-> BlaaarghMonad (Maybe (StringTemplate ByteString))
cascadingTemplateFind directories templateName = do
- templates <- liftM blaaarghTemplates get
assert (not $ null directories) (return ())
findFirstMatchingTemplate templatesToSearch
View
18 src/Blaaargh/Types.hs
@@ -1,12 +1,23 @@
-{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
-module Blaaargh.Types where
+module Blaaargh.Types
+ ( module Blaaargh.Exception
+ , Post(..)
+ , getPostTime
+ , ContentMap
+ , ContentItem(..)
+ , BlaaarghState(..)
+ , BlaaarghMonad
+ , BlaaarghHandler
+ , liftB
+ , runBlaaarghHandler
+ , addExtraTemplateArguments
+ )
+where
------------------------------------------------------------------------------
-import Control.Exception
import Control.Monad.State
import qualified Data.ByteString.Char8 as B
import qualified Data.ByteString.Lazy.Char8 as L
@@ -15,7 +26,6 @@ import qualified Data.Map as Map
import Data.Map (Map)
import Data.Maybe
import Data.Time.LocalTime
-import Data.Typeable
import Happstack.Server
import qualified Text.Atom.Feed as Atom
import qualified Text.Atom.Feed.Export as Atom
View
8 src/Blaaargh/Util/Templates.hs
@@ -27,10 +27,10 @@ import Blaaargh.Exception
import Blaaargh.Util.ExcludeList
------------------------------------------------------------------------------
-data TemplateDirs = TemplateDirs {
- templateGroup :: TemplateGroup
- , subGroups :: Map ByteString TemplateDirs
-}
+data TemplateDirs =
+ TemplateDirs TemplateGroup -- ^ top-level template group
+ (Map ByteString TemplateDirs) -- ^ template group
+ -- for subdirs
instance Show TemplateDirs where
View
5 src/Test/TestBlaaargh.hs → src/Standalone/BlaaarghStandalone.hs
@@ -6,15 +6,12 @@ import Prelude hiding (catch)
import Control.Exception
import Happstack.Server
import System.Environment
-import System.FilePath
import System.Log.Handler.Simple
import System.Log.Logger
import System.IO
import Blaaargh
-import Blaaargh.Handlers
-import Blaaargh.Types
getBlaaarghDir :: IO FilePath
@@ -24,9 +21,9 @@ getBlaaarghDir = getEnv "BLAAARGH_DIR" `catch`
main :: IO ()
main = do
+ -- FIXME: parse arguments, usage statement
bs <- getBlaaarghDir >>= initBlaaargh
-
loghandler <- streamHandler stdout DEBUG
updateGlobalLogger rootLoggerName

0 comments on commit 72a0bf1

Please sign in to comment.