diff --git a/errors.go b/errors.go
index 52aa61e6..4cb5377d 100644
--- a/errors.go
+++ b/errors.go
@@ -9,15 +9,15 @@ var error_notfound []byte
func init_errors() error {
var b bytes.Buffer
user := User{0,"Guest","",0,false,false,false,false,false,false,GuestPerms,"",false,"","","","","",0,0,"0.0.0.0.0"}
- pi := Page{"Internal Server Error",user,nList,tList,"A problem has occurred in the system."}
+ pi := Page{"Internal Server Error",user,hvars,tList,"A problem has occurred in the system."}
err := templates.ExecuteTemplate(&b,"error.html", pi)
if err != nil {
return err
}
error_internal = b.Bytes()
-
+
b.Reset()
- pi = Page{"Not Found",user,nList,tList,"The requested page doesn't exist."}
+ pi = Page{"Not Found",user,hvars,tList,"The requested page doesn't exist."}
err = templates.ExecuteTemplate(&b,"error.html", pi)
if err != nil {
return err
@@ -50,7 +50,7 @@ func InternalErrorJS(err error, w http.ResponseWriter, r *http.Request) {
func PreError(errmsg string, w http.ResponseWriter, r *http.Request) {
w.WriteHeader(500)
user := User{ID:0,Group:6,Perms:GuestPerms,}
- pi := Page{"Error",user,nList,tList,errmsg}
+ pi := Page{"Error",user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html",pi)
fmt.Fprintln(w,b.String())
@@ -58,7 +58,7 @@ func PreError(errmsg string, w http.ResponseWriter, r *http.Request) {
func LocalError(errmsg string, w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(500)
- pi := Page{"Local Error",user,nList,tList,errmsg}
+ pi := Page{"Local Error",user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html",pi)
fmt.Fprintln(w,b.String())
@@ -66,7 +66,7 @@ func LocalError(errmsg string, w http.ResponseWriter, r *http.Request, user User
func LoginRequired(w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(401)
- pi := Page{"Local Error",user,nList,tList,"You need to login to do that."}
+ pi := Page{"Local Error",user,hvars,tList,"You need to login to do that."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html",pi)
fmt.Fprintln(w,b.String())
@@ -76,7 +76,7 @@ func PreErrorJSQ(errmsg string, w http.ResponseWriter, r *http.Request, is_js st
w.WriteHeader(500)
if is_js == "0" {
user := User{ID:0,Group:6,Perms:GuestPerms,}
- pi := Page{"Local Error",user,nList,tList,errmsg}
+ pi := Page{"Local Error",user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -88,7 +88,7 @@ func PreErrorJSQ(errmsg string, w http.ResponseWriter, r *http.Request, is_js st
func LocalErrorJSQ(errmsg string, w http.ResponseWriter, r *http.Request, user User, is_js string) {
w.WriteHeader(500)
if is_js == "0" {
- pi := Page{"Local Error",user,nList,tList,errmsg}
+ pi := Page{"Local Error",user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -104,7 +104,7 @@ func LocalErrorJS(errmsg string, w http.ResponseWriter, r *http.Request) {
func NoPermissions(w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(403)
- pi := Page{"Local Error",user,nList,tList,"You don't have permission to do that."}
+ pi := Page{"Local Error",user,hvars,tList,"You don't have permission to do that."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
errpage := b.String()
@@ -114,7 +114,7 @@ func NoPermissions(w http.ResponseWriter, r *http.Request, user User) {
func NoPermissionsJSQ(w http.ResponseWriter, r *http.Request, user User, is_js string) {
w.WriteHeader(403)
if is_js == "0" {
- pi := Page{"Local Error",user,nList,tList,"You don't have permission to do that."}
+ pi := Page{"Local Error",user,hvars,tList,"You don't have permission to do that."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -125,7 +125,7 @@ func NoPermissionsJSQ(w http.ResponseWriter, r *http.Request, user User, is_js s
func Banned(w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(403)
- pi := Page{"Banned",user,nList,tList,"You have been banned from this site."}
+ pi := Page{"Banned",user,hvars,tList,"You have been banned from this site."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -134,7 +134,7 @@ func Banned(w http.ResponseWriter, r *http.Request, user User) {
func BannedJSQ(w http.ResponseWriter, r *http.Request, user User, is_js string) {
w.WriteHeader(403)
if is_js == "0" {
- pi := Page{"Banned",user,nList,tList,"You have been banned from this site."}
+ pi := Page{"Banned",user,hvars,tList,"You have been banned from this site."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -146,7 +146,7 @@ func BannedJSQ(w http.ResponseWriter, r *http.Request, user User, is_js string)
func LoginRequiredJSQ(w http.ResponseWriter, r *http.Request, user User, is_js string) {
w.WriteHeader(401)
if is_js == "0" {
- pi := Page{"Local Error",user,nList,tList,"You need to login to do that."}
+ pi := Page{"Local Error",user,hvars,tList,"You need to login to do that."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -157,7 +157,7 @@ func LoginRequiredJSQ(w http.ResponseWriter, r *http.Request, user User, is_js s
func SecurityError(w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(403)
- pi := Page{"Security Error",user,nList,tList,"There was a security issue with your request."}
+ pi := Page{"Security Error",user,hvars,tList,"There was a security issue with your request."}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -170,7 +170,7 @@ func NotFound(w http.ResponseWriter, r *http.Request) {
func CustomError(errmsg string, errcode int, errtitle string, w http.ResponseWriter, r *http.Request, user User) {
w.WriteHeader(errcode)
- pi := Page{errtitle,user,nList,tList,errmsg}
+ pi := Page{errtitle,user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
@@ -179,7 +179,7 @@ func CustomError(errmsg string, errcode int, errtitle string, w http.ResponseWri
func CustomErrorJSQ(errmsg string, errcode int, errtitle string, w http.ResponseWriter, r *http.Request, user User, is_js string) {
w.WriteHeader(errcode)
if is_js == "0" {
- pi := Page{errtitle,user,nList,tList,errmsg}
+ pi := Page{errtitle,user,hvars,tList,errmsg}
var b bytes.Buffer
templates.ExecuteTemplate(&b,"error.html", pi)
fmt.Fprintln(w,b.String())
diff --git a/main.go b/main.go
index 071345c4..dfeb099b 100644
--- a/main.go
+++ b/main.go
@@ -58,7 +58,11 @@ var template_create_topic_handle func(CreateTopicPage,io.Writer) = nil
func compile_templates() {
var c CTemplateSet
user := User{62,"","compiler@localhost",0,false,false,false,false,false,false,GuestPerms,"",false,"","","","","",0,0,"0.0.0.0.0"}
- noticeList := []string{"test"}
+ headerVars := HeaderVars{
+ NoticeList:[]string{"test"},
+ Stylesheets:[]string{"panel"},
+ Scripts:[]string{"whatever"},
+ }
log.Print("Compiling the templates")
@@ -67,12 +71,12 @@ func compile_templates() {
replyList = append(replyList, Reply{0,0,"","Yo!",0,"",default_group,"",0,0,"",no_css_tmpl,0,"","","","",0,"127.0.0.1",false,1,"",""})
var varList map[string]VarItem = make(map[string]VarItem)
- tpage := TopicPage{"Title",user,noticeList,replyList,topic,1,1,false}
+ tpage := TopicPage{"Title",user,headerVars,replyList,topic,1,1,extData}
topic_id_tmpl := c.compile_template("topic.html","templates/","TopicPage", tpage, varList)
topic_id_alt_tmpl := c.compile_template("topic_alt.html","templates/","TopicPage", tpage, varList)
varList = make(map[string]VarItem)
- ppage := ProfilePage{"User 526",user,noticeList,replyList,user,false}
+ ppage := ProfilePage{"User 526",user,headerVars,replyList,user,extData}
profile_tmpl := c.compile_template("profile.html","templates/","ProfilePage", ppage, varList)
var forumList []Forum
@@ -82,18 +86,18 @@ func compile_templates() {
}
}
varList = make(map[string]VarItem)
- forums_page := ForumsPage{"Forum List",user,noticeList,forumList,0}
+ forums_page := ForumsPage{"Forum List",user,headerVars,forumList,extData}
forums_tmpl := c.compile_template("forums.html","templates/","ForumsPage", forums_page, varList)
var topicsList []TopicsRow
topicsList = append(topicsList,TopicsRow{1,"Topic Title","The topic content.",1,false,false,"Date","Date",1,"","127.0.0.1",0,1,"classname","Admin","","",0,"","","","",58,"General"})
- topics_page := TopicsPage{"Topic List",user,noticeList,topicsList,""}
+ topics_page := TopicsPage{"Topic List",user,headerVars,topicsList,extData}
topics_tmpl := c.compile_template("topics.html","templates/","TopicsPage", topics_page, varList)
var topicList []TopicUser
topicList = append(topicList,TopicUser{1,"Topic Title","The topic content.",1,false,false,"Date","Date",1,"","127.0.0.1",0,1,"classname","","Admin",default_group,"","",0,"","","","",58,false})
forum_item := Forum{1,"General Forum","Where the general stuff happens",true,"all",0,"",0,"",0,""}
- forum_page := ForumPage{"General Forum",user,noticeList,topicList,forum_item,1,1,nil}
+ forum_page := ForumPage{"General Forum",user,headerVars,topicList,forum_item,1,1,extData}
forum_tmpl := c.compile_template("forum.html","templates/","ForumPage", forum_page, varList)
log.Print("Writing the templates")
@@ -114,6 +118,9 @@ func write_template(name string, content string) {
}
func init_templates() {
+ if debug {
+ log.Print("Initialising the template system")
+ }
compile_templates()
// Filler functions for now...
@@ -127,6 +134,9 @@ func init_templates() {
fmap["divide"] = filler_func
// The interpreted templates...
+ if debug {
+ log.Print("Loading the template files...")
+ }
templates.Funcs(fmap)
template.Must(templates.ParseGlob("templates/*"))
template.Must(templates.ParseGlob("pages/*"))
diff --git a/mod_routes.go b/mod_routes.go
index ef4942ff..61fedbbb 100644
--- a/mod_routes.go
+++ b/mod_routes.go
@@ -1,8 +1,8 @@
package main
import (
-// "log"
-// "fmt"
+ //"log"
+ //"fmt"
"strconv"
"net"
"net/http"
@@ -535,7 +535,7 @@ func route_profile_reply_delete_submit(w http.ResponseWriter, r *http.Request) {
}
func route_ban(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -563,7 +563,7 @@ func route_ban(w http.ResponseWriter, r *http.Request) {
confirm_msg := "Are you sure you want to ban '" + uname + "'?"
yousure := AreYouSure{"/users/ban/submit/" + strconv.Itoa(uid),confirm_msg}
- pi := Page{"Ban User",user,noticeList,tList,yousure}
+ pi := Page{"Ban User",user,headerVars,tList,yousure}
templates.ExecuteTemplate(w,"areyousure.html",pi)
}
diff --git a/pages.go b/pages.go
index 0959ef2b..5df8bdaf 100644
--- a/pages.go
+++ b/pages.go
@@ -1,16 +1,31 @@
package main
+
//import "fmt"
+import "sync"
import "bytes"
import "strings"
import "strconv"
import "regexp"
import "html/template"
+type HeaderVars struct
+{
+ NoticeList []string
+ Scripts []string
+ Stylesheets []string
+}
+
+type ExtData struct
+{
+ items map[string]interface{} // Key: pluginname
+ sync.RWMutex
+}
+
type Page struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []interface{}
Something interface{}
}
@@ -19,62 +34,62 @@ type TopicPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []Reply
Topic TopicUser
Page int
LastPage int
- ExtData interface{}
+ ExtData ExtData
}
type TopicsPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []TopicsRow
- ExtData interface{}
+ ExtData ExtData
}
type ForumPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []TopicUser
Forum Forum
Page int
LastPage int
- ExtData interface{}
+ ExtData ExtData
}
type ForumsPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []Forum
- ExtData interface{}
+ ExtData ExtData
}
type ProfilePage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []Reply
ProfileOwner User
- ExtData interface{}
+ ExtData ExtData
}
type CreateTopicPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ItemList []Forum
FID int
- ExtData interface{}
+ ExtData ExtData
}
type GridElement struct
@@ -92,32 +107,32 @@ type PanelDashboardPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
GridItems []GridElement
- ExtData interface{}
+ ExtData ExtData
}
type ThemesPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
PrimaryThemes []Theme
VariantThemes []Theme
- ExtData interface{}
+ ExtData ExtData
}
type EditGroupPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ID int
Name string
Tag string
Rank string
DisableRank bool
- ExtData interface{}
+ ExtData ExtData
}
type GroupForumPermPreset struct
@@ -130,14 +145,14 @@ type EditForumPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ID int
Name string
Desc string
Active bool
Preset string
Groups []GroupForumPermPreset
- ExtData interface{}
+ ExtData ExtData
}
type NameLangPair struct
@@ -157,12 +172,12 @@ type EditGroupPermsPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
ID int
Name string
LocalPerms []NameLangToggle
GlobalPerms []NameLangToggle
- ExtData interface{}
+ ExtData ExtData
}
type Log struct {
@@ -175,9 +190,9 @@ type LogsPage struct
{
Title string
CurrentUser User
- NoticeList []string
+ Header HeaderVars
Logs []Log
- ExtData interface{}
+ ExtData ExtData
}
type PageSimple struct
diff --git a/panel_routes.go b/panel_routes.go
index 64282749..36f41c5d 100644
--- a/panel_routes.go
+++ b/panel_routes.go
@@ -20,14 +20,10 @@ import "github.com/shirou/gopsutil/cpu"
import "github.com/shirou/gopsutil/mem"
func route_panel(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod {
- NoPermissions(w,r,user)
- return
- }
var cpustr, cpuColour string
perc2, err := cpu.Percent(time.Duration(time.Second),true)
@@ -189,16 +185,16 @@ func route_panel(w http.ResponseWriter, r *http.Request){
gridElements = append(gridElements, GridElement{"dash-visitorsperweek","2 visitors / week",13,"grid_stat stat_disabled","","","Coming Soon!"/*"The number of unique visitors we've had over the last 7 days"*/})
gridElements = append(gridElements, GridElement{"dash-postsperuser","5 posts / user / week",14,"grid_stat stat_disabled","","","Coming Soon!"/*"The average number of posts made by each active user over the past week"*/})
- pi := PanelDashboardPage{"Control Panel Dashboard",user,noticeList,gridElements,nil}
+ pi := PanelDashboardPage{"Control Panel Dashboard",user,headerVars,gridElements,extData}
templates.ExecuteTemplate(w,"panel-dashboard.html",pi)
}
func route_panel_forums(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -213,7 +209,7 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request){
forumList = append(forumList,fadmin)
}
}
- pi := Page{"Forum Manager",user,noticeList,forumList,nil}
+ pi := Page{"Forum Manager",user,headerVars,forumList,nil}
err := templates.ExecuteTemplate(w,"panel-forums.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -221,11 +217,11 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request){
}
func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -257,11 +253,11 @@ func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request){
}
func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, sfid string){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -284,16 +280,16 @@ func route_panel_forums_delete(w http.ResponseWriter, r *http.Request, sfid stri
confirm_msg := "Are you sure you want to delete the '" + forums[fid].Name + "' forum?"
yousure := AreYouSure{"/panel/forums/delete/submit/" + strconv.Itoa(fid),confirm_msg}
- pi := Page{"Delete Forum",user,noticeList,tList,yousure}
+ pi := Page{"Delete Forum",user,headerVars,tList,yousure}
templates.ExecuteTemplate(w,"areyousure.html",pi)
}
func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, sfid string) {
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -321,11 +317,11 @@ func route_panel_forums_delete_submit(w http.ResponseWriter, r *http.Request, sf
}
func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, sfid string) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -354,7 +350,7 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, sfid string
gplist = append(gplist,GroupForumPermPreset{group,forum_perms_to_group_forum_preset(group.Forums[fid])})
}
- pi := EditForumPage{"Forum Editor",user,noticeList,forum.ID,forum.Name,forum.Desc,forum.Active,forum.Preset,gplist,nil}
+ pi := EditForumPage{"Forum Editor",user,headerVars,forum.ID,forum.Name,forum.Desc,forum.Active,forum.Preset,gplist,extData}
err = templates.ExecuteTemplate(w,"panel-forum-edit.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -362,11 +358,11 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, sfid string
}
func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid string) {
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -442,11 +438,11 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid
}
func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request, sfid string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageForums {
+ if !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
@@ -512,11 +508,11 @@ func route_panel_forums_edit_perms_submit(w http.ResponseWriter, r *http.Request
}
func route_panel_settings(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditSettings {
+ if !user.Perms.EditSettings {
NoPermissions(w,r,user)
return
}
@@ -561,16 +557,16 @@ func route_panel_settings(w http.ResponseWriter, r *http.Request){
return
}
- pi := Page{"Setting Manager",user,noticeList,tList,settingList}
+ pi := Page{"Setting Manager",user,headerVars,tList,settingList}
templates.ExecuteTemplate(w,"panel-settings.html",pi)
}
func route_panel_setting(w http.ResponseWriter, r *http.Request, sname string){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditSettings {
+ if !user.Perms.EditSettings {
NoPermissions(w,r,user)
return
}
@@ -609,16 +605,16 @@ func route_panel_setting(w http.ResponseWriter, r *http.Request, sname string){
}
}
- pi := Page{"Edit Setting",user,noticeList,itemList,setting}
+ pi := Page{"Edit Setting",user,headerVars,itemList,setting}
templates.ExecuteTemplate(w,"panel-setting.html",pi)
}
func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, sname string) {
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditSettings {
+ if !user.Perms.EditSettings {
NoPermissions(w,r,user)
return
}
@@ -668,11 +664,11 @@ func route_panel_setting_edit(w http.ResponseWriter, r *http.Request, sname stri
}
func route_panel_plugins(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManagePlugins {
+ if !user.Perms.ManagePlugins {
NoPermissions(w,r,user)
return
}
@@ -682,16 +678,16 @@ func route_panel_plugins(w http.ResponseWriter, r *http.Request){
pluginList = append(pluginList,plugin)
}
- pi := Page{"Plugin Manager",user,noticeList,pluginList,nil}
+ pi := Page{"Plugin Manager",user,headerVars,pluginList,nil}
templates.ExecuteTemplate(w,"panel-plugins.html",pi)
}
func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, uname string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManagePlugins {
+ if !user.Perms.ManagePlugins {
NoPermissions(w,r,user)
return
}
@@ -748,11 +744,11 @@ func route_panel_plugins_activate(w http.ResponseWriter, r *http.Request, uname
}
func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, uname string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManagePlugins {
+ if !user.Perms.ManagePlugins {
NoPermissions(w,r,user)
return
}
@@ -796,14 +792,10 @@ func route_panel_plugins_deactivate(w http.ResponseWriter, r *http.Request, unam
}
func route_panel_users(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod {
- NoPermissions(w,r,user)
- return
- }
var userList []interface{}
rows, err := get_users_stmt.Query()
@@ -843,7 +835,7 @@ func route_panel_users(w http.ResponseWriter, r *http.Request){
return
}
- pi := Page{"User Manager",user,noticeList,userList,nil}
+ pi := Page{"User Manager",user,headerVars,userList,nil}
err = templates.ExecuteTemplate(w,"panel-users.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -851,13 +843,12 @@ func route_panel_users(w http.ResponseWriter, r *http.Request){
}
func route_panel_users_edit(w http.ResponseWriter, r *http.Request,suid string){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- // 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
- if !user.Is_Super_Mod || !user.Perms.EditUser {
+ if !user.Perms.EditUser {
NoPermissions(w,r,user)
return
}
@@ -893,7 +884,7 @@ func route_panel_users_edit(w http.ResponseWriter, r *http.Request,suid string){
groupList = append(groupList,group)
}
- pi := Page{"User Editor",user,noticeList,groupList,targetUser}
+ pi := Page{"User Editor",user,headerVars,groupList,targetUser}
err = templates.ExecuteTemplate(w,"panel-user-edit.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -901,11 +892,11 @@ func route_panel_users_edit(w http.ResponseWriter, r *http.Request,suid string){
}
func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, suid string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditUser {
+ if !user.Perms.EditUser {
NoPermissions(w,r,user)
return
}
@@ -996,14 +987,10 @@ func route_panel_users_edit_submit(w http.ResponseWriter, r *http.Request, suid
}
func route_panel_groups(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod {
- NoPermissions(w,r,user)
- return
- }
var groupList []interface{}
for _, group := range groups[1:] {
@@ -1034,16 +1021,16 @@ func route_panel_groups(w http.ResponseWriter, r *http.Request){
}
//fmt.Printf("%+v\n", groupList)
- pi := Page{"Group Manager",user,noticeList,groupList,nil}
+ pi := Page{"Group Manager",user,headerVars,groupList,nil}
templates.ExecuteTemplate(w,"panel-groups.html",pi)
}
func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, sgid string){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditGroup {
+ if !user.Perms.EditGroup {
NoPermissions(w,r,user)
return
}
@@ -1085,7 +1072,7 @@ func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, sgid string
disable_rank := !user.Perms.EditGroupGlobalPerms || (group.ID == 6)
- pi := EditGroupPage{"Group Editor",user,noticeList,group.ID,group.Name,group.Tag,rank,disable_rank,nil}
+ pi := EditGroupPage{"Group Editor",user,headerVars,group.ID,group.Name,group.Tag,rank,disable_rank,extData}
err = templates.ExecuteTemplate(w,"panel-group-edit.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -1093,11 +1080,11 @@ func route_panel_groups_edit(w http.ResponseWriter, r *http.Request, sgid string
}
func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, sgid string){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditGroup {
+ if !user.Perms.EditGroup {
NoPermissions(w,r,user)
return
}
@@ -1158,7 +1145,7 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, sgid
globalPerms = append(globalPerms, NameLangToggle{"ViewAdminLogs",GetGlobalPermPhrase("ViewAdminLogs"),group.Perms.ViewAdminLogs})
globalPerms = append(globalPerms, NameLangToggle{"ViewIPs",GetGlobalPermPhrase("ViewIPs"),group.Perms.ViewIPs})
- pi := EditGroupPermsPage{"Group Editor",user,noticeList,group.ID,group.Name,localPerms,globalPerms,nil}
+ pi := EditGroupPermsPage{"Group Editor",user,headerVars,group.ID,group.Name,localPerms,globalPerms,extData}
err = templates.ExecuteTemplate(w,"panel-group-edit-perms.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -1166,11 +1153,11 @@ func route_panel_groups_edit_perms(w http.ResponseWriter, r *http.Request, sgid
}
func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, sgid string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditGroup {
+ if !user.Perms.EditGroup {
NoPermissions(w,r,user)
return
}
@@ -1298,11 +1285,11 @@ func route_panel_groups_edit_submit(w http.ResponseWriter, r *http.Request, sgid
}
func route_panel_groups_edit_perms_submit(w http.ResponseWriter, r *http.Request, sgid string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditGroup {
+ if !user.Perms.EditGroup {
NoPermissions(w,r,user)
return
}
@@ -1374,11 +1361,11 @@ 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, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.EditGroup {
+ if !user.Perms.EditGroup {
NoPermissions(w,r,user)
return
}
@@ -1425,11 +1412,11 @@ func route_panel_groups_create_submit(w http.ResponseWriter, r *http.Request){
}
func route_panel_themes(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageThemes {
+ if !user.Perms.ManageThemes {
NoPermissions(w,r,user)
return
}
@@ -1447,7 +1434,7 @@ func route_panel_themes(w http.ResponseWriter, r *http.Request){
}
- pi := ThemesPage{"Theme Manager",user,noticeList,pThemeList,vThemeList,nil}
+ pi := ThemesPage{"Theme Manager",user,headerVars,pThemeList,vThemeList,extData}
err := templates.ExecuteTemplate(w,"panel-themes.html",pi)
if err != nil {
log.Print(err)
@@ -1455,11 +1442,11 @@ func route_panel_themes(w http.ResponseWriter, r *http.Request){
}
func route_panel_themes_default(w http.ResponseWriter, r *http.Request, uname string){
- user, ok := SimpleSessionCheck(w,r)
+ user, ok := SimplePanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod || !user.Perms.ManageThemes {
+ if !user.Perms.ManageThemes {
NoPermissions(w,r,user)
return
}
@@ -1531,14 +1518,10 @@ func route_panel_themes_default(w http.ResponseWriter, r *http.Request, uname st
}
func route_panel_logs_mod(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := PanelSessionCheck(w,r)
if !ok {
return
}
- if !user.Is_Super_Mod {
- NoPermissions(w,r,user)
- return
- }
rows, err := get_modlogs_stmt.Query()
if err != nil {
@@ -1626,7 +1609,7 @@ func route_panel_logs_mod(w http.ResponseWriter, r *http.Request){
return
}
- pi := LogsPage{"Moderation Logs",user,noticeList,logs,nil}
+ pi := LogsPage{"Moderation Logs",user,headerVars,logs,extData}
err = templates.ExecuteTemplate(w,"panel-modlogs.html",pi)
if err != nil {
log.Print(err)
diff --git a/public/global.js b/public/global.js
index 5f2e5623..2ccba975 100644
--- a/public/global.js
+++ b/public/global.js
@@ -351,7 +351,11 @@ $(document).ready(function(){
document.getElementById("back").className += " alertActive"
});
- this.onkeyup = function(event){
+ $("input,textarea,select,option").keyup(function(event){
+ event.stopPropagation();
+ })
+
+ this.onkeyup = function(event) {
if(event.which == 37) this.querySelectorAll("#prevFloat a")[0].click();
if(event.which == 39) this.querySelectorAll("#nextFloat a")[0].click();
};
diff --git a/query_gen/main.go b/query_gen/main.go
index 9be176e3..d213d02e 100644
--- a/query_gen/main.go
+++ b/query_gen/main.go
@@ -116,9 +116,9 @@ func write_selects(adapter qgen.DB_Adapter) error {
adapter.SimpleSelect("get_activity_entry","activity_stream","actor, targetUser, event, elementType, elementID","asid = ?","","")
- adapter.SimpleSelect("forum_entry_exists","forums","fid","name = ''","fid ASC","0,1") // Is '' empty?
+ adapter.SimpleSelect("forum_entry_exists","forums","fid","name = ''","fid ASC","0,1")
- adapter.SimpleSelect("group_entry_exists","users_groups","gid","name = ''","gid ASC","0,1") // Is '' empty?
+ adapter.SimpleSelect("group_entry_exists","users_groups","gid","name = ''","gid ASC","0,1")
return nil
}
diff --git a/routes.go b/routes.go
index 9972d246..f70c26d9 100644
--- a/routes.go
+++ b/routes.go
@@ -24,6 +24,8 @@ import "golang.org/x/crypto/bcrypt"
// A blank list to fill out that parameter in Page for routes which don't use it
var tList []interface{}
var nList []string
+var hvars HeaderVars
+var extData ExtData
var success_json_bytes []byte = []byte(`{"success":"1"}`)
// GET functions
@@ -68,11 +70,11 @@ func route_fstatic(w http.ResponseWriter, r *http.Request){
}*/
func route_overview(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
- pi := Page{"Overview",user,noticeList,tList,nil}
+ pi := Page{"Overview",user,headerVars,tList,nil}
err := templates.ExecuteTemplate(w,"overview.html",pi)
if err != nil {
InternalError(err,w,r)
@@ -80,7 +82,7 @@ func route_overview(w http.ResponseWriter, r *http.Request){
}
func route_custom_page(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -90,14 +92,14 @@ func route_custom_page(w http.ResponseWriter, r *http.Request){
return
}
- err := templates.ExecuteTemplate(w,"page_" + name,Page{"Page",user,noticeList,tList,nil})
+ err := templates.ExecuteTemplate(w,"page_" + name,Page{"Page",user,headerVars,tList,nil})
if err != nil {
InternalError(err,w,r)
}
}
func route_topics(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -160,11 +162,15 @@ func route_topics(w http.ResponseWriter, r *http.Request){
}
rows.Close()
- pi := TopicsPage{"Topic List",user,noticeList,topicList,nil}
+ pi := TopicsPage{"Topic List",user,headerVars,topicList,extData}
if template_topics_handle != nil {
template_topics_handle(pi,w)
} else {
- err = templates.ExecuteTemplate(w,"topics.html",pi)
+ mapping, ok := themes[defaultTheme].TemplatesMap["topic"]
+ if !ok {
+ mapping = "topic"
+ }
+ err = templates.ExecuteTemplate(w,mapping + ".html", pi)
if err != nil {
InternalError(err,w,r)
}
@@ -179,7 +185,7 @@ func route_forum(w http.ResponseWriter, r *http.Request, sfid string){
return
}
- user, noticeList, ok := ForumSessionCheck(w,r,fid)
+ user, headerVars, ok := ForumSessionCheck(w,r,fid)
if !ok {
return
}
@@ -240,11 +246,15 @@ func route_forum(w http.ResponseWriter, r *http.Request, sfid string){
}
rows.Close()
- pi := ForumPage{forums[fid].Name,user,noticeList,topicList,forums[fid],page,last_page,nil}
+ pi := ForumPage{forums[fid].Name,user,headerVars,topicList,forums[fid],page,last_page,extData}
if template_forum_handle != nil {
template_forum_handle(pi,w)
} else {
- err = templates.ExecuteTemplate(w,"forum.html",pi)
+ mapping, ok := themes[defaultTheme].TemplatesMap["forum"]
+ if !ok {
+ mapping = "forum"
+ }
+ err = templates.ExecuteTemplate(w,mapping + ".html", pi)
if err != nil {
InternalError(err,w,r)
}
@@ -252,7 +262,7 @@ func route_forum(w http.ResponseWriter, r *http.Request, sfid string){
}
func route_forums(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -278,11 +288,15 @@ func route_forums(w http.ResponseWriter, r *http.Request){
}
}
- pi := ForumsPage{"Forum List",user,noticeList,forumList,nil}
+ pi := ForumsPage{"Forum List",user,headerVars,forumList,extData}
if template_forums_handle != nil {
template_forums_handle(pi,w)
} else {
- err := templates.ExecuteTemplate(w,"forums.html",pi)
+ mapping, ok := themes[defaultTheme].TemplatesMap["forums"]
+ if !ok {
+ mapping = "forums"
+ }
+ err = templates.ExecuteTemplate(w,mapping + ".html", pi)
if err != nil {
InternalError(err,w,r)
}
@@ -312,7 +326,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
}
topic.Css = no_css_tmpl
- user, noticeList, ok := ForumSessionCheck(w,r,topic.ParentID)
+ user, headerVars, ok := ForumSessionCheck(w,r,topic.ParentID)
if !ok {
return
}
@@ -450,11 +464,15 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
}
rows.Close()
- tpage := TopicPage{topic.Title,user,noticeList,replyList,topic,page,last_page,nil}
+ tpage := TopicPage{topic.Title,user,headerVars,replyList,topic,page,last_page,extData}
if template_topic_handle != nil {
template_topic_handle(tpage,w)
} else {
- err = templates.ExecuteTemplate(w,"topic.html", tpage)
+ mapping, ok := themes[defaultTheme].TemplatesMap["topic"]
+ if !ok {
+ mapping = "topic"
+ }
+ err = templates.ExecuteTemplate(w,mapping + ".html", tpage)
if err != nil {
InternalError(err,w,r)
}
@@ -462,7 +480,7 @@ func route_topic_id(w http.ResponseWriter, r *http.Request){
}
func route_profile(w http.ResponseWriter, r *http.Request){
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -543,7 +561,7 @@ func route_profile(w http.ResponseWriter, r *http.Request){
return
}
- ppage := ProfilePage{puser.Name + "'s Profile",user,noticeList,replyList,*puser,false}
+ ppage := ProfilePage{puser.Name + "'s Profile",user,headerVars,replyList,*puser,extData}
if template_profile_handle != nil {
template_profile_handle(ppage,w)
} else {
@@ -565,7 +583,7 @@ func route_topic_create(w http.ResponseWriter, r *http.Request, sfid string){
}
}
- user, noticeList, ok := ForumSessionCheck(w,r,fid)
+ user, headerVars, ok := ForumSessionCheck(w,r,fid)
if !ok {
return
}
@@ -582,7 +600,7 @@ func route_topic_create(w http.ResponseWriter, r *http.Request, sfid string){
}
}
- ctpage := CreateTopicPage{"Create Topic",user,noticeList,forumList,fid,nil}
+ ctpage := CreateTopicPage{"Create Topic",user,headerVars,forumList,fid,extData}
if template_create_topic_handle != nil {
template_create_topic_handle(ctpage,w)
} else {
@@ -1151,7 +1169,7 @@ func route_report_submit(w http.ResponseWriter, r *http.Request, sitem_id string
}
func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1159,12 +1177,12 @@ func route_account_own_edit_critical(w http.ResponseWriter, r *http.Request) {
LocalError("You need to login to edit your account.",w,r,user)
return
}
- pi := Page{"Edit Password",user,noticeList,tList,nil}
+ pi := Page{"Edit Password",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"account-own-edit.html", pi)
}
func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1222,13 +1240,13 @@ func route_account_own_edit_critical_submit(w http.ResponseWriter, r *http.Reque
return
}
- noticeList = append(noticeList,"Your password was successfully updated")
- pi := Page{"Edit Password",user,noticeList,tList,nil}
+ headerVars.NoticeList = append(headerVars.NoticeList,"Your password was successfully updated")
+ pi := Page{"Edit Password",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"account-own-edit.html", pi)
}
func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1236,7 +1254,7 @@ func route_account_own_edit_avatar(w http.ResponseWriter, r *http.Request) {
LocalError("You need to login to edit your account.",w,r,user)
return
}
- pi := Page{"Edit Avatar",user,noticeList,tList,nil}
+ pi := Page{"Edit Avatar",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"account-own-edit-avatar.html",pi)
}
@@ -1247,7 +1265,7 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
}
r.Body = http.MaxBytesReader(w, r.Body, int64(max_request_size))
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1328,13 +1346,13 @@ func route_account_own_edit_avatar_submit(w http.ResponseWriter, r *http.Request
return
}
- noticeList = append(noticeList, "Your avatar was successfully updated")
- pi := Page{"Edit Avatar",user,noticeList,tList,nil}
+ headerVars.NoticeList = append(headerVars.NoticeList, "Your avatar was successfully updated")
+ pi := Page{"Edit Avatar",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"account-own-edit-avatar.html", pi)
}
func route_account_own_edit_username(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1342,12 +1360,12 @@ func route_account_own_edit_username(w http.ResponseWriter, r *http.Request) {
LocalError("You need to login to edit your account.",w,r,user)
return
}
- pi := Page{"Edit Username",user,noticeList,tList,user.Name}
+ pi := Page{"Edit Username",user,headerVars,tList,user.Name}
templates.ExecuteTemplate(w,"account-own-edit-username.html",pi)
}
func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1375,13 +1393,13 @@ func route_account_own_edit_username_submit(w http.ResponseWriter, r *http.Reque
return
}
- noticeList = append(noticeList,"Your username was successfully updated")
- pi := Page{"Edit Username",user,noticeList,tList,nil}
+ headerVars.NoticeList = append(headerVars.NoticeList,"Your username was successfully updated")
+ pi := Page{"Edit Username",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"account-own-edit-username.html", pi)
}
func route_account_own_edit_email(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1424,14 +1442,14 @@ func route_account_own_edit_email(w http.ResponseWriter, r *http.Request) {
}
if !enable_emails {
- noticeList = append(noticeList,"The mail system is currently disabled.")
+ headerVars.NoticeList = append(headerVars.NoticeList,"The mail system is currently disabled.")
}
- pi := Page{"Email Manager",user,noticeList,emailList,nil}
+ pi := Page{"Email Manager",user,headerVars,emailList,nil}
templates.ExecuteTemplate(w,"account-own-edit-email.html", pi)
}
func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1497,10 +1515,10 @@ func route_account_own_edit_email_token_submit(w http.ResponseWriter, r *http.Re
}
if !enable_emails {
- noticeList = append(noticeList,"The mail system is currently disabled.")
+ headerVars.NoticeList = append(headerVars.NoticeList,"The mail system is currently disabled.")
}
- noticeList = append(noticeList,"Your email was successfully verified")
- pi := Page{"Email Manager",user,noticeList,emailList,nil}
+ headerVars.NoticeList = append(headerVars.NoticeList,"Your email was successfully verified")
+ pi := Page{"Email Manager",user,headerVars,emailList,nil}
templates.ExecuteTemplate(w,"account-own-edit-email.html", pi)
}
@@ -1529,7 +1547,7 @@ func route_logout(w http.ResponseWriter, r *http.Request) {
}
func route_login(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1537,7 +1555,7 @@ func route_login(w http.ResponseWriter, r *http.Request) {
LocalError("You're already logged in.",w,r,user)
return
}
- pi := Page{"Login",user,noticeList,tList,nil}
+ pi := Page{"Login",user,headerVars,tList,nil}
templates.ExecuteTemplate(w,"login.html",pi)
}
@@ -1633,7 +1651,7 @@ func route_login_submit(w http.ResponseWriter, r *http.Request) {
}
func route_register(w http.ResponseWriter, r *http.Request) {
- user, noticeList, ok := SessionCheck(w,r)
+ user, headerVars, ok := SessionCheck(w,r)
if !ok {
return
}
@@ -1641,7 +1659,7 @@ func route_register(w http.ResponseWriter, r *http.Request) {
LocalError("You're already logged in.",w,r,user)
return
}
- templates.ExecuteTemplate(w,"register.html",Page{"Registration",user,noticeList,tList,nil})
+ templates.ExecuteTemplate(w,"register.html",Page{"Registration",user,headerVars,tList,nil})
}
func route_register_submit(w http.ResponseWriter, r *http.Request) {
diff --git a/run.bat b/run.bat
index 05e9f277..4cc1c433 100644
--- a/run.bat
+++ b/run.bat
@@ -6,7 +6,6 @@ if %errorlevel% neq 0 (
exit /b %errorlevel%
)
-
echo Building the router generator
go build ./router_gen
if %errorlevel% neq 0 (
diff --git a/template_forum.go b/template_forum.go
index 486f84a9..2db4e46e 100644
--- a/template_forum.go
+++ b/template_forum.go
@@ -1,5 +1,6 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
import "io"
import "strconv"
@@ -16,8 +17,24 @@ func template_forum(tmpl_forum_vars ForumPage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_forum_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_forum_vars.CurrentUser.Session))
+if len(tmpl_forum_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_forum_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_forum_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_forum_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_forum_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_forum_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_forum_vars.NoticeList) != 0 {
-for _, item := range tmpl_forum_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_forum_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_forum_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
if tmpl_forum_vars.Page > 1 {
diff --git a/template_forums.go b/template_forums.go
index 50a26944..45cb1fa7 100644
--- a/template_forums.go
+++ b/template_forums.go
@@ -1,8 +1,9 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
-import "strconv"
import "io"
+import "strconv"
func init() {
template_forums_handle = template_forums
@@ -16,8 +17,24 @@ func template_forums(tmpl_forums_vars ForumsPage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_forums_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_forums_vars.CurrentUser.Session))
+if len(tmpl_forums_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_forums_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_forums_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_forums_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_forums_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_forums_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_forums_vars.NoticeList) != 0 {
-for _, item := range tmpl_forums_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_forums_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_forums_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
w.Write(forums_0)
diff --git a/template_list.go b/template_list.go
index d38a665a..d822ca10 100644
--- a/template_list.go
+++ b/template_list.go
@@ -6,9 +6,21 @@ var header_0 []byte = []byte(`
`)
var header_1 []byte = []byte(`
+ `)
+var header_2 []byte = []byte(`
+
+ `)
+var header_4 []byte = []byte(`
+ `)
+var header_5 []byte = []byte(`
+
+ `)
+var header_7 []byte = []byte(`
@@ -51,11 +63,11 @@ var menu_7 []byte = []byte(`
`)
-var header_3 []byte = []byte(`
+var header_9 []byte = []byte(`
`)
-var header_4 []byte = []byte(`
`)
-var header_5 []byte = []byte(`
`)
+var header_10 []byte = []byte(`
`)
+var header_11 []byte = []byte(`
`)
var topic_0 []byte = []byte(`
`)
diff --git a/template_profile.go b/template_profile.go
index 7aabdd5d..3c8474ca 100644
--- a/template_profile.go
+++ b/template_profile.go
@@ -1,5 +1,6 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
import "strconv"
import "io"
@@ -16,8 +17,24 @@ func template_profile(tmpl_profile_vars ProfilePage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_profile_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
+if len(tmpl_profile_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_profile_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_profile_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_profile_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_profile_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_profile_vars.NoticeList) != 0 {
-for _, item := range tmpl_profile_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_profile_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_profile_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
w.Write(profile_0)
diff --git a/template_topic.go b/template_topic.go
index 016d17cd..08f8a202 100644
--- a/template_topic.go
+++ b/template_topic.go
@@ -1,5 +1,6 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
import "io"
import "strconv"
@@ -16,8 +17,24 @@ func template_topic(tmpl_topic_vars TopicPage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_topic_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
+if len(tmpl_topic_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_topic_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_topic_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_topic_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_topic_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_topic_vars.NoticeList) != 0 {
-for _, item := range tmpl_topic_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_topic_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_topic_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
if tmpl_topic_vars.Page > 1 {
diff --git a/template_topic_alt.go b/template_topic_alt.go
index e9359bab..68d50b68 100644
--- a/template_topic_alt.go
+++ b/template_topic_alt.go
@@ -1,5 +1,6 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
import "io"
import "strconv"
@@ -16,8 +17,24 @@ func template_topic_alt(tmpl_topic_alt_vars TopicPage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_topic_alt_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
+if len(tmpl_topic_alt_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_topic_alt_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_topic_alt_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_topic_alt_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_topic_alt_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_topic_alt_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_topic_alt_vars.NoticeList) != 0 {
-for _, item := range tmpl_topic_alt_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_topic_alt_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_topic_alt_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
if tmpl_topic_alt_vars.Page > 1 {
diff --git a/template_topics.go b/template_topics.go
index 6d5eb24d..3a010ea8 100644
--- a/template_topics.go
+++ b/template_topics.go
@@ -1,5 +1,6 @@
-// Code generated by. DO NOT EDIT.
+// 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. */
+// +build !no_templategen
package main
import "io"
import "strconv"
@@ -16,8 +17,24 @@ func template_topics(tmpl_topics_vars TopicsPage, w io.Writer) {
w.Write(header_0)
w.Write([]byte(tmpl_topics_vars.Title))
w.Write(header_1)
-w.Write([]byte(tmpl_topics_vars.CurrentUser.Session))
+if len(tmpl_topics_vars.Header.Stylesheets) != 0 {
+for _, item := range tmpl_topics_vars.Header.Stylesheets {
w.Write(header_2)
+w.Write([]byte(item))
+w.Write(header_3)
+}
+}
+w.Write(header_4)
+if len(tmpl_topics_vars.Header.Scripts) != 0 {
+for _, item := range tmpl_topics_vars.Header.Scripts {
+w.Write(header_5)
+w.Write([]byte(item))
+w.Write(header_6)
+}
+}
+w.Write(header_7)
+w.Write([]byte(tmpl_topics_vars.CurrentUser.Session))
+w.Write(header_8)
w.Write(menu_0)
if tmpl_topics_vars.CurrentUser.Loggedin {
w.Write(menu_1)
@@ -33,12 +50,12 @@ w.Write(menu_5)
w.Write(menu_6)
}
w.Write(menu_7)
-w.Write(header_3)
-if len(tmpl_topics_vars.NoticeList) != 0 {
-for _, item := range tmpl_topics_vars.NoticeList {
-w.Write(header_4)
+w.Write(header_9)
+if len(tmpl_topics_vars.Header.NoticeList) != 0 {
+for _, item := range tmpl_topics_vars.Header.NoticeList {
+w.Write(header_10)
w.Write([]byte(item))
-w.Write(header_5)
+w.Write(header_11)
}
}
w.Write(topics_0)
diff --git a/templates.go b/templates.go
index 805763f9..b9c74433 100644
--- a/templates.go
+++ b/templates.go
@@ -75,7 +75,7 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
"multiply": true,
"divide": true,
}
-
+
c.importMap = map[string]string{
"io":"io",
"strconv":"strconv",
@@ -86,17 +86,17 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
c.stats = make(map[string]int)
c.expectsInt = expectsInt
holdreflect := reflect.ValueOf(expectsInt)
-
+
res, err := ioutil.ReadFile(dir + name)
if err != nil {
log.Fatal(err)
}
-
+
content := string(res)
if minify_templates {
content = minify(content)
}
-
+
tree := parse.New(name, c.funcMap)
var treeSet map[string]*parse.Tree = make(map[string]*parse.Tree)
tree, err = tree.Parse(content,"{{","}}", treeSet, c.funcMap)
@@ -106,13 +106,13 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
if super_debug {
fmt.Println(name)
}
-
+
out = ""
fname := strings.TrimSuffix(name, filepath.Ext(name))
c.tlist = make(map[string]*parse.Tree)
c.tlist[fname] = tree
varholder := "tmpl_" + fname + "_vars"
-
+
if super_debug {
fmt.Println(c.tlist)
}
@@ -124,18 +124,18 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
}
c.FragmentCursor = make(map[string]int)
c.FragmentCursor[fname] = 0
-
+
subtree := c.tlist[fname]
if super_debug {
fmt.Println(subtree.Root)
}
-
+
treeLength := len(subtree.Root.Nodes)
for index, node := range subtree.Root.Nodes {
if super_debug {
fmt.Println("Node: " + node.String())
}
-
+
c.previousNode = c.currentNode
c.currentNode = node.Type()
if treeLength != (index + 1) {
@@ -143,38 +143,38 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
}
out += c.compile_switch(varholder, holdreflect, fname, node)
}
-
+
var importList string
if c.doImports {
for _, item := range c.importMap {
importList += "import \"" + item + "\"\n"
}
}
-
+
var varString string
for _, varItem := range c.varList {
varString += "var " + varItem.Name + " " + varItem.Type + " = " + varItem.Destination + "\n"
}
-
- fout := "// Code generated by. DO NOT EDIT.\n/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */\n"
- fout += "package main\n" + importList + c.pVarList + "\n"
+
+ fout := "// Code generated by Gosora. More below:\n/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */\n"
+ fout += "// +build !no_templategen\npackage main\n" + importList + c.pVarList + "\n"
fout += "func init() {\n\ttemplate_" + fname +"_handle = template_" + fname + "\n\t//o_template_" + fname +"_handle = template_" + fname + "\n\tctemplates = append(ctemplates,\"" + fname + "\")\n\ttmpl_ptr_map[\"" + fname + "\"] = &template_" + fname + "_handle\n\ttmpl_ptr_map[\"o_" + fname + "\"] = template_" + fname + "\n}\n\n"
fout += "func template_" + fname + "(tmpl_" + fname + "_vars " + expects + ", w io.Writer) {\n" + varString + out + "}\n"
-
+
fout = strings.Replace(fout,`))
w.Write([]byte(`," + ",-1)
fout = strings.Replace(fout,"` + `","",-1)
//spstr := "`([:space:]*)`"
//whitespace_writes := regexp.MustCompile(`(?s)w.Write\(\[\]byte\(`+spstr+`\)\)`)
//fout = whitespace_writes.ReplaceAllString(fout,"")
-
+
if debug {
for index, count := range c.stats {
fmt.Println(index + ": " + strconv.Itoa(count))
}
fmt.Println(" ")
}
-
+
if super_debug {
fmt.Println("Output!")
fmt.Println(fout)
@@ -203,7 +203,7 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
fmt.Println("If Node:")
fmt.Println("node.Pipe",node.Pipe)
}
-
+
var expr string
for _, cmd := range node.Pipe.Cmds {
if super_debug {
@@ -215,11 +215,11 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
fmt.Println("If Node Expression Step:",c.compile_varswitch(varholder, holdreflect, template_name, cmd))
}
}
-
+
if super_debug {
fmt.Println("If Node Expression:",expr)
}
-
+
c.previousNode = c.currentNode
c.currentNode = parse.NodeList
c.nextNode = -1
@@ -247,7 +247,7 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
fmt.Println("Range Node!")
fmt.Println(node.Pipe)
}
-
+
var outVal reflect.Value
for _, cmd := range node.Pipe.Cmds {
if super_debug {
@@ -255,19 +255,19 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
}
out, outVal = c.compile_reflectswitch(varholder, holdreflect, template_name, cmd)
}
-
+
if super_debug {
fmt.Println("Returned:",out)
fmt.Println("Range Kind Switch!")
}
-
+
switch outVal.Kind() {
case reflect.Map:
var item reflect.Value
for _, key := range outVal.MapKeys() {
item = outVal.MapIndex(key)
}
-
+
if node.ElseList != nil {
out = "if len(" + out + ") != 0 {\nfor _, item := range " + out + " {\n" + c.compile_switch("item", item, template_name, node.List) + "}\n} else {\n" + c.compile_switch("item", item, template_name, node.ElseList) + "}\n"
} else {
@@ -275,12 +275,11 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
}
case reflect.Slice:
item := outVal.Index(0)
-
out = "if len(" + out + ") != 0 {\nfor _, item := range " + out + " {\n" + c.compile_switch("item", item, template_name, node.List) + "}\n}"
case reflect.Invalid:
return ""
}
-
+
if node.ElseList != nil {
out += " else {\n" + c.compile_switch(varholder, holdreflect, template_name, node.ElseList) + "}\n"
} else {
@@ -323,22 +322,22 @@ func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.V
if super_debug {
fmt.Println("Field Node:",n.Ident)
}
-
+
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
cur := holdreflect
-
+
var varbit string
if cur.Kind() == reflect.Interface {
cur = cur.Elem()
varbit += ".(" + cur.Type().Name() + ")"
}
-
+
for _, id := range n.Ident {
if super_debug {
fmt.Println("Data Kind:",cur.Kind().String())
fmt.Println("Field Bit:",id)
}
-
+
cur = cur.FieldByName(id)
if cur.Kind() == reflect.Interface {
cur = cur.Elem()
@@ -359,7 +358,7 @@ func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.V
}
}
out = c.compile_varsub(varholder + varbit, cur)
-
+
for _, varItem := range c.varList {
if strings.HasPrefix(out, varItem.Destination) {
out = strings.Replace(out, varItem.Destination, varItem.Name, 1)
@@ -409,7 +408,7 @@ func (c *CTemplateSet) compile_varswitch(varholder string, holdreflect reflect.V
fmt.Println("Field Bit:",id)
}
}
-
+
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
return c.compile_boolsub(n.String(), varholder, template_name, holdreflect)
case *parse.ChainNode:
@@ -442,7 +441,7 @@ func (c *CTemplateSet) compile_varswitch(varholder string, holdreflect reflect.V
fmt.Println("Args:",node.Args)
}
out += c.compile_identswitch_n(varholder, holdreflect, template_name, node)
-
+
if super_debug {
fmt.Println("Out:",out)
}
@@ -467,7 +466,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
if super_debug {
fmt.Println("in compile_identswitch")
}
-
+
//var outbuf map[int]string
ArgLoop:
for pos := 0; pos < len(node.Args); pos++ {
@@ -494,26 +493,26 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
panic("or is missing a right operand")
return out, val
}
-
+
left := c.compile_boolsub(node.Args[pos - 1].String(), varholder, template_name, holdreflect)
_, funcExists := c.funcMap[node.Args[pos + 1].String()]
-
+
var right string
if !funcExists {
right = c.compile_boolsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
}
-
+
out += left + " || " + right
-
+
if super_debug {
fmt.Println("Left operand:",node.Args[pos - 1])
fmt.Println("Right operand:",node.Args[pos + 1])
}
-
+
if !funcExists {
pos++
}
-
+
if super_debug {
fmt.Println("pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
@@ -533,26 +532,26 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
panic("and is missing a right operand")
return out, val
}
-
+
left := c.compile_boolsub(node.Args[pos - 1].String(), varholder, template_name, holdreflect)
_, funcExists := c.funcMap[node.Args[pos + 1].String()]
-
+
var right string
if !funcExists {
right = c.compile_boolsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
}
-
+
out += left + " && " + right
-
+
if super_debug {
fmt.Println("Left operand:",node.Args[pos - 1])
fmt.Println("Right operand:",node.Args[pos + 1])
}
-
+
if !funcExists {
pos++
}
-
+
if super_debug {
fmt.Println("pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
@@ -602,7 +601,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
case "add":
param1, val2 := c.compile_if_varsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
param2, val3 := c.compile_if_varsub(node.Args[pos + 2].String(), varholder, template_name, holdreflect)
-
+
if val2.IsValid() {
val = val2
} else if val3.IsValid() {
@@ -611,7 +610,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
numSample := 1
val = reflect.ValueOf(numSample)
}
-
+
out += param1 + " + " + param2
if super_debug {
fmt.Println("add")
@@ -622,7 +621,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
case "subtract":
param1, val2 := c.compile_if_varsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
param2, val3 := c.compile_if_varsub(node.Args[pos + 2].String(), varholder, template_name, holdreflect)
-
+
if val2.IsValid() {
val = val2
} else if val3.IsValid() {
@@ -631,7 +630,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
numSample := 1
val = reflect.ValueOf(numSample)
}
-
+
out += param1 + " - " + param2
if super_debug {
fmt.Println("subtract")
@@ -642,7 +641,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
case "divide":
param1, val2 := c.compile_if_varsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
param2, val3 := c.compile_if_varsub(node.Args[pos + 2].String(), varholder, template_name, holdreflect)
-
+
if val2.IsValid() {
val = val2
} else if val3.IsValid() {
@@ -651,7 +650,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
numSample := 1
val = reflect.ValueOf(numSample)
}
-
+
out += param1 + " / " + param2
if super_debug {
fmt.Println("divide")
@@ -662,7 +661,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
case "multiply":
param1, val2 := c.compile_if_varsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
param2, val3 := c.compile_if_varsub(node.Args[pos + 2].String(), varholder, template_name, holdreflect)
-
+
if val2.IsValid() {
val = val2
} else if val3.IsValid() {
@@ -671,7 +670,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
numSample := 1
val = reflect.ValueOf(numSample)
}
-
+
out += param1 + " * " + param2
if super_debug {
fmt.Println("multiply")
@@ -692,7 +691,7 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
out += c.compile_if_varsub_n(id.String(), varholder, template_name, holdreflect)
}
}
-
+
//for _, outval := range outbuf {
// out += outval
//}
@@ -746,7 +745,7 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
if varname[0] != '.' && varname[0] != '$' {
return varname, cur
}
-
+
bits := strings.Split(varname,".")
if varname[0] == '$' {
var res VarItemReflect
@@ -757,7 +756,7 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
}
out += res.Destination
cur = res.Value
-
+
if cur.Kind() == reflect.Interface {
cur = cur.Elem()
}
@@ -770,22 +769,22 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
}
}
bits[0] = strings.TrimPrefix(bits[0],"$")
-
+
if super_debug {
fmt.Println("Cur Kind:",cur.Kind())
fmt.Println("Cur Type:",cur.Type().Name())
}
-
+
for _, bit := range bits {
if super_debug {
fmt.Println("Variable Field!")
fmt.Println(bit)
}
-
+
if bit == "" {
continue
}
-
+
cur = cur.FieldByName(bit)
if cur.Kind() == reflect.Interface {
cur = cur.Elem()
@@ -793,38 +792,38 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
} else {
out += "." + bit
}
-
+
if super_debug {
fmt.Println("Data Kind:",cur.Kind())
fmt.Println("Data Type:",cur.Type().Name())
}
}
-
+
if super_debug {
fmt.Println("Out Value:",out)
fmt.Println("Out Kind:",cur.Kind())
fmt.Println("Out Type:",cur.Type().Name())
}
-
+
for _, varItem := range c.varList {
if strings.HasPrefix(out, varItem.Destination) {
out = strings.Replace(out, varItem.Destination, varItem.Name, 1)
}
}
-
+
if super_debug {
fmt.Println("Out Value:",out)
fmt.Println("Out Kind:",cur.Kind())
fmt.Println("Out Type:",cur.Type().Name())
}
-
+
_, ok := c.stats[out]
if ok {
c.stats[out]++
} else {
c.stats[out] = 1
}
-
+
return out, cur
}
@@ -856,18 +855,18 @@ func (c *CTemplateSet) compile_varsub(varname string, val reflect.Value) string
varname = strings.Replace(varname, varItem.Destination, varItem.Name, 1)
}
}
-
+
_, ok := c.stats[varname]
if ok {
c.stats[varname]++
} else {
c.stats[varname] = 1
}
-
+
if val.Kind() == reflect.Interface {
val = val.Elem()
}
-
+
switch val.Kind() {
case reflect.Int:
return "w.Write([]byte(strconv.Itoa(" + varname + ")))\n"
@@ -894,7 +893,7 @@ func (c *CTemplateSet) compile_subtemplate(pvarholder string, pholdreflect refle
fmt.Println("in compile_subtemplate")
fmt.Println("Template Node: " + node.Name)
}
-
+
fname := strings.TrimSuffix(node.Name, filepath.Ext(node.Name))
varholder := "tmpl_" + fname + "_vars"
var holdreflect reflect.Value
@@ -914,40 +913,40 @@ func (c *CTemplateSet) compile_subtemplate(pvarholder string, pholdreflect refle
}
}
}
-
+
res, err := ioutil.ReadFile(c.dir + node.Name)
if err != nil {
log.Fatal(err)
}
-
+
content := string(res)
if minify_templates {
content = minify(content)
}
-
+
tree := parse.New(node.Name, c.funcMap)
var treeSet map[string]*parse.Tree = make(map[string]*parse.Tree)
tree, err = tree.Parse(content,"{{","}}", treeSet, c.funcMap)
if err != nil {
log.Fatal(err)
}
-
+
c.tlist[fname] = tree
subtree := c.tlist[fname]
if super_debug {
fmt.Println(subtree.Root)
}
-
+
c.localVars[fname] = make(map[string]VarItemReflect)
c.localVars[fname]["."] = VarItemReflect{".",varholder,holdreflect}
c.FragmentCursor[fname] = 0
-
+
treeLength := len(subtree.Root.Nodes)
for index, node := range subtree.Root.Nodes {
if super_debug {
fmt.Println("Node:",node.String())
}
-
+
c.previousNode = c.currentNode
c.currentNode = node.Type()
if treeLength != (index + 1) {
@@ -955,7 +954,7 @@ func (c *CTemplateSet) compile_subtemplate(pvarholder string, pholdreflect refle
}
out += c.compile_switch(varholder, holdreflect, fname, node)
}
- return out
+ return out
}
func (c *CTemplateSet) compile_command(*parse.CommandNode) (out string) {
diff --git a/templates/header.html b/templates/header.html
index efc9e7c4..474ec461 100644
--- a/templates/header.html
+++ b/templates/header.html
@@ -3,7 +3,13 @@
{{.Title}}
+ {{range .Header.Stylesheets}}
+
+ {{end}}
+ {{range .Header.Scripts}}
+
+ {{end}}
@@ -13,4 +19,4 @@
{{template "menu.html" .}}
-{{range .NoticeList}}
{{.}}
{{end}}
\ No newline at end of file
+{{range .Header.NoticeList}}
{{.}}
{{end}}
diff --git a/themes.go b/themes.go
index 98f1a5f2..2b39b41c 100644
--- a/themes.go
+++ b/themes.go
@@ -34,6 +34,7 @@ type Theme struct
URL string
Settings map[string]ThemeSetting
Templates []TemplateMapping
+ TemplatesMap map[string]string // TO-DO: Make template mapping work without the template compiler
// This variable should only be set and unset by the system, not the theme meta file
Active bool
@@ -73,6 +74,13 @@ func LoadThemes() error {
continue
}
+ theme.TemplatesMap = make(map[string]string)
+ if theme.Templates != nil {
+ for _, themeTmpl := range theme.Templates {
+ theme.TemplatesMap[themeTmpl.Name] = themeTmpl.Source
+ }
+ }
+
if defaultThemeSwitch {
log.Print("Loading the theme '" + theme.Name + "'")
theme.Active = true
@@ -115,7 +123,6 @@ func init_themes() {
log.Fatal(err)
}
-
theme.Active = false // Set this to false, just in case someone explicitly overrode this value in the JSON file
if theme.FullImage != "" {
@@ -179,7 +186,7 @@ func map_theme_templates(theme Theme) {
dest_tmpl_ptr, ok := tmpl_ptr_map[themeTmpl.Name]
if !ok {
- log.Fatal("The destination template doesn't exist!")
+ return
}
source_tmpl_ptr, ok := tmpl_ptr_map[themeTmpl.Source]
if !ok {
diff --git a/themes/cosmo-conflux/public/main.css b/themes/cosmo-conflux/public/main.css
index e9a9f199..180c6569 100644
--- a/themes/cosmo-conflux/public/main.css
+++ b/themes/cosmo-conflux/public/main.css
@@ -195,8 +195,8 @@ hr { color: silver; border: 1px solid silver; }
.rowhead, .colhead {
background: #ce2424;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#f97779), to(#ce2424));
- background: -moz-linear-gradient(#f97779, #ce2424);
- background: linear-gradient(#f97779, #ce2424);
+ background: -moz-linear-gradient(#f97779, #ce2424);
+ background: linear-gradient(#f97779, #ce2424);
border: 0px solid #b32424;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
@@ -284,8 +284,8 @@ hr { color: silver; border: 1px solid silver; }
padding-bottom: 12px;
font-size: 16px;
}
-.grid_istat { margin-bottom: 5px; }
+.grid_istat { margin-bottom: 5px; }
.stat_green { background-color: lightgreen; border-color: green; }
.stat_orange { background-color: #ffe4b3; border-color: orange; }
.stat_red { background-color: #ffb2b2; border-color: red; }
@@ -646,62 +646,6 @@ blockquote p {
.next_button { right: 14px; }
.head_tag_upshift { display: none; }
-/* Control Panel */
-.tag-mini {
- margin-left: 0px;
- padding-left: 0px;
- padding-right: 0px;
- padding-top: 2px;
- padding-bottom: 2px;
-
- color: black;
- font-size: 12px;
-}
-
-.panel_tag {
- padding-left: 0px;
- padding-right: 0px;
- border: none;
- background: none;
- color: #202020;
- font-size: 14px;
-}
-
-.panel_floater { float: right; }
-#panel_groups > .rowitem > .panel_floater { float: none; }
-#panel_groups > .rowitem > .panel_floater > .panel_right_button { float: right; }
-#panel_forums > .rowitem > .panel_floater { float: none; }
-#panel_forums > .rowitem > .panel_floater > .panel_buttons { float: right; }
-
-.panel_rank_tag, .forum_preset, .forum_active {
- float: none;
- color: #202020 !important;
- font-size: 11px;
-}
-.panel_rank_tag_admin:before { content: "Admins"; }
-.panel_rank_tag_mod:before { content: "Mods"; }
-.panel_rank_tag_banned:before { content: "Banned"; }
-.panel_rank_tag_guest:before { content: "Guests"; }
-.panel_rank_tag_member:before { content: "Members"; }
-
-.forum_preset_announce:after { content: "Announcements"; }
-.forum_preset_members:after { content: "Member Only"; }
-.forum_preset_staff:after { content: "Staff Only"; }
-.forum_preset_admins:after { content: "Admin Only"; }
-.forum_preset_archive:after { content: "Archive"; }
-.forum_preset_all:after { content: "Public"; }
-.forum_preset_custom, .forum_preset_ { display: none !important; }
-.forum_active_Hide:before { content: "Hidden"; }
-.forum_active_Hide + .forum_preset:before { content: " | "; }
-.forum_active_Show { display: none !important; }
-
-.perm_preset_no_access:before { content: "No Access"; color: maroon; }
-.perm_preset_read_only:before { content: "Read Only"; color: green; }
-.perm_preset_can_post:before { content: "Can Post"; color: green; }
-.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
-.perm_preset_custom:before { content: "Custom"; color: black; }
-.perm_preset_default:before { content: "Default"; }
-
/* Responsive Layout */
/* Anything that isn't a small mobile */
@media(min-width: 501px) {
diff --git a/themes/cosmo-conflux/public/panel.css b/themes/cosmo-conflux/public/panel.css
new file mode 100644
index 00000000..a41e9989
--- /dev/null
+++ b/themes/cosmo-conflux/public/panel.css
@@ -0,0 +1,69 @@
+/* Control Panel */
+
+.tag-mini {
+ margin-left: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+
+ color: black;
+ font-size: 12px;
+}
+
+.panel_tag {
+ padding-left: 0px;
+ padding-right: 0px;
+ border: none;
+ background: none;
+ color: #202020;
+ font-size: 14px;
+}
+
+.panel_floater {
+ float: right;
+}
+#panel_groups > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_groups > .rowitem > .panel_floater > .panel_right_button {
+ float: right;
+}
+#panel_forums > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_forums > .rowitem > .panel_floater > .panel_buttons {
+ float: right;
+}
+#panel_forums > .rowitem > span > .forum_name {
+ margin-right: 4px;
+}
+
+.panel_rank_tag, .forum_preset, .forum_active {
+ float: none;
+ color: #202020 !important;
+ font-size: 11px;
+}
+.panel_rank_tag_admin:before { content: "Admins"; }
+.panel_rank_tag_mod:before { content: "Mods"; }
+.panel_rank_tag_banned:before { content: "Banned"; }
+.panel_rank_tag_guest:before { content: "Guests"; }
+.panel_rank_tag_member:before { content: "Members"; }
+
+.forum_preset_announce:after { content: "Announcements"; }
+.forum_preset_members:after { content: "Member Only"; }
+.forum_preset_staff:after { content: "Staff Only"; }
+.forum_preset_admins:after { content: "Admin Only"; }
+.forum_preset_archive:after { content: "Archive"; }
+.forum_preset_all:after { content: "Public"; }
+.forum_preset_custom, .forum_preset_ { display: none !important; }
+.forum_active_Hide:before { content: "Hidden"; }
+.forum_active_Hide + .forum_preset:before { content: " | "; }
+.forum_active_Show { display: none !important; }
+
+.perm_preset_no_access:before { content: "No Access"; color: maroon; }
+.perm_preset_read_only:before { content: "Read Only"; color: green; }
+.perm_preset_can_post:before { content: "Can Post"; color: green; }
+.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
+.perm_preset_custom:before { content: "Custom"; color: black; }
+.perm_preset_default:before { content: "Default"; }
diff --git a/themes/cosmo/public/main.css b/themes/cosmo/public/main.css
index 8471bb62..1e20b1a5 100644
--- a/themes/cosmo/public/main.css
+++ b/themes/cosmo/public/main.css
@@ -1,4 +1,4 @@
-/* AtomBB Cosmo Port. Copyright Azareal 2017 */
+/* AtomBB Cosmo Port. Copyright Azareal 2017 - 2018 */
/* I'm currently converting the CSS over from one of my previous projects. Don't use this yet! */
* {
@@ -182,8 +182,8 @@ hr { color: silver; border: 1px solid silver; }
.rowhead, .colhead {
background: #ce2424;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#f97779), to(#ce2424));
- background: -moz-linear-gradient(#f97779, #ce2424);
- background: url('/static/fabric-base-simple-alpha.png'), linear-gradient(#f97779, #ce2424);
+ background: -moz-linear-gradient(#f97779, #ce2424);
+ background: url('/static/fabric-base-simple-alpha.png'), linear-gradient(#f97779, #ce2424);
border: 0px solid #b32424;
border-top-right-radius: 5px;
border-top-left-radius: 5px;
@@ -271,8 +271,8 @@ hr { color: silver; border: 1px solid silver; }
padding-bottom: 12px;
font-size: 16px;
}
-.grid_istat { margin-bottom: 5px; }
+.grid_istat { margin-bottom: 5px; }
.stat_green { background-color: lightgreen; border-color: green; }
.stat_orange { background-color: #ffe4b3; border-color: orange; }
.stat_red { background-color: #ffb2b2; border-color: red; }
@@ -654,8 +654,8 @@ blockquote p {
border-style: dotted;
border-color: #505050;
padding: 0px;
- padding-left: 5px;
- padding-right: 5px;
+ padding-left: 5px;
+ padding-right: 5px;
z-index: 100;
}
@@ -671,62 +671,6 @@ blockquote p {
.next_button { right: 14px; }
.head_tag_upshift { display: none !important; }
-/* Control Panel */
-.tag-mini {
- margin-left: 0px;
- padding-left: 0px;
- padding-right: 0px;
- padding-top: 2px;
- padding-bottom: 2px;
-
- color: black;
- font-size: 12px;
-}
-
-.panel_tag {
- padding-left: 0px;
- padding-right: 0px;
- border: none;
- background: none;
- color: #202020;
- font-size: 14px;
-}
-
-.panel_floater { float: right; }
-#panel_groups > .rowitem > .panel_floater { float: none; }
-#panel_groups > .rowitem > .panel_floater > .panel_right_button { float: right; }
-#panel_forums > .rowitem > .panel_floater { float: none; }
-#panel_forums > .rowitem > .panel_floater > .panel_buttons { float: right; }
-
-.panel_rank_tag, .forum_preset, .forum_active {
- float: none;
- color: #202020 !important;
- font-size: 11px;
-}
-.panel_rank_tag_admin:before { content: "Admins"; }
-.panel_rank_tag_mod:before { content: "Mods"; }
-.panel_rank_tag_banned:before { content: "Banned"; }
-.panel_rank_tag_guest:before { content: "Guests"; }
-.panel_rank_tag_member:before { content: "Members"; }
-
-.forum_preset_announce:after { content: "Announcements"; }
-.forum_preset_members:after { content: "Member Only"; }
-.forum_preset_staff:after { content: "Staff Only"; }
-.forum_preset_admins:after { content: "Admin Only"; }
-.forum_preset_archive:after { content: "Archive"; }
-.forum_preset_all:after { content: "Public"; }
-.forum_preset_custom, .forum_preset_ { display: none !important; }
-.forum_active_Hide:before { content: "Hidden"; }
-.forum_active_Hide + .forum_preset:before { content: " | "; }
-.forum_active_Show { display: none !important; }
-
-.perm_preset_no_access:before { content: "No Access"; color: maroon; }
-.perm_preset_read_only:before { content: "Read Only"; color: green; }
-.perm_preset_can_post:before { content: "Can Post"; color: green; }
-.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
-.perm_preset_custom:before { content: "Custom"; color: black; }
-.perm_preset_default:before { content: "Default"; }
-
/* Responsive Layout */
/* Anything that isn't a small mobile */
@media(min-width: 501px) {
diff --git a/themes/cosmo/public/panel.css b/themes/cosmo/public/panel.css
new file mode 100644
index 00000000..a41e9989
--- /dev/null
+++ b/themes/cosmo/public/panel.css
@@ -0,0 +1,69 @@
+/* Control Panel */
+
+.tag-mini {
+ margin-left: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+
+ color: black;
+ font-size: 12px;
+}
+
+.panel_tag {
+ padding-left: 0px;
+ padding-right: 0px;
+ border: none;
+ background: none;
+ color: #202020;
+ font-size: 14px;
+}
+
+.panel_floater {
+ float: right;
+}
+#panel_groups > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_groups > .rowitem > .panel_floater > .panel_right_button {
+ float: right;
+}
+#panel_forums > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_forums > .rowitem > .panel_floater > .panel_buttons {
+ float: right;
+}
+#panel_forums > .rowitem > span > .forum_name {
+ margin-right: 4px;
+}
+
+.panel_rank_tag, .forum_preset, .forum_active {
+ float: none;
+ color: #202020 !important;
+ font-size: 11px;
+}
+.panel_rank_tag_admin:before { content: "Admins"; }
+.panel_rank_tag_mod:before { content: "Mods"; }
+.panel_rank_tag_banned:before { content: "Banned"; }
+.panel_rank_tag_guest:before { content: "Guests"; }
+.panel_rank_tag_member:before { content: "Members"; }
+
+.forum_preset_announce:after { content: "Announcements"; }
+.forum_preset_members:after { content: "Member Only"; }
+.forum_preset_staff:after { content: "Staff Only"; }
+.forum_preset_admins:after { content: "Admin Only"; }
+.forum_preset_archive:after { content: "Archive"; }
+.forum_preset_all:after { content: "Public"; }
+.forum_preset_custom, .forum_preset_ { display: none !important; }
+.forum_active_Hide:before { content: "Hidden"; }
+.forum_active_Hide + .forum_preset:before { content: " | "; }
+.forum_active_Show { display: none !important; }
+
+.perm_preset_no_access:before { content: "No Access"; color: maroon; }
+.perm_preset_read_only:before { content: "Read Only"; color: green; }
+.perm_preset_can_post:before { content: "Can Post"; color: green; }
+.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
+.perm_preset_custom:before { content: "Custom"; color: black; }
+.perm_preset_default:before { content: "Default"; }
diff --git a/themes/tempra-conflux/public/main.css b/themes/tempra-conflux/public/main.css
index 925086b4..03e67197 100644
--- a/themes/tempra-conflux/public/main.css
+++ b/themes/tempra-conflux/public/main.css
@@ -503,8 +503,8 @@ button.username {
font-size: 30px;
border-width: 1px;
background-color: #FFFFFF;
- border-style: dotted;
- border-color: #505050;
+ border-style: solid;
+ border-color: #ccc;
padding: 0px;
padding-left: 5px;
padding-right: 5px;
@@ -527,73 +527,6 @@ button.username {
top: -2px;
}
-/* Control Panel */
-.panel_upshift:visited { color: black; }
-
-.tag-mini {
- margin-left: 0px;
- padding-left: 0px;
- padding-right: 0px;
- padding-top: 2px;
- padding-bottom: 2px;
-
- color: black;
- font-size: 12px;
-}
-
-.panel_tag {
- padding-left: 0px;
- padding-right: 0px;
- border: none;
- background: none;
- color: #202020;
- font-size: 14px;
-}
-
-.panel_floater { float: right; }
-#panel_groups > .rowitem > .panel_floater { float: none; }
-#panel_groups > .rowitem > .panel_floater > .panel_right_button { float: right; }
-#panel_forums > .rowitem > .panel_floater { float: none; }
-#panel_forums > .rowitem > .panel_floater > .panel_buttons { float: right; }
-#panel_forums > .rowitem > span > .forum_name { margin-right: 4px; }
-#panel_forum_quick_perms > .formrow > .formitem > a { margin-right: 4px; }
-.forum_active > select { margin-bottom: 3px } /* Quick fix, need to properly patch this */
-
-.panel_rank_tag, .forum_preset, .forum_active {
- float: none;
- color: #202020 !important;
- font-size: 11px;
-}
-.panel_rank_tag_admin:before { content: "Admins"; }
-.panel_rank_tag_mod:before { content: "Mods"; }
-.panel_rank_tag_banned:before { content: "Banned"; }
-.panel_rank_tag_guest:before { content: "Guests"; }
-.panel_rank_tag_member:before { content: "Members"; }
-
-.forum_preset_announce:after { content: "Announcements"; }
-.forum_preset_members:after { content: "Member Only"; }
-.forum_preset_staff:after { content: "Staff Only"; }
-.forum_preset_admins:after { content: "Admin Only"; }
-.forum_preset_archive:after { content: "Archive"; }
-.forum_preset_all:after { content: "Public"; }
-.forum_preset_custom, .forum_preset_ { display: none !important; }
-.forum_active_Hide:before { content: "Hidden"; }
-.forum_active_Hide + .forum_preset:before { content: " | "; }
-.forum_active_Show { display: none !important; }
-
-.perm_preset_no_access:before { content: "No Access"; color: maroon; }
-.perm_preset_read_only:before { content: "Read Only"; color: green; }
-.perm_preset_can_post:before { content: "Can Post"; color: green; }
-.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
-.perm_preset_custom:before { content: "Custom"; color: black; }
-.perm_preset_default:before { content: "Default"; }
-
-.theme_row > .panel_floater > .panel_right_button { margin-left: 5px; }
-
-@media(max-width: 1300px) {
- .theme_row { background-image: none !important; }
-}
-
/* The Media Queries */
@media (max-width: 880px) {
li {
diff --git a/themes/tempra-conflux/public/panel.css b/themes/tempra-conflux/public/panel.css
new file mode 100644
index 00000000..32776780
--- /dev/null
+++ b/themes/tempra-conflux/public/panel.css
@@ -0,0 +1,85 @@
+/* Control Panel */
+
+.panel_upshift:visited { color: black; }
+
+.panel_tag {
+ padding-left: 0px;
+ padding-right: 0px;
+ border: none;
+ background: none;
+ color: #202020;
+ font-size: 14px;
+}
+
+.tag-mini {
+ margin-left: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+
+ color: black;
+ font-size: 12px;
+}
+
+.panel_floater {
+ float: right;
+}
+#panel_groups > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_groups > .rowitem > .panel_floater > .panel_right_button {
+ float: right;
+}
+#panel_forums > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_forums > .rowitem > .panel_floater > .panel_buttons {
+ float: right;
+}
+#panel_forums > .rowitem > span > .forum_name {
+ margin-right: 4px;
+}
+#panel_forum_quick_perms > .formrow > .formitem > a {
+ margin-right: 4px;
+}
+
+/* Quick fix, need to properly patch this */
+.forum_active > select {
+ margin-bottom: 3px
+}
+
+.panel_rank_tag, .forum_preset, .forum_active {
+ float: none;
+ color: #202020 !important;
+ font-size: 11px;
+}
+.panel_rank_tag_admin:before { content: "Admins"; }
+.panel_rank_tag_mod:before { content: "Mods"; }
+.panel_rank_tag_banned:before { content: "Banned"; }
+.panel_rank_tag_guest:before { content: "Guests"; }
+.panel_rank_tag_member:before { content: "Members"; }
+
+.forum_preset_announce:after { content: "Announcements"; }
+.forum_preset_members:after { content: "Member Only"; }
+.forum_preset_staff:after { content: "Staff Only"; }
+.forum_preset_admins:after { content: "Admin Only"; }
+.forum_preset_archive:after { content: "Archive"; }
+.forum_preset_all:after { content: "Public"; }
+.forum_preset_custom, .forum_preset_ { display: none !important; }
+.forum_active_Hide:before { content: "Hidden"; }
+.forum_active_Hide + .forum_preset:before { content: " | "; }
+.forum_active_Show { display: none !important; }
+
+.perm_preset_no_access:before { content: "No Access"; color: maroon; }
+.perm_preset_read_only:before { content: "Read Only"; color: green; }
+.perm_preset_can_post:before { content: "Can Post"; color: green; }
+.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
+.perm_preset_custom:before { content: "Custom"; color: black; }
+.perm_preset_default:before { content: "Default"; }
+
+.theme_row > .panel_floater > .panel_right_button { margin-left: 5px; }
+
+@media(max-width: 1300px) {
+ .theme_row { background-image: none !important; }
+}
diff --git a/themes/tempra-cursive/public/main.css b/themes/tempra-cursive/public/main.css
index 123003f4..cceb512c 100644
--- a/themes/tempra-cursive/public/main.css
+++ b/themes/tempra-cursive/public/main.css
@@ -183,8 +183,7 @@ li a {
word-wrap: break-word;
}
.colstack_head { margin-bottom: 0px; }
-.colstack_left:empty { display: none; }
-.colstack_right:empty { display: none; }
+.colstack_left:empty, .colstack_right:empty { display: none; }
.colstack_grid {
display: grid;
@@ -387,27 +386,13 @@ button.username {
content: "|";
margin-right: 5px;
}
-.edit_label:before {
- content: "Edit";
-}
-.trash_label:before {
- content: "Delete";
-}
-.pin_label:before {
- content: "Pin";
-}
-.unpin_label:before {
- content: "Unpin";
-}
-.flag_label:before {
- content: "Flag";
-}
-.level_label {
- margin-right: 1px;
-}
-.level_label:before {
- content: "Level";
-}
+.edit_label:before { content: "Edit"; }
+.trash_label:before { content: "Delete"; }
+.pin_label:before { content: "Pin"; }
+.unpin_label:before { content: "Unpin"; }
+.flag_label:before { content: "Flag"; }
+.level_label { margin-right: 1px; }
+.level_label:before { content: "Level"; }
.controls {
margin-top: 23px;
@@ -496,60 +481,6 @@ button.username {
font-size: 12px;
}
-/* Control Panel */
-
-.tag-mini {
- margin-left: 0px;
- padding-left: 0px;
- padding-right: 0px;
- padding-top: 2px;
- padding-bottom: 2px;
-
- font-family: cursive;
- font-size: 12px;
- color: #202020;
- opacity: 0.7;
-}
-
-.panel_floater { float: right; }
-#panel_groups > .rowitem > .panel_floater { float: none; }
-#panel_groups > .rowitem > .panel_floater > .panel_right_button { float: right; }
-#panel_forums > .rowitem > .panel_floater { float: none; }
-#panel_forums > .rowitem > .panel_floater > .panel_buttons { float: right; }
-#panel_forums > .rowitem > .panel_floater > .panel_buttons > .panel_right_button {
- color: #505050;
- font-size: 14px;
-}
-.panel_rank_tag, .forum_preset, .forum_active {
- float: none;
- color: #202020;
- opacity: 0.7;
- font-size: 10px;
-}
-.panel_rank_tag_admin:before { content: "Admin Group"; }
-.panel_rank_tag_mod:before { content: "Mod Group"; }
-.panel_rank_tag_banned:before { content: "Banned Group"; }
-.panel_rank_tag_guest:before { content: "Guest Group"; }
-.panel_rank_tag_member:before { content: "Member Group"; }
-
-.forum_preset_announce:after { content: "Announcements"; }
-.forum_preset_members:after { content: "Member Only"; }
-.forum_preset_staff:after { content: "Staff Only"; }
-.forum_preset_admins:after { content: "Admin Only"; }
-.forum_preset_archive:after { content: "Archive"; }
-.forum_preset_all:after { content: "Public"; }
-.forum_preset_custom, .forum_preset_ { display: none !important; }
-.forum_active_Hide:before { content: "Hidden"; }
-.forum_active_Hide + .forum_preset:before { content: " | "; }
-.forum_active_Show { display: none !important; }
-
-.perm_preset_no_access:before { content: "No Access"; color: maroon; }
-.perm_preset_read_only:before { content: "Read Only"; color: green; }
-.perm_preset_can_post:before { content: "Can Post"; color: green; }
-.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
-.perm_preset_custom:before { content: "Custom"; color: black; }
-.perm_preset_default:before { content: "Default"; }
-
@media(max-width: 1300px) {
.theme_row {
background-image: none !important;
diff --git a/themes/tempra-cursive/public/panel.css b/themes/tempra-cursive/public/panel.css
new file mode 100644
index 00000000..75b30e79
--- /dev/null
+++ b/themes/tempra-cursive/public/panel.css
@@ -0,0 +1,67 @@
+/* Control Panel */
+
+.tag-mini {
+ margin-left: 0px;
+ padding-left: 0px;
+ padding-right: 0px;
+ padding-top: 2px;
+ padding-bottom: 2px;
+
+ font-family: cursive;
+ font-size: 12px;
+ color: #202020;
+ opacity: 0.7;
+}
+
+.panel_floater {
+ float: right;
+}
+#panel_groups > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_groups > .rowitem > .panel_floater > .panel_right_button {
+ float: right;
+}
+#panel_forums > .rowitem > .panel_floater {
+ float: none;
+}
+#panel_forums > .rowitem > .panel_floater > .panel_buttons {
+ float: right;
+}
+#panel_forums > .rowitem > span > .forum_name {
+ margin-right: 4px;
+}
+#panel_forums > .rowitem > .panel_floater > .panel_buttons > .panel_right_button {
+ color: #505050;
+ font-size: 14px;
+}
+
+.panel_rank_tag, .forum_preset, .forum_active {
+ float: none;
+ color: #202020;
+ opacity: 0.7;
+ font-size: 10px;
+}
+.panel_rank_tag_admin:before { content: "Admin Group"; }
+.panel_rank_tag_mod:before { content: "Mod Group"; }
+.panel_rank_tag_banned:before { content: "Banned Group"; }
+.panel_rank_tag_guest:before { content: "Guest Group"; }
+.panel_rank_tag_member:before { content: "Member Group"; }
+
+.forum_preset_announce:after { content: "Announcements"; }
+.forum_preset_members:after { content: "Member Only"; }
+.forum_preset_staff:after { content: "Staff Only"; }
+.forum_preset_admins:after { content: "Admin Only"; }
+.forum_preset_archive:after { content: "Archive"; }
+.forum_preset_all:after { content: "Public"; }
+.forum_preset_custom, .forum_preset_ { display: none !important; }
+.forum_active_Hide:before { content: "Hidden"; }
+.forum_active_Hide + .forum_preset:before { content: " | "; }
+.forum_active_Show { display: none !important; }
+
+.perm_preset_no_access:before { content: "No Access"; color: maroon; }
+.perm_preset_read_only:before { content: "Read Only"; color: green; }
+.perm_preset_can_post:before { content: "Can Post"; color: green; }
+.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
+.perm_preset_custom:before { content: "Custom"; color: black; }
+.perm_preset_default:before { content: "Default"; }
diff --git a/themes/tempra-simple/public/main.css b/themes/tempra-simple/public/main.css
index 465ce0c8..7a0bd8c6 100644
--- a/themes/tempra-simple/public/main.css
+++ b/themes/tempra-simple/public/main.css
@@ -211,11 +211,8 @@ li a {
padding-bottom: 12px;
font-size: 16px;
}
-.grid_istat {
- /*margin-bottom: 10px;*/
- margin-bottom: 5px;
-}
+.grid_istat { margin-bottom: 5px; }
.stat_green { background-color: lightgreen; border-color: lightgreen; }
.stat_orange { background-color: #ffe4b3; border-color: #ffe4b3; }
.stat_red { background-color: #ffb2b2; border-color: #ffb2b2; }
@@ -336,21 +333,6 @@ button.username { position: relative; top: -0.25px; }
.username.real_username:hover { color: black; }
.post_item > .username { margin-top: 20px; display: inline-block; }
-.tag-mini {
- text-transform: none;
- margin-left: 0px;
- padding-left: 3px;
- padding-right: 3px;
- padding-top: 1.5px;
- padding-bottom: 0px;
- color: #505050; /* 80,80,80 */
- background-color: #FFFFFF;
- border-style: dotted;
- border-color: #505050; /* 232,232,232. All three RGB colours being the same seems to create a shade of gray */
- border-width: 1px;
- font-size: 10px;
-}
-
.post_item > .mod_button > button {
font-size: 15px;
color: #202020;
@@ -358,10 +340,7 @@ button.username { position: relative; top: -0.25px; }
}
.post_item > .mod_button > button:hover { opacity: 0.9; }
-.mod_button {
- margin-right: 4px;
- /*z-index: 10;*/
-}
+.mod_button { margin-right: 4px; }
.like_label:before, .like_count_label:before { content: "😀"; }
.like_count_label {
color: #505050;
@@ -470,44 +449,6 @@ button.username { position: relative; top: -0.25px; }
top: -2px;
}
-/* Control Panel */
-
-.panel_upshift {
- font-size: 18px;
- position: relative;
- top: -2px;
-}
-.panel_upshift:visited { color: black; }
-/*.panel_tag_upshift {
- margin-left: 2px;
- position: relative;
- top:-3px;
- color: #505050;
-}*/
-
-.panel_floater { float: right; }
-.panel_rank_tag_admin:before { content: "👑"; }
-.panel_rank_tag_mod:before { content: "👮"; }
-.panel_rank_tag_banned:before { content: "⛓️"; }
-.panel_rank_tag_guest:before { content: "👽"; }
-.panel_rank_tag_member:before { content: "👪"; }
-
-.forum_preset_announce:before { content: "📣"; }
-.forum_preset_members:before { content: "👪"; }
-.forum_preset_staff:before { content: "👮"; }
-.forum_preset_admins:before { content: "👑"; }
-.forum_preset_archive:before { content: "☠️"; }
-.forum_preset_all, .forum_preset_custom, .forum_preset_ { display: none !important; }
-.forum_active_Hide:before { content: "🕵️"; }
-.forum_active_Show { display: none !important; }
-
-.perm_preset_no_access:before { content: "No Access"; color: maroon; }
-.perm_preset_read_only:before { content: "Read Only"; color: green; }
-.perm_preset_can_post:before { content: "Can Post"; color: green; }
-.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
-.perm_preset_custom:before { content: "Custom"; color: black; }
-.perm_preset_default:before { content: "Default"; }
-
@media (max-width: 880px) {
li {
height: 29px;
diff --git a/themes/tempra-simple/public/panel.css b/themes/tempra-simple/public/panel.css
new file mode 100644
index 00000000..f30d2689
--- /dev/null
+++ b/themes/tempra-simple/public/panel.css
@@ -0,0 +1,52 @@
+/* Control Panel */
+
+.tag-mini {
+ text-transform: none;
+ margin-left: 0px;
+ padding-left: 3px;
+ padding-right: 3px;
+ padding-top: 1.5px;
+ padding-bottom: 0px;
+ color: #505050; /* 80,80,80 */
+ background-color: #FFFFFF;
+ border-style: dotted;
+ border-color: #505050; /* 232,232,232. All three RGB colours being the same seems to create a shade of gray */
+ border-width: 1px;
+ font-size: 10px;
+}
+
+.panel_upshift {
+ font-size: 18px;
+ position: relative;
+ top: -2px;
+}
+.panel_upshift:visited { color: black; }
+/*.panel_tag_upshift {
+ margin-left: 2px;
+ position: relative;
+ top:-3px;
+ color: #505050;
+}*/
+
+.panel_floater { float: right; }
+.panel_rank_tag_admin:before { content: "👑"; }
+.panel_rank_tag_mod:before { content: "👮"; }
+.panel_rank_tag_banned:before { content: "⛓️"; }
+.panel_rank_tag_guest:before { content: "👽"; }
+.panel_rank_tag_member:before { content: "👪"; }
+
+.forum_preset_announce:before { content: "📣"; }
+.forum_preset_members:before { content: "👪"; }
+.forum_preset_staff:before { content: "👮"; }
+.forum_preset_admins:before { content: "👑"; }
+.forum_preset_archive:before { content: "☠️"; }
+.forum_preset_all, .forum_preset_custom, .forum_preset_ { display: none !important; }
+.forum_active_Hide:before { content: "🕵️"; }
+.forum_active_Show { display: none !important; }
+
+.perm_preset_no_access:before { content: "No Access"; color: maroon; }
+.perm_preset_read_only:before { content: "Read Only"; color: green; }
+.perm_preset_can_post:before { content: "Can Post"; color: green; }
+.perm_preset_can_moderate:before { content: "Can Moderate"; color: darkblue; }
+.perm_preset_custom:before { content: "Custom"; color: black; }
+.perm_preset_default:before { content: "Default"; }
diff --git a/user.go b/user.go
index b2a7fa98..83b6db08 100644
--- a/user.go
+++ b/user.go
@@ -12,6 +12,8 @@ import (
var guest_user User = User{ID:0,Group:6,Perms:GuestPerms}
var SimpleSessionCheck func(http.ResponseWriter, *http.Request) (User,bool) = _simple_session_check
+var PanelSessionCheck func(http.ResponseWriter, *http.Request) (User,HeaderVars,bool) = _panel_session_check
+var SimplePanelSessionCheck func(http.ResponseWriter, *http.Request) (User,bool) = _simple_panel_session_check
type User struct
{
@@ -105,10 +107,10 @@ func SimpleForumSessionCheck(w http.ResponseWriter, r *http.Request, fid int) (u
return user, success
}
-func ForumSessionCheck(w http.ResponseWriter, r *http.Request, fid int) (user User, noticeList []string, success bool) {
+func ForumSessionCheck(w http.ResponseWriter, r *http.Request, fid int) (user User, headerVars HeaderVars, success bool) {
if !forum_exists(fid) {
NotFound(w,r)
- return user, noticeList, false
+ return user, headerVars, false
}
user, success = SimpleSessionCheck(w,r)
fperms := groups[user.Group].Forums[fid]
@@ -133,17 +135,36 @@ func ForumSessionCheck(w http.ResponseWriter, r *http.Request, fid int) (user Us
}
}
if user.Is_Banned {
- noticeList = append(noticeList,"Your account has been suspended. Some of your permissions may have been revoked.")
+ headerVars.NoticeList = append(headerVars.NoticeList,"Your account has been suspended. Some of your permissions may have been revoked.")
}
- return user, noticeList, success
+ return user, headerVars, success
}
-func SessionCheck(w http.ResponseWriter, r *http.Request) (user User, noticeList []string, success bool) {
+// 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, success bool) {
+ user, success = SimpleSessionCheck(w,r)
+ if !user.Is_Super_Mod {
+ NoPermissions(w,r,user)
+ return user, headerVars, false
+ }
+ headerVars.Stylesheets = append(headerVars.Stylesheets,"panel")
+ return user, headerVars, success
+}
+func _simple_panel_session_check(w http.ResponseWriter, r *http.Request) (user User, success bool) {
+ user, success = SimpleSessionCheck(w,r)
+ if !user.Is_Super_Mod {
+ NoPermissions(w,r,user)
+ return user, false
+ }
+ return user, success
+}
+
+func SessionCheck(w http.ResponseWriter, r *http.Request) (user User, headerVars HeaderVars, success bool) {
user, success = SimpleSessionCheck(w,r)
if user.Is_Banned {
- noticeList = append(noticeList,"Your account has been suspended. Some of your permissions may have been revoked.")
+ headerVars.NoticeList = append(headerVars.NoticeList,"Your account has been suspended. Some of your permissions may have been revoked.")
}
- return user, noticeList, success
+ return user, headerVars, success
}
func _simple_session_check(w http.ResponseWriter, r *http.Request) (User,bool) {