aboutsummaryrefslogtreecommitdiffstats
path: root/frontend/app/Route.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2024-10-11 23:30:56 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2024-10-11 23:30:56 +0200
commit80a6150610182eefa0deb1f0932d3b780456ca09 (patch)
tree4471a8ffecfc527d6b9c2a5c48e445e7a4d6a74f /frontend/app/Route.hs
parent2e0cf98254976e443ea7f693961fc105ed6cf563 (diff)
use backend REST library for frontend
Diffstat (limited to 'frontend/app/Route.hs')
-rw-r--r--frontend/app/Route.hs25
1 files changed, 13 insertions, 12 deletions
diff --git a/frontend/app/Route.hs b/frontend/app/Route.hs
index d683b76..e2d2838 100644
--- a/frontend/app/Route.hs
+++ b/frontend/app/Route.hs
@@ -1,7 +1,7 @@
module Route
( Route (..),
parseURI,
- routeToString,
+ routeToMisoString,
)
where
@@ -9,11 +9,12 @@ import Data.Attoparsec.Text qualified as P
import Data.Default
import Data.Text qualified as T
import Miso
+import Miso.String (MisoString, toMisoString)
data Route
= Home
- | ListCollection String
- | EditValue String String
+ | ListCollection MisoString
+ | EditValue MisoString MisoString
| NewCollection
deriving (Show, Eq)
@@ -26,18 +27,18 @@ parseURI uri =
P.parseOnly
( P.choice
[ EditValue
- <$> (P.string "#collection/" *> P.manyTill P.anyChar (P.string "/"))
- <*> (P.many1 P.anyChar),
- pure NewCollection <* (P.string "#collection/new"),
- ListCollection <$> (P.string "#collection/" *> P.many1 P.anyChar),
+ <$> (toMisoString <$> (P.string "#collection/" *> P.manyTill P.anyChar (P.string "/")))
+ <*> (toMisoString <$> (P.many1 P.anyChar)),
+ pure NewCollection <* (toMisoString <$> (P.string "#collection/new")),
+ ListCollection <$> (toMisoString <$> (P.string "#collection/" *> P.many1 P.anyChar)),
pure Home
]
<* P.endOfInput
)
(T.pack uri.uriFragment)
-routeToString :: Route -> String
-routeToString Home = "#"
-routeToString (ListCollection collection) = "#collection/" <> collection
-routeToString (EditValue collection fileName) = "#collection/" <> collection <> "/" <> fileName
-routeToString NewCollection = "#collection/new"
+routeToMisoString :: Route -> MisoString
+routeToMisoString Home = "#"
+routeToMisoString (ListCollection collection) = "#collection/" <> collection
+routeToMisoString (EditValue collection fileName) = "#collection/" <> collection <> "/" <> fileName
+routeToMisoString NewCollection = "#collection/new"