remove registry icon

This commit is contained in:
Lucy Cifferello
2022-11-29 09:44:46 -05:00
parent 995af16e7e
commit 1b4541a5c7
3 changed files with 2 additions and 18 deletions

View File

@@ -36,7 +36,6 @@ tor-port: "_env:TOR_PORT:447"
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/registry/"
marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
icon-path: "_env:ICON_PATH:/var/www/html/resources"
max-eos-version: "_env:MAX_VERSION:0.3.3.0"
run-migration: "_env:RUN_MIGRATION:false"

View File

@@ -6,19 +6,13 @@ import Foundation (Handler, RegistryCtx (..))
import Handler.Util (tickleMAU)
import Model (Category (..), EntityField (..))
import Settings (AppSettings (..))
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>), MonadIO (liftIO), decodeUtf8, Maybe)
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>))
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getsYesod)
import Yesod.Core.Types (JSONResponse (..))
import System.FilePath ((</>))
import Data.ByteString (readFile)
import System.Directory (doesFileExist)
import Data.Maybe (Maybe(..))
data InfoRes = InfoRes
{ name :: !Text
, categories :: ![Text]
, icon :: Maybe Text -- base64
}
deriving (Show, Generic)
instance ToJSON InfoRes
@@ -31,17 +25,10 @@ instance ToTypedContent InfoRes where
getInfoR :: Handler (JSONResponse InfoRes)
getInfoR = do
name <- getsYesod $ marketplaceName . appSettings
iconFile <- getsYesod $ (</> "icon") . iconPath . appSettings
existingIcon <- liftIO $ doesFileExist iconFile
icon <- if existingIcon
then do
icon' <- liftIO $ readFile iconFile
pure $ Just $ decodeUtf8 icon'
else pure $ Nothing
allCategories <- runDB $
select $ do
cats <- from $ table @Category
orderBy [asc (cats ^. CategoryPriority)]
pure cats
tickleMAU
pure $ JSONResponse $ InfoRes name (categoryName . entityVal <$> allCategories) icon
pure $ JSONResponse $ InfoRes name (categoryName . entityVal <$> allCategories)

View File

@@ -73,7 +73,6 @@ data AppSettings = AppSettings
-- behind a reverse proxy.
, appShouldLogAll :: !Bool
-- ^ Should all log messages be displayed?
, iconPath :: !FilePath
, errorLogRoot :: !FilePath
, marketplaceName :: !Text
, maxEosVersion :: !Version
@@ -110,7 +109,6 @@ instance FromJSON AppSettings where
appPort <- o .: "port"
appShouldLogAll <- o .:? "should-log-all" .!= False
errorLogRoot <- o .: "error-log-root"
iconPath <- o .: "icon-path"
marketplaceName <- o .: "marketplace-name"
maxEosVersion <- o .: "max-eos-version"
registryHostname <- o .: "registry-hostname"