Fix some small bugs

This commit is contained in:
Ben Visness 2021-08-29 19:15:48 -05:00
parent 4204081563
commit e5055a1237
4 changed files with 32 additions and 17 deletions

View File

@ -14,6 +14,9 @@ help: ## Print this help.
deploy: deploy:
/home/hmn/hmn/server/deploy.sh $1 /home/hmn/hmn/server/deploy.sh $1
build:
sudo -u hmn --preserve-env=PATH bash -c "cd ~/hmn && go build -o /home/hmn/bin/hmn src/main.go"
edit-config: edit-config:
vim /home/hmn/hmn/src/config/config.go vim /home/hmn/hmn/src/config/config.go
@echo 'Now that you have edited the config, you probably want to re-deploy the site:' @echo 'Now that you have edited the config, you probably want to re-deploy the site:'
@ -21,7 +24,7 @@ edit-config:
@echo ' make deploy' @echo ' make deploy'
@echo '' @echo ''
logs-hmn: ## View logs for the website logs: ## View logs for the website
journalctl -u hmn.service -f journalctl -u hmn.service -f
logs-caddy: ## View logs for Caddy logs-caddy: ## View logs for Caddy

View File

@ -135,7 +135,9 @@ SCRIPT
fi fi
# Set up SSH # Set up SSH
if [ $checkpoint -lt 81] if [ $checkpoint -lt 81 ]; then
set +x
do_as hmn <<'SCRIPT' do_as hmn <<'SCRIPT'
ssh-keygen -t ed25519 -C "beta-server" -N "" -f ~/.ssh/gitlab ssh-keygen -t ed25519 -C "beta-server" -N "" -f ~/.ssh/gitlab
git config --global core.sshCommand "ssh -i ~/.ssh/gitlab" git config --global core.sshCommand "ssh -i ~/.ssh/gitlab"
@ -253,9 +255,22 @@ ${BLUE_BOLD}Caddy${RESET}: /home/caddy/Caddyfile
use when deploying. For example, a deployment of the beta site should use use when deploying. For example, a deployment of the beta site should use
the 'beta' branch. the 'beta' branch.
${BLUE_BOLD}Monit${RESET}: ~/.monitrc ${BLUE_BOLD}Website${RESET}: /home/hmn/hmn/src/config/config.go
Add the password for the email server. First make sure you have Go on your path:
source ~/.bashrc
Then edit the config file using a special make task:
make edit-config
Fill out everything, then rebuild the site:
make build
You don't need to deploy the site yet; wait until you've
configured everything.
${BLUE_BOLD}Deploy Secret${RESET}: /home/hmn/hmn/server/deploy.conf ${BLUE_BOLD}Deploy Secret${RESET}: /home/hmn/hmn/server/deploy.conf
@ -267,16 +282,6 @@ ${BLUE_BOLD}Deploy Secret${RESET}: /home/hmn/hmn/server/deploy.conf
Then, edit the above file and fill in the secret value from the Then, edit the above file and fill in the secret value from the
GitLab webhook. GitLab webhook.
${BLUE_BOLD}Website${RESET}: /home/hmn/hmn/src/config/config.go
Fill out everything :)
Then rebuild the site:
su hmn
cd ~/hmn
go build -o /home/hmn/bin/hmn src/main.go
${BLUE_BOLD}Cinera${RESET}: /home/hmn/hmn/cinera/cinera.conf ${BLUE_BOLD}Cinera${RESET}: /home/hmn/hmn/cinera/cinera.conf
Add the correct domain. Add the correct domain.
@ -302,4 +307,6 @@ Then deploy the site:
make deploy make deploy
Run 'make' on its own to see all the other tasks available to you!
HELP HELP

View File

@ -39,8 +39,8 @@ var Config = HMNConfig{
AssetsSpacesRegion: "", AssetsSpacesRegion: "",
AssetsSpacesEndpoint: "", AssetsSpacesEndpoint: "",
AssetsSpacesBucket: "", AssetsSpacesBucket: "",
AssetsPathPrefix: "", AssetsPathPrefix: "", // Empty is fine for production, but may be necessary for dev
AssetsPublicUrlRoot: "", AssetsPublicUrlRoot: "", // e.g. "https://bucket-name.region.cdn.digitaloceanspaces.com/". Note the trailing slash...
}, },
EpisodeGuide: EpisodeGuide{ EpisodeGuide: EpisodeGuide{
CineraOutputPath: "./annotations/", CineraOutputPath: "./annotations/",

View File

@ -14,6 +14,7 @@ import (
"regexp" "regexp"
"strings" "strings"
"git.handmade.network/hmn/hmn/src/hmnurl"
"git.handmade.network/hmn/hmn/src/logging" "git.handmade.network/hmn/hmn/src/logging"
"git.handmade.network/hmn/hmn/src/models" "git.handmade.network/hmn/hmn/src/models"
"git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/oops"
@ -252,7 +253,11 @@ func (c *RequestContext) Redirect(dest string, code int) ResponseData {
} }
// Escape stuff // Escape stuff
destUrl, _ := url.Parse(dest) destUrl, err := url.Parse(dest)
if err != nil {
c.Logger.Warn().Err(err).Str("dest", dest).Msg("Failed to parse redirect URI")
return c.Redirect(hmnurl.BuildHomepage(), http.StatusSeeOther)
}
dest = destUrl.String() dest = destUrl.String()
res.Header().Set("Location", dest) res.Header().Set("Location", dest)