mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-12-22 19:57:57 +00:00
new: Show version number
This commit is contained in:
parent
0227c5f783
commit
95a8263797
@ -63,7 +63,9 @@
|
||||
</div>
|
||||
|
||||
<div name="github-link">
|
||||
<a href="https://github.com/SinTan1729/chhoto-url" target="_blank" rel="noopener noreferrer">Source Code</a>
|
||||
<a id="version-number" href="https://github.com/SinTan1729/chhoto-url" target="_blank" rel="noopener noreferrer"
|
||||
hidden>Source Code</a>
|
||||
<!-- The version number would be inserted here -->
|
||||
</div>
|
||||
|
||||
<dialog id="login-dialog">
|
||||
|
@ -9,6 +9,12 @@ const getSiteUrl = async () => await fetch("/api/siteurl")
|
||||
}
|
||||
});
|
||||
|
||||
const getVersion = async () => await fetch("/api/version")
|
||||
.then(res => res.text())
|
||||
.then(text => {
|
||||
return text;
|
||||
});
|
||||
|
||||
const refreshData = async () => {
|
||||
let reply = await fetch("/api/all").then(res => res.text());
|
||||
if (reply == "logged_out") {
|
||||
@ -32,7 +38,14 @@ const refreshData = async () => {
|
||||
};
|
||||
|
||||
const displayData = async (data) => {
|
||||
let version = await getVersion();
|
||||
link = document.getElementById("version-number")
|
||||
link.innerText = "v" + version;
|
||||
link.href = "https://github.com/SinTan1729/chhoto-url/releases/tag/" + version;
|
||||
link.hidden = false;
|
||||
|
||||
let site = await getSiteUrl();
|
||||
|
||||
table_box = document.querySelector(".pure-table");
|
||||
loading_text = document.getElementsByName("loading-text")[0];
|
||||
|
||||
|
@ -19,6 +19,9 @@ struct AppState {
|
||||
db: Connection,
|
||||
}
|
||||
|
||||
// Store the version number
|
||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
|
||||
// Define the routes
|
||||
|
||||
// Add new links
|
||||
@ -57,6 +60,12 @@ async fn siteurl(session: Session) -> HttpResponse {
|
||||
}
|
||||
}
|
||||
|
||||
// Get the version number
|
||||
#[get("/api/version")]
|
||||
async fn version() -> HttpResponse {
|
||||
HttpResponse::Ok().body(VERSION)
|
||||
}
|
||||
|
||||
// 404 error page
|
||||
async fn error404() -> impl Responder {
|
||||
NamedFile::open_async("./resources/static/404.html")
|
||||
@ -141,6 +150,7 @@ async fn main() -> std::io::Result<()> {
|
||||
.service(link_handler)
|
||||
.service(getall)
|
||||
.service(siteurl)
|
||||
.service(version)
|
||||
.service(add_link)
|
||||
.service(delete_link)
|
||||
.service(login)
|
||||
|
Loading…
Reference in New Issue
Block a user