Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@

[pageContext.youtube]
APIKey = "AIzaSyCzI5Gvpq1hPlfjvB81EVc0vLv_11eW7NI"
sessionsPlaylistID = "PLsxUDJzU4VKDudlmlYb-ImFKreFKAfFln"
homepagePlaylistID = "PLsxUDJzU4VKDag-NVag4kMN1i5C7ZyP85"
homepageDescription = "Fresh music from fresh artists, something witty here..."
homepageTitle = "Q-Fest"
homepageBGColour = "#235660"
homepageColor = "#fff"
od1PlaylistID = "PLsxUDJzU4VKDudlmlYb-ImFKreFKAfFln"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eeeeeeek. Have you considered just using an array?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, there must be a better way. Or maybe toml isnt appropriate for this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://toml.io/en/v1.0.0-rc.2#array-of-tables looks like you can do something with tables and arrays :)

od1Description = "Fresh music from fresh artists, something witty here..."
od1Title = "URY Sessions"
od1BGColor = "#53306a"
od1Color = "#fff"
od2PlaylistID = "PLsxUDJzU4VKDag-NVag4kMN1i5C7ZyP85"
od2Description = "Fresh music from fresh artists, something witty here..."
od2Title = "Q-Fest"
od2BGColor = "#235660"
od2Color = "#fff"
cinPlaylistID = "PLsxUDJzU4VKAAH1pOogbzJx7pZgd-2zOx"
channelURL = "//youtube.com/ury1350"

Expand Down
25 changes: 16 additions & 9 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function getYoutubeFeed(playlistid, results, htmlid) {
"</div>"
);
}
if (isIndex && htmlid === "#sessions-videos") {
if (htmlid === "#homepage-videos") {
$(htmlid).append(
'<div class="thumbnail-container col-10 col-sm-7 col-md-4 col-lg-3">' +
"<a class=\"ury-card sessions link\" href='/ontap/'>" +
Expand All @@ -42,7 +42,7 @@ function getYoutubeFeed(playlistid, results, htmlid) {
"</div>"
);
}
if (isOD && htmlid === "#sessions-videos") {
if (isOD && htmlid !== "#cin-videos") {
$(htmlid).append(
'<div class="thumbnail-container col-10 col-sm-7 col-md-4 col-lg-3">' +
'<a class="ury-card sessions link" href="' +
Expand All @@ -66,7 +66,7 @@ function getYoutubeFeed(playlistid, results, htmlid) {
"</div>"
);
}
if (isCIN && htmlid === "#cin-videos") {
if (!isCIN && htmlid === "#cin-videos") {
$(htmlid).append(
'<div class="thumbnail-container col-10 col-sm-7 col-md-4 col-lg-3">' +
'<a class="ury-card cin link" href="' +
Expand Down Expand Up @@ -129,15 +129,22 @@ istorn2020Counter();
//Youtube slideshow for index page
function onGoogleLoad() {
if (isIndex) {
getYoutubeFeed(youtubeSessionsPlaylistID, 7, "#sessions-videos");
if (youtubeHomepagePlaylistID) {
getYoutubeFeed(youtubeHomepagePlaylistID, 7, "#homepage-videos");
}
}
if (isOD) {
getYoutubeFeed(youtubeSessionsPlaylistID, 15, "#sessions-videos");
}
if (isIndex) {
getYoutubeFeed(youtubeCINPlaylistID, 7, "#cin-videos");
if (youtubeOD1PlaylistID) {
getYoutubeFeed(youtubeOD1PlaylistID, 15, "#od1-videos");
}
if (youtubeOD2PlaylistID) {
getYoutubeFeed(youtubeOD2PlaylistID, 15, "#od2-videos");
}
}
if (isCIN) {
if (isOD && isCIN) {
getYoutubeFeed(youtubeCINPlaylistID, 15, "#cin-videos");
}
if (isIndex && isCIN) {
getYoutubeFeed(youtubeCINPlaylistID, 7, "#cin-videos");
}
}
30 changes: 22 additions & 8 deletions structs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type Config struct {

// Server is a structure containing server configuration.
type Server struct {
Address string `toml:"address"`
Port int `toml:"port"`
Timeout int `toml:"timeout"`
MyRadioAPI string `toml:"myradio_api"`
Address string `toml:"address"`
Port int `toml:"port"`
Timeout int `toml:"timeout"`
MyRadioAPI string `toml:"myradio_api"`
}

// PageContext is a structure containing static information to provide
Expand Down Expand Up @@ -63,10 +63,24 @@ type Page struct {
}

type youtube struct {
APIKey string `toml:"apiKey"`
SessionsPlaylistID string `toml:"sessionsPlaylistID"`
CINPlaylistID string `toml:"cinPlaylistID"`
ChannelURL string `toml:"channelURL"`
APIKey string `toml:"apiKey"`
HomepagePlaylistID string `toml:"homepagePlaylistID"`
HomepageTitle string `toml:"homepageTitle"`
HomepageDescription string `toml:"homepageDescription"`
HomepageBGColor string `toml:"homepageBGColour"`
HomepageColor string `toml:"homepageColor"`
OD1PlaylistID string `toml:"od1PlaylistID"`
OD1Title string `toml:"od1Title"`
OD1Description string `toml:"od1Description"`
OD1BGColor string `toml:"od1BGColor"`
OD1Color string `toml:"od1Color"`
OD2PlaylistID string `toml:"od2PlaylistID"`
OD2Title string `toml:"od2Title"`
OD2Description string `toml:"od2Description"`
OD2BGColor string `toml:"od2BGColor"`
OD2Color string `toml:"od2Color"`
CINPlaylistID string `toml:"cinPlaylistID"`
ChannelURL string `toml:"channelURL"`
}

type gmaps struct {
Expand Down
3 changes: 1 addition & 2 deletions views/cin.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
{{define "footer-scripts"}}
<!-- Youtube slider script -->
<script>
var youtubeAPIKey = {{.PageContext.Youtube.APIKey}};
var youtubeSessionsPlaylistID = "{{.PageContext.Youtube.SessionsPlaylistID}}";
var youtubeAPIKey = "{{.PageContext.Youtube.APIKey}}";
var youtubeCINPlaylistID = "{{.PageContext.Youtube.CINPlaylistID}}";
var youtubeLink = "{{.PageContext.Youtube.ChannelURL}}";
var isIndex = false;
Expand Down
2 changes: 1 addition & 1 deletion views/elements/banner.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{{range $index, $Banners := .Banners}}
<div class="carousel-item {{ if eq $index 0 }} active {{end}}">
<a class="w-100" href="{{$Banners.Target}}">
<img class="d-block img-fluid" src="https://ury.org.uk{{$Banners.URL}}" alt="{{$Banners.Alt}}">
<img class="d-block img-fluid" src="{{$.PageContext.FullURL}}{{$Banners.URL}}" alt="{{$Banners.Alt}}">
</a>
</div>
{{end}}
Expand Down
16 changes: 10 additions & 6 deletions views/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
</div>
{{end}}
{{if .PageContext.CIN}}
<div id="index-videos" class="container-fluid container-padded pb-0 bg-cin">
<div id="index-cin" class="container-fluid container-padded pb-0 bg-cin">
<h2 class="cin-text">URY Candidate Interview Night</h2>
<div id="cin-videos" class="row scroll-horiz pb-3 custom-scrollbar-cin thumbnail-slider">
</div>
Expand Down Expand Up @@ -87,9 +87,12 @@
</div>
</div>
{{end}}
<div id="index-videos" class="container-fluid container-padded pb-0 bg-sessions">
<h2>URY Sessions</h2>
<div id="sessions-videos" class="row scroll-horiz pb-3 custom-scrollbar-music thumbnail-slider">
{{end}}
{{ if .PageContext.Youtube.HomepagePlaylistID }}
<div id="index-videos" class="container-fluid container-padded pb-0" style="background:{{.PageContext.Youtube.HomepageBGColor}};color:{{.PageContext.Youtube.HomepageColor}};">
<h2 class="d-inline">{{.PageContext.Youtube.HomepageTitle}}</h2>
<h3 class="d-inline ml-1">{{.PageContext.Youtube.HomepageDescription}}</h3>
<div id="homepage-videos" class="row scroll-horiz pb-3 custom-scrollbar-music thumbnail-slider">
</div>
</div>
{{end}}
Expand All @@ -98,9 +101,10 @@
{{define "footer-scripts"}}
<!-- Youtube slider script -->
<script>
var youtubeAPIKey = {{.PageContext.Youtube.APIKey}};
var youtubeSessionsPlaylistID = "{{.PageContext.Youtube.SessionsPlaylistID}}";
var youtubeAPIKey = "{{.PageContext.Youtube.APIKey}}";
var youtubeHomepagePlaylistID = "{{.PageContext.Youtube.HomepagePlaylistID}}";
var youtubeCINPlaylistID = "{{.PageContext.Youtube.CINPlaylistID}}";
var youtubeLink = "{{.PageContext.Youtube.ChannelURL}}";
var isIndex = true;
var isCIN = {{if .PageContext.CIN}}true{{else}}false{{end}};
var isOD = false;
Expand Down
30 changes: 23 additions & 7 deletions views/on_demand.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
</div>
</div>
{{if .PageData.LatestPodcasts}}
<div id="index-podcasts" class="container-fluid container-padded pb-0 bg-podcasts">
<div class="container-fluid container-padded pb-0 bg-podcasts">
<h2>Latest Podcasts</h2>
<div class="row custom-scrollbar scroll-horiz thumbnail-slider">
{{range .PageData.LatestPodcasts}}
Expand All @@ -77,23 +77,39 @@
</div>
</div>
{{end}}
<div id="index-videos" class="container-fluid container-padded bg-sessions">
<!-- OD2 for current events (other than the regular sessions etc -->
{{ if .PageContext.Youtube.OD2PlaylistID }}
<div class="container-fluid container-padded" style="background:{{.PageContext.Youtube.OD2BGColor}};color:{{.PageContext.Youtube.OD2Color}};">
<div class="row">
<div class="col-12 col-md-8">
<a name="YouTube"></a><h2>URY Sessions</h2>
<h2 class="d-inline">{{.PageContext.Youtube.OD2Title}}</h2>
<h3 class="d-inline ml-1">{{.PageContext.Youtube.OD2Description}}</h3>
</div>
</div>
<div id="sessions-videos" class="row pb-3 thumbnail-grid">
<div id="od2-videos" class="row pb-3 thumbnail-grid">
</div>
</div>
{{end}}
{{ if .PageContext.Youtube.OD1PlaylistID }}
<div class="container-fluid container-padded" style="background:{{.PageContext.Youtube.OD1BGColor}};color:{{.PageContext.Youtube.OD2Color}};">
<div class="row">
<div class="col-12 col-md-8">
<h2 class="d-inline">{{.PageContext.Youtube.OD1Title}}</h2>
<h3 class="d-inline ml-1">{{.PageContext.Youtube.OD1Description}}</h3>
</div>
</div>
<div id="od1-videos" class="row pb-3 thumbnail-grid">
</div>
</div>
{{end}}
{{end}}

{{define "footer-scripts"}}
<!-- Youtube slider script -->
<script>
var youtubeAPIKey = {{.PageContext.Youtube.APIKey}};
var youtubeSessionsPlaylistID = "{{.PageContext.Youtube.SessionsPlaylistID}}";
var youtubeCINPlaylistID = "{{.PageContext.Youtube.CINPlaylistID}}";
var youtubeAPIKey = "{{.PageContext.Youtube.APIKey}}";
var youtubeOD1PlaylistID = "{{.PageContext.Youtube.OD1PlaylistID}}";
var youtubeOD2PlaylistID = "{{.PageContext.Youtube.OD2PlaylistID}}";
var youtubeLink = "{{.PageContext.Youtube.ChannelURL}}";
var isIndex = false;
var isCIN = false;
Expand Down