Each theme has more of a distinct feel in the control panel now. I moved a large portion of the inline CSS into global.css, tweaked some core code which didn't line up, and added CSS text insertions to make things more flexible. Revamped the alerts interface. We have more changes coming up! Added screenshots for Tempra Cursive and Tempra Conflux Mobile to the README. Added a .htaccess file, just in case someone plops Gosora in Apache's /www/ folder to stop the contents of config.go from becoming publically visible. Never put Gosora in your /www/ folder, Gosora is a standalone program which does NOT use Apache or any other webserver. Fixed a bug in the inline forum editor. Added a hand-written Markdown parser which is much faster than the previous Regex based one. This is still a work in progress. Added support for strikethrough and underline elements to the Markdown parser. Fixed the missing semicolons in global.js Revamped the form CSS. Author bits on the theme manager now link to the author's website. Improved the profiles a little. The code in the stylesheets now have a more consistent style. Fixed a bug in the Cosmo theme relating to the fact that Gosora doesn't have sidebars yet. There are many more changes which aren't listed here. If weirdness regarding lines or spacing occurs, I'm experimenting with a new text editor. I hope to have this fixed by the next commit.
106 lines
2.0 KiB
Go
106 lines
2.0 KiB
Go
package main
|
|
|
|
//import "fmt"
|
|
import "sync"
|
|
import "strconv"
|
|
import "database/sql"
|
|
import _ "github.com/go-sql-driver/mysql"
|
|
|
|
type ForumAdmin struct
|
|
{
|
|
ID int
|
|
Name string
|
|
Active bool
|
|
Preset string
|
|
TopicCount int
|
|
PresetLang string
|
|
}
|
|
|
|
type Forum struct
|
|
{
|
|
ID int
|
|
Name string
|
|
Active bool
|
|
Preset string
|
|
TopicCount int
|
|
LastTopic string
|
|
LastTopicID int
|
|
LastReplyer string
|
|
LastReplyerID int
|
|
LastTopicTime string
|
|
}
|
|
|
|
type ForumSimple struct
|
|
{
|
|
ID int
|
|
Name string
|
|
Active bool
|
|
Preset string
|
|
}
|
|
|
|
var forum_update_mutex sync.Mutex
|
|
func create_forum(forum_name string, active bool, preset string) (int, error) {
|
|
var fid int
|
|
err := forum_entry_exists_stmt.QueryRow().Scan(&fid)
|
|
if err != nil && err != sql.ErrNoRows {
|
|
return 0, err
|
|
}
|
|
if err != sql.ErrNoRows {
|
|
forum_update_mutex.Lock()
|
|
_, err = update_forum_stmt.Exec(forum_name, active, preset, fid)
|
|
if err != nil {
|
|
return fid, err
|
|
}
|
|
forums[fid].Name = forum_name
|
|
forums[fid].Active = active
|
|
forums[fid].Preset = preset
|
|
forum_update_mutex.Unlock()
|
|
return fid, nil
|
|
}
|
|
|
|
res, err := create_forum_stmt.Exec(forum_name, active, preset)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
|
|
fid64, err := res.LastInsertId()
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
fid = int(fid64)
|
|
|
|
forums = append(forums, Forum{fid,forum_name,active,preset,0,"",0,"",0,""})
|
|
return fid, nil
|
|
}
|
|
|
|
func delete_forum(fid int) error {
|
|
_, err := delete_forum_stmt.Exec(fid)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
forums[fid].Name = ""
|
|
return nil
|
|
}
|
|
|
|
func get_forum(fid int) (forum *Forum, res bool) {
|
|
if !((fid <= forumCapCount) && (fid >= 0) && forums[fid].Name!="") {
|
|
return forum, false
|
|
}
|
|
return &forums[fid], true
|
|
}
|
|
|
|
func get_forum_copy(fid int) (forum Forum, res bool) {
|
|
if !((fid <= forumCapCount) && (fid >= 0) && forums[fid].Name!="") {
|
|
return forum, false
|
|
}
|
|
return forums[fid], true
|
|
}
|
|
|
|
func forum_exists(fid int) bool {
|
|
return (fid <= forumCapCount) && (fid >= 0) && forums[fid].Name!=""
|
|
}
|
|
|
|
func build_forum_url(fid int) string {
|
|
return "/forum/" + strconv.Itoa(fid)
|
|
}
|