obs-status-service: add landing page at root endpoint( fixes issue #114) #124

Open
schrodinger wants to merge 1 commits from schrodinger/autogits:issue-114 into main
2 changed files with 102 additions and 2 deletions

View File

@@ -41,6 +41,7 @@ const (
AppName = "obs-status-service"
)
var obs *common.ObsClient
type RepoBuildCounters struct {
@@ -271,8 +272,7 @@ func main() {
res.WriteHeader(500)
return
}
res.WriteHeader(404)
res.Write([]byte("404 page not found\n"))
http.ServeFile(res, req, "static/index.html")
})
http.HandleFunc("GET /status/{Project}", func(res http.ResponseWriter, req *http.Request) {
mime := ParseMimeHeader(req)

View File

@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>openSUSE OBS Status Service</title>
<style>
body {
font-family: sans-serif;
max-width: 900px;
margin: auto;
padding: 20px;
}
input {
width: 100%;
margin: 6px 0;
padding: 6px;
}
button {
padding: 6px 12px;
margin-top: 8px;
}
pre {
background: #f5f5f5;
padding: 10px;
overflow-x: auto;
}
img {
margin-top: 10px;
}
</style>
</head>
<body>
<h1>OBS Status Service</h1>
<p>
This service reports build results from the openSUSE Build Service (OBS)
as easily embeddable SVG images. Repository build results are cached to
provide low-overhead access.
</p>
<h2>Usage</h2>
<p>Requests for individual build results:</p>
<pre>/status/obs:project/package/repo/arch</pre>
<p><em>package, repo and arch are optional.</em></p>
<p>Requests for project results:</p>
<pre>/status/obs:project</pre>
<p>
By default, SVG output is generated. JSON and XML output are available
by setting the <code>Accept</code> request header.
</p>
<h2>Generate Build Result Image</h2>
<label>Project (required)</label>
<input id="project" placeholder="devel:languages:python:Factory">
<label>Package (optional)</label>
<input id="package" placeholder="python313">
<label>Repo &amp; Arch (optional)</label>
<input id="repo" placeholder="openSUSE_Tumbleweed/x86_64">
<button onclick="generate()">Generate</button>
<h3>Link</h3>
<pre id="link"></pre>
<h3>Markdown</h3>
<pre id="markdown"></pre>
<h3>Preview</h3>
<img id="preview" alt="Build status preview">
<script>
function generate() {
const project = document.getElementById("project").value.trim();
const pkg = document.getElementById("package").value.trim();
const repo = document.getElementById("repo").value.trim();
if (!project) {
alert("Project is required");
return;
}
let url = "https://br.opensuse.org/status/" + project;
if (pkg) url += "/" + pkg;
if (repo) url += "/" + repo;
document.getElementById("link").textContent = url;
document.getElementById("markdown").textContent =
"![br](" + url + ")";
document.getElementById("preview").src = url;
}
</script>
</body>
</html>