Overhauled the widget system. You can now specify more complex logic for where a widget can show up and you can now place widgets in the footer.

Added fsnotify as a dependency, we'll be using it, Rez, and Riot (maybe) soon.
Removed the intercept_build_widgets vhook.
You can now pass an ID to BlankReply() for mocking replies or whatever else you want to do with this.
Added the dock template function for widget docks.
Added the logf internal function to the template transpiler and did some minor clean-up.
Removed the Sidebars property from theme.json and added the more general Docks one.
Improved the footer and the associated CSS.
Added the about widget, previously the AboutSegment feature.
Removed the about_segment_title and about_segment_body settings.
Gosora now exits when it receives the appropriate OS signal.
Refactored the modlogs route.

More progress on the theme in the Control Panel.
This commit is contained in:
Azareal 2017-11-29 02:34:02 +00:00
parent 381ce3083a
commit 0e9cebfa47
43 changed files with 508 additions and 415 deletions

View File

@ -111,6 +111,8 @@ go get -u github.com/lib/pq
go get -u github.com/denisenkom/go-mssqldb
go get -u github.com/fsnotify/fsnotify
go generate
@ -166,7 +168,7 @@ We're looking for ways to clean-up the plugin system so that all of them (except
More images in the /images/ folder. Beware though, some of them are *really* outdated.
# Dependencies
# Dependencies (a few of these like Riot aren't currently in use, but we anticipate that we'll need some sort of search engine library in the very immediate future)
* Go 1.9
@ -194,6 +196,10 @@ More images in the /images/ folder. Beware though, some of them are *really* out
* github.com/go-ego/riot A search engine library.
* github.com/bamiaux/rez An image resizer (e.g. for spitting out thumbnails)
* github.com/fsnotify/fsnotify A library for watching events on the file system.
# Bundled Plugins
There are several plugins which are bundled with the software by default. These cover various common tasks which aren't common enough to clutter the core with or which have competing implementation methods (E.g. plugin_markdown vs plugin_bbcode for post mark-up).

View File

@ -26,7 +26,6 @@ var Hooks = map[string][]func(interface{}) interface{}{
// Hooks with a variable number of arguments
var Vhooks = map[string]func(...interface{}) interface{}{
"intercept_build_widgets": nil,
"forum_trow_assign": nil,
"topics_topic_row_assign": nil,
//"topics_user_row_assign": nil,

View File

@ -2,6 +2,7 @@ package common
import (
"html/template"
"net/http"
"sync"
"time"
)
@ -16,6 +17,8 @@ type HeaderVars struct {
Themes map[string]Theme // TODO: Use a slice containing every theme instead of the main map for speed?
Theme Theme
//TemplateName string // TODO: Use this to move template calls to the router rather than duplicating them over and over and over?
Zone string
Writer http.ResponseWriter
ExtData ExtData
}

View File

@ -131,6 +131,10 @@ func (reply *Reply) Copy() Reply {
return *reply
}
func BlankReply() *Reply {
return &Reply{ID: 0}
func BlankReply(ids ...int) *Reply {
var id int
if len(ids) != 0 {
id = ids[0]
}
return &Reply{ID: id}
}

View File

@ -2,7 +2,6 @@ package common
import (
"html"
"html/template"
"log"
"net"
"net/http"
@ -22,30 +21,6 @@ var MemberCheck func(w http.ResponseWriter, r *http.Request, user *User) (header
var SimpleUserCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerLite *HeaderLite, err RouteError) = simpleUserCheck
var UserCheck func(w http.ResponseWriter, r *http.Request, user *User) (headerVars *HeaderVars, err RouteError) = userCheck
// TODO: Support for left sidebars and sidebars on both sides
// http.Request is for context.Context middleware. Mostly for plugin_guilds right now
func BuildWidgets(zone string, data interface{}, headerVars *HeaderVars, r *http.Request) {
if Vhooks["intercept_build_widgets"] != nil {
if RunVhook("intercept_build_widgets", zone, data, headerVars, r).(bool) {
return
}
}
if Themes[headerVars.Theme.Name].Sidebars == "right" {
if len(Docks.RightSidebar) != 0 {
var sbody string
for _, widget := range Docks.RightSidebar {
if widget.Enabled {
if widget.Location == "global" || widget.Location == zone {
sbody += widget.Body
}
}
}
headerVars.Widgets.RightSidebar = template.HTML(sbody)
}
}
}
func simpleForumUserCheck(w http.ResponseWriter, r *http.Request, user *User, fid int) (headerLite *HeaderLite, rerr RouteError) {
if !Forums.Exists(fid) {
return nil, PreError("The target forum doesn't exist.", w, r)
@ -140,6 +115,7 @@ func panelUserCheck(w http.ResponseWriter, r *http.Request, user *User) (headerV
Settings: SettingBox.Load().(SettingMap),
Themes: Themes,
Theme: theme,
Zone: "panel",
}
// TODO: We should probably initialise headerVars.ExtData
@ -231,6 +207,7 @@ func userCheck(w http.ResponseWriter, r *http.Request, user *User) (headerVars *
Settings: SettingBox.Load().(SettingMap),
Themes: Themes,
Theme: theme,
Zone: "frontend",
}
if user.IsBanned {

View File

@ -138,7 +138,6 @@ func compileTemplates() error {
}
for _, forum := range forums {
//log.Printf("*forum %+v\n", *forum)
forumList = append(forumList, *forum)
}
varList = make(map[string]tmpl.VarItem)
@ -272,6 +271,10 @@ func InitTemplates() error {
return leftInt / rightInt
}
fmap["dock"] = func(dock interface{}, headerVarInt interface{}) interface{} {
return template.HTML(BuildWidget(dock.(string), headerVarInt.(*HeaderVars)))
}
// The interpreted templates...
if Dev.DebugMode {
log.Print("Loading the template files...")

View File

@ -91,6 +91,7 @@ func (c *CTemplateSet) Compile(name string, dir string, expects string, expectsI
"subtract": true,
"multiply": true,
"divide": true,
"dock": true,
}
c.importMap = map[string]string{
@ -450,7 +451,10 @@ func (c *CTemplateSet) compileSubswitch(varholder string, holdreflect reflect.Va
case *parse.IdentifierNode:
c.log("Identifier Node:", node)
c.log("Identifier Node Args:", node.Args)
out, outval := c.compileIdentSwitch(varholder, holdreflect, templateName, node)
out, outval, lit := c.compileIdentSwitch(varholder, holdreflect, templateName, node)
if lit {
return out
}
return c.compileVarsub(out, outval, "")
default:
return c.unknownNode(node)
@ -507,7 +511,7 @@ func (c *CTemplateSet) unknownNode(node parse.Node) (out string) {
func (c *CTemplateSet) compileIdentSwitchN(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string) {
c.log("in compileIdentSwitchN")
out, _ = c.compileIdentSwitch(varholder, holdreflect, templateName, node)
out, _, _ = c.compileIdentSwitch(varholder, holdreflect, templateName, node)
return out
}
@ -541,7 +545,7 @@ func (c *CTemplateSet) simpleMath(varholder string, holdreflect reflect.Value, t
}
func (c *CTemplateSet) compareJoin(varholder string, holdreflect reflect.Value, templateName string, pos int, node *parse.CommandNode, symbol string) (pos2 int, out string) {
c.log("Building " + symbol + " function")
c.logf("Building %s function", symbol)
if pos == 0 {
fmt.Println("pos:", pos)
panic(symbol + " is missing a left operand")
@ -572,7 +576,7 @@ func (c *CTemplateSet) compareJoin(varholder string, holdreflect reflect.Value,
return pos, out
}
func (c *CTemplateSet) compileIdentSwitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, val reflect.Value) {
func (c *CTemplateSet) compileIdentSwitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, val reflect.Value, literal bool) {
c.log("in compileIdentSwitch")
ArgLoop:
for pos := 0; pos < len(node.Args); pos++ {
@ -624,6 +628,35 @@ ArgLoop:
out += rout
val = rval
break ArgLoop
case "dock":
var leftParam, rightParam string
// TODO: Implement string literals properly
leftOperand := node.Args[pos+1].String()
rightOperand := node.Args[pos+2].String()
if len(leftOperand) == 0 || len(rightOperand) == 0 {
panic("The left or right operand for function dock cannot be left blank")
}
if leftOperand[0] == '"' {
leftParam = leftOperand
} else {
leftParam, _ = c.compileIfVarsub(leftOperand, varholder, templateName, holdreflect)
}
if rightOperand[0] == '"' {
panic("The right operand for function dock cannot be a string")
}
rightParam, val3 := c.compileIfVarsub(rightOperand, varholder, templateName, holdreflect)
if val3.IsValid() {
val = val3
} else {
panic("val3 is invalid")
}
// TODO: Refactor this
out = "w.Write([]byte(common.BuildWidget(" + leftParam + "," + rightParam + ")))\n"
literal = true
break ArgLoop
default:
c.log("Variable!")
if len(node.Args) > (pos + 1) {
@ -635,7 +668,7 @@ ArgLoop:
out += c.compileIfVarsubN(id.String(), varholder, templateName, holdreflect)
}
}
return out, val
return out, val, literal
}
func (c *CTemplateSet) compileReflectSwitch(varholder string, holdreflect reflect.Value, templateName string, node *parse.CommandNode) (out string, outVal reflect.Value) {
@ -778,6 +811,12 @@ func (c *CTemplateSet) compileBoolsub(varname string, varholder string, template
func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value, assLines string) (out string) {
c.log("in compileVarsub")
// Is this a literal string?
if len(varname) != 0 && varname[0] == '"' {
return assLines + "w.Write([]byte(" + varname + "))\n"
}
for _, varItem := range c.varList {
if strings.HasPrefix(varname, varItem.Destination) {
varname = strings.Replace(varname, varItem.Destination, varItem.Name, 1)
@ -818,7 +857,7 @@ func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value, assLines
fmt.Println("Unknown Variable Name:", varname)
fmt.Println("Unknown Kind:", val.Kind())
fmt.Println("Unknown Type:", val.Type().Name())
panic("// I don't know what this variable's type is o.o\n")
panic("-- I don't know what this variable's type is o.o\n")
}
c.log("out: ", out)
return assLines + out
@ -826,7 +865,7 @@ func (c *CTemplateSet) compileVarsub(varname string, val reflect.Value, assLines
func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflect.Value, node *parse.TemplateNode) (out string) {
c.log("in compileSubtemplate")
c.log("Template Node:", node.Name)
c.log("Template Node: ", node.Name)
fname := strings.TrimSuffix(node.Name, filepath.Ext(node.Name))
varholder := "tmpl_" + fname + "_vars"
@ -841,8 +880,8 @@ func (c *CTemplateSet) compileSubtemplate(pvarholder string, pholdreflect reflec
case *parse.NilNode:
panic("Nil is not a command x.x")
default:
out = "var " + varholder + " := false\n"
out += c.compileCommand(cmd)
c.log("Unknown Node: ", firstWord)
panic("")
}
}
}
@ -883,16 +922,18 @@ func (c *CTemplateSet) log(args ...interface{}) {
}
}
func (c *CTemplateSet) logf(left string, args ...interface{}) {
if c.superDebug {
fmt.Printf(left, args...)
}
}
func (c *CTemplateSet) error(args ...interface{}) {
if c.debug {
fmt.Println(args...)
}
}
func (c *CTemplateSet) compileCommand(*parse.CommandNode) (out string) {
panic("Uh oh! Something went wrong!")
}
// TODO: Write unit tests for this
func minify(data string) string {
data = strings.Replace(data, "\t", "", -1)

View File

@ -30,25 +30,22 @@ var ChangeDefaultThemeMutex sync.Mutex
// TODO: Use this when the default theme doesn't exist
var fallbackTheme = "shadow"
//var overridenTemplates map[string]interface{} = make(map[string]interface{})
var overridenTemplates = make(map[string]bool)
type Theme struct {
Name string
FriendlyName string
Version string
Creator string
FullImage string
MobileFriendly bool
Disabled bool
HideFromThemes bool
ForkOf string
Tag string
URL string
Sidebars string // Allowed Values: left, right, both, false
AboutSegment bool // ? - Should this be a theme var instead?
//DisableMinifier // Is this really a good idea? I don't think themes should be fighting against the minifier
Name string
FriendlyName string
Version string
Creator string
FullImage string
MobileFriendly bool
Disabled bool
HideFromThemes bool
ForkOf string
Tag string
URL string
Docks []string // Allowed Values: leftSidebar, rightSidebar, footer
AboutSegment bool // ? - Should this be a theme var instead?
Settings map[string]ThemeSetting
Templates []TemplateMapping
TemplatesMap map[string]string
@ -117,12 +114,12 @@ func (themes ThemeList) LoadActiveStatus() error {
}
if defaultThemeSwitch {
log.Print("Loading the default theme '" + theme.Name + "'")
log.Printf("Loading the default theme '%s'", theme.Name)
theme.Active = true
DefaultThemeBox.Store(theme.Name)
MapThemeTemplates(theme)
} else {
log.Print("Loading the theme '" + theme.Name + "'")
log.Printf("Loading the theme '%s'", theme.Name)
theme.Active = false
}
@ -144,7 +141,7 @@ func InitThemes() error {
}
themeName := themeFile.Name()
log.Print("Adding theme '" + themeName + "'")
log.Printf("Adding theme '%s'", themeName)
themeFile, err := ioutil.ReadFile("./themes/" + themeName + "/theme.json")
if err != nil {
return err
@ -172,9 +169,7 @@ func InitThemes() error {
}
if theme.FullImage != "" {
if Dev.DebugMode {
log.Print("Adding theme image")
}
debugLog("Adding theme image")
err = StaticFiles.Add("./themes/"+themeName+"/"+theme.FullImage, "./themes/"+themeName)
if err != nil {
return err
@ -207,9 +202,7 @@ func InitThemes() error {
func AddThemeStaticFiles(theme Theme) error {
// TODO: Use a function instead of a closure to make this more testable? What about a function call inside the closure to take the theme variable into account?
return filepath.Walk("./themes/"+theme.Name+"/public", func(path string, f os.FileInfo, err error) error {
if Dev.DebugMode {
log.Print("Attempting to add static file '" + path + "' for default theme '" + theme.Name + "'")
}
debugLog("Attempting to add static file '" + path + "' for default theme '" + theme.Name + "'")
if err != nil {
return err
}
@ -224,13 +217,10 @@ func AddThemeStaticFiles(theme Theme) error {
}
var ext = filepath.Ext(path)
//log.Print("path ",path)
//log.Print("ext ",ext)
if ext == ".css" && len(data) != 0 {
var b bytes.Buffer
var pieces = strings.Split(path, "/")
var filename = pieces[len(pieces)-1]
//log.Print("filename ", filename)
err = theme.ResourceTemplates.ExecuteTemplate(&b, filename, CSSData{ComingSoon: "We don't have any data to pass you yet!"})
if err != nil {
return err
@ -242,9 +232,7 @@ func AddThemeStaticFiles(theme Theme) error {
gzipData := compressBytesGzip(data)
StaticFiles["/static/"+theme.Name+path] = SFile{data, gzipData, 0, int64(len(data)), int64(len(gzipData)), mime.TypeByExtension(ext), f, f.ModTime().UTC().Format(http.TimeFormat)}
if Dev.DebugMode {
log.Print("Added the '/" + theme.Name + path + "' static file for theme " + theme.Name + ".")
}
debugLog("Added the '/" + theme.Name + path + "' static file for theme " + theme.Name + ".")
return nil
})
}
@ -349,14 +337,12 @@ func ResetTemplateOverrides() {
originPointer, ok := TmplPtrMap["o_"+name]
if !ok {
//log.Fatal("The origin template doesn't exist!")
log.Print("The origin template doesn't exist!")
return
}
destTmplPtr, ok := TmplPtrMap[name]
if !ok {
//log.Fatal("The destination template doesn't exist!")
log.Print("The destination template doesn't exist!")
return
}
@ -519,3 +505,12 @@ func GetDefaultThemeName() string {
func SetDefaultThemeName(name string) {
DefaultThemeBox.Store(name)
}
func (theme Theme) HasDock(name string) bool {
for _, dock := range theme.Docks {
if dock == name {
return true
}
}
return false
}

View File

@ -5,7 +5,9 @@ import (
"bytes"
"database/sql"
"encoding/json"
"html/template"
"log"
"strings"
"sync"
"../query_gen/lib"
@ -15,9 +17,10 @@ var Docks WidgetDocks
var widgetUpdateMutex sync.RWMutex
type WidgetDocks struct {
LeftSidebar []Widget
RightSidebar []Widget
LeftSidebar []*Widget
RightSidebar []*Widget
//PanelLeft []Menus
Footer []*Widget
}
type Widget struct {
@ -25,6 +28,9 @@ type Widget struct {
Location string // Coming Soon: overview, topics, topic / topic_view, forums, forum, global
Position int
Body string
Side string
Type string
Literal bool
}
type WidgetMenu struct {
@ -40,7 +46,7 @@ type WidgetMenuItem struct {
type NameTextPair struct {
Name string
Text string
Text template.HTML
}
type WidgetStmts struct {
@ -58,6 +64,113 @@ func init() {
})
}
func preparseWidget(widget *Widget, wdata string) (err error) {
prebuildWidget := func(name string, data interface{}) (string, error) {
var b bytes.Buffer
err := Templates.ExecuteTemplate(&b, name+".html", data)
return string(b.Bytes()), err
}
sbytes := []byte(wdata)
switch widget.Type {
case "simple":
var tmp NameTextPair
err = json.Unmarshal(sbytes, &tmp)
if err != nil {
return err
}
widget.Literal = true
widget.Body, err = prebuildWidget("widget_simple", tmp)
case "about":
var tmp NameTextPair
err = json.Unmarshal(sbytes, &tmp)
if err != nil {
return err
}
widget.Literal = true
widget.Body, err = prebuildWidget("widget_about", tmp)
default:
widget.Literal = true
widget.Body = wdata
}
// TODO: Test this
// TODO: Should we toss this through a proper parser rather than crudely replacing it?
widget.Location = strings.Replace(widget.Location, " ", "", -1)
widget.Location = strings.Replace(widget.Location, "frontend", "!panel", -1)
widget.Location = strings.Replace(widget.Location, "!!", "", -1)
// Skip blank zones
var locs = strings.Split(widget.Location, "|")
if len(locs) > 0 {
widget.Location = ""
for _, loc := range locs {
if loc == "" {
continue
}
widget.Location += loc + "|"
}
widget.Location = widget.Location[:len(widget.Location)-1]
}
return err
}
func BuildWidget(dock string, headerVars *HeaderVars) (sbody string) {
var widgets []*Widget
if !headerVars.Theme.HasDock(dock) {
return ""
}
switch dock {
case "rightSidebar":
widgets = Docks.RightSidebar
case "footer":
widgets = Docks.Footer
}
for _, widget := range widgets {
if !widget.Enabled {
continue
}
if widget.Allowed(headerVars.Zone) {
item, err := widget.Build(headerVars)
if err != nil {
LogError(err)
}
sbody += item
}
}
return sbody
}
// TODO: Test this
// TODO: Add support for zone:id. Perhaps, carry a ZoneID property around in headerVars? It might allow some weirdness like frontend[5] which matches any zone with an ID of 5 but it would be a tad faster than verifying each zone, although it might be problematic if users end up relying on this behaviour for areas which don't pass IDs to the widgets system but *probably* should
func (widget *Widget) Allowed(zone string) bool {
for _, loc := range strings.Split(widget.Location, "|") {
if loc == "global" || loc == zone {
return true
} else if len(loc) > 0 && loc[0] == '!' {
loc = loc[1:]
if loc != "global" && loc != zone {
return true
}
}
}
return false
}
// TODO: Refactor
func (widget *Widget) Build(hvars interface{}) (string, error) {
if widget.Literal {
return widget.Body, nil
}
var b bytes.Buffer
var headerVars = hvars.(*HeaderVars)
err := RunThemeTemplate(headerVars.Theme.Name, widget.Body, hvars, headerVars.Writer)
return string(b.Bytes()), err
}
// TODO: Make a store for this?
func InitWidgets() error {
rows, err := widgetStmts.getWidgets.Query()
@ -66,42 +179,30 @@ func InitWidgets() error {
}
defer rows.Close()
var sbytes []byte
var side, wtype, data string
var leftWidgets []Widget
var rightWidgets []Widget
var data string
var leftWidgets []*Widget
var rightWidgets []*Widget
var footerWidgets []*Widget
for rows.Next() {
var widget Widget
err = rows.Scan(&widget.Position, &side, &wtype, &widget.Enabled, &widget.Location, &data)
var widget = &Widget{Position: 0}
err = rows.Scan(&widget.Position, &widget.Side, &widget.Type, &widget.Enabled, &widget.Location, &data)
if err != nil {
return err
}
sbytes = []byte(data)
switch wtype {
case "simple":
var tmp NameTextPair
err = json.Unmarshal(sbytes, &tmp)
if err != nil {
return err
}
var b bytes.Buffer
err = Templates.ExecuteTemplate(&b, "widget_simple.html", tmp)
if err != nil {
return err
}
widget.Body = string(b.Bytes())
default:
widget.Body = data
err = preparseWidget(widget, data)
if err != nil {
return err
}
if side == "left" {
switch widget.Side {
case "left":
leftWidgets = append(leftWidgets, widget)
} else if side == "right" {
case "right":
rightWidgets = append(rightWidgets, widget)
case "footer":
footerWidgets = append(footerWidgets, widget)
}
}
err = rows.Err()
@ -112,11 +213,13 @@ func InitWidgets() error {
widgetUpdateMutex.Lock()
Docks.LeftSidebar = leftWidgets
Docks.RightSidebar = rightWidgets
Docks.Footer = footerWidgets
widgetUpdateMutex.Unlock()
if Dev.SuperDebug {
log.Print("Docks.LeftSidebar", Docks.LeftSidebar)
log.Print("Docks.RightSidebar", Docks.RightSidebar)
log.Print("Docks.Footer", Docks.Footer)
}
return nil

View File

@ -112,6 +112,7 @@ func PrebuildTmplList(user common.User, headerVars *common.HeaderVars) common.CT
}
// TODO: Do this properly via the widget system
// TODO: REWRITE THIS
func CommonAreaWidgets(headerVars *common.HeaderVars) {
// TODO: Hot Groups? Featured Groups? Official Groups?
var b bytes.Buffer
@ -125,9 +126,9 @@ func CommonAreaWidgets(headerVars *common.HeaderVars) {
return
}
if common.Themes[headerVars.Theme.Name].Sidebars == "left" {
if headerVars.Theme.HasDock("leftSidebar") {
headerVars.Widgets.LeftSidebar = template.HTML(string(b.Bytes()))
} else if common.Themes[headerVars.Theme.Name].Sidebars == "right" || common.Themes[headerVars.Theme.Name].Sidebars == "both" {
} else if headerVars.Theme.HasDock("rightSidebar") {
headerVars.Widgets.RightSidebar = template.HTML(string(b.Bytes()))
}
}

View File

@ -28,6 +28,9 @@ go get -u github.com/robertkrimen/otto
echo "Installing the Rez Image Resizer"
go get -u github.com/bamiaux/rez
echo "Installing fsnotify"
go get -u github.com/fsnotify/fsnotify
echo "Building the installer"
cd ./install

View File

@ -85,6 +85,13 @@ if %errorlevel% neq 0 (
exit /b %errorlevel%
)
echo Installing fsnotify
go get -u github.com/fsnotify/fsnotify
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Building the installer
go generate

14
main.go
View File

@ -12,6 +12,8 @@ import (
"log"
"net/http"
"os"
"os/signal"
"syscall"
"time"
//"runtime/pprof"
"./common"
@ -144,6 +146,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
defer db.Close()
err = afterDBInit()
if err != nil {
@ -158,7 +161,7 @@ func main() {
// Run this goroutine once a second
secondTicker := time.NewTicker(1 * time.Second)
fifteenMinuteTicker := time.NewTicker(15 * time.Minute)
//hour_ticker := time.NewTicker(1 * time.Hour)
//hourTicker := time.NewTicker(1 * time.Hour)
go func() {
for {
select {
@ -231,13 +234,18 @@ func main() {
router.HandleFunc("/profile/reply/edit/submit/", routeProfileReplyEditSubmit)
router.HandleFunc("/profile/reply/delete/submit/", routeProfileReplyDeleteSubmit)
//router.HandleFunc("/user/edit/submit/", routeLogout) // routeLogout? what on earth? o.o
//router.HandleFunc("/exit/", routeExit)
router.HandleFunc("/ws/", routeWebsockets)
log.Print("Initialising the plugins")
common.InitPlugins()
defer db.Close()
sigs := make(chan os.Signal, 1)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
go func() {
sig := <-sigs
// TODO: Gracefully shutdown the HTTP server
log.Fatal("Received a signal to shutdown: ", sig)
}()
//if profiling {
// pprof.StopCPUProfile()

View File

@ -41,8 +41,8 @@ func routeTopicCreate(w http.ResponseWriter, r *http.Request, user common.User,
if !user.Perms.ViewTopic || !user.Perms.CreateTopic {
return common.NoPermissions(w, r, user)
}
common.BuildWidgets("create_topic", nil, headerVars, r)
headerVars.Zone = "create_topic"
headerVars.Writer = w
// Lock this to the forum being linked?
// Should we always put it in strictmode when it's linked from another forum? Well, the user might end up changing their mind on what forum they want to post in and it would be a hassle, if they had to switch pages, even if it is a single click for many (exc. mobile)

View File

@ -1614,6 +1614,60 @@ func routePanelBackups(w http.ResponseWriter, r *http.Request, user common.User,
return nil
}
// TODO: Log errors when something really screwy is going on?
func handleUnknownUser(user *common.User, err error) *common.User {
if err != nil {
return &common.User{Name: "Unknown", Link: common.BuildProfileURL("unknown", 0)}
}
return user
}
func handleUnknownTopic(topic *common.Topic, err error) *common.Topic {
if err != nil {
return &common.Topic{Title: "Unknown", Link: common.BuildProfileURL("unknown", 0)}
}
return topic
}
func modlogsElementType(action string, elementType string, elementID int, actor *common.User) (out string) {
switch elementType {
case "topic":
topic := handleUnknownTopic(common.Topics.Get(elementID))
switch action {
case "lock":
out = "<a href='%s'>%s</a> was locked by <a href='%s'>%s</a>"
case "unlock":
out = "<a href='%s'>%s</a> was reopened by <a href='%s'>%s</a>"
case "stick":
out = "<a href='%s'>%s</a> was pinned by <a href='%s'>%s</a>"
case "unstick":
out = "<a href='%s'>%s</a> was unpinned by <a href='%s'>%s</a>"
case "delete":
return fmt.Sprintf("Topic #%d was deleted by <a href='%s'>%s</a>", elementID, actor.Link, actor.Name)
}
out = fmt.Sprintf(out, topic.Link, topic.Title, actor.Link, actor.Name)
case "user":
targetUser := handleUnknownUser(common.Users.Get(elementID))
switch action {
case "ban":
out = "<a href='%s'>%s</a> was banned by <a href='%s'>%s</a>"
case "unban":
out = "<a href='%s'>%s</a> was unbanned by <a href='%s'>%s</a>"
case "activate":
out = "<a href='%s'>%s</a> was activated by <a href='%s'>%s</a>"
}
out = fmt.Sprintf(out, targetUser.Link, targetUser.Name, actor.Link, actor.Name)
case "reply":
if action == "delete" {
topic := handleUnknownTopic(common.BlankReply(elementID).Topic())
out = fmt.Sprintf("A reply in <a href='%s'>%s</a> was deleted by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
}
}
if out == "" {
out = fmt.Sprintf("Unknown action '%s' on elementType '%s' by <a href='%s'>%s</a>", action, elementType, actor.Link, actor.Name)
}
return out
}
func routePanelLogsMod(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
if ferr != nil {
@ -1631,21 +1685,6 @@ func routePanelLogsMod(w http.ResponseWriter, r *http.Request, user common.User)
}
defer rows.Close()
// TODO: Log errors when something really screwy is going on?
handleUnknownUser := func(user *common.User, err error) *common.User {
if err != nil {
return &common.User{Name: "Unknown", Link: common.BuildProfileURL("unknown", 0)}
}
return user
}
handleUnknownTopic := func(topic *common.Topic, err error) *common.Topic {
if err != nil {
return &common.Topic{Title: "Unknown", Link: common.BuildProfileURL("unknown", 0)}
}
return topic
}
var logs []common.LogItem
var action, elementType, ipaddress, doneAt string
var elementID, actorID int
@ -1656,41 +1695,7 @@ func routePanelLogsMod(w http.ResponseWriter, r *http.Request, user common.User)
}
actor := handleUnknownUser(common.Users.Get(actorID))
switch action {
case "lock":
topic := handleUnknownTopic(common.Topics.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was locked by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
case "unlock":
topic := handleUnknownTopic(common.Topics.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was reopened by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
case "stick":
topic := handleUnknownTopic(common.Topics.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was pinned by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
case "unstick":
topic := handleUnknownTopic(common.Topics.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was unpinned by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
case "delete":
if elementType == "topic" {
action = fmt.Sprintf("Topic #%d was deleted by <a href='%s'>%s</a>", elementID, actor.Link, actor.Name)
} else {
reply := common.BlankReply()
reply.ID = elementID
topic := handleUnknownTopic(reply.Topic())
action = fmt.Sprintf("A reply in <a href='%s'>%s</a> was deleted by <a href='%s'>%s</a>", topic.Link, topic.Title, actor.Link, actor.Name)
}
case "ban":
targetUser := handleUnknownUser(common.Users.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was banned by <a href='%s'>%s</a>", targetUser.Link, targetUser.Name, actor.Link, actor.Name)
case "unban":
targetUser := handleUnknownUser(common.Users.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was unbanned by <a href='%s'>%s</a>", targetUser.Link, targetUser.Name, actor.Link, actor.Name)
case "activate":
targetUser := handleUnknownUser(common.Users.Get(elementID))
action = fmt.Sprintf("<a href='%s'>%s</a> was activated by <a href='%s'>%s</a>", targetUser.Link, targetUser.Name, actor.Link, actor.Name)
default:
action = fmt.Sprintf("Unknown action '%s' by <a href='%s'>%s</a>", action, actor.Link, actor.Name)
}
action = modlogsElementType(action, elementType, elementID, actor)
logs = append(logs, common.LogItem{Action: template.HTML(action), IPAddress: ipaddress, DoneAt: doneAt})
}
err = rows.Err()

View File

@ -115,8 +115,6 @@ func seedTables(adapter qgen.Adapter) error {
qgen.Install.SimpleInsert("settings", "name, content, type, constraints", "'activation_type','1','list','1-3'")
qgen.Install.SimpleInsert("settings", "name, content, type", "'bigpost_min_words','250','int'")
qgen.Install.SimpleInsert("settings", "name, content, type", "'megapost_min_words','1000','int'")
qgen.Install.SimpleInsert("settings", "name, content, type", "'about_segment_title','','text'")
qgen.Install.SimpleInsert("settings", "name, content, type", "'about_segment_body','','text'")
qgen.Install.SimpleInsert("themes", "uname, default", "'tempra-simple',1")
qgen.Install.SimpleInsert("emails", "email, uid, validated", "'admin@localhost',1,1") // ? - Use a different default email or let the admin input it during installation?

View File

@ -101,7 +101,8 @@ func routeOverview(w http.ResponseWriter, r *http.Request, user common.User) com
if ferr != nil {
return ferr
}
common.BuildWidgets("overview", nil, headerVars, r)
headerVars.Zone = "overview"
headerVars.Writer = w
pi := common.Page{common.GetTitlePhrase("overview"), user, headerVars, tList, nil}
if common.PreRenderHooks["pre_render_overview"] != nil {
@ -127,7 +128,8 @@ func routeCustomPage(w http.ResponseWriter, r *http.Request, user common.User) c
if common.Templates.Lookup("page_"+name) == nil {
return common.NotFound(w, r)
}
common.BuildWidgets("custom_page", name, headerVars, r)
headerVars.Zone = "custom_page"
headerVars.Writer = w
pi := common.Page{common.GetTitlePhrase("page"), user, headerVars, tList, nil}
if common.PreRenderHooks["pre_render_custom_page"] != nil {
@ -148,7 +150,8 @@ func routeTopics(w http.ResponseWriter, r *http.Request, user common.User) commo
if ferr != nil {
return ferr
}
common.BuildWidgets("topics", nil, headerVars, r)
headerVars.Zone = "topics"
headerVars.Writer = w
// TODO: Add a function for the qlist stuff
var qlist string
@ -333,8 +336,8 @@ func routeForum(w http.ResponseWriter, r *http.Request, user common.User, sfid s
} else if err != nil {
return common.InternalError(err, w, r)
}
common.BuildWidgets("view_forum", forum, headerVars, r)
headerVars.Zone = "view_forum"
headerVars.Writer = w
// Calculate the offset
var offset int
@ -420,7 +423,8 @@ func routeForums(w http.ResponseWriter, r *http.Request, user common.User) commo
if ferr != nil {
return ferr
}
common.BuildWidgets("forums", nil, headerVars, r)
headerVars.Zone = "forums"
headerVars.Writer = w
var err error
var forumList []common.Forum
@ -509,8 +513,8 @@ func routeTopicID(w http.ResponseWriter, r *http.Request, user common.User) comm
//log.Printf("user.Perms: %+v\n", user.Perms)
return common.NoPermissions(w, r, user)
}
common.BuildWidgets("view_topic", &topic, headerVars, r)
headerVars.Zone = "view_topic"
headerVars.Writer = w
topic.ContentHTML = common.ParseMessage(topic.Content, topic.ParentID, "forums")
topic.ContentLines = strings.Count(topic.Content, "\n")

View File

@ -3,8 +3,6 @@ INSERT INTO [settings] ([name],[content],[type]) VALUES ('url_tags','1','bool');
INSERT INTO [settings] ([name],[content],[type],[constraints]) VALUES ('activation_type','1','list','1-3');
INSERT INTO [settings] ([name],[content],[type]) VALUES ('bigpost_min_words','250','int');
INSERT INTO [settings] ([name],[content],[type]) VALUES ('megapost_min_words','1000','int');
INSERT INTO [settings] ([name],[content],[type]) VALUES ('about_segment_title','','text');
INSERT INTO [settings] ([name],[content],[type]) VALUES ('about_segment_body','','text');
INSERT INTO [themes] ([uname],[default]) VALUES ('tempra-simple',1);
INSERT INTO [emails] ([email],[uid],[validated]) VALUES ('admin@localhost',1,1);
INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[tag]) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}','{}',1,1,'Admin');

View File

@ -3,8 +3,6 @@ INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('url_tags','1','bool');
INSERT INTO `settings`(`name`,`content`,`type`,`constraints`) VALUES ('activation_type','1','list','1-3');
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('bigpost_min_words','250','int');
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('megapost_min_words','1000','int');
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('about_segment_title','','text');
INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('about_segment_body','','text');
INSERT INTO `themes`(`uname`,`default`) VALUES ('tempra-simple',1);
INSERT INTO `emails`(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}','{}',1,1,'Admin');

View File

@ -27,5 +27,3 @@
;
;
;
;
;

View File

@ -203,37 +203,26 @@ w.Write(forum_57)
w.Write(forum_58)
}
w.Write(forum_59)
if tmpl_forum_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_forum_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_forum_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_forum_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_forum_vars.Header.Themes) != 0 {
for _, item := range tmpl_forum_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_forum_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_forum_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_forum_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_forum_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -118,37 +118,26 @@ w.Write(forums_18)
w.Write(forums_19)
}
w.Write(forums_20)
if tmpl_forums_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_forums_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_forums_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_forums_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_forums_vars.Header.Themes) != 0 {
for _, item := range tmpl_forums_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_forums_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_forums_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_forums_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_forums_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -91,37 +91,26 @@ w.Write(guilds_guild_list_6)
w.Write(guilds_guild_list_7)
}
w.Write(guilds_guild_list_8)
if tmpl_guilds_guild_list_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_guilds_guild_list_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_guilds_guild_list_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_guilds_guild_list_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_guilds_guild_list_vars.Header.Themes) != 0 {
for _, item := range tmpl_guilds_guild_list_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_guilds_guild_list_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_guilds_guild_list_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_guilds_guild_list_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_guilds_guild_list_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -264,36 +264,31 @@ var topic_100 = []byte(`
</main>
`)
var footer_0 = []byte(`<div class="about">
<a id="aboutTitle">`)
var footer_1 = []byte(`</a>
<span id="aboutDesc">`)
var footer_2 = []byte(`</span>
</div>`)
var footer_3 = []byte(`
<div class="footer">
<div id="poweredBy">
<a id="poweredByName" href="https://github.com/Azareal/Gosora">Powered by Gosora</a><span id="poweredByDash"> - </span><span id="poweredByMaker">Made with love by Azareal</span>
</div>
<form action="/theme/" method="post">
<div id="themeSelector" style="float: right;">
<select id="themeSelectorSelect" name="themeSelector" aria-label="Change the site's appearance">
`)
var footer_4 = []byte(`<option val="`)
var footer_5 = []byte(`"`)
var footer_6 = []byte(` selected`)
var footer_7 = []byte(`>`)
var footer_8 = []byte(`</option>`)
var footer_9 = []byte(`
</select>
var footer_0 = []byte(`<div class="footer">
`)
var footer_1 = []byte(`
<div id="poweredByHolder" class="footerBit">
<div id="poweredBy">
<a id="poweredByName" href="https://github.com/Azareal/Gosora">Powered by Gosora</a><span id="poweredByDash"> - </span><span id="poweredByMaker">Made with love by Azareal</span>
</div>
</form>
<form action="/theme/" method="post">
<div id="themeSelector" style="float: right;">
<select id="themeSelectorSelect" name="themeSelector" aria-label="Change the site's appearance">
`)
var footer_2 = []byte(`<option val="`)
var footer_3 = []byte(`"`)
var footer_4 = []byte(` selected`)
var footer_5 = []byte(`>`)
var footer_6 = []byte(`</option>`)
var footer_7 = []byte(`
</select>
</div>
</form>
</div>
</div>
</div>
`)
var footer_10 = []byte(`<aside class="sidebar">`)
var footer_11 = []byte(`</aside>`)
var footer_12 = []byte(`
<aside class="sidebar">`)
var footer_8 = []byte(`</aside>
<div style="clear: both;"></div>
</div>
</div>

View File

@ -161,37 +161,26 @@ w.Write(profile_41)
}
w.Write(profile_42)
w.Write(profile_43)
if tmpl_profile_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_profile_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_profile_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_profile_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_profile_vars.Header.Themes) != 0 {
for _, item := range tmpl_profile_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_profile_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_profile_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_profile_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_profile_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -3,9 +3,9 @@
// Code generated by Gosora. More below:
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
import "strconv"
import "net/http"
import "./common"
import "strconv"
// nolint
func init() {
@ -296,37 +296,26 @@ w.Write(topic_98)
w.Write(topic_99)
}
w.Write(topic_100)
if tmpl_topic_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_topic_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_topic_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_topic_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_topic_vars.Header.Themes) != 0 {
for _, item := range tmpl_topic_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_topic_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_topic_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_topic_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_topic_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -3,9 +3,9 @@
// Code generated by Gosora. More below:
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
import "net/http"
import "./common"
import "strconv"
import "net/http"
// nolint
func init() {
@ -302,37 +302,26 @@ w.Write(topic_alt_102)
w.Write(topic_alt_103)
}
w.Write(topic_alt_104)
if tmpl_topic_alt_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_topic_alt_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_topic_alt_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_topic_alt_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_topic_alt_vars.Header.Themes) != 0 {
for _, item := range tmpl_topic_alt_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_topic_alt_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_topic_alt_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_topic_alt_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_topic_alt_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -3,9 +3,9 @@
// Code generated by Gosora. More below:
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
import "strconv"
import "net/http"
import "./common"
import "strconv"
// nolint
func init() {
@ -199,37 +199,26 @@ w.Write(topics_55)
w.Write(topics_56)
}
w.Write(topics_57)
if tmpl_topics_vars.Header.Theme.AboutSegment {
w.Write(footer_0)
dispInt := tmpl_topics_vars.Header.Settings["about_segment_title"]
w.Write([]byte(dispInt.(string)))
w.Write([]byte(common.BuildWidget("footer",tmpl_topics_vars.Header)))
w.Write(footer_1)
dispInt = tmpl_topics_vars.Header.Settings["about_segment_body"]
w.Write([]byte(dispInt.(string)))
w.Write(footer_2)
}
w.Write(footer_3)
if len(tmpl_topics_vars.Header.Themes) != 0 {
for _, item := range tmpl_topics_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_4)
w.Write(footer_2)
w.Write([]byte(item.Name))
w.Write(footer_5)
w.Write(footer_3)
if tmpl_topics_vars.Header.Theme.Name == item.Name {
w.Write(footer_4)
}
w.Write(footer_5)
w.Write([]byte(item.FriendlyName))
w.Write(footer_6)
}
}
}
w.Write(footer_7)
w.Write([]byte(item.FriendlyName))
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_topics_vars.Header)))
w.Write(footer_8)
}
}
}
w.Write(footer_9)
if tmpl_topics_vars.Header.Widgets.RightSidebar != "" {
w.Write(footer_10)
w.Write([]byte(string(tmpl_topics_vars.Header.Widgets.RightSidebar)))
w.Write(footer_11)
}
w.Write(footer_12)
return nil
}

View File

@ -1,23 +1,22 @@
{{if .Header.Theme.AboutSegment}}<div class="about">
<a id="aboutTitle">{{.Header.Settings.about_segment_title}}</a>
<span id="aboutDesc">{{.Header.Settings.about_segment_body}}</span>
</div>{{end}}
<div class="footer">
<div id="poweredBy">
<a id="poweredByName" href="https://github.com/Azareal/Gosora">Powered by Gosora</a><span id="poweredByDash"> - </span><span id="poweredByMaker">Made with love by Azareal</span>
</div>
<form action="/theme/" method="post">
<div id="themeSelector" style="float: right;">
<select id="themeSelectorSelect" name="themeSelector" aria-label="Change the site's appearance">
{{range .Header.Themes}}
{{if not .HideFromThemes}}<option val="{{.Name}}"{{if eq $.Header.Theme.Name .Name}} selected{{end}}>{{.FriendlyName}}</option>{{end}}
{{end}}
</select>
{{dock "footer" .Header }}
<div id="poweredByHolder" class="footerBit">
<div id="poweredBy">
<a id="poweredByName" href="https://github.com/Azareal/Gosora">Powered by Gosora</a><span id="poweredByDash"> - </span><span id="poweredByMaker">Made with love by Azareal</span>
</div>
</form>
<form action="/theme/" method="post">
<div id="themeSelector" style="float: right;">
<select id="themeSelectorSelect" name="themeSelector" aria-label="Change the site's appearance">
{{range .Header.Themes}}
{{if not .HideFromThemes}}<option val="{{.Name}}"{{if eq $.Header.Theme.Name .Name}} selected{{end}}>{{.FriendlyName}}</option>{{end}}
{{end}}
</select>
</div>
</form>
</div>
</div>
</div>
{{if .Header.Widgets.RightSidebar}}<aside class="sidebar">{{.Header.Widgets.RightSidebar}}</aside>{{end}}
<aside class="sidebar">{{dock "rightSidebar" .Header }}</aside>
<div style="clear: both;"></div>
</div>
</div>

View File

@ -31,7 +31,7 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>Create Group</h1></div>
</div>
<div class="colstack_item">
<div class="colstack_item the_form">
<form action="/panel/groups/create/?session={{.CurrentUser.Session}}" method="post">
<div class="formrow">
<div class="formitem formlabel"><a>Name</a></div>

View File

@ -28,7 +28,7 @@
<div class="colstack_item colstack_head">
<div class="rowitem"><h1>Add Filter</h1></div>
</div>
<div class="colstack_item">
<div class="colstack_item the_form">
<form action="/panel/settings/word-filters/create/?session={{.CurrentUser.Session}}" method="post">
<div class="formrow">
<div class="formitem formlabel"><a>Find</a></div>

View File

@ -0,0 +1,4 @@
<div class="about widget">
<a id="aboutTitle">{{.Name}}</a>
<span id="aboutDesc">{{.Text}}</span>
</div>

View File

@ -34,22 +34,26 @@ body {
margin: 0px;
color: var(--primary-text-color);
}
a {
text-decoration: none;
color: var(--primary-link-color);
}
body, #back {
/*background-color: hsl(0,0%,97%);*/
background-color: hsl(0,0%,98%);
}
#back {
padding: 8px;
padding-top: 14px;
display: flex;
/*background-color: hsl(0,0%,97%);*/
background-color: hsl(0,0%,98%);
padding-left: 0px;
padding-right: 0px;
padding-bottom: 0px;
}
.container {
background-color: var(--element-background-color);
}
#main {
width: 100%;
@ -61,7 +65,7 @@ a {
display: none;
}
.nav {
border-bottom: 1px solid var(--header-border-color);
border-bottom: 2px solid var(--header-border-color);
}
li {
@ -163,9 +167,11 @@ ul {
margin-bottom: 12px;
border: 1px solid var(--header-border-color);
border-bottom: 2px solid var(--header-border-color);
background-color: var(--element-background-color);
margin-left: 12px;
}
.rowblock:not(.topic_list), .colstack_head, .topic_row .rowitem {
background-color: var(--element-background-color);
}
.rowblock {
margin-right: 12px;
}
@ -203,7 +209,7 @@ ul {
width: 300px;
}
.colstack:not(#profile_container) .colstack_right {
width: calc(90% - 300px);
width: 100%;
}
.extra_little_row_avatar {
@ -470,18 +476,25 @@ select, input, textarea, button {
display: flex;
flex-wrap: wrap;
}
.topic_list .topic_row:last-child .rowitem {
margin-bottom: 0px;
}
#forum_topic_list .topic_inner_left .starter {
display: inline-block;
width: 200px;
}
.topic_left, .topic_right {
.rowlist .rowitem, .topic_left, .topic_right {
margin-bottom: 8px;
padding: 4px;
display: flex;
border: 1px solid var(--element-border-color);
border-bottom: 2px solid var(--element-border-color);
}
.rowlist .rowitem {
background-color: var(--element-background-color);
padding: 12px;
}
.topic_list .rowtopic {
font-size: 17px;
@ -788,9 +801,10 @@ select, input, textarea, button {
width: 100%;
margin-right: 12px;
}
#profile_right_lane .colstack_item, .colstack_right .colstack_item {
#profile_right_lane .colstack_item, .colstack_right .colstack_item:not(.rowlist) {
border: 1px solid var(--element-border-color);
border-bottom: 2px solid var(--element-border-color);
background-color: var(--element-background-color);
}
#profile_right_lane .colstack_item, .colstack_right .colstack_item, .colstack_right .colstack_grid {
margin-left: 16px;
@ -836,7 +850,11 @@ select, input, textarea, button {
border-right: none !important;
}
.about, .footer {
/* TODO: Make widget_about's CSS less footer centric */
.footer {
margin-top: 14px;
}
.footerBit, .footer .widget {
border-top: 1px solid var(--element-border-color);
padding: 12px;
padding-top: 10px;
@ -846,14 +864,14 @@ select, input, textarea, button {
background-color: var(--element-background-color);
display: flex;
}
#poweredByHolder {
border-bottom: 2px solid var(--element-border-color);
}
.about, #poweredBy {
font-size: 17px;
display: flex;
flex-direction: column;
}
.about {
margin-top: 14px;
}
#poweredBy {
margin-right: auto;
}
@ -861,8 +879,9 @@ select, input, textarea, button {
font-size: 16px;
}
#aboutTitle {
font-size: 18px;
font-size: 17px;
margin: 8px;
margin-bottom: 4px;
}
#poweredByName {
font-size: 17px;
@ -872,12 +891,17 @@ select, input, textarea, button {
margin-left: 8px;
margin-top: 8px;
width: 60%;
font-size: 16px;
}
#aboutDesc p {
-webkit-margin-before: 12px;
-webkit-margin-after: 12px;
}
#aboutDesc p:last-child {
-webkit-margin-after: 8px;
}
#aboutDesc p:first-child {
-webkit-margin-before: 3px;
-webkit-margin-before: 0px;
}
#poweredByDash, #poweredByMaker {
display: none;
@ -890,12 +914,13 @@ select, input, textarea, button {
.colstack_grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 8px;
}
.grid_item {
background: var(--element-background-color);
border: 1px solid var(--element-border-color);
border-bottom: 2px solid var(--element-border-color);
margin: 8px;
margin: 0px;
padding: 16px;
padding-left: 0px;
display: flex;
@ -919,7 +944,6 @@ select, input, textarea, button {
padding-top: 16px;
padding-right: 19px;
color: hsl(0,0%,20%);
border-bottom: 1px solid var(--element-border-color);
}
#dash-version:before {
content: "\f126";
@ -935,14 +959,4 @@ select, input, textarea, button {
.topic_inner_right {
display: none;
}
}
/*#dash-cpu:before {
content: "\f2db";
width: 30px;
margin-right: 8px;
display: inline-block;
padding-left: 20px;
background: hsl(0,0%,98%);
font: normal normal normal 14px/1 FontAwesome;
}*/
}

View File

@ -1,6 +1,3 @@
.about {
display: none;
}
.footer {
margin-top: 14px;
}

View File

@ -5,7 +5,7 @@
"Creator": "Azareal",
"URL": "github.com/Azareal/Gosora",
"Tag": "WIP",
"Sidebars":"right",
"Docks":["rightSidebar","footer"],
"AboutSegment":true,
"Templates": [
{

View File

@ -511,7 +511,7 @@ input, select, textarea {
padding-left: 30px;
}
.footer {
#poweredByHolder {
background-color: var(--main-block-color);
margin-top: 5px;
padding: 10px;
@ -521,7 +521,7 @@ input, select, textarea {
clear: left;
height: 25px;
}
.footer select {
#poweredByHolder select {
background-color: var(--input-background-color);
border: 1px solid var(--input-border-color);
color: var(--input-text-color);

View File

@ -860,7 +860,7 @@ button.username {
margin-bottom: 6px !important;
}
.footer {
#poweredByHolder {
border: 1px solid var(--main-border-color);
margin-top: 12px;
clear: both;
@ -871,7 +871,7 @@ button.username {
background-color: white;
border-bottom: 1.5px inset var(--main-border-color);
}
.footer select {
#poweredByHolder select {
padding: 2px;
margin-top: 1px;
}
@ -902,13 +902,13 @@ button.username {
/* Firefox specific CSS */
@supports (-moz-appearance: none) {
.footer, .rowmenu, #profile_right_lane .topic_reply_form, .content_container {
#poweredByHolder, .rowmenu, #profile_right_lane .topic_reply_form, .content_container {
border-bottom: 2px inset hsl(0,0%,40%);
}
}
/* Edge... We can't get the exact shade here, because of how they implemented it x.x */
@supports (-ms-ime-align:auto) {
.footer, .rowmenu, #profile_right_lane .topic_reply_form, .content_container {
#poweredByHolder, .rowmenu, #profile_right_lane .topic_reply_form, .content_container {
border-bottom: 1.5px inset hsl(0,0%,100%);
}
}

View File

@ -6,7 +6,7 @@
"FullImage": "tempra-conflux.png",
"MobileFriendly": true,
"URL": "github.com/Azareal/Gosora",
"Sidebars":"right",
"Docks":["rightSidebar"],
"Templates": [
{
"Name": "topic",

View File

@ -8,5 +8,5 @@
"MobileFriendly": true,
"HideFromThemes": true,
"URL": "github.com/Azareal/Gosora",
"Sidebars":"right"
"Docks":["rightSidebar"]
}

View File

@ -718,7 +718,7 @@ button.username {
top: -2px;
}
.footer {
#poweredByHolder {
border: 1px solid hsl(0, 0%, 80%);
margin-top: 12px;
clear: both;
@ -727,7 +727,7 @@ button.username {
padding-left: 10px;
padding-right: 10px;
}
.footer select {
#poweredByHolder select {
padding: 2px;
margin-top: 1px;
}

View File

@ -6,7 +6,7 @@
"FullImage": "tempra-simple.png",
"MobileFriendly": true,
"URL": "github.com/Azareal/Gosora",
"Sidebars":"right",
"Docks":["rightSidebar"],
"Resources": [
{
"Name":"tempra-simple/misc.js",

View File

@ -27,3 +27,6 @@ go get -u github.com/go-ego/riot
echo "Updating the Rez Image Resizer"
go get -u github.com/bamiaux/rez
echo "Updating fsnotify"
go get -u github.com/fsnotify/fsnotify

View File

@ -82,5 +82,12 @@ if %errorlevel% neq 0 (
exit /b %errorlevel%
)
echo Updating fsnotify
go get -u github.com/fsnotify/fsnotify
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo The dependencies were successfully updated
pause