repo host can be set

This commit is contained in:
Filip Gralinski 2018-06-05 23:04:58 +02:00
parent 1262cc7cb8
commit 28222d5a37
4 changed files with 12 additions and 4 deletions

View File

@ -77,6 +77,9 @@ getChallengeHowToR name = do
(Entity _ challenge) <- runDB $ getBy404 $ UniqueName name (Entity _ challenge) <- runDB $ getBy404 $ UniqueName name
maybeUser <- maybeAuth maybeUser <- maybeAuth
app <- getYesod
let repoHost = appRepoHost $ appSettings app
case maybeUser of case maybeUser of
Just (Entity userId user) -> do Just (Entity userId user) -> do
enableTriggerToken userId (userTriggerToken user) enableTriggerToken userId (userTriggerToken user)
@ -94,7 +97,7 @@ getChallengeHowToR name = do
keys <- runDB $ selectList [PublicKeyUser ==. userId] [] keys <- runDB $ selectList [PublicKeyUser ==. userId] []
return $ not (null keys) return $ not (null keys)
Nothing -> return False Nothing -> return False
challengeLayout False challenge (challengeHowTo challenge (idToBeShown challenge maybeUser) isIDSet isSSHUploaded mToken) challengeLayout False challenge (challengeHowTo challenge repoHost (idToBeShown challenge maybeUser) isIDSet isSSHUploaded mToken)
idToBeShown challenge maybeUser = idToBeShown challenge maybeUser =
case maybeUser of case maybeUser of
@ -106,7 +109,7 @@ idToBeShown challenge maybeUser =
defaultRepo challenge maybeUser = "ssh://gitolite@gonito.net/" ++ (idToBeShown challenge maybeUser) ++ "/" ++ (challengeName challenge) defaultRepo challenge maybeUser = "ssh://gitolite@gonito.net/" ++ (idToBeShown challenge maybeUser) ++ "/" ++ (challengeName challenge)
challengeHowTo challenge idToBeShown isIDSet isSSHUploaded mToken = $(widgetFile "challenge-how-to") challengeHowTo challenge repoHost idToBeShown isIDSet isSSHUploaded mToken = $(widgetFile "challenge-how-to")
getChallengeSubmissionR :: Text -> Handler Html getChallengeSubmissionR :: Text -> Handler Html
getChallengeSubmissionR name = do getChallengeSubmissionR name = do

View File

@ -61,6 +61,8 @@ data AppSettings = AppSettings
, appAdminPassword :: Maybe Text , appAdminPassword :: Maybe Text
-- ^ Additional info for the instance -- ^ Additional info for the instance
, appLocation :: Maybe Text , appLocation :: Maybe Text
-- ^ Repo host
, appRepoHost :: Text
} }
instance FromJSON AppSettings where instance FromJSON AppSettings where
@ -93,6 +95,8 @@ instance FromJSON AppSettings where
appAdminPassword <- o .:? "admin-password" appAdminPassword <- o .:? "admin-password"
appLocation <- o .:? "location" appLocation <- o .:? "location"
appRepoHost <- o .: "repo-host"
return AppSettings {..} return AppSettings {..}
-- | Settings for 'widgetFile', such as which template languages to support and -- | Settings for 'widgetFile', such as which template languages to support and

View File

@ -8,6 +8,7 @@ approot: "_env:APPROOT:http://localhost:3000"
ip-from-header: "_env:IP_FROM_HEADER:false" ip-from-header: "_env:IP_FROM_HEADER:false"
var-dir: "_env:VAR_DIR:." var-dir: "_env:VAR_DIR:."
contact-email: "_env:CONTACT_EMAIL:filipg@amu.edu.pl" contact-email: "_env:CONTACT_EMAIL:filipg@amu.edu.pl"
repo-host: "_env:REPO_HOST:ssh://gitolite@gonito.net/"
# Optional values with the following production defaults. # Optional values with the following production defaults.
# In development, they default to the inverse. # In development, they default to the inverse.

View File

@ -40,13 +40,13 @@ $if not isIDSet || not isSSHUploaded
\ (see <a href="@{YourAccountR}">your account</a>) if you want to have a repo hosted on Gonito.net, then: \ (see <a href="@{YourAccountR}">your account</a>) if you want to have a repo hosted on Gonito.net, then:
<pre> <pre>
git clone ssh://gitolite@gonito.net/#{idToBeShown}/#{challengeName challenge} git clone #{repoHost}#{idToBeShown}/#{challengeName challenge}
<p>(Warning about empty repository is expected, don't worry about it.) <p>(Warning about empty repository is expected, don't worry about it.)
<pre> <pre>
cd #{challengeName challenge} cd #{challengeName challenge}
git pull ssh://gitolite@gonito.net/#{challengeName challenge} git pull #{repoHost}#{challengeName challenge}
<p>(Alternatively, you can use any other Git repo, e.g. GitHub, make sure Gonito.net has access to your repo.) <p>(Alternatively, you can use any other Git repo, e.g. GitHub, make sure Gonito.net has access to your repo.)