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