Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 83ed0b5

Browse files
committed
api: Add API changelog page
1 parent 847aef1 commit 83ed0b5

File tree

5 files changed

+128
-3
lines changed

5 files changed

+128
-3
lines changed

api/handlers.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,26 @@ func branchesHandler(w http.ResponseWriter, r *http.Request) {
6767
return
6868
}
6969

70+
// changeLogHandler handles requests for the Changelog (a html page)
71+
func changeLogHandler(w http.ResponseWriter, r *http.Request) {
72+
var pageData struct {
73+
ServerName string
74+
}
75+
76+
// Log the incoming request
77+
logReq(r, "-")
78+
79+
// Pass through some variables, useful for the generated docs
80+
pageData.ServerName = com.Conf.Web.ServerName
81+
82+
// Display our API documentation
83+
t := tmpl.Lookup("changelog")
84+
err := t.Execute(w, pageData)
85+
if err != nil {
86+
log.Printf("Error: %s", err)
87+
}
88+
}
89+
7090
// columnsHandler returns the list of columns in a table or view
7191
// This can be run from the command line using curl, like this:
7292
//

api/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func main() {
120120

121121
// Our pages
122122
http.Handle("/", gz.GzipHandler(handleWrapper(rootHandler)))
123+
http.Handle("/changelog", gz.GzipHandler(handleWrapper(changeLogHandler)))
124+
http.Handle("/changelog.html", gz.GzipHandler(handleWrapper(changeLogHandler)))
123125
http.Handle("/v1/branches", gz.GzipHandler(handleWrapper(branchesHandler)))
124126
http.Handle("/v1/columns", gz.GzipHandler(handleWrapper(columnsHandler)))
125127
http.Handle("/v1/commits", gz.GzipHandler(handleWrapper(commitsHandler)))

api/templates/changelog.html

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
[[ define "changelog" ]]
2+
<!doctype html>
3+
<html>
4+
<head>
5+
<meta charset="UTF-8">
6+
<title>DBHub.io API Changelog</title>
7+
<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
8+
</head>
9+
<body>
10+
<style>
11+
* {
12+
font-size: large;
13+
}
14+
.apiheading {
15+
font-size: large;
16+
font-weight: bold;
17+
}
18+
.heading {
19+
font-size: large;
20+
font-weight: bold;
21+
}
22+
.indent {
23+
margin: 5px;
24+
}
25+
.pad {
26+
padding-top: 10px;
27+
}
28+
.paramname {
29+
font-style: italic;
30+
}
31+
pre {
32+
margin-top: 5px;
33+
}
34+
.version {
35+
margin-bottom: 10px;
36+
font-family: monospace;
37+
font-style: italic;
38+
}
39+
</style>
40+
<div style="margin-left: 2%; margin-right: 2%; padding-left: 2%; padding-right: 2%;">
41+
<div class="row">
42+
<div class="col-md-12"><a href="https://dbhub.io"><h1>DBHub API Changelog</h1></a></div>
43+
</div>
44+
<div class="row">
45+
<div class="col-md-12 version">[[ template "version" . ]] (<a href="/" style="color: #333; font-weight: bold">API</a>)</div>
46+
</div>
47+
48+
<div class="panel panel-primary">
49+
<div class="panel-heading">Version 0.3 - Current release</div>
50+
<div class="panel-body" style="padding: 0">
51+
<div class="col-md-1" style="font-weight: bold; padding-top: 1%">2023-03-06</div>
52+
<div class="col-md-11">
53+
<ul class="list-group" style="padding-left: 1%; margin: 1%">
54+
<li class="list-group-item"><a href="/#execute" class="apiheading">Execute()</a> - The return data now includes the number of rows changed</li>
55+
</ul>
56+
</div>
57+
</div>
58+
</div>
59+
60+
<div class="panel panel-info">
61+
<div class="panel-heading">Version 0.2 - Adds initial support for live databases</div>
62+
<div class="panel-body" style="padding: 0">
63+
<div class="col-md-1" style="font-weight: bold; padding-top: 1%">2023-03-20</div>
64+
<div class="col-md-11">
65+
<ul class="list-group" style="padding-left: 1%; margin: 1%">
66+
<li class="list-group-item"><a href="/#databases" class="apiheading">Databases()</a> - Added the optional 'live' request parameter, to return the list of Live databases in the user account</li>
67+
<li class="list-group-item"><a href="/#execute" class="apiheading">Execute()</a> - New function, allows executing a SQL statement on a live database</li>
68+
<li class="list-group-item"><a href="/#upload" class="apiheading">Upload()</a> - Added the optional 'live' request parameter, to specify the upload is a live database rather than a standard database</li>
69+
</ul>
70+
</div>
71+
</div>
72+
</div>
73+
74+
<div class="panel panel-info">
75+
<div class="panel-heading">Version 0.1 - First release</div>
76+
<div class="panel-body" style="padding: 0">
77+
<div class="col-md-1" style="font-weight: bold; padding-top: 1%">2020-08-14</div>
78+
<div class="col-md-11">
79+
<ul class="list-group" style="padding-left: 1%; margin: 1%">
80+
<li class="list-group-item">Only supports standard databases</li>
81+
</ul>
82+
</div>
83+
</div>
84+
</div>
85+
86+
</div>
87+
<script>
88+
(function(f, a, t, h, o, m){
89+
a[h]=a[h]||function(){
90+
(a[h].q=a[h].q||[]).push(arguments)
91+
};
92+
o=f.createElement('script'),
93+
m=f.getElementsByTagName('script')[0];
94+
o.async=1; o.src=t; o.id='fathom-script';
95+
m.parentNode.insertBefore(o,m)
96+
})(document, window, '//stats.sqlitebrowser.org/tracker.js', 'fathom');
97+
fathom('set', 'siteId', 'XTAOE');
98+
fathom('trackPageview');
99+
</script>
100+
</body>
101+
</html>
102+
[[ end ]]

api/templates/root.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@
5555
</style>
5656
<div style="margin-left: 2%; margin-right: 2%; padding-left: 2%; padding-right: 2%;">
5757
<div class="row">
58-
<div class="col-md-12"><a href="https://dbhub.io"><h1>DBHub API (in early development)</h1></a></div>
58+
<div class="col-md-12"><a href="https://dbhub.io"><h1>DBHub API</h1></a></div>
5959
</div>
6060
<div class="row">
61-
<div class="col-md-12 version">API version 0.3, last modified 2023-03-26</div>
61+
<div class="col-md-12 version">[[ template "version" . ]] (<a href="/changelog.html" style="color: #333; font-weight: bold">Changelog</a>)</div>
6262
</div>
6363
<div class="panel panel-primary" id="note">
6464
<div class="panel-heading heading">Note</div>
@@ -864,7 +864,7 @@
864864
<div class="row indent" style="color: #a01e1a">
865865
<div class="col-md-4 paramname">rows_changed</div>
866866
<div class="col-md-1 type">integer</div>
867-
<div class="col-md-7"><div style="font-style: italic; font-weight: bold">NEW in API version 0.3</div><div>Contain the number of rows changed by the Execute() call</div></div>
867+
<div class="col-md-7"><div style="font-style: italic; font-weight: bold">NEW in API version 0.3</div><div>Contains the number of rows changed by the Execute() call</div></div>
868868
</div>
869869
<div class="row indent">
870870
<div class="col-md-4 paramname">status</div>

api/templates/version.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[[ define "version" ]]API version 0.3, last modified 2023-03-26[[ end ]]

0 commit comments

Comments
 (0)