Testing jam embed

This commit is contained in:
Asaf Gartner 2023-10-14 17:39:57 +03:00
parent c6893f3f3f
commit 38acf4a904
2 changed files with 30 additions and 0 deletions

View File

@ -18,6 +18,12 @@
} }
</style> </style>
{{ if .TwitchEmbedUrl }}
<div class="section mw8 margin-center ph3 ph4-l mv4" style="aspect-ratio: 16 / 9;">
<iframe src="{{ .TwitchEmbedUrl }}" allowfullscreen width="100%" height="100%"></iframe>
</div>
{{ end }}
<div id="top-container" class="flex flex-column items-center ph3"> <div id="top-container" class="flex flex-column items-center ph3">
<img id="logo" src="{{ static "wheeljam2023/logo.svg" }}"> <img id="logo" src="{{ static "wheeljam2023/logo.svg" }}">
<h1 id="title">Wheel Reinvention Jam</h1> <h1 id="title">Wheel Reinvention Jam</h1>

View File

@ -1,12 +1,16 @@
package website package website
import ( import (
"fmt"
"net/http" "net/http"
"net/url"
"time" "time"
"git.handmade.network/hmn/hmn/src/config"
"git.handmade.network/hmn/hmn/src/db" "git.handmade.network/hmn/hmn/src/db"
"git.handmade.network/hmn/hmn/src/hmndata" "git.handmade.network/hmn/hmn/src/hmndata"
"git.handmade.network/hmn/hmn/src/hmnurl" "git.handmade.network/hmn/hmn/src/hmnurl"
"git.handmade.network/hmn/hmn/src/models"
"git.handmade.network/hmn/hmn/src/oops" "git.handmade.network/hmn/hmn/src/oops"
"git.handmade.network/hmn/hmn/src/templates" "git.handmade.network/hmn/hmn/src/templates"
"git.handmade.network/hmn/hmn/src/utils" "git.handmade.network/hmn/hmn/src/utils"
@ -61,6 +65,7 @@ func JamIndex2023(c *RequestContext) ResponseData {
ProjectSubmissionUrl string ProjectSubmissionUrl string
ShowcaseFeedUrl string ShowcaseFeedUrl string
ShowcaseJson string ShowcaseJson string
TwitchEmbedUrl string
JamProjects []templates.Project JamProjects []templates.Project
} }
@ -119,6 +124,24 @@ func JamIndex2023(c *RequestContext) ResponseData {
showcaseJson := templates.TimelineItemsToJSON(showcaseItems) showcaseJson := templates.TimelineItemsToJSON(showcaseItems)
twitchEmbedUrl := ""
twitchStatus, err := db.QueryOne[models.TwitchLatestStatus](c, c.Conn,
`
SELECT $columns
FROM twitch_latest_status
WHERE twitch_login = $1
`,
"piratesoftware",
)
if err == nil {
if twitchStatus.Live {
hmnUrl, err := url.Parse(config.Config.BaseUrl)
if err == nil {
twitchEmbedUrl = fmt.Sprintf("https://player.twitch.tv/?channel=%s&parent=%s", twitchStatus.TwitchLogin, hmnUrl.Hostname())
}
}
}
res.MustWriteTemplate("jam_2023_wrj_index.html", JamPageData{ res.MustWriteTemplate("jam_2023_wrj_index.html", JamPageData{
BaseData: baseData, BaseData: baseData,
DaysUntilStart: daysUntilStart, DaysUntilStart: daysUntilStart,
@ -130,6 +153,7 @@ func JamIndex2023(c *RequestContext) ResponseData {
ShowcaseFeedUrl: hmnurl.BuildJamFeed2023(), ShowcaseFeedUrl: hmnurl.BuildJamFeed2023(),
ShowcaseJson: showcaseJson, ShowcaseJson: showcaseJson,
JamProjects: pageProjects, JamProjects: pageProjects,
TwitchEmbedUrl: twitchEmbedUrl,
}, c.Perf) }, c.Perf)
return res return res
} }