diff options
author | Lia Lenckowski <lialenck@protonmail.com> | 2023-10-31 23:22:55 +0100 |
---|---|---|
committer | Lia Lenckowski <lialenck@protonmail.com> | 2023-10-31 23:22:55 +0100 |
commit | e1616d4ab5b8a4a34faeb058693112ba95bed024 (patch) | |
tree | f0cdd164ff371b5cdc9ae56bab8adad9d0c3b2d8 | |
parent | 78fd3c5c4c3f601219669dd335220441e82c8e96 (diff) | |
download | fastbangs-e1616d4ab5b8a4a34faeb058693112ba95bed024.tar fastbangs-e1616d4ab5b8a4a34faeb058693112ba95bed024.tar.bz2 fastbangs-e1616d4ab5b8a4a34faeb058693112ba95bed024.tar.zst |
simplify some code; version bump
-rw-r--r-- | package.yaml | 2 | ||||
-rw-r--r-- | src/Main.hs | 24 |
2 files changed, 12 insertions, 14 deletions
diff --git a/package.yaml b/package.yaml index 2b13bf1..d142b42 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: fastbangs -version: 0.1.0.1 +version: 0.1.0.2 #synopsis: #description: homepage: https://codeberg.org/lialenck/fastbangs diff --git a/src/Main.hs b/src/Main.hs index a59b38a..7d3a331 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -57,27 +57,25 @@ instance YesodPersist Search where getHomeR :: Handler TypedContent getHomeR = do cacheSeconds $ 60 * 60 * 24 * 7 - return $ TypedContent typeHtml $ toContent ($(embedFile "build/index.html")) + respond typeHtml ($(embedFile "build/index.html")) getBundleR :: Handler TypedContent getBundleR = do cacheSeconds $ 60 * 60 * 24 * 7 noEmbed <- confNoEmbed . config <$> getYesod - bundle <- liftIO $ bool - (pure $ toContent ($(embedFile "build/bundle.js"))) - (toContent <$> readFile "../build/bundle.js") - noEmbed - return $ TypedContent typeJavascript bundle + + respond typeJavascript =<< if noEmbed + then liftIO $ BS.readFile "../build/bundle.js" + else pure ($(embedFile "build/bundle.js")) getStyleR :: Handler TypedContent getStyleR = do cacheSeconds $ 60 * 60 * 24 * 7 noEmbed <- confNoEmbed . config <$> getYesod - stylesheet <- liftIO $ bool - (pure $ toContent ($(embedFile "build/style.css"))) - (toContent <$> readFile "../build/style.css") - noEmbed - return $ TypedContent typeCss stylesheet + + respond typeCss =<< if noEmbed + then liftIO $ BS.readFile "../build/style.css" + else pure ($(embedFile "build/style.css")) getBangsR :: Handler TypedContent getBangsR = do @@ -95,7 +93,7 @@ getBangsR = do _ -> do liftIO $ getBangsJSON st - return $ TypedContent typeJson $ toContent bs + respond typeJson bs postSubmitR :: Handler () postSubmitR = do @@ -111,7 +109,7 @@ getOpenSearchR = do cfg <- config <$> getYesod resXml <- makeOpenSearch cfg <$> lookupGetParam "default" - return $ TypedContent "application/opensearchdescription+xml" $ toContent resXml + respond "application/opensearchdescription+xml" resXml postVerdictR :: Bool -> Handler () postVerdictR b = do |