summaryrefslogtreecommitdiff
path: root/Handler/Common.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Handler/Common.hs')
-rw-r--r--Handler/Common.hs12
1 files changed, 8 insertions, 4 deletions
diff --git a/Handler/Common.hs b/Handler/Common.hs
index aacab92..c2788e8 100644
--- a/Handler/Common.hs
+++ b/Handler/Common.hs
@@ -14,11 +14,12 @@ module Handler.Common
14 , humanId 14 , humanId
15 ) where 15 ) where
16 16
17import Import 17import Import hiding ((\\))
18 18
19import Data.Unique 19import Data.Unique
20 20
21import qualified Data.Text as Text 21import qualified Data.Text as Text
22import qualified Data.ByteString.Char8 as CBS
22 23
23import Data.Set (Set) 24import Data.Set (Set)
24import qualified Data.Set as Set 25import qualified Data.Set as Set
@@ -29,11 +30,14 @@ import Handler.Common.Types
29 30
30import Text.Julius (RawJS(..)) 31import Text.Julius (RawJS(..))
31 32
32import qualified Codec.Crockford as Crockford (encode)
33import Database.Persist.Sql (fromSqlKey) 33import Database.Persist.Sql (fromSqlKey)
34import qualified Web.Hashids as HID
35import Data.List ((\\))
34 36
35humanId :: ItemId -> String 37humanId :: ItemId -> Text
36humanId = Crockford.encode . fromSqlKey 38humanId = Text.pack . CBS.unpack . HID.encode ctx . fromIntegral . fromSqlKey
39 where
40 ctx = HID.createHashidsContext "ItemId" 3 $ (['0'..'9'] ++ ['a'..'z']) \\ ['0', 'l', 'v', '2']
37 41
38dayFormat :: Day -> String 42dayFormat :: Day -> String
39dayFormat = formatTime defaultTimeLocale "%e. %b %y" 43dayFormat = formatTime defaultTimeLocale "%e. %b %y"