mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-24 08:46:24 -07:00
parent
178150e803
commit
a0966925cb
4 changed files with 240 additions and 64 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/gochan-org/gochan/pkg/config"
|
||||
"github.com/gochan-org/gochan/pkg/gclog"
|
||||
"github.com/gochan-org/gochan/pkg/gcutil"
|
||||
)
|
||||
|
||||
|
@ -891,18 +892,14 @@ func CreateDefaultBoardIfNoneExist() error {
|
|||
if err != nil && err != sql.ErrNoRows {
|
||||
return err
|
||||
}
|
||||
var board = Board{
|
||||
Dir: "test",
|
||||
Title: "Testing board",
|
||||
Subtitle: "Board for testing",
|
||||
Description: "Board for testing",
|
||||
Section: defaultSectionID}
|
||||
board.SetDefaults()
|
||||
err = CreateBoard(&board)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
board := Board{}
|
||||
board.SetDefaults("", "", "")
|
||||
board.Section = defaultSectionID
|
||||
if err = CreateBoard(&board); err != nil {
|
||||
gclog.Println(gclog.LFatal|gclog.LStdLog, err.Error())
|
||||
return err
|
||||
}
|
||||
return nil // CreateBoard(&board)
|
||||
return nil
|
||||
}
|
||||
|
||||
//CreateDefaultAdminIfNoStaff creates a new default admin account if no accounts exist
|
||||
|
|
|
@ -185,20 +185,40 @@ func (board *Board) PagePath(pageNum interface{}) string {
|
|||
return board.WebPath(page+".html", "boardPage")
|
||||
}
|
||||
|
||||
func (board *Board) SetDefaults() {
|
||||
func (board *Board) SetDefaults(title string, subtitle string, description string) {
|
||||
board.CurrentPage = 1
|
||||
board.NumPages = 15
|
||||
board.ListOrder = 0
|
||||
board.Dir = "test"
|
||||
board.Type = 0
|
||||
board.UploadType = 0
|
||||
if title == "" {
|
||||
board.Title = "Testing board"
|
||||
} else {
|
||||
board.Title = title
|
||||
}
|
||||
if subtitle == "" {
|
||||
board.Subtitle = "Board for testing stuff"
|
||||
} else {
|
||||
board.Subtitle = subtitle
|
||||
}
|
||||
if description == "" {
|
||||
board.Description = "/test/ board description"
|
||||
} else {
|
||||
board.Description = description
|
||||
}
|
||||
board.Section = 1
|
||||
board.MaxFilesize = 4096
|
||||
board.MaxPages = 11
|
||||
board.MaxFilesize = 10000
|
||||
board.MaxPages = 16
|
||||
board.DefaultStyle = config.GetBoardConfig("").DefaultStyle
|
||||
board.Locked = false
|
||||
board.CreatedOn = time.Now()
|
||||
board.Anonymous = "Anonymous"
|
||||
board.ForcedAnon = false
|
||||
board.MaxAge = 0
|
||||
board.AutosageAfter = 200
|
||||
board.NoImagesAfter = 0
|
||||
board.NoImagesAfter = 500
|
||||
board.MaxMessageLength = 8192
|
||||
board.EmbedsAllowed = true
|
||||
board.EmbedsAllowed = false
|
||||
board.RedirectToThread = false
|
||||
board.ShowID = false
|
||||
board.RequireFile = false
|
||||
|
@ -206,7 +226,12 @@ func (board *Board) SetDefaults() {
|
|||
board.EnableSpoileredImages = true
|
||||
board.EnableSpoileredThreads = true
|
||||
board.Worksafe = true
|
||||
board.ThreadsPerPage = 10
|
||||
board.Cooldowns = BoardCooldowns{
|
||||
NewThread: 30,
|
||||
Reply: 7,
|
||||
ImageReply: 7,
|
||||
}
|
||||
board.ThreadsPerPage = 20
|
||||
}
|
||||
|
||||
type BoardSection struct {
|
||||
|
|
|
@ -6,11 +6,9 @@ import (
|
|||
"fmt"
|
||||
"html"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/gochan-org/gochan/pkg/building"
|
||||
|
@ -70,7 +68,6 @@ type Action struct {
|
|||
Callback func(writer http.ResponseWriter, request *http.Request, wantsJSON bool) (output interface{}, err error) `json:"-"`
|
||||
}
|
||||
|
||||
// var actions = map[string]Action{
|
||||
var actions = []Action{
|
||||
{
|
||||
ID: "logout",
|
||||
|
@ -584,7 +581,26 @@ var actions = []Action{
|
|||
Title: "Boards",
|
||||
Permissions: AdminPerms,
|
||||
Callback: func(writer http.ResponseWriter, request *http.Request, wantsJSON bool) (output interface{}, err error) {
|
||||
var outputStr string
|
||||
pageBuffer := bytes.NewBufferString("")
|
||||
tmpBoard := gcsql.Board{}
|
||||
tmpBoard.SetDefaults("", "", "")
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ManageBoards,
|
||||
map[string]interface{}{
|
||||
"webroot": config.GetSystemCriticalConfig().WebRoot,
|
||||
"site_config": config.GetSiteConfig(),
|
||||
"sections": gcsql.AllSections,
|
||||
"boards": gcsql.AllBoards,
|
||||
"board_config": config.GetBoardConfig(""),
|
||||
"editing": true,
|
||||
"board": tmpBoard,
|
||||
}, pageBuffer, "text/html"); err != nil {
|
||||
gclog.Printf(gclog.LErrorLog|gclog.LStaffLog,
|
||||
"Error executing manage boards template: %q", err.Error())
|
||||
return "", err
|
||||
}
|
||||
|
||||
return pageBuffer.String(), nil
|
||||
/* var outputStr string
|
||||
do := request.FormValue("do")
|
||||
var done bool
|
||||
board := new(gcsql.Board)
|
||||
|
@ -744,21 +760,9 @@ var actions = []Action{
|
|||
manageBoardsBuffer := bytes.NewBufferString("")
|
||||
gcsql.AllSections, _ = gcsql.GetAllSectionsOrCreateDefault()
|
||||
|
||||
boardConfig := config.GetBoardConfig("")
|
||||
|
||||
if err = serverutil.MinifyTemplate(gctemplates.ManageStaff,
|
||||
map[string]interface{}{
|
||||
"boardConfig": boardConfig,
|
||||
"board": board,
|
||||
"section_arr": gcsql.AllSections,
|
||||
},
|
||||
manageBoardsBuffer, "text/html"); err != nil {
|
||||
return "", errors.New(gclog.Print(gclog.LErrorLog,
|
||||
"Error executing board management page template: ", err.Error()))
|
||||
}
|
||||
return outputStr + manageBoardsBuffer.String(), nil
|
||||
}
|
||||
gcsql.ResetBoardSectionArrays()
|
||||
gcsql.ResetBoardSectionArrays() */
|
||||
return
|
||||
}},
|
||||
{
|
||||
|
|
|
@ -1,30 +1,180 @@
|
|||
<form action="/manage?action=boards" method="POST">
|
||||
<input type="hidden" name="do" value="add" />
|
||||
<table id="board-options">
|
||||
<tr><th class="option-column">Option</th><th class="value-column">Value</th></tr>
|
||||
<tr><td>Directory</td><td><input type="text" name="dir" value="" /></td></tr>
|
||||
<tr><td>Section</td><td><select name="section">{{range $_, $section := .section_arr}}
|
||||
<option value="{{$section.ID}}">{{$section.Name}}</option>{{end}}
|
||||
</select></td></tr>
|
||||
<tr><td>Order</td><td><input type="text" name="order" value="0" /></td></tr>
|
||||
<tr><td>Title</td><td><input type="text" name="title" value="{{$.board.Title}}" /></td></tr>
|
||||
<tr><td>Subtitle</td><td><input type="text" name="subtitle" value="{{$.board.Subtitle}}" /></td></tr>
|
||||
<tr><td>Description</td><td><input type="text" name="description" value="{{$.board.Description}}" /></td></tr>
|
||||
<tr><td>Max image size</td><td><input type="text" name="maximagesize" value="{{$.board.MaxFilesize}}" /></td></tr>
|
||||
<tr><td>Max pages</td><td><input type="text" name="maxpages" value="{{$.board.MaxPages}}" /></td></tr>
|
||||
<tr><td>Default style</td><td><select name="defaultstyle">{{range $_, $style := $.boardConfig.Styles}}
|
||||
<option value="{{$style.Filename}}">{{$style.Name}} ({{$style.Filename}})</option>{{end}}
|
||||
</select></td></tr>
|
||||
<tr><td>Locked</td><td><input type="checkbox" name="locked" {{if $.board.Locked}}checked{{end}}/></td></tr>
|
||||
<tr><td>Forced anonymity</td><td><input type="checkbox" name="forcedanon" {{if .board.ForcedAnon}}checked{{end}}/></td></tr>
|
||||
<tr><td>Anonymous name</td><td><input type="text" name="anonymous" value="{{.board.Anonymous}}" /></td></tr>
|
||||
<tr><td>Max age</td><td><input type="text" name="maxage" value="{{.board.MaxAge}}"/></td></tr>
|
||||
<tr><td>Bump limit<sup title="After this many posts, the thread will stop being bumped when a new post is made. ">[?]</sup></td><td><input type="text" name="autosageafter" value="{{.board.AutosageAfter}}"/></td></tr>
|
||||
<tr><td>No images after</td><td><input type="text" name="noimagesafter" value="{{.board.NoImagesAfter}}"/></td></tr>
|
||||
<tr><td>Max message length</td><td><input type="text" name="maxmessagelength" value="{{.board.MaxMessageLength}}"/></td></tr>
|
||||
<tr><td>Embeds allowed</td><td><input type="checkbox" name="embedsallowed" {{if .board.EmbedsAllowed}}checked{{end}}/></td></tr>
|
||||
<tr><td>Redirect to thread<sup title="If checked, posts will redirect to the thread by default without requiring 'noko' in the email">[?]</sup></td><td><input type="checkbox" name="redirecttothread" {{if .board.RedirectToThread}}checked{{end}}/></td></tr>
|
||||
<tr><td>Require an uploaded file</td><td><input type="checkbox" name="require_file" {{if .board.RequireFile}}checked{{end}}/></td></tr>
|
||||
<tr><td>Enable catalog</td><td><input type="checkbox" name="enablecatalog" {{if .board.EnableCatalog}}checked{{end}}/></td></tr>
|
||||
<h2>Manage Boards</h2>
|
||||
<form action="{{$.webroot}}manage?action=boards" method="GET">
|
||||
<input type="hidden" name="action" value="boards">
|
||||
<input type="hidden" name="do" value="select">
|
||||
{{with $.boards}}{{else}}
|
||||
<input type="hidden" name="noboards" value="1">
|
||||
{{end}}
|
||||
{{/* <input type="hidden" name="confirm" value="1"> */}}
|
||||
<select name="board" id="modifyboard">
|
||||
{{range $_, $board := $.boards}}
|
||||
<option value="{{$board.Dir}}">/{{$board.Dir}}/ - {{$board.Title}}</option>
|
||||
{{else}}
|
||||
<option value="" selected="true" disabled="disabled">No boards</option>
|
||||
{{end}}
|
||||
</select><br>
|
||||
<input type="submit" name="editsubmit" value="Edit" >
|
||||
<input type="submit" name="delsubmit" value="Delete" onclick="return confirm('Are you sure you want to delete this board? This cannot be undone.');"><br>
|
||||
</form>
|
||||
<hr />
|
||||
{{if $.editing}}
|
||||
<h2>Edit board</h2>
|
||||
{{else}}
|
||||
<h2>Create new board</h2>
|
||||
{{end}}
|
||||
<form action="{{$.webroot}}manage?action=boards" method="GET">
|
||||
<input type="hidden" name="action" value="boards">
|
||||
{{if $.editing}}
|
||||
<input type="hidden" name="do" value="edit">
|
||||
{{else}}
|
||||
<input type="hidden" name="do" value="create">
|
||||
{{end}}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>Option</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
{{/* <tr>
|
||||
<td>List order</td>
|
||||
<td><input type="number" min="0" name="listorder"></td>
|
||||
</tr>*/}}
|
||||
<tr>
|
||||
<td>Directory</td>
|
||||
<td><input type="text" name="dir" {{if $.editing}}disabled="disabled"{{end}} value="{{$.board.Dir}}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Title</td>
|
||||
<td><input type="text" name="title" value="{{$.board.Title}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Subtitle</td>
|
||||
<td><input type="text" name="subtitle" value="{{$.board.Subtitle}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Description</td>
|
||||
<td><input type="text" name="description" value="{{$.board.Description}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Type</td>
|
||||
<td><input type="number" min="0" name="boardtype" value="{{$.board.Type}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Upload type</td>
|
||||
<td><input type="number" min="0" name="uploadtype" value="{{$.board.UploadType}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Section</td>
|
||||
<td><select name="section">
|
||||
{{- range $_, $section := $.sections -}}
|
||||
<option value="{{$section.ID}}">{{$section.Name}}</option>
|
||||
{{- end -}}
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max filesize</td>
|
||||
<td><input type="number" min="0" name="maxfilesize" value="{{$.board.MaxFilesize}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max number of pages</td>
|
||||
<td><input type="number" min="0" name="numpages" value="{{$.board.MaxPages}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Default style</td>
|
||||
<td><select name="defaultstyle">
|
||||
{{range $_, $style := $.board_config.Styles}}
|
||||
<option value="{{$style.Filename}}" {{if eq $style.Filename $.board.DefaultStyle -}}
|
||||
selected="selected"
|
||||
{{- end}}>{{$style.Name}}</option>
|
||||
{{- end -}}
|
||||
</select></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Locked board</td>
|
||||
<td><input type="checkbox" name="locked" {{if $.board.Locked}}checked="checked"{{end}}/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Anonymous name</td>
|
||||
<td><input type="text" name="anonname" value="{{$.board.Anonymous}}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Forced anonymous</td>
|
||||
<td><input type="checkbox" name="locked" {{- if $.board.ForcedAnon}}checked="checked"{{end}}/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max age</td>
|
||||
<td><input type="number" min="0" name="maxage" value="{{$.board.MaxAge}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Autosage after # replies</td>
|
||||
<td><input type="number" min="0" name="autosageafter" value="{{$.board.AutosageAfter}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Don't allow uploads after # replies</td>
|
||||
<td><input type="number" min="0" name="noimagesafter" value="{{$.board.NoImagesAfter}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Max message length (in characters)</td>
|
||||
<td><input type="number" min="0" name="maxmessagelength" value="{{$.board.MaxMessageLength}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Embeds allowed</td>
|
||||
<td><input type="checkbox" name="embedsallowed" {{if $.board.EmbedsAllowed}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Redirect to thread by default</td>
|
||||
<td><input type="checkbox" name="redirecttothread" {{if $.board.RedirectToThread}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Show user ID tag</td>
|
||||
<td><input type="checkbox" name="showid" {{if $.board.ShowID}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Require file in OP</td>
|
||||
<td><input type="checkbox" name="requirefile" {{if $.board.RequireFile}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Create catalog</td>
|
||||
<td><input type="checkbox" name="enablecatalog" {{if $.board.EnableCatalog}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Allow file spoilers</td>
|
||||
<td><input type="checkbox" name="enablespoileredimages" {{if $.board.EnableSpoileredImages}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Enable spoilered threads</td>
|
||||
<td><input type="checkbox" name="enablespoileredthreads" {{if $.board.ForcedAnon}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Worksafe board (no NSFW threads)</td>
|
||||
<td><input type="checkbox" name="worksafe" {{if $.board.Worksafe}}checked="checked"{{end}}/>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>New thread cooldown</td>
|
||||
<td><input type="number" min="0" name="threadcooldown" value="{{$.board.Cooldowns.NewThread}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Reply cooldown</td>
|
||||
<td><input type="number" min="0" name="replycooldown" value="{{$.board.Cooldowns.Reply}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image reply cooldown</td>
|
||||
<td><input type="number" min="0" name="imagecooldown" value="{{$.board.Cooldowns.ImageReply}}"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Threads per page</td>
|
||||
<td><input type="number" min="0" name="threadsperpage" value="{{$.board.ThreadsPerPage}}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<input type="submit" /></form>
|
||||
<input type="submit" name="submitchanges" value="
|
||||
{{- if $.editing}}Save changes{{else}}Create new board
|
||||
{{- end}}" onclick="return confirm('Click ok to confirm')"/></form>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue