about summary refs log tree commit diff
path: root/src/BlogDB.hs
diff options
context:
space:
mode:
authorVincent Ambo <vincent@kivra.com>2015-11-21T01·59+0100
committerVincent Ambo <vincent@kivra.com>2015-11-21T01·59+0100
commit7610e790139717bf87ff25c9d694d7d589d5c420 (patch)
treebc86bda3804e6fdad32815e555130ebc52055d30 /src/BlogDB.hs
parent30e9f29fe19d29c39fc315e6e43cde3998d377cb (diff)
[db] Update interactiveUserAdd for remote state
Diffstat (limited to 'src/BlogDB.hs')
-rw-r--r--src/BlogDB.hs52
1 files changed, 25 insertions, 27 deletions
diff --git a/src/BlogDB.hs b/src/BlogDB.hs
index dd8aaaa66c30..316c2fdc08ff 100644
--- a/src/BlogDB.hs
+++ b/src/BlogDB.hs
@@ -1,20 +1,20 @@
 module BlogDB where
 
-import           Control.Monad.Reader   (ask)
-import           Control.Monad.State    (get, put)
-import           Data.Acid
-import           Data.Acid.Advanced
-import           Data.Acid.Local
-import           Data.ByteString        (ByteString)
-import           Data.Data              (Data, Typeable)
-import           Data.IxSet             (Indexable (..), IxSet (..), Proxy (..),
-                                         getOne, ixFun, ixSet, (@=))
-import           Data.List              (insert)
-import           Data.SafeCopy          (SafeCopy, base, deriveSafeCopy)
-import           Data.Text              (Text, pack)
-import           Data.Text.Lazy         (toStrict)
-import           Data.Time
-import           System.Environment     (getEnv)
+import Control.Monad.Reader (ask)
+import Control.Monad.State  (get, put)
+import Data.Acid
+import Data.Acid.Advanced
+import Data.Acid.Remote
+import Data.ByteString      (ByteString)
+import Data.Data            (Data, Typeable)
+import Data.IxSet           (Indexable (..), IxSet (..), Proxy (..), getOne, ixFun, ixSet, (@=))
+import Data.List            (insert)
+import Data.SafeCopy        (SafeCopy, base, deriveSafeCopy)
+import Data.Text            (Text, pack)
+import Data.Text.Lazy       (toStrict)
+import Data.Time
+import Network              (PortID (..))
+import System.Environment   (getEnv)
 
 import qualified Crypto.Hash.SHA512     as SHA (hash)
 import qualified Data.ByteString.Base64 as B64 (encode)
@@ -22,7 +22,6 @@ import qualified Data.ByteString.Char8  as B
 import qualified Data.IxSet             as IxSet
 import qualified Data.Text              as Text
 
-
 newtype EntryId = EntryId { unEntryId :: Integer }
     deriving (Eq, Ord, Data, Enum, Typeable)
 
@@ -41,13 +40,13 @@ instance Show BlogLang where
 $(deriveSafeCopy 0 'base ''BlogLang)
 
 data Entry = Entry {
-    entryId  :: EntryId,
-    lang     :: BlogLang,
-    author   :: Text,
-    title    :: Text,
-    btext    :: Text,
-    mtext    :: Text,
-    edate    :: UTCTime
+    entryId :: EntryId,
+    lang    :: BlogLang,
+    author  :: Text,
+    title   :: Text,
+    btext   :: Text,
+    mtext   :: Text,
+    edate   :: UTCTime
 } deriving (Eq, Ord, Show, Data, Typeable)
 
 $(deriveSafeCopy 2 'base ''Entry)
@@ -201,10 +200,9 @@ $(makeAcidic ''Blog
     , 'clearSessions
     ])
 
-interactiveUserAdd :: IO ()
-interactiveUserAdd = do
-  tbDir <- getEnv "TAZBLOG"
-  acid <- openLocalStateFrom (tbDir ++ "/BlogState") initialBlogState
+interactiveUserAdd :: String -> IO ()
+interactiveUserAdd dbHost = do
+  acid <- openRemoteState skipAuthenticationPerform dbHost (PortNumber 8070)
   putStrLn "Username:"
   un <- getLine
   putStrLn "Password:"