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 {
|
||||
@@ -105,6 +102,14 @@ func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||
s.DbMgr.Db.Save(m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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>
|
||||
@@ -31,7 +32,7 @@
|
||||
color: #FFFFFF;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
font-family: "Inter UI","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
|
||||
font-family: "Inter UI", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
height: 4rem;
|
||||
@@ -53,12 +54,13 @@
|
||||
.button-36 {
|
||||
padding: 0 2.6rem;
|
||||
}
|
||||
.button-delete{
|
||||
|
||||
.button-delete {
|
||||
padding: 0 2.6rem;
|
||||
}
|
||||
}
|
||||
|
||||
.button-delete{
|
||||
.button-delete {
|
||||
background-image: linear-gradient(92.88deg, #f44336 9.16%, #f44336 43.89%, #f44336 64.72%);
|
||||
border-radius: 8px;
|
||||
border-style: none;
|
||||
@@ -66,7 +68,7 @@
|
||||
color: #FFFFFF;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
font-family: "Inter UI","SF Pro Display",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif;
|
||||
font-family: "Inter UI", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
height: 4rem;
|
||||
@@ -84,18 +86,22 @@
|
||||
transition-duration: .1s;
|
||||
}
|
||||
|
||||
.table-left{
|
||||
.table-left {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.thumbnail{
|
||||
border: 1px solid #ddd; /* Gray border */
|
||||
border-radius: 4px; /* Rounded border */
|
||||
padding: 5px; /* Some padding */
|
||||
width: 150px; /* Set a small width */
|
||||
.thumbnail {
|
||||
border: 1px solid #ddd;
|
||||
/* Gray border */
|
||||
border-radius: 4px;
|
||||
/* Rounded border */
|
||||
padding: 5px;
|
||||
/* Some padding */
|
||||
width: 150px;
|
||||
/* Set a small width */
|
||||
}
|
||||
|
||||
.thumbnail:hover{
|
||||
.thumbnail:hover {
|
||||
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
|
||||
}
|
||||
|
||||
@@ -103,7 +109,7 @@
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
td{
|
||||
td {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -119,10 +125,10 @@
|
||||
margin-bottom: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body class="{{(index .Settings "theme").Value}}">
|
||||
|
||||
<body class="{{(index .Settings " theme").Value}}">
|
||||
<form method="post" action="/new/">
|
||||
<label>
|
||||
New Sub Url
|
||||
@@ -131,11 +137,17 @@
|
||||
<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">
|
||||
<option {{if eq (index .Settings "theme").Value "white"}} selected {{end}} value="white">White</option>
|
||||
<option {{if eq (index .Settings "theme").Value "dark"}} selected {{end}} value="dark">Dark</option>
|
||||
<option {{if eq (index .Settings "theme" ).Value "white" }} selected {{end}} value="white">White</option>
|
||||
<option {{if eq (index .Settings "theme" ).Value "dark" }} selected {{end}} value="dark">Dark</option>
|
||||
</select>
|
||||
<input type="hidden" name="setting" value="theme">
|
||||
</form>
|
||||
@@ -153,7 +165,7 @@
|
||||
<tr>
|
||||
<td>
|
||||
<a target="_blank" href="/img/{{.ThumbnailUrl}}">
|
||||
<img class="thumbnail" src="/img/{{.ThumbnailUrl}}" alt="img_{{.ThumbnailUrl}}"/>
|
||||
<img class="thumbnail" src="/img/{{.ThumbnailUrl}}" alt="img_{{.ThumbnailUrl}}" />
|
||||
</a>
|
||||
</td>
|
||||
<td class="table-left">{{.Title}}</td>
|
||||
@@ -176,4 +188,5 @@
|
||||
{{end}}
|
||||
</table>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user