Added the query generator. It's a work in progress and in constant flux.

Added forum descriptions.
Began work on the Advanced Forum Editor. Not to be confused with the Quick Forum Editor. You can access it by going to /panel/forums/edit/{forumid} We'll fix it so the Forum Manager links to it in the next commit.
Fixed the Linux shell scripts.
Fixed an issue with relative timess being off by an hour due to timezones.
Added reply count and author names to the topic list and forum pages.
Improved the look of the forum list, forum page, and topic list.
Added an overlay effect for when the alert list is open on mobile.
You can now close the alert list by clicking on the bell.
Removed the "Report:" prefix from report posts.
Fixed a bug in the template system where "and" and "or" wouldn't work on non-boolean values.
Improved the debug logging in the template system.
Fixed a bug in the forum creator where the "Hidden?" value was inverted.
Fixed a visual bug in the profile where the Ban button rendered in a glitchy way.
Added support for hidden fields to the JS Framework for inline editing rows.
Fixed a bug with the like counter rendering on-top of the alert list.
Atom's stripping trailing tabs for some reason, so don't be confused if there are a bunch of weird changes.
This commit is contained in:
Azareal 2017-06-05 12:57:27 +01:00
parent 9b1489b90f
commit e099dfd40e
48 changed files with 1879 additions and 1232 deletions

View File

@ -1,4 +1,8 @@
echo "Building Gosora"
go generate
go build -o Gosora
echo "Building the installer"
go build ./install
cd ./install
go build -o Install
mv ./Install ..
cd ..

View File

@ -1,4 +1,8 @@
echo "Building Gosora"
go generate
go build -o Gosora -tags no_ws
echo "Building the installer"
go build ./install
cd ./install
go build -o Install
mv ./Install ..
cd ..

View File

@ -26,5 +26,12 @@ if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Building the query generator
go build ./query_gen
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Gosora was successfully built
pause

View File

@ -26,5 +26,12 @@ if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Building the query generator
go build ./query_gen
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Gosora was successfully built
pause

View File

@ -46,6 +46,7 @@ CREATE TABLE `emails`(
CREATE TABLE `forums`(
`fid` int not null AUTO_INCREMENT,
`name` varchar(100) not null,
`desc` varchar(200) not null,
`active` tinyint DEFAULT 1 not null,
`topicCount` int DEFAULT 0 not null,
`preset` varchar(100) DEFAULT '' not null,
@ -71,6 +72,7 @@ CREATE TABLE `topics`(
`parsed_content` text not null,
`createdAt` datetime not null,
`lastReplyAt` datetime not null,
/*`lastReplyBy` int not null,*/
`createdBy` int not null,
`is_closed` tinyint DEFAULT 0 not null,
`sticky` tinyint DEFAULT 0 not null,
@ -79,6 +81,7 @@ CREATE TABLE `topics`(
`postCount` int DEFAULT 1 not null,
`likeCount` int DEFAULT 0 not null,
`words` int DEFAULT 0 not null,
`css_class` varchar(100) DEFAULT '' not null,
`data` varchar(200) DEFAULT '' not null,
primary key(`tid`)
) CHARSET=utf8mb4 COLLATE utf8mb4_general_ci;
@ -193,7 +196,7 @@ INSERT INTO settings(`name`,`content`,`type`) VALUES ('bigpost_min_chars','250',
INSERT INTO settings(`name`,`content`,`type`) VALUES ('megapost_min_chars','1000','int');
INSERT INTO themes(`uname`,`default`) VALUES ('tempra-simple',1);
INSERT INTO users(`name`,`password`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`,`last_ip`)
INSERT INTO users(`name`,`password`,`email`,`group`,`is_super_admin`,`createdAt`,`lastActiveAt`,`message`,`last_ip`)
VALUES ('Admin','password','admin@localhost',1,1,NOW(),NOW(),'','127.0.0.1');
INSERT INTO emails(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1);
@ -247,8 +250,8 @@ INSERT INTO forums_permissions(`gid`,`fid`,`permissions`) VALUES (3,1,'{}');
INSERT INTO forums_permissions(`gid`,`fid`,`permissions`) VALUES (4,1,'{}');
INSERT INTO forums_permissions(`gid`,`fid`,`permissions`) VALUES (5,1,'{}');
INSERT INTO forums_permissions(`gid`,`fid`,`permissions`) VALUES (6,1,'{}');
INSERT INTO topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`)
INSERT INTO topics(`title`,`content`,`createdAt`,`lastReplyAt`,`createdBy`,`parentID`)
VALUES ('Test Topic','A topic automatically generated by the software.',NOW(),NOW(),1,2);
INSERT INTO replies(`tid`,`content`,`createdAt`,`createdBy`,`lastEdit`,`lastEditBy`)
VALUES (1,'Reply 1',NOW(),1,0,0);
INSERT INTO replies(`tid`,`content`,`createdAt`,`createdBy`,`lastEdit`,`lastEditBy`)
VALUES (1,'Reply 1',NOW(),1,0,0);

View File

@ -10,6 +10,7 @@ type ForumAdmin struct
{
ID int
Name string
Desc string
Active bool
Preset string
TopicCount int
@ -20,6 +21,7 @@ type Forum struct
{
ID int
Name string
Desc string
Active bool
Preset string
TopicCount int
@ -39,7 +41,7 @@ type ForumSimple struct
}
var forum_update_mutex sync.Mutex
func create_forum(forum_name string, active bool, preset string) (int, error) {
func create_forum(forum_name string, forum_desc string, active bool, preset string) (int, error) {
var fid int
err := forum_entry_exists_stmt.QueryRow().Scan(&fid)
if err != nil && err != sql.ErrNoRows {
@ -47,29 +49,30 @@ func create_forum(forum_name string, active bool, preset string) (int, error) {
}
if err != sql.ErrNoRows {
forum_update_mutex.Lock()
_, err = update_forum_stmt.Exec(forum_name, active, preset, fid)
_, err = update_forum_stmt.Exec(forum_name, forum_desc, active, preset, fid)
if err != nil {
return fid, err
}
forums[fid].Name = forum_name
forums[fid].Desc = forum_desc
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)
res, err := create_forum_stmt.Exec(forum_name, forum_desc, 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,""})
forums = append(forums, Forum{fid,forum_name,forum_desc,active,preset,0,"",0,"",0,""})
return fid, nil
}
@ -90,14 +93,14 @@ func get_forum(fid int) (forum *Forum, res bool) {
}
func get_forum_copy(fid int) (forum Forum, res bool) {
if !((fid <= forumCapCount) && (fid >= 0) && forums[fid].Name!="") {
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!=""
return (fid <= forumCapCount) && (fid >= 0) && forums[fid].Name != ""
}
func build_forum_url(fid int) string {

63
gen_mysql.go Normal file
View File

@ -0,0 +1,63 @@
/* This file was generated by Gosora's Query Generator */
package main
import "log"
import "database/sql"
var get_user_stmt *sql.Stmt
var get_full_user_stmt *sql.Stmt
var get_topic_stmt *sql.Stmt
var get_reply_stmt *sql.Stmt
var login_stmt *sql.Stmt
var get_password_stmt *sql.Stmt
var username_exists_stmt *sql.Stmt
func gen_mysql() (err error) {
if debug {
log.Print("Building the generated statements")
}
log.Print("Preparing get_user statement.")
get_user_stmt, err = db.Prepare("SELECT `name`,`group`,`is_super_admin`,`avatar`,`message`,`url_prefix`,`url_name`,`level` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_full_user statement.")
get_full_user_stmt, err = db.Prepare("SELECT `name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_topic statement.")
get_topic_stmt, err = db.Prepare("SELECT `title`,`content`,`createdBy`,`createdAt`,`is_closed`,`sticky`,`parentID`,`ipaddress`,`postCount`,`likeCount` FROM topics WHERE `tid`= ?")
if err != nil {
return err
}
log.Print("Preparing get_reply statement.")
get_reply_stmt, err = db.Prepare("SELECT `content`,`createdBy`,`createdAt`,`lastEdit`,`lastEditBy`,`ipaddress`,`likeCount` FROM replies WHERE `rid`= ?")
if err != nil {
return err
}
log.Print("Preparing login statement.")
login_stmt, err = db.Prepare("SELECT `uid`,`name`,`password`,`salt` FROM users WHERE `name`= ?")
if err != nil {
return err
}
log.Print("Preparing get_password statement.")
get_password_stmt, err = db.Prepare("SELECT `password`,`salt` FROM users WHERE `uid`= ?")
if err != nil {
return err
}
log.Print("Preparing username_exists statement.")
username_exists_stmt, err = db.Prepare("SELECT `name` FROM users WHERE `name`= ?")
if err != nil {
return err
}
return nil
}

View File

@ -1,6 +1,5 @@
// Code generated by. DO NOT EDIT.
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
// The router generator might be discontinued in favour of syncmaps in Go 1.9, it will be temporarily used for a couple of months as a lockless alternative to maps
package main
//import "fmt"
@ -102,6 +101,9 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
case "/panel/forums/edit/submit/":
route_panel_forums_edit_submit(w,req,extra_data)
return
case "/panel/forums/edit/perms/submit/":
route_panel_forums_edit_perms_submit(w,req,extra_data)
return
case "/panel/settings/":
route_panel_settings(w,req)
return

69
main.go
View File

@ -6,6 +6,7 @@ import (
"fmt"
"log"
"mime"
"time"
"strings"
"path/filepath"
"io"
@ -32,6 +33,8 @@ const saltLength int = 32
const sessionLength int = 80
var enable_websockets bool = false // Don't change this, the value is overwritten by an initialiser
var startTime time.Time
var timeLocation *time.Location
var templates = template.New("")
var no_css_tmpl = template.CSS("")
var staff_css_tmpl = template.CSS(staff_css)
@ -40,8 +43,7 @@ var external_sites map[string]string = make(map[string]string)
var groups []Group
var forums []Forum // The IDs for a forum tend to be low and sequential for the most part, so we can get more performance out of using a slice instead of a map AND it has better concurrency
var forum_perms map[int]map[int]ForumPerms // [gid][fid]Perms
var groupCapCount int
var forumCapCount int
var groupCapCount, forumCapCount int
var static_files map[string]SFile = make(map[string]SFile)
var template_topic_handle func(TopicPage,io.Writer) = nil
@ -56,22 +58,22 @@ 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"}
log.Print("Compiling the templates")
topic := TopicUser{1,"Blah","Hey there!",0,false,false,"Date","Date",0,"","127.0.0.1",0,1,"",default_group,"",no_css_tmpl,0,"","","","",58,false}
topic := TopicUser{1,"Blah","Hey there!",0,false,false,"Date","Date",0,"","127.0.0.1",0,1,"classname","",default_group,"",no_css_tmpl,0,"","","","",58,false}
var replyList []Reply
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}
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}
profile_tmpl := c.compile_template("profile.html","templates/","ProfilePage", ppage, varList)
var forumList []Forum
for _, forum := range forums {
if forum.Active {
@ -81,18 +83,18 @@ func compile_templates() {
varList = make(map[string]VarItem)
forums_page := ForumsPage{"Forum List",user,noticeList,forumList,0}
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,"Admin","","",0,"","","","",58,"General"})
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_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,"Admin",default_group,"","",0,"","","","",58,false})
forum_item := Forum{1,"General Forum",true,"all",0,"",0,"",0,""}
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_tmpl := c.compile_template("forum.html","templates/","ForumPage", forum_page, varList)
log.Print("Writing the templates")
go write_template("topic", topic_id_tmpl)
go write_template("topic_alt", topic_id_alt_tmpl)
@ -112,7 +114,7 @@ func write_template(name string, content string) {
func init_templates() {
compile_templates()
// Filler functions for now...
filler_func := func(in interface{}, in2 interface{})interface{} {
return 1
@ -122,7 +124,7 @@ func init_templates() {
fmap["subtract"] = filler_func
fmap["multiply"] = filler_func
fmap["divide"] = filler_func
// The interpreted templates...
templates.Funcs(fmap)
template.Must(templates.ParseGlob("templates/*"))
@ -135,19 +137,19 @@ func init_static_files() {
if f.IsDir() {
return nil
}
path = strings.Replace(path,"\\","/",-1)
data, err := ioutil.ReadFile(path)
if err != nil {
return err
}
path = strings.TrimPrefix(path,"public/")
if debug {
log.Print("Added the '" + path + "' static file.")
}
gzip_data := compress_bytes_gzip(data)
static_files["/static/" + path] = SFile{data,gzip_data,0,int64(len(data)),int64(len(gzip_data)),mime.TypeByExtension(filepath.Ext("/public/" + path)),f,f.ModTime().UTC().Format(http.TimeFormat)}
return nil
})
@ -164,22 +166,24 @@ func main(){
// }
// pprof.StartCPUProfile(f)
//}
log.Print("Running Gosora v" + version.String())
fmt.Println("")
startTime = time.Now()
timeLocation = startTime.Location()
init_themes()
err := init_database()
if err != nil {
log.Fatal(err)
}
init_templates()
err = init_errors()
if err != nil {
log.Fatal(err)
}
if cache_topicuser == CACHE_STATIC {
users = NewStaticUserStore(user_cache_capacity)
topics = NewStaticTopicStore(topic_cache_capacity)
@ -187,13 +191,13 @@ func main(){
users = NewSqlUserStore()
topics = NewSqlTopicStore()
}
init_static_files()
external_sites["YT"] = "https://www.youtube.com/"
hooks["trow_assign"] = nil
hooks["rrow_assign"] = nil
init_plugins()
router := NewGenRouter(http.FileServer(http.Dir("./uploads")))
///router.HandleFunc("/static/", route_static)
///router.HandleFunc("/overview/", route_overview)
@ -215,17 +219,17 @@ func main(){
router.HandleFunc("/topic/stick/submit/", route_stick_topic)
router.HandleFunc("/topic/unstick/submit/", route_unstick_topic)
router.HandleFunc("/topic/like/submit/", route_like_topic)
// Custom Pages
router.HandleFunc("/pages/", route_custom_page)
// Accounts
router.HandleFunc("/accounts/login/", route_login)
router.HandleFunc("/accounts/create/", route_register)
router.HandleFunc("/accounts/logout/", route_logout)
router.HandleFunc("/accounts/login/submit/", route_login_submit)
router.HandleFunc("/accounts/create/submit/", route_register_submit)
//router.HandleFunc("/accounts/list/", route_login) // Redirect /accounts/ and /user/ to here.. // Get a list of all of the accounts on the forum
//router.HandleFunc("/accounts/create/full/", route_logout) // Advanced account creator for admins?
//router.HandleFunc("/user/edit/", route_logout)
@ -246,7 +250,7 @@ func main(){
router.HandleFunc("/users/ban/submit/", route_ban_submit)
router.HandleFunc("/users/unban/", route_unban)
router.HandleFunc("/users/activate/", route_activate)
// The Control Panel
///router.HandleFunc("/panel/", route_panel)
///router.HandleFunc("/panel/forums/", route_panel_forums)
@ -255,6 +259,7 @@ func main(){
///router.HandleFunc("/panel/forums/delete/submit/", route_panel_forums_delete_submit)
///router.HandleFunc("/panel/forums/edit/", route_panel_forums_edit)
///router.HandleFunc("/panel/forums/edit/submit/", route_panel_forums_edit_submit)
///router.HandleFunc("/panel/forums/edit/perms/submit/", route_panel_forums_edit_perms_submit)
///router.HandleFunc("/panel/settings/", route_panel_settings)
///router.HandleFunc("/panel/settings/edit/", route_panel_setting)
///router.HandleFunc("/panel/settings/edit/submit/", route_panel_setting_edit)
@ -273,17 +278,17 @@ func main(){
///router.HandleFunc("/panel/groups/edit/perms/submit/", route_panel_groups_edit_perms_submit)
///router.HandleFunc("/panel/groups/create/", route_panel_groups_create_submit)
///router.HandleFunc("/panel/logs/mod/", route_panel_logs_mod)
///router.HandleFunc("/api/", route_api)
//router.HandleFunc("/exit/", route_exit)
///router.HandleFunc("/", default_route)
router.HandleFunc("/ws/", route_websockets)
defer db.Close()
//if profiling {
// pprof.StopCPUProfile()
//}
if !enable_ssl {
if server_port == "" {
server_port = "80"

300
mysql.go
View File

@ -12,15 +12,11 @@ var db *sql.DB
var db_version string
var db_collation string = "utf8mb4_general_ci"
var get_user_stmt *sql.Stmt
var get_full_user_stmt *sql.Stmt
var get_topic_list_stmt *sql.Stmt
var get_topic_user_stmt *sql.Stmt
var get_topic_stmt *sql.Stmt
var get_topic_by_reply_stmt *sql.Stmt
var get_topic_replies_stmt *sql.Stmt
var get_topic_replies_offset_stmt *sql.Stmt
var get_reply_stmt *sql.Stmt
var get_forum_topics_stmt *sql.Stmt
var get_forum_topics_offset_stmt *sql.Stmt
var create_topic_stmt *sql.Stmt
@ -47,18 +43,15 @@ var stick_topic_stmt *sql.Stmt
var unstick_topic_stmt *sql.Stmt
var get_activity_feed_by_watcher_stmt *sql.Stmt
var update_last_ip_stmt *sql.Stmt
var login_stmt *sql.Stmt
var update_session_stmt *sql.Stmt
var logout_stmt *sql.Stmt
var set_password_stmt *sql.Stmt
var get_password_stmt *sql.Stmt
var set_avatar_stmt *sql.Stmt
var set_username_stmt *sql.Stmt
var add_email_stmt *sql.Stmt
var update_email_stmt *sql.Stmt
var verify_email_stmt *sql.Stmt
var register_stmt *sql.Stmt
var username_exists_stmt *sql.Stmt
var change_group_stmt *sql.Stmt
var activate_user_stmt *sql.Stmt
var update_user_level_stmt *sql.Stmt
@ -82,6 +75,8 @@ var add_forum_perms_to_forum_admins_stmt *sql.Stmt
var add_forum_perms_to_forum_staff_stmt *sql.Stmt
var add_forum_perms_to_forum_members_stmt *sql.Stmt
var add_forum_perms_to_group_stmt *sql.Stmt
//var forum_perm_exists_for_group_stmt *sql.Stmt
var update_forum_perms_for_group_stmt *sql.Stmt
var update_setting_stmt *sql.Stmt
var add_plugin_stmt *sql.Stmt
var update_plugin_stmt *sql.Stmt
@ -99,530 +94,488 @@ func init_database() (err error) {
if(dbpassword != ""){
dbpassword = ":" + dbpassword
}
// Open the database connection
db, err = sql.Open("mysql",dbuser + dbpassword + "@tcp(" + dbhost + ":" + dbport + ")/" + dbname + "?collation=" + db_collation)
if err != nil {
return err
}
// Make sure that the connection is alive
err = db.Ping()
if err != nil {
return err
}
// Fetch the database version
db.QueryRow("SELECT VERSION()").Scan(&db_version)
// Set the number of max open connections
db.SetMaxOpenConns(64)
/*log.Print("Preparing get_session statement.")
get_session_stmt, err = db.Prepare("select `uid`,`name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` from `users` where `uid` = ? and `session` = ? AND `session` <> ''")
if err != nil {
return err
}*/
log.Print("Preparing get_user statement.")
get_user_stmt, err = db.Prepare("select `name`,`group`,`is_super_admin`,`avatar`,`message`,`url_prefix`,`url_name`,`level` from `users` where `uid` = ?")
// Build the generated prepared statements, we are going to slowly move the queries over to the query generator rather than writing them all by hand, this'll make it easier for us to implement database adapters for other databases like PostgreSQL, MSSQL, SQlite, etc.
err = gen_mysql()
if err != nil {
return err
}
log.Print("Preparing get_full_user statement.")
get_full_user_stmt, err = db.Prepare("select `name`,`group`,`is_super_admin`,`session`,`email`,`avatar`,`message`,`url_prefix`,`url_name`,`level`,`score`,`last_ip` from `users` where `uid` = ?")
if err != nil {
return err
}
log.Print("Preparing get_topic_list statement.")
get_topic_list_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC")
if err != nil {
return err
}
log.Print("Preparing get_topic_user statement.")
get_topic_user_stmt, err = db.Prepare("select topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount, users.name, users.avatar, users.group, users.url_prefix, users.url_name, users.level from topics left join users ON topics.createdBy = users.uid where tid = ?")
if err != nil {
return err
}
log.Print("Preparing get_topic statement.")
get_topic_stmt, err = db.Prepare("select title, content, createdBy, createdAt, is_closed, sticky, parentID, ipaddress, postCount, likeCount from topics where tid = ?")
if err != nil {
return err
}
log.Print("Preparing get_topic_by_reply statement.")
get_topic_by_reply_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.createdAt, topics.is_closed, topics.sticky, topics.parentID, topics.ipaddress, topics.postCount, topics.likeCount from replies left join topics on replies.tid = topics.tid where rid = ?")
if err != nil {
return err
}
log.Print("Preparing get_topic_replies statement.")
get_topic_replies_stmt, err = db.Prepare("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress from replies left join users ON replies.createdBy = users.uid where tid = ?")
if err != nil {
return err
}
log.Print("Preparing get_topic_replies_offset statement.")
get_topic_replies_offset_stmt, err = db.Prepare("select replies.rid, replies.content, replies.createdBy, replies.createdAt, replies.lastEdit, replies.lastEditBy, users.avatar, users.name, users.group, users.url_prefix, users.url_name, users.level, replies.ipaddress, replies.likeCount, replies.actionType from replies left join users on replies.createdBy = users.uid where tid = ? limit ?, " + strconv.Itoa(items_per_page))
if err != nil {
return err
}
log.Print("Preparing get_reply statement.")
get_reply_stmt, err = db.Prepare("select content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress, likeCount from replies where rid = ?")
if err != nil {
return err
}
log.Print("Preparing get_forum_topics statement.")
get_forum_topics_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid where topics.parentID = ? order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy desc")
if err != nil {
return err
}
log.Print("Preparing get_forum_topics_offset statement.")
get_forum_topics_offset_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.likeCount, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid WHERE topics.parentID = ? order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC limit ?, " + strconv.Itoa(items_per_page))
get_forum_topics_offset_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.postCount, topics.likeCount, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid WHERE topics.parentID = ? order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC limit ?, " + strconv.Itoa(items_per_page))
if err != nil {
return err
}
log.Print("Preparing create_topic statement.")
create_topic_stmt, err = db.Prepare("insert into topics(parentID,title,content,parsed_content,createdAt,lastReplyAt,ipaddress,words,createdBy) VALUES(?,?,?,?,NOW(),NOW(),?,?,?)")
if err != nil {
return err
}
log.Print("Preparing create_report statement.")
create_report_stmt, err = db.Prepare("INSERT INTO topics(title,content,parsed_content,createdAt,lastReplyAt,createdBy,data,parentID) VALUES(?,?,?,NOW(),NOW(),?,?,1)")
create_report_stmt, err = db.Prepare("INSERT INTO topics(title,content,parsed_content,createdAt,lastReplyAt,createdBy,data,parentID,css_class) VALUES(?,?,?,NOW(),NOW(),?,?,1,'report')")
if err != nil {
return err
}
log.Print("Preparing create_reply statement.")
create_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,content,parsed_content,createdAt,ipaddress,words,createdBy) VALUES(?,?,?,NOW(),?,?,?)")
if err != nil {
return err
}
log.Print("Preparing create_action_reply statement.")
create_action_reply_stmt, err = db.Prepare("INSERT INTO replies(tid,actionType,ipaddress,createdBy) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing add_replies_to_topic statement.")
add_replies_to_topic_stmt, err = db.Prepare("UPDATE topics SET postCount = postCount + ?, lastReplyAt = NOW() WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing remove_replies_from_topic statement.")
remove_replies_from_topic_stmt, err = db.Prepare("UPDATE topics SET postCount = postCount - ? WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing add_topics_to_forum statement.")
add_topics_to_forum_stmt, err = db.Prepare("UPDATE forums SET topicCount = topicCount + ? WHERE fid = ?")
if err != nil {
return err
}
log.Print("Preparing remove_topics_from_forum statement.")
remove_topics_from_forum_stmt, err = db.Prepare("UPDATE forums SET topicCount = topicCount - ? WHERE fid = ?")
if err != nil {
return err
}
log.Print("Preparing update_forum_cache statement.")
update_forum_cache_stmt, err = db.Prepare("UPDATE forums SET lastTopic = ?, lastTopicID = ?, lastReplyer = ?, lastReplyerID = ?, lastTopicTime = NOW() WHERE fid = ?")
if err != nil {
return err
}
log.Print("Preparing create_like statement.")
create_like_stmt, err = db.Prepare("INSERT INTO likes(weight, targetItem, targetType, sentBy) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing add_likes_to_topic statement.")
add_likes_to_topic_stmt, err = db.Prepare("UPDATE topics SET likeCount = likeCount + ? WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing add_likes_to_reply statement.")
add_likes_to_reply_stmt, err = db.Prepare("UPDATE replies SET likeCount = likeCount + ? WHERE rid = ?")
if err != nil {
return err
}
log.Print("Preparing add_activity statement.")
add_activity_stmt, err = db.Prepare("INSERT INTO activity_stream(actor,targetUser,event,elementType,elementID) VALUES(?,?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing notify_watchers statement.")
notify_watchers_stmt, err = db.Prepare("INSERT INTO activity_stream_matches(watcher, asid) SELECT activity_subscriptions.user, activity_stream.asid FROM activity_stream INNER JOIN activity_subscriptions ON activity_subscriptions.targetType = activity_stream.elementType and activity_subscriptions.targetID = activity_stream.elementID and activity_subscriptions.user != activity_stream.actor where asid = ?")
if err != nil {
return err
}
log.Print("Preparing notify_one statement.")
notify_one_stmt, err = db.Prepare("INSERT INTO activity_stream_matches(watcher,asid) VALUES(?,?)")
if err != nil {
return err
}
log.Print("Preparing add_subscription statement.")
add_subscription_stmt, err = db.Prepare("INSERT INTO activity_subscriptions(user,targetID,targetType,level) VALUES(?,?,?,2)")
if err != nil {
return err
}
log.Print("Preparing edit_topic statement.")
edit_topic_stmt, err = db.Prepare("UPDATE topics SET title = ?, content = ?, parsed_content = ?, is_closed = ? WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing edit_reply statement.")
edit_reply_stmt, err = db.Prepare("UPDATE replies SET content = ?, parsed_content = ? WHERE rid = ?")
if err != nil {
return err
}
log.Print("Preparing delete_reply statement.")
delete_reply_stmt, err = db.Prepare("DELETE FROM replies WHERE rid = ?")
if err != nil {
return err
}
log.Print("Preparing delete_topic statement.")
delete_topic_stmt, err = db.Prepare("DELETE FROM topics WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing stick_topic statement.")
stick_topic_stmt, err = db.Prepare("UPDATE topics SET sticky = 1 WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing unstick_topic statement.")
unstick_topic_stmt, err = db.Prepare("UPDATE topics SET sticky = 0 WHERE tid = ?")
if err != nil {
return err
}
log.Print("Preparing get_activity_feed_by_watcher statement.")
get_activity_feed_by_watcher_stmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID FROM `activity_stream_matches` INNER JOIN `activity_stream` ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE `watcher` = ?")
if err != nil {
return err
}
log.Print("Preparing update_last_ip statement.")
update_last_ip_stmt, err = db.Prepare("UPDATE users SET last_ip = ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing login statement.")
login_stmt, err = db.Prepare("SELECT `uid`,`name`,`password`,`salt` FROM `users` WHERE `name` = ?")
if err != nil {
return err
}
log.Print("Preparing update_session statement.")
update_session_stmt, err = db.Prepare("UPDATE users SET session = ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing logout statement.")
logout_stmt, err = db.Prepare("UPDATE users SET session = '' WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing set_password statement.")
set_password_stmt, err = db.Prepare("UPDATE users SET password = ?, salt = ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing get_password statement.")
get_password_stmt, err = db.Prepare("SELECT `password`,`salt` FROM `users` WHERE `uid` = ?")
if err != nil {
return err
}
log.Print("Preparing set_avatar statement.")
set_avatar_stmt, err = db.Prepare("UPDATE users SET avatar = ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing set_username statement.")
set_username_stmt, err = db.Prepare("UPDATE users SET name = ? WHERE uid = ?")
if err != nil {
return err
}
// Add an admin version of register_stmt with more flexibility
// create_account_stmt, err = db.Prepare("INSERT INTO
// create_account_stmt, err = db.Prepare("INSERT INTO
log.Print("Preparing register statement.")
register_stmt, err = db.Prepare("INSERT INTO users(`name`,`email`,`password`,`salt`,`group`,`is_super_admin`,`session`,`active`,`message`) VALUES(?,?,?,?,?,0,?,?,'')")
if err != nil {
return err
}
log.Print("Preparing username_exists statement.")
username_exists_stmt, err = db.Prepare("SELECT `name` FROM `users` WHERE `name` = ?")
if err != nil {
return err
}
log.Print("Preparing change_group statement.")
change_group_stmt, err = db.Prepare("update `users` set `group` = ? where `uid` = ?")
if err != nil {
return err
}
log.Print("Preparing add_email statement.")
add_email_stmt, err = db.Prepare("INSERT INTO emails(`email`,`uid`,`validated`,`token`) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing update_email statement.")
update_email_stmt, err = db.Prepare("UPDATE emails SET email = ?, uid = ?, validated = ?, token = ? WHERE email = ?")
if err != nil {
return err
}
log.Print("Preparing verify_email statement.")
verify_email_stmt, err = db.Prepare("UPDATE emails SET validated = 1, token = '' WHERE email = ?")
if err != nil {
return err
}
log.Print("Preparing activate_user statement.")
activate_user_stmt, err = db.Prepare("UPDATE users SET active = 1 WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing update_user_level statement.")
update_user_level_stmt, err = db.Prepare("UPDATE users SET level = ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing increment_user_score statement.")
increment_user_score_stmt, err = db.Prepare("UPDATE users SET score = score + ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing increment_user_posts statement.")
increment_user_posts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing increment_user_bigposts statement.")
increment_user_bigposts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ?, bigposts = bigposts + ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing increment_user_megaposts statement.")
increment_user_megaposts_stmt, err = db.Prepare("UPDATE users SET posts = posts + ?, bigposts = bigposts + ?, megaposts = megaposts + ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing increment_user_topics statement.")
increment_user_topics_stmt, err = db.Prepare("UPDATE users SET topics = topics + ? WHERE uid = ?")
if err != nil {
return err
}
log.Print("Preparing create_profile_reply statement.")
create_profile_reply_stmt, err = db.Prepare("INSERT INTO users_replies(uid,content,parsed_content,createdAt,createdBy) VALUES(?,?,?,NOW(),?)")
if err != nil {
return err
}
log.Print("Preparing edit_profile_reply statement.")
edit_profile_reply_stmt, err = db.Prepare("UPDATE users_replies SET content = ?, parsed_content = ? WHERE rid = ?")
if err != nil {
return err
}
log.Print("Preparing delete_profile_reply statement.")
delete_profile_reply_stmt, err = db.Prepare("DELETE FROM users_replies WHERE rid = ?")
if err != nil {
return err
}
log.Print("Preparing create_forum statement.")
create_forum_stmt, err = db.Prepare("INSERT INTO forums(name,active,preset) VALUES(?,?,?)")
create_forum_stmt, err = db.Prepare("INSERT INTO forums(`name`,`desc`,`active`,`preset`) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing delete_forum statement.")
//delete_forum_stmt, err = db.Prepare("DELETE FROM forums WHERE fid = ?")
//delete_forum_stmt, err = db.Prepare("delete from forums where fid = ?")
delete_forum_stmt, err = db.Prepare("update forums set name= '', active = 0 where fid = ?")
if err != nil {
return err
}
log.Print("Preparing update_forum statement.")
update_forum_stmt, err = db.Prepare("update forums set name = ?, active = ?, preset = ? where fid = ?")
update_forum_stmt, err = db.Prepare("update forums set `name` = ?, `desc` = ?, `active` = ?, `preset` = ? where fid = ?")
if err != nil {
return err
}
log.Print("Preparing forum_entry_exists statement.")
forum_entry_exists_stmt, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' order by fid asc limit 1")
if err != nil {
return err
}
log.Print("Preparing group_entry_exists statement.")
group_entry_exists_stmt, err = db.Prepare("SELECT `gid` FROM `users_groups` WHERE `name` = '' order by gid asc limit 1")
if err != nil {
return err
}
log.Print("Preparing delete_forum_perms_by_forum statement.")
delete_forum_perms_by_forum_stmt, err = db.Prepare("DELETE FROM forums_permissions WHERE fid = ?")
if err != nil {
return err
}
log.Print("Preparing add_forum_perms_to_forum statement.")
add_forum_perms_to_forum_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing add_forum_perms_to_forum_admins statement.")
add_forum_perms_to_forum_admins_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 1")
if err != nil {
return err
}
log.Print("Preparing add_forum_perms_to_forum_staff statement.")
add_forum_perms_to_forum_staff_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 0 AND is_mod = 1")
if err != nil {
return err
}
log.Print("Preparing add_forum_perms_to_forum_members statement.")
add_forum_perms_to_forum_members_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) SELECT `gid`,? AS fid,? AS preset,? AS permissions FROM users_groups WHERE is_admin = 0 AND is_mod = 0 AND is_banned = 0")
if err != nil {
return err
}
log.Print("Preparing add_forum_perms_to_group statement.")
add_forum_perms_to_group_stmt, err = db.Prepare("INSERT INTO forums_permissions(gid,fid,preset,permissions) VALUES(?,?,?,?)")
add_forum_perms_to_group_stmt, err = db.Prepare("REPLACE INTO forums_permissions(gid,fid,preset,permissions) VALUES(?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing update_setting statement.")
update_setting_stmt, err = db.Prepare("UPDATE settings SET content = ? WHERE name = ?")
if err != nil {
return err
}
log.Print("Preparing add_plugin statement.")
add_plugin_stmt, err = db.Prepare("INSERT INTO plugins(uname,active) VALUES(?,?)")
if err != nil {
return err
}
log.Print("Preparing update_plugin statement.")
update_plugin_stmt, err = db.Prepare("UPDATE plugins SET active = ? WHERE uname = ?")
if err != nil {
return err
}
log.Print("Preparing add_theme statement.")
add_theme_stmt, err = db.Prepare("INSERT INTO `themes`(`uname`,`default`) VALUES(?,?)")
if err != nil {
return err
}
log.Print("Preparing update_theme statement.")
update_theme_stmt, err = db.Prepare("update `themes` set `default` = ? where `uname` = ?")
if err != nil {
return err
}
log.Print("Preparing update_user statement.")
update_user_stmt, err = db.Prepare("update `users` set `name` = ?,`email` = ?,`group` = ? where `uid` = ?")
if err != nil {
return err
}
log.Print("Preparing update_group_rank statement.")
update_group_perms_stmt, err = db.Prepare("update `users_groups` set `permissions` = ? where `gid` = ?")
if err != nil {
return err
}
log.Print("Preparing update_group_rank statement.")
update_group_rank_stmt, err = db.Prepare("update `users_groups` set `is_admin` = ?, `is_mod` = ?, `is_banned` = ? where `gid` = ?")
if err != nil {
return err
}
log.Print("Preparing update_group statement.")
update_group_stmt, err = db.Prepare("update `users_groups` set `name` = ?, `tag` = ? where `gid` = ?")
if err != nil {
return err
}
log.Print("Preparing create_group statement.")
create_group_stmt, err = db.Prepare("INSERT INTO users_groups(name,tag,is_admin,is_mod,is_banned,permissions) VALUES(?,?,?,?,?,?)")
if err != nil {
return err
}
log.Print("Preparing add_modlog_entry statement.")
add_modlog_entry_stmt, err = db.Prepare("INSERT INTO moderation_logs(action,elementID,elementType,ipaddress,actorID,doneAt) VALUES(?,?,?,?,?,NOW())")
if err != nil {
return err
}
log.Print("Preparing add_adminlog_entry statement.")
add_adminlog_entry_stmt, err = db.Prepare("INSERT INTO moderation_logs(action,elementID,elementType,ipaddress,actorID,doneAt) VALUES(?,?,?,?,?,NOW())")
if err != nil {
return err
}
log.Print("Loading the usergroups.")
groups = append(groups, Group{ID:0,Name:"System"})
rows, err := db.Query("select gid,name,permissions,is_mod,is_admin,is_banned,tag from users_groups")
if err != nil {
return err
}
defer rows.Close()
i := 1
for ;rows.Next();i++ {
group := Group{ID: 0,}
@ -630,13 +583,13 @@ func init_database() (err error) {
if err != nil {
return err
}
// Ugh, you really shouldn't physically delete these items, it makes a big mess of things
if group.ID != i {
log.Print("Stop physically deleting groups. You are messing up the IDs. Use the Group Manager or delete_group() instead x.x")
fill_group_id_gap(i, group.ID)
}
err = json.Unmarshal(group.PermissionsText, &group.Perms)
if err != nil {
return err
@ -645,7 +598,7 @@ func init_database() (err error) {
log.Print(group.Name + ": ")
fmt.Printf("%+v\n", group.Perms)
}
group.Perms.ExtData = make(map[string]bool)
groups = append(groups, group)
}
@ -654,45 +607,35 @@ func init_database() (err error) {
return err
}
groupCapCount = i
log.Print("Binding the Not Loggedin Group")
GuestPerms = groups[6].Perms
log.Print("Loading the forums.")
log.Print("Adding the uncategorised forum")
forums = append(forums, Forum{0,"Uncategorised",uncategorised_forum_visible,"all",0,"",0,"",0,""})
forums = append(forums, Forum{0,"Uncategorised","",uncategorised_forum_visible,"all",0,"",0,"",0,""})
//rows, err = db.Query("SELECT fid, name, active, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime FROM forums")
rows, err = db.Query("select fid, name, active, preset, topicCount, lastTopic, lastTopicID, lastReplyer, lastReplyerID, lastTopicTime from forums order by fid asc")
rows, err = db.Query("select `fid`, `name`, `desc`, `active`, `preset`, `topicCount`, `lastTopic`, `lastTopicID`, `lastReplyer`, `lastReplyerID`, `lastTopicTime` from forums order by fid asc")
if err != nil {
return err
}
defer rows.Close()
i = 1
for ;rows.Next();i++ {
forum := Forum{ID:0,Name:"",Active:true,Preset:"all"}
err := rows.Scan(&forum.ID, &forum.Name, &forum.Active, &forum.Preset, &forum.TopicCount, &forum.LastTopic, &forum.LastTopicID, &forum.LastReplyer, &forum.LastReplyerID, &forum.LastTopicTime)
err := rows.Scan(&forum.ID, &forum.Name, &forum.Desc, &forum.Active, &forum.Preset, &forum.TopicCount, &forum.LastTopic, &forum.LastTopicID, &forum.LastReplyer, &forum.LastReplyerID, &forum.LastTopicTime)
if err != nil {
return err
}
// Ugh, you really shouldn't physically delete these items, it makes a big mess of things
if forum.ID != i {
log.Print("Stop physically deleting forums. You are messing up the IDs. Use the Forum Manager or delete_forum() instead x.x")
fill_forum_id_gap(i, forum.ID)
}
/*if forum.LastTopicID != 0 {
forum.LastTopicTime, err = relative_time(forum.LastTopicTime)
if err != nil {
return err
}
} else {
forum.LastTopic = "None"
forum.LastTopicTime = ""
}*/
if forum.Name == "" {
if debug {
log.Print("Adding a placeholder forum")
@ -707,17 +650,17 @@ func init_database() (err error) {
return err
}
forumCapCount = i
//log.Print("Adding the reports forum")
//forums[-1] = Forum{-1,"Reports",false,0,"",0,"",0,""}
log.Print("Loading the forum permissions")
rows, err = db.Query("select gid, fid, permissions from forums_permissions order by gid asc, fid asc")
if err != nil {
return err
}
defer rows.Close()
if debug {
log.Print("Adding the forum permissions")
}
@ -760,7 +703,7 @@ func init_database() (err error) {
forum_perm = BlankForumPerms
groups[gid].Forums = append(groups[gid].Forums,forum_perm)
}
if forum_perm.Overrides {
if forum_perm.ViewTopic {
groups[gid].CanSee = append(groups[gid].CanSee, fid)
@ -774,18 +717,15 @@ func init_database() (err error) {
//fmt.Println(len(groups[gid].CanSee))
//fmt.Println(len(groups[gid].Forums))
}
log.Print("Loading the settings.")
rows, err = db.Query("select name, content, type, constraints from settings")
if err != nil {
return err
}
defer rows.Close()
var sname string
var scontent string
var stype string
var sconstraints string
var sname, scontent, stype, sconstraints string
for rows.Next() {
err := rows.Scan(&sname, &scontent, &stype, &sconstraints)
if err != nil {
@ -800,14 +740,14 @@ func init_database() (err error) {
if err != nil {
return err
}
log.Print("Loading the plugins.")
rows, err = db.Query("select uname, active from plugins")
if err != nil {
return err
}
defer rows.Close()
var uname string
var active bool
for rows.Next() {
@ -815,7 +755,7 @@ func init_database() (err error) {
if err != nil {
return err
}
// Was the plugin deleted at some point?
plugin, ok := plugins[uname]
if !ok {
@ -828,27 +768,27 @@ func init_database() (err error) {
if err != nil {
return err
}
log.Print("Loading the themes.")
rows, err = db.Query("select `uname`, `default` from `themes`")
if err != nil {
return err
}
defer rows.Close()
var defaultThemeSwitch bool
for rows.Next() {
err := rows.Scan(&uname, &defaultThemeSwitch)
if err != nil {
return err
}
// Was the theme deleted at some point?
theme, ok := themes[uname]
if !ok {
continue
}
if defaultThemeSwitch {
log.Print("Loading the theme '" + theme.Name + "'")
theme.Active = true

View File

@ -120,6 +120,26 @@ type EditGroupPage struct
ExtData interface{}
}
type GroupForumPermPreset struct
{
Group Group
Preset string
}
type EditForumPage struct
{
Title string
CurrentUser User
NoticeList []string
ID int
Name string
Desc string
Active bool
Preset string
Groups []GroupForumPermPreset
ExtData interface{}
}
type NameLangPair struct
{
Name string
@ -318,7 +338,7 @@ func shortcode_to_unicode(msg string) string {
msg = strings.Replace(msg,":frowning2:","☹️",-1)
msg = strings.Replace(msg,":information_source:","",-1)
msg = strings.Replace(msg,":interrobang:","⁉️",-1)
return msg
}
@ -339,7 +359,7 @@ func parse_message(msg string/*, user User*/) string {
msg = strings.Replace(msg,":p","😛",-1)
msg = strings.Replace(msg,":o","😲",-1)
//msg = url_reg.ReplaceAllString(msg,"<a href=\"$2$3//$4\" rel=\"nofollow\">$2$3//$4</a>")
// Search for URLs, mentions and hashlinks in the messages...
//fmt.Println("Parser Loop!")
var msgbytes = []byte(msg)
@ -367,7 +387,7 @@ func parse_message(msg string/*, user User*/) string {
if (i != 0) || msgbytes[i] < 33 {
i++
}
if msgbytes[i]=='#' {
//fmt.Println("IN #")
if bytes.Equal(msgbytes[i+1:i+5],[]byte("tid-")) {
@ -376,14 +396,14 @@ func parse_message(msg string/*, user User*/) string {
start := i
tid, int_len := coerce_int_bytes(msgbytes[start:])
i += int_len
topic, err := topics.CascadeGet(tid)
if err != nil || !forum_exists(topic.ParentID) {
outbytes = append(outbytes,invalid_topic...)
lastItem = i
continue
}
outbytes = append(outbytes, url_open...)
var url_bit []byte = []byte(build_topic_url(tid))
outbytes = append(outbytes, url_bit...)
@ -392,7 +412,7 @@ func parse_message(msg string/*, user User*/) string {
outbytes = append(outbytes, tid_bit...)
outbytes = append(outbytes, url_close...)
lastItem = i
//fmt.Println(string(msgbytes))
//fmt.Println(msgbytes)
//fmt.Println(msgbytes[lastItem - 1])
@ -405,14 +425,14 @@ func parse_message(msg string/*, user User*/) string {
start := i
rid, int_len := coerce_int_bytes(msgbytes[start:])
i += int_len
topic, err := get_topic_by_reply(rid)
if err != nil || !forum_exists(topic.ParentID) {
outbytes = append(outbytes,invalid_topic...)
lastItem = i
continue
}
outbytes = append(outbytes, url_open...)
var url_bit []byte = []byte(build_topic_url(topic.ID))
outbytes = append(outbytes, url_bit...)
@ -427,13 +447,13 @@ func parse_message(msg string/*, user User*/) string {
start := i
fid, int_len := coerce_int_bytes(msgbytes[start:])
i += int_len
if !forum_exists(fid) {
outbytes = append(outbytes,invalid_forum...)
lastItem = i
continue
}
outbytes = append(outbytes, url_open...)
var url_bit []byte = []byte(build_forum_url(fid))
outbytes = append(outbytes, url_bit...)
@ -452,14 +472,14 @@ func parse_message(msg string/*, user User*/) string {
start := i
uid, int_len := coerce_int_bytes(msgbytes[start:])
i += int_len
menUser, err := users.CascadeGet(uid)
if err != nil {
outbytes = append(outbytes,invalid_profile...)
lastItem = i
continue
}
outbytes = append(outbytes, url_open...)
var url_bit []byte = []byte(build_profile_url(uid))
outbytes = append(outbytes, url_bit...)
@ -470,7 +490,7 @@ func parse_message(msg string/*, user User*/) string {
outbytes = append(outbytes, uid_bit...)
outbytes = append(outbytes, url_close...)
lastItem = i
//fmt.Println(string(msgbytes))
//fmt.Println(msgbytes)
//fmt.Println(msgbytes[lastItem - 1])
@ -494,7 +514,7 @@ func parse_message(msg string/*, user User*/) string {
} else {
continue
}
outbytes = append(outbytes,msgbytes[lastItem:i]...)
url_len := partial_url_bytes_len(msgbytes[i:])
if msgbytes[i + url_len] != ' ' && msgbytes[i + url_len] != 10 {
@ -512,7 +532,7 @@ func parse_message(msg string/*, user User*/) string {
}
}
}
if lastItem != i && len(outbytes) != 0 {
//fmt.Println("lastItem:")
//fmt.Println(msgbytes[lastItem])
@ -532,7 +552,7 @@ func parse_message(msg string/*, user User*/) string {
}
//fmt.Println(`"`+string(outbytes)+`"`)
//fmt.Println(`"`+msg+`"`)
msg = strings.Replace(msg,"\n","<br>",-1)
if hooks["parse_assign"] != nil {
out := run_hook("parse_assign", msg)
@ -559,7 +579,7 @@ func regex_parse_message(msg string) string {
func validate_url_bytes(data []byte) bool {
datalen := len(data)
i := 0
if datalen >= 6 {
if bytes.Equal(data[0:6],[]byte("ftp://")) || bytes.Equal(data[0:6],[]byte("git://")) {
i = 6
@ -569,7 +589,7 @@ func validate_url_bytes(data []byte) bool {
i = 8
}
}
for ;datalen > i; i++ {
if data[i] != '\\' && data[i] != '_' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
return false
@ -581,7 +601,7 @@ func validate_url_bytes(data []byte) bool {
func validated_url_bytes(data []byte) (url []byte) {
datalen := len(data)
i := 0
if datalen >= 6 {
if bytes.Equal(data[0:6],[]byte("ftp://")) || bytes.Equal(data[0:6],[]byte("git://")) {
i = 6
@ -591,13 +611,13 @@ func validated_url_bytes(data []byte) (url []byte) {
i = 8
}
}
for ;datalen > i; i++ {
if data[i] != '\\' && data[i] != '_' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
return invalid_url
}
}
url = append(url, data...)
return url
}
@ -606,7 +626,7 @@ func partial_url_bytes(data []byte) (url []byte) {
datalen := len(data)
i := 0
end := datalen - 1
if datalen >= 6 {
if bytes.Equal(data[0:6],[]byte("ftp://")) || bytes.Equal(data[0:6],[]byte("git://")) {
i = 6
@ -616,13 +636,13 @@ func partial_url_bytes(data []byte) (url []byte) {
i = 8
}
}
for ;end >= i; i++ {
if data[i] != '\\' && data[i] != '_' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
end = i
}
}
url = append(url, data[0:end]...)
return url
}
@ -630,7 +650,7 @@ func partial_url_bytes(data []byte) (url []byte) {
func partial_url_bytes_len(data []byte) int {
datalen := len(data)
i := 0
if datalen >= 6 {
//fmt.Println(string(data[0:5]))
if bytes.Equal(data[0:6],[]byte("ftp://")) || bytes.Equal(data[0:6],[]byte("git://")) {
@ -641,7 +661,7 @@ func partial_url_bytes_len(data []byte) int {
i = 8
}
}
for ;datalen > i; i++ {
if data[i] != '\\' && data[i] != '_' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
//fmt.Println("Bad Character:")
@ -649,7 +669,7 @@ func partial_url_bytes_len(data []byte) int {
return i
}
}
//fmt.Println("Data Length:")
//fmt.Println(datalen)
return datalen
@ -658,7 +678,7 @@ func partial_url_bytes_len(data []byte) int {
func parse_media_bytes(data []byte) (protocol []byte, url []byte) {
datalen := len(data)
i := 0
if datalen >= 6 {
if bytes.Equal(data[0:6],[]byte("ftp://")) || bytes.Equal(data[0:6],[]byte("git://")) {
i = 6
@ -671,13 +691,13 @@ func parse_media_bytes(data []byte) (protocol []byte, url []byte) {
protocol = []byte("https")
}
}
for ;datalen > i; i++ {
if data[i] != '\\' && data[i] != '_' && !(data[i] > 44 && data[i] < 58) && !(data[i] > 64 && data[i] < 91) && !(data[i] > 96 && data[i] < 123) {
return []byte(""), invalid_url
}
}
if len(protocol) == 0 {
protocol = []byte("http")
}
@ -688,7 +708,7 @@ func coerce_int_bytes(data []byte) (res int, length int) {
if !(data[0] > 47 && data[0] < 58) {
return 0, 1
}
i := 0
for ;len(data) > i; i++ {
if !(data[i] > 47 && data[i] < 58) {
@ -699,7 +719,7 @@ func coerce_int_bytes(data []byte) (res int, length int) {
return conv, i
}
}
conv, err := strconv.Atoi(string(data))
if err != nil {
return 0, i

View File

@ -206,7 +206,7 @@ func route_panel_forums(w http.ResponseWriter, r *http.Request){
var forumList []interface{}
for _, forum := range forums {
if forum.Name != "" {
fadmin := ForumAdmin{forum.ID,forum.Name,forum.Active,forum.Preset,forum.TopicCount,preset_to_lang(forum.Preset)}
fadmin := ForumAdmin{forum.ID,forum.Name,forum.Desc,forum.Active,forum.Preset,forum.TopicCount,preset_to_lang(forum.Preset)}
if fadmin.Preset == "" {
fadmin.Preset = "custom"
}
@ -240,17 +240,13 @@ func route_panel_forums_create_submit(w http.ResponseWriter, r *http.Request){
return
}
var active bool
fname := r.PostFormValue("forum-name")
fdesc := r.PostFormValue("forum-desc")
fpreset := strip_invalid_preset(r.PostFormValue("forum-preset"))
factive := r.PostFormValue("forum-name")
if factive == "on" || factive == "1" {
active = true
} else {
active = false
}
active := (factive == "on" || factive == "1" )
fid, err := create_forum(fname,active,fpreset)
fid, err := create_forum(fname,fdesc,active,fpreset)
if err != nil {
InternalError(err,w,r)
return
@ -344,8 +340,25 @@ func route_panel_forums_edit(w http.ResponseWriter, r *http.Request, sfid string
return
}
pi := Page{"Forum Editor",user,noticeList,tList,nil}
templates.ExecuteTemplate(w,"panel-forum-edit.html",pi)
var forum Forum = forums[fid]
if forum.Preset == "" {
forum.Preset = "custom"
}
var glist []Group = groups
var gplist []GroupForumPermPreset
for gid, group := range glist {
if gid == 0 {
continue
}
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}
err = templates.ExecuteTemplate(w,"panel-forum-edit.html",pi)
if err != nil {
InternalError(err,w,r)
}
}
func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid string) {
@ -379,6 +392,7 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid
}
forum_name := r.PostFormValue("forum_name")
forum_desc := r.PostFormValue("forum_desc")
forum_preset := strip_invalid_preset(r.PostFormValue("forum_preset"))
forum_active := r.PostFormValue("forum_active")
if !forum_exists(fid) {
@ -386,11 +400,6 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid
return
}
/*if forum_name == "" && forum_active == "" {
LocalErrorJSQ("You haven't changed anything!",w,r,user,is_js)
return
}*/
if forum_name == "" {
forum_name = forums[fid].Name
}
@ -404,7 +413,7 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid
active = false
}
_, err = update_forum_stmt.Exec(forum_name,active,forum_preset,fid)
_, err = update_forum_stmt.Exec(forum_name,forum_desc,active,forum_preset,fid)
if err != nil {
InternalErrorJSQ(err,w,r,is_js)
return
@ -413,6 +422,9 @@ func route_panel_forums_edit_submit(w http.ResponseWriter, r *http.Request, sfid
if forums[fid].Name != forum_name {
forums[fid].Name = forum_name
}
if forums[fid].Desc != forum_desc {
forums[fid].Desc = forum_desc
}
if forums[fid].Active != active {
forums[fid].Active = active
}
@ -429,6 +441,70 @@ 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)
if !ok {
return
}
if !user.Is_Super_Mod || !user.Perms.ManageForums {
NoPermissions(w,r,user)
return
}
err := r.ParseForm()
if err != nil {
LocalError("Bad Form",w,r,user)
return
}
if r.FormValue("session") != user.Session {
SecurityError(w,r,user)
return
}
is_js := r.PostFormValue("js")
if is_js == "" {
is_js = "0"
}
fid, err := strconv.Atoi(sfid)
if err != nil {
LocalErrorJSQ("The provided Forum ID is not a valid number.",w,r,user,is_js)
return
}
gid, err := strconv.Atoi("gid")
if err != nil {
LocalErrorJSQ("Invalid Group ID",w,r,user,is_js)
return
}
perm_preset := strip_invalid_group_forum_preset(r.PostFormValue("perm_preset"))
fperms, changed := group_forum_preset_to_forum_perms(perm_preset)
if changed {
permupdate_mutex.Lock()
groups[gid].Forums[fid] = fperms
perms, err := json.Marshal(fperms)
if err != nil {
InternalErrorJSQ(err,w,r,is_js)
return
}
//_, err = update_forum_perms_for_group_stmt.Exec(perm_preset,perms,gid,fid)
_, err = add_forum_perms_to_group_stmt.Exec(gid,fid,perm_preset,perms)
if err != nil {
InternalErrorJSQ(err,w,r,is_js)
return
}
permupdate_mutex.Unlock()
}
if is_js == "0" {
http.Redirect(w,r,"/panel/forums/edit/" + strconv.Itoa(fid),http.StatusSeeOther)
} else {
w.Write(success_json_bytes)
}
}
func route_panel_settings(w http.ResponseWriter, r *http.Request){
user, noticeList, ok := SessionCheck(w,r)
if !ok {

View File

@ -6,6 +6,7 @@ import "sync"
import "strconv"
import "encoding/json"
var permupdate_mutex sync.Mutex
var BlankPerms Perms
var BlankForumPerms ForumPerms
var GuestPerms Perms
@ -50,12 +51,6 @@ var GlobalPermList []string = []string{
"ViewIPs",
}
/*type PermMeta struct
{
Name string
Type int // 0: global, 1: local
}*/
// Permission Structure: ActionComponent[Subcomponent]Flag
type Perms struct
{
@ -73,7 +68,7 @@ type Perms struct
EditGroupGlobalPerms bool
EditGroupSuperMod bool
EditGroupAdmin bool
ManageForums bool // This could be local, albeit limited for per-forum managers
ManageForums bool // This could be local, albeit limited for per-forum managers?
EditSettings bool
ManageThemes bool
ManagePlugins bool
@ -259,7 +254,6 @@ func preset_to_permmap(preset string) (out map[string]ForumPerms) {
return out
}
var permupdate_mutex sync.Mutex
func permmap_to_query(permmap map[string]ForumPerms, fid int) error {
permupdate_mutex.Lock()
defer permupdate_mutex.Unlock()
@ -374,6 +368,59 @@ func build_forum_permissions() error {
return nil
}
func forum_perms_to_group_forum_preset(fperms ForumPerms) string {
if !fperms.Overrides {
return "default"
}
if !fperms.ViewTopic {
return "no_access"
}
var can_post bool = (fperms.LikeItem && fperms.CreateTopic && fperms.CreateReply)
var can_moderate bool = (can_post && fperms.EditTopic && fperms.DeleteTopic && fperms.EditReply && fperms.DeleteReply && fperms.PinTopic && fperms.CloseTopic)
if can_moderate {
return "can_moderate"
}
if (fperms.EditTopic || fperms.DeleteTopic || fperms.EditReply || fperms.DeleteReply || fperms.PinTopic || fperms.CloseTopic) {
if !can_post {
return "custom"
}
return "quasi_mod"
}
if can_post {
return "can_post"
}
if fperms.ViewTopic && !fperms.LikeItem && !fperms.CreateTopic && !fperms.CreateReply {
return "read_only"
}
return "custom"
}
func group_forum_preset_to_forum_perms(preset string) (fperms ForumPerms, changed bool) {
switch(preset) {
case "read_only":
return ReadForumPerms, true
case "can_post":
return ReadWriteForumPerms, true
case "can_moderate":
return AllForumPerms, true
case "no_access":
return ForumPerms{Overrides: true}, true
case "default":
return BlankForumPerms, true
//case "custom": return fperms, false
}
return fperms, false
}
func strip_invalid_group_forum_preset(preset string) string {
switch(preset) {
case "read_only","can_post","can_moderate","no_access","default","custom":
return preset
}
return ""
}
func strip_invalid_preset(preset string) string {
switch(preset) {
case "all","announce","members","staff","admins","archive","custom":
@ -396,18 +443,6 @@ func preset_to_lang(preset string) string {
return ""
}
/*func preset_to_emoji(preset string) string {
switch(preset) {
case "all": return ""//return "Everyone"
case "announce": return "📣"
case "members": return "👪"
case "staff": return "👮"
case "admins": return "👑"
case "archive": return "☠️"
}
return ""
}*/
func rebuild_group_permissions(gid int) error {
var permstr []byte
log.Print("Reloading a group")

View File

@ -7,6 +7,7 @@ func init() {
// init_helloworld is separate from init() as we don't want the plugin to run if the plugin is disabled
func init_helloworld() {
plugins["helloworld"].AddHook("rrow_assign", helloworld_reply)
// TO-DO: Add a route injection example here
}
func deactivate_helloworld() {
@ -19,4 +20,4 @@ func helloworld_reply(data interface{}) interface{} {
reply.ContentHtml = "Hello World!"
reply.Tag = "Auto"
return reply
}
}

View File

@ -7,14 +7,10 @@ import "regexp"
var markdown_max_depth int = 25 // How deep the parser will go when parsing Markdown strings
var markdown_unclosed_element []byte
var markdown_bold_tag_open []byte
var markdown_bold_tag_close []byte
var markdown_italic_tag_open []byte
var markdown_italic_tag_close []byte
var markdown_underline_tag_open []byte
var markdown_underline_tag_close []byte
var markdown_strike_tag_open []byte
var markdown_strike_tag_close []byte
var markdown_bold_tag_open, markdown_bold_tag_close []byte
var markdown_italic_tag_open, markdown_italic_tag_close []byte
var markdown_underline_tag_open, markdown_underline_tag_close []byte
var markdown_strike_tag_open, markdown_strike_tag_close []byte
var markdown_bold_italic *regexp.Regexp
var markdown_bold *regexp.Regexp
@ -29,9 +25,9 @@ func init() {
func init_markdown() {
//plugins["markdown"].AddHook("parse_assign", markdown_regex_parse)
plugins["markdown"].AddHook("parse_assign", markdown_parse)
markdown_unclosed_element = []byte("<span style='color: red;'>[Unclosed Element]</span>")
markdown_bold_tag_open = []byte("<b>")
markdown_bold_tag_close = []byte("</b>")
markdown_italic_tag_open = []byte("<i>")
@ -40,7 +36,7 @@ func init_markdown() {
markdown_underline_tag_close = []byte("</u>")
markdown_strike_tag_open = []byte("<s>")
markdown_strike_tag_close = []byte("</s>")
markdown_bold_italic = regexp.MustCompile(`\*\*\*(.*)\*\*\*`)
markdown_bold = regexp.MustCompile(`\*\*(.*)\*\*`)
markdown_italic = regexp.MustCompile(`\*(.*)\*`)
@ -77,12 +73,12 @@ func _markdown_parse(msg string, n int) string {
if n > markdown_max_depth {
return "<span style='color: red;'>[Markdown Error: Overflowed the max depth of 20]</span>"
}
var outbytes []byte
var lastElement int
//fmt.Println("enter message loop")
//fmt.Printf("Message: %v\n",strings.Replace(msg,"\r","\\r",-1))
for index := 0; index < len(msg); index++ {
/*//fmt.Println("--OUTER MARKDOWN LOOP START--")
//fmt.Println("index",index)
@ -90,29 +86,29 @@ func _markdown_parse(msg string, n int) string {
//fmt.Println("string(msg[index])",string(msg[index]))
//fmt.Println("--OUTER MARKDOWN LOOP END--")
//fmt.Println(" ")*/
switch(msg[index]) {
case '_':
var startIndex int = index
if (index + 1) >= len(msg) {
break
}
index++
index = markdown_skip_until_char(msg, index, '_')
if (index - (startIndex + 1)) < 2 || index >= len(msg) {
break
}
sIndex := startIndex + 1
lIndex := index
index++
outbytes = append(outbytes, msg[lastElement:startIndex]...)
outbytes = append(outbytes, markdown_underline_tag_open...)
outbytes = append(outbytes, msg[sIndex:lIndex]...)
outbytes = append(outbytes, markdown_underline_tag_close...)
lastElement = index
index--
case '~':
@ -120,22 +116,22 @@ func _markdown_parse(msg string, n int) string {
if (index + 1) >= len(msg) {
break
}
index++
index = markdown_skip_until_char(msg, index, '~')
if (index - (startIndex + 1)) < 2 || index >= len(msg) {
break
}
sIndex := startIndex + 1
lIndex := index
index++
outbytes = append(outbytes, msg[lastElement:startIndex]...)
outbytes = append(outbytes, markdown_strike_tag_open...)
outbytes = append(outbytes, msg[sIndex:lIndex]...)
outbytes = append(outbytes, markdown_strike_tag_close...)
lastElement = index
index--
case '*':
@ -146,7 +142,7 @@ func _markdown_parse(msg string, n int) string {
//fmt.Println("start msg[index]",msg[index])
//fmt.Println("start string(msg[index])",string(msg[index]))
//fmt.Println("start []byte(msg[:index])",[]byte(msg[:index]))
var startIndex int = index
var italic bool = true
var bold bool
@ -154,7 +150,7 @@ func _markdown_parse(msg string, n int) string {
//fmt.Println("start index + 1",index + 1)
//fmt.Println("start msg[index]",msg[index + 1])
//fmt.Println("start string(msg[index])",string(msg[index + 1]))
if msg[index + 1] == '*' {
//fmt.Println("two asterisks")
bold = true
@ -167,39 +163,39 @@ func _markdown_parse(msg string, n int) string {
}
}
}
//fmt.Println("lastElement",lastElement)
//fmt.Println("startIndex:",startIndex)
//fmt.Println("msg[startIndex]",msg[startIndex])
//fmt.Println("string(msg[startIndex])",string(msg[startIndex]))
//fmt.Println("preabrupt index",index)
//fmt.Println("preabrupt msg[index]",msg[index])
//fmt.Println("preabrupt string(msg[index])",string(msg[index]))
//fmt.Println("preabrupt []byte(msg[:index])",[]byte(msg[:index]))
//fmt.Println("preabrupt msg[:index]",msg[:index])
// Does the string terminate abruptly?
if (index + 1) >= len(msg) {
break
}
index++
//fmt.Println("preskip index",index)
//fmt.Println("preskip msg[index]",msg[index])
//fmt.Println("preskip string(msg[index])",string(msg[index]))
index = markdown_skip_until_asterisk(msg,index)
if index >= len(msg) {
break
}
//fmt.Println("index",index)
//fmt.Println("[]byte(msg[:index])",[]byte(msg[:index]))
//fmt.Println("msg[index]",msg[index])
sIndex := startIndex
lIndex := index
if bold && italic {
@ -236,10 +232,10 @@ func _markdown_parse(msg string, n int) string {
index++
sIndex++
}
//fmt.Println("sIndex",sIndex)
//fmt.Println("lIndex",lIndex)
if lIndex <= sIndex {
//fmt.Println("unclosed markdown element @ lIndex <= sIndex")
outbytes = append(outbytes, msg[lastElement:startIndex]...)
@ -247,7 +243,7 @@ func _markdown_parse(msg string, n int) string {
lastElement = startIndex
break
}
if sIndex < 0 || lIndex < 0 {
//fmt.Println("unclosed markdown element @ sIndex < 0 || lIndex < 0")
outbytes = append(outbytes, msg[lastElement:startIndex]...)
@ -255,39 +251,39 @@ func _markdown_parse(msg string, n int) string {
lastElement = startIndex
break
}
//fmt.Println("final sIndex",sIndex)
//fmt.Println("final lIndex",lIndex)
//fmt.Println("final index",index)
//fmt.Println("final msg[index]",msg[index])
//fmt.Println("final string(msg[index])",string(msg[index]))
//fmt.Println("final msg[sIndex]",msg[sIndex])
//fmt.Println("final string(msg[sIndex])",string(msg[sIndex]))
//fmt.Println("final msg[lIndex]",msg[lIndex])
//fmt.Println("final string(msg[lIndex])",string(msg[lIndex]))
//fmt.Println("[]byte(msg[:sIndex])",[]byte(msg[:sIndex]))
//fmt.Println("[]byte(msg[:lIndex])",[]byte(msg[:lIndex]))
outbytes = append(outbytes, msg[lastElement:startIndex]...)
if bold {
outbytes = append(outbytes, markdown_bold_tag_open...)
}
if italic {
outbytes = append(outbytes, markdown_italic_tag_open...)
}
outbytes = append(outbytes, msg[sIndex:lIndex]...)
if bold {
outbytes = append(outbytes, markdown_bold_tag_close...)
}
if italic {
outbytes = append(outbytes, markdown_italic_tag_close...)
}
lastElement = index
index--
//case '`':
@ -296,10 +292,10 @@ func _markdown_parse(msg string, n int) string {
//case 10: // newline
}
}
//fmt.Println("exit message loop")
//fmt.Println(" ")
if len(outbytes) == 0 {
return msg
} else if lastElement < (len(msg) - 1) {
@ -345,7 +341,7 @@ SwitchLoop:
func markdown_skip_list(data string, index int) int {
var lastNewline int
var datalen int = len(data)
for ; index < datalen; index++ {
SkipListInnerLoop:
if data[index] == 10 {
@ -357,7 +353,7 @@ func markdown_skip_list(data string, index int) int {
goto SkipListInnerLoop
}
}
if index >= datalen {
if data[index] != '*' && data[index] != '-' {
if (lastNewline + 1) < datalen {
@ -368,6 +364,6 @@ func markdown_skip_list(data string, index int) int {
}
}
}
return index
}

View File

@ -17,12 +17,13 @@ function load_alerts(menu_alerts)
url:'/api/?action=get&module=alerts&format=json',
success: function(data) {
if("errmsg" in data) {
console.log(data.errmsg);
//console.log(data.errmsg);
menu_alerts.find(".alertList").html("<div class='alertItem'>"+data.errmsg+"</div>");
return;
}
var alist = "";
var anyAvatar = false
for(var i in data.msgs) {
var msg = data.msgs[i];
var mmsg = msg.msg;
@ -30,8 +31,8 @@ function load_alerts(menu_alerts)
if("sub" in msg) {
for(var i = 0; i < msg.sub.length; i++) {
mmsg = mmsg.replace("\{"+i+"\}", msg.sub[i]);
console.log("Sub #" + i);
console.log(msg.sub[i]);
//console.log("Sub #" + i);
//console.log(msg.sub[i]);
}
}
@ -39,30 +40,28 @@ function load_alerts(menu_alerts)
else if(mmsg.length > 35) size_dial = " smaller"; //9px
else size_dial = ""; // 10px
if("avatar" in msg) {
if("avatar" in msg)
{
alist += "<div class='alertItem withAvatar' style='background-image:url(\""+msg.avatar+"\");'><a class='text"+size_dial+"' href=\""+msg.path+"\">"+mmsg+"</a></div>";
console.log(msg.avatar);
} else {
alist += "<div class='alertItem'><a href=\""+msg.path+"\" class='text"+size_dial+"'>"+mmsg+"</a></div>";
anyAvatar = true
}
console.log(msg);
else alist += "<div class='alertItem'><a href=\""+msg.path+"\" class='text"+size_dial+"'>"+mmsg+"</a></div>";
//console.log(msg);
//console.log(mmsg);
}
if(alist == "") alist = "<div class='alertItem'>You don't have any alerts</div>";
menu_alerts.find(".alertList").html(alist);
if(data.msgs.length != 0) {
menu_alerts.find(".alert_counter").text(data.msgs.length);
else {
//menu_alerts.removeClass("hasAvatars");
//if(anyAvatar) menu_alerts.addClass("hasAvatars");
}
menu_alerts.find(".alertList").html(alist);
if(data.msgs.length != 0) menu_alerts.find(".alert_counter").text(data.msgs.length);
},
error: function(magic,theStatus,error) {
try {
var data = JSON.parse(magic.responseText);
if("errmsg" in data)
{
console.log(data.errmsg);
errtxt = data.errmsg;
}
if("errmsg" in data) errtxt = data.errmsg;
else errtxt = "Unable to get the alerts";
} catch(e) { errtxt = "Unable to get the alerts"; }
menu_alerts.find(".alertList").html("<div class='alertItem'>"+errtxt+"</div>");
@ -110,22 +109,17 @@ $(document).ready(function(){
if(messages[i].startsWith("set ")) {
//msgblocks = messages[i].split(' ',3);
msgblocks = SplitN(messages[i]," ",3);
if(msgblocks.length < 3) {
continue;
}
if(msgblocks.length < 3) continue;
document.querySelector(msgblocks[1]).innerHTML = msgblocks[2];
} else if(messages[i].startsWith("set-class ")) {
msgblocks = SplitN(messages[i]," ",3);
if(msgblocks.length < 3) {
continue;
}
if(msgblocks.length < 3) continue;
document.querySelector(msgblocks[1]).className = msgblocks[2];
}
}
}
} else {
conn = false
}
else conn = false;
$(".open_edit").click(function(event){
//console.log("Clicked on edit");
@ -239,21 +233,18 @@ $(document).ready(function(){
//console.log("Field Name '" + field_name + "'")
//console.log("Field Type",field_type)
//console.log("Field Value '" + field_value + "'")
for (var i = 0; i < itLen; i++){
//console.log("Field Possibility '" + it[i] + "'");
for (var i = 0; i < itLen; i++) {
if(field_value == i || field_value == it[i]) {
sel = "selected ";
//console.log("Class List: ",this.classList)
this.classList.remove(field_name + '_' + it[i]);
//console.log("Removing " + field_name + '_' + it[i]);
//console.log(this.classList)
this.innerHTML = "";
} else sel = "";
out += "<option "+sel+"value='"+i+"'>"+it[i]+"</option>";
}
this.innerHTML = "<select data-field='"+field_name+"' name='"+field_name+"'>" + out + "</select>";
this.innerHTML = "<select data-field='"+field_name+"' name='"+field_name+"'>"+out+"</select>";
}
else this.innerHTML = "<input name='"+field_name+"' value='" + this.textContent + "' type='text'/>";
else if(field_type=="hidden") {}
else this.innerHTML = "<input name='"+field_name+"' value='"+this.textContent+"' type='text'/>";
});
block_parent.find('.show_on_edit').eq(0).show();
@ -269,15 +260,16 @@ $(document).ready(function(){
var block = block_parent.find('.editable_block').each(function(){
var field_name = this.getAttribute("data-field");
var field_type = this.getAttribute("data-type");
if(field_type == "list") {
if(field_type=="list") {
var newContent = $(this).find('select :selected').text();
this.classList.add(field_name + '_' + newContent);
this.innerHTML = "";
} else if(field_type=="hidden") {
var newContent = $(this).val();
} else {
var newContent = $(this).find('input').eq(0).val();
this.innerHTML = newContent;
}
//console.log(".submit_edit");
//console.log("field_name",field_name);
//console.log("field_type",field_type);
//console.log("newContent",newContent);
@ -296,7 +288,6 @@ $(document).ready(function(){
$(".ip_item").each(function(){
var ip = this.textContent;
//console.log("IP: " + ip);
if(ip.length > 10){
this.innerHTML = "Show IP";
this.onclick = function(event){
@ -308,6 +299,15 @@ $(document).ready(function(){
$(this).click(function() {
$(".selectedAlert").removeClass("selectedAlert");
$("#back").removeClass("alertActive");
});
$(".alert_bell").click(function(){
var menu_alerts = $(this).parent();
if(menu_alerts.hasClass("selectedAlert")) {
event.stopPropagation();
menu_alerts.removeClass("selectedAlert");
$("#back").removeClass("alertActive");
}
});
$(".menu_alerts").ready(function(){
@ -317,8 +317,9 @@ $(document).ready(function(){
$(".menu_alerts").click(function(event) {
event.stopPropagation();
if($(this).hasClass("selectedAlert")) return;
this.className += " selectedAlert";
load_alerts($(this));
this.className += " selectedAlert";
document.getElementById("back").className += " alertActive"
});
this.onkeyup = function(event){

9
query_gen/build.bat Normal file
View File

@ -0,0 +1,9 @@
@echo off
echo Building the query generator
go build
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo The query generator was successfully built
pause

173
query_gen/main.go Normal file
View File

@ -0,0 +1,173 @@
/* WIP Under Construction */
package main
import "fmt"
import "strings"
import "log"
import "os"
var db_registry []DB_Adapter
var blank_order []DB_Order
type DB_Where struct
{
Left string
Right string
Operator string
LeftType string
RightType string
}
type DB_Joiner struct
{
Left string
Right string
}
type DB_Order struct
{
Column string
Order string
}
type DB_Adapter interface {
get_name() string
simple_insert(string,string,string,[]string,[]bool) error
//simple_replace(string,string,[]string,[]string,[]bool) error
simple_update() error
simple_select(string,string,string,string,[]DB_Order/*,int,int*/) error
simple_left_join(string,string,string,string,[]DB_Joiner,string,[]DB_Order/*,int,int*/) error
write() error
// TO-DO: Add a simple query builder
}
func main() {
log.Println("Running the query generator")
for _, adapter := range db_registry {
log.Println("Building the queries for the " + adapter.get_name() + " adapter")
write_statements(adapter)
adapter.write()
}
}
func write_statements(adapter DB_Adapter) error {
// url_prefix and url_name will be removed from this query in a later commit
adapter.simple_select("get_user","users","name, group, is_super_admin, avatar, message, url_prefix, url_name, level","uid = ?",blank_order)
adapter.simple_select("get_full_user","users","name, group, is_super_admin, session, email, avatar, message, url_prefix, url_name, level, score, last_ip","uid = ?",blank_order)
adapter.simple_select("get_topic","topics","title, content, createdBy, createdAt, is_closed, sticky, parentID, ipaddress, postCount, likeCount","tid = ?",blank_order)
adapter.simple_select("get_reply","replies","content, createdBy, createdAt, lastEdit, lastEditBy, ipaddress, likeCount","rid = ?",blank_order)
adapter.simple_select("login","users","uid, name, password, salt","name = ?",blank_order)
adapter.simple_select("get_password","users","password,salt","uid = ?",blank_order)
adapter.simple_select("username_exists","users","name","name = ?",blank_order)
/*
get_topic_list_stmt, err = db.Prepare("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.parentID, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC")
// A visual reference for me to glance at while I design this thing
*/
//func (adapter *Mysql_Adapter) simple_left_join(name string, table1 string, table2 string, columns string, joiners []DB_Joiner, where []DB_Where, orderby []DB_Order/*, offset int, maxCount int*/) error {
/*adapter.simple_left_join("get_topic_list","topics","users",
"topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.parentID, users.name, users.avatar",
[]DB_Joiner{}
)*/
return nil
}
func write_file(name string, content string) (err error) {
f, err := os.Create(name)
if err != nil {
return err
}
_, err = f.WriteString(content)
if err != nil {
return err
}
f.Sync()
f.Close()
return
}
func _process_where(wherestr string) (where []DB_Where) {
if wherestr == "" {
return where
}
wherestr = strings.Replace(wherestr," and "," AND ",-1)
for _, segment := range strings.Split(wherestr," AND ") {
// TO-DO: Subparse the contents of a function and spit out a DB_Function struct
var outwhere DB_Where
var parseOffset int
outwhere.Left, parseOffset = _get_identifier(segment, parseOffset)
outwhere.Operator, parseOffset = _get_operator(segment, parseOffset + 1)
outwhere.Right, parseOffset = _get_identifier(segment, parseOffset + 1)
outwhere.LeftType = _get_identifier_type(outwhere.Left)
outwhere.RightType = _get_identifier_type(outwhere.Right)
where = append(where,outwhere)
}
return where
}
func _get_identifier_type(identifier string) string {
if ('a' <= identifier[0] && identifier[0] <= 'z') || ('A' <= identifier[0] && identifier[0] <= 'Z') {
if identifier[len(identifier) - 1] == ')' {
return "function"
}
return "column"
}
if identifier[0] == '\'' || identifier[0] == '"' {
return "string"
}
return "literal"
}
func _get_identifier(segment string, startOffset int) (out string, i int) {
fmt.Println("entering _get_identifier")
segment = strings.TrimSpace(segment)
segment += " " // Avoid overflow bugs with slicing
for i = startOffset; i < len(segment); i++ {
if segment[i] == '(' {
i = _skip_function_call(segment,i)
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
}
if segment[i] == ' ' && i != startOffset {
fmt.Println("segment[startOffset:i]",segment[startOffset:i])
fmt.Println("startOffset",startOffset)
fmt.Println("segment[startOffset]",string(segment[startOffset]))
fmt.Println("i",i)
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
}
}
return strings.TrimSpace(segment[startOffset:]), (i - 1)
}
func _get_operator(segment string, startOffset int) (out string, i int) {
segment = strings.TrimSpace(segment)
segment += " " // Avoid overflow bugs with slicing
for i = startOffset; i < len(segment); i++ {
if segment[i] == ' ' && i != startOffset {
return strings.TrimSpace(segment[startOffset:i]), (i - 1)
}
}
return strings.TrimSpace(segment[startOffset:]), (i - 1)
}
func _skip_function_call(segment string, i int) int {
var brace_count int = 1
for ; i < len(segment); i++ {
if segment[i] == '(' {
brace_count++
} else if segment[i] == ')' {
brace_count--
}
if brace_count == 0 {
return i
}
}
return i
}

219
query_gen/mysql.go Normal file
View File

@ -0,0 +1,219 @@
/* WIP Under Construction */
package main
import "fmt"
import "strings"
import "errors"
func init() {
db_registry = append(db_registry,&Mysql_Adapter{Name:"mysql"})
}
type Mysql_Adapter struct
{
Name string
Stmts string
Body string
}
func (adapter *Mysql_Adapter) get_name() string {
return adapter.Name
}
func (adapter *Mysql_Adapter) simple_insert(name string, table string, columns string, fields []string, quoteWhat []bool) error {
if name == "" {
return errors.New("You need a name for this statement")
}
if table == "" {
return errors.New("You need a name for this table")
}
if len(columns) == 0 {
return errors.New("No columns found for simple_insert")
}
if len(fields) == 0 {
return errors.New("No input data found for simple_insert")
}
// Slice up the user friendly strings into something easier to process
var colslice []string = strings.Split(strings.TrimSpace(columns),",")
var noquotes bool = (len(quoteWhat) == 0)
var querystr string = "INSERT INTO " + table + "("
// Escape the column names, just in case we've used a reserved keyword
// TO-DO: Subparse the columns to allow functions and AS keywords
for _, column := range colslice {
querystr += "`" + column + "`,"
}
// Remove the trailing comma
querystr = querystr[0:len(querystr) - 1]
querystr += ") VALUES ("
for fid, field := range fields {
if !noquotes && quoteWhat[fid] {
querystr += "'" + field + "',"
} else {
querystr += field + ","
}
}
querystr = querystr[0:len(querystr) - 1]
adapter.write_statement(name,querystr + ")")
return nil
}
func (adapter *Mysql_Adapter) simple_update() error {
return nil
}
func (adapter *Mysql_Adapter) simple_select(name string, table string, columns string, where string, orderby []DB_Order/*, offset int, maxCount int*/) error {
if name == "" {
return errors.New("You need a name for this statement")
}
if table == "" {
return errors.New("You need a name for this table")
}
if len(columns) == 0 {
return errors.New("No columns found for simple_select")
}
// Slice up the user friendly strings into something easier to process
var colslice []string = strings.Split(strings.TrimSpace(columns),",")
var querystr string = "SELECT "
// Escape the column names, just in case we've used a reserved keyword
for _, column := range colslice {
querystr += "`" + strings.TrimSpace(column) + "`,"
}
// Remove the trailing comma
querystr = querystr[0:len(querystr) - 1]
querystr += " FROM " + table
if len(where) != 0 {
querystr += " WHERE"
fmt.Println("where",where)
fmt.Println("_process_where(where)",_process_where(where))
for _, loc := range _process_where(where) {
var lquote, rquote string
if loc.LeftType == "column" {
lquote = "`"
}
if loc.RightType == "column" {
rquote = "`"
}
querystr += " " + lquote + loc.Left + lquote + loc.Operator + " " + rquote + loc.Right + rquote + " AND "
}
}
// Remove the trailing AND
querystr = querystr[0:len(querystr) - 4]
if len(orderby) != 0 {
querystr += " ORDER BY "
for _, column := range orderby {
querystr += column.Column + " " + column.Order + ","
}
}
querystr = querystr[0:len(querystr) - 1]
adapter.write_statement(name,querystr)
return nil
}
func (adapter *Mysql_Adapter) simple_left_join(name string, table1 string, table2 string, columns string, joiners []DB_Joiner, where string, orderby []DB_Order/*, offset int, maxCount int*/) error {
if name == "" {
return errors.New("You need a name for this statement")
}
if table1 == "" {
return errors.New("You need a name for the left table")
}
if table2 == "" {
return errors.New("You need a name for the right table")
}
if len(columns) == 0 {
return errors.New("No columns found for simple_left_join")
}
if len(joiners) == 0 {
return errors.New("No joiners found for simple_left_join")
}
// Slice up the user friendly strings into something easier to process
var colslice []string = strings.Split(strings.TrimSpace(columns),",")
var querystr string = "SELECT "
// Escape the column names, just in case we've used a reserved keyword
for _, column := range colslice {
querystr += "`" + strings.TrimSpace(column) + "`,"
}
// Remove the trailing comma
querystr = querystr[0:len(querystr) - 1]
querystr += " FROM " + table1 + " LEFT JOIN " + table2 + " ON "
for _, joiner := range joiners {
querystr += "`" + joiner.Left + "`=`" + joiner.Right + "` AND "
}
// Remove the trailing AND
querystr = querystr[0:len(querystr) - 4]
if len(where) != 0 {
querystr += " " + "WHERE"
for _, loc := range _process_where(where) {
var lquote, rquote string
if loc.LeftType == "column" {
lquote = "`"
}
if loc.RightType == "column" {
rquote = "`"
}
querystr += " " + lquote + loc.Left + lquote + loc.Operator + " " + rquote + loc.Right + rquote + " AND "
}
}
querystr = querystr[0:len(querystr) - 3]
if len(orderby) != 0 {
querystr += " ORDER BY "
for _, column := range orderby {
querystr += column.Column + " " + column.Order + ","
}
}
querystr = querystr[0:len(querystr) - 1]
adapter.write_statement(name,querystr)
return nil
}
func (adapter *Mysql_Adapter) write() error {
out := `/* This file was generated by Gosora's Query Generator */
package main
import "log"
import "database/sql"
` + adapter.Stmts + `
func gen_mysql() (err error) {
if debug {
log.Print("Building the generated statements")
}
` + adapter.Body + `
return nil
}
`
return write_file("./gen_mysql.go", out)
}
// Internal method, not exposed in the interface
func (adapter *Mysql_Adapter) write_statement(name string, querystr string ) {
adapter.Stmts += "var " + name + "_stmt *sql.Stmt\n"
adapter.Body += `
log.Print("Preparing ` + name + ` statement.")
` + name + `_stmt, err = db.Prepare("` + querystr + `")
if err != nil {
return err
}
`
}

10
query_gen/run.bat Normal file
View File

@ -0,0 +1,10 @@
@echo off
echo Building the query generator
go build
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo The query generator was successfully built
query_gen.exe
pause

View File

@ -1,4 +1,5 @@
package main
//import "fmt"
import "strings"
import "sync"
@ -33,7 +34,7 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
w.Write([]byte(""))
return
}
var /*extra_data, */prefix string
if req.URL.Path[len(req.URL.Path) - 1] != '/' {
//extra_data = req.URL.Path[strings.LastIndexByte(req.URL.Path,'/') + 1:]
@ -41,11 +42,11 @@ func (router *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
} else {
prefix = req.URL.Path
}
router.RLock()
handle, ok := router.routes[prefix]
router.RUnlock()
if ok {
handle(w,req)
return

View File

@ -1,5 +1,4 @@
/* WIP Under Construction */
// The router generator might be discontinued in favour of syncmaps in Go 1.9, it will be temporarily used for a couple of months as a lockless alternative to maps
package main
import "log"
@ -17,7 +16,7 @@ func main() {
routes()
var out string
var fdata string = "// 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// The router generator might be discontinued in favour of syncmaps in Go 1.9, it will be temporarily used for a couple of months as a lockless alternative to maps\n"
var fdata string = "// 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"
for _, route := range route_list {
var end int

View File

@ -30,16 +30,16 @@ func routes() {
addRoute("route_forum","/forum/","","extra_data")
//addRoute("route_topic_create","/topics/create/","","extra_data")
//addRoute("route_topics","/topics/",""/*,"&groups","&forums"*/)
addRouteGroup("/report/",
Route{"route_report_submit","/report/submit/","",[]string{"extra_data"}},
)
addRouteGroup("/topics/",
Route{"route_topics","/topics/","",[]string{}},
Route{"route_topic_create","/topics/create/","",[]string{"extra_data"}},
)
// The Control Panel
addRouteGroup("/panel/",
Route{"route_panel","/panel/","",[]string{}},
@ -49,29 +49,30 @@ func routes() {
Route{"route_panel_forums_delete_submit","/panel/forums/delete/submit/","",[]string{"extra_data"}},
Route{"route_panel_forums_edit","/panel/forums/edit/","",[]string{"extra_data"}},
Route{"route_panel_forums_edit_submit","/panel/forums/edit/submit/","",[]string{"extra_data"}},
Route{"route_panel_forums_edit_perms_submit","/panel/forums/edit/perms/submit/","",[]string{"extra_data"}},
Route{"route_panel_settings","/panel/settings/","",[]string{}},
Route{"route_panel_setting","/panel/settings/edit/","",[]string{"extra_data"}},
Route{"route_panel_setting_edit","/panel/settings/edit/submit/","",[]string{"extra_data"}},
Route{"route_panel_themes","/panel/themes/","",[]string{}},
Route{"route_panel_themes_default","/panel/themes/default/","",[]string{"extra_data"}},
Route{"route_panel_plugins","/panel/plugins/","",[]string{}},
Route{"route_panel_plugins_activate","/panel/plugins/activate/","",[]string{"extra_data"}},
Route{"route_panel_plugins_deactivate","/panel/plugins/deactivate/","",[]string{"extra_data"}},
Route{"route_panel_users","/panel/users/","",[]string{}},
Route{"route_panel_users_edit","/panel/users/edit/","",[]string{"extra_data"}},
Route{"route_panel_users_edit_submit","/panel/users/edit/submit/","",[]string{"extra_data"}},
Route{"route_panel_groups","/panel/groups/","",[]string{}},
Route{"route_panel_groups_edit","/panel/groups/edit/","",[]string{"extra_data"}},
Route{"route_panel_groups_edit_perms","/panel/groups/edit/perms/","",[]string{"extra_data"}},
Route{"route_panel_groups_edit_submit","/panel/groups/edit/submit/","",[]string{"extra_data"}},
Route{"route_panel_groups_edit_perms_submit","/panel/groups/edit/perms/submit/","",[]string{"extra_data"}},
Route{"route_panel_groups_create_submit","/panel/groups/create/","",[]string{}},
Route{"route_panel_logs_mod","/panel/logs/mod/","",[]string{}},
)
}

View File

@ -56,11 +56,13 @@ func route_static(w http.ResponseWriter, r *http.Request){
//io.CopyN(w, bytes.NewReader(file.Data), static_files[r.URL.Path].Length)
}
// Deprecated: Test route for stopping the server during a performance analysis
/*func route_exit(w http.ResponseWriter, r *http.Request){
db.Close()
os.Exit(0)
}
// Deprecated: Test route to see which is faster
func route_fstatic(w http.ResponseWriter, r *http.Request){
http.ServeFile(w,r,r.URL.Path)
}*/
@ -109,7 +111,7 @@ func route_topics(w http.ResponseWriter, r *http.Request){
}
var topicList []TopicsRow
rows, err := db.Query("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.likeCount, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid where parentID in("+strings.Join(fidList,",")+") order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC")
rows, err := db.Query("select topics.tid, topics.title, topics.content, topics.createdBy, topics.is_closed, topics.sticky, topics.createdAt, topics.lastReplyAt, topics.parentID, topics.postCount, topics.likeCount, users.name, users.avatar from topics left join users ON topics.createdBy = users.uid where parentID in("+strings.Join(fidList,",")+") order by topics.sticky DESC, topics.lastReplyAt DESC, topics.createdBy DESC")
//rows, err := get_topic_list_stmt.Query()
if err != nil {
InternalError(err,w,r)
@ -118,7 +120,7 @@ func route_topics(w http.ResponseWriter, r *http.Request){
topicItem := TopicsRow{ID: 0}
for rows.Next() {
err := rows.Scan(&topicItem.ID, &topicItem.Title, &topicItem.Content, &topicItem.CreatedBy, &topicItem.Is_Closed, &topicItem.Sticky, &topicItem.CreatedAt, &topicItem.LastReplyAt, &topicItem.ParentID, &topicItem.LikeCount, &topicItem.CreatedByName, &topicItem.Avatar)
err := rows.Scan(&topicItem.ID, &topicItem.Title, &topicItem.Content, &topicItem.CreatedBy, &topicItem.Is_Closed, &topicItem.Sticky, &topicItem.CreatedAt, &topicItem.LastReplyAt, &topicItem.ParentID, &topicItem.PostCount, &topicItem.LikeCount, &topicItem.CreatedByName, &topicItem.Avatar)
if err != nil {
InternalError(err,w,r)
return
@ -206,9 +208,9 @@ func route_forum(w http.ResponseWriter, r *http.Request, sfid string){
}
var topicList []TopicUser
topicItem := TopicUser{ID: 0}
var topicItem TopicUser = TopicUser{ID: 0}
for rows.Next() {
err := rows.Scan(&topicItem.ID, &topicItem.Title, &topicItem.Content, &topicItem.CreatedBy, &topicItem.Is_Closed, &topicItem.Sticky, &topicItem.CreatedAt, &topicItem.LastReplyAt, &topicItem.ParentID, &topicItem.LikeCount, &topicItem.CreatedByName, &topicItem.Avatar)
err := rows.Scan(&topicItem.ID, &topicItem.Title, &topicItem.Content, &topicItem.CreatedBy, &topicItem.Is_Closed, &topicItem.Sticky, &topicItem.CreatedAt, &topicItem.LastReplyAt, &topicItem.ParentID, &topicItem.PostCount, &topicItem.LikeCount, &topicItem.CreatedByName, &topicItem.Avatar)
if err != nil {
InternalError(err,w,r)
return
@ -262,7 +264,7 @@ func route_forums(w http.ResponseWriter, r *http.Request){
//fmt.Println(group.CanSee)
for _, fid := range group.CanSee {
//fmt.Println(forums[fid])
forum := forums[fid]
var forum Forum = forums[fid]
if forum.Active && forum.Name != "" {
if forum.LastTopicID != 0 {
forum.LastTopicTime, err = relative_time(forum.LastTopicTime)
@ -1099,7 +1101,6 @@ func route_report_submit(w http.ResponseWriter, r *http.Request, sitem_id string
return
}
title = "Report: " + title
res, err := create_report_stmt.Exec(title,content,parse_message(content),user.ID,item_type + "_" + strconv.Itoa(item_id))
if err != nil {
InternalError(err,w,r)
@ -1526,9 +1527,7 @@ func route_login_submit(w http.ResponseWriter, r *http.Request) {
}
var uid int
var real_password string
var salt string
var session string
var real_password, salt, session string
username := html.EscapeString(r.PostFormValue("username"))
password := r.PostFormValue("password")
@ -1579,11 +1578,11 @@ func route_login_submit(w http.ResponseWriter, r *http.Request) {
return
}
cookie := http.Cookie{Name: "uid",Value: strconv.Itoa(uid),Path: "/",MaxAge: year}
cookie := http.Cookie{Name:"uid",Value:strconv.Itoa(uid),Path:"/",MaxAge:year}
http.SetCookie(w,&cookie)
cookie = http.Cookie{Name: "session",Value: session,Path: "/",MaxAge: year}
cookie = http.Cookie{Name:"session",Value:session,Path:"/",MaxAge:year}
http.SetCookie(w,&cookie)
http.Redirect(w,r, "/", http.StatusSeeOther)
http.Redirect(w,r,"/",http.StatusSeeOther)
}
func route_register(w http.ResponseWriter, r *http.Request) {

View File

@ -15,6 +15,15 @@ if %errorlevel% neq 0 (
echo Running the router generator
router_gen.exe
echo Building the query generator
go build ./query_gen
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Running the query generator
query_gen.exe
echo Building the executable
go build -o gosora.exe -tags no_ws
if %errorlevel% neq 0 (

View File

@ -16,6 +16,15 @@ if %errorlevel% neq 0 (
echo Running the router generator
router_gen.exe
echo Building the query generator
go build ./query_gen
if %errorlevel% neq 0 (
pause
exit /b %errorlevel%
)
echo Running the query generator
query_gen.exe
echo Building the executable
go build -o gosora.exe
if %errorlevel% neq 0 (

View File

@ -88,26 +88,32 @@ w.Write(forum_18)
}
}
w.Write(forum_19)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write([]byte(strconv.Itoa(item.PostCount)))
w.Write(forum_20)
w.Write([]byte(item.Title))
w.Write(forum_21)
if item.Is_Closed {
w.Write(forum_22)
}
w.Write(forum_23)
w.Write([]byte(item.LastReplyAt))
w.Write(forum_21)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(forum_22)
w.Write([]byte(item.Title))
w.Write(forum_23)
w.Write([]byte(strconv.Itoa(item.CreatedBy)))
w.Write(forum_24)
}
} else {
w.Write([]byte(item.CreatedByName))
w.Write(forum_25)
if tmpl_forum_vars.CurrentUser.Perms.CreateTopic {
if item.Is_Closed {
w.Write(forum_26)
w.Write([]byte(strconv.Itoa(tmpl_forum_vars.Forum.ID)))
}
w.Write(forum_27)
}
} else {
w.Write(forum_28)
}
if tmpl_forum_vars.CurrentUser.Perms.CreateTopic {
w.Write(forum_29)
w.Write([]byte(strconv.Itoa(tmpl_forum_vars.Forum.ID)))
w.Write(forum_30)
}
w.Write(forum_31)
}
w.Write(forum_32)
w.Write(footer_0)
}

View File

@ -1,8 +1,8 @@
// Code generated by. DO NOT EDIT.
/* 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 "io"
import "strconv"
import "io"
func init() {
template_forums_handle = template_forums
@ -45,20 +45,48 @@ w.Write(forums_0)
if len(tmpl_forums_vars.ItemList) != 0 {
for _, item := range tmpl_forums_vars.ItemList {
w.Write(forums_1)
w.Write([]byte(strconv.Itoa(item.ID)))
if item.Desc != "" || item.LastTopicTime != "" {
w.Write(forums_2)
w.Write([]byte(item.Name))
}
w.Write(forums_3)
w.Write([]byte(strconv.Itoa(item.LastTopicID)))
if item.Desc != "" {
w.Write(forums_4)
w.Write([]byte(item.LastTopic))
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(forums_5)
w.Write([]byte(item.LastTopicTime))
w.Write([]byte(item.Name))
w.Write(forums_6)
w.Write([]byte(item.Desc))
w.Write(forums_7)
} else {
if item.LastTopicTime != "" {
w.Write(forums_8)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(forums_9)
w.Write([]byte(item.Name))
w.Write(forums_10)
} else {
w.Write(forums_11)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(forums_12)
w.Write([]byte(item.Name))
w.Write(forums_13)
}
}
w.Write(forums_14)
w.Write([]byte(strconv.Itoa(item.LastTopicID)))
w.Write(forums_15)
w.Write([]byte(item.LastTopic))
w.Write(forums_16)
if item.LastTopicTime != "" {
w.Write(forums_17)
w.Write([]byte(item.LastTopicTime))
w.Write(forums_18)
}
w.Write(forums_19)
}
} else {
w.Write(forums_7)
w.Write(forums_20)
}
w.Write(forums_8)
w.Write(forums_21)
w.Write(footer_0)
}

View File

@ -40,7 +40,8 @@ var menu_6 []byte = []byte(`
<li class="menu_left menu_login"><a href="/accounts/login/">Login</a></li>
`)
var menu_7 []byte = []byte(`
<li class="menu_right menu_alerts">🔔
<li class="menu_right menu_alerts">
<div class="alert_bell">🔔</div>
<div class="alert_counter"></div>
<div class="alertList"></div>
</li>
@ -48,7 +49,8 @@ var menu_7 []byte = []byte(`
</div>
</div>
<div style="clear: both;"></div>
</div>`)
</div>
`)
var header_3 []byte = []byte(`
<div id="back"><div id="main">
`)
@ -389,18 +391,23 @@ var profile_5 []byte = []byte(`
<div class="rowitem passive">
<a class="profile_menu_item">Add Friend</a>
</div>
<div class="rowitem passive"
`)
var profile_6 []byte = []byte(`<div class="rowitem passive">
`)
var profile_6 []byte = []byte(`<a href="/users/unban/`)
var profile_7 []byte = []byte(`?session=`)
var profile_8 []byte = []byte(`" class="username">Unban</a>`)
var profile_9 []byte = []byte(`<a href="/users/ban/`)
var profile_10 []byte = []byte(`?session=`)
var profile_11 []byte = []byte(`" class="username">Ban</a>`)
var profile_12 []byte = []byte(`
var profile_7 []byte = []byte(`<a href="/users/unban/`)
var profile_8 []byte = []byte(`?session=`)
var profile_9 []byte = []byte(`" class="profile_menu_item">Unban</a>
`)
var profile_10 []byte = []byte(`<a href="/users/ban/`)
var profile_11 []byte = []byte(`?session=`)
var profile_12 []byte = []byte(`" class="profile_menu_item">Ban</a>`)
var profile_13 []byte = []byte(`
</div>`)
var profile_14 []byte = []byte(`
<div class="rowitem passive">
<a href="/report/submit/`)
var profile_13 []byte = []byte(`?session=`)
var profile_14 []byte = []byte(`&type=user" class="profile_menu_item report_item">Report</a>
var profile_15 []byte = []byte(`?session=`)
var profile_16 []byte = []byte(`&type=user" class="profile_menu_item report_item">Report</a>
</div>
</div>
@ -408,45 +415,45 @@ var profile_14 []byte = []byte(`&type=user" class="profile_menu_item report_item
<div class="rowitem rowhead"><a>Comments</a></div>
</div>
<div id="profile_comments" class="colblock_right" style="overflow: hidden;border-top: none;width:calc(95% - 210px);">`)
var profile_15 []byte = []byte(`
var profile_17 []byte = []byte(`
<div class="rowitem passive deletable_block editable_parent simple" style="`)
var profile_16 []byte = []byte(`background-image: url(`)
var profile_17 []byte = []byte(`), url(/static/white-dot.jpg);background-position: 0px `)
var profile_18 []byte = []byte(`-1`)
var profile_19 []byte = []byte(`0px;background-repeat: no-repeat, repeat-y;background-size: 128px;padding-left: 136px;`)
var profile_20 []byte = []byte(`">
var profile_18 []byte = []byte(`background-image: url(`)
var profile_19 []byte = []byte(`), url(/static/white-dot.jpg);background-position: 0px `)
var profile_20 []byte = []byte(`-1`)
var profile_21 []byte = []byte(`0px;background-repeat: no-repeat, repeat-y;background-size: 128px;padding-left: 136px;`)
var profile_22 []byte = []byte(`">
<span class="editable_block user_content simple">`)
var profile_21 []byte = []byte(`</span><br /><br />
var profile_23 []byte = []byte(`</span><br /><br />
<a href="/user/`)
var profile_22 []byte = []byte(`" class="real_username username">`)
var profile_23 []byte = []byte(`</a>&nbsp;&nbsp;
var profile_24 []byte = []byte(`" class="real_username username">`)
var profile_25 []byte = []byte(`</a>&nbsp;&nbsp;
`)
var profile_24 []byte = []byte(`<a href="/profile/reply/edit/submit/`)
var profile_25 []byte = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
var profile_26 []byte = []byte(`<a href="/profile/reply/edit/submit/`)
var profile_27 []byte = []byte(`" class="mod_button" title="Edit Item"><button class="username edit_item edit_label"></button></a>
<a href="/profile/reply/delete/submit/`)
var profile_26 []byte = []byte(`" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>`)
var profile_27 []byte = []byte(`
var profile_28 []byte = []byte(`" class="mod_button" title="Delete Item"><button class="username delete_item trash_label"></button></a>`)
var profile_29 []byte = []byte(`
<a class="mod_button" href="/report/submit/`)
var profile_28 []byte = []byte(`?session=`)
var profile_29 []byte = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
var profile_30 []byte = []byte(`?session=`)
var profile_31 []byte = []byte(`&type=user-reply"><button class="username report_item flag_label"></button></a>
`)
var profile_30 []byte = []byte(`<a class="username hide_on_mobile" style="float: right;">`)
var profile_31 []byte = []byte(`</a>`)
var profile_32 []byte = []byte(`
var profile_32 []byte = []byte(`<a class="username hide_on_mobile" style="float: right;">`)
var profile_33 []byte = []byte(`</a>`)
var profile_34 []byte = []byte(`
</div>
`)
var profile_33 []byte = []byte(`</div>
var profile_35 []byte = []byte(`</div>
<div class="colblock_right" style="border-top: none;width: calc(95% - 210px);">
`)
var profile_34 []byte = []byte(`
var profile_36 []byte = []byte(`
<form action="/profile/reply/create/" method="post">
<input name="uid" value='`)
var profile_35 []byte = []byte(`' type="hidden" />
var profile_37 []byte = []byte(`' type="hidden" />
<div class="formrow">
<div class="formitem"><textarea name="reply-content" placeholder="Insert reply here"></textarea></div>
</div>
@ -455,7 +462,7 @@ var profile_35 []byte = []byte(`' type="hidden" />
</div>
</form>
`)
var profile_36 []byte = []byte(`
var profile_38 []byte = []byte(`
</div>
`)
@ -465,48 +472,84 @@ var forums_0 []byte = []byte(`
</div>
<div class="rowblock">
`)
var forums_1 []byte = []byte(`<div class="rowitem">
<a href="/forum/`)
var forums_2 []byte = []byte(`" class="panel_upshift">`)
var forums_3 []byte = []byte(`</a>
<a href="/topic/`)
var forums_4 []byte = []byte(`" style="float: right;">`)
var forums_5 []byte = []byte(` <small style="font-size: 12px;">`)
var forums_6 []byte = []byte(`</small></a>
var forums_1 []byte = []byte(`<div class="rowitem `)
var forums_2 []byte = []byte(`datarow`)
var forums_3 []byte = []byte(`">
`)
var forums_4 []byte = []byte(`<span style="float: left;">
<a href="/forum/`)
var forums_5 []byte = []byte(`" style="">`)
var forums_6 []byte = []byte(`</a>
<br /><span class="rowsmall">`)
var forums_7 []byte = []byte(`</span>
</span>`)
var forums_8 []byte = []byte(`<span style="float: left;padding-top: 8px;font-size: 18px;">
<a href="/forum/`)
var forums_9 []byte = []byte(`">`)
var forums_10 []byte = []byte(`</a>
</span>`)
var forums_11 []byte = []byte(`<span style="float: left;">
<a href="/forum/`)
var forums_12 []byte = []byte(`">`)
var forums_13 []byte = []byte(`</a>
</span>`)
var forums_14 []byte = []byte(`
<span style="float: right;">
<a href="/topic/`)
var forums_15 []byte = []byte(`" style="float: right;font-size: 14px;">`)
var forums_16 []byte = []byte(`</a>
`)
var forums_17 []byte = []byte(`<br /><span class="rowsmall">`)
var forums_18 []byte = []byte(`</span>`)
var forums_19 []byte = []byte(`
</span>
<div style="clear: both;"></div>
</div>
`)
var forums_7 []byte = []byte(`<div class="rowitem passive">You don't have access to any forums.</div>`)
var forums_8 []byte = []byte(`
var forums_20 []byte = []byte(`<div class="rowitem passive">You don't have access to any forums.</div>`)
var forums_21 []byte = []byte(`
</div>
`)
var topics_0 []byte = []byte(`
<div class="rowblock">
<div class="rowitem rowhead"><a>Topic List</a></div>
</div>
<div class="rowblock">
<div id="topic_list" class="rowblock topic_list">
`)
var topics_1 []byte = []byte(`<div class="rowitem passive" style="`)
var topics_1 []byte = []byte(`<div class="rowitem passive datarow" style="`)
var topics_2 []byte = []byte(`background-image: url(`)
var topics_3 []byte = []byte(`);background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;`)
var topics_4 []byte = []byte(`background-color: #FFFFCC;`)
var topics_5 []byte = []byte(`background-color: #eaeaea;`)
var topics_6 []byte = []byte(`">
<a href="/topic/`)
var topics_7 []byte = []byte(`">`)
var topics_8 []byte = []byte(`</a> `)
var topics_9 []byte = []byte(`<a href="/forum/`)
var topics_10 []byte = []byte(`" style="font-size:12px;">`)
var topics_11 []byte = []byte(`</a> `)
var topics_12 []byte = []byte(`<span class="username topic_status_e topic_status_closed" style="float: right;position:relative;top:-5px;margin-left:8px;" title="Status: Closed">&#x1F512;&#xFE0E</span>`)
var topics_13 []byte = []byte(`
<a style="float: right;font-size:12px;">`)
var topics_14 []byte = []byte(`</a>
<span class="rowsmall" style="float: right;">
<span class="replyCount">`)
var topics_7 []byte = []byte(` replies</span><br />
<span class="lastReplyAt">`)
var topics_8 []byte = []byte(`</span>
</span>
<span>
<a class="rowtopic" href="/topic/`)
var topics_9 []byte = []byte(`">`)
var topics_10 []byte = []byte(`</a> `)
var topics_11 []byte = []byte(`<a class="rowsmall" href="/forum/`)
var topics_12 []byte = []byte(`">`)
var topics_13 []byte = []byte(`</a>`)
var topics_14 []byte = []byte(`
<br /><a class="rowsmall" href="/user/`)
var topics_15 []byte = []byte(`">Starter: `)
var topics_16 []byte = []byte(`</a>
`)
var topics_17 []byte = []byte(`<span class="rowsmall topic_status_e topic_status_closed" title="Status: Closed"> | &#x1F512;&#xFE0E`)
var topics_18 []byte = []byte(`</span>
</span>
</div>
`)
var topics_15 []byte = []byte(`<div class="rowitem passive">There aren't any topics yet.`)
var topics_16 []byte = []byte(` <a href="/topics/create/">Start one?</a>`)
var topics_17 []byte = []byte(`</div>`)
var topics_18 []byte = []byte(`
var topics_19 []byte = []byte(`<div class="rowitem passive">There aren't any topics yet.`)
var topics_20 []byte = []byte(` <a href="/topics/create/">Start one?</a>`)
var topics_21 []byte = []byte(`</div>`)
var topics_22 []byte = []byte(`
</div>
`)
var forum_0 []byte = []byte(`<div id="prevFloat" class="prev_button"><a class="prev_link" href="/forum/`)
@ -529,27 +572,37 @@ var forum_11 []byte = []byte(`<a href="/topics/create/`)
var forum_12 []byte = []byte(`" class='username head_tag_upshift'>New Topic</a>`)
var forum_13 []byte = []byte(`</div>
</div>
<div class="rowblock">
<div id="forum_topic_list" class="rowblock topic_list">
`)
var forum_14 []byte = []byte(`<div class="rowitem passive" style="`)
var forum_14 []byte = []byte(`<div class="rowitem passive datarow" style="`)
var forum_15 []byte = []byte(`background-image: url(`)
var forum_16 []byte = []byte(`);background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;`)
var forum_17 []byte = []byte(`background-color: #FFFFCC;`)
var forum_18 []byte = []byte(`background-color: #eaeaea;`)
var forum_19 []byte = []byte(`">
<a href="/topic/`)
var forum_20 []byte = []byte(`">`)
var forum_21 []byte = []byte(`</a> `)
var forum_22 []byte = []byte(`<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;position:relative;top:-5px;margin-left:8px;">&#x1F512;&#xFE0E</span>`)
var forum_23 []byte = []byte(`
<a style="float: right;font-size:12px;">`)
var forum_24 []byte = []byte(`</a>
<span class="rowsmall" style="float: right;">
<span class="replyCount">`)
var forum_20 []byte = []byte(` replies</span><br />
<span class="lastReplyAt">`)
var forum_21 []byte = []byte(`</span>
</span>
<span>
<a class="rowtopic" href="/topic/`)
var forum_22 []byte = []byte(`">`)
var forum_23 []byte = []byte(`</a>
<br /><a class="rowsmall" href="/user/`)
var forum_24 []byte = []byte(`">Starter: `)
var forum_25 []byte = []byte(`</a>
`)
var forum_26 []byte = []byte(`<span class="rowsmall topic_status_e topic_status_closed" title="Status: Closed"> | &#x1F512;&#xFE0E`)
var forum_27 []byte = []byte(`</span>
</span>
</div>
`)
var forum_25 []byte = []byte(`<div class="rowitem passive">There aren't any topics in this forum yet.`)
var forum_26 []byte = []byte(` <a href="/topics/create/`)
var forum_27 []byte = []byte(`">Start one?</a>`)
var forum_28 []byte = []byte(`</div>`)
var forum_29 []byte = []byte(`
var forum_28 []byte = []byte(`<div class="rowitem passive">There aren't any topics in this forum yet.`)
var forum_29 []byte = []byte(` <a href="/topics/create/`)
var forum_30 []byte = []byte(`">Start one?</a>`)
var forum_31 []byte = []byte(`</div>`)
var forum_32 []byte = []byte(`
</div>
`)

View File

@ -1,8 +1,8 @@
// Code generated by. DO NOT EDIT.
/* 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 "io"
import "strconv"
import "io"
func init() {
template_profile_handle = template_profile
@ -53,71 +53,73 @@ w.Write(profile_4)
}
w.Write(profile_5)
if tmpl_profile_vars.CurrentUser.Is_Super_Mod && !tmpl_profile_vars.ProfileOwner.Is_Super_Mod {
if tmpl_profile_vars.ProfileOwner.Is_Banned {
w.Write(profile_6)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
if tmpl_profile_vars.ProfileOwner.Is_Banned {
w.Write(profile_7)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_8)
} else {
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_9)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
} else {
w.Write(profile_10)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_11)
}
}
w.Write(profile_12)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_13)
w.Write(profile_11)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_12)
}
w.Write(profile_13)
}
w.Write(profile_14)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_15)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_16)
if len(tmpl_profile_vars.ItemList) != 0 {
for _, item := range tmpl_profile_vars.ItemList {
w.Write(profile_15)
if item.Avatar != "" {
w.Write(profile_16)
w.Write([]byte(item.Avatar))
w.Write(profile_17)
if item.ContentLines <= 5 {
if item.Avatar != "" {
w.Write(profile_18)
}
w.Write([]byte(item.Avatar))
w.Write(profile_19)
if item.ContentLines <= 5 {
w.Write(profile_20)
}
w.Write(profile_21)
w.Write([]byte(string(item.Css)))
}
w.Write(profile_20)
w.Write([]byte(item.ContentHtml))
w.Write(profile_21)
w.Write([]byte(strconv.Itoa(item.CreatedBy)))
w.Write(profile_22)
w.Write([]byte(item.CreatedByName))
w.Write([]byte(item.ContentHtml))
w.Write(profile_23)
if tmpl_profile_vars.CurrentUser.Is_Mod {
w.Write([]byte(strconv.Itoa(item.CreatedBy)))
w.Write(profile_24)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write([]byte(item.CreatedByName))
w.Write(profile_25)
w.Write([]byte(strconv.Itoa(item.ID)))
if tmpl_profile_vars.CurrentUser.Is_Mod {
w.Write(profile_26)
}
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_27)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_28)
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
}
w.Write(profile_29)
if item.Tag != "" {
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(profile_30)
w.Write([]byte(item.Tag))
w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(profile_31)
}
if item.Tag != "" {
w.Write(profile_32)
}
}
w.Write([]byte(item.Tag))
w.Write(profile_33)
if !tmpl_profile_vars.CurrentUser.Is_Banned {
w.Write(profile_34)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_35)
}
w.Write(profile_34)
}
}
w.Write(profile_35)
if !tmpl_profile_vars.CurrentUser.Is_Banned {
w.Write(profile_36)
w.Write([]byte(strconv.Itoa(tmpl_profile_vars.ProfileOwner.ID)))
w.Write(profile_37)
}
w.Write(profile_38)
w.Write(footer_0)
}

View File

@ -58,31 +58,38 @@ w.Write(topics_5)
}
}
w.Write(topics_6)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write([]byte(strconv.Itoa(item.PostCount)))
w.Write(topics_7)
w.Write([]byte(item.Title))
w.Write(topics_8)
if item.ForumName != "" {
w.Write(topics_9)
w.Write([]byte(strconv.Itoa(item.ParentID)))
w.Write(topics_10)
w.Write([]byte(item.ForumName))
w.Write(topics_11)
}
if item.Is_Closed {
w.Write(topics_12)
}
w.Write(topics_13)
w.Write([]byte(item.LastReplyAt))
w.Write(topics_8)
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topics_9)
w.Write([]byte(item.Title))
w.Write(topics_10)
if item.ForumName != "" {
w.Write(topics_11)
w.Write([]byte(strconv.Itoa(item.ParentID)))
w.Write(topics_12)
w.Write([]byte(item.ForumName))
w.Write(topics_13)
}
w.Write(topics_14)
}
} else {
w.Write([]byte(strconv.Itoa(item.CreatedBy)))
w.Write(topics_15)
if tmpl_topics_vars.CurrentUser.Perms.CreateTopic {
w.Write([]byte(item.CreatedByName))
w.Write(topics_16)
}
if item.Is_Closed {
w.Write(topics_17)
}
w.Write(topics_18)
}
} else {
w.Write(topics_19)
if tmpl_topics_vars.CurrentUser.Perms.CreateTopic {
w.Write(topics_20)
}
w.Write(topics_21)
}
w.Write(topics_22)
w.Write(footer_0)
}

View File

@ -1,15 +1,17 @@
package main
import "log"
import "fmt"
import "bytes"
import "strings"
import "strconv"
//import "regexp"
import "reflect"
import "path/filepath"
import "io/ioutil"
import "text/template/parse"
import (
"log"
"fmt"
"bytes"
"strings"
"strconv"
//"regexp"
"reflect"
"path/filepath"
"io/ioutil"
"text/template/parse"
)
var ctemplates []string
var tmpl_ptr_map map[string]interface{} = make(map[string]interface{})
@ -181,12 +183,14 @@ w.Write([]byte(`," + ",-1)
}
func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Value, template_name string, node interface{}) (out string) {
if super_debug {
fmt.Println("in compile_switch")
}
switch node := node.(type) {
case *parse.ActionNode:
if super_debug {
fmt.Println("Action Node")
}
if node.Pipe == nil {
break
}
@ -196,18 +200,24 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
return out
case *parse.IfNode:
if super_debug {
fmt.Println("If Node: ")
fmt.Println(node.Pipe)
fmt.Println("If Node:")
fmt.Println("node.Pipe",node.Pipe)
}
var expr string
for _, cmd := range node.Pipe.Cmds {
if super_debug {
fmt.Println("If Node Bit: ")
fmt.Println(cmd)
fmt.Println(reflect.ValueOf(cmd).Type().Name())
fmt.Println("If Node Bit:",cmd)
fmt.Println("If Node Bit Type:",reflect.ValueOf(cmd).Type().Name())
}
expr += c.compile_varswitch(varholder, holdreflect, template_name, cmd)
if super_debug {
fmt.Println("If Node Expression Step:",c.compile_varswitch(varholder, holdreflect, template_name, cmd))
}
}
if super_debug {
fmt.Println("If Node Expression:",expr)
}
c.previousNode = c.currentNode
@ -215,12 +225,12 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
c.nextNode = -1
if node.ElseList == nil {
if super_debug {
fmt.Println("Branch 1")
fmt.Println("Selected Branch 1")
}
return "if " + expr + " {\n" + c.compile_switch(varholder, holdreflect, template_name, node.List) + "}\n"
} else {
if super_debug {
fmt.Println("Branch 2")
fmt.Println("Selected Branch 2")
}
return "if " + expr + " {\n" + c.compile_switch(varholder, holdreflect, template_name, node.List) + "} else {\n" + c.compile_switch(varholder, holdreflect, template_name, node.ElseList) + "}\n"
}
@ -241,15 +251,13 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
var outVal reflect.Value
for _, cmd := range node.Pipe.Cmds {
if super_debug {
fmt.Println("Range Bit: ")
fmt.Println(cmd)
fmt.Println("Range Bit:",cmd)
}
out, outVal = c.compile_reflectswitch(varholder, holdreflect, template_name, cmd)
}
if super_debug {
fmt.Println("Returned: ")
fmt.Println(out)
fmt.Println("Returned:",out)
fmt.Println("Range Kind Switch!")
}
@ -280,9 +288,6 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
}
return out
case *parse.TemplateNode:
if super_debug {
fmt.Println("Template Node")
}
return c.compile_subtemplate(varholder, holdreflect, node)
case *parse.TextNode:
c.previousNode = c.currentNode
@ -309,12 +314,14 @@ func (c *CTemplateSet) compile_switch(varholder string, holdreflect reflect.Valu
}
func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.Value, template_name string, node *parse.CommandNode) (out string) {
if super_debug {
fmt.Println("in compile_subswitch")
}
firstWord := node.Args[0]
switch n := firstWord.(type) {
case *parse.FieldNode:
if super_debug {
fmt.Println("Field Node: ")
fmt.Println(n.Ident)
fmt.Println("Field Node:",n.Ident)
}
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
@ -328,10 +335,8 @@ func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.V
for _, id := range n.Ident {
if super_debug {
fmt.Println("Data Kind: ")
fmt.Println(cur.Kind().String())
fmt.Println("Field Bit: ")
fmt.Println(id)
fmt.Println("Data Kind:",cur.Kind().String())
fmt.Println("Field Bit:",id)
}
cur = cur.FieldByName(id)
@ -363,16 +368,14 @@ func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.V
return out
case *parse.DotNode:
if super_debug {
fmt.Println("Dot Node")
fmt.Println(node.String())
fmt.Println("Dot Node:",node.String())
}
return c.compile_varsub(varholder, holdreflect)
case *parse.NilNode:
panic("Nil is not a command x.x")
case *parse.VariableNode:
if super_debug {
fmt.Println("Variable Node")
fmt.Println(n.String())
fmt.Println("Variable Node:",n.String())
fmt.Println(n.Ident)
}
varname, reflectVal := c.compile_if_varsub(n.String(), varholder, template_name, holdreflect)
@ -381,32 +384,29 @@ func (c *CTemplateSet) compile_subswitch(varholder string, holdreflect reflect.V
return n.Quoted
case *parse.IdentifierNode:
if super_debug {
fmt.Println("Identifier Node: ")
fmt.Println(node)
fmt.Println(node.Args)
fmt.Println("Identifier Node:",node)
fmt.Println("Identifier Node Args:",node.Args)
}
return c.compile_varsub(c.compile_identswitch(varholder, holdreflect, template_name, node))
default:
fmt.Println("Unknown Kind: ")
fmt.Println(reflect.ValueOf(firstWord).Elem().Kind())
fmt.Println("Unknown Type: ")
fmt.Println(reflect.ValueOf(firstWord).Elem().Type().Name())
fmt.Println("Unknown Kind:",reflect.ValueOf(firstWord).Elem().Kind())
fmt.Println("Unknown Type:",reflect.ValueOf(firstWord).Elem().Type().Name())
panic("I don't know what node this is")
}
return ""
}
func (c *CTemplateSet) compile_varswitch(varholder string, holdreflect reflect.Value, template_name string, node *parse.CommandNode) (out string) {
if super_debug {
fmt.Println("in compile_varswitch")
}
firstWord := node.Args[0]
switch n := firstWord.(type) {
case *parse.FieldNode:
if super_debug {
fmt.Println("Field Node: ")
fmt.Println(n.Ident)
fmt.Println("Field Node:",n.Ident)
for _, id := range n.Ident {
fmt.Println("Field Bit: ")
fmt.Println(id)
fmt.Println("Field Bit:",id)
}
}
@ -414,25 +414,22 @@ func (c *CTemplateSet) compile_varswitch(varholder string, holdreflect reflect.V
return c.compile_boolsub(n.String(), varholder, template_name, holdreflect)
case *parse.ChainNode:
if super_debug {
fmt.Println("Chain Node: ")
fmt.Println(n.Node)
fmt.Println(node.Args)
fmt.Println("Chain Node:",n.Node)
fmt.Println("Chain Node Args:",node.Args)
}
break
case *parse.IdentifierNode:
if super_debug {
fmt.Println("Identifier Node: ")
fmt.Println(node)
fmt.Println(node.Args)
fmt.Println("Identifier Node:",node)
fmt.Println("Identifier Node Args:",node.Args)
}
return c.compile_identswitch_n(varholder, holdreflect, template_name, node)
case *parse.DotNode:
return varholder
case *parse.VariableNode:
if super_debug {
fmt.Println("Variable Node")
fmt.Println(n.String())
fmt.Println(n.Ident)
fmt.Println("Variable Node:",n.String())
fmt.Println("Variable Node Identifier:",n.Ident)
}
out, _ = c.compile_if_varsub(n.String(), varholder, template_name, holdreflect)
return out
@ -442,45 +439,124 @@ func (c *CTemplateSet) compile_varswitch(varholder string, holdreflect reflect.V
if super_debug {
fmt.Println("Pipe Node!")
fmt.Println(n)
fmt.Println("Args: ")
fmt.Println(node.Args)
fmt.Println("Args:",node.Args)
}
out += c.compile_identswitch_n(varholder, holdreflect, template_name, node)
if super_debug {
fmt.Println("Out: ")
fmt.Println(out)
fmt.Println("Out:",out)
}
return out
default:
fmt.Println("Unknown Kind: ")
fmt.Println(reflect.ValueOf(firstWord).Elem().Kind())
fmt.Println("Unknown Type: ")
fmt.Println(reflect.ValueOf(firstWord).Elem().Type().Name())
fmt.Println("Unknown Kind:",reflect.ValueOf(firstWord).Elem().Kind())
fmt.Println("Unknown Type:",reflect.ValueOf(firstWord).Elem().Type().Name())
panic("I don't know what node this is! Grr...")
}
return ""
}
func (c *CTemplateSet) compile_identswitch_n(varholder string, holdreflect reflect.Value, template_name string, node *parse.CommandNode) (out string) {
if super_debug {
fmt.Println("in compile_identswitch_n")
}
out, _ = c.compile_identswitch(varholder, holdreflect, template_name, node)
return out
}
func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect.Value, template_name string, node *parse.CommandNode) (out string, val reflect.Value) {
if super_debug {
fmt.Println("in compile_identswitch")
}
//var outbuf map[int]string
ArgLoop:
for pos, id := range node.Args {
for pos := 0; pos < len(node.Args); pos++ {
id := node.Args[pos]
if super_debug {
fmt.Println(id)
fmt.Println("pos:",pos)
fmt.Println("ID:",id)
}
switch id.String() {
case "not":
out += "!"
case "or":
out += " || "
if super_debug {
fmt.Println("Building or function")
}
if pos == 0 {
fmt.Println("pos:",pos)
panic("or is missing a left operand")
return out, val
}
if len(node.Args) <= pos {
fmt.Println("post pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
panic("or is missing a right operand")
return out, val
}
left := c.compile_boolsub(node.Args[pos - 1].String(), varholder, template_name, holdreflect)
_, funcExists := c.funcMap[node.Args[pos + 1].String()]
var right string
if !funcExists {
right = c.compile_boolsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
}
out += left + " || " + right
if super_debug {
fmt.Println("Left operand:",node.Args[pos - 1])
fmt.Println("Right operand:",node.Args[pos + 1])
}
if !funcExists {
pos++
}
if super_debug {
fmt.Println("pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
}
case "and":
out += " && "
if super_debug {
fmt.Println("Building and function")
}
if pos == 0 {
fmt.Println("pos:",pos)
panic("and is missing a left operand")
return out, val
}
if len(node.Args) <= pos {
fmt.Println("post pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
panic("and is missing a right operand")
return out, val
}
left := c.compile_boolsub(node.Args[pos - 1].String(), varholder, template_name, holdreflect)
_, funcExists := c.funcMap[node.Args[pos + 1].String()]
var right string
if !funcExists {
right = c.compile_boolsub(node.Args[pos + 1].String(), varholder, template_name, holdreflect)
}
out += left + " && " + right
if super_debug {
fmt.Println("Left operand:",node.Args[pos - 1])
fmt.Println("Right operand:",node.Args[pos + 1])
}
if !funcExists {
pos++
}
if super_debug {
fmt.Println("pos:",pos)
fmt.Println("len(node.Args):",len(node.Args))
}
case "le":
out += c.compile_if_varsub_n(node.Args[pos + 1].String(), varholder, template_name, holdreflect) + " <= " + c.compile_if_varsub_n(node.Args[pos + 2].String(), varholder, template_name, holdreflect)
if super_debug {
@ -607,23 +683,33 @@ func (c *CTemplateSet) compile_identswitch(varholder string, holdreflect reflect
if super_debug {
fmt.Println("Variable!")
}
if len(node.Args) > (pos + 1) {
next_node := node.Args[pos + 1].String()
if next_node == "or" || next_node == "and" {
continue
}
}
out += c.compile_if_varsub_n(id.String(), varholder, template_name, holdreflect)
}
}
//for _, outval := range outbuf {
// out += outval
//}
return out, val
}
func (c *CTemplateSet) compile_reflectswitch(varholder string, holdreflect reflect.Value, template_name string, node *parse.CommandNode) (out string, outVal reflect.Value) {
if super_debug {
fmt.Println("in compile_reflectswitch")
}
firstWord := node.Args[0]
switch n := firstWord.(type) {
case *parse.FieldNode:
if super_debug {
fmt.Println("Field Node: ")
fmt.Println(n.Ident)
fmt.Println("Field Node:",n.Ident)
for _, id := range n.Ident {
fmt.Println("Field Bit: ")
fmt.Println(id)
fmt.Println("Field Bit:",id)
}
}
/* Use reflect to determine if the field is for a method, otherwise assume it's a variable. Coming Soon. */
@ -646,11 +732,17 @@ func (c *CTemplateSet) compile_reflectswitch(varholder string, holdreflect refle
}
func (c *CTemplateSet) compile_if_varsub_n(varname string, varholder string, template_name string, cur reflect.Value) (out string) {
if super_debug {
fmt.Println("in compile_if_varsub_n")
}
out, _ = c.compile_if_varsub(varname, varholder, template_name, cur)
return out
}
func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, template_name string, cur reflect.Value) (out string, val reflect.Value) {
if super_debug {
fmt.Println("in compile_if_varsub")
}
if varname[0] != '.' && varname[0] != '$' {
return varname, cur
}
@ -680,10 +772,8 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
bits[0] = strings.TrimPrefix(bits[0],"$")
if super_debug {
fmt.Println("Cur Kind: ")
fmt.Println(cur.Kind())
fmt.Println("Cur Type: ")
fmt.Println(cur.Type().Name())
fmt.Println("Cur Kind:",cur.Kind())
fmt.Println("Cur Type:",cur.Type().Name())
}
for _, bit := range bits {
@ -705,20 +795,15 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
}
if super_debug {
fmt.Println("Data Kind: ")
fmt.Println(cur.Kind())
fmt.Println("Data Type: ")
fmt.Println(cur.Type().Name())
fmt.Println("Data Kind:",cur.Kind())
fmt.Println("Data Type:",cur.Type().Name())
}
}
if super_debug {
fmt.Println("Out Value: ")
fmt.Println(out)
fmt.Println("Out Kind: ")
fmt.Println(cur.Kind())
fmt.Println("Out Type: ")
fmt.Println(cur.Type().Name())
fmt.Println("Out Value:",out)
fmt.Println("Out Kind:",cur.Kind())
fmt.Println("Out Type:",cur.Type().Name())
}
for _, varItem := range c.varList {
@ -728,12 +813,9 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
}
if super_debug {
fmt.Println("Out Value: ")
fmt.Println(out)
fmt.Println("Out Kind: ")
fmt.Println(cur.Kind())
fmt.Println("Out Type: ")
fmt.Println(cur.Type().Name())
fmt.Println("Out Value:",out)
fmt.Println("Out Kind:",cur.Kind())
fmt.Println("Out Type:",cur.Type().Name())
}
_, ok := c.stats[out]
@ -747,6 +829,9 @@ func (c *CTemplateSet) compile_if_varsub(varname string, varholder string, templ
}
func (c *CTemplateSet) compile_boolsub(varname string, varholder string, template_name string, val reflect.Value) string {
if super_debug {
fmt.Println("in compile_boolsub")
}
out, val := c.compile_if_varsub(varname, varholder, template_name, val)
switch val.Kind() {
case reflect.Int: out += " > 0"
@ -754,15 +839,18 @@ func (c *CTemplateSet) compile_boolsub(varname string, varholder string, templat
case reflect.String: out += " != \"\""
case reflect.Int64: out += " > 0"
default:
fmt.Println(varname)
fmt.Println(varholder)
fmt.Println(val.Kind())
fmt.Println("Variable Name:",varname)
fmt.Println("Variable Holder:",varholder)
fmt.Println("Variable Kind:",val.Kind())
panic("I don't know what this variable's type is o.o\n")
}
return out
}
func (c *CTemplateSet) compile_varsub(varname string, val reflect.Value) string {
if super_debug {
fmt.Println("in compile_varsub")
}
for _, varItem := range c.varList {
if strings.HasPrefix(varname, varItem.Destination) {
varname = strings.Replace(varname, varItem.Destination, varItem.Name, 1)
@ -794,18 +882,16 @@ func (c *CTemplateSet) compile_varsub(varname string, val reflect.Value) string
case reflect.Int64:
return "w.Write([]byte(strconv.FormatInt(" + varname + ", 10)))"
default:
fmt.Println("Unknown Variable Name: ")
fmt.Println(varname)
fmt.Println("Unknown Kind: ")
fmt.Println(val.Kind())
fmt.Println("Unknown Type: ")
fmt.Println(val.Type().Name())
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")
}
}
func (c *CTemplateSet) compile_subtemplate(pvarholder string, pholdreflect reflect.Value, node *parse.TemplateNode) (out string) {
if super_debug {
fmt.Println("in compile_subtemplate")
fmt.Println("Template Node: " + node.Name)
}
@ -859,7 +945,7 @@ func (c *CTemplateSet) compile_subtemplate(pvarholder string, pholdreflect refle
treeLength := len(subtree.Root.Nodes)
for index, node := range subtree.Root.Nodes {
if super_debug {
fmt.Println("Node: " + node.String())
fmt.Println("Node:",node.String())
}
c.previousNode = c.currentNode

View File

@ -8,11 +8,18 @@
<div class="rowitem rowhead"><a>{{.Title}}</a>
{{if ne .CurrentUser.ID 0}}{{if not .CurrentUser.Perms.CreateTopic}}<span class='username head_tag_upshift' title='No Permissions'>&#x1F512;&#xFE0E</span>{{else}}<a href="/topics/create/{{.Forum.ID}}" class='username head_tag_upshift'>New Topic</a>{{end}}{{end}}</div>
</div>
<div class="rowblock">
{{range .ItemList}}<div class="rowitem passive" style="{{if .Avatar}}background-image: url({{.Avatar}});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{if .Sticky}}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}">
<a href="/topic/{{.ID}}">{{.Title}}</a> {{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" title="Status: Closed" style="float: right;position:relative;top:-5px;margin-left:8px;">&#x1F512;&#xFE0E</span>{{end}}
<a style="float: right;font-size:12px;">{{.LastReplyAt}}</a>
<div id="forum_topic_list" class="rowblock topic_list">
{{range .ItemList}}<div class="rowitem passive datarow" style="{{if .Avatar}}background-image: url({{.Avatar}});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{if .Sticky}}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}">
<span class="rowsmall" style="float: right;">
<span class="replyCount">{{.PostCount}} replies</span><br />
<span class="lastReplyAt">{{.LastReplyAt}}</span>
</span>
<span>
<a class="rowtopic" href="/topic/{{.ID}}">{{.Title}}</a>
<br /><a class="rowsmall" href="/user/{{.CreatedBy}}">Starter: {{.CreatedByName}}</a>
{{if .Is_Closed}}<span class="rowsmall topic_status_e topic_status_closed" title="Status: Closed"> | &#x1F512;&#xFE0E{{end}}</span>
</span>
</div>
{{else}}<div class="rowitem passive">There aren't any topics in this forum yet.{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/{{.Forum.ID}}">Start one?</a>{{end}}</div>{{end}}
</div>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -3,10 +3,22 @@
<div class="rowitem rowhead"><a>Forums</a></div>
</div>
<div class="rowblock">
{{range .ItemList}}<div class="rowitem">
<a href="/forum/{{.ID}}" class="panel_upshift">{{.Name}}</a>
<a href="/topic/{{.LastTopicID}}" style="float: right;">{{.LastTopic}} <small style="font-size: 12px;">{{.LastTopicTime}}</small></a>
{{range .ItemList}}<div class="rowitem {{if (.Desc) or (.LastTopicTime)}}datarow{{end}}">
{{if .Desc}}<span style="float: left;">
<a href="/forum/{{.ID}}" style="">{{.Name}}</a>
<br /><span class="rowsmall">{{.Desc}}</span>
</span>{{else if .LastTopicTime}}<span style="float: left;padding-top: 8px;font-size: 18px;">
<a href="/forum/{{.ID}}">{{.Name}}</a>
</span>{{else}}<span style="float: left;">
<a href="/forum/{{.ID}}">{{.Name}}</a>
</span>{{end}}
<span style="float: right;">
<a href="/topic/{{.LastTopicID}}" style="float: right;font-size: 14px;">{{.LastTopic}}</a>
{{if .LastTopicTime}}<br /><span class="rowsmall">{{.LastTopicTime}}</span>{{end}}
</span>
<div style="clear: both;"></div>
</div>
{{else}}<div class="rowitem passive">You don't have access to any forums.</div>{{end}}
</div>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -15,7 +15,8 @@
<li class="menu_left menu_register"><a href="/accounts/create/">Register</a></li>
<li class="menu_left menu_login"><a href="/accounts/login/">Login</a></li>
{{end}}
<li class="menu_right menu_alerts">🔔︎
<li class="menu_right menu_alerts">
<div class="alert_bell">🔔︎</div>
<div class="alert_counter"></div>
<div class="alertList"></div>
</li>
@ -23,4 +24,4 @@
</div>
</div>
<div style="clear: both;"></div>
</div>
</div>

View File

@ -0,0 +1,67 @@
{{template "header.html" . }}
{{template "panel-menu.html" . }}
<script>
var form_vars = {'perm_preset': ['can_moderate','can_post','read_only','no_access','default','custom']};
</script>
</div>
<div class="colstack_right">
<div class="colstack_item colstack_head">
<div class="rowitem rowhead"><a>{{.Name}} Forum</a></div>
</div>
<div id="panel_forum" class="colstack_item">
<form action="/panel/forums/edit/submit/{{.ID}}?session={{.CurrentUser.Session}}" method="post">
<div class="formrow">
<div class="formitem formlabel"><a>Name</a></div>
<div class="formitem"><input name="forum_name" type="text" value="{{.Name}}" placeholder="General Forum" /></div>
</div>
<div class="formrow">
<div class="formitem formlabel"><a>Description</a></div>
<div class="formitem"><input name="forum_desc" type="text" value="{{.Desc}}" placeholder="Where the general stuff happens" /></div>
</div>
<div class="formrow">
<div class="formitem formlabel"><a>Hidden?</a></div>
<div class="formitem"><select name="forum_active">
<option{{if not .Active}} selected{{end}} value="1">Yes</option>
<option{{if .Active}} selected{{end}} value="0">No</option>
</select></div>
</div>
<div class="formrow">
<div class="formitem formlabel"><a>Preset</a></div>
<div class="formitem">
<select name="forum_preset">
<option{{if eq .Preset "all"}} selected{{end}} value="all">Everyone</option>
<option{{if eq .Preset "announce"}} selected{{end}} value="announce">Announcements</option>
<option{{if eq .Preset "members"}} selected{{end}} value="members">Member Only</option>
<option{{if eq .Preset "staff"}} selected{{end}} value="staff">Staff Only</option>
<option{{if eq .Preset "admins"}} selected{{end}} value="admins">Admin Only</option>
<option{{if eq .Preset "archive"}} selected{{end}} value="archive">Archive</option>
<option{{if eq .Preset "custom"}} selected{{end}} value="custom">Custom</option>
</select>
</div>
</div>
<div class="formrow">
<div class="formitem"><button name="panel-button" class="formbutton">Update Forum</button></div>
</div>
</form>
</div>
<div class="colstack_item colstack_head">
<div class="rowitem rowhead"><a>Forum Permissions</a></div>
</div>
<div id="forum_quick_perms" class="colstack_item">
{{range .Groups}}
<div class="formrow">
<div class="formitem editable_parent">
<a>{{.Group.Name}}</a>
<input name="gid" value="{{.Group.ID}}" type="hidden" class="editable_block" data-field="gid" data-type="hidden" data-value="{{.Group.ID}}" />
<span class="edit_fields hide_on_edit rowsmall">Edit</span>
<div class="panel_floater">
<span data-field="perm_preset" data-type="list" data-value="{{.Preset}}" class="editable_block perm_preset perm_preset_{{.Preset}}"></span>
<a class="panel_right_button" href="/panel/forums/edit/perms/submit/{{$.ID}}"><button class='panel_tag submit_edit show_on_edit' type='submit'>Update</button></a>
</div>
</div>
</div>
{{end}}
</div>
</div>
{{template "footer.html" . }}

View File

@ -12,17 +12,22 @@
<div id="panel_forums" class="colstack_item">
{{range .ItemList}}
<div class="rowitem editable_parent" style="{{if eq .ID 1}}border-bottom-style:solid;{{end}}">
<a data-field="forum_name" data-type="text" class="editable_block panel_upshift" style="{{if not .Active}}color:#707070;{{end}}">{{.Name}}</a>
<span class="panel_floater">
<span data-field="forum_active" data-type="list" class="panel_tag editable_block forum_active {{if .Active}}forum_active_Show" data-value="1{{else}}forum_active_Hide" data-value="0{{end}}" title="Hidden"></span>
<span data-field="forum_preset" data-type="list" data-value="{{.Preset}}" class="panel_tag editable_block forum_preset forum_preset_{{.Preset}}" title="{{.PresetLang}}"></span>
<span class="panel_buttons">
{{if gt .ID 0}}<a class="panel_tag edit_fields hide_on_edit panel_right_button">Edit</a>
<a class="panel_right_button" href="/panel/forums/edit/submit/{{.ID}}"><button class='panel_tag submit_edit show_on_edit' type='submit'>Update</button></a>{{end}}
{{if gt .ID 1}}<a href="/panel/forums/delete/{{.ID}}?session={{$.CurrentUser.Session}}" class="panel_tag panel_right_button">Delete</a>{{end}}
{{if gt .ID 1}}<a href="/panel/forums/delete/{{.ID}}?session={{$.CurrentUser.Session}}" class="panel_tag panel_right_button hide_on_edit">Delete</a>{{end}}
<a href="/panel/forums/edit/{{.ID}}" class="panel_tag panel_right_button show_on_edit">Full Edit</a>
</span>
</span>
<span style="float: left;">
<a data-field="forum_name" data-type="text" class="editable_block forum_name" style="{{if not .Active}}color:#707070;{{end}}">{{.Name}}</a>
</span>
<br /><span data-field="forum_desc" data-type="text" class="editable_block forum_desc rowsmall">{{.Desc}}</span>
<div style="clear: both;"></div>
</div>
{{end}}
</div>
@ -36,11 +41,15 @@
<div class="formitem formlabel"><a>Forum Name</a></div>
<div class="formitem"><input name="forum-name" type="text" placeholder="Super Secret Forum" /></div>
</div>
<div class="formrow">
<div class="formitem formlabel"><a>Description</a></div>
<div class="formitem"><input name="forum-desc" type="text" placeholder="Where all the super secret stuff happens" /></div>
</div>
<div class="formrow">
<div class="formitem formlabel"><a>Hidden?</a></div>
<div class="formitem"><select name="forum-active">
<option value="1">Yes</option>
<option value="0">No</option>
<option value="0">Yes</option>
<option value="1">No</option>
</select></div>
</div>
<div class="formrow">

View File

@ -18,7 +18,7 @@
<form action="/panel/groups/edit/submit/{{.ID}}?session={{.CurrentUser.Session}}" method="post">
<div class="formrow">
<div class="formitem formlabel"><a>Name</a></div>
<div class="formitem"><input name="group-name" type="text" value="{{.Name}}" placeholder="General Forum" /></div>
<div class="formitem"><input name="group-name" type="text" value="{{.Name}}" placeholder="Random Group" /></div>
</div>
{{if .CurrentUser.Perms.EditGroup}}
<div class="formrow">

View File

@ -10,10 +10,11 @@
<div class="rowitem passive">
<a class="profile_menu_item">Add Friend</a>
</div>
<div class="rowitem passive"
{{if (.CurrentUser.Is_Super_Mod) and not (.ProfileOwner.Is_Super_Mod) }}
{{if .ProfileOwner.Is_Banned }}<a href="/users/unban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="username">Unban</a>{{else}}<a href="/users/ban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="username">Ban</a>{{end}}
{{end}}
{{if (.CurrentUser.Is_Super_Mod) and not (.ProfileOwner.Is_Super_Mod) }}<div class="rowitem passive">
{{if .ProfileOwner.Is_Banned }}<a href="/users/unban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="profile_menu_item">Unban</a>
{{else}}<a href="/users/ban/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}" class="profile_menu_item">Ban</a>{{end}}
</div>{{end}}
<div class="rowitem passive">
<a href="/report/submit/{{.ProfileOwner.ID}}?session={{.CurrentUser.Session}}&type=user" class="profile_menu_item report_item">Report</a>
</div>
</div>

View File

@ -2,12 +2,18 @@
<div class="rowblock">
<div class="rowitem rowhead"><a>Topic List</a></div>
</div>
<div class="rowblock">
{{range .ItemList}}<div class="rowitem passive" style="{{if .Avatar}}background-image: url({{.Avatar}});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{if .Sticky}}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}">
<a href="/topic/{{.ID}}">{{.Title}}</a> {{if .ForumName}}<a href="/forum/{{.ParentID}}" style="font-size:12px;">{{.ForumName}}</a> {{end}}
{{if .Is_Closed}}<span class="username topic_status_e topic_status_closed" style="float: right;position:relative;top:-5px;margin-left:8px;" title="Status: Closed">&#x1F512;&#xFE0E</span>{{end}}
<a style="float: right;font-size:12px;">{{.LastReplyAt}}</a>
<div id="topic_list" class="rowblock topic_list">
{{range .ItemList}}<div class="rowitem passive datarow" style="{{if .Avatar}}background-image: url({{.Avatar}});background-position: left;background-repeat: no-repeat;background-size: 64px;padding-left: 72px;{{end}}{{if .Sticky}}background-color: #FFFFCC;{{else if .Is_Closed}}background-color: #eaeaea;{{end}}">
<span class="rowsmall" style="float: right;">
<span class="replyCount">{{.PostCount}} replies</span><br />
<span class="lastReplyAt">{{.LastReplyAt}}</span>
</span>
<span>
<a class="rowtopic" href="/topic/{{.ID}}">{{.Title}}</a> {{if .ForumName}}<a class="rowsmall" href="/forum/{{.ParentID}}">{{.ForumName}}</a>{{end}}
<br /><a class="rowsmall" href="/user/{{.CreatedBy}}">Starter: {{.CreatedByName}}</a>
{{if .Is_Closed}}<span class="rowsmall topic_status_e topic_status_closed" title="Status: Closed"> | &#x1F512;&#xFE0E{{end}}</span>
</span>
</div>
{{else}}<div class="rowitem passive">There aren't any topics yet.{{if .CurrentUser.Perms.CreateTopic}} <a href="/topics/create/">Start one?</a>{{end}}</div>{{end}}
</div>
{{template "footer.html" . }}
{{template "footer.html" . }}

View File

@ -53,12 +53,7 @@ li {
}
li:first-child { border-left: 1px solid #7a7a7a; }
li a {
color: white;
text-decoration: none;
}
li:hover a, li a:hover, li a:link, li a:visited {
li a, li:hover a, li a:hover, li a:link, li a:visited {
color: white;
text-decoration: none;
}
@ -97,9 +92,7 @@ li:hover {
opacity: 0.8;
text-align: center;
}
.menu_alerts .alert_counter:empty {
display: none;
}
.menu_alerts .alert_counter:empty { display: none; }
.selectedAlert {
background: white;
@ -110,12 +103,8 @@ li:hover {
color: black;
font-weight: bold;
}
.selectedAlert .alert_counter {
display: none;
}
.menu_alerts .alertList {
display: none;
}
.selectedAlert .alert_counter { display: none; }
.menu_alerts .alertList { display: none; }
.selectedAlert .alertList {
position: absolute;
top: 41px;
@ -152,9 +141,7 @@ li:hover {
width: 100%;
color: black;
}
.alertItem .text.smaller {
font-size: 9px;
}
.alertItem .text.smaller { font-size: 9px; }
#footer {
clear: left;
@ -198,6 +185,14 @@ hr { color: silver; border: 1px solid silver; }
.rowitem:not(:last-child) { border-bottom: 1px dotted #ccc; }
.rowblock:first-of-type { margin-top: 8px; }
.datarow {
padding-top: 10px;
padding-bottom: 10px;
}
.rowsmall {
font-size:12px;
}
.rowhead, .colhead {
background: #ce2424;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#f97779), to(#ce2424));
@ -265,8 +260,7 @@ hr { color: silver; border: 1px solid silver; }
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;
@ -529,9 +523,7 @@ blockquote p {
padding-bottom: 0;
width: 100%;
}
.user_content.nobuttons {
min-height: 168px;
}
.user_content.nobuttons { min-height: 168px; }
.button_container {
border-top: solid 1px #eaeaea;
@ -560,26 +552,14 @@ blockquote p {
border-left: solid 1px #eaeaea;
}
.like_label:before {
content: "😀";
}
.edit_label:before {
content: "🖊️";
}
.trash_label:before {
content: "🗑️";
}
.flag_label:before {
content: "🚩";
}
.like_label:before { content: "😀"; }
.edit_label:before { content: "🖊️"; }
.trash_label:before { content: "🗑️"; }
.flag_label:before { content: "🚩"; }
.mod_button {
margin-right: 4px;
}
.mod_button { margin-right: 4px; }
.post_item:not(.simple) {
background-color: #eaeaea;
}
.post_item:not(.simple) { background-color: #eaeaea; }
.post_item {
background-color: #eaeaea;
padding-top: 4px;
@ -634,9 +614,7 @@ blockquote p {
box-shadow:0 1px 2px rgba(0,0,0,.1);
}
.action_item .userinfo {
display: none;
}
.action_item .userinfo { display: none; }
.action_item .content_container {
min-height: auto;
padding: 15px;
@ -690,73 +668,40 @@ blockquote p {
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_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";
}
.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;
}
.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 */
@ -840,9 +785,7 @@ blockquote p {
}
.rowblock { border-left: none; border-right: none; border-bottom: none; }
.rowitem { border-left: none; border-right: none; }
.rowhead { border-left: none; border-right: none; }
.tbody { border-left: none; border-right: none; }
.rowitem, .rowhead, .tbody { border-left: none; border-right: none; }
}
@media(max-width: 620px) {
@ -1000,9 +943,7 @@ blockquote p {
border: 1px solid rgba(90,90,90,0.75);
transition: transform 0.7s;
}
ul:hover {
transform: rotateX(-15deg);
}
ul:hover { transform: rotateX(-15deg); }
li {
font-size: 15px;
@ -1055,23 +996,13 @@ blockquote p {
}
@media (min-width: 1603px) {
#back {
width: 1548px;
margin-left: auto;
margin-right: auto;
}
#back { width: 1548px; }
#main { width: 1250px; }
#main:not(.shrink_main) { width: calc(100% - 30px); }
}
@media (min-width: 2400px) {
#back {
width: 2000px;
margin-left: auto;
margin-right: auto;
}
#back { width: 2000px; }
#main { width: 1690px; }
#main:not(.shrink_main) { width: calc(100% - 30px); }
.index_category {
@ -1089,6 +1020,5 @@ blockquote p {
#main:not(.shrink_main) { width: calc(100% - 30px); }
.index_category { width: 1230px; }
.index_category:only-child { width: 100%; }
.right_sidebar { width: 350px; }
}

View File

@ -87,9 +87,7 @@ li:hover {
opacity: 0.8;
text-align: center;
}
.menu_alerts .alert_counter:empty {
display: none;
}
.menu_alerts .alert_counter:empty { display: none; }
.selectedAlert {
background: white;
@ -100,12 +98,8 @@ li:hover {
color: black;
font-weight: bold;
}
.selectedAlert .alert_counter {
display: none;
}
.menu_alerts .alertList {
display: none;
}
.selectedAlert .alert_counter { display: none; }
.menu_alerts .alertList { display: none; }
.selectedAlert .alertList {
position: absolute;
top: 41px;
@ -142,9 +136,7 @@ li:hover {
width: 100%;
color: black;
}
.alertItem .text.smaller {
font-size: 9px;
}
.alertItem .text.smaller { font-size: 9px; }
hr { color: silver; border: 1px solid silver; }
@ -180,6 +172,14 @@ hr { color: silver; border: 1px solid silver; }
.rowblock:first-of-type { margin-top: 8px; }
.rowitem:not(:last-child) { border-bottom: 1px dotted #ccc; }
.datarow {
padding-top: 10px;
padding-bottom: 10px;
}
.rowsmall {
font-size:12px;
}
.rowhead, .colhead {
background: #ce2424;
background: -webkit-gradient(linear, 0 0, 0 bottom, from(#f97779), to(#ce2424));
@ -247,8 +247,7 @@ hr { color: silver; border: 1px solid silver; }
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;
@ -492,7 +491,6 @@ blockquote p {
top: 44px;
}
.gadget { padding-bottom: 20px; }
.cell_author img { margin-right: 8px; }
.cell_last img { margin-right: 8px; }
@ -542,10 +540,7 @@ blockquote p {
border-top-right-radius: 3px;
right: -1px;
}
.tag_block.groupRibbon {
display: none;
}
.tag_block.groupRibbon { display: none; }
/* From Tempra Conflux */
.user_content:not(.simple) {
@ -558,9 +553,7 @@ blockquote p {
width: 100%;
border-radius: 4px;
}
.user_content.nobuttons {
min-height: 190px;
}
.user_content.nobuttons { min-height: 190px; }
.button_container {
border-top: solid 1px #eaeaea;
@ -589,26 +582,14 @@ blockquote p {
border-left: solid 1px #eaeaea;
}
.like_label:before {
content: "😀";
}
.edit_label:before {
content: "🖊️";
}
.trash_label:before {
content: "🗑️";
}
.flag_label:before {
content: "🚩";
}
.like_label:before { content: "😀"; }
.edit_label:before { content: "🖊️"; }
.trash_label:before { content: "🗑️"; }
.flag_label:before { content: "🚩"; }
.mod_button {
margin-right: 4px;
}
.mod_button { margin-right: 4px; }
.post_item:not(.simple) {
background-color: #eaeaea;
}
.post_item:not(.simple) { background-color: #eaeaea; }
.post_item {
padding-top: 4px;
padding-left: 7px !important;
@ -618,9 +599,7 @@ blockquote p {
padding-right: 7px !important;
padding-bottom: 2px;
}
.post_item:last-child {
padding-bottom: 7px;
}
.post_item:last-child { padding-bottom: 7px; }
.the_name {
margin-top: 3px;
text-align: center;
@ -630,7 +609,6 @@ blockquote p {
.userinfo {
border-radius: 5px;
background: white;
width: 132px;
padding: 2px;
@ -661,9 +639,7 @@ blockquote p {
border-radius: 4px;
}
.action_item .userinfo {
display: none;
}
.action_item .userinfo { display: none; }
.action_item .content_container {
min-height: auto;
padding: 15px;
@ -717,73 +693,40 @@ blockquote p {
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_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";
}
.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;
}
.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 */

View File

@ -12,9 +12,7 @@ body {
}
/* Patch for Edge, until they fix emojis in arial x.x */
@supports (-ms-ime-align:auto) {
.user_content { font-family: Segoe UI Emoji, arial; }
}
@supports (-ms-ime-align:auto) { .user_content { font-family: Segoe UI Emoji, arial; } }
ul {
padding-left: 0px;
@ -49,11 +47,15 @@ li a {
padding-right: 10px;
}
.menu_bell {
cursor: default;
}
.menu_alerts {
/*padding-left: 7px;*/
font-size: 20px;
padding-top: 2px;
color: rgb(80,80,80);
z-index: 500;
}
.menu_alerts .alert_counter {
position: relative;
@ -69,9 +71,7 @@ li a {
text-align: center;
border: white solid 1px;
}
.menu_alerts .alert_counter:empty {
display: none;
}
.menu_alerts .alert_counter:empty { display: none; }
.selectedAlert {
background: white;
@ -126,9 +126,7 @@ li a {
white-space: nowrap;
font-weight: normal;
}
.alertItem:not(.withAvatar) {
margin-left: 5px;
}
.alertItem:not(.withAvatar) { margin-left: 5px; }
.container {
width: 90%;
@ -144,6 +142,9 @@ li a {
padding-top: 0px;
}
.rowblock:empty { display: none; }
.rowsmall {
font-size:12px;
}
.colblock_left {
border: 1px solid #ccc;
@ -184,8 +185,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;
@ -241,6 +241,10 @@ li a {
}
.rowitem a:hover { color: silver; }
.opthead { display: none; }
.datarow {
padding-top: 10px;
padding-bottom: 10px;
}
.formrow {
width: 100%;
@ -310,9 +314,7 @@ button {
}
.topic_status:empty { display: none; }
.rowhead {
background: linear-gradient(to bottom, white, hsl(0, 0%, 93%));
}
.rowhead { background: linear-gradient(to bottom, white, hsl(0, 0%, 93%)); }
.topic_sticky_head {
background-color: #FFFFEA;
background: linear-gradient(to bottom, hsl(60, 70%, 96%), hsl(60, 70%, 89%)), url('/static/fabric-base-simple-alpha.png');
@ -395,9 +397,7 @@ button.username {
padding-bottom: 0;
width: 100%;
}
.user_content.nobuttons {
min-height: 168px;
}
.user_content.nobuttons { min-height: 168px; }
.button_container {
border-top: solid 1px #eaeaea;
@ -426,29 +426,17 @@ button.username {
border-left: solid 1px #eaeaea;
}
.like_label:before {
content: "😀";
}
.edit_label:before {
content: "🖊️";
}
.trash_label:before {
content: "🗑️";
}
.flag_label:before {
content: "🚩";
}
.like_label:before { content: "😀"; }
.edit_label:before { content: "🖊️"; }
.trash_label:before { content: "🗑️"; }
.flag_label:before { content: "🚩"; }
.mod_button {
margin-right: 4px;
}
.mod_button { margin-right: 4px; }
.simple > .real_username { color: #404040; font-size: 17px; }
.simple > .user_content { background: none; }
.simple { background-color: white; }
.post_item:not(.simple) {
background-color: #eaeaea;
}
.post_item:not(.simple) { background-color: #eaeaea; }
.post_item {
padding-top: 4px;
padding-left: 5px;
@ -457,9 +445,7 @@ button.username {
padding-right: 4px;
padding-bottom: 2px;
}
.post_item:last-child {
padding-bottom: 7px;
}
.post_item:last-child { padding-bottom: 7px; }
.post_tag {
margin-top: 0px;
text-align: center;
@ -504,9 +490,7 @@ button.username {
box-shadow:0 1px 2px rgba(0,0,0,.1);
}
.action_item .userinfo {
display: none;
}
.action_item .userinfo { display: none; }
.action_item .content_container {
min-height: auto;
padding: 15px;
@ -544,9 +528,7 @@ button.username {
}
/* Control Panel */
.panel_upshift:visited {
color: black;
}
.panel_upshift:visited { color: black; }
.tag-mini {
margin-left: 0px;
@ -568,82 +550,48 @@ button.username {
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_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";
}
.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;
}
.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; }
.theme_row > .panel_floater > .panel_right_button {
margin-left: 5px;
}
.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;
}
.theme_row { background-image: none !important; }
}
/* The Media Queries */
@ -717,18 +665,14 @@ button.username {
padding-left: 42px;
height: 46px;
}
.alertItem {
padding: 8px;
}
.alertItem { padding: 8px; }
.alertItem .text {
height: 30px;
font-size: 10px;
font-weight: bold;
white-space: normal;
}
.alertItem .text.smaller {
font-size: 9px;
}
.alertItem .text.smaller { font-size: 9px; }
.post_container { overflow: visible !important; }
.post_item {
@ -772,6 +716,7 @@ button.username {
.user_content.nobuttons { min-height: 100.5px !important; }
.the_name { font-size: 15px; }
.post_tag { font-size: 12px; }
.rowtopic { font-size: 14px; }
.container { width: 100% !important; }
}

View File

@ -49,11 +49,15 @@ li a {
padding-right: 10px;
}
.menu_bell {
cursor: default;
}
.menu_alerts {
/*padding-left: 7px;*/
font-size: 20px;
padding-top: 2px;
color: rgb(80,80,80);
z-index: 500;
}
.menu_alerts .alert_counter {
position: relative;
@ -138,6 +142,7 @@ li a {
padding-top: 0px;
}
.rowblock:empty { display: none; }
.rowsmall { font-size:12px; }
.colblock_left {
border: 1px solid #ccc;
@ -235,6 +240,11 @@ li a {
.top_post { margin-bottom: 16px; }
.opthead { display: none; }
.datarow {
padding-top: 10px;
padding-bottom: 10px;
}
.formrow {
width: 100%;
background-color: white;
@ -501,21 +511,11 @@ button.username {
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_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;
@ -526,52 +526,30 @@ button.username {
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";
}
.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"; }
.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;
}
@media(max-width: 1300px) {
.theme_row {
background-image: none !important;

View File

@ -10,9 +10,7 @@ body {
}
/* Patch for Edge, until they fix emojis in arial x.x */
@supports (-ms-ime-align:auto) {
.user_content { font-family: Segoe UI Emoji, arial; }
}
@supports (-ms-ime-align:auto) { .user_content { font-family: Segoe UI Emoji, arial; } }
ul {
padding-left: 0px;
@ -47,6 +45,7 @@ li a {
padding-right: 10px;
}
.menu_bell { cursor: default; }
.menu_alerts {
/*padding-left: 7px;*/
font-size: 20px;
@ -67,9 +66,7 @@ li a {
text-align: center;
border: white solid 1px;
}
.menu_alerts .alert_counter:empty {
display: none;
}
.menu_alerts .alert_counter:empty { display: none; }
.selectedAlert {
background: white;
@ -79,9 +76,12 @@ li a {
background: white;
color: black;
}
.selectedAlert .alert_counter { display: none; }
.menu_alerts .alertList {
display: none;
z-index: 500;
}
.selectedAlert .alertList {
position: absolute;
top: 51px;
@ -142,6 +142,9 @@ li a {
padding-top: 0px;
}
.rowblock:empty { display: none; }
.rowsmall {
font-size:12px;
}
.colblock_left {
border: 1px solid #ccc;
@ -182,8 +185,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;
@ -229,15 +231,10 @@ li a {
padding-top: 14px;
padding-bottom: 12px;
padding-right: 10px;
/*font-weight: bold;*/
background-color: white;
}
/*.rowitem:not(.passive) {
font-size: 17px;
}*/
.rowitem:not(:last-child) {
border-bottom: 1px dotted #ccc;
}
/*.rowitem:not(.passive) { font-size: 17px; }*/
.rowitem:not(:last-child) { border-bottom: 1px dotted #ccc; }
.rowitem a {
text-decoration: none;
color: black;
@ -246,6 +243,11 @@ li a {
.top_post { margin-bottom: 12px; }
.opthead { display: none; }
.datarow {
padding-top: 10px;
padding-bottom: 10px;
}
.formrow {
width: 100%;
background-color: white;
@ -332,11 +334,7 @@ button.username { position: relative; top: -0.25px; }
.username.level { color: #303030; }
.username.real_username { color: #404040; font-size: 17px; }
.username.real_username:hover { color: black; }
.post_item > .username {
margin-top: 20px;
display: inline-block;
}
.post_item > .username { margin-top: 20px; display: inline-block; }
.tag-mini {
text-transform: none;
@ -358,17 +356,13 @@ button.username { position: relative; top: -0.25px; }
color: #202020;
opacity: 0.7;
}
.post_item > .mod_button > button:hover {
opacity: 0.9;
}
.post_item > .mod_button > button:hover { opacity: 0.9; }
.mod_button {
margin-right: 4px;
/*z-index: 10;*/
}
.like_label:before, .like_count_label:before {
content: "😀";
}
.like_label:before, .like_count_label:before { content: "😀"; }
.like_count_label {
color: #505050;
float: right;
@ -383,27 +377,14 @@ button.username { position: relative; top: -0.25px; }
padding-right: 5px;
font-size: 17px;
}
.edit_label:before {
content: "🖊️";
}
.trash_label:before {
content: "🗑️";
}
.pin_label:before {
content: "📌";
}
.unpin_label:before {
content: "📌";
}
.unpin_label {
background-color: #D6FFD6;
}
.flag_label:before {
content: "🚩";
}
.level_label:before {
content: "👑";
}
.edit_label:before { content: "🖊️"; }
.trash_label:before { content: "🗑️"; }
.pin_label:before { content: "📌"; }
.unpin_label:before { content: "📌"; }
.unpin_label { background-color: #D6FFD6; }
.flag_label:before { content: "🚩"; }
.level_label:before { content: "👑"; }
.controls {
margin-top: 23px;
@ -496,9 +477,7 @@ button.username { position: relative; top: -0.25px; }
position: relative;
top: -2px;
}
.panel_upshift:visited {
color: black;
}
.panel_upshift:visited { color: black; }
/*.panel_tag_upshift {
margin-left: 2px;
position: relative;
@ -506,49 +485,28 @@ button.username { position: relative; top: -0.25px; }
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: "👪";
}
.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;
}
.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 {
@ -562,8 +520,7 @@ button.username { position: relative; top: -0.25px; }
height: 30px;
margin-top: 8px;
}
.menu_left { padding-right: 9px; }
.menu_right { padding-right: 9px; }
.menu_left, .menu_right { padding-right: 9px; }
.menu_alerts {
padding-left: 7px;
padding-right: 7px;
@ -591,9 +548,8 @@ button.username { position: relative; top: -0.25px; }
}
li a { font-size: 14px; }
ul { height: 26px; }
.menu_left { padding-right: 7px; }
.menu_right { padding-right: 7px; }
.menu_create_topic { display: none;}
.menu_left, .menu_right { padding-right: 7px; }
.menu_create_topic { display: none; }
.menu_alerts {
padding-left: 4px;
@ -615,25 +571,34 @@ button.username { position: relative; top: -0.25px; }
width: 135px;
margin-bottom: 5px;
}
.selectedAlert.hasAvatars .alertList { width: calc(100% - 8px); }
.alertItem.withAvatar {
background-size: 36px;
text-align: right;
padding-left: 10px;
height: 46px;
}
.alertItem {
padding: 8px;
.hasAvatars > .alertList > .alertItem.withAvatar {
background-size: 46px;
text-align: inherit;
padding-left: 56px;
height: 42px;
}
.alertItem.withAvatar .text {
.alertItem { padding: 8px; }
.hasAvatars > .alertList > .alertItem { padding-top: 11px; }
.selectedAlert:not(.hasAvatars) > .alertList > .alertItem.withAvatar .text {
width: calc(100% - 20px);
height: 30px;
white-space: normal;
}
.alertItem .text {
.selectedAlert:not(.hasAvatars) > .alertList > .alertItem .text {
font-size: 10px;
font-weight: bold;
margin-left: 0px;
}
.alertActive {
opacity: 0.7;
}
.hide_on_micro { display: none !important; }
.post_container { overflow: visible !important; }
@ -672,6 +637,9 @@ button.username { position: relative; top: -0.25px; }
margin-left: 74px;
width: calc(100% - 74px);
}
.rowtopic {
font-size: 14px;
}
.container { width: 100% !important; }
}
@ -685,13 +653,7 @@ button.username { position: relative; top: -0.25px; }
text-overflow: clip;
max-width: 84px;
}
.post_item > .controls {
margin-left: 72px;
}
.top_post > .post_item > .controls > .real_username {
max-width: 57px;
}
.top_post > .post_item {
padding-right: 4px;
}
.post_item > .controls { margin-left: 72px; }
.top_post > .post_item > .controls > .real_username { max-width: 57px; }
.top_post > .post_item { padding-right: 4px; }
}

View File

@ -15,11 +15,13 @@ type Topic struct
Sticky bool
CreatedAt string
LastReplyAt string
//LastReplyBy int
ParentID int
Status string // Deprecated. Marked for removal.
IpAddress string
PostCount int
LikeCount int
ClassName string // CSS Class Name
}
type TopicUser struct
@ -32,12 +34,14 @@ type TopicUser struct
Sticky bool
CreatedAt string
LastReplyAt string
//LastReplyBy int
ParentID int
Status string // Deprecated. Marked for removal.
IpAddress string
PostCount int
LikeCount int
ClassName string
CreatedByName string
Group int
Avatar string
@ -61,12 +65,14 @@ type TopicsRow struct
Sticky bool
CreatedAt string
LastReplyAt string
//LastReplyBy int
ParentID int
Status string // Deprecated. Marked for removal.
IpAddress string
PostCount int
LikeCount int
ClassName string
CreatedByName string
Avatar string
Css template.CSS
@ -76,7 +82,7 @@ type TopicsRow struct
URLPrefix string
URLName string
Level int
ForumName string //TopicsRow
}
@ -131,7 +137,7 @@ func (sts *StaticTopicStore) CascadeGet(id int) (*Topic, error) {
if ok {
return topic, nil
}
topic = &Topic{ID:id}
err := get_topic_stmt.QueryRow(id).Scan(&topic.Title, &topic.Content, &topic.CreatedBy, &topic.CreatedAt, &topic.Is_Closed, &topic.Sticky, &topic.ParentID, &topic.IpAddress, &topic.PostCount, &topic.LikeCount)
if err == nil {
@ -292,7 +298,7 @@ func get_topicuser(tid int) (TopicUser,error) {
return TopicUser{ID:tid}, err
}
init_user_perms(user)
// We might be better off just passing seperate topic and user structs to the caller?
return copy_topic_to_topicuser(topic, user), nil
} else if users.GetLength() < users.GetCapacity() {
@ -309,10 +315,10 @@ func get_topicuser(tid int) (TopicUser,error) {
return tu, nil
}
}
tu := TopicUser{ID:tid}
err := get_topic_user_stmt.QueryRow(tid).Scan(&tu.Title, &tu.Content, &tu.CreatedBy, &tu.CreatedAt, &tu.Is_Closed, &tu.Sticky, &tu.ParentID, &tu.IpAddress, &tu.PostCount, &tu.LikeCount, &tu.CreatedByName, &tu.Avatar, &tu.Group, &tu.URLPrefix, &tu.URLName, &tu.Level)
the_topic := Topic{ID:tu.ID, Title:tu.Title, Content:tu.Content, CreatedBy:tu.CreatedBy, Is_Closed:tu.Is_Closed, Sticky:tu.Sticky, CreatedAt:tu.CreatedAt, LastReplyAt:tu.LastReplyAt, ParentID:tu.ParentID, IpAddress:tu.IpAddress, PostCount:tu.PostCount, LikeCount:tu.LikeCount}
//fmt.Printf("%+v\n", the_topic)
tu.Tag = groups[tu.Group].Tag
@ -328,7 +334,7 @@ func copy_topic_to_topicuser(topic *Topic, user *User) (tu TopicUser) {
tu.URLPrefix = user.URLPrefix
tu.URLName = user.URLName
tu.Level = user.Level
tu.ID = topic.ID
tu.Title = topic.Title
tu.Content = topic.Content

20
user.go
View File

@ -1,14 +1,16 @@
package main
//import "fmt"
import "sync"
import "strings"
import "strconv"
import "net"
import "net/http"
import "golang.org/x/crypto/bcrypt"
import "database/sql"
import _ "github.com/go-sql-driver/mysql"
import (
//"fmt"
"sync"
"strings"
"strconv"
"net"
"net/http"
"golang.org/x/crypto/bcrypt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
var guest_user User = User{ID:0,Group:6,Perms:GuestPerms}

View File

@ -48,11 +48,11 @@ func relative_time(in string) (string, error) {
return "", nil
}
layout := "2006-01-02 15:04:05"
t, err := time.Parse(layout, in)
t, err := time.ParseInLocation(layout, in, timeLocation)
if err != nil {
return "", err
}
diff := time.Since(t)
hours := diff.Hours()
seconds := diff.Seconds()
@ -95,7 +95,7 @@ func convert_byte_in_unit(bytes float64,unit string) (count float64) {
case "KB": count = bytes / float64(kilobyte)
default: count = 0.1
}
if count < 0.1 {
count = 0.1
}
@ -128,12 +128,12 @@ func SendEmail(email string, subject string, msg string) (res bool) {
return vhooks["email_send_intercept"](email, subject, msg).(bool)
}
body := "Subject: " + subject + "\n\n" + msg + "\n"
con, err := smtp.Dial(smtp_server + ":" + smtp_port)
if err != nil {
return
}
if smtp_username != "" {
auth := smtp.PlainAuth("",smtp_username,smtp_password,smtp_server)
err = con.Auth(auth)
@ -141,7 +141,7 @@ func SendEmail(email string, subject string, msg string) (res bool) {
return
}
}
err = con.Mail(site_email)
if err != nil {
return
@ -150,7 +150,7 @@ func SendEmail(email string, subject string, msg string) (res bool) {
if err != nil {
return
}
email_data, err := con.Data()
if err != nil {
return
@ -159,7 +159,7 @@ func SendEmail(email string, subject string, msg string) (res bool) {
if err != nil {
return
}
err = email_data.Close()
if err != nil {
return
@ -208,7 +208,7 @@ func getLevel(score int) (level int) {
var base float64 = 25
var current, prev float64
exp_factor := 2.8
for i := 1;;i++ {
_, bit := math.Modf(float64(i) / 10)
if bit == 0 {
@ -229,7 +229,7 @@ func getLevelScore(getLevel int) (score int) {
var current, prev float64
var level int
exp_factor := 2.8
for i := 1;;i++ {
_, bit := math.Modf(float64(i) / 10)
if bit == 0 {
@ -251,7 +251,7 @@ func getLevels(maxLevel int) []float64 {
exp_factor := 2.8
var out []float64
out = append(out, 0)
for i := 1;i <= maxLevel;i++ {
_, bit := math.Modf(float64(i) / 10)
if bit == 0 {