mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-30 11:51:57 +00:00
add marketplace icon to info response
This commit is contained in:
@@ -31,11 +31,12 @@ detailed-logging: true
|
|||||||
resources-path: "_env:RESOURCES_PATH:/var/www/html/resources"
|
resources-path: "_env:RESOURCES_PATH:/var/www/html/resources"
|
||||||
ssl-path: "_env:SSL_PATH:/var/ssl"
|
ssl-path: "_env:SSL_PATH:/var/ssl"
|
||||||
ssl-auto: "_env:SSL_AUTO:true"
|
ssl-auto: "_env:SSL_AUTO:true"
|
||||||
registry-hostname: "_env:REGISTRY_HOSTNAME:alpha-registry.start9labs.com"
|
registry-hostname: "_env:REGISTRY_HOSTNAME:alpha-registry-x.start9.com"
|
||||||
tor-port: "_env:TOR_PORT:447"
|
tor-port: "_env:TOR_PORT:447"
|
||||||
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
|
static-bin-dir: "_env:STATIC_BIN:/usr/local/bin/"
|
||||||
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/embassy-os/"
|
error-log-root: "_env:ERROR_LOG_ROOT:/var/log/registry/"
|
||||||
marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
|
marketplace-name: "_env:MARKETPLACE_NAME:CHANGE ME"
|
||||||
|
icon-path: "_env:ICON_PATH:/var/www/html/resources"
|
||||||
|
|
||||||
database:
|
database:
|
||||||
database: "_env:PG_DATABASE:start9_registry"
|
database: "_env:PG_DATABASE:start9_registry"
|
||||||
|
|||||||
@@ -6,14 +6,17 @@ import Foundation (Handler, RegistryCtx (..))
|
|||||||
import Handler.Util (tickleMAU)
|
import Handler.Util (tickleMAU)
|
||||||
import Model (Category (..), EntityField (..))
|
import Model (Category (..), EntityField (..))
|
||||||
import Settings (AppSettings (..))
|
import Settings (AppSettings (..))
|
||||||
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>))
|
import Startlude (Generic, Show, Text, pure, ($), (.), (<$>), MonadIO (liftIO), decodeUtf8)
|
||||||
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getsYesod)
|
import Yesod (ToContent (..), ToTypedContent (..), YesodPersist (runDB), getsYesod)
|
||||||
import Yesod.Core.Types (JSONResponse (..))
|
import Yesod.Core.Types (JSONResponse (..))
|
||||||
|
import System.FilePath ((</>))
|
||||||
|
import Data.ByteString (readFile)
|
||||||
|
|
||||||
|
|
||||||
data InfoRes = InfoRes
|
data InfoRes = InfoRes
|
||||||
{ name :: !Text
|
{ name :: !Text
|
||||||
, categories :: ![Text]
|
, categories :: ![Text]
|
||||||
|
, icon :: !Text -- base64
|
||||||
}
|
}
|
||||||
deriving (Show, Generic)
|
deriving (Show, Generic)
|
||||||
instance ToJSON InfoRes
|
instance ToJSON InfoRes
|
||||||
@@ -26,10 +29,14 @@ instance ToTypedContent InfoRes where
|
|||||||
getInfoR :: Handler (JSONResponse InfoRes)
|
getInfoR :: Handler (JSONResponse InfoRes)
|
||||||
getInfoR = do
|
getInfoR = do
|
||||||
name <- getsYesod $ marketplaceName . appSettings
|
name <- getsYesod $ marketplaceName . appSettings
|
||||||
|
iconFile <- getsYesod $ (</> "icon") . iconPath . appSettings
|
||||||
|
icon' <- liftIO $ readFile iconFile
|
||||||
|
let icon = decodeUtf8 icon'
|
||||||
|
|
||||||
allCategories <- runDB $
|
allCategories <- runDB $
|
||||||
select $ do
|
select $ do
|
||||||
cats <- from $ table @Category
|
cats <- from $ table @Category
|
||||||
orderBy [asc (cats ^. CategoryPriority)]
|
orderBy [asc (cats ^. CategoryPriority)]
|
||||||
pure cats
|
pure cats
|
||||||
tickleMAU
|
tickleMAU
|
||||||
pure $ JSONResponse $ InfoRes name $ categoryName . entityVal <$> allCategories
|
pure $ JSONResponse $ InfoRes name (categoryName . entityVal <$> allCategories) icon
|
||||||
|
|||||||
@@ -62,29 +62,30 @@ import Orphans.Emver ( )
|
|||||||
type AppPort = Word16
|
type AppPort = Word16
|
||||||
data AppSettings = AppSettings
|
data AppSettings = AppSettings
|
||||||
{ appDatabaseConf :: !PostgresConf
|
{ appDatabaseConf :: !PostgresConf
|
||||||
, appHost :: !HostPreference
|
|
||||||
-- ^ Host/interface the server should bind to.
|
|
||||||
, appPort :: !AppPort
|
|
||||||
-- ^ Port to listen on
|
|
||||||
, appIpFromHeader :: !Bool
|
|
||||||
-- ^ Get the IP address from the header when logging. Useful when sitting
|
|
||||||
-- behind a reverse proxy.
|
|
||||||
, appDetailedRequestLogging :: !Bool
|
, appDetailedRequestLogging :: !Bool
|
||||||
-- ^ Use detailed request logging system
|
-- ^ Use detailed request logging system
|
||||||
|
, appHost :: !HostPreference
|
||||||
|
-- ^ Host/interface the server should bind to.
|
||||||
|
, appIpFromHeader :: !Bool
|
||||||
|
-- ^ Get the IP address from the header when logging. Useful when sitting
|
||||||
|
, appPort :: !AppPort
|
||||||
|
-- ^ Port to listen on
|
||||||
|
-- behind a reverse proxy.
|
||||||
, appShouldLogAll :: !Bool
|
, appShouldLogAll :: !Bool
|
||||||
-- ^ Should all log messages be displayed?
|
-- ^ Should all log messages be displayed?
|
||||||
, resourcesDir :: !FilePath
|
, iconPath :: !FilePath
|
||||||
, sslPath :: !FilePath
|
|
||||||
, sslAuto :: !Bool
|
|
||||||
, registryHostname :: !Text
|
|
||||||
, registryVersion :: !Version
|
|
||||||
, sslKeyLocation :: !FilePath
|
|
||||||
, sslCsrLocation :: !FilePath
|
|
||||||
, sslCertLocation :: !FilePath
|
|
||||||
, torPort :: !AppPort
|
|
||||||
, staticBinDir :: !FilePath
|
|
||||||
, errorLogRoot :: !FilePath
|
, errorLogRoot :: !FilePath
|
||||||
, marketplaceName :: !Text
|
, marketplaceName :: !Text
|
||||||
|
, registryHostname :: !Text
|
||||||
|
, registryVersion :: !Version
|
||||||
|
, resourcesDir :: !FilePath
|
||||||
|
, sslAuto :: !Bool
|
||||||
|
, sslCertLocation :: !FilePath
|
||||||
|
, sslCsrLocation :: !FilePath
|
||||||
|
, sslKeyLocation :: !FilePath
|
||||||
|
, sslPath :: !FilePath
|
||||||
|
, staticBinDir :: !FilePath
|
||||||
|
, torPort :: !AppPort
|
||||||
}
|
}
|
||||||
instance Has PkgRepo AppSettings where
|
instance Has PkgRepo AppSettings where
|
||||||
extract = liftA2 PkgRepo ((</> "apps") . resourcesDir) staticBinDir
|
extract = liftA2 PkgRepo ((</> "apps") . resourcesDir) staticBinDir
|
||||||
@@ -101,26 +102,26 @@ instance Has EosRepo AppSettings where
|
|||||||
instance FromJSON AppSettings where
|
instance FromJSON AppSettings where
|
||||||
parseJSON = withObject "AppSettings" $ \o -> do
|
parseJSON = withObject "AppSettings" $ \o -> do
|
||||||
appDatabaseConf <- o .: "database"
|
appDatabaseConf <- o .: "database"
|
||||||
appHost <- fromString <$> o .: "host"
|
|
||||||
appPort <- o .: "port"
|
|
||||||
appIpFromHeader <- o .: "ip-from-header"
|
|
||||||
appDetailedRequestLogging <- o .:? "detailed-logging" .!= True
|
appDetailedRequestLogging <- o .:? "detailed-logging" .!= True
|
||||||
|
appHost <- fromString <$> o .: "host"
|
||||||
|
appIpFromHeader <- o .: "ip-from-header"
|
||||||
|
appPort <- o .: "port"
|
||||||
appShouldLogAll <- o .:? "should-log-all" .!= False
|
appShouldLogAll <- o .:? "should-log-all" .!= False
|
||||||
resourcesDir <- o .: "resources-path"
|
|
||||||
sslPath <- o .: "ssl-path"
|
|
||||||
sslAuto <- o .: "ssl-auto"
|
|
||||||
registryHostname <- o .: "registry-hostname"
|
|
||||||
torPort <- o .: "tor-port"
|
|
||||||
staticBinDir <- o .: "static-bin-dir"
|
|
||||||
errorLogRoot <- o .: "error-log-root"
|
errorLogRoot <- o .: "error-log-root"
|
||||||
|
iconPath <- o .: "icon-path"
|
||||||
|
marketplaceName <- o .: "marketplace-name"
|
||||||
|
registryHostname <- o .: "registry-hostname"
|
||||||
|
resourcesDir <- o .: "resources-path"
|
||||||
|
sslAuto <- o .: "ssl-auto"
|
||||||
|
sslPath <- o .: "ssl-path"
|
||||||
|
staticBinDir <- o .: "static-bin-dir"
|
||||||
|
torPort <- o .: "tor-port"
|
||||||
|
|
||||||
let sslKeyLocation = sslPath </> "key.pem"
|
let sslKeyLocation = sslPath </> "key.pem"
|
||||||
let sslCsrLocation = sslPath </> "certificate.csr"
|
let sslCsrLocation = sslPath </> "certificate.csr"
|
||||||
let sslCertLocation = sslPath </> "certificate.pem"
|
let sslCertLocation = sslPath </> "certificate.pem"
|
||||||
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
let registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
||||||
|
|
||||||
marketplaceName <- o .: "marketplace-name"
|
|
||||||
|
|
||||||
return AppSettings { .. }
|
return AppSettings { .. }
|
||||||
|
|
||||||
-- | Raw bytes at compile time of @config/settings.yml@
|
-- | Raw bytes at compile time of @config/settings.yml@
|
||||||
|
|||||||
Reference in New Issue
Block a user