diff --git a/gochan.example.json b/gochan.example.json index 5ac2af47..80c8960a 100644 --- a/gochan.example.json +++ b/gochan.example.json @@ -34,8 +34,11 @@ "SiteWebfolder": "/", "DomainRegex": "(https|http):\\/\\/(gochan\\.lunachan\\.net|gochan\\.org)\\/(.*)", - "Styles": ["pipes","efchan"], - "DefaultStyle": "pipes", + "Styles": [ + { "Name": "Pipes", "Filename": "pipes.css" }, + { "Name": "Burichan", "Filename": "burichan.css" } + ], + "DefaultStyle": "pipes.css", "AllowDuplicateImages": true, "AllowVideoUploads": true, diff --git a/html/javascript/gochan.js b/html/javascript/gochan.js index 9da23435..87e1aae6 100644 --- a/html/javascript/gochan.js +++ b/html/javascript/gochan.js @@ -399,7 +399,7 @@ $jq(document).ready(function() { topbar = $jq("div#topbar"); var settings_html = "
Style:
Pin top bar:
Enable post previews on hover

" diff --git a/src/manage.go b/src/manage.go index 1a31c53a..af9e0ac0 100644 --- a/src/manage.go +++ b/src/manage.go @@ -249,12 +249,13 @@ var manage_functions = map[string]ManageFunction{ config.SiteSlogan = request.PostFormValue("SiteSlogan") config.SiteHeaderURL = request.PostFormValue("SiteHeaderURL") config.SiteWebfolder = request.PostFormValue("SiteWebfolder") - Styles_arr := strings.Split(request.PostFormValue("Styles"), "\n") + // TODO: Change this to match the new Style type in gochan.json + /* Styles_arr := strings.Split(request.PostFormValue("Styles"), "\n") var Styles []string for _, style := range Styles_arr { Styles = append(Styles, strings.Trim(style, " \n\r")) } - config.Styles = Styles + config.Styles = Styles */ config.DefaultStyle = request.PostFormValue("DefaultStyle") config.AllowDuplicateImages = (request.PostFormValue("AllowDuplicateImages") == "on") config.AllowVideoUploads = (request.PostFormValue("AllowVideoUploads") == "on") diff --git a/src/types.go b/src/types.go index 8d6e8ad5..fbef8e55 100644 --- a/src/types.go +++ b/src/types.go @@ -350,6 +350,11 @@ type ErrorJSON struct { Message string `json:"error"` } +type Style struct { + Name string + Filename string +} + // GochanConfig stores crucial info and is read from/written to gochan.json type GochanConfig struct { ListenIP string @@ -385,8 +390,8 @@ type GochanConfig struct { SiteDomain string `description:"The server's domain (duh). Do not edit this unless you know what you are doing or BAD THINGS WILL HAPPEN!" default:"127.0.0.1" critical:"true"` DomainRegex string `description:"Regular expression used for incoming request validation. Do not edit this unless you know what you are doing or BAD THINGS WILL HAPPEN!" default:"(https|http):\\\\/\\\\/(gochan\\\\.lunachan\\.net|gochan\\\\.org)\\/(.*)" critical:"true"` - Styles []string `description:"List of styles (one per line) that should be accessed online at /<SiteWebFolder>/css/<Style>/"` - DefaultStyle string `description:"Style used by default (duh). This should appear in the list above or bad things might happen."` + Styles []Style `description:"List of styles (one per line) that should be accessed online at <SiteWebFolder>/css/<Style>/"` + DefaultStyle string `description:"Filename of the default Style. This should appear in the list above or bad things might happen."` AllowDuplicateImages bool `description:"Disabling this will cause gochan to reject a post if the image has already been uploaded for another post.
This may end up being removed or being made board-specific in the future." default:"checked"` AllowVideoUploads bool `description:"Allows users to upload .webm videos.
This may end up being removed or being made board-specific in the future."` @@ -438,7 +443,23 @@ func initConfig() { } if err = json.Unmarshal(jfile, &config); err != nil { - printf(0, "Error parsing \"gochan.json\": %s\n", err.Error()) + errStr := err.Error() + switch errStr { + case "json: cannot unmarshal string into Go struct field GochanConfig.Styles of type main.Style": + printf(0, `Error parsing gochan.json. config.Styles has been changed from a string array to an object. +Each Style in gochan.json must have a Name field that will appear in the style dropdowns and a Filename field. For example +{ + "Styles": [ + {"Name": "Pipes", "Filename": "pipes.css"}, + {"Name": "Burichan", "Filename": "burichan.css"} + ], +} +DefaultStyle must refer to a given Style's Filename field. If DefaultStyle does not appear in gochan.json, the first element in Styles will be used. +`) + default: + printf(0, "Error parsing \"gochan.json\": %s\n", err.Error()) + } + os.Exit(2) } @@ -578,7 +599,7 @@ func initConfig() { } if config.DefaultStyle == "" { - config.DefaultStyle = config.Styles[0] + config.DefaultStyle = config.Styles[0].Filename } if config.NewThreadDelay == 0 { diff --git a/templates/banpage.html b/templates/banpage.html index 50cf8da7..2b97f86f 100644 --- a/templates/banpage.html +++ b/templates/banpage.html @@ -4,9 +4,9 @@ Banned - + diff --git a/templates/front.html b/templates/front.html index 23587934..1dd096fb 100644 --- a/templates/front.html +++ b/templates/front.html @@ -6,14 +6,14 @@ {{.config.SiteName}} - + diff --git a/templates/img_header.html b/templates/img_header.html index d65702a7..986bae50 100644 --- a/templates/img_header.html +++ b/templates/img_header.html @@ -12,7 +12,7 @@ {{else}}/{{.board.Dir}}/ - {{.board.Title}}{{end}} - + diff --git a/templates/manage_header.html b/templates/manage_header.html index 9d6c4f47..e6e87614 100644 --- a/templates/manage_header.html +++ b/templates/manage_header.html @@ -1,9 +1,9 @@ Gochan Manage page - + diff --git a/templates/post_edit.html b/templates/post_edit.html index c9866906..c39831ab 100644 --- a/templates/post_edit.html +++ b/templates/post_edit.html @@ -6,14 +6,14 @@ Edit Post {{range $_, $style := .config.Styles}} - {{end}} + {{end}} @@ -31,7 +31,7 @@ - +
Name{{stringAppend .post.Name "#" .post.Tripcode}}
Email{{.post.Email}}
Subject
Subject
Message

diff --git a/templates/postbox.html b/templates/postbox.html index 3812554e..4864dffd 100644 --- a/templates/postbox.html +++ b/templates/postbox.html @@ -7,9 +7,10 @@ {{end}} - - - + + + +
Name
Email
Subject
Name
Email
Subject
Message
File
Password (for post/file deletion)