Added the HeaderVars struct which is now used in the header template.

The NoticeList field in the various page structs is now part of the HeaderVars struct.
The Left / Right hotkeys will no longer take you to the next or previous page, if you have a textarea, input, or select element selected.
Added the panel.css file.
Added the PanelSessionCheck and SimplePanelSessionCheck functions.
Reworked the ExtData field in the page structs, we'll have some hooks for you to inject stuff in here soon!
Fixed a problem with the templates not getting remapped properly with Tempra Conflux when the compiled templates are missing.
More Atom Madness.
This commit is contained in:
Azareal 2017-06-16 11:41:30 +01:00
parent 1ccd4479ae
commit c4e109adb7
30 changed files with 855 additions and 644 deletions

View File

@ -9,7 +9,7 @@ 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
@ -17,7 +17,7 @@ func init_errors() error {
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())

22
main.go
View File

@ -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/*"))

View File

@ -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)
}

View File

@ -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

View File

@ -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)

View File

@ -351,6 +351,10 @@ $(document).ready(function(){
document.getElementById("back").className += " alertActive"
});
$("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();

View File

@ -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
}

110
routes.go
View File

@ -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) {

View File

@ -6,7 +6,6 @@ if %errorlevel% neq 0 (
exit /b %errorlevel%
)
echo Building the router generator
go build ./router_gen
if %errorlevel% neq 0 (

View File

@ -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 {

View File

@ -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)

View File

@ -6,9 +6,21 @@ var header_0 []byte = []byte(`<!doctype html>
<title>`)
var header_1 []byte = []byte(`</title>
<link href="/static/main.css" rel="stylesheet" type="text/css">
`)
var header_2 []byte = []byte(`
<link href="/static/`)
var header_3 []byte = []byte(`.css" rel="stylesheet" type="text/css">
`)
var header_4 []byte = []byte(`
<script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script>
`)
var header_5 []byte = []byte(`
<script type="text/javascript" src="/static/`)
var header_6 []byte = []byte(`.js"></script>
`)
var header_7 []byte = []byte(`
<script type="text/javascript">var session = "`)
var header_2 []byte = []byte(`";
var header_8 []byte = []byte(`";
</script>
<script type="text/javascript" src="/static/global.js"></script>
<meta name="viewport" content="width=device-width,initial-scale = 1.0, maximum-scale=1.0,user-scalable=no" />
@ -51,11 +63,11 @@ var menu_7 []byte = []byte(`
<div style="clear: both;"></div>
</div>
`)
var header_3 []byte = []byte(`
var header_9 []byte = []byte(`
<div id="back"><div id="main">
`)
var header_4 []byte = []byte(`<div class="alert">`)
var header_5 []byte = []byte(`</div>`)
var header_10 []byte = []byte(`<div class="alert">`)
var header_11 []byte = []byte(`</div>`)
var topic_0 []byte = []byte(`<div id="prevFloat" class="prev_button"><a class="prev_link" href="/topic/`)
var topic_1 []byte = []byte(`?page=`)
var topic_2 []byte = []byte(`">&lt;</a></div>`)

View File

@ -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)

View File

@ -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 {

View File

@ -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 {

View File

@ -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)

View File

@ -156,8 +156,8 @@ func (c *CTemplateSet) compile_template(name string, dir string, expects string,
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"
@ -275,7 +275,6 @@ 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 ""

View File

@ -3,7 +3,13 @@
<head>
<title>{{.Title}}</title>
<link href="/static/main.css" rel="stylesheet" type="text/css">
{{range .Header.Stylesheets}}
<link href="/static/{{.}}.css" rel="stylesheet" type="text/css">
{{end}}
<script type="text/javascript" src="/static/jquery-3.1.1.min.js"></script>
{{range .Header.Scripts}}
<script type="text/javascript" src="/static/{{.}}.js"></script>
{{end}}
<script type="text/javascript">var session = "{{.CurrentUser.Session}}";
</script>
<script type="text/javascript" src="/static/global.js"></script>
@ -13,4 +19,4 @@
<div class="container">
{{template "menu.html" .}}
<div id="back"><div id="main">
{{range .NoticeList}}<div class="alert">{{.}}</div>{{end}}
{{range .Header.NoticeList}}<div class="alert">{{.}}</div>{{end}}

View File

@ -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 {

View File

@ -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) {

View File

@ -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"; }

View File

@ -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! */
* {
@ -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; }
@ -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) {

View File

@ -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"; }

View File

@ -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 {

View File

@ -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; }
}

View File

@ -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;

View File

@ -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"; }

View File

@ -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;

View File

@ -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"; }

35
user.go
View File

@ -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) {