diff options
author | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-01 23:38:18 +0100 |
---|---|---|
committer | Hugo Hörnquist <hugo@lysator.liu.se> | 2022-11-01 23:38:18 +0100 |
commit | ebe3d7707601934fc4677accbeca0f2c1d5b71be (patch) | |
tree | 31191f772c6298937eb36c84c8bc24c5e44dc26e | |
parent | Minor cleanup. (diff) | |
download | vimwiki-scripts-ebe3d7707601934fc4677accbeca0f2c1d5b71be.tar.gz vimwiki-scripts-ebe3d7707601934fc4677accbeca0f2c1d5b71be.tar.xz |
Remove fromJust.
-rw-r--r-- | hs/src/Html.hs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/hs/src/Html.hs b/hs/src/Html.hs index eda9384..f46974d 100644 --- a/hs/src/Html.hs +++ b/hs/src/Html.hs @@ -27,7 +27,7 @@ import Data.Default (def) import Data.List (partition) import qualified Data.Map as M import Data.Map (Map) -import Data.Maybe (listToMaybe, fromMaybe, fromJust) +import Data.Maybe (listToMaybe, fromMaybe, maybeToList) import Data.Set (Set) import qualified Data.Set as S import Data.Text (Text, pack) @@ -86,7 +86,6 @@ isWikiFile = isFiletype "wiki" -- TODO -- - Colorful headers? -- - All headers should link to themselves --- - remove all fromJust, instead omit those elements -- - Tilde-expand paths from filenames @@ -94,12 +93,11 @@ mailRewriter :: String -> [Inline] -> URI -> ([Inline], PandocStr) mailRewriter mu4eURL body uri = (body, conv $ mu4eURL <> "?id=" <> uriPath uri) urlRewrites :: Configuration -> Map String ([Inline] -> URI -> ([Inline], PandocStr)) -urlRewrites conf = M.fromList [ ("mail", mailRewriter $ (fromJust $ conf ^. output . mu4eURL)) - -- , ("man", manRewriter $ (rewriters ! (fromJust $ conf ^. output . manProvider))) +urlRewrites conf = M.fromList $ (maybeToList $ ((,) "mail") . mailRewriter <$> (conf ^. output . mu4eURL)) -- TODO choose man implementation from -- configuration item - , ("man", manRewriter $ mannedMan) - ] + ++ [("man", manRewriter $ mannedMan)] + -- , ("man", manRewriter $ (rewriters ! (fromJust $ conf ^. output . manProvider))) fixExtension url @@ -189,12 +187,14 @@ htmlWrap conf title parts backlinks toc main = docTypeHtml $ do , tail bc , [ H.span $ H.string . takeBaseName . last $ parts ] ] mconcat $ intersperse (H.string "»") all - H.nav ! A.id "search" $ do - H.form ! A.method "GET" - ! A.action (textValue . pack . fromJust $ conf ^. output . xapianOmega) - $ do - H.input ! A.type_ "search" ! A.name "P" ! A.placeholder "Sök..." - H.input ! A.type_ "submit" ! A.value "Sök" + H.nav ! A.id "search" $ + case conf ^. output . xapianOmega of + Nothing -> mempty + Just url -> H.form ! A.method "GET" + ! A.action (textValue . pack $ url) + $ do + H.input ! A.type_ "search" ! A.name "P" ! A.placeholder "Sök..." + H.input ! A.type_ "submit" ! A.value "Sök" H.div ! A.id "with-resizer" $ do H.main $ main H.div ! A.id "resizer" $ do |