diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 21:39:15 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2017-03-15 21:39:15 +0100 |
commit | 3d828feba67f21ae62d1e6eb598a22ffaebf1174 (patch) | |
tree | f81437dab5090906362404b5df61aa5ab1f5203a /Handler/Common.hs | |
parent | 299731a0cef7462dd8c17bde7ba1a4aeb6f211cd (diff) | |
download | bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.gz bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.bz2 bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.tar.xz bar-3d828feba67f21ae62d1e6eb598a22ffaebf1174.zip |
Better ids & warnings
Diffstat (limited to 'Handler/Common.hs')
-rw-r--r-- | Handler/Common.hs | 12 |
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 | ||
17 | import Import | 17 | import Import hiding ((\\)) |
18 | 18 | ||
19 | import Data.Unique | 19 | import Data.Unique |
20 | 20 | ||
21 | import qualified Data.Text as Text | 21 | import qualified Data.Text as Text |
22 | import qualified Data.ByteString.Char8 as CBS | ||
22 | 23 | ||
23 | import Data.Set (Set) | 24 | import Data.Set (Set) |
24 | import qualified Data.Set as Set | 25 | import qualified Data.Set as Set |
@@ -29,11 +30,14 @@ import Handler.Common.Types | |||
29 | 30 | ||
30 | import Text.Julius (RawJS(..)) | 31 | import Text.Julius (RawJS(..)) |
31 | 32 | ||
32 | import qualified Codec.Crockford as Crockford (encode) | ||
33 | import Database.Persist.Sql (fromSqlKey) | 33 | import Database.Persist.Sql (fromSqlKey) |
34 | import qualified Web.Hashids as HID | ||
35 | import Data.List ((\\)) | ||
34 | 36 | ||
35 | humanId :: ItemId -> String | 37 | humanId :: ItemId -> Text |
36 | humanId = Crockford.encode . fromSqlKey | 38 | humanId = 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 | ||
38 | dayFormat :: Day -> String | 42 | dayFormat :: Day -> String |
39 | dayFormat = formatTime defaultTimeLocale "%e. %b %y" | 43 | dayFormat = formatTime defaultTimeLocale "%e. %b %y" |