1. Luke Plant
  2. haskellblog

Commits

Luke Plant  committed 1791a06

Moved library code to 'Blog' subdir

  • Participants
  • Parent commits ccd1bea
  • Branches default

Comments (0)

Files changed (19)

File src/Blog.hs

--- "Hello, world" in CGI
-
-import Network.CGI
-import Text.XHtml
-
-page :: Html
-page = body << h1 << "Hello, blogosphere!"
-
-cgiMain :: CGI CGIResult
-cgiMain = output $ renderHtml page
-
-
-main :: IO ()
-main = runCGI $ handleErrors cgiMain

File src/Blog/Category.hs

View file
+module Blog.Category where
+{
+
+    data Category = Category { id :: Int,
+                               name :: String,
+                               slug :: String
+                             } deriving (Show, Eq)
+
+}

File src/Blog/DB.hs

View file
+module Blog.DB where
+
+import Database.HDBC
+import Database.HDBC.Sqlite3 (connectSqlite3 {-, setBusyTimeout-})
+import qualified Blog.Settings  as Settings
+import List
+
+connect = connectSqlite3 Settings.sqlite_path
+
+doInsert conn table columns values = let stmnt = mkInsertStatement table columns
+                                     in run conn stmnt values
+
+mkInsertStatement table columns = let joinC = concat . intersperse ", "
+                                      colSql = joinC columns
+                                      valSql = joinC $ take (length columns) $ repeat "?"
+                                   in "INSERT INTO " ++ table ++ 
+                                      " (" ++ colSql ++ ")" ++
+                                      " VALUES " ++
+                                      " (" ++ valSql ++ ");"

File src/Blog/Formats.hs

View file
+module Blog.Formats where
+
+rawhtml = 1 :: Int
+plaintext = 2 :: Int
+

File src/Blog/Post.hs

View file
+module Blog.Post where
+{
+  data Post = Post {
+        id :: Int,
+        title :: String,
+        slug :: String,
+        post_raw :: String,
+        post_formatted :: String,
+        summary_raw :: String,
+        summary_formatted :: String,
+        format_id :: Int,
+        timestamp :: Int,
+        comments_open :: Bool
+      } deriving (Show, Eq)
+}
+

File src/Blog/Settings.hs

View file
+settingslocal.hs

File src/Blog/Utils.hs

View file
+{-# OPTIONS_GHC -fbang-patterns  #-}
+module Blog.Utils where
+
+import qualified Data.ByteString.Char8 as B
+import System.Environment(getArgs)
+import Text.Regex.PCRE
+import Text.Regex.Base
+import Data.Char
+
+regexReplace !re !rep !source = go source []
+ where go str res =
+         if B.null str
+             then B.concat . reverse $ res
+             else case (str =~~ re) :: Maybe (B.ByteString, B.ByteString, B.ByteString) of
+               Nothing -> B.concat . reverse $ (str:res)
+               Just (bef, _ , aft) -> go aft (rep:bef:res)

File src/Blog/settingslive.hs

View file
+module Blog.Settings where
+
+sqlite_path="/home/lukeplantuk/public_html/cgi-bin/data/test1.db"
+

File src/Blog/settingslocal.hs

View file
+module Blog.Settings where
+
+sqlite_path = "/home/luke/httpd/lukeplant.me.uk/web/cgi-bin/data/test1.db"
+root_url = "/blog/"
+
+
+-- Migration time settings:
+
+old_data_path = "/home/luke/httpd/lukeplant.me.uk/web/blog/data/"
+redirect_file_template = "/home/luke/devel/haskell/haskellblog/src/blog.php.tpl"
+redirect_file_output = "/home/luke/devel/haskell/haskellblog/src/blog.php"

File src/BlogCgi.hs

View file
+-- "Hello, world" in CGI
+
+import Network.CGI
+import Text.XHtml
+
+page :: Html
+page = body << h1 << "Hello, blogosphere!"
+
+cgiMain :: CGI CGIResult
+cgiMain = output $ renderHtml page
+
+
+main :: IO ()
+main = runCGI $ handleErrors cgiMain

File src/Category.hs

-module Category where
-{
-
-    data Category = Category { id :: Int,
-                               name :: String,
-                               slug :: String
-                             } deriving (Show, Eq)
-
-}

File src/DB.hs

-module DB where
-
-import Database.HDBC
-import Database.HDBC.Sqlite3 (connectSqlite3 {-, setBusyTimeout-})
-import qualified Settings 
-import List
-
-connect = connectSqlite3 Settings.sqlite_path
-
-doInsert conn table columns values = let stmnt = mkInsertStatement table columns
-                                     in run conn stmnt values
-
-mkInsertStatement table columns = let joinC = concat . intersperse ", "
-                                      colSql = joinC columns
-                                      valSql = joinC $ take (length columns) $ repeat "?"
-                                   in "INSERT INTO " ++ table ++ 
-                                      " (" ++ colSql ++ ")" ++
-                                      " VALUES " ++
-                                      " (" ++ valSql ++ ");"

File src/Formats.hs

-module Formats where
-
-rawhtml = 1 :: Int
-plaintext = 2 :: Int
-

File src/Migrate.hs

View file
 import qualified Data.ByteString.Char8 as B
 import qualified Data.ByteString.Lazy.UTF8 as UTF8
 import qualified Data.ByteString.Lazy as BL
-import qualified Category as C
-import qualified Post as P
-import qualified Settings
-import qualified DB
-import qualified Formats
+import qualified Blog.Category as C
+import qualified Blog.Post as P
+import qualified Blog.Settings as Settings
+import qualified Blog.DB as DB
+import qualified Blog.Formats as Formats
 import Database.HDBC
 import List (sortBy, intersperse)
 import qualified Data.Map as Map
 import GHC.Unicode (toLower)
 import Monad (liftM)
 import Text.Template (readTemplate, renderToFile)
-import Utils (regexReplace)
+import Blog.Utils (regexReplace)
 -- Migration script for the old data
 
 -- Misc utilities

File src/Post.hs

-module Post where
-{
-  data Post = Post {
-        id :: Int,
-        title :: String,
-        slug :: String,
-        post_raw :: String,
-        post_formatted :: String,
-        summary_raw :: String,
-        summary_formatted :: String,
-        format_id :: Int,
-        timestamp :: Int,
-        comments_open :: Bool
-      } deriving (Show, Eq)
-}
-

File src/Settings.hs

-settingslocal.hs

File src/Utils.hs

-{-# OPTIONS_GHC -fbang-patterns  #-}
-module Utils where
-
-import qualified Data.ByteString.Char8 as B
-import System.Environment(getArgs)
-import Text.Regex.PCRE
-import Text.Regex.Base
-import Data.Char
-
-regexReplace !re !rep !source = go source []
- where go str res =
-         if B.null str
-             then B.concat . reverse $ res
-             else case (str =~~ re) :: Maybe (B.ByteString, B.ByteString, B.ByteString) of
-               Nothing -> B.concat . reverse $ (str:res)
-               Just (bef, _ , aft) -> go aft (rep:bef:res)

File src/settingslive.hs

-module Settings where
-
-sqlite_path="/home/lukeplantuk/public_html/cgi-bin/data/test1.db"
-

File src/settingslocal.hs

-module Settings where
-
-sqlite_path = "/home/luke/httpd/lukeplant.me.uk/web/cgi-bin/data/test1.db"
-root_url = "/blog/"
-
-
--- Migration time settings:
-
-old_data_path = "/home/luke/httpd/lukeplant.me.uk/web/blog/data/"
-redirect_file_template = "/home/luke/devel/haskell/haskellblog/src/blog.php.tpl"
-redirect_file_output = "/home/luke/devel/haskell/haskellblog/src/blog.php"