mirror of
https://git.phreedom.club/localhost_frssoft/bloat.git
synced 2024-11-26 05:41:29 +00:00
Add setting for default format
This commit is contained in:
parent
ef41ff32e2
commit
fdd9b8fd2b
|
@ -7,6 +7,7 @@ type PostFormat struct {
|
||||||
|
|
||||||
type PostContext struct {
|
type PostContext struct {
|
||||||
DefaultVisibility string
|
DefaultVisibility string
|
||||||
|
DefaultFormat string
|
||||||
ReplyContext *ReplyContext
|
ReplyContext *ReplyContext
|
||||||
Formats []PostFormat
|
Formats []PostFormat
|
||||||
DarkMode bool
|
DarkMode bool
|
||||||
|
|
|
@ -2,6 +2,7 @@ package model
|
||||||
|
|
||||||
type Settings struct {
|
type Settings struct {
|
||||||
DefaultVisibility string `json:"default_visibility"`
|
DefaultVisibility string `json:"default_visibility"`
|
||||||
|
DefaultFormat string `json:"default_format"`
|
||||||
CopyScope bool `json:"copy_scope"`
|
CopyScope bool `json:"copy_scope"`
|
||||||
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
ThreadInNewTab bool `json:"thread_in_new_tab"`
|
||||||
HideAttachments bool `json:"hide_attachments"`
|
HideAttachments bool `json:"hide_attachments"`
|
||||||
|
@ -15,6 +16,7 @@ type Settings struct {
|
||||||
func NewSettings() *Settings {
|
func NewSettings() *Settings {
|
||||||
return &Settings{
|
return &Settings{
|
||||||
DefaultVisibility: "public",
|
DefaultVisibility: "public",
|
||||||
|
DefaultFormat: "",
|
||||||
CopyScope: true,
|
CopyScope: true,
|
||||||
ThreadInNewTab: false,
|
ThreadInNewTab: false,
|
||||||
HideAttachments: false,
|
HideAttachments: false,
|
||||||
|
|
|
@ -121,5 +121,6 @@ type SearchData struct {
|
||||||
|
|
||||||
type SettingsData struct {
|
type SettingsData struct {
|
||||||
*CommonData
|
*CommonData
|
||||||
Settings *model.Settings
|
Settings *model.Settings
|
||||||
|
PostFormats []model.PostFormat
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"mime/multipart"
|
|
||||||
"html/template"
|
"html/template"
|
||||||
|
"mime/multipart"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ func (svc *service) ServeNavPage(c *model.Client) (err error) {
|
||||||
|
|
||||||
postContext := model.PostContext{
|
postContext := model.PostContext{
|
||||||
DefaultVisibility: c.Session.Settings.DefaultVisibility,
|
DefaultVisibility: c.Session.Settings.DefaultVisibility,
|
||||||
|
DefaultFormat: c.Session.Settings.DefaultFormat,
|
||||||
Formats: svc.postFormats,
|
Formats: svc.postFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -326,6 +327,7 @@ func (svc *service) ServeThreadPage(c *model.Client, id string, reply bool) (err
|
||||||
|
|
||||||
postContext = model.PostContext{
|
postContext = model.PostContext{
|
||||||
DefaultVisibility: visibility,
|
DefaultVisibility: visibility,
|
||||||
|
DefaultFormat: c.Session.Settings.DefaultFormat,
|
||||||
Formats: svc.postFormats,
|
Formats: svc.postFormats,
|
||||||
ReplyContext: &model.ReplyContext{
|
ReplyContext: &model.ReplyContext{
|
||||||
InReplyToID: id,
|
InReplyToID: id,
|
||||||
|
@ -686,8 +688,9 @@ func (svc *service) ServeSearchPage(c *model.Client,
|
||||||
func (svc *service) ServeSettingsPage(c *model.Client) (err error) {
|
func (svc *service) ServeSettingsPage(c *model.Client) (err error) {
|
||||||
commonData := svc.getCommonData(c, "settings")
|
commonData := svc.getCommonData(c, "settings")
|
||||||
data := &renderer.SettingsData{
|
data := &renderer.SettingsData{
|
||||||
CommonData: commonData,
|
CommonData: commonData,
|
||||||
Settings: &c.Session.Settings,
|
Settings: &c.Session.Settings,
|
||||||
|
PostFormats: svc.postFormats,
|
||||||
}
|
}
|
||||||
|
|
||||||
rCtx := getRendererContext(c)
|
rCtx := getRendererContext(c)
|
||||||
|
|
|
@ -584,6 +584,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
||||||
settings := func(w http.ResponseWriter, req *http.Request) {
|
settings := func(w http.ResponseWriter, req *http.Request) {
|
||||||
c := newClient(w, req, req.FormValue("csrf_token"))
|
c := newClient(w, req, req.FormValue("csrf_token"))
|
||||||
visibility := req.FormValue("visibility")
|
visibility := req.FormValue("visibility")
|
||||||
|
format := req.FormValue("format")
|
||||||
copyScope := req.FormValue("copy_scope") == "true"
|
copyScope := req.FormValue("copy_scope") == "true"
|
||||||
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
threadInNewTab := req.FormValue("thread_in_new_tab") == "true"
|
||||||
hideAttachments := req.FormValue("hide_attachments") == "true"
|
hideAttachments := req.FormValue("hide_attachments") == "true"
|
||||||
|
@ -595,6 +596,7 @@ func NewHandler(s Service, staticDir string) http.Handler {
|
||||||
|
|
||||||
settings := &model.Settings{
|
settings := &model.Settings{
|
||||||
DefaultVisibility: visibility,
|
DefaultVisibility: visibility,
|
||||||
|
DefaultFormat: format,
|
||||||
CopyScope: copyScope,
|
CopyScope: copyScope,
|
||||||
ThreadInNewTab: threadInNewTab,
|
ThreadInNewTab: threadInNewTab,
|
||||||
HideAttachments: hideAttachments,
|
HideAttachments: hideAttachments,
|
||||||
|
|
|
@ -16,8 +16,11 @@
|
||||||
<div>
|
<div>
|
||||||
{{if gt (len .Formats) 0}}
|
{{if gt (len .Formats) 0}}
|
||||||
<span class="post-form-field">
|
<span class="post-form-field">
|
||||||
|
{{$defFormat := .DefaultFormat}}
|
||||||
<select id="post-format" name="format" accesskey="F" title="Format (F)">
|
<select id="post-format" name="format" accesskey="F" title="Format (F)">
|
||||||
{{range .Formats}} <option value="{{.Type}}">{{.Name}}</option> {{end}}
|
{{range .Formats}}
|
||||||
|
<option value="{{.Type}}" {{if eq $defFormat .Type}}selected{{end}}>{{.Name}}</option>
|
||||||
|
{{end}}
|
||||||
</select>
|
</select>
|
||||||
</span>
|
</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
|
|
||||||
<form id="settings-form" action="/settings" method="POST">
|
<form id="settings-form" action="/settings" method="POST">
|
||||||
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
<input type="hidden" name="csrf_token" value="{{$.Ctx.CSRFToken}}">
|
||||||
|
<div class="settings-form-field">
|
||||||
|
<label for="visibility"> Default format </label>
|
||||||
|
{{$defFormat := .Settings.DefaultFormat}}
|
||||||
|
<select id="post-format" name="format">
|
||||||
|
{{range .PostFormats}}
|
||||||
|
<option value="{{.Type}}" {{if eq $defFormat .Type}}selected{{end}}>{{.Name}}</option>
|
||||||
|
{{end}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
<div class="settings-form-field">
|
<div class="settings-form-field">
|
||||||
<label for="visibility"> Default scope </label>
|
<label for="visibility"> Default scope </label>
|
||||||
<select id="visibility" name="visibility">
|
<select id="visibility" name="visibility">
|
||||||
|
|
Loading…
Reference in a new issue