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,22 +90,26 @@ func (s *Server) Start(port int) error {
|
|||||||
return server.ListenAndServe()
|
return server.ListenAndServe()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Server) UpdateMangaList() {
|
||||||
|
var all []*database.Manga
|
||||||
|
s.DbMgr.Db.Find(&all)
|
||||||
|
for _, m := range all {
|
||||||
|
err, updated := s.UpdateLatestAvailableChapter(m)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
if updated {
|
||||||
|
s.DbMgr.Db.Save(m)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Server) RegisterUpdater(interval time.Duration) {
|
func (s *Server) RegisterUpdater(interval time.Duration) {
|
||||||
go func(s *Server) {
|
go func(s *Server) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-time.After(interval):
|
case <-time.After(interval):
|
||||||
var all []*database.Manga
|
s.UpdateMangaList()
|
||||||
s.DbMgr.Db.Find(&all)
|
|
||||||
for _, m := range all {
|
|
||||||
err, updated := s.UpdateLatestAvailableChapter(m)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println(err)
|
|
||||||
}
|
|
||||||
if updated {
|
|
||||||
s.DbMgr.Db.Save(m)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(s)
|
}(s)
|
||||||
|
|||||||
@@ -1,179 +1,192 @@
|
|||||||
<!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>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
padding: 25px;
|
padding: 25px;
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
font-size: 25px;
|
font-size: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark {
|
.dark {
|
||||||
background-color: #171717;
|
background-color: #171717;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.white {
|
.white {
|
||||||
background-color: white;
|
background-color: white;
|
||||||
color: black;
|
color: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-36 {
|
.button-36 {
|
||||||
background-image: linear-gradient(92.88deg, #455EB5 9.16%, #5643CC 43.89%, #673FD7 64.72%);
|
background-image: linear-gradient(92.88deg, #455EB5 9.16%, #5643CC 43.89%, #673FD7 64.72%);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border-style: none;
|
border-style: none;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
color: #FFFFFF;
|
color: #FFFFFF;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
flex-shrink: 0;
|
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-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
height: 4rem;
|
height: 4rem;
|
||||||
padding: 0 1.6rem;
|
padding: 0 1.6rem;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px;
|
text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px;
|
||||||
transition: all .5s;
|
transition: all .5s;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
-webkit-user-select: none;
|
-webkit-user-select: none;
|
||||||
touch-action: manipulation;
|
touch-action: manipulation;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button-36:hover {
|
.button-36:hover {
|
||||||
box-shadow: rgba(80, 63, 205, 0.5) 0 1px 30px;
|
box-shadow: rgba(80, 63, 205, 0.5) 0 1px 30px;
|
||||||
transition-duration: .1s;
|
transition-duration: .1s;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 768px) {
|
@media (min-width: 768px) {
|
||||||
.button-36 {
|
.button-36 {
|
||||||
padding: 0 2.6rem;
|
padding: 0 2.6rem;
|
||||||
}
|
}
|
||||||
.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%);
|
padding: 0 2.6rem;
|
||||||
border-radius: 8px;
|
}
|
||||||
border-style: none;
|
}
|
||||||
box-sizing: border-box;
|
|
||||||
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-size: 16px;
|
|
||||||
font-weight: 500;
|
|
||||||
height: 4rem;
|
|
||||||
padding: 0 1.6rem;
|
|
||||||
text-align: center;
|
|
||||||
text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px;
|
|
||||||
transition: all .5s;
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
touch-action: manipulation;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-delete:hover {
|
.button-delete {
|
||||||
box-shadow: rgba(244, 67, 54, 0.5) 0 1px 30px;
|
background-image: linear-gradient(92.88deg, #f44336 9.16%, #f44336 43.89%, #f44336 64.72%);
|
||||||
transition-duration: .1s;
|
border-radius: 8px;
|
||||||
}
|
border-style: none;
|
||||||
|
box-sizing: border-box;
|
||||||
|
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-size: 16px;
|
||||||
|
font-weight: 500;
|
||||||
|
height: 4rem;
|
||||||
|
padding: 0 1.6rem;
|
||||||
|
text-align: center;
|
||||||
|
text-shadow: rgba(0, 0, 0, 0.25) 0 3px 8px;
|
||||||
|
transition: all .5s;
|
||||||
|
user-select: none;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
touch-action: manipulation;
|
||||||
|
}
|
||||||
|
|
||||||
.table-left{
|
.button-delete:hover {
|
||||||
text-align: left;
|
box-shadow: rgba(244, 67, 54, 0.5) 0 1px 30px;
|
||||||
}
|
transition-duration: .1s;
|
||||||
|
}
|
||||||
|
|
||||||
.thumbnail{
|
.table-left {
|
||||||
border: 1px solid #ddd; /* Gray border */
|
text-align: left;
|
||||||
border-radius: 4px; /* Rounded border */
|
}
|
||||||
padding: 5px; /* Some padding */
|
|
||||||
width: 150px; /* Set a small width */
|
|
||||||
}
|
|
||||||
|
|
||||||
.thumbnail:hover{
|
.thumbnail {
|
||||||
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
|
border: 1px solid #ddd;
|
||||||
}
|
/* Gray border */
|
||||||
|
border-radius: 4px;
|
||||||
|
/* Rounded border */
|
||||||
|
padding: 5px;
|
||||||
|
/* Some padding */
|
||||||
|
width: 150px;
|
||||||
|
/* Set a small width */
|
||||||
|
}
|
||||||
|
|
||||||
.table {
|
.thumbnail:hover {
|
||||||
width: 100%;
|
box-shadow: 0 0 2px 1px rgba(0, 140, 186, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
td{
|
.table {
|
||||||
text-align: center;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
label {
|
td {
|
||||||
display: flex;
|
text-align: center;
|
||||||
align-content: center;
|
}
|
||||||
justify-content: center;
|
|
||||||
margin: 0 auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
select {
|
label {
|
||||||
width: 10em;
|
display: flex;
|
||||||
margin-bottom: 10px;
|
align-content: center;
|
||||||
margin-top: 10px;
|
justify-content: center;
|
||||||
}
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
select {
|
||||||
|
width: 10em;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body class="{{(index .Settings "theme").Value}}">
|
|
||||||
<form method="post" action="/new/">
|
|
||||||
<label>
|
|
||||||
New Sub Url
|
|
||||||
<input type="text" name="subUrl">
|
|
||||||
</label>
|
|
||||||
<input type="submit" value="Open" class="button-36">
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<form method="post" action="/setting/">
|
<body class="{{(index .Settings " theme").Value}}">
|
||||||
<label for="theme">Theme</label>
|
<form method="post" action="/new/">
|
||||||
<select onchange="this.form.submit()" id="theme" name="theme">
|
<label>
|
||||||
<option {{if eq (index .Settings "theme").Value "white"}} selected {{end}} value="white">White</option>
|
New Sub Url
|
||||||
<option {{if eq (index .Settings "theme").Value "dark"}} selected {{end}} value="dark">Dark</option>
|
<input type="text" name="subUrl">
|
||||||
</select>
|
</label>
|
||||||
<input type="hidden" name="setting" value="theme">
|
<input type="submit" value="Open" class="button-36">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<table class="table">
|
<a href="/update">
|
||||||
<tr>
|
<button class="button-36">
|
||||||
<th>Thumbnail</th>
|
Update Chapters
|
||||||
<th class="table-left"><a href="setting/set/order/title">Title</a></th>
|
</button>
|
||||||
<th><a href="setting/set/order/chapter">Current Chapter</a></th>
|
</a>
|
||||||
<th><a href="setting/set/order/last">Last Accessed</a></th>
|
|
||||||
<th>Link</th>
|
<form method="post" action="/setting/">
|
||||||
<th>Delete</th>
|
<label for="theme">Theme</label>
|
||||||
</tr>
|
<select onchange="this.form.submit()" id="theme" name="theme">
|
||||||
{{range .Mangas}}
|
<option {{if eq (index .Settings "theme" ).Value "white" }} selected {{end}} value="white">White</option>
|
||||||
<tr>
|
<option {{if eq (index .Settings "theme" ).Value "dark" }} selected {{end}} value="dark">Dark</option>
|
||||||
<td>
|
</select>
|
||||||
<a target="_blank" href="/img/{{.ThumbnailUrl}}">
|
<input type="hidden" name="setting" value="theme">
|
||||||
<img class="thumbnail" src="/img/{{.ThumbnailUrl}}" alt="img_{{.ThumbnailUrl}}"/>
|
</form>
|
||||||
</a>
|
|
||||||
</td>
|
<table class="table">
|
||||||
<td class="table-left">{{.Title}}</td>
|
<tr>
|
||||||
<td>{{.Number}} / {{.LastNumber}}</td>
|
<th>Thumbnail</th>
|
||||||
<td>{{.LastTime}}</td>
|
<th class="table-left"><a href="setting/set/order/title">Title</a></th>
|
||||||
<td>
|
<th><a href="setting/set/order/chapter">Current Chapter</a></th>
|
||||||
<a href="/new/{{.Url}}">
|
<th><a href="setting/set/order/last">Last Accessed</a></th>
|
||||||
<button class="button-36">
|
<th>Link</th>
|
||||||
To chapter
|
<th>Delete</th>
|
||||||
</button>
|
</tr>
|
||||||
</a>
|
{{range .Mangas}}
|
||||||
</td>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<form method="post" action="/delete">
|
<a target="_blank" href="/img/{{.ThumbnailUrl}}">
|
||||||
<input type="hidden" name="mangaId" value="{{.ID}}">
|
<img class="thumbnail" src="/img/{{.ThumbnailUrl}}" alt="img_{{.ThumbnailUrl}}" />
|
||||||
<input type="submit" class="button-delete" value="Delete">
|
</a>
|
||||||
</form>
|
</td>
|
||||||
</td>
|
<td class="table-left">{{.Title}}</td>
|
||||||
</tr>
|
<td>{{.Number}} / {{.LastNumber}}</td>
|
||||||
{{end}}
|
<td>{{.LastTime}}</td>
|
||||||
</table>
|
<td>
|
||||||
|
<a href="/new/{{.Url}}">
|
||||||
|
<button class="button-36">
|
||||||
|
To chapter
|
||||||
|
</button>
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<form method="post" action="/delete">
|
||||||
|
<input type="hidden" name="mangaId" value="{{.ID}}">
|
||||||
|
<input type="submit" class="button-delete" value="Delete">
|
||||||
|
</form>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{{end}}
|
||||||
|
</table>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
|
||||||
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user