@@ -39,9 +39,9 @@ tshow = T.pack . show
3939
4040frontend :: Frontend (R FrontendRoute)
4141frontend = Frontend
42− { _frontend_head = pure ()
43− -- TODO lib/Frontend needs fixing for this to work
44− -- el "title" $ text "Obelisk Minimal Example"
42+ { _frontend_head = do
43+ el "title" $ text "Obelisk Minimal Example"
44+ elAttr "meta" mempty blank
4545 , _frontend_body = do
4646 text "Welcome to Obelisk!"
4747 el "p" $ text $ T.pack commonStuff
@@ -50,38 +50,38 @@ frontend = Frontend
5050 performEvent $ liftIO . print <$> updated clicks
5151 el "p" $ text "Clicks: " >> el "span" (display clicks) -- TODO multiple text bug
5252
53+ pb <- getPostBuild
54+
5355 timer <- tickLossy 1 =<< liftIO getCurrentTime
5456 seconds <- count timer
5557 el "p" $ display seconds
5658 text "-----------------------------------------------"
5759
58−-- elAttr "article" ("style" =: "background: lightcoral") $ do
59−-- prerender
60−-- (prerender
61−-- (el "span" $ text "Server span")
62−-- (el "a" $ text "JS link"))
63−-- (el "a" $ text "JS link")
64−
65− pb <- getPostBuild
60+ elAttr "article" ("style" =: "background: lightcoral") $ do
61+ prerender
62+ (prerender
63+ (el "span" $ text "Server span")
64+ (el "a" $ text "JS link, inner"))
65+ (el "a" $ text "JS link")
6666
67− elAttr "article" ("style" =: "background: moccasin") $ do
68− widgetHold_ (el "div" $ text "first") $ ffor pb $ \() -> display seconds
67+-- elAttr "article" ("style" =: "background: moccasin") $ do
68+-- widgetHold_ (el "div" $ text "first") $ ffor pb $ \() -> display seconds
6969
7070-- elAttr "article" ("style" =: "background: lightgreen") $ do
7171-- widgetHold_ (do prerender (liftIO $ putStrLn "-------- server missiles") (liftIO $ putStrLn "-------- client missiles"); el "div" $ text "first") never
7272
73− elAttr "article" ("style" =: "background: paleturquoise") $ do
74− dyn_ $ ffor clicks $ \x -> case x `mod` 2 of
75− 0 -> el "span" $ text "Even"
76− 1 -> el "span" $ text "Odd"
77−
78− elAttr "article" ("style" =: "background: cornflowerblue") $ do
79− widgetHold (text "first") $ ffor (updated clicks) $ \x -> case x `mod` 2 of
80− 0 -> do
81− dyn_ $ ffor seconds $ \x -> case x `mod` 2 of
82− 0 -> el "span" $ text "Even"
83− 1 -> text "Odd"
84− 1 -> el "span" $ text "Odd inner"
73+-- elAttr "article" ("style" =: "background: paleturquoise") $ do
74+-- dyn_ $ ffor clicks $ \x -> case x `mod` 2 of
75+-- 0 -> el "span" $ text "Even"
76+-- 1 -> el "span" $ text "Odd"
77+--
78+-- elAttr "article" ("style" =: "background: cornflowerblue") $ do
79+-- widgetHold (text "first") $ ffor (updated clicks) $ \x -> case x `mod` 2 of
80+-- 0 -> do
81+-- dyn_ $ ffor seconds $ \x -> case x `mod` 2 of
82+-- 0 -> el "span" $ text "Even"
83+-- 1 -> text "Odd"
84+-- 1 -> el "span" $ text "Odd inner"
8585
8686 -- These will be squashed into a single text node by the static renderer
8787-- text "Test"
@@ -92,48 +92,46 @@ frontend = Frontend
9292
9393 --traverseDMapWithKeyWithAdjust' :: (forall a. k a -> v a -> m (v' a)) -> DMap k v -> Event t (PatchDMap k v) -> m (DMap k v', Event t (PatchDMap k v'))
9494-- elAttr "article" ("style" =: "background: thistle") $ do
95−-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \_ -> case 0 of -- x -> case x `mod` 2 of
95+-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \x -> case x `mod` 2 of
9696-- 0 -> PatchDMap $ DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity 10)
9797-- 1 -> PatchDMap $ DMap.singleton Key_Bool (ComposeMaybe $ case x `mod` 3 of 0 -> Nothing; _ -> Just $ Identity True) <> DMap.singleton Key_Char (ComposeMaybe $ Just $ Identity (toEnum $ fromEnum 'A' + x))
98− pure ()
99−
100−
98+-- pure ()
99+--
100+--
101101-- elAttr "article" ("style" =: "background: thistle") $ do
102102-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $
103103-- PatchDMap (DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity 10)) <$ pb
104104-- pure ()
105−
106− {-
107− elAttr "article" ("style" =: "background: maroon") $ do
108− widgetHold (text "first") $ ffor pb $ \_ -> do
109− (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \x -> case x `mod` 2 of
110− 0 -> PatchDMap $ DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity x)
111− 1 -> PatchDMap $ DMap.singleton Key_Bool (ComposeMaybe $ case x `mod` 3 of 0 -> Nothing; _ -> Just $ Identity True) <> DMap.singleton Key_Char (ComposeMaybe $ Just $ Identity (toEnum $ fromEnum 'A' + x))
112− pure ()
113−
114− move <- button "Move"
115− ins <- button "Insert"
116− del <- button "Delete"
105+--
106+-- elAttr "article" ("style" =: "background: maroon") $ do
107+-- widgetHold (text "first") $ ffor pb $ \_ -> do
108+-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \x -> case x `mod` 2 of
109+-- 0 -> PatchDMap $ DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity x)
110+-- 1 -> PatchDMap $ DMap.singleton Key_Bool (ComposeMaybe $ case x `mod` 3 of 0 -> Nothing; _ -> Just $ Identity True) <> DMap.singleton Key_Char (ComposeMaybe $ Just $ Identity (toEnum $ fromEnum 'A' + x))
111+-- pure ()
112+--
113+-- move <- button "Move"
114+-- ins <- button "Insert"
115+-- del <- button "Delete"
117116
118117 --traverseDMapWithKeyWithAdjust' :: (forall a. k a -> v a -> m (v' a)) -> DMap k v -> Event t (PatchDMap k v) -> m (DMap k v', Event t (PatchDMap k v'))
119− elAttr "article" ("style" =: "background: yellow") $ do
120− (m', e') <- traverseDMapWithKeyWithAdjustWithMove (\k v -> has @Show k $ dkeyWidget k v) keyMap $ leftmost
121− -- TODO: move causes JSException here and in Immediate builder
122− [ ffor move $ \() -> moveDMapKey Key_Int2 Key_Int
123− , ffor ins $ \() -> insertDMapKey Key_Int (Identity 4)
124− , ffor del $ \() -> deleteDMapKey Key_Int
125− ]
126− pure ()
127−
128− elAttr "article" ("style" =: "background: cyan") $ do
129− (m', e') <- traverseIntMapWithKeyWithAdjust (\k v -> intkeyWidget k v) intMap $ leftmost
130− -- TODO: move causes JSException here and in Immediate builder
131− [ ffor move $ \() -> PatchIntMap $ IntMap.singleton 1 (Just 'Z')
132− , ffor ins $ \() -> PatchIntMap $ IntMap.singleton 5 (Just 'Z')
133− , ffor del $ \() -> PatchIntMap $ IntMap.singleton 3 Nothing
134− ]
135− pure ()
136− -}
118+-- elAttr "article" ("style" =: "background: yellow") $ do
119+-- (m', e') <- traverseDMapWithKeyWithAdjustWithMove (\k v -> has @Show k $ dkeyWidget k v) keyMap $ leftmost
120+-- -- TODO: move causes JSException here and in Immediate builder
121+-- [ ffor move $ \() -> moveDMapKey Key_Int2 Key_Int
122+-- , ffor ins $ \() -> insertDMapKey Key_Int (Identity 4)
123+-- , ffor del $ \() -> deleteDMapKey Key_Int
124+-- ]
125+-- pure ()
126+--
127+-- elAttr "article" ("style" =: "background: cyan") $ do
128+-- (m', e') <- traverseIntMapWithKeyWithAdjust (\k v -> intkeyWidget k v) intMap $ leftmost
129+-- -- TODO: move causes JSException here and in Immediate builder
130+-- [ ffor move $ \() -> PatchIntMap $ IntMap.singleton 1 (Just 'Z')
131+-- , ffor ins $ \() -> PatchIntMap $ IntMap.singleton 5 (Just 'Z')
132+-- , ffor del $ \() -> PatchIntMap $ IntMap.singleton 3 Nothing
133+-- ]
134+-- pure ()
137135
138136-- el "footer" $ text "Footer"
139137 pure ()