diff options
author | Yuchen Pei <hi@ypei.me> | 2022-09-19 11:22:21 +1000 |
---|---|---|
committer | Yuchen Pei <hi@ypei.me> | 2022-09-19 11:22:21 +1000 |
commit | ef1b927861f9a949aed20341144ffb5bfd42f038 (patch) | |
tree | 48bd4688928546bedc6504aad76bf6e0327fcef9 /app | |
parent | 117850d8f659517cb818a857dc04c8f5157795c4 (diff) |
Removing the web client
Diffstat (limited to 'app')
-rw-r--r-- | app/Server.hs | 35 |
1 files changed, 4 insertions, 31 deletions
diff --git a/app/Server.hs b/app/Server.hs index 557459f..628bf19 100644 --- a/app/Server.hs +++ b/app/Server.hs @@ -158,7 +158,6 @@ import System.Log.FastLogger ) import Text.Blaze.Html.Renderer.Text (renderHtml) import qualified Text.Blaze.Html5 as Html hiding (html, source) -import Data.FileEmbed (embedDir, embedFile) import Data.Bifunctor (second) import qualified Store @@ -174,7 +173,6 @@ data ServerConfig = ServerConfig , configIndexDirectoryName :: !(Maybe FilePath) , configLog :: !HCE.Log , configStaticFilesUrlPrefix :: !String - , configJsDistDirectory :: !(Maybe String) , configMaxPerPage :: !Int , configStore :: !(Maybe Store) , configUseHoogleApi :: !Bool @@ -231,10 +229,6 @@ configParser = strOption (long "static-url-prefix" <> metavar "STRING" <> help "URL prefix for static files (default is 'files')")) <*> - optional - (strOption - (long "js-path" <> help "Path to a directory with javascript files (by default, the server uses javascript files that are embedded in the executable)" <> - metavar "PATH")) <*> (pure 50 <|> option auto @@ -1701,8 +1695,8 @@ parsePackageId (PackageId text) = Left _ -> Just (PackageName text, Nothing) _ -> Nothing -staticMiddleware :: String -> PackagePathMap -> Maybe FilePath -> Middleware -staticMiddleware staticFilesPrefix packagePathMap _ app req callback +staticMiddleware :: String -> PackagePathMap -> Middleware +staticMiddleware staticFilesPrefix packagePathMap app req callback | ("api":_) <- pathInfo req = app req callback | (prefix:packageId:rest) <- pathInfo req , prefix == T.pack staticFilesPrefix = @@ -1737,27 +1731,7 @@ staticMiddleware staticFilesPrefix packagePathMap _ app req callback then callback $ sendFile path else callback fileNotFound _ -> callback fileNotFound -staticMiddleware _ _ mbJsDistPath _app req callback = - case mbJsDistPath of - Just jsDistPath -> do - let path = jsDistPath </> T.unpack (T.intercalate "/" $ pathInfo req) - exists <- doesFileExist path - if exists - then callback $ sendFile path - else callback $ sendFile (jsDistPath </> "index.html") - Nothing -> do - let path = T.unpack $ T.intercalate "/" $ pathInfo req - if path == "" - then callback $ sendEmbeddedFile "index.html" indexHtml - else case HM.lookup path staticAssets of - Just bs -> callback $ sendEmbeddedFile path bs - Nothing -> callback $ sendEmbeddedFile "index.html" indexHtml - -staticAssets :: HM.HashMap FilePath BS.ByteString -staticAssets = HM.fromList $(embedDir "javascript/release") - -indexHtml :: BS.ByteString -indexHtml = $(embedFile "javascript/release/index.html") +staticMiddleware _ _ _ _ callback = callback fileNotFound sendFile :: FilePath -> Response sendFile path = @@ -1843,7 +1817,6 @@ main = do mkRequestLogger def {outputFormat = Detailed True, destination = Logger loggerSet} let staticFilePrefix = configStaticFilesUrlPrefix config - mbJsDistPath = configJsDistDirectory config environment = Environment loggerSet @@ -1854,7 +1827,7 @@ main = do config static = if configServeStaticFiles config - then staticMiddleware staticFilePrefix packagePathMap mbJsDistPath + then staticMiddleware staticFilePrefix packagePathMap else id run (configPort config) |