-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add display showing a logo and a configurable message.
- Loading branch information
Showing
10 changed files
with
173 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
Copyright 2024 Team 254. All Rights Reserved. | ||
Author: [email protected] (Patrick Fairbank) | ||
*/ | ||
|
||
html { | ||
-webkit-user-select: none; | ||
-moz-user-select: none; | ||
overflow: hidden; | ||
height: 100%; | ||
} | ||
body { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
background-color: #000; | ||
font-family: "FuturaLTBold"; | ||
color: #fff; | ||
} | ||
#logo #logoImg { | ||
height: 35vw; | ||
} | ||
#message { | ||
margin-top: 5vw; | ||
font-size: 3.5vw; | ||
line-height: 4.5vw; | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Copyright 2024 Team 254. All Rights Reserved. | ||
// Author: [email protected] (Patrick Fairbank) | ||
// | ||
// Client-side logic for the logo display. | ||
|
||
var websocket; | ||
|
||
$(function() { | ||
// Read the configuration for this display from the URL query string. | ||
const urlParams = new URLSearchParams(window.location.search); | ||
const message = urlParams.get("message"); | ||
const messageDiv = $("#message"); | ||
messageDiv.text(message); | ||
messageDiv.toggle(message !== ""); | ||
|
||
// Set up the websocket back to the server. | ||
websocket = new CheesyWebsocket("/displays/logo/websocket", {}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{/* | ||
Copyright 2024 Team 254. All Rights Reserved. | ||
Author: [email protected] (Patrick Fairbank) | ||
|
||
Display to show a static logo and configurable message. | ||
*/}} | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Logo Display - {{.EventSettings.Name}} - Cheesy Arena </title> | ||
<link rel="shortcut icon" href="/static/img/favicon.ico"> | ||
<link rel="stylesheet" href="/static/css/lib/bootstrap.min.css" /> | ||
<link rel="stylesheet" href="/static/css/cheesy-arena.css" /> | ||
<link rel="stylesheet" href="/static/css/logo_display.css" /> | ||
</head> | ||
<body> | ||
<div id="logo"> | ||
<img id="logoImg" src="/static/img/alliance-station-logo.png" alt="logo" /> | ||
</div> | ||
<div id="message"></div> | ||
<script src="/static/js/lib/jquery.min.js"></script> | ||
<script src="/static/js/lib/jquery.json-2.4.min.js"></script> | ||
<script src="/static/js/lib/jquery.websocket-0.0.1.js"></script> | ||
<script src="/static/js/cheesy-websocket.js"></script> | ||
<script src="/static/js/match_timing.js"></script> | ||
<script src="/static/js/logo_display.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2024 Team 254. All Rights Reserved. | ||
// Author: [email protected] (Patrick Fairbank) | ||
// | ||
// Web routes for a display to show a static logo and configurable message. | ||
|
||
package web | ||
|
||
import ( | ||
"github.com/Team254/cheesy-arena/model" | ||
"github.com/Team254/cheesy-arena/websocket" | ||
"net/http" | ||
) | ||
|
||
// Renders the logo view. | ||
func (web *Web) logoDisplayHandler(w http.ResponseWriter, r *http.Request) { | ||
if !web.enforceDisplayConfiguration(w, r, map[string]string{"message": ""}) { | ||
return | ||
} | ||
|
||
template, err := web.parseFiles("templates/logo_display.html") | ||
if err != nil { | ||
handleWebErr(w, err) | ||
return | ||
} | ||
data := struct { | ||
*model.EventSettings | ||
}{web.arena.EventSettings} | ||
err = template.ExecuteTemplate(w, "logo_display.html", data) | ||
if err != nil { | ||
handleWebErr(w, err) | ||
return | ||
} | ||
} | ||
|
||
// The websocket endpoint for sending configuration commands to the display. | ||
func (web *Web) logoDisplayWebsocketHandler(w http.ResponseWriter, r *http.Request) { | ||
display, err := web.registerDisplay(r) | ||
if err != nil { | ||
handleWebErr(w, err) | ||
return | ||
} | ||
defer web.arena.MarkDisplayDisconnected(display.DisplayConfiguration.Id) | ||
|
||
ws, err := websocket.NewWebsocket(w, r) | ||
if err != nil { | ||
handleWebErr(w, err) | ||
return | ||
} | ||
defer ws.Close() | ||
|
||
// Subscribe the websocket to the notifiers whose messages will be passed on to the client. | ||
ws.HandleNotifiers(display.Notifier, web.arena.ReloadDisplaysNotifier) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2024 Team 254. All Rights Reserved. | ||
// Author: [email protected] (Patrick Fairbank) | ||
|
||
package web | ||
|
||
import ( | ||
"github.com/Team254/cheesy-arena/websocket" | ||
gorillawebsocket "github.com/gorilla/websocket" | ||
"github.com/stretchr/testify/assert" | ||
"testing" | ||
) | ||
|
||
func TestLogoDisplay(t *testing.T) { | ||
web := setupTestWeb(t) | ||
|
||
recorder := web.getHttpResponse("/displays/logo?displayId=1&message=") | ||
assert.Equal(t, 200, recorder.Code) | ||
assert.Contains(t, recorder.Body.String(), "Logo Display - Untitled Event - Cheesy Arena") | ||
} | ||
|
||
func TestLogoDisplayWebsocket(t *testing.T) { | ||
web := setupTestWeb(t) | ||
|
||
server, wsUrl := web.startTestServer() | ||
defer server.Close() | ||
conn, _, err := gorillawebsocket.DefaultDialer.Dial(wsUrl+"/displays/logo/websocket?displayId=123", nil) | ||
assert.Nil(t, err) | ||
defer conn.Close() | ||
ws := websocket.NewTestWebsocket(conn) | ||
|
||
// Should get a few status updates right after connection. | ||
readWebsocketType(t, ws, "displayConfiguration") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters