diff --git a/main.go b/main.go
index 296efdd0..c6513946 100644
--- a/main.go
+++ b/main.go
@@ -32,7 +32,6 @@ var startTime time.Time
//var timeLocation *time.Location
var templates = template.New("")
//var no_css_tmpl template.CSS = template.CSS("")
-var settings map[string]interface{} = make(map[string]interface{})
var external_sites map[string]string = map[string]string{
"YT":"https://www.youtube.com/",
}
@@ -340,6 +339,28 @@ func main(){
log.Print("Initialising the authentication system")
auth = NewDefaultAuth()
+ // Run this goroutine once a second
+ second_ticker := time.NewTicker(1 * time.Second)
+ fifteen_minute_ticker := time.NewTicker(15 * time.Minute)
+ //hour_ticker := time.NewTicker(1 * time.Hour)
+ go func() {
+ for {
+ select {
+ case <- second_ticker.C:
+ // TO-DO: Handle delayed moderation tasks
+ // TO-DO: Handle the daily clean-up. Move this to a 24 hour task?
+ // TO-DO: Sync with the database, if there are any changes
+ // TO-DO: Manage the TopicStore, UserStore, and ForumStore
+ // TO-DO: Alert the admin, if CPU usage, RAM usage, or the number of posts in the past second are too high
+ // TO-DO: Clean-up alerts with no unread matches which are over two weeks old. Move this to a 24 hour task?
+ case <- fifteen_minute_ticker.C:
+ // TO-DO: Handle temporary bans.
+ // TO-DO: Automatically lock topics, if they're really old, and the associated setting is enabled.
+ // TO-DO: Publish scheduled posts. Move this to a 15 minute task?
+ }
+ }
+ }()
+
log.Print("Initialising the router")
router = NewGenRouter(http.FileServer(http.Dir("./uploads")))
///router.HandleFunc("/static/", route_static)
diff --git a/pages.go b/pages.go
index 2ce132b2..6d5b0bde 100644
--- a/pages.go
+++ b/pages.go
@@ -15,9 +15,17 @@ type HeaderVars struct
Stylesheets []string
Widgets PageWidgets
Site *Site
+ Settings map[string]interface{}
ExtData ExtData
}
+// TO-DO: Add this to routes which don't use templates. E.g. Json APIs.
+type HeaderLite struct
+{
+ Site *Site
+ Settings SettingBox
+}
+
type PageWidgets struct
{
LeftSidebar template.HTML
diff --git a/panel_routes.go b/panel_routes.go
index bbcc4083..47791405 100644
--- a/panel_routes.go
+++ b/panel_routes.go
@@ -219,7 +219,7 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request, user User){
}
func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request, user User){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -298,7 +298,7 @@ func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, user User
}
func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -380,7 +380,7 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, user User,
}
func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user User, sfid string) {
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -466,7 +466,7 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, user
}
func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sfid string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -557,6 +557,7 @@ func route_panel_settings(w http.ResponseWriter, r *http.Request, user User){
return
}
+ //log.Print("headerVars.Settings",headerVars.Settings)
var settingList map[string]interface{} = make(map[string]interface{})
rows, err := get_settings_stmt.Query()
if err != nil {
@@ -666,7 +667,7 @@ func route_panel_setting(w http.ResponseWriter, r *http.Request, user User, snam
}
func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User, sname string) {
- ok := SimplePanelSessionCheck(w,r,&user)
+ headerLite, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -711,11 +712,13 @@ func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, user User,
return
}
- errmsg := parseSetting(sname, scontent, stype, sconstraints)
+ errmsg := headerLite.Settings.ParseSetting(sname, scontent, stype, sconstraints)
if errmsg != "" {
LocalError(errmsg,w,r,user)
return
}
+ settingBox.Store(headerLite.Settings)
+
http.Redirect(w,r,"/panel/settings/",http.StatusSeeOther)
}
@@ -749,7 +752,7 @@ func route_panel_plugins(w http.ResponseWriter, r *http.Request, user User){
}
func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user User, uname string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -825,7 +828,7 @@ func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, user U
}
func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user User, uname string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -873,7 +876,7 @@ func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, user
}
func route_panel_plugins_install(w http.ResponseWriter, r *http.Request, user User, uname string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -1075,7 +1078,7 @@ func route_panel_users_edit(w http.ResponseWriter, r *http.Request, user User, s
}
func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, user User, suid string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -1369,7 +1372,7 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, user
}
func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user User, sgid string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -1501,7 +1504,7 @@ func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, user
}
func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request, user User, sgid string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -1577,7 +1580,7 @@ func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request
}
func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request, user User){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
@@ -1662,7 +1665,7 @@ func route_panel_themes(w http.ResponseWriter, r *http.Request, user User){
}
func route_panel_themes_default(w http.ResponseWriter, r *http.Request, user User, uname string){
- ok := SimplePanelSessionCheck(w,r,&user)
+ _, ok := SimplePanelSessionCheck(w,r,&user)
if !ok {
return
}
diff --git a/public/global.js b/public/global.js
index 286403f8..69a6514f 100644
--- a/public/global.js
+++ b/public/global.js
@@ -197,7 +197,7 @@ $(document).ready(function(){
$(".topic_item .submit_edit").click(function(event){
event.preventDefault();
- console.log("clicked on .topic_item .submit_edit");
+ //console.log("clicked on .topic_item .submit_edit");
$(".topic_name").html($(".topic_name_input").val());
$(".topic_content").html($(".topic_content_input").val());
$(".topic_status_e:not(.open_edit)").html($(".topic_status_input").val());
diff --git a/routes.go b/routes.go
index 1ad526e8..539c26d2 100644
--- a/routes.go
+++ b/routes.go
@@ -480,7 +480,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request, user User){
topic.ClassName = config.StaffCss
}
- /*if settings["url_tags"] == false {
+ /*if headerVars.Settings["url_tags"] == false {
topic.URLName = ""
} else {
topic.URL, ok = external_sites[topic.URLPrefix]
@@ -547,7 +547,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request, user User){
replyItem.Tag = groups[replyItem.Group].Tag
- /*if settings["url_tags"] == false {
+ /*if headerVars.Settings["url_tags"] == false {
replyItem.URLName = ""
} else {
replyItem.URL, ok = external_sites[replyItem.URLPrefix]
@@ -1683,7 +1683,7 @@ func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Re
}
// If Email Activation is on, then activate the account while we're here
- if settings["activation_type"] == 2 {
+ if headerVars.Settings["activation_type"] == 2 {
_, err = activate_user_stmt.Exec(user.ID)
if err != nil {
InternalError(err,w)
@@ -1801,6 +1801,8 @@ func route_register(w http.ResponseWriter, r *http.Request, user User) {
}
func route_register_submit(w http.ResponseWriter, r *http.Request, user User) {
+ headerLite, _ := SimpleSessionCheck(w,r,&user)
+
err := r.ParseForm()
if err != nil {
LocalError("Bad Form",w,r,user)
@@ -1850,7 +1852,7 @@ func route_register_submit(w http.ResponseWriter, r *http.Request, user User) {
}
var active, group int
- switch settings["activation_type"] {
+ switch headerLite.Settings["activation_type"] {
case 1: // Activate All
active = 1
group = config.DefaultGroup
diff --git a/setting.go b/setting.go
index 859dfc9c..b0aee067 100644
--- a/setting.go
+++ b/setting.go
@@ -1,9 +1,12 @@
package main
import "strconv"
import "strings"
+import "sync/atomic"
// TO-DO: Move this into the phrase system
var settingLabels map[string]string
+type SettingBox map[string]interface{}
+var settingBox atomic.Value // An atomic value pointing to a SettingBox
type OptionLabel struct
{
@@ -23,6 +26,8 @@ type Setting struct
func init() {
settingLabels = make(map[string]string)
settingLabels["activation_type"] = "Activate All,Email Activation,Admin Approval"
+ settingBox.Store(SettingBox(make(map[string]interface{})))
+ //settingBox.Store(make(map[string]interface{}))
}
func LoadSettings() error {
@@ -32,13 +37,15 @@ func LoadSettings() error {
}
defer rows.Close()
+ sBox := settingBox.Load().(SettingBox)
+ //sBox := settingBox.Load().(map[string]interface{})
var sname, scontent, stype, sconstraints string
for rows.Next() {
err = rows.Scan(&sname, &scontent, &stype, &sconstraints)
if err != nil {
return err
}
- errmsg := parseSetting(sname, scontent, stype, sconstraints)
+ errmsg := sBox.ParseSetting(sname, scontent, stype, sconstraints)
if errmsg != "" {
return err
}
@@ -47,21 +54,24 @@ func LoadSettings() error {
if err != nil {
return err
}
+
+ settingBox.Store(sBox)
return nil
}
// TO-DO: Add better support for HTML attributes (html-attribute). E.g. Meta descriptions.
-func parseSetting(sname string, scontent string, stype string, constraint string) string {
+func (sBox SettingBox) ParseSetting(sname string, scontent string, stype string, constraint string) string {
var err error
+ var ssBox map[string]interface{} = map[string]interface{}(sBox)
if stype == "bool" {
- settings[sname] = (scontent == "1")
+ ssBox[sname] = (scontent == "1")
} else if stype == "int" {
- settings[sname], err = strconv.Atoi(scontent)
+ ssBox[sname], err = strconv.Atoi(scontent)
if err != nil {
return "You were supposed to enter an integer x.x\nType mismatch in " + sname
}
} else if stype == "int64" {
- settings[sname], err = strconv.ParseInt(scontent, 10, 64)
+ ssBox[sname], err = strconv.ParseInt(scontent, 10, 64)
if err != nil {
return "You were supposed to enter an integer x.x\nType mismatch in " + sname
}
@@ -88,9 +98,9 @@ func parseSetting(sname string, scontent string, stype string, constraint string
if value < con1 || value > con2 {
return "Only integers between a certain range are allowed in this setting"
}
- settings[sname] = value
+ ssBox[sname] = value
} else {
- settings[sname] = scontent
+ ssBox[sname] = scontent
}
return ""
}
diff --git a/template_list.go b/template_list.go
index 409f1aa4..69a0fe69 100644
--- a/template_list.go
+++ b/template_list.go
@@ -30,7 +30,7 @@ var header_9 []byte = []byte(`.supermod_only { display: none !important; }`)
var header_10 []byte = []byte(`
`)
-var menu_0 []byte = []byte(`
+var menu_0 []byte = []byte(`
@@ -63,7 +63,7 @@ var menu_6 []byte = []byte(`
-
+
`)
var header_11 []byte = []byte(`
>
`)
var topic_10 []byte = []byte(`
+
+
+
`)
var topic_53 []byte = []byte(`
-
+
`)
var topic_54 []byte = []byte(`
`)
var topic_55 []byte = []byte(`
-
+
`)
var topic_56 []byte = []byte(`
-
-
+
`)
var topic_84 []byte = []byte(`
@@ -230,6 +232,11 @@ var topic_86 []byte = []byte(`' type="hidden" />
+`)
+var topic_87 []byte = []byte(`
+
+
+
`)
var footer_0 []byte = []byte(`
`)
@@ -253,6 +260,8 @@ var topic_alt_6 []byte = []byte(`?page=`)
var topic_alt_7 []byte = []byte(`">>
`)
var topic_alt_8 []byte = []byte(`
+
+
+
-
+
@@ -329,10 +339,10 @@ var topic_alt_48 []byte = []byte(` up`)
var topic_alt_49 []byte = []byte(`
-
+
`)
var topic_alt_50 []byte = []byte(`
-
@@ -388,7 +398,7 @@ var topic_alt_83 []byte = []byte(`
var topic_alt_84 []byte = []byte(`
-
+
`)
var topic_alt_85 []byte = []byte(`
`)
@@ -405,6 +415,11 @@ var topic_alt_87 []byte = []byte(`' type="hidden" />
+`)
+var topic_alt_88 []byte = []byte(`
+
+
+
`)
var profile_0 []byte = []byte(`
@@ -510,6 +525,8 @@ var profile_39 []byte = []byte(`
`)
var forums_0 []byte = []byte(`
+
+
@@ -549,8 +566,12 @@ var forums_16 []byte = []byte(`
var forums_17 []byte = []byte(`You don't have access to any forums.
`)
var forums_18 []byte = []byte(`
+
+
`)
var topics_0 []byte = []byte(`
+
+
@@ -604,6 +625,8 @@ var topics_28 []byte = []byte(` Start one? `)
var topics_29 []byte = []byte(``)
var topics_30 []byte = []byte(`
+
+
`)
var forum_0 []byte = []byte(``)
var forum_8 []byte = []byte(`
+
+
Start one?`)
var forum_42 []byte = []byte(`
`)
var forum_43 []byte = []byte(`
+
+
`)
diff --git a/template_topic.go b/template_topic.go
index 1332bf0c..29b363b5 100644
--- a/template_topic.go
+++ b/template_topic.go
@@ -3,8 +3,8 @@
// Code generated by Gosora. More below:
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
-import "strconv"
import "net/http"
+import "strconv"
func init() {
template_topic_handle = template_topic
@@ -256,6 +256,7 @@ w.Write(topic_85)
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_86)
}
+w.Write(topic_87)
w.Write(footer_0)
if tmpl_topic_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_1)
diff --git a/template_topic_alt.go b/template_topic_alt.go
index 9e3cddcd..ced58eaf 100644
--- a/template_topic_alt.go
+++ b/template_topic_alt.go
@@ -259,6 +259,7 @@ w.Write(topic_alt_86)
w.Write([]byte(strconv.Itoa(tmpl_topic_alt_vars.Topic.ID)))
w.Write(topic_alt_87)
}
+w.Write(topic_alt_88)
w.Write(footer_0)
if tmpl_topic_alt_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_1)
diff --git a/templates/account-menu.html b/templates/account-menu.html
index 01c77356..42c48f57 100644
--- a/templates/account-menu.html
+++ b/templates/account-menu.html
@@ -1,15 +1,15 @@
-
+
diff --git a/templates/account-own-edit-avatar.html b/templates/account-own-edit-avatar.html
index 3c0415e4..0afddd69 100644
--- a/templates/account-own-edit-avatar.html
+++ b/templates/account-own-edit-avatar.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "account-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/account-own-edit-email.html b/templates/account-own-edit-email.html
index 98963f0e..ad9c8219 100644
--- a/templates/account-own-edit-email.html
+++ b/templates/account-own-edit-email.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "account-menu.html" . }}
-
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/account-own-edit-username.html b/templates/account-own-edit-username.html
index 3683bb4a..f42c272d 100644
--- a/templates/account-own-edit-username.html
+++ b/templates/account-own-edit-username.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "account-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/account-own-edit.html b/templates/account-own-edit.html
index e13d180e..e02ca811 100644
--- a/templates/account-own-edit.html
+++ b/templates/account-own-edit.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "account-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/areyousure.html b/templates/areyousure.html
index 74da6096..ed67a617 100644
--- a/templates/areyousure.html
+++ b/templates/areyousure.html
@@ -1,10 +1,12 @@
{{template "header.html" . }}
-
-
-
+
+
{{template "footer.html" . }}
diff --git a/templates/create-topic.html b/templates/create-topic.html
index 54cfad1a..4e177147 100644
--- a/templates/create-topic.html
+++ b/templates/create-topic.html
@@ -1,26 +1,28 @@
{{template "header.html" . }}
-
-
+
+
+
+
{{template "footer.html" . }}
diff --git a/templates/custom_page.html b/templates/custom_page.html
index 77366441..873b5a3b 100644
--- a/templates/custom_page.html
+++ b/templates/custom_page.html
@@ -1,6 +1,8 @@
{{template "header.html" . }}
-
-
{{.Something}}
-{{template "footer.html" . }}
\ No newline at end of file
+
+
+ {{.Something}}
+
+{{template "footer.html" . }}
diff --git a/templates/edit-topic.html b/templates/edit-topic.html
index f754fa23..c54dd64b 100644
--- a/templates/edit-topic.html
+++ b/templates/edit-topic.html
@@ -1,29 +1,29 @@
{{template "header.html" . }}
-
-
-
-
-
- {{range .StatusList}}{{.}} {{end}}
-
-
Update
+
+
+
+
+
+
+ {{range .StatusList}}{{.}} {{end}}
+
+ Update
+
+
+
+
+ {{range $index, $element := .ItemList}}
{{$element.Content}}
{{end}}
+
+
+
-
-
-
- {{range $index, $element := .ItemList}}
- {{$element.Content}}
-
{{end}}
-
-
-
-
-{{template "footer.html" . }}
\ No newline at end of file
+
+{{template "footer.html" . }}
diff --git a/templates/error.html b/templates/error.html
index f55c57a0..ba6baecc 100644
--- a/templates/error.html
+++ b/templates/error.html
@@ -1,8 +1,10 @@
{{template "header.html" . }}
-
-
+
+
+
+
{{template "footer.html" . }}
diff --git a/templates/forum.html b/templates/forum.html
index 1b6b8f25..30b461af 100644
--- a/templates/forum.html
+++ b/templates/forum.html
@@ -4,6 +4,8 @@
{{if ne .LastPage .Page}}
{{end}}
+
+
{{else}}There aren't any topics in this forum yet.{{if .CurrentUser.Perms.CreateTopic}}
Start one? {{end}}
{{end}}
+
+
{{template "footer.html" . }}
diff --git a/templates/forums.html b/templates/forums.html
index a4d6a2fe..f626da5d 100644
--- a/templates/forums.html
+++ b/templates/forums.html
@@ -1,4 +1,6 @@
{{template "header.html" . }}
+
+
@@ -20,4 +22,6 @@
{{else}}You don't have access to any forums.
{{end}}
+
+
{{template "footer.html" . }}
diff --git a/templates/menu.html b/templates/menu.html
index 34b1a34e..d41a114f 100644
--- a/templates/menu.html
+++ b/templates/menu.html
@@ -1,4 +1,4 @@
-
+
diff --git a/templates/overview.html b/templates/overview.html
index 17308004..8c2da1f1 100644
--- a/templates/overview.html
+++ b/templates/overview.html
@@ -1,3 +1,5 @@
{{template "header.html" . }}
+
-{{template "footer.html" . }}
\ No newline at end of file
+
+{{template "footer.html" . }}
diff --git a/templates/panel-adminlogs.html b/templates/panel-adminlogs.html
index c62dfbff..7c4c09f0 100644
--- a/templates/panel-adminlogs.html
+++ b/templates/panel-adminlogs.html
@@ -1,5 +1,5 @@
{{template "header.html" . }}
-
+
@@ -8,8 +8,8 @@
{{if .CurrentUser.Perms.ViewAdminLogs}}{{end}}
{{template "panel-inner-menu.html" . }}
-
-
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-dashboard.html b/templates/panel-dashboard.html
index 60842ab4..f5853aea 100644
--- a/templates/panel-dashboard.html
+++ b/templates/panel-dashboard.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
+
@@ -10,5 +10,5 @@
{{if .Background}}background-color: {{.Background}};{{end}}">{{.Body}}
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-debug.html b/templates/panel-debug.html
index 5646cc40..4332f4e9 100644
--- a/templates/panel-debug.html
+++ b/templates/panel-debug.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
+
@@ -13,5 +13,5 @@
{{.OpenConns}}
{{.DBAdapter}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-forum-edit.html b/templates/panel-forum-edit.html
index 6a99a948..0b43ce37 100644
--- a/templates/panel-forum-edit.html
+++ b/templates/panel-forum-edit.html
@@ -4,7 +4,7 @@
var form_vars = {'perm_preset': ['can_moderate','can_post','read_only','no_access','default','custom']};
-
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-forums.html b/templates/panel-forums.html
index a1f3b251..fa03ed6d 100644
--- a/templates/panel-forums.html
+++ b/templates/panel-forums.html
@@ -5,7 +5,7 @@
'forum_preset': ['all','announce','members','staff','admins','archive','custom']};
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-group-edit-perms.html b/templates/panel-group-edit-perms.html
index 2b66e30e..5d89a3e6 100644
--- a/templates/panel-group-edit-perms.html
+++ b/templates/panel-group-edit-perms.html
@@ -1,5 +1,5 @@
{{template "header.html" . }}
-
{{template "panel-inner-menu.html" . }}
-
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-group-edit.html b/templates/panel-group-edit.html
index 0eca4947..594b8e41 100644
--- a/templates/panel-group-edit.html
+++ b/templates/panel-group-edit.html
@@ -1,5 +1,5 @@
{{template "header.html" . }}
-
{{template "panel-inner-menu.html" . }}
-
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-groups.html b/templates/panel-groups.html
index 67cc750b..4b5045e2 100644
--- a/templates/panel-groups.html
+++ b/templates/panel-groups.html
@@ -1,7 +1,7 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-menu.html b/templates/panel-menu.html
index 75b274e8..c711498b 100644
--- a/templates/panel-menu.html
+++ b/templates/panel-menu.html
@@ -1 +1 @@
-{{template "panel-inner-menu.html" . }}
\ No newline at end of file
+{{template "panel-inner-menu.html" . }}
diff --git a/templates/panel-modlogs.html b/templates/panel-modlogs.html
index 2b87bbea..b6482b2c 100644
--- a/templates/panel-modlogs.html
+++ b/templates/panel-modlogs.html
@@ -1,5 +1,5 @@
{{template "header.html" . }}
-
+
@@ -8,8 +8,8 @@
{{if .CurrentUser.Perms.ViewAdminLogs}}{{end}}
{{template "panel-inner-menu.html" . }}
-
-
+
+
@@ -36,5 +36,5 @@
{{if ne .LastPage .Page}}{{end}}
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-plugins.html b/templates/panel-plugins.html
index 109fd374..e83c0f2e 100644
--- a/templates/panel-plugins.html
+++ b/templates/panel-plugins.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-setting.html b/templates/panel-setting.html
index 61cda60e..17e59c92 100644
--- a/templates/panel-setting.html
+++ b/templates/panel-setting.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-settings.html b/templates/panel-settings.html
index 400fd2f4..2291a7bf 100644
--- a/templates/panel-settings.html
+++ b/templates/panel-settings.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-themes.html b/templates/panel-themes.html
index 969e4fc5..00d2cbfa 100644
--- a/templates/panel-themes.html
+++ b/templates/panel-themes.html
@@ -1,5 +1,5 @@
{{template "header.html" . }}
-
{{template "panel-inner-menu.html" . }}
-
+
-
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-user-edit.html b/templates/panel-user-edit.html
index 7838d2fb..371b3d40 100644
--- a/templates/panel-user-edit.html
+++ b/templates/panel-user-edit.html
@@ -1,6 +1,6 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
-
+
{{template "footer.html" . }}
diff --git a/templates/panel-users.html b/templates/panel-users.html
index cf26d74d..bde330cb 100644
--- a/templates/panel-users.html
+++ b/templates/panel-users.html
@@ -1,7 +1,7 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
-
+
@@ -28,5 +28,5 @@
{{if ne .LastPage .Page}}{{end}}
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/register.html b/templates/register.html
index e0696b39..2b33f450 100644
--- a/templates/register.html
+++ b/templates/register.html
@@ -1,4 +1,6 @@
{{template "header.html" . }}
+
+
@@ -25,4 +27,6 @@
+
+
{{template "footer.html" . }}
diff --git a/templates/socialgroups_create_group.html b/templates/socialgroups_create_group.html
index 3e01f9d8..8473d0b0 100644
--- a/templates/socialgroups_create_group.html
+++ b/templates/socialgroups_create_group.html
@@ -1,4 +1,6 @@
{{template "header.html" . }}
+
+
@@ -27,4 +29,6 @@
+
+
{{template "footer.html" . }}
diff --git a/templates/socialgroups_group_list.html b/templates/socialgroups_group_list.html
index fc117fec..bba3acc5 100644
--- a/templates/socialgroups_group_list.html
+++ b/templates/socialgroups_group_list.html
@@ -1,19 +1,21 @@
{{template "header.html" . }}
-
-
- {{range .GroupList}}
-
- {{.Name}}
- {{.Desc}}
-
-
- {{.MemberCount}} members
- {{.LastUpdateTime}}
-
-
+
+
- {{else}}There aren't any visible groups.
{{end}}
-
+
+ {{range .GroupList}}
+
+ {{.Name}}
+ {{.Desc}}
+
+
+ {{.MemberCount}} members
+ {{.LastUpdateTime}}
+
+
+
+ {{else}}
There aren't any visible groups.
{{end}}
+
+
{{template "footer.html" . }}
diff --git a/templates/socialgroups_member_list.html b/templates/socialgroups_member_list.html
index b5f0025a..70b38011 100644
--- a/templates/socialgroups_member_list.html
+++ b/templates/socialgroups_member_list.html
@@ -8,16 +8,16 @@
{{end}}
-
+
{{range .ItemList}}
{{.RankString}}
@@ -30,5 +30,5 @@
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/socialgroups_view_group.html b/templates/socialgroups_view_group.html
index 2b4acd62..920522a9 100644
--- a/templates/socialgroups_view_group.html
+++ b/templates/socialgroups_view_group.html
@@ -8,17 +8,17 @@
{{end}}
-
+
{{range .ItemList}}
{{.PostCount}} replies
@@ -37,5 +37,5 @@
{{else}}There aren't any topics in here yet.{{if .CurrentUser.Perms.CreateTopic}}
Start one? {{end}}
{{end}}
-
+
{{template "footer.html" . }}
diff --git a/templates/topic.html b/templates/topic.html
index df0dd975..0bb1b7a1 100644
--- a/templates/topic.html
+++ b/templates/topic.html
@@ -8,6 +8,8 @@
>
{{end}}
+
+
-
+
{{.Topic.Content}}
{{.Topic.Content}}
@@ -47,14 +49,14 @@
-
+
{{range .ItemList}}{{if .ActionType}}
-
+
{{.ActionIcon}}
{{.ActionType}}
-
+
{{else}}
-
+
{{.ContentHtml}}
@@ -72,7 +74,7 @@
{{if .Tag}}{{.Tag}} {{else}}{{.Level}} {{end}}
-
+
{{end}}{{end}}
{{if .CurrentUser.Perms.CreateReply}}
@@ -88,4 +90,7 @@
{{end}}
+
+
+
{{template "footer.html" . }}
diff --git a/templates/topic_alt.html b/templates/topic_alt.html
index 3467b984..a4400d5f 100644
--- a/templates/topic_alt.html
+++ b/templates/topic_alt.html
@@ -3,6 +3,8 @@
{{if ne .LastPage .Page}}
{{end}}
+
+
@@ -20,9 +22,10 @@
+
+
{{range .ItemList}}
-
+
{{end}}
{{if .CurrentUser.Perms.CreateReply}}
@@ -88,4 +91,7 @@
{{end}}
+
+
+
{{template "footer.html" . }}
diff --git a/templates/topics.html b/templates/topics.html
index 9e920c9d..41409002 100644
--- a/templates/topics.html
+++ b/templates/topics.html
@@ -1,4 +1,6 @@
{{template "header.html" . }}
+
+
@@ -24,4 +26,6 @@
{{else}}There aren't any topics yet.{{if .CurrentUser.Perms.CreateTopic}}
Start one? {{end}}
{{end}}
+
+
{{template "footer.html" . }}
diff --git a/templates/widget_menu.html b/templates/widget_menu.html
index 94f035e8..d2a11507 100644
--- a/templates/widget_menu.html
+++ b/templates/widget_menu.html
@@ -1,6 +1,6 @@
-{{range .MenuList}}
+
{{range .MenuList}}
-{{end}}
+{{end}}
diff --git a/themes/shadow/public/main.css b/themes/shadow/public/main.css
index 9bec6a8b..4fe01cc1 100644
--- a/themes/shadow/public/main.css
+++ b/themes/shadow/public/main.css
@@ -166,9 +166,16 @@ a {
display: none;
}
+/* Topic View */
+
+/* TO-DO: How should we handle the sticky headers? */
.topic_sticky_head {
}
-.topic_closed_head {
+
+/* TO-DO: Rewrite the closed topic header so that it looks more consistent with the rest of the theme */
+.topic_closed_head .topic_status_closed {
+ margin-bottom: -10px;
+ font-size: 19px;
}
.post_item {
diff --git a/user.go b/user.go
index f7d43f13..376f7680 100644
--- a/user.go
+++ b/user.go
@@ -14,10 +14,13 @@ import (
var guest_user User = User{ID:0,Link:"#",Group:6,Perms:GuestPerms}
var PreRoute func(http.ResponseWriter, *http.Request) (User,bool) = _pre_route
+
+// TO-DO: Are these even session checks anymore? We might need to rethink these names
var PanelSessionCheck func(http.ResponseWriter, *http.Request, *User) (HeaderVars,PanelStats,bool) = _panel_session_check
-var SimplePanelSessionCheck func(http.ResponseWriter, *http.Request, *User) bool = _simple_panel_session_check
+var SimplePanelSessionCheck func(http.ResponseWriter, *http.Request, *User) (HeaderLite,bool) = _simple_panel_session_check
var SimpleForumSessionCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (success bool) = _simple_forum_session_check
var ForumSessionCheck func(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerVars HeaderVars, success bool) = _forum_session_check
+var SimpleSessionCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerLite HeaderLite, success bool) = _simple_session_check
var SessionCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerVars HeaderVars, success bool) = _session_check
var CheckPassword func(real_password string, password string, salt string) (err error) = BcryptCheckPassword
@@ -210,6 +213,7 @@ func _forum_session_check(w http.ResponseWriter, r *http.Request, user *User, fi
// Even if they have the right permissions, the control panel is only open to supermods+. There are many areas without subpermissions which assume that the current user is a supermod+ and admins are extremely unlikely to give these permissions to someone who isn't at-least a supermod to begin with
func _panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerVars HeaderVars, stats PanelStats, success bool) {
headerVars.Site = site
+ headerVars.Settings = settingBox.Load().(SettingBox)
if !user.Is_Super_Mod {
NoPermissions(w,r,*user)
return headerVars, stats, false
@@ -241,7 +245,7 @@ func _panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (h
stats.Users = users.GetGlobalCount()
stats.Forums = fstore.GetGlobalCount() // TO-DO: Stop it from showing the blanked forums
- stats.Settings = len(settings) // TO-DO: IS this racey?
+ stats.Settings = len(headerVars.Settings) // TO-DO: IS this racey?
stats.Themes = len(themes)
stats.Reports = 0 // TO-DO: Do the report count. Only show open threads?
@@ -258,16 +262,27 @@ func _panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (h
return headerVars, stats, true
}
-func _simple_panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (success bool) {
+
+func _simple_panel_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerLite HeaderLite, success bool) {
if !user.Is_Super_Mod {
NoPermissions(w,r,*user)
- return false
+ return headerLite, false
}
- return true
+ headerLite.Site = site
+ headerLite.Settings = settingBox.Load().(SettingBox)
+ return headerLite, true
+}
+
+// SimpleSessionCheck is back from the grave, yay :D
+func _simple_session_check(w http.ResponseWriter, r *http.Request, user *User) (headerLite HeaderLite, success bool) {
+ headerLite.Site = site
+ headerLite.Settings = settingBox.Load().(SettingBox)
+ return headerLite, true
}
func _session_check(w http.ResponseWriter, r *http.Request, user *User) (headerVars HeaderVars, success bool) {
headerVars.Site = site
+ headerVars.Settings = settingBox.Load().(SettingBox)
if user.Is_Banned {
headerVars.NoticeList = append(headerVars.NoticeList,"Your account has been suspended. Some of your permissions may have been revoked.")
}
@@ -336,6 +351,7 @@ func words_to_score(wcount int, topic bool) (score int) {
score = 1
}
+ settings := settingBox.Load().(map[string]interface{})
if wcount >= settings["megapost_min_words"].(int) {
score += 4
} else if wcount >= settings["bigpost_min_words"].(int) {
@@ -355,6 +371,7 @@ func increase_post_user_stats(wcount int, uid int, topic bool, user User) error
base_score = 2
}
+ settings := settingBox.Load().(map[string]interface{})
if wcount >= settings["megapost_min_words"].(int) {
_, err := increment_user_megaposts_stmt.Exec(1,1,1,uid)
if err != nil {
@@ -394,6 +411,7 @@ func decrease_post_user_stats(wcount int, uid int, topic bool, user User) error
base_score = -2
}
+ settings := settingBox.Load().(map[string]interface{})
if wcount >= settings["megapost_min_words"].(int) {
_, err := increment_user_megaposts_stmt.Exec(-1,-1,-1,uid)
if err != nil {
@@ -30,5 +30,5 @@