mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-09-13 09:26:23 -07:00
Add manage page for viewing the main log (non-access)
This commit is contained in:
parent
1276b3524a
commit
7f07139430
5 changed files with 53 additions and 1 deletions
|
@ -39,4 +39,12 @@ input.config-text {
|
|||
.warning, div.config-status {
|
||||
color:red;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
textarea.viewlog {
|
||||
width: 80%;
|
||||
white-space: pre;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
|
@ -315,6 +315,14 @@ input.config-text {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
textarea.viewlog {
|
||||
width: 80%;
|
||||
white-space: pre;
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.lightbox {
|
||||
background: #CDCDCD;
|
||||
border: 1px solid #000;
|
||||
|
|
|
@ -33,6 +33,7 @@ var (
|
|||
ManageLogin *template.Template
|
||||
ManageReports *template.Template
|
||||
ManageStaff *template.Template
|
||||
ManageViewLog *template.Template
|
||||
MoveThreadPage *template.Template
|
||||
PageHeader *template.Template
|
||||
PageFooter *template.Template
|
||||
|
@ -229,6 +230,12 @@ func templateLoading(t string, buildAll bool) error {
|
|||
return templateError("manage_staff.html", err)
|
||||
}
|
||||
}
|
||||
if buildAll || t == "manageviewlog" {
|
||||
ManageViewLog, err = LoadTemplate("manage_viewlog.html")
|
||||
if err != nil {
|
||||
return templateError("manage_viewlog.html", err)
|
||||
}
|
||||
}
|
||||
if buildAll || t == "movethreadpage" {
|
||||
MoveThreadPage, err = LoadTemplate("movethreadpage.html", "page_header.html", "topbar.html", "page_footer.html")
|
||||
if err != nil {
|
||||
|
|
|
@ -5,8 +5,10 @@ import (
|
|||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
|
||||
"github.com/gochan-org/gochan/pkg/building"
|
||||
|
@ -628,6 +630,32 @@ func registerAdminPages() {
|
|||
}
|
||||
infoEv.Send()
|
||||
return managePageBuffer.String(), err
|
||||
}},
|
||||
},
|
||||
},
|
||||
Action{
|
||||
ID: "viewlog",
|
||||
Title: "View log",
|
||||
Permissions: AdminPerms,
|
||||
Callback: func(writer http.ResponseWriter, request *http.Request, staff *gcsql.Staff, wantsJSON bool, infoEv *zerolog.Event,
|
||||
errEv *zerolog.Event) (output interface{}, err error) {
|
||||
logPath := path.Join(config.GetSystemCriticalConfig().LogDir, "gochan.log")
|
||||
logFile, err := os.Open(logPath)
|
||||
if err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return "", errors.New("unable to open log file")
|
||||
}
|
||||
defer logFile.Close()
|
||||
ba, err := io.ReadAll(logFile)
|
||||
if err != nil {
|
||||
errEv.Err(err).Caller().Send()
|
||||
return "", err
|
||||
}
|
||||
buf := bytes.NewBufferString("")
|
||||
err = serverutil.MinifyTemplate(gctemplates.ManageViewLog, map[string]interface{}{
|
||||
"logText": string(ba),
|
||||
}, buf, "text/html")
|
||||
return buf.String(), err
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
1
templates/manage_viewlog.html
Normal file
1
templates/manage_viewlog.html
Normal file
|
@ -0,0 +1 @@
|
|||
<textarea class="viewlog" rows="24">{{.logText}}</textarea>
|
Loading…
Add table
Add a link
Reference in a new issue