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