Skip to content

Commit

Permalink
Merge branch 'development' into marks/errors
Browse files Browse the repository at this point in the history
  • Loading branch information
markspolakovs committed Sep 15, 2024
2 parents 50e6f59 + f7f457d commit 9653b62
Show file tree
Hide file tree
Showing 70 changed files with 1,602 additions and 617 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
10 changes: 5 additions & 5 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Go
uses: WillAbides/setup-go-faster@v1.6.0
uses: WillAbides/setup-go-faster@v1.14.0
with:
go-version: 1.17

Expand All @@ -31,15 +31,15 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Set up Go
uses: WillAbides/setup-go-faster@v1.6.0
uses: WillAbides/setup-go-faster@v1.14.0
with:
go-version: 1.17

- name: Lint
uses: golangci/golangci-lint-action@v2
uses: golangci/golangci-lint-action@v6
with:
version: latest
working-directory: ${{ github.workspace }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ public/css/*.scss.css
.myradio.key
config.toml
public/css/*.scss.css.map


.direnv/

13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.7
FROM golang:1.21

ENV SASS_VERSION=3.3.6

Expand All @@ -9,14 +9,15 @@ RUN set -e && \
cp /usr/local/sassc-$SASS_VERSION/bin/sassc /usr/local/bin/sassc && \
rm -rf /usr/local/sassc-$SASS_VERSION /usr/local/libsass-$SASS_VERSION

RUN mkdir -p /go/src/github.com/UniversityRadioYork/2016-site
WORKDIR /go/src/github.com/UniversityRadioYork/2016-site
WORKDIR /usr/src/app

COPY . /go/src/github.com/UniversityRadioYork/2016-site
COPY . /usr/src/app/

EXPOSE 3000
RUN go get

ENV TZ "Europe/London"

RUN go get -d -v
EXPOSE 3000

ENTRYPOINT echo "\033[0;31mWARNING: \033[0mRunning with Docker will change \"localhost\" to \"0.0.0.0\" in your config. Remember to change it back!" && \
sed -i 's/localhost/0.0.0.0/g' *.toml && make run
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ build-docker-image:
docker build -t 2016-site .

docker:
docker run -it --rm -p 3000:3000 -v $$GOPATH/src/github.com/UniversityRadioYork/2016-site:/go/src/github.com/UniversityRadioYork/2016-site 2016-site
docker run -it --rm -p 3000:3000 -v .:/usr/src/app 2016-site

clean:
rm -f $(OUTPUT_FILE) $(BINARY)
Expand Down
10 changes: 5 additions & 5 deletions config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
[pageContext]
longName = "University Radio York"
shortName = "URY"
siteDescription = "University Radio York (URY) is the student radio station for the University of York, broadcasting 24 hours a day during term time on 1350AM and 88.3FM across campus, and worldwide via this website."
siteDescription = "University Radio York (URY) is the student radio station for the University of York, broadcasting 24 hours a day during term time on 88.3FM across campus, and worldwide via this website."

urlPrefix = ""
fullURL = "https://ury.org.uk"
Expand All @@ -37,6 +37,7 @@

christmas = true
aprilFools = false
pride = true

# Candidate Interview Night Stuff
cin = true
Expand Down Expand Up @@ -64,12 +65,10 @@

[pageContext.youtube]
APIKey = "AIzaSyCzI5Gvpq1hPlfjvB81EVc0vLv_11eW7NI"
sessionsPlaylistID = "PLsxUDJzU4VKDudlmlYb-ImFKreFKAfFln"
cinPlaylistID = "PLsxUDJzU4VKAAH1pOogbzJx7pZgd-2zOx"
channelURL = "//youtube.com/ury1350"

[pageContext.gmaps]
APIKey = "AIzaSyACeeyIgdIhiSxV01OIPiA3MyJDqrOspLQ"
[pageContext.osm]
latitude = 53.948193
longitude = -1.054030

Expand All @@ -79,4 +78,5 @@

[schedule.sustainer]
name = "Overnight Owen"
desc = "Non-stop tones from the URY jukebox."
desc = "Non-stop tunes from the URY jukebox."
image = "//ury.org.uk/media/image_meta/ShowImageMetadata/22.png"
43 changes: 43 additions & 0 deletions controllers/about.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package controllers

import (
"log"
"net/http"

"github.com/UniversityRadioYork/2016-site/models"
"github.com/UniversityRadioYork/2016-site/structs"
"github.com/UniversityRadioYork/2016-site/utils"
"github.com/UniversityRadioYork/myradio-go"
)

// AboutController is the controller for the about page.
type AboutController struct {
Controller
}

// NewAboutController returns a new AboutController with the MyRadio session s
// and configuration context c.
func NewAboutController(s *myradio.Session, c *structs.Config) *AboutController {
return &AboutController{Controller{session: s, config: c}}
}

// Get handles the HTTP GET request r for the about us page, writing to w.
func (aboutC *AboutController) Get(w http.ResponseWriter, r *http.Request) {
teamM := models.NewTeamModel(aboutC.session)
teams, err := teamM.GetAll()
if err != nil {
log.Println(err)
utils.RenderTemplate(w, aboutC.config.PageContext, nil, "404.tmpl")
return
}
data := struct {
Teams []myradio.Team
}{
Teams: teams,
}
err = utils.RenderTemplate(w, aboutC.config.PageContext, data, "about.tmpl")

Check failure on line 38 in controllers/about.go

View workflow job for this annotation

GitHub Actions / build

utils.RenderTemplate(w, aboutC.Controller.config.PageContext, data, "about.tmpl") used as value

Check failure on line 38 in controllers/about.go

View workflow job for this annotation

GitHub Actions / lint

utils.RenderTemplate(w, aboutC.config.PageContext, data, "about.tmpl") (no value) used as value (typecheck)
if err != nil {
log.Println(err)
return
}
}
12 changes: 9 additions & 3 deletions controllers/getinvolved.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package controllers
import (
"net/http"
"sort"
"strings"

"github.com/UniversityRadioYork/2016-site/models"
"github.com/UniversityRadioYork/2016-site/structs"
Expand All @@ -22,9 +21,16 @@ func (s CollegeSorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s CollegeSorter) Less(i, j int) bool {
if strings.Contains(s[i].CollegeName, "N/A") || strings.Contains(s[i].CollegeName, "Unknown") {
return true
for _, v := range []string{"Unknown", "N/A - non student"} {
if s[i].CollegeName == v {
return true
}

if s[j].CollegeName == v {
return false
}
}

return s[i].CollegeName < s[j].CollegeName
}

Expand Down
10 changes: 5 additions & 5 deletions controllers/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type IndexController struct {
type RenderData struct {
CurrentAndNext *myradio.CurrentAndNext
Banners []myradio.Banner
Teams []myradio.Team
Timeslots []myradio.Timeslot
Podcasts []myradio.Podcast
MsgBoxError bool
ShowOnAir bool
Expand All @@ -36,7 +36,7 @@ func (ic *IndexController) Get(w http.ResponseWriter, r *http.Request) {
// This is where any form params would be parsed
model := models.NewIndexModel(ic.session)

currentAndNext, banners, teams, podcasts, showOnAir, err := model.Get()
currentAndNext, banners, timeslots, podcasts, showOnAir, err := model.Get()

if err != nil {
ic.handleError(w, r, err, "IndexModel.Get")
Expand All @@ -46,7 +46,7 @@ func (ic *IndexController) Get(w http.ResponseWriter, r *http.Request) {
data := RenderData{
CurrentAndNext: currentAndNext,
Banners: banners,
Teams: teams,
Timeslots: timeslots,
Podcasts: podcasts,
ShowOnAir: showOnAir,
MsgBoxError: false,
Expand All @@ -64,7 +64,7 @@ func (ic *IndexController) Post(w http.ResponseWriter, r *http.Request) {
// Get all the data for the webpage
model := models.NewIndexModel(ic.session)

currentAndNext, banners, teams, podcasts, showOnAir, err := model.Get()
currentAndNext, banners, timeslots, podcasts, showOnAir, err := model.Get()

if err != nil {
ic.handleError(w, r, err, "IndexModel.Get")
Expand All @@ -74,7 +74,7 @@ func (ic *IndexController) Post(w http.ResponseWriter, r *http.Request) {
data := RenderData{
CurrentAndNext: currentAndNext,
Banners: banners,
Teams: teams,
Timeslots: timeslots,
Podcasts: podcasts,
ShowOnAir: showOnAir,
MsgBoxError: false,
Expand Down
5 changes: 5 additions & 0 deletions controllers/schedule_week.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,11 @@ func (sc *ScheduleWeekController) makeAndRenderWeek(w http.ResponseWriter, r *ht
return
}

if err != nil {
log.Println(err)
return
}

data := struct {
Schedule *models.WeekSchedule
PrevURL, CurrURL, NextURL *url.URL
Expand Down
2 changes: 1 addition & 1 deletion controllers/signup.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (gic *SignUpController) Post(w http.ResponseWriter, r *http.Request) {
} else {
// Ignore an added @york.ac.uk (since we assume it)
eduroam = strings.TrimSuffix(eduroam, "@york.ac.uk")
match, _ := regexp.MatchString("^[a-z]{1,6}[0-9]{1,6}$", eduroam)
match, _ := regexp.MatchString("^([a-z]|[A-Z]){1,6}[0-9]{1,6}$", eduroam)
if !match {
feedback = append(feedback, "The @york.ac.uk email you provided seems invalid")
}
Expand Down
5 changes: 0 additions & 5 deletions controllers/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ func NewStaticController(c *structs.Config) *StaticController {
return &StaticController{Controller{config: c}}
}

// GetAbout handles the HTTP GET request r for the About page, writing to w.
func (staticC *StaticController) GetAbout(w http.ResponseWriter, r *http.Request) {
utils.RenderTemplate(w, staticC.config.PageContext, nil, "about.tmpl")
}

// GetContact handles the HTTP GET request r for the Contact page, writing to w.
func (staticC *StaticController) GetContact(w http.ResponseWriter, r *http.Request) {
utils.RenderTemplate(w, staticC.config.PageContext, nil, "contact.tmpl")
Expand Down
16 changes: 0 additions & 16 deletions controllers/team.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,3 @@ func (teamC *TeamController) Get(w http.ResponseWriter, r *http.Request) {
}
utils.RenderTemplate(w, teamC.config.PageContext, data, "team.tmpl")
}

// GetAll handles the HTTP GET request r for the all teams page, writing to w.
func (teamC *TeamController) GetAll(w http.ResponseWriter, r *http.Request) {
teamM := models.NewTeamModel(teamC.session)
teams, err := teamM.GetAll()
if err != nil {
teamC.handleError(w, r, err, "TeamModel.GetAll")
return
}
data := struct {
Teams []myradio.Team
}{
Teams: teams,
}
utils.RenderTemplate(w, teamC.config.PageContext, data, "teams.tmpl")
}
2 changes: 1 addition & 1 deletion faqs.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

[[faqs]]
question = "How do I listen to URY?"
answer = "Grab the boombox from your parents’ attic and tune it to 1350AM or 88.3FM, go to our website: ury.org.uk/live, ask your smart speaker “play University Radio York”, or get the Radioplayer, TuneIn, or Apple Music app."
answer = "Grab the boombox from your parents’ attic and tune it to 88.3FM, go to our website: ury.org.uk/live, ask your smart speaker “play University Radio York”, or get the Radioplayer, TuneIn, or Apple Music app."

[[faqs]]
question = "Can I get a show?"
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem(system:
let
pkgs = import nixpkgs {
inherit system;
};
inherit (pkgs) lib;
in
{
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
sassc
gnumake
go
];
};
}
);
}
4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ require (
github.com/codegangsta/negroni v1.0.0
github.com/gedex/inflector v0.0.0-20170307190818-16278e9db813
github.com/gorilla/mux v1.8.0
github.com/grokify/html-strip-tags-go v0.0.1
github.com/microcosm-cc/bluemonday v1.0.15
github.com/stretchr/graceful v1.2.15
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d
golang.org/x/net v0.7.0
)
Loading

0 comments on commit 9653b62

Please sign in to comment.