mirror of
https://github.com/aelve/guide.git
synced 2024-11-23 21:13:07 +03:00
Handle Hackage/extra links differently
This commit is contained in:
parent
2a13b7b680
commit
1b69540f5e
24
src/Main.hs
24
src/Main.hs
@ -113,7 +113,7 @@ sampleState = do
|
|||||||
_itemPros = [ProCon 131 "very small",
|
_itemPros = [ProCon 131 "very small",
|
||||||
ProCon 132 "good for libraries"],
|
ProCon 132 "good for libraries"],
|
||||||
_itemCons = [ProCon 133 "doesn't have advanced features"],
|
_itemCons = [ProCon 133 "doesn't have advanced features"],
|
||||||
_itemLink = Nothing,
|
_itemLink = Just "https://github.com/aelve/microlens",
|
||||||
_itemKind = HackageLibrary }
|
_itemKind = HackageLibrary }
|
||||||
let lensesCategory = Category {
|
let lensesCategory = Category {
|
||||||
_categoryUid = 1,
|
_categoryUid = 1,
|
||||||
@ -295,8 +295,6 @@ renderCategory category =
|
|||||||
let handler s = js_addLibrary (itemsNode, category^.uid, s)
|
let handler s = js_addLibrary (itemsNode, category^.uid, s)
|
||||||
input_ [type_ "text", placeholder_ "new item", submitFunc handler]
|
input_ [type_ "text", placeholder_ "new item", submitFunc handler]
|
||||||
|
|
||||||
-- TODO: when the link for a HackageLibrary isn't empty, show it separately
|
|
||||||
-- (as “site”), don't replace the Hackage link
|
|
||||||
renderItem
|
renderItem
|
||||||
:: Editable -- ^ Show edit buttons?
|
:: Editable -- ^ Show edit buttons?
|
||||||
-> Item
|
-> Item
|
||||||
@ -305,7 +303,16 @@ renderItem editable item =
|
|||||||
div_ [class_ "item", id_ (tshow (item^.uid))] $ do
|
div_ [class_ "item", id_ (tshow (item^.uid))] $ do
|
||||||
itemNode <- thisNode
|
itemNode <- thisNode
|
||||||
h3_ $ do
|
h3_ $ do
|
||||||
itemHeader
|
-- If the library is on Hackage, the title links to its Hackage page;
|
||||||
|
-- otherwise, it doesn't link anywhere. Even if the link field is
|
||||||
|
-- present, it's going to be rendered as “(site)”, not linked in the
|
||||||
|
-- title.
|
||||||
|
case item^.kind of
|
||||||
|
HackageLibrary -> a_ [href_ hackageLink] (toHtml (item^.name))
|
||||||
|
_otherwise -> toHtml (item^.name)
|
||||||
|
case item^.link of
|
||||||
|
Just l -> " (" >> a_ [href_ l] "site" >> ")"
|
||||||
|
Nothing -> return ()
|
||||||
case editable of
|
case editable of
|
||||||
Normal -> textButton "edit" $
|
Normal -> textButton "edit" $
|
||||||
js_enableItemEdit (itemNode, item^.uid)
|
js_enableItemEdit (itemNode, item^.uid)
|
||||||
@ -335,14 +342,7 @@ renderItem editable item =
|
|||||||
let handler s = js_addCon (listNode, item^.uid, s)
|
let handler s = js_addCon (listNode, item^.uid, s)
|
||||||
input_ [type_ "text", placeholder_ "add con", submitFunc handler]
|
input_ [type_ "text", placeholder_ "add con", submitFunc handler]
|
||||||
where
|
where
|
||||||
hackageLink = format "https://hackage.haskell.org/package/{}"
|
hackageLink = "https://hackage.haskell.org/package/" <> item^.name
|
||||||
[item^.name]
|
|
||||||
itemHeader = case (item^.link, item^.kind) of
|
|
||||||
(Just l, _) ->
|
|
||||||
a_ [href_ l] (toHtml (item^.name))
|
|
||||||
(Nothing, HackageLibrary) ->
|
|
||||||
a_ [href_ hackageLink] (toHtml (item^.name))
|
|
||||||
_otherwise -> toHtml (item^.name)
|
|
||||||
|
|
||||||
renderProCon :: Editable -> Uid -> ProCon -> HtmlT IO ()
|
renderProCon :: Editable -> Uid -> ProCon -> HtmlT IO ()
|
||||||
renderProCon Normal _ proCon = li_ (toHtml (proCon^.content))
|
renderProCon Normal _ proCon = li_ (toHtml (proCon^.content))
|
||||||
|
Loading…
Reference in New Issue
Block a user