/
frontend.go
89 lines (85 loc) · 3.4 KB
/
frontend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
//
// TheFederation Github Integration Server
// Copyright (C) 2018 Lukas Matt <lukas@zauberstuhl.de>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
package main
import (
"net/http"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/sqlite"
"fmt"
)
func frontend(w http.ResponseWriter, r *http.Request) {
db, err := gorm.Open(databaseDriver, databaseDSN)
if err != nil {
logger.Println(err)
fmt.Fprintf(w, "Database Error :(")
return
}
defer db.Close()
var repos Repos
err = db.Find(&repos).Error
if err != nil {
logger.Println(err)
fmt.Fprintf(w, "Database Query Error :(")
return
}
fmt.Fprintf(w, `<!DOCTYPE html>
<html>
<head>
<title>Federation Testsuite</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
</head>
<body>
<div class="container" role="main">
<h1>Federation Testsuite</h1>
<h2>How to add your project to the list</h2>
<p class="mb-0">Follow the <a href="https://github.com/thefederationinfo/federation-tests/blob/master/README.md">instructions</a> and add your own image to the repository.</p>
<p>Then register your project with the <a href="/auth">integration service</a>.</p>
<p><img class="img-thumbnail" src="/images/stats/builds.png" title="Builds" /></p>
<h3>Covered Projects</h3>
<p>Following projects are covered by our <a href="https://github.com/thefederationinfo/federation-tests">continuous integration tests</a>:</p>
<table class="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Slug</th>
<th scope="col">Project</th>
</tr>
</thead>
<tbody>`)
for i, repo := range repos {
fmt.Fprintf(w, `
<tr>
<th scope="row">%d</th>
<td>%s</td>
<td>
<a href="https://github.com/%s">Details</a>
</td>
</tr>`, i+1, repo.Slug, repo.Slug)
}
fmt.Fprintf(w, `
</tbody>
</table>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>
</html>`)
}