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
maybeUser <- maybeAuth
app <- getYesod
let repoHost = appRepoHost $ appSettings app
case maybeUser of
Just (Entity userId user) -> do
enableTriggerToken userId (userTriggerToken user)
@ -94,7 +97,7 @@ getChallengeHowToR name = do
keys <- runDB $ selectList [PublicKeyUser ==. userId] []
return $ not (null keys)
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 =
case maybeUser of
@ -106,7 +109,7 @@ idToBeShown challenge maybeUser =
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 name = do

View File

@ -61,6 +61,8 @@ data AppSettings = AppSettings
, appAdminPassword :: Maybe Text
-- ^ Additional info for the instance
, appLocation :: Maybe Text
-- ^ Repo host
, appRepoHost :: Text
}
instance FromJSON AppSettings where
@ -93,6 +95,8 @@ instance FromJSON AppSettings where
appAdminPassword <- o .:? "admin-password"
appLocation <- o .:? "location"
appRepoHost <- o .: "repo-host"
return AppSettings {..}
-- | 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"
var-dir: "_env:VAR_DIR:."
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.
# 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:
<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.)
<pre>
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.)