Add Update Button
This commit is contained in:
@@ -18,8 +18,12 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *Server) HandleUpdate(w http.ResponseWriter, r *http.Request){
|
||||
s.UpdateMangaList()
|
||||
http.Redirect(w, r, "/", http.StatusFound)
|
||||
}
|
||||
|
||||
func (s *Server) HandleLoginPost(w http.ResponseWriter, r *http.Request) {
|
||||
fmt.Println("Setting auth")
|
||||
secret := r.PostFormValue("secret")
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "auth",
|
||||
|
||||
@@ -67,6 +67,7 @@ func (s *Server) RegisterRoutes() {
|
||||
s.mux.HandleFunc("/favicon.ico", s.HandleFavicon)
|
||||
s.mux.HandleFunc("POST /setting/", s.HandleSetting)
|
||||
s.mux.HandleFunc("GET /setting/set/{setting}/{value}", s.HandleSettingSet)
|
||||
s.mux.HandleFunc("GET /update", s.HandleUpdate)
|
||||
}
|
||||
|
||||
func (s *Server) StartTLS(port int, certFile, keyFile string) error {
|
||||
@@ -89,11 +90,7 @@ func (s *Server) Start(port int) error {
|
||||
return server.ListenAndServe()
|
||||
}
|
||||
|
||||
func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||
go func(s *Server) {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(interval):
|
||||
func (s *Server) UpdateMangaList() {
|
||||
var all []*database.Manga
|
||||
s.DbMgr.Db.Find(&all)
|
||||
for _, m := range all {
|
||||
@@ -106,6 +103,14 @@ func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||
go func(s *Server) {
|
||||
for {
|
||||
select {
|
||||
case <-time.After(interval):
|
||||
s.UpdateMangaList()
|
||||
}
|
||||
}
|
||||
}(s)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<!DOCTYPE html>
|
||||
<!--suppress CssUnusedSymbol -->
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Main Menu</title>
|
||||
@@ -53,6 +54,7 @@
|
||||
.button-36 {
|
||||
padding: 0 2.6rem;
|
||||
}
|
||||
|
||||
.button-delete {
|
||||
padding: 0 2.6rem;
|
||||
}
|
||||
@@ -89,10 +91,14 @@
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
border: 1px solid #ddd; /* Gray border */
|
||||
border-radius: 4px; /* Rounded border */
|
||||
padding: 5px; /* Some padding */
|
||||
width: 150px; /* Set a small width */
|
||||
border: 1px solid #ddd;
|
||||
/* Gray border */
|
||||
border-radius: 4px;
|
||||
/* Rounded border */
|
||||
padding: 5px;
|
||||
/* Some padding */
|
||||
width: 150px;
|
||||
/* Set a small width */
|
||||
}
|
||||
|
||||
.thumbnail:hover {
|
||||
@@ -119,9 +125,9 @@
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body class="{{(index .Settings " theme").Value}}">
|
||||
<form method="post" action="/new/">
|
||||
<label>
|
||||
@@ -131,6 +137,12 @@
|
||||
<input type="submit" value="Open" class="button-36">
|
||||
</form>
|
||||
|
||||
<a href="/update">
|
||||
<button class="button-36">
|
||||
Update Chapters
|
||||
</button>
|
||||
</a>
|
||||
|
||||
<form method="post" action="/setting/">
|
||||
<label for="theme">Theme</label>
|
||||
<select onchange="this.form.submit()" id="theme" name="theme">
|
||||
@@ -176,4 +188,5 @@
|
||||
{{end}}
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user