Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
KSZK
Schönherz Mátrix
games
Aggregator Backend
Commits
d4bc9a0e
Commit
d4bc9a0e
authored
Oct 03, 2021
by
Miklós Tóth
🤷
Browse files
Add list of teams
parent
6fd8cdcf
Pipeline
#8886
passed with stages
in 1 minute and 13 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
web/out.go
View file @
d4bc9a0e
package
web
import
(
"git.sch.bme.hu/kszk/schmatrix/games/aggregator-backend/db"
"git.sch.bme.hu/kszk/schmatrix/games/aggregator-backend/logic"
"github.com/gin-gonic/gin"
"net/http"
...
...
@@ -37,3 +38,21 @@ func startHandler(c *gin.Context) {
}
broadcast
(
true
)
}
func
teamHandler
(
c
*
gin
.
Context
)
{
teams
,
e
:=
db
.
GetTeams
(
c
)
if
e
!=
nil
{
c
.
String
(
500
,
"%s"
,
e
.
Error
())
return
}
c
.
JSON
(
200
,
teams
)
}
func
humanTeams
(
c
*
gin
.
Context
)
{
teams
,
e
:=
db
.
GetTeams
(
c
)
if
e
!=
nil
{
c
.
String
(
500
,
"%s"
,
e
.
Error
())
return
}
c
.
HTML
(
200
,
"teams.html"
,
teams
)
}
web/router.go
View file @
d4bc9a0e
...
...
@@ -21,7 +21,10 @@ func init() {
Router
.
GET
(
sockPrefix
,
gin
.
WrapH
(
sock
))
Router
.
NoRoute
(
gin
.
WrapH
(
http
.
FileServer
(
http
.
Dir
(
"static"
))))
AdminRouter
.
SetHTMLTemplate
(
html
)
AdminRouter
.
GET
(
"/data"
,
sumHandler
)
AdminRouter
.
POST
(
"/stop"
,
stopHandler
)
AdminRouter
.
POST
(
"/start"
,
startHandler
)
AdminRouter
.
GET
(
"/teams"
,
teamHandler
)
AdminRouter
.
GET
(
"/teams/human"
,
humanTeams
)
}
web/teams.html
0 → 100644
View file @
d4bc9a0e
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Matrix team links
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU"
crossorigin=
"anonymous"
>
</head>
<body>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
Csapat
</th>
<th
scope=
"col"
>
Link
</th>
</tr>
</thead>
<tbody>
{{ range $k, $v := . }}
<tr>
<th
scope=
"row"
>
{{ $v }}
</th>
<td>
<a
href=
"https://ablak.sch.bme.hu/#/{{ $k }}"
>
https://ablak.sch.bme.hu/#/{{ $k }}
</a>
</td>
</tr>
{{ end }}
</tbody>
</table>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-/bQdsTh/da6pkI1MST/rWKFNjaCP5gBSY4sEBT38Q/9RBh9AH40zEOg7Hlq2THRZ"
crossorigin=
"anonymous"
></script>
</body>
</html>
\ No newline at end of file
web/template.go
0 → 100644
View file @
d4bc9a0e
package
web
import
(
_
"embed"
"html/template"
)
//go:embed teams.html
var
teamsHtml
string
var
html
=
template
.
Must
(
template
.
New
(
"teams.html"
)
.
Parse
(
teamsHtml
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment