mirror of
https://github.com/Start9Labs/registry.git
synced 2026-03-26 02:11:53 +00:00
Merge branch 'master' of github.com:Start9Labs/registry
This commit is contained in:
@@ -4,14 +4,10 @@
|
||||
/version VersionR GET
|
||||
|
||||
/apps/version/#Text VersionAppR GET --get most recent appId version
|
||||
/sys/version/agent VersionAgentR GET --get most recent agent version
|
||||
/sys/version/appmgr VersionAppMgrR GET --get most recent appmgr version
|
||||
/sys/version/torrc VersionTorrcR GET --get most recent torrc version
|
||||
/sys/version/#Text VersionSysR GET --get most recent sys app version
|
||||
|
||||
/icons/#PNG IconsR GET -- get icons
|
||||
!/apps/#S9PK AppR GET --get most recent appId at appversion spec, defaults to >=0.0.0 -- ?spec={semver-spec}
|
||||
/sys/agent AgentR GET --get most recent agent at appversion -- ?spec={semver-spec}
|
||||
/sys/appmgr AppMgrR GET --get most recent appmgr at appversion -- ?spec={semver-spec}
|
||||
/sys/torrc TorrcR GET --get most recent torrc at appversion -- ?spec={semver-spec}
|
||||
!/sys/#SYS_EXTENSIONLESS SysR GET --get most recent sys app -- ?spec={semver-spec}
|
||||
|
||||
/sys.tar.gz ImageR GET --get most recent iso image, ?spec={semver-spec}
|
||||
@@ -12,7 +12,7 @@ sslPath :: FilePath
|
||||
sslPath = "/var/ssl"
|
||||
|
||||
resourcesDir :: FilePath
|
||||
resourcesDir = "/var/www/html/resources"
|
||||
resourcesDir = "/var/www/html/resources" -- "./resources" --
|
||||
|
||||
registryVersion :: AppVersion
|
||||
registryVersion = fromJust . parseMaybe parseJSON . String . toS . showVersion $ version
|
||||
|
||||
@@ -42,14 +42,8 @@ getAppsManifestR = respondSource typePlain $ CB.sourceFile appManifestPath .| aw
|
||||
getImageR :: Handler TypedContent
|
||||
getImageR = getApp resourcesDir ("sys" :: Extension "tar.gz")
|
||||
|
||||
getAgentR :: Handler TypedContent
|
||||
getAgentR = getApp sysResourceDir ("agent" :: Extension "")
|
||||
|
||||
getAppMgrR :: Handler TypedContent
|
||||
getAppMgrR = getApp sysResourceDir ("appmgr" :: Extension "")
|
||||
|
||||
getTorrcR :: Handler TypedContent
|
||||
getTorrcR = getApp sysResourceDir ("torrc" :: Extension "")
|
||||
getSysR :: Extension "" -> Handler TypedContent
|
||||
getSysR = getApp sysResourceDir
|
||||
|
||||
getAppR :: Extension "s9pk" -> Handler TypedContent
|
||||
getAppR = getApp appResourceDir
|
||||
|
||||
@@ -21,14 +21,10 @@ getVersionAppR appId = getVersionWSpec appResourceDir appExt
|
||||
where
|
||||
appExt = Extension (toS appId) :: Extension "s9pk"
|
||||
|
||||
getVersionAgentR :: Handler (Maybe AppVersionRes)
|
||||
getVersionAgentR = getVersionWSpec sysResourceDir ("agent" :: Extension "")
|
||||
|
||||
getVersionAppMgrR :: Handler (Maybe AppVersionRes)
|
||||
getVersionAppMgrR = getVersionWSpec sysResourceDir ("appmgr" :: Extension "")
|
||||
|
||||
getVersionTorrcR :: Handler (Maybe AppVersionRes)
|
||||
getVersionTorrcR = getVersionWSpec sysResourceDir ("torrc" :: Extension "")
|
||||
getVersionSysR :: Text -> Handler (Maybe AppVersionRes)
|
||||
getVersionSysR sysAppId = getVersionWSpec sysResourceDir sysExt
|
||||
where
|
||||
sysExt = Extension (toS sysAppId) :: Extension ""
|
||||
|
||||
getVersionWSpec :: KnownSymbol a => FilePath -> Extension a -> Handler (Maybe AppVersionRes)
|
||||
getVersionWSpec rootDir ext = do
|
||||
|
||||
@@ -14,8 +14,6 @@ import System.Directory
|
||||
import System.FilePath
|
||||
import Yesod.Core
|
||||
|
||||
import Data.Text (isSuffixOf)
|
||||
|
||||
import Constants
|
||||
import Lib.Semver
|
||||
import Lib.Types.Semver
|
||||
@@ -64,6 +62,7 @@ getUnversionedFileFromDir rootDirectory appExt = fmap (join . hush) . try @SomeE
|
||||
|
||||
newtype Extension (a :: Symbol) = Extension String deriving (Eq)
|
||||
type S9PK = Extension "s9pk"
|
||||
type SYS_EXTENSIONLESS = Extension ""
|
||||
type PNG = Extension "png"
|
||||
|
||||
instance IsString (Extension a) where
|
||||
@@ -79,11 +78,16 @@ instance KnownSymbol a => Show (Extension a) where
|
||||
show e@(Extension file) = file <.> extension e
|
||||
|
||||
instance KnownSymbol a => Read (Extension a) where
|
||||
readsPrec _ s = [(Extension . take (m - n - 1) $ s, "") | toS ext' `isSuffixOf` toS s]
|
||||
readsPrec _ s = [(Extension fileName, "") | ("" <.> fileExt) == ("" <.> ext')]
|
||||
where
|
||||
m = length s
|
||||
(fileName, fileExt) = splitExtension s
|
||||
ext' = extension (def :: Extension a)
|
||||
n = length ext'
|
||||
|
||||
withPeriod :: String -> String
|
||||
withPeriod word@(a:_) = case a of
|
||||
'.' -> word
|
||||
_ -> "." <> word
|
||||
withPeriod word = word
|
||||
|
||||
instance KnownSymbol a => PathPiece (Extension a) where
|
||||
fromPathPiece = readMaybe . toS
|
||||
|
||||
Reference in New Issue
Block a user