summaryrefslogtreecommitdiffstats
path: root/Regfish/Default.hs
diff options
context:
space:
mode:
authortv <tv@shackspace.de>2014-11-18 16:05:40 +0100
committertv <tv@shackspace.de>2014-11-18 16:05:40 +0100
commit179d8980e55578e3553bad0b237368d74e074f15 (patch)
treecee326bc5071a71866ede0487beb28d510ea989a /Regfish/Default.hs
initial commit
Diffstat (limited to 'Regfish/Default.hs')
-rw-r--r--Regfish/Default.hs37
1 files changed, 37 insertions, 0 deletions
diff --git a/Regfish/Default.hs b/Regfish/Default.hs
new file mode 100644
index 0000000..bb78dd3
--- /dev/null
+++ b/Regfish/Default.hs
@@ -0,0 +1,37 @@
+{-# LANGUAGE TemplateHaskell #-}
+{-# OPTIONS_GHC -fno-warn-orphans #-}
+
+
+module Regfish.Default () where
+
+import Control.Applicative
+import Data.Default
+import Regfish.Types
+import System.Environment (getEnv)
+import System.IO.Unsafe (unsafePerformIO)
+
+
+instance Default RFConfig where
+ def = RFConfig
+ { _username = user
+ , _password = pass
+ , _allinone = mkAllInOne domain
+ }
+ where
+ (user, pass, domain) =
+ unsafePerformIO $
+ (,,) <$> getEnv "REGFISH_USER"
+ <*> getEnv "REGFISH_PASS"
+ <*> getEnv "REGFISH_DOMAIN"
+
+
+instance Default RFState where
+ def = RFState def
+
+
+
+mkAllInOne :: String -> String
+mkAllInOne domain =
+ "https://www.regfish.de/my/domains/*/"++tld++"/"++sld++"/rr/allinone"
+ where
+ (sld, '.':tld) = break (=='.') domain