diff --git a/cmd/elasticsearch/setup.go b/cmd/elasticsearch/setup.go index b0930f57..e02c8c0d 100644 --- a/cmd/elasticsearch/setup.go +++ b/cmd/elasticsearch/setup.go @@ -2,17 +2,17 @@ package main import ( - "context" - "database/sql" - "encoding/json" - "errors" - "log" - "os" - "strconv" + "context" + "database/sql" + "encoding/json" + "errors" + "log" + "os" + "strconv" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/query_gen" - "gopkg.in/olivere/elastic.v6" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + "gopkg.in/olivere/elastic.v6" ) func main() { diff --git a/cmd/hook_gen/main.go b/cmd/hook_gen/main.go index 423a62ac..705511d4 100644 --- a/cmd/hook_gen/main.go +++ b/cmd/hook_gen/main.go @@ -1,16 +1,17 @@ +//go:build hookgen // +build hookgen -package main // import "github.com/Azareal/Gosora/hook_gen" +package main // import "git.tuxpa.in/a/gosora/hook_gen" import ( - "fmt" - "log" - "runtime/debug" - "strings" + "fmt" + "log" + "runtime/debug" + "strings" - h "github.com/Azareal/Gosora/cmd/common_hook_gen" - c "github.com/Azareal/Gosora/common" - _ "github.com/Azareal/Gosora/extend" + h "git.tuxpa.in/a/gosora/cmd/common_hook_gen" + c "git.tuxpa.in/a/gosora/common" + _ "git.tuxpa.in/a/gosora/extend" ) // TODO: Make sure all the errors in this file propagate upwards properly diff --git a/cmd/hook_stub_gen/main.go b/cmd/hook_stub_gen/main.go index b9a31fd6..d33b9f79 100644 --- a/cmd/hook_stub_gen/main.go +++ b/cmd/hook_stub_gen/main.go @@ -1,12 +1,12 @@ -package main // import "github.com/Azareal/Gosora/hook_stub_gen" +package main // import "git.tuxpa.in/a/gosora/hook_stub_gen" import ( - "fmt" - "log" - "strings" - "runtime/debug" - - h "github.com/Azareal/Gosora/cmd/common_hook_gen" + "fmt" + "log" + "runtime/debug" + "strings" + + h "git.tuxpa.in/a/gosora/cmd/common_hook_gen" ) // TODO: Make sure all the errors in this file propagate upwards properly diff --git a/cmd/install/install.go b/cmd/install/install.go index 4569df1a..63d1a83f 100644 --- a/cmd/install/install.go +++ b/cmd/install/install.go @@ -7,15 +7,15 @@ package main import ( - "bufio" - "errors" - "fmt" - "os" - "runtime/debug" - "strconv" - "strings" + "bufio" + "errors" + "fmt" + "os" + "runtime/debug" + "strconv" + "strings" - "github.com/Azareal/Gosora/install" + "git.tuxpa.in/a/gosora/install" ) var scanner *bufio.Scanner diff --git a/cmd/query_gen/main.go b/cmd/query_gen/main.go index a7080517..d9086c39 100644 --- a/cmd/query_gen/main.go +++ b/cmd/query_gen/main.go @@ -1,17 +1,17 @@ /* WIP Under Construction */ -package main // import "github.com/Azareal/Gosora/query_gen" +package main // import "git.tuxpa.in/a/gosora/query_gen" import ( - "encoding/json" - "fmt" - "log" - "os" - "runtime/debug" - "strconv" - "strings" + "encoding/json" + "fmt" + "log" + "os" + "runtime/debug" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Make sure all the errors in this file propagate upwards properly diff --git a/cmd/query_gen/spitter.go b/cmd/query_gen/spitter.go index a2f68b9b..ff12516a 100644 --- a/cmd/query_gen/spitter.go +++ b/cmd/query_gen/spitter.go @@ -1,7 +1,10 @@ package main -import "strings" -import "github.com/Azareal/Gosora/query_gen" +import ( + "strings" + + qgen "git.tuxpa.in/a/gosora/query_gen" +) type PrimaryKeySpitter struct { keys map[string]string diff --git a/cmd/query_gen/tables.go b/cmd/query_gen/tables.go index 4b9ecd25..914328e9 100644 --- a/cmd/query_gen/tables.go +++ b/cmd/query_gen/tables.go @@ -1,6 +1,6 @@ package main -import qgen "github.com/Azareal/Gosora/query_gen" +import qgen "git.tuxpa.in/a/gosora/query_gen" var mysqlPre = "utf8mb4" var mysqlCol = "utf8mb4_general_ci" @@ -12,820 +12,820 @@ type tC = tblColumn type tblKey = qgen.DBTableKey func createTables(a qgen.Adapter) error { - tables = nil - f := func(table, charset, collation string, cols []tC, keys []tblKey) error { - tables = append(tables, table) - return qgen.Install.CreateTable(table, charset, collation, cols, keys) - } - return createTables2(a, f) + tables = nil + f := func(table, charset, collation string, cols []tC, keys []tblKey) error { + tables = append(tables, table) + return qgen.Install.CreateTable(table, charset, collation, cols, keys) + } + return createTables2(a, f) } func createTables2(a qgen.Adapter, f func(table, charset, collation string, columns []tC, keys []tblKey) error) (err error) { - createTable := func(table, charset, collation string, cols []tC, keys []tblKey) { - if err != nil { - return - } - err = f(table, charset, collation, cols, keys) - } - bcol := func(col string, val bool) qgen.DBTableColumn { - if val { - return tC{col, "boolean", 0, false, false, "1"} - } - return tC{col, "boolean", 0, false, false, "0"} - } - ccol := func(col string, size int, sdefault string) qgen.DBTableColumn { - return tC{col, "varchar", size, false, false, sdefault} - } - text := func(params ...string) qgen.DBTableColumn { - if len(params) == 0 { - return tC{"", "text", 0, false, false, ""} - } - col, sdefault := params[0], "" - if len(params) > 1 { - sdefault = params[1] - if sdefault == "" { - sdefault = "''" - } - } - return tC{col, "text", 0, false, false, sdefault} - } - createdAt := func(coll ...string) qgen.DBTableColumn { - var col string - if len(coll) > 0 { - col = coll[0] - } - if col == "" { - col = "createdAt" - } - return tC{col, "createdAt", 0, false, false, ""} - } - - createTable("users", mysqlPre, mysqlCol, - []tC{ - {"uid", "int", 0, false, true, ""}, - ccol("name", 100, ""), - ccol("password", 100, ""), - - ccol("salt", 80, "''"), - {"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key - bcol("active", false), - bcol("is_super_admin", false), - createdAt(), - {"lastActiveAt", "datetime", 0, false, false, ""}, - ccol("session", 200, "''"), - //ccol("authToken", 200, "''"), - ccol("last_ip", 200, "''"), - {"profile_comments", "int", 0, false, false, "0"}, - {"who_can_convo", "int", 0, false, false, "0"}, - {"enable_embeds", "int", 0, false, false, "-1"}, - ccol("email", 200, "''"), - ccol("avatar", 100, "''"), - text("message"), - - // TODO: Drop these columns? - ccol("url_prefix", 20, "''"), - ccol("url_name", 100, "''"), - //text("pub_key"), - - {"level", "smallint", 0, false, false, "0"}, - {"score", "int", 0, false, false, "0"}, - {"posts", "int", 0, false, false, "0"}, - {"bigposts", "int", 0, false, false, "0"}, - {"megaposts", "int", 0, false, false, "0"}, - {"topics", "int", 0, false, false, "0"}, - {"liked", "int", 0, false, false, "0"}, - - // These two are to bound liked queries with little bits of information we know about the user to reduce the server load - {"oldestItemLikedCreatedAt", "datetime", 0, false, false, ""}, // For internal use only, semantics may change - {"lastLiked", "datetime", 0, false, false, ""}, // For internal use only, semantics may change - - //{"penalty_count","int",0,false,false,"0"}, - {"temp_group", "int", 0, false, false, "0"}, // For temporary groups, set this to zero when a temporary group isn't in effect - }, - []tK{ - {"uid", "primary", "", false}, - {"name", "unique", "", false}, - }, - ) - - createTable("users_groups", mysqlPre, mysqlCol, - []tC{ - {"gid", "int", 0, false, true, ""}, - ccol("name", 100, ""), - text("permissions"), - text("plugin_perms"), - bcol("is_mod", false), - bcol("is_admin", false), - bcol("is_banned", false), - {"user_count", "int", 0, false, false, "0"}, // TODO: Implement this - - ccol("tag", 50, "''"), - }, - []tK{ - {"gid", "primary", "", false}, - }, - ) - - createTable("users_groups_promotions", mysqlPre, mysqlCol, - []tC{ - {"pid", "int", 0, false, true, ""}, - {"from_gid", "int", 0, false, false, ""}, - {"to_gid", "int", 0, false, false, ""}, - bcol("two_way", false), // If a user no longer meets the requirements for this promotion then they will be demoted if this flag is set - - // Requirements - {"level", "int", 0, false, false, ""}, - {"posts", "int", 0, false, false, "0"}, - {"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted - {"registeredFor", "int", 0, false, false, "0"}, // minutes - }, - []tK{ - {"pid", "primary", "", false}, - }, - ) - - /* - createTable("users_groups_promotions_scheduled","","", - []tC{ - {"prid","int",0,false,false,""}, - {"uid","int",0,false,false,""}, - {"runAt","datetime",0,false,false,""}, - }, - []tK{ - // TODO: Test to see that the compound primary key works - {"prid,uid", "primary", "", false}, - }, - ) - */ - - createTable("users_2fa_keys", mysqlPre, mysqlCol, - []tC{ - {"uid", "int", 0, false, false, ""}, - ccol("secret", 100, ""), - ccol("scratch1", 50, ""), - ccol("scratch2", 50, ""), - ccol("scratch3", 50, ""), - ccol("scratch4", 50, ""), - ccol("scratch5", 50, ""), - ccol("scratch6", 50, ""), - ccol("scratch7", 50, ""), - ccol("scratch8", 50, ""), - {"createdAt", "createdAt", 0, false, false, ""}, - }, - []tK{ - {"uid", "primary", "", false}, - }, - ) - - // What should we do about global penalties? Put them on the users table for speed? Or keep them here? - // Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans? - // TODO: Perm overrides - // TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag - // TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups - // TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly. - /*createTable("users_penalties","","", - []tC{ - {"uid","int",0,false,false,""}, - {"element_id","int",0,false,false,""}, - ccol("element_type",50,""), //forum, profile?, and social_group. Leave blank for global. - text("overrides","{}"), - - bcol("mod_queue",false), - bcol("shadow_ban",false), - bcol("no_avatar",false), // Coming Soon. Should this be a perm override instead? - - // Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something? - //{"posts_per_hour","int",0,false,false,"0"}, - //{"topics_per_hour","int",0,false,false,"0"}, - //{"posts_count","int",0,false,false,"0"}, - //{"topic_count","int",0,false,false,"0"}, - //{"last_hour","int",0,false,false,"0"}, // UNIX Time, as we don't need to do anything too fancy here. When an hour has elapsed since that time, reset the hourly penalty counters. - - {"issued_by","int",0,false,false,""}, - createdAt("issued_at"), - {"expires_at","datetime",0,false,false,""}, - }, nil, - )*/ - - createTable("users_groups_scheduler", "", "", - []tC{ - {"uid", "int", 0, false, false, ""}, - {"set_group", "int", 0, false, false, ""}, - - {"issued_by", "int", 0, false, false, ""}, - createdAt("issued_at"), - {"revert_at", "datetime", 0, false, false, ""}, - {"temporary", "boolean", 0, false, false, ""}, // special case for permanent bans to do the necessary bookkeeping, might be removed in the future - }, - []tK{ - {"uid", "primary", "", false}, - }, - ) - - // TODO: Can we use a piece of software dedicated to persistent queues for this rather than relying on the database for it? - createTable("users_avatar_queue", "", "", - []tC{ - {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - }, - []tK{ - {"uid", "primary", "", false}, - }, - ) - - // TODO: Should we add a users prefix to this table to fit the "unofficial convention"? - // TODO: Add an autoincrement key? - createTable("emails", "", "", - []tC{ - ccol("email", 200, ""), - {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - bcol("validated", false), - ccol("token", 200, "''"), - }, nil, - ) - - // TODO: Allow for patterns in domains, if the bots try to shake things up there? - /* - createTable("email_domain_blacklist", "", "", - []tC{ - ccol("domain", 200, ""), - bcol("gtld", false), - }, - []tK{ - {"domain", "primary"}, - }, - ) - */ - - // TODO: Implement password resets - createTable("password_resets", "", "", - []tC{ - ccol("email", 200, ""), - {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token - ccol("token", 200, ""), - createdAt(), - }, nil, - ) - - createTable("forums", mysqlPre, mysqlCol, - []tC{ - {"fid", "int", 0, false, true, ""}, - ccol("name", 100, ""), - ccol("desc", 200, ""), - ccol("tmpl", 200, "''"), - bcol("active", true), - {"order", "int", 0, false, false, "0"}, - {"topicCount", "int", 0, false, false, "0"}, - ccol("preset", 100, "''"), - {"parentID", "int", 0, false, false, "0"}, - ccol("parentType", 50, "''"), - {"lastTopicID", "int", 0, false, false, "0"}, - {"lastReplyerID", "int", 0, false, false, "0"}, - }, - []tK{ - {"fid", "primary", "", false}, - }, - ) - - createTable("forums_permissions", "", "", - []tC{ - {"fid", "int", 0, false, false, ""}, - {"gid", "int", 0, false, false, ""}, - ccol("preset", 100, "''"), - text("permissions", "{}"), - }, - []tK{ - // TODO: Test to see that the compound primary key works - {"fid,gid", "primary", "", false}, - }, - ) - - createTable("topics", mysqlPre, mysqlCol, - []tC{ - {"tid", "int", 0, false, true, ""}, - ccol("title", 100, ""), // TODO: Increase the max length to 200? - text("content"), - text("parsed_content"), - createdAt(), - {"lastReplyAt", "datetime", 0, false, false, ""}, - {"lastReplyBy", "int", 0, false, false, ""}, - {"lastReplyID", "int", 0, false, false, "0"}, - {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - bcol("is_closed", false), - bcol("sticky", false), - // TODO: Add an index for this - {"parentID", "int", 0, false, false, "2"}, - ccol("ip", 200, "''"), - {"postCount", "int", 0, false, false, "1"}, - {"likeCount", "int", 0, false, false, "0"}, - {"attachCount", "int", 0, false, false, "0"}, - {"words", "int", 0, false, false, "0"}, - {"views", "int", 0, false, false, "0"}, - //{"dayViews", "int", 0, false, false, "0"}, - {"weekEvenViews", "int", 0, false, false, "0"}, - {"weekOddViews", "int", 0, false, false, "0"}, - ///{"weekViews", "int", 0, false, false, "0"}, - ///{"lastWeekViews", "int", 0, false, false, "0"}, - //{"monthViews", "int", 0, false, false, "0"}, - // ? - A little hacky, maybe we could do something less likely to bite us with huge numbers of topics? - // TODO: Add an index for this? - //{"lastMonth", "datetime", 0, false, false, ""}, - ccol("css_class", 100, "''"), - {"poll", "int", 0, false, false, "0"}, - ccol("data", 200, "''"), - }, - []tK{ - {"tid", "primary", "", false}, - {"title", "fulltext", "", false}, - {"content", "fulltext", "", false}, - }, - ) - - createTable("replies", mysqlPre, mysqlCol, - []tC{ - {"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID? - {"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID? - text("content"), - text("parsed_content"), - createdAt(), - {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"lastEdit", "int", 0, false, false, "0"}, - {"lastEditBy", "int", 0, false, false, "0"}, - {"lastUpdated", "datetime", 0, false, false, ""}, - ccol("ip", 200, "''"), - {"likeCount", "int", 0, false, false, "0"}, - {"attachCount", "int", 0, false, false, "0"}, - {"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why? - ccol("actionType", 20, "''"), - {"poll", "int", 0, false, false, "0"}, - }, - []tK{ - {"rid", "primary", "", false}, - {"content", "fulltext", "", false}, - }, - ) - - createTable("attachments", mysqlPre, mysqlCol, - []tC{ - {"attachID", "int", 0, false, true, ""}, - {"sectionID", "int", 0, false, false, "0"}, - ccol("sectionTable", 200, "forums"), - {"originID", "int", 0, false, false, ""}, - ccol("originTable", 200, "replies"), - {"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key - ccol("path", 200, ""), - ccol("extra", 200, ""), - }, - []tK{ - {"attachID", "primary", "", false}, - }, - ) - - createTable("revisions", mysqlPre, mysqlCol, - []tC{ - {"reviseID", "int", 0, false, true, ""}, - text("content"), - {"contentID", "int", 0, false, false, ""}, - ccol("contentType", 100, "replies"), - createdAt(), - // TODO: Add a createdBy column? - }, - []tK{ - {"reviseID", "primary", "", false}, - }, - ) - - createTable("polls", mysqlPre, mysqlCol, - []tC{ - {"pollID", "int", 0, false, true, ""}, - {"parentID", "int", 0, false, false, "0"}, - ccol("parentTable", 100, "topics"), // topics, replies - {"type", "int", 0, false, false, "0"}, - {"options", "json", 0, false, false, ""}, - {"votes", "int", 0, false, false, "0"}, - }, - []tK{ - {"pollID", "primary", "", false}, - }, - ) - - createTable("polls_options", "", "", - []tC{ - {"pollID", "int", 0, false, false, ""}, - {"option", "int", 0, false, false, "0"}, - {"votes", "int", 0, false, false, "0"}, - }, nil, - ) - - createTable("polls_votes", mysqlPre, mysqlCol, - []tC{ - {"pollID", "int", 0, false, false, ""}, - {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"option", "int", 0, false, false, "0"}, - createdAt("castAt"), - ccol("ip", 200, "''"), - }, nil, - ) - - createTable("users_replies", mysqlPre, mysqlCol, - []tC{ - {"rid", "int", 0, false, true, ""}, - {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - text("content"), - text("parsed_content"), - createdAt(), - {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"lastEdit", "int", 0, false, false, "0"}, - {"lastEditBy", "int", 0, false, false, "0"}, - ccol("ip", 200, "''"), - }, - []tK{ - {"rid", "primary", "", false}, - }, - ) - - createTable("likes", "", "", - []tC{ - {"weight", "tinyint", 0, false, false, "1"}, - {"targetItem", "int", 0, false, false, ""}, - ccol("targetType", 50, "replies"), - {"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - createdAt(), - {"recalc", "tinyint", 0, false, false, "0"}, - }, nil, - ) - - //columns("participants,createdBy,createdAt,lastReplyBy,lastReplyAt").Where("cid=?") - createTable("conversations", "", "", - []tC{ - {"cid", "int", 0, false, true, ""}, - {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key - createdAt(), - {"lastReplyAt", "datetime", 0, false, false, ""}, - {"lastReplyBy", "int", 0, false, false, ""}, - }, - []tK{ - {"cid", "primary", "", false}, - }, - ) - - createTable("conversations_posts", "", "", - []tC{ - {"pid", "int", 0, false, true, ""}, - {"cid", "int", 0, false, false, ""}, - {"createdBy", "int", 0, false, false, ""}, - ccol("body", 50, ""), - ccol("post", 50, "''"), - }, - []tK{ - {"pid", "primary", "", false}, - }, - ) - - createTable("conversations_participants", "", "", - []tC{ - {"uid", "int", 0, false, false, ""}, - {"cid", "int", 0, false, false, ""}, - }, nil, - ) - - /* - createTable("users_friends", "", "", - []tC{ - {"uid", "int", 0, false, false, ""}, - {"uid2", "int", 0, false, false, ""}, - }, nil, - ) - createTable("users_friends_invites", "", "", - []tC{ - {"requester", "int", 0, false, false, ""}, - {"target", "int", 0, false, false, ""}, - }, nil, - ) - */ - - createTable("users_blocks", "", "", - []tC{ - {"blocker", "int", 0, false, false, ""}, - {"blockedUser", "int", 0, false, false, ""}, - }, nil, - ) - - createTable("activity_stream_matches", "", "", - []tC{ - {"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key - }, - []tK{ - {"asid,asid", "foreign", "activity_stream", true}, - }, - ) - - createTable("activity_stream", "", "", - []tC{ - {"asid", "int", 0, false, true, ""}, - {"actor", "int", 0, false, false, ""}, /* the one doing the act */ // TODO: Make this a foreign key - {"targetUser", "int", 0, false, false, ""}, /* the user who created the item the actor is acting on, some items like forums may lack a targetUser field */ - ccol("event", 50, ""), /* mention, like, reply (as in the act of replying to an item, not the reply item type, you can "reply" to a forum by making a topic in it), friend_invite */ - ccol("elementType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */ - - // replacement for elementType - tC{"elementTable", "int", 0, false, false, "0"}, - - {"elementID", "int", 0, false, false, ""}, /* the ID of the element being acted upon */ - createdAt(), - ccol("extra", 200, "''"), - }, - []tK{ - {"asid", "primary", "", false}, - }, - ) - - createTable("activity_subscriptions", "", "", - []tC{ - {"user", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"targetID", "int", 0, false, false, ""}, /* the ID of the element being acted upon */ - ccol("targetType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */ - {"level", "int", 0, false, false, "0"}, /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/ - }, nil, - ) - - /* Due to MySQL's design, we have to drop the unique keys for table settings, plugins, and themes down from 200 to 180 or it will error */ - createTable("settings", "", "", - []tC{ - ccol("name", 180, ""), - ccol("content", 250, ""), - ccol("type", 50, ""), - ccol("constraints", 200, "''"), - }, - []tK{ - {"name", "unique", "", false}, - }, - ) - - createTable("word_filters", "", "", - []tC{ - {"wfid", "int", 0, false, true, ""}, - ccol("find", 200, ""), - ccol("replacement", 200, ""), - }, - []tK{ - {"wfid", "primary", "", false}, - }, - ) - - createTable("plugins", "", "", - []tC{ - ccol("uname", 180, ""), - bcol("active", false), - bcol("installed", false), - }, - []tK{ - {"uname", "unique", "", false}, - }, - ) - - createTable("themes", "", "", - []tC{ - ccol("uname", 180, ""), - bcol("default", false), - //text("profileUserVars"), - }, - []tK{ - {"uname", "unique", "", false}, - }, - ) - - createTable("widgets", "", "", - []tC{ - {"wid", "int", 0, false, true, ""}, - {"position", "int", 0, false, false, ""}, - ccol("side", 100, ""), - ccol("type", 100, ""), - bcol("active", false), - ccol("location", 100, ""), - text("data"), - }, - []tK{ - {"wid", "primary", "", false}, - }, - ) - - createTable("menus", "", "", - []tC{ - {"mid", "int", 0, false, true, ""}, - }, - []tK{ - {"mid", "primary", "", false}, - }, - ) - - createTable("menu_items", "", "", - []tC{ - {"miid", "int", 0, false, true, ""}, - {"mid", "int", 0, false, false, ""}, - ccol("name", 200, "''"), - ccol("htmlID", 200, "''"), - ccol("cssClass", 200, "''"), - ccol("position", 100, ""), - ccol("path", 200, "''"), - ccol("aria", 200, "''"), - ccol("tooltip", 200, "''"), - ccol("tmplName", 200, "''"), - {"order", "int", 0, false, false, "0"}, - - bcol("guestOnly", false), - bcol("memberOnly", false), - bcol("staffOnly", false), - bcol("adminOnly", false), - }, - []tK{ - {"miid", "primary", "", false}, - }, - ) - - createTable("pages", mysqlPre, mysqlCol, - []tC{ - {"pid", "int", 0, false, true, ""}, - //ccol("path", 200, ""), - ccol("name", 200, ""), - ccol("title", 200, ""), - text("body"), - // TODO: Make this a table? - text("allowedGroups"), - {"menuID", "int", 0, false, false, "-1"}, // simple sidebar menu - }, - []tK{ - {"pid", "primary", "", false}, - }, - ) - - createTable("registration_logs", "", "", - []tC{ - {"rlid", "int", 0, false, true, ""}, - ccol("username", 100, ""), - {"email", "varchar", 100, false, false, ""}, - ccol("failureReason", 100, ""), - bcol("success", false), // Did this attempt succeed? - ccol("ipaddress", 200, ""), - createdAt("doneAt"), - }, - []tK{ - {"rlid", "primary", "", false}, - }, - ) - - createTable("login_logs", "", "", - []tC{ - {"lid", "int", 0, false, true, ""}, - {"uid", "int", 0, false, false, ""}, - - bcol("success", false), // Did this attempt succeed? - ccol("ipaddress", 200, ""), - createdAt("doneAt"), - }, - []tK{ - {"lid", "primary", "", false}, - }, - ) - - createTable("moderation_logs", "", "", - []tC{ - ccol("action", 100, ""), - {"elementID", "int", 0, false, false, ""}, - ccol("elementType", 100, ""), - ccol("ipaddress", 200, ""), - {"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"doneAt", "datetime", 0, false, false, ""}, - text("extra"), - }, nil, - ) - - createTable("administration_logs", "", "", - []tC{ - ccol("action", 100, ""), - {"elementID", "int", 0, false, false, ""}, - ccol("elementType", 100, ""), - ccol("ipaddress", 200, ""), - {"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key - {"doneAt", "datetime", 0, false, false, ""}, - text("extra"), - }, nil, - ) - - createTable("viewchunks", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"avg", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - ccol("route", 200, ""), // TODO: set a default empty here - }, nil, - ) - - createTable("viewchunks_agents", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - ccol("browser", 200, ""), // googlebot, firefox, opera, etc. - //ccol("version",0,""), // the version of the browser or bot - }, nil, - ) - - createTable("viewchunks_systems", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - ccol("system", 200, ""), // windows, android, unknown, etc. - }, nil, - ) - - createTable("viewchunks_langs", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - ccol("lang", 200, ""), // en, ru, etc. - }, nil, - ) - - createTable("viewchunks_referrers", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - ccol("domain", 200, ""), - }, nil, - ) - - createTable("viewchunks_forums", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - {"forum", "int", 0, false, false, ""}, - }, nil, - ) - - createTable("topicchunks", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - // TODO: Add a column for the parent forum? - }, nil, - ) - - createTable("postchunks", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - // TODO: Add a column for the parent topic / profile? - }, nil, - ) - - createTable("memchunks", "", "", - []tC{ - {"count", "int", 0, false, false, "0"}, - {"stack", "int", 0, false, false, "0"}, - {"heap", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - }, nil, - ) - - createTable("perfchunks", "", "", - []tC{ - {"low", "int", 0, false, false, "0"}, - {"high", "int", 0, false, false, "0"}, - {"avg", "int", 0, false, false, "0"}, - {"createdAt", "datetime", 0, false, false, ""}, - }, nil, - ) - - createTable("sync", "", "", - []tC{ - {"last_update", "datetime", 0, false, false, ""}, - }, nil, - ) - - createTable("updates", "", "", - []tC{ - {"dbVersion", "int", 0, false, false, "0"}, - }, nil, - ) - - createTable("meta", "", "", - []tC{ - ccol("name", 200, ""), - ccol("value", 200, ""), - }, nil, - ) - - /*createTable("tables", "", "", - []tC{ - {"id", "int", 0, false, true, ""}, - ccol("name", 200, ""), - }, - []tK{ - {"id", "primary", "", false}, - {"name", "unique", "", false}, - }, - )*/ - - return err + createTable := func(table, charset, collation string, cols []tC, keys []tblKey) { + if err != nil { + return + } + err = f(table, charset, collation, cols, keys) + } + bcol := func(col string, val bool) qgen.DBTableColumn { + if val { + return tC{col, "boolean", 0, false, false, "1"} + } + return tC{col, "boolean", 0, false, false, "0"} + } + ccol := func(col string, size int, sdefault string) qgen.DBTableColumn { + return tC{col, "varchar", size, false, false, sdefault} + } + text := func(params ...string) qgen.DBTableColumn { + if len(params) == 0 { + return tC{"", "text", 0, false, false, ""} + } + col, sdefault := params[0], "" + if len(params) > 1 { + sdefault = params[1] + if sdefault == "" { + sdefault = "''" + } + } + return tC{col, "text", 0, false, false, sdefault} + } + createdAt := func(coll ...string) qgen.DBTableColumn { + var col string + if len(coll) > 0 { + col = coll[0] + } + if col == "" { + col = "createdAt" + } + return tC{col, "createdAt", 0, false, false, ""} + } + + createTable("users", mysqlPre, mysqlCol, + []tC{ + {"uid", "int", 0, false, true, ""}, + ccol("name", 100, ""), + ccol("password", 100, ""), + + ccol("salt", 80, "''"), + {"group", "int", 0, false, false, ""}, // TODO: Make this a foreign key + bcol("active", false), + bcol("is_super_admin", false), + createdAt(), + {"lastActiveAt", "datetime", 0, false, false, ""}, + ccol("session", 200, "''"), + //ccol("authToken", 200, "''"), + ccol("last_ip", 200, "''"), + {"profile_comments", "int", 0, false, false, "0"}, + {"who_can_convo", "int", 0, false, false, "0"}, + {"enable_embeds", "int", 0, false, false, "-1"}, + ccol("email", 200, "''"), + ccol("avatar", 100, "''"), + text("message"), + + // TODO: Drop these columns? + ccol("url_prefix", 20, "''"), + ccol("url_name", 100, "''"), + //text("pub_key"), + + {"level", "smallint", 0, false, false, "0"}, + {"score", "int", 0, false, false, "0"}, + {"posts", "int", 0, false, false, "0"}, + {"bigposts", "int", 0, false, false, "0"}, + {"megaposts", "int", 0, false, false, "0"}, + {"topics", "int", 0, false, false, "0"}, + {"liked", "int", 0, false, false, "0"}, + + // These two are to bound liked queries with little bits of information we know about the user to reduce the server load + {"oldestItemLikedCreatedAt", "datetime", 0, false, false, ""}, // For internal use only, semantics may change + {"lastLiked", "datetime", 0, false, false, ""}, // For internal use only, semantics may change + + //{"penalty_count","int",0,false,false,"0"}, + {"temp_group", "int", 0, false, false, "0"}, // For temporary groups, set this to zero when a temporary group isn't in effect + }, + []tK{ + {"uid", "primary", "", false}, + {"name", "unique", "", false}, + }, + ) + + createTable("users_groups", mysqlPre, mysqlCol, + []tC{ + {"gid", "int", 0, false, true, ""}, + ccol("name", 100, ""), + text("permissions"), + text("plugin_perms"), + bcol("is_mod", false), + bcol("is_admin", false), + bcol("is_banned", false), + {"user_count", "int", 0, false, false, "0"}, // TODO: Implement this + + ccol("tag", 50, "''"), + }, + []tK{ + {"gid", "primary", "", false}, + }, + ) + + createTable("users_groups_promotions", mysqlPre, mysqlCol, + []tC{ + {"pid", "int", 0, false, true, ""}, + {"from_gid", "int", 0, false, false, ""}, + {"to_gid", "int", 0, false, false, ""}, + bcol("two_way", false), // If a user no longer meets the requirements for this promotion then they will be demoted if this flag is set + + // Requirements + {"level", "int", 0, false, false, ""}, + {"posts", "int", 0, false, false, "0"}, + {"minTime", "int", 0, false, false, ""}, // How long someone needs to have been in their current group before being promoted + {"registeredFor", "int", 0, false, false, "0"}, // minutes + }, + []tK{ + {"pid", "primary", "", false}, + }, + ) + + /* + createTable("users_groups_promotions_scheduled","","", + []tC{ + {"prid","int",0,false,false,""}, + {"uid","int",0,false,false,""}, + {"runAt","datetime",0,false,false,""}, + }, + []tK{ + // TODO: Test to see that the compound primary key works + {"prid,uid", "primary", "", false}, + }, + ) + */ + + createTable("users_2fa_keys", mysqlPre, mysqlCol, + []tC{ + {"uid", "int", 0, false, false, ""}, + ccol("secret", 100, ""), + ccol("scratch1", 50, ""), + ccol("scratch2", 50, ""), + ccol("scratch3", 50, ""), + ccol("scratch4", 50, ""), + ccol("scratch5", 50, ""), + ccol("scratch6", 50, ""), + ccol("scratch7", 50, ""), + ccol("scratch8", 50, ""), + {"createdAt", "createdAt", 0, false, false, ""}, + }, + []tK{ + {"uid", "primary", "", false}, + }, + ) + + // What should we do about global penalties? Put them on the users table for speed? Or keep them here? + // Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans? + // TODO: Perm overrides + // TODO: Add a mod-queue and other basic auto-mod features. This is needed for awaiting activation and the mod_queue penalty flag + // TODO: Add a penalty type where a user is stopped from creating plugin_guilds social groups + // TODO: Shadow bans. We will probably have a CanShadowBan permission for this, as we *really* don't want people using this lightly. + /*createTable("users_penalties","","", + []tC{ + {"uid","int",0,false,false,""}, + {"element_id","int",0,false,false,""}, + ccol("element_type",50,""), //forum, profile?, and social_group. Leave blank for global. + text("overrides","{}"), + + bcol("mod_queue",false), + bcol("shadow_ban",false), + bcol("no_avatar",false), // Coming Soon. Should this be a perm override instead? + + // Do we *really* need rate-limit penalty types? Are we going to be allowing bots or something? + //{"posts_per_hour","int",0,false,false,"0"}, + //{"topics_per_hour","int",0,false,false,"0"}, + //{"posts_count","int",0,false,false,"0"}, + //{"topic_count","int",0,false,false,"0"}, + //{"last_hour","int",0,false,false,"0"}, // UNIX Time, as we don't need to do anything too fancy here. When an hour has elapsed since that time, reset the hourly penalty counters. + + {"issued_by","int",0,false,false,""}, + createdAt("issued_at"), + {"expires_at","datetime",0,false,false,""}, + }, nil, + )*/ + + createTable("users_groups_scheduler", "", "", + []tC{ + {"uid", "int", 0, false, false, ""}, + {"set_group", "int", 0, false, false, ""}, + + {"issued_by", "int", 0, false, false, ""}, + createdAt("issued_at"), + {"revert_at", "datetime", 0, false, false, ""}, + {"temporary", "boolean", 0, false, false, ""}, // special case for permanent bans to do the necessary bookkeeping, might be removed in the future + }, + []tK{ + {"uid", "primary", "", false}, + }, + ) + + // TODO: Can we use a piece of software dedicated to persistent queues for this rather than relying on the database for it? + createTable("users_avatar_queue", "", "", + []tC{ + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + }, + []tK{ + {"uid", "primary", "", false}, + }, + ) + + // TODO: Should we add a users prefix to this table to fit the "unofficial convention"? + // TODO: Add an autoincrement key? + createTable("emails", "", "", + []tC{ + ccol("email", 200, ""), + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + bcol("validated", false), + ccol("token", 200, "''"), + }, nil, + ) + + // TODO: Allow for patterns in domains, if the bots try to shake things up there? + /* + createTable("email_domain_blacklist", "", "", + []tC{ + ccol("domain", 200, ""), + bcol("gtld", false), + }, + []tK{ + {"domain", "primary"}, + }, + ) + */ + + // TODO: Implement password resets + createTable("password_resets", "", "", + []tC{ + ccol("email", 200, ""), + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + ccol("validated", 200, ""), // Token given once the one-use token is consumed, used to prevent multiple people consuming the same one-use token + ccol("token", 200, ""), + createdAt(), + }, nil, + ) + + createTable("forums", mysqlPre, mysqlCol, + []tC{ + {"fid", "int", 0, false, true, ""}, + ccol("name", 100, ""), + ccol("desc", 200, ""), + ccol("tmpl", 200, "''"), + bcol("active", true), + {"order", "int", 0, false, false, "0"}, + {"topicCount", "int", 0, false, false, "0"}, + ccol("preset", 100, "''"), + {"parentID", "int", 0, false, false, "0"}, + ccol("parentType", 50, "''"), + {"lastTopicID", "int", 0, false, false, "0"}, + {"lastReplyerID", "int", 0, false, false, "0"}, + }, + []tK{ + {"fid", "primary", "", false}, + }, + ) + + createTable("forums_permissions", "", "", + []tC{ + {"fid", "int", 0, false, false, ""}, + {"gid", "int", 0, false, false, ""}, + ccol("preset", 100, "''"), + text("permissions", "{}"), + }, + []tK{ + // TODO: Test to see that the compound primary key works + {"fid,gid", "primary", "", false}, + }, + ) + + createTable("topics", mysqlPre, mysqlCol, + []tC{ + {"tid", "int", 0, false, true, ""}, + ccol("title", 100, ""), // TODO: Increase the max length to 200? + text("content"), + text("parsed_content"), + createdAt(), + {"lastReplyAt", "datetime", 0, false, false, ""}, + {"lastReplyBy", "int", 0, false, false, ""}, + {"lastReplyID", "int", 0, false, false, "0"}, + {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + bcol("is_closed", false), + bcol("sticky", false), + // TODO: Add an index for this + {"parentID", "int", 0, false, false, "2"}, + ccol("ip", 200, "''"), + {"postCount", "int", 0, false, false, "1"}, + {"likeCount", "int", 0, false, false, "0"}, + {"attachCount", "int", 0, false, false, "0"}, + {"words", "int", 0, false, false, "0"}, + {"views", "int", 0, false, false, "0"}, + //{"dayViews", "int", 0, false, false, "0"}, + {"weekEvenViews", "int", 0, false, false, "0"}, + {"weekOddViews", "int", 0, false, false, "0"}, + ///{"weekViews", "int", 0, false, false, "0"}, + ///{"lastWeekViews", "int", 0, false, false, "0"}, + //{"monthViews", "int", 0, false, false, "0"}, + // ? - A little hacky, maybe we could do something less likely to bite us with huge numbers of topics? + // TODO: Add an index for this? + //{"lastMonth", "datetime", 0, false, false, ""}, + ccol("css_class", 100, "''"), + {"poll", "int", 0, false, false, "0"}, + ccol("data", 200, "''"), + }, + []tK{ + {"tid", "primary", "", false}, + {"title", "fulltext", "", false}, + {"content", "fulltext", "", false}, + }, + ) + + createTable("replies", mysqlPre, mysqlCol, + []tC{ + {"rid", "int", 0, false, true, ""}, // TODO: Rename to replyID? + {"tid", "int", 0, false, false, ""}, // TODO: Rename to topicID? + text("content"), + text("parsed_content"), + createdAt(), + {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"lastEdit", "int", 0, false, false, "0"}, + {"lastEditBy", "int", 0, false, false, "0"}, + {"lastUpdated", "datetime", 0, false, false, ""}, + ccol("ip", 200, "''"), + {"likeCount", "int", 0, false, false, "0"}, + {"attachCount", "int", 0, false, false, "0"}, + {"words", "int", 0, false, false, "1"}, // ? - replies has a default of 1 and topics has 0? why? + ccol("actionType", 20, "''"), + {"poll", "int", 0, false, false, "0"}, + }, + []tK{ + {"rid", "primary", "", false}, + {"content", "fulltext", "", false}, + }, + ) + + createTable("attachments", mysqlPre, mysqlCol, + []tC{ + {"attachID", "int", 0, false, true, ""}, + {"sectionID", "int", 0, false, false, "0"}, + ccol("sectionTable", 200, "forums"), + {"originID", "int", 0, false, false, ""}, + ccol("originTable", 200, "replies"), + {"uploadedBy", "int", 0, false, false, ""}, // TODO; Make this a foreign key + ccol("path", 200, ""), + ccol("extra", 200, ""), + }, + []tK{ + {"attachID", "primary", "", false}, + }, + ) + + createTable("revisions", mysqlPre, mysqlCol, + []tC{ + {"reviseID", "int", 0, false, true, ""}, + text("content"), + {"contentID", "int", 0, false, false, ""}, + ccol("contentType", 100, "replies"), + createdAt(), + // TODO: Add a createdBy column? + }, + []tK{ + {"reviseID", "primary", "", false}, + }, + ) + + createTable("polls", mysqlPre, mysqlCol, + []tC{ + {"pollID", "int", 0, false, true, ""}, + {"parentID", "int", 0, false, false, "0"}, + ccol("parentTable", 100, "topics"), // topics, replies + {"type", "int", 0, false, false, "0"}, + {"options", "json", 0, false, false, ""}, + {"votes", "int", 0, false, false, "0"}, + }, + []tK{ + {"pollID", "primary", "", false}, + }, + ) + + createTable("polls_options", "", "", + []tC{ + {"pollID", "int", 0, false, false, ""}, + {"option", "int", 0, false, false, "0"}, + {"votes", "int", 0, false, false, "0"}, + }, nil, + ) + + createTable("polls_votes", mysqlPre, mysqlCol, + []tC{ + {"pollID", "int", 0, false, false, ""}, + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"option", "int", 0, false, false, "0"}, + createdAt("castAt"), + ccol("ip", 200, "''"), + }, nil, + ) + + createTable("users_replies", mysqlPre, mysqlCol, + []tC{ + {"rid", "int", 0, false, true, ""}, + {"uid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + text("content"), + text("parsed_content"), + createdAt(), + {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"lastEdit", "int", 0, false, false, "0"}, + {"lastEditBy", "int", 0, false, false, "0"}, + ccol("ip", 200, "''"), + }, + []tK{ + {"rid", "primary", "", false}, + }, + ) + + createTable("likes", "", "", + []tC{ + {"weight", "tinyint", 0, false, false, "1"}, + {"targetItem", "int", 0, false, false, ""}, + ccol("targetType", 50, "replies"), + {"sentBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + createdAt(), + {"recalc", "tinyint", 0, false, false, "0"}, + }, nil, + ) + + //columns("participants,createdBy,createdAt,lastReplyBy,lastReplyAt").Where("cid=?") + createTable("conversations", "", "", + []tC{ + {"cid", "int", 0, false, true, ""}, + {"createdBy", "int", 0, false, false, ""}, // TODO: Make this a foreign key + createdAt(), + {"lastReplyAt", "datetime", 0, false, false, ""}, + {"lastReplyBy", "int", 0, false, false, ""}, + }, + []tK{ + {"cid", "primary", "", false}, + }, + ) + + createTable("conversations_posts", "", "", + []tC{ + {"pid", "int", 0, false, true, ""}, + {"cid", "int", 0, false, false, ""}, + {"createdBy", "int", 0, false, false, ""}, + ccol("body", 50, ""), + ccol("post", 50, "''"), + }, + []tK{ + {"pid", "primary", "", false}, + }, + ) + + createTable("conversations_participants", "", "", + []tC{ + {"uid", "int", 0, false, false, ""}, + {"cid", "int", 0, false, false, ""}, + }, nil, + ) + + /* + createTable("users_friends", "", "", + []tC{ + {"uid", "int", 0, false, false, ""}, + {"uid2", "int", 0, false, false, ""}, + }, nil, + ) + createTable("users_friends_invites", "", "", + []tC{ + {"requester", "int", 0, false, false, ""}, + {"target", "int", 0, false, false, ""}, + }, nil, + ) + */ + + createTable("users_blocks", "", "", + []tC{ + {"blocker", "int", 0, false, false, ""}, + {"blockedUser", "int", 0, false, false, ""}, + }, nil, + ) + + createTable("activity_stream_matches", "", "", + []tC{ + {"watcher", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"asid", "int", 0, false, false, ""}, // TODO: Make this a foreign key + }, + []tK{ + {"asid,asid", "foreign", "activity_stream", true}, + }, + ) + + createTable("activity_stream", "", "", + []tC{ + {"asid", "int", 0, false, true, ""}, + {"actor", "int", 0, false, false, ""}, /* the one doing the act */ // TODO: Make this a foreign key + {"targetUser", "int", 0, false, false, ""}, /* the user who created the item the actor is acting on, some items like forums may lack a targetUser field */ + ccol("event", 50, ""), /* mention, like, reply (as in the act of replying to an item, not the reply item type, you can "reply" to a forum by making a topic in it), friend_invite */ + ccol("elementType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */ + + // replacement for elementType + tC{"elementTable", "int", 0, false, false, "0"}, + + {"elementID", "int", 0, false, false, ""}, /* the ID of the element being acted upon */ + createdAt(), + ccol("extra", 200, "''"), + }, + []tK{ + {"asid", "primary", "", false}, + }, + ) + + createTable("activity_subscriptions", "", "", + []tC{ + {"user", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"targetID", "int", 0, false, false, ""}, /* the ID of the element being acted upon */ + ccol("targetType", 50, ""), /* topic, post (calling it post here to differentiate it from the 'reply' event), forum, user */ + {"level", "int", 0, false, false, "0"}, /* 0: Mentions (aka the global default for any post), 1: Replies To You, 2: All Replies*/ + }, nil, + ) + + /* Due to MySQL's design, we have to drop the unique keys for table settings, plugins, and themes down from 200 to 180 or it will error */ + createTable("settings", "", "", + []tC{ + ccol("name", 180, ""), + ccol("content", 250, ""), + ccol("type", 50, ""), + ccol("constraints", 200, "''"), + }, + []tK{ + {"name", "unique", "", false}, + }, + ) + + createTable("word_filters", "", "", + []tC{ + {"wfid", "int", 0, false, true, ""}, + ccol("find", 200, ""), + ccol("replacement", 200, ""), + }, + []tK{ + {"wfid", "primary", "", false}, + }, + ) + + createTable("plugins", "", "", + []tC{ + ccol("uname", 180, ""), + bcol("active", false), + bcol("installed", false), + }, + []tK{ + {"uname", "unique", "", false}, + }, + ) + + createTable("themes", "", "", + []tC{ + ccol("uname", 180, ""), + bcol("default", false), + //text("profileUserVars"), + }, + []tK{ + {"uname", "unique", "", false}, + }, + ) + + createTable("widgets", "", "", + []tC{ + {"wid", "int", 0, false, true, ""}, + {"position", "int", 0, false, false, ""}, + ccol("side", 100, ""), + ccol("type", 100, ""), + bcol("active", false), + ccol("location", 100, ""), + text("data"), + }, + []tK{ + {"wid", "primary", "", false}, + }, + ) + + createTable("menus", "", "", + []tC{ + {"mid", "int", 0, false, true, ""}, + }, + []tK{ + {"mid", "primary", "", false}, + }, + ) + + createTable("menu_items", "", "", + []tC{ + {"miid", "int", 0, false, true, ""}, + {"mid", "int", 0, false, false, ""}, + ccol("name", 200, "''"), + ccol("htmlID", 200, "''"), + ccol("cssClass", 200, "''"), + ccol("position", 100, ""), + ccol("path", 200, "''"), + ccol("aria", 200, "''"), + ccol("tooltip", 200, "''"), + ccol("tmplName", 200, "''"), + {"order", "int", 0, false, false, "0"}, + + bcol("guestOnly", false), + bcol("memberOnly", false), + bcol("staffOnly", false), + bcol("adminOnly", false), + }, + []tK{ + {"miid", "primary", "", false}, + }, + ) + + createTable("pages", mysqlPre, mysqlCol, + []tC{ + {"pid", "int", 0, false, true, ""}, + //ccol("path", 200, ""), + ccol("name", 200, ""), + ccol("title", 200, ""), + text("body"), + // TODO: Make this a table? + text("allowedGroups"), + {"menuID", "int", 0, false, false, "-1"}, // simple sidebar menu + }, + []tK{ + {"pid", "primary", "", false}, + }, + ) + + createTable("registration_logs", "", "", + []tC{ + {"rlid", "int", 0, false, true, ""}, + ccol("username", 100, ""), + {"email", "varchar", 100, false, false, ""}, + ccol("failureReason", 100, ""), + bcol("success", false), // Did this attempt succeed? + ccol("ipaddress", 200, ""), + createdAt("doneAt"), + }, + []tK{ + {"rlid", "primary", "", false}, + }, + ) + + createTable("login_logs", "", "", + []tC{ + {"lid", "int", 0, false, true, ""}, + {"uid", "int", 0, false, false, ""}, + + bcol("success", false), // Did this attempt succeed? + ccol("ipaddress", 200, ""), + createdAt("doneAt"), + }, + []tK{ + {"lid", "primary", "", false}, + }, + ) + + createTable("moderation_logs", "", "", + []tC{ + ccol("action", 100, ""), + {"elementID", "int", 0, false, false, ""}, + ccol("elementType", 100, ""), + ccol("ipaddress", 200, ""), + {"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"doneAt", "datetime", 0, false, false, ""}, + text("extra"), + }, nil, + ) + + createTable("administration_logs", "", "", + []tC{ + ccol("action", 100, ""), + {"elementID", "int", 0, false, false, ""}, + ccol("elementType", 100, ""), + ccol("ipaddress", 200, ""), + {"actorID", "int", 0, false, false, ""}, // TODO: Make this a foreign key + {"doneAt", "datetime", 0, false, false, ""}, + text("extra"), + }, nil, + ) + + createTable("viewchunks", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"avg", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + ccol("route", 200, ""), // TODO: set a default empty here + }, nil, + ) + + createTable("viewchunks_agents", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + ccol("browser", 200, ""), // googlebot, firefox, opera, etc. + //ccol("version",0,""), // the version of the browser or bot + }, nil, + ) + + createTable("viewchunks_systems", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + ccol("system", 200, ""), // windows, android, unknown, etc. + }, nil, + ) + + createTable("viewchunks_langs", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + ccol("lang", 200, ""), // en, ru, etc. + }, nil, + ) + + createTable("viewchunks_referrers", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + ccol("domain", 200, ""), + }, nil, + ) + + createTable("viewchunks_forums", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + {"forum", "int", 0, false, false, ""}, + }, nil, + ) + + createTable("topicchunks", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + // TODO: Add a column for the parent forum? + }, nil, + ) + + createTable("postchunks", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + // TODO: Add a column for the parent topic / profile? + }, nil, + ) + + createTable("memchunks", "", "", + []tC{ + {"count", "int", 0, false, false, "0"}, + {"stack", "int", 0, false, false, "0"}, + {"heap", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + }, nil, + ) + + createTable("perfchunks", "", "", + []tC{ + {"low", "int", 0, false, false, "0"}, + {"high", "int", 0, false, false, "0"}, + {"avg", "int", 0, false, false, "0"}, + {"createdAt", "datetime", 0, false, false, ""}, + }, nil, + ) + + createTable("sync", "", "", + []tC{ + {"last_update", "datetime", 0, false, false, ""}, + }, nil, + ) + + createTable("updates", "", "", + []tC{ + {"dbVersion", "int", 0, false, false, "0"}, + }, nil, + ) + + createTable("meta", "", "", + []tC{ + ccol("name", 200, ""), + ccol("value", 200, ""), + }, nil, + ) + + /*createTable("tables", "", "", + []tC{ + {"id", "int", 0, false, true, ""}, + ccol("name", 200, ""), + }, + []tK{ + {"id", "primary", "", false}, + {"name", "unique", "", false}, + }, + )*/ + + return err } diff --git a/common/activity_stream.go b/common/activity_stream.go index 3edfdfd7..13041680 100644 --- a/common/activity_stream.go +++ b/common/activity_stream.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Activity ActivityStream diff --git a/common/activity_stream_matches.go b/common/activity_stream_matches.go index bd170d83..f8eccd2b 100644 --- a/common/activity_stream_matches.go +++ b/common/activity_stream_matches.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var ActivityMatches ActivityStreamMatches diff --git a/common/alerts.go b/common/alerts.go index 60961285..0138bafc 100644 --- a/common/alerts.go +++ b/common/alerts.go @@ -7,16 +7,16 @@ package common import ( - "database/sql" - "errors" - "strconv" - "strings" - "time" + "database/sql" + "errors" + "strconv" + "strings" + "time" - //"fmt" + //"fmt" - "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type Alert struct { diff --git a/common/analytics.go b/common/analytics.go index 2e4e810f..f8fb54c3 100644 --- a/common/analytics.go +++ b/common/analytics.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "log" - "time" + "database/sql" + "log" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Analytics AnalyticsStore diff --git a/common/attachments.go b/common/attachments.go index bb03c3b4..05dd76ae 100644 --- a/common/attachments.go +++ b/common/attachments.go @@ -1,15 +1,15 @@ package common import ( - "database/sql" - "errors" + "database/sql" + "errors" - //"fmt" - "os" - "path/filepath" - "strings" + //"fmt" + "os" + "path/filepath" + "strings" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Attachments AttachmentStore diff --git a/common/audit_logs.go b/common/audit_logs.go index b4fd4d3e..be96bdb2 100644 --- a/common/audit_logs.go +++ b/common/audit_logs.go @@ -1,10 +1,10 @@ package common import ( - "database/sql" - "time" + "database/sql" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var ModLogs LogStore diff --git a/common/auth.go b/common/auth.go index 777ac6c5..4f545d01 100644 --- a/common/auth.go +++ b/common/auth.go @@ -7,20 +7,20 @@ package common import ( - "crypto/sha256" - "crypto/subtle" - "database/sql" - "encoding/hex" - "errors" - "net/http" - "strconv" - "strings" + "crypto/sha256" + "crypto/subtle" + "database/sql" + "encoding/hex" + "errors" + "net/http" + "strconv" + "strings" - "github.com/Azareal/Gosora/common/gauth" - qgen "github.com/Azareal/Gosora/query_gen" + "git.tuxpa.in/a/gosora/common/gauth" + qgen "git.tuxpa.in/a/gosora/query_gen" - //"golang.org/x/crypto/argon2" - "golang.org/x/crypto/bcrypt" + //"golang.org/x/crypto/argon2" + "golang.org/x/crypto/bcrypt" ) // TODO: Write more authentication tests diff --git a/common/common.go b/common/common.go index 9929333e..139debb5 100644 --- a/common/common.go +++ b/common/common.go @@ -4,23 +4,23 @@ * Copyright Azareal 2018 - 2020 * */ -package common // import "github.com/Azareal/Gosora/common" +package common // import "git.tuxpa.in/a/gosora/common" import ( - "database/sql" - "io" - "log" - "net" - "net/http" - "os" - "runtime/debug" - "strconv" - "strings" - "sync/atomic" - "time" + "database/sql" + "io" + "log" + "net" + "net/http" + "os" + "runtime/debug" + "strconv" + "strings" + "sync/atomic" + "time" - meta "github.com/Azareal/Gosora/common/meta" - qgen "github.com/Azareal/Gosora/query_gen" + meta "git.tuxpa.in/a/gosora/common/meta" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var SoftwareVersion = Version{Major: 0, Minor: 3, Patch: 0, Tag: "dev"} diff --git a/common/conversations.go b/common/conversations.go index 82023503..6103ad70 100644 --- a/common/conversations.go +++ b/common/conversations.go @@ -1,15 +1,15 @@ package common import ( - "errors" - "time" + "errors" + "time" - //"log" + //"log" - "database/sql" - "strconv" + "database/sql" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Convos ConversationStore diff --git a/common/counters/agents.go b/common/counters/agents.go index b0a80c5a..e1689cc1 100644 --- a/common/counters/agents.go +++ b/common/counters/agents.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/forums.go b/common/counters/forums.go index 8858ed96..b08869ed 100644 --- a/common/counters/forums.go +++ b/common/counters/forums.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/langs.go b/common/counters/langs.go index 28d0da19..d2ab37c8 100644 --- a/common/counters/langs.go +++ b/common/counters/langs.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/memory.go b/common/counters/memory.go index c947a90e..1643dd6c 100644 --- a/common/counters/memory.go +++ b/common/counters/memory.go @@ -6,8 +6,8 @@ import ( "sync" "time" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/performance.go b/common/counters/performance.go index 43357780..b6def286 100644 --- a/common/counters/performance.go +++ b/common/counters/performance.go @@ -5,8 +5,8 @@ import ( "math" "time" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/posts.go b/common/counters/posts.go index 189312cb..64c8480b 100644 --- a/common/counters/posts.go +++ b/common/counters/posts.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/referrers.go b/common/counters/referrers.go index 0a80adea..d2bdfd88 100644 --- a/common/counters/referrers.go +++ b/common/counters/referrers.go @@ -5,8 +5,8 @@ import ( "sync" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/requests.go b/common/counters/requests.go index 347cdc94..7ca8085f 100644 --- a/common/counters/requests.go +++ b/common/counters/requests.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/routes.go b/common/counters/routes.go index 34e450ef..472b8f0e 100644 --- a/common/counters/routes.go +++ b/common/counters/routes.go @@ -6,9 +6,9 @@ import ( "sync/atomic" "time" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/Azareal/Gosora/uutils" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + "git.tuxpa.in/a/gosora/uutils" "github.com/pkg/errors" ) diff --git a/common/counters/systems.go b/common/counters/systems.go index 9e928b8d..38472f1d 100644 --- a/common/counters/systems.go +++ b/common/counters/systems.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/topics.go b/common/counters/topics.go index 5a63e04a..5871def5 100644 --- a/common/counters/topics.go +++ b/common/counters/topics.go @@ -4,8 +4,8 @@ import ( "database/sql" "sync/atomic" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/counters/topics_views.go b/common/counters/topics_views.go index f558a5ba..eec5b418 100644 --- a/common/counters/topics_views.go +++ b/common/counters/topics_views.go @@ -8,8 +8,8 @@ import ( "sync/atomic" "time" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/pkg/errors" ) diff --git a/common/email.go b/common/email.go index b4189821..785debe6 100644 --- a/common/email.go +++ b/common/email.go @@ -1,13 +1,13 @@ package common import ( - "crypto/tls" - "fmt" - "net/mail" - "net/smtp" - "strings" + "crypto/tls" + "fmt" + "net/mail" + "net/smtp" + "strings" - p "github.com/Azareal/Gosora/common/phrases" + p "git.tuxpa.in/a/gosora/common/phrases" ) func SendActivationEmail(username, email, token string) error { diff --git a/common/email_store.go b/common/email_store.go index 06952ac2..f70c95a7 100644 --- a/common/email_store.go +++ b/common/email_store.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Emails EmailStore diff --git a/common/errors.go b/common/errors.go index 590020c3..7e49a14c 100644 --- a/common/errors.go +++ b/common/errors.go @@ -1,15 +1,15 @@ package common import ( - "fmt" - "log" - "net/http" - "runtime/debug" - "strings" - "sync" - "sync/atomic" + "fmt" + "log" + "net/http" + "runtime/debug" + "strings" + "sync" + "sync/atomic" - p "github.com/Azareal/Gosora/common/phrases" + p "git.tuxpa.in/a/gosora/common/phrases" ) type ErrorItem struct { diff --git a/common/extend.go b/common/extend.go index 9b775444..adb66e89 100644 --- a/common/extend.go +++ b/common/extend.go @@ -8,14 +8,14 @@ package common // TODO: Break this file up into multiple files to make it easier to maintain import ( - "database/sql" - "errors" - "log" - "net/http" - "sync" - "sync/atomic" + "database/sql" + "errors" + "log" + "net/http" + "sync" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var ErrPluginNotInstallable = errors.New("This plugin is not installable") diff --git a/common/files.go b/common/files.go index e4c906b0..fad54912 100644 --- a/common/files.go +++ b/common/files.go @@ -1,25 +1,25 @@ package common import ( - "bytes" - "compress/gzip" - "crypto/sha256" - "encoding/base64" - "encoding/hex" - "errors" - "fmt" - "io/ioutil" - "mime" - "net/http" - "net/url" - "os" - "path/filepath" - "strconv" - "strings" - "sync" + "bytes" + "compress/gzip" + "crypto/sha256" + "encoding/base64" + "encoding/hex" + "errors" + "fmt" + "io/ioutil" + "mime" + "net/http" + "net/url" + "os" + "path/filepath" + "strconv" + "strings" + "sync" - tmpl "github.com/Azareal/Gosora/tmpl_client" - "github.com/andybalholm/brotli" + tmpl "git.tuxpa.in/a/gosora/tmpl_client" + "github.com/andybalholm/brotli" ) //type SFileList map[string]*SFile diff --git a/common/forum.go b/common/forum.go index d4f79204..b9afc98a 100644 --- a/common/forum.go +++ b/common/forum.go @@ -1,14 +1,14 @@ package common import ( - //"log" - "database/sql" - "errors" - "strconv" - "strings" + //"log" + "database/sql" + "errors" + "strconv" + "strings" - qgen "github.com/Azareal/Gosora/query_gen" - _ "github.com/go-sql-driver/mysql" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/go-sql-driver/mysql" ) // TODO: Do we really need this? diff --git a/common/forum_actions.go b/common/forum_actions.go index 3d60d1d2..087d1445 100644 --- a/common/forum_actions.go +++ b/common/forum_actions.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "fmt" - "strconv" + "database/sql" + "fmt" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var ForumActionStore ForumActionStoreInt diff --git a/common/forum_perms.go b/common/forum_perms.go index 3bc5c3fb..80f97b5f 100644 --- a/common/forum_perms.go +++ b/common/forum_perms.go @@ -1,10 +1,10 @@ package common import ( - "database/sql" - "encoding/json" + "database/sql" + "encoding/json" - "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // ? - Can we avoid duplicating the items in this list in a bunch of places? diff --git a/common/forum_perms_store.go b/common/forum_perms_store.go index 8021ce7f..400538ec 100644 --- a/common/forum_perms_store.go +++ b/common/forum_perms_store.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "encoding/json" - "sync" + "database/sql" + "encoding/json" + "sync" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var FPStore ForumPermsStore diff --git a/common/forum_store.go b/common/forum_store.go index 1a634eb2..15f02c0b 100644 --- a/common/forum_store.go +++ b/common/forum_store.go @@ -7,16 +7,16 @@ package common import ( - "database/sql" - "errors" - "log" + "database/sql" + "errors" + "log" - //"fmt" - "sort" - "sync" - "sync/atomic" + //"fmt" + "sort" + "sync" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var forumCreateMutex sync.Mutex diff --git a/common/group.go b/common/group.go index 1ba7a1b0..f00f7e31 100644 --- a/common/group.go +++ b/common/group.go @@ -1,10 +1,10 @@ package common import ( - "database/sql" - "encoding/json" + "database/sql" + "encoding/json" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var blankGroup = Group{ID: 0, Name: ""} diff --git a/common/group_store.go b/common/group_store.go index 8dc91aae..42229497 100644 --- a/common/group_store.go +++ b/common/group_store.go @@ -2,15 +2,15 @@ package common import ( - "database/sql" - "encoding/json" - "errors" - "log" - "sort" - "strconv" - "sync" + "database/sql" + "encoding/json" + "errors" + "log" + "sort" + "strconv" + "sync" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Groups GroupStore diff --git a/common/ip_search.go b/common/ip_search.go index 20a2a4dd..2c2df743 100644 --- a/common/ip_search.go +++ b/common/ip_search.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var IPSearch IPSearcher diff --git a/common/likes.go b/common/likes.go index 6473e5ef..d6ce5525 100644 --- a/common/likes.go +++ b/common/likes.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Likes LikeStore diff --git a/common/menu_store.go b/common/menu_store.go index 7da71532..ec1b2411 100644 --- a/common/menu_store.go +++ b/common/menu_store.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "strconv" - "sync/atomic" + "database/sql" + "strconv" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Menus *DefaultMenuStore diff --git a/common/menus.go b/common/menus.go index ce77f25f..ca414de7 100644 --- a/common/menus.go +++ b/common/menus.go @@ -1,17 +1,17 @@ package common import ( - "bytes" - "database/sql" - "fmt" - "io" - "io/ioutil" - "strconv" - "strings" + "bytes" + "database/sql" + "fmt" + "io" + "io/ioutil" + "strconv" + "strings" - "github.com/Azareal/Gosora/common/phrases" - tmpl "github.com/Azareal/Gosora/common/templates" - qgen "github.com/Azareal/Gosora/query_gen" + "git.tuxpa.in/a/gosora/common/phrases" + tmpl "git.tuxpa.in/a/gosora/common/templates" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type MenuItemList []MenuItem diff --git a/common/meta/meta_store.go b/common/meta/meta_store.go index 77ef38d2..e58730ac 100644 --- a/common/meta/meta_store.go +++ b/common/meta/meta_store.go @@ -3,7 +3,7 @@ package common import ( "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // MetaStore is a simple key-value store for the system to stash things in when needed diff --git a/common/mfa_store.go b/common/mfa_store.go index 8b35c103..95a5b64d 100644 --- a/common/mfa_store.go +++ b/common/mfa_store.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "errors" - "strings" + "database/sql" + "errors" + "strings" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var MFAstore MFAStore diff --git a/common/misc_logs.go b/common/misc_logs.go index 305744b1..466458bc 100644 --- a/common/misc_logs.go +++ b/common/misc_logs.go @@ -1,10 +1,10 @@ package common import ( - "database/sql" - "time" + "database/sql" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var RegLogs RegLogStore diff --git a/common/page_store.go b/common/page_store.go index 39b24161..d275487a 100644 --- a/common/page_store.go +++ b/common/page_store.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "strconv" - "strings" + "database/sql" + "strconv" + "strings" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type CustomPageStmts struct { diff --git a/common/pages.go b/common/pages.go index f851cb97..e433d29a 100644 --- a/common/pages.go +++ b/common/pages.go @@ -1,13 +1,13 @@ package common import ( - "html/template" - "net/http" - "runtime" - "sync" - "time" + "html/template" + "net/http" + "runtime" + "sync" + "time" - p "github.com/Azareal/Gosora/common/phrases" + p "git.tuxpa.in/a/gosora/common/phrases" ) /*type HResource struct { diff --git a/common/password_reset.go b/common/password_reset.go index db271ac9..2009562d 100644 --- a/common/password_reset.go +++ b/common/password_reset.go @@ -1,11 +1,11 @@ package common import ( - "crypto/subtle" - "database/sql" - "errors" + "crypto/subtle" + "database/sql" + "errors" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var PasswordResetter *DefaultPasswordResetter diff --git a/common/permissions.go b/common/permissions.go index 1fde4d5b..9c58ae87 100644 --- a/common/permissions.go +++ b/common/permissions.go @@ -1,11 +1,11 @@ package common import ( - "encoding/json" - "log" + "encoding/json" + "log" - "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Refactor the perms system diff --git a/common/poll.go b/common/poll.go index 114d9dcd..78960c4c 100644 --- a/common/poll.go +++ b/common/poll.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var pollStmts PollStmts diff --git a/common/poll_store.go b/common/poll_store.go index f88af7b5..d0de4633 100644 --- a/common/poll_store.go +++ b/common/poll_store.go @@ -1,13 +1,13 @@ package common import ( - "database/sql" - "encoding/json" - "errors" - "log" - "strconv" + "database/sql" + "encoding/json" + "errors" + "log" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Polls PollStore diff --git a/common/profile_reply.go b/common/profile_reply.go index c1a23b3d..8d798334 100644 --- a/common/profile_reply.go +++ b/common/profile_reply.go @@ -1,12 +1,12 @@ package common import ( - "database/sql" - "html" - "strconv" - "time" + "database/sql" + "html" + "strconv" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var profileReplyStmts ProfileReplyStmts diff --git a/common/profile_reply_store.go b/common/profile_reply_store.go index a348b5d1..25082490 100644 --- a/common/profile_reply_store.go +++ b/common/profile_reply_store.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Prstore ProfileReplyStore diff --git a/common/promotions.go b/common/promotions.go index 580bc939..568ade00 100644 --- a/common/promotions.go +++ b/common/promotions.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - //"log" - "time" + "database/sql" + //"log" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var GroupPromotions GroupPromotionStore diff --git a/common/recalc.go b/common/recalc.go index 7ad79bb3..56d3debc 100644 --- a/common/recalc.go +++ b/common/recalc.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - //"log" - "strconv" + "database/sql" + //"log" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Recalc RecalcInt diff --git a/common/relations.go b/common/relations.go index 96b4c113..bb3314d4 100644 --- a/common/relations.go +++ b/common/relations.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var UserBlocks BlockStore diff --git a/common/reply.go b/common/reply.go index 7d9292ec..c5aaeda1 100644 --- a/common/reply.go +++ b/common/reply.go @@ -7,13 +7,13 @@ package common import ( - "database/sql" - "errors" - "html" - "strconv" - "time" + "database/sql" + "errors" + "html" + "strconv" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type ReplyUser struct { diff --git a/common/reply_store.go b/common/reply_store.go index 575c62da..ccbcc5b6 100644 --- a/common/reply_store.go +++ b/common/reply_store.go @@ -2,9 +2,9 @@ package common //import "log" import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Rstore ReplyStore diff --git a/common/report_store.go b/common/report_store.go index 4bf9b29e..88d6e8dc 100644 --- a/common/report_store.go +++ b/common/report_store.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "errors" - "strconv" + "database/sql" + "errors" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Make the default report forum ID configurable diff --git a/common/routes_common.go b/common/routes_common.go index b9109543..9ba480a3 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -1,19 +1,19 @@ package common import ( - "crypto/subtle" - "html" - "io" - "net" - "net/http" - "os" - "regexp" - "strconv" - "strings" - "time" + "crypto/subtle" + "html" + "io" + "net" + "net/http" + "os" + "regexp" + "strconv" + "strings" + "time" - "github.com/Azareal/Gosora/common/phrases" - "github.com/Azareal/Gosora/uutils" + "git.tuxpa.in/a/gosora/common/phrases" + "git.tuxpa.in/a/gosora/uutils" ) // nolint diff --git a/common/search.go b/common/search.go index 63038702..cd7beae3 100644 --- a/common/search.go +++ b/common/search.go @@ -1,11 +1,11 @@ package common import ( - "database/sql" - "errors" - "strconv" + "database/sql" + "errors" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var RepliesSearch Searcher diff --git a/common/settings.go b/common/settings.go index a6c0497a..85e331a1 100644 --- a/common/settings.go +++ b/common/settings.go @@ -1,13 +1,13 @@ package common import ( - "database/sql" - "errors" - "strconv" - "strings" - "sync/atomic" + "database/sql" + "errors" + "strconv" + "strings" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var SettingBox atomic.Value // An atomic value pointing to a SettingBox diff --git a/common/subscription.go b/common/subscription.go index b78b51fe..24d00c43 100644 --- a/common/subscription.go +++ b/common/subscription.go @@ -1,9 +1,9 @@ package common import ( - "database/sql" + "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Subscriptions SubscriptionStore diff --git a/common/tasks.go b/common/tasks.go index 059672a7..2f4347ed 100644 --- a/common/tasks.go +++ b/common/tasks.go @@ -7,11 +7,11 @@ package common import ( - "database/sql" - "log" - "time" + "database/sql" + "log" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type TaskStmts struct { diff --git a/common/template_init.go b/common/template_init.go index ff6cf60b..4cf5bfb6 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -1,23 +1,23 @@ package common import ( - "fmt" - "html/template" - "io" - "io/ioutil" - "log" - "path/filepath" - "runtime" - "strconv" - "strings" - "sync" - "time" + "fmt" + "html/template" + "io" + "io/ioutil" + "log" + "path/filepath" + "runtime" + "strconv" + "strings" + "sync" + "time" - "github.com/Azareal/Gosora/common/alerts" - p "github.com/Azareal/Gosora/common/phrases" - tmpl "github.com/Azareal/Gosora/common/templates" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/Azareal/Gosora/uutils" + "git.tuxpa.in/a/gosora/common/alerts" + p "git.tuxpa.in/a/gosora/common/phrases" + tmpl "git.tuxpa.in/a/gosora/common/templates" + qgen "git.tuxpa.in/a/gosora/query_gen" + "git.tuxpa.in/a/gosora/uutils" ) var Ctemplates []string // TODO: Use this to filter out top level templates we don't need @@ -182,7 +182,7 @@ func CompileTemplates() error { c.SetConfig(config) c.SetBaseImportMap(map[string]string{ "io": "io", - "github.com/Azareal/Gosora/common": "c github.com/Azareal/Gosora/common", + "git.tuxpa.in/a/gosora/common": "c git.tuxpa.in/a/gosora/common", }) c.SetBuildTags("!no_templategen") c.SetOverrideTrack(overriden) @@ -520,7 +520,7 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri c.SetBaseImportMap(map[string]string{ "io": "io", - "github.com/Azareal/Gosora/common/alerts": "github.com/Azareal/Gosora/common/alerts", + "git.tuxpa.in/a/gosora/common/alerts": "git.tuxpa.in/a/gosora/common/alerts", }) // TODO: Check what sort of path is sent exactly and use it here @@ -532,7 +532,7 @@ func compileJSTemplates(wg *sync.WaitGroup, c *tmpl.CTemplateSet, themeName stri c.SetBaseImportMap(map[string]string{ "io": "io", - "github.com/Azareal/Gosora/common": "c github.com/Azareal/Gosora/common", + "git.tuxpa.in/a/gosora/common": "c git.tuxpa.in/a/gosora/common", }) // TODO: Fix the import loop so we don't have to use this hack anymore c.SetBuildTags("!no_templategen,tmplgentopic") diff --git a/common/templates/templates.go b/common/templates/templates.go index fdbb68b1..8bf338b5 100644 --- a/common/templates/templates.go +++ b/common/templates/templates.go @@ -20,7 +20,7 @@ import ( var textOverlapList = make(map[string]int) // TODO: Stop hard-coding this here -var langPkg = "github.com/Azareal/Gosora/common/phrases" +var langPkg = "git.tuxpa.in/a/gosora/common/phrases" type VarItem struct { Name string @@ -241,7 +241,7 @@ func (c *CTemplateSet) CompileByLoggedin(name, fileDir, expects string, expectsI } fname += "_" + c.themeName } - c.importMap["github.com/Azareal/Gosora/common"] = "c github.com/Azareal/Gosora/common" + c.importMap["git.tuxpa.in/a/gosora/common"] = "c git.tuxpa.in/a/gosora/common" c.fsb.Reset() stub = `package ` + c.config.PackageName + "\n" + importList + "\n" @@ -1319,7 +1319,7 @@ ArgLoop: // TODO: Validate that this is actually a time.Time //litString("time.Since("+leftParam+").String()", false) c.importMap["time"] = "time" - c.importMap["github.com/Azareal/Gosora/uutils"] = "github.com/Azareal/Gosora/uutils" + c.importMap["git.tuxpa.in/a/gosora/uutils"] = "git.tuxpa.in/a/gosora/uutils" litString("time.Duration(uutils.Nanotime() - "+leftParam+").String()", false) break ArgLoop case "dock": diff --git a/common/theme.go b/common/theme.go index ba942af7..a0cc5948 100644 --- a/common/theme.go +++ b/common/theme.go @@ -2,26 +2,26 @@ package common import ( - "bytes" - "crypto/sha256" - "database/sql" - "encoding/base64" - "encoding/hex" - "errors" - htmpl "html/template" - "io" - "io/ioutil" - "log" - "mime" - "net/http" - "os" - "path/filepath" - "reflect" - "strconv" - "strings" - "text/template" + "bytes" + "crypto/sha256" + "database/sql" + "encoding/base64" + "encoding/hex" + "errors" + htmpl "html/template" + "io" + "io/ioutil" + "log" + "mime" + "net/http" + "os" + "path/filepath" + "reflect" + "strconv" + "strings" + "text/template" - p "github.com/Azareal/Gosora/common/phrases" + p "git.tuxpa.in/a/gosora/common/phrases" ) var ErrNoDefaultTheme = errors.New("The default theme isn't registered in the system") diff --git a/common/theme_list.go b/common/theme_list.go index 7ef0d154..a312e80b 100644 --- a/common/theme_list.go +++ b/common/theme_list.go @@ -1,21 +1,21 @@ package common import ( - "database/sql" - "encoding/json" - "errors" - "html/template" - "io" - "io/ioutil" - "log" - "net/http" - "os" - "path/filepath" - "strings" - "sync" - "sync/atomic" + "database/sql" + "encoding/json" + "errors" + "html/template" + "io" + "io/ioutil" + "log" + "net/http" + "os" + "path/filepath" + "strings" + "sync" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Something more thread-safe diff --git a/common/thumbnailer.go b/common/thumbnailer.go index 19492a24..e34d69d2 100644 --- a/common/thumbnailer.go +++ b/common/thumbnailer.go @@ -1,17 +1,17 @@ package common import ( - "image" - "image/gif" - "image/jpeg" - "image/png" - "os" - "strconv" + "image" + "image/gif" + "image/jpeg" + "image/png" + "os" + "strconv" - "golang.org/x/image/tiff" + "golang.org/x/image/tiff" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/pkg/errors" + qgen "git.tuxpa.in/a/gosora/query_gen" + "github.com/pkg/errors" ) func ThumbTask(thumbChan chan bool) { diff --git a/common/tickloop.go b/common/tickloop.go index 03779fa8..7a8a8a94 100644 --- a/common/tickloop.go +++ b/common/tickloop.go @@ -1,16 +1,16 @@ package common import ( - "fmt" - "log" - "strconv" - "strings" - "sync/atomic" - "time" + "fmt" + "log" + "strconv" + "strings" + "sync/atomic" + "time" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/Azareal/Gosora/uutils" - "github.com/pkg/errors" + qgen "git.tuxpa.in/a/gosora/query_gen" + "git.tuxpa.in/a/gosora/uutils" + "github.com/pkg/errors" ) var CTickLoop *TickLoop diff --git a/common/topic.go b/common/topic.go index 1d7b2baf..a68af843 100644 --- a/common/topic.go +++ b/common/topic.go @@ -7,18 +7,18 @@ package common import ( - "database/sql" - "html" - "html/template" + "database/sql" + "html" + "html/template" - "strconv" - "strings" - "time" + "strconv" + "strings" + "time" - //"log" + //"log" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // This is also in reply.go diff --git a/common/topic_list.go b/common/topic_list.go index 7c214e61..ba3d7a79 100644 --- a/common/topic_list.go +++ b/common/topic_list.go @@ -1,13 +1,13 @@ package common import ( - "database/sql" - "fmt" - "strconv" - "sync" - "time" + "database/sql" + "fmt" + "strconv" + "sync" + "time" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var TopicList TopicListInt diff --git a/common/topic_store.go b/common/topic_store.go index 4872795e..7cefacc4 100644 --- a/common/topic_store.go +++ b/common/topic_store.go @@ -7,12 +7,12 @@ package common import ( - "database/sql" - "errors" - "strconv" - "strings" + "database/sql" + "errors" + "strconv" + "strings" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Add the watchdog goroutine diff --git a/common/user.go b/common/user.go index 9b4e52a2..11a23022 100644 --- a/common/user.go +++ b/common/user.go @@ -7,16 +7,16 @@ package common import ( - "database/sql" - "errors" - "strconv" - "strings" - "time" + "database/sql" + "errors" + "strconv" + "strings" + "time" - //"log" + //"log" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/go-sql-driver/mysql" + qgen "git.tuxpa.in/a/gosora/query_gen" + "github.com/go-sql-driver/mysql" ) // TODO: Replace any literals with this diff --git a/common/user_store.go b/common/user_store.go index 7d0cfc97..b2cfa3e5 100644 --- a/common/user_store.go +++ b/common/user_store.go @@ -1,12 +1,12 @@ package common import ( - "database/sql" - "errors" - "strconv" + "database/sql" + "errors" + "strconv" - qgen "github.com/Azareal/Gosora/query_gen" - "golang.org/x/crypto/bcrypt" + qgen "git.tuxpa.in/a/gosora/query_gen" + "golang.org/x/crypto/bcrypt" ) // TODO: Add the watchdog goroutine diff --git a/common/websockets.go b/common/websockets.go index f0b83cb0..5cf54522 100644 --- a/common/websockets.go +++ b/common/websockets.go @@ -1,3 +1,4 @@ +//go:build !no_ws // +build !no_ws /* @@ -9,20 +10,20 @@ package common import ( - "bytes" - "errors" - "fmt" - "net/http" - "runtime" - "strconv" - "strings" - "sync" - "time" + "bytes" + "errors" + "fmt" + "net/http" + "runtime" + "strconv" + "strings" + "sync" + "time" - p "github.com/Azareal/Gosora/common/phrases" - "github.com/Azareal/gopsutil/cpu" - "github.com/Azareal/gopsutil/mem" - "github.com/gorilla/websocket" + p "git.tuxpa.in/a/gosora/common/phrases" + "github.com/Azareal/gopsutil/cpu" + "github.com/Azareal/gopsutil/mem" + "github.com/gorilla/websocket" ) // TODO: Disable WebSockets on high load? Add a Control Panel interface for disabling it? diff --git a/common/widget.go b/common/widget.go index 628a9f51..89952f26 100644 --- a/common/widget.go +++ b/common/widget.go @@ -1,13 +1,13 @@ package common import ( - "database/sql" - "encoding/json" - "strconv" - "strings" - "sync/atomic" + "database/sql" + "encoding/json" + "strconv" + "strings" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type WidgetStmts struct { diff --git a/common/widget_wol.go b/common/widget_wol.go index 8b31c9a3..87539947 100644 --- a/common/widget_wol.go +++ b/common/widget_wol.go @@ -1,12 +1,12 @@ package common import ( - "bytes" - //"log" - "net/http/httptest" + "bytes" + //"log" + "net/http/httptest" - p "github.com/Azareal/Gosora/common/phrases" - min "github.com/Azareal/Gosora/common/templates" + p "git.tuxpa.in/a/gosora/common/phrases" + min "git.tuxpa.in/a/gosora/common/templates" ) type wolUsers struct { diff --git a/common/widget_wol_context.go b/common/widget_wol_context.go index 1de263dc..31fd25be 100644 --- a/common/widget_wol_context.go +++ b/common/widget_wol_context.go @@ -1,29 +1,29 @@ package common -import "github.com/Azareal/Gosora/common/phrases" +import "git.tuxpa.in/a/gosora/common/phrases" func wolContextRender(widget *Widget, hvars interface{}) (string, error) { - header := hvars.(*Header) - if header.Zone != "view_topic" { - return "", nil - } - var ucount int - var users []*User - topicMutex.RLock() - topic, ok := topicWatchers[header.ZoneID] - if ok { - ucount = len(topic) - if ucount < 30 { - users = make([]*User, len(topic)) - i := 0 - for wsUser, _ := range topic { - users[i] = wsUser.User - i++ - } - } - } - topicMutex.RUnlock() - wol := &wolUsers{header, phrases.GetTmplPhrase("widget.online_view_topic_name"), users, ucount} - e := header.Theme.RunTmpl("widget_online", wol, header.Writer) - return "", e + header := hvars.(*Header) + if header.Zone != "view_topic" { + return "", nil + } + var ucount int + var users []*User + topicMutex.RLock() + topic, ok := topicWatchers[header.ZoneID] + if ok { + ucount = len(topic) + if ucount < 30 { + users = make([]*User, len(topic)) + i := 0 + for wsUser, _ := range topic { + users[i] = wsUser.User + i++ + } + } + } + topicMutex.RUnlock() + wol := &wolUsers{header, phrases.GetTmplPhrase("widget.online_view_topic_name"), users, ucount} + e := header.Theme.RunTmpl("widget_online", wol, header.Writer) + return "", e } diff --git a/common/widgets.go b/common/widgets.go index 8cdbec3b..b9622d3d 100644 --- a/common/widgets.go +++ b/common/widgets.go @@ -2,17 +2,17 @@ package common import ( - "bytes" - "encoding/json" - "fmt" - "html/template" - "strings" - "sync" - "sync/atomic" + "bytes" + "encoding/json" + "fmt" + "html/template" + "strings" + "sync" + "sync/atomic" - min "github.com/Azareal/Gosora/common/templates" - "github.com/Azareal/Gosora/uutils" - "github.com/pkg/errors" + min "git.tuxpa.in/a/gosora/common/templates" + "git.tuxpa.in/a/gosora/uutils" + "github.com/pkg/errors" ) // TODO: Clean this file up diff --git a/common/word_filters.go b/common/word_filters.go index e4c8e668..99144d05 100644 --- a/common/word_filters.go +++ b/common/word_filters.go @@ -1,10 +1,10 @@ package common import ( - "database/sql" - "sync/atomic" + "database/sql" + "sync/atomic" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // TODO: Move some features into methods on this? diff --git a/database.go b/database.go index a115b7fe..37ca28d9 100644 --- a/database.go +++ b/database.go @@ -1,11 +1,11 @@ package main import ( - "database/sql" - "log" + "database/sql" + "log" - c "github.com/Azareal/Gosora/common" - "github.com/pkg/errors" + c "git.tuxpa.in/a/gosora/common" + "github.com/pkg/errors" ) var stmts *Stmts diff --git a/docs/configuration.md b/docs/configuration.md index b5ce5d13..86f8e375 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -14,9 +14,9 @@ Dev is for a few flags which help out with the development of Gosora. Plugin which you may not have run into is a category in which plugins can define their own custom configuration settings. -An example of what the file might look like: https://github.com/Azareal/Gosora/blob/master/config/config_example.json +An example of what the file might look like: https://git.tuxpa.in/a/gosora/blob/master/config/config_example.json -Other configuration files: [config/weakpass.json](https://github.com/Azareal/Gosora/blob/master/docs/weak_passwords.md), [config/emoji.json](https://github.com/Azareal/Gosora/blob/master/docs/emoji.md) (WIP) +Other configuration files: [config/weakpass.json](https://git.tuxpa.in/a/gosora/blob/master/docs/weak_passwords.md), [config/emoji.json](https://git.tuxpa.in/a/gosora/blob/master/docs/emoji.md) (WIP) # Site @@ -36,7 +36,7 @@ EnableEmails - Determines whether the SMTP mail subsystem is enabled. The experi HasProxy - Brittle, but lets you set whether you're sitting behind a proxy like Cloudflare. Unknown effects with reverse-proxies like Nginx. -Language - The language you want to use. Defaults to english. Please consult [internationalisation](https://github.com/Azareal/Gosora/blob/master/docs/internationalisation.md) for details. +Language - The language you want to use. Defaults to english. Please consult [internationalisation](https://git.tuxpa.in/a/gosora/blob/master/docs/internationalisation.md) for details. # Config diff --git a/docs/installation.md b/docs/installation.md index 95b52feb..8fe65a93 100644 --- a/docs/installation.md +++ b/docs/installation.md @@ -17,7 +17,7 @@ First, we need somewhere for the software to live, if you're familiar with Linux First, we'll navigate to our home folder by typing: `cd ~` -And then, we'll going to pull a copy of Gosora off the git server with: `git clone https://github.com/Azareal/Gosora gosora` +And then, we'll going to pull a copy of Gosora off the git server with: `git clone https://git.tuxpa.in/a/gosora gosora` We can now hop into the newly created folder with the same command we used for getting to the home folder: @@ -63,7 +63,7 @@ mkdir gosora cd gosora -git clone https://github.com/Azareal/Gosora src +git clone https://git.tuxpa.in/a/gosora src chown -R gosora ../gosora @@ -99,7 +99,7 @@ We will also want to setup a service: # Additional Configuration -For things like HTTPS, you might also need to [modify your config.json](https://github.com/Azareal/Gosora/blob/master/docs/configuration.md) file after installing Gosora to get it working. +For things like HTTPS, you might also need to [modify your config.json](https://git.tuxpa.in/a/gosora/blob/master/docs/configuration.md) file after installing Gosora to get it working. You can get a free private key and certificate pair from Let's Encrypt or Cloudflare. @@ -125,7 +125,7 @@ For more info, you might want to take a gander inside the `./run-linux` and `./i Linux: ```bash -git clone https://github.com/Azareal/Gosora gosora +git clone https://git.tuxpa.in/a/gosora gosora cd gosora @@ -181,7 +181,7 @@ easyjson -pkg common Windows: ```batch -git clone https://github.com/Azareal/Gosora gosora +git clone https://git.tuxpa.in/a/gosora gosora cd gosora diff --git a/docs/updating.md b/docs/updating.md index 0e635c5f..46fe6eaf 100644 --- a/docs/updating.md +++ b/docs/updating.md @@ -2,7 +2,7 @@ The update system is currently under development, but you can run `dev-update.bat` to update your instance to the latest commit and to update the associated database schema, etc. -If you run into any issues doing so, please open an issue: https://github.com/Azareal/Gosora/issues/new +If you run into any issues doing so, please open an issue: https://git.tuxpa.in/a/gosora/issues/new If you want to manually patch Gosora rather than relying on the above scripts to do it, you'll first want to save your changes with `git stash`, and then, you'll overwrite the files with the new ones with `git pull origin master`, and then, you can re-apply your custom changes with `git stash apply` @@ -14,7 +14,7 @@ Once you've done that, you just need to run `patcher.exe` to apply the latest pa The update system is currently under development, but you can run `dev-update-linux` to update your instance to the latest commit and to update the associated database schema, etc. -If you run into any issues doing so, please open an issue: https://github.com/Azareal/Gosora/issues/new +If you run into any issues doing so, please open an issue: https://git.tuxpa.in/a/gosora/issues/new If you want to manually patch Gosora rather than relying on the above scripts to do it, you'll first want to save your changes with `git stash`, and then, you'll overwrite the files with the new ones with `git pull origin master`, and then, you'll re-apply your changes with `git stash apply`. @@ -29,7 +29,7 @@ You will first want to follow the instructions in the section for updating depen The update system is currently under development, but you can run `quick-update-linux` in `/home/gosora/src`to update your instance to the latest commit and to update the associated database schema, etc. -If you run into any issues doing so, please open an issue: https://github.com/Azareal/Gosora/issues/new +If you run into any issues doing so, please open an issue: https://git.tuxpa.in/a/gosora/issues/new If you're using a systemd service, then you might want to switch to the `gosora` user with `su gosora` (you may be prompted for the password to the user), you can switch back by typing `exit`. If this is the first time you've done an update as the `gosora` user, then you might have to configure Git, simply do: diff --git a/experimental/plugin_geoip.go b/experimental/plugin_geoip.go index 6b6d51a4..be52b77d 100644 --- a/experimental/plugin_geoip.go +++ b/experimental/plugin_geoip.go @@ -1,20 +1,22 @@ package main -import c "github.com/Azareal/Gosora/common" -import "github.com/oschwald/geoip2-golang" +import ( + c "git.tuxpa.in/a/gosora/common" + "github.com/oschwald/geoip2-golang" +) -var geoipDB *geoip.DB +var geoipDB *geoip2.Reader var geoipDBLocation = "geoip_db.mmdb" func init() { - c.Plugins.Add(&c.Plugin{UName: "geoip", Name: "Geoip", Author: "Azareal", Init: initGeoip, Deactivate: deactivateGeoip}) + c.Plugins.Add(&c.Plugin{UName: "geoip", Name: "Geoip", Author: "Azareal", Init: initGeoip, Deactivate: deactivateGeoip}) } func initGeoip(plugin *c.Plugin) (err error) { - geoipDB, err = geoip2.Open(geoipDBLocation) - return err + geoipDB, err = geoip2.Open(geoipDBLocation) + return err } func deactivateGeoip(plugin *c.Plugin) { - geoipDB.Close() + geoipDB.Close() } diff --git a/experimental/plugin_sendmail.go b/experimental/plugin_sendmail.go index b2d6b86c..5eb7547f 100644 --- a/experimental/plugin_sendmail.go +++ b/experimental/plugin_sendmail.go @@ -1,17 +1,17 @@ package main import ( - "errors" - "io" - "os/exec" - "runtime" + "errors" + "io" + "os/exec" + "runtime" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) /* - Sending emails in a way you really shouldn't be sending them. - This method doesn't require a SMTP server, but has higher chances of an email being rejected or being seen as spam. Use at your own risk. Only for Linux as Windows doesn't have Sendmail. + Sending emails in a way you really shouldn't be sending them. + This method doesn't require a SMTP server, but has higher chances of an email being rejected or being seen as spam. Use at your own risk. Only for Linux as Windows doesn't have Sendmail. */ func init() { // Don't bother registering this plugin on platforms other than Linux diff --git a/extend/adventure/plugin.json b/extend/adventure/plugin.json index 383999e6..ef0c31e2 100644 --- a/extend/adventure/plugin.json +++ b/extend/adventure/plugin.json @@ -2,6 +2,6 @@ "UName":"adventure", "Name":"Adventure", "Author":"Azareal", - "URL":"https://github.com/Azareal/Gosora", + "URL":"https://git.tuxpa.in/a/gosora", "Skip":true } \ No newline at end of file diff --git a/extend/guilds/lib/guild_store.go b/extend/guilds/lib/guild_store.go index 79701557..b152afb4 100644 --- a/extend/guilds/lib/guild_store.go +++ b/extend/guilds/lib/guild_store.go @@ -3,7 +3,7 @@ package guilds import ( "database/sql" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var Gstore GuildStore diff --git a/extend/guilds/lib/guilds.go b/extend/guilds/lib/guilds.go index a44927d7..53d857f3 100644 --- a/extend/guilds/lib/guilds.go +++ b/extend/guilds/lib/guilds.go @@ -1,4 +1,4 @@ -package guilds // import "github.com/Azareal/Gosora/extend/guilds/lib" +package guilds // import "git.tuxpa.in/a/gosora/extend/guilds/lib" import ( "bytes" @@ -10,8 +10,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/routes" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/routes" ) // A blank list to fill out that parameter in Page for routes which don't use it @@ -62,6 +62,7 @@ type Page struct { // ListPage is a page struct for constructing a list of every guild type ListPage struct { Title string + User *c.User Header *c.Header GuildList []*Guild } diff --git a/extend/guilds/plugin.json b/extend/guilds/plugin.json index b35e87f6..a2d7087c 100644 --- a/extend/guilds/plugin.json +++ b/extend/guilds/plugin.json @@ -2,6 +2,6 @@ "UName":"guilds", "Name":"Guilds", "Author":"Azareal", - "URL":"https://github.com/Azareal/Gosora", + "URL":"https://git.tuxpa.in/a/gosora", "Skip":true } \ No newline at end of file diff --git a/extend/guilds/plugin_guilds.go b/extend/guilds/plugin_guilds.go index 1c71557e..aa06ac4e 100644 --- a/extend/guilds/plugin_guilds.go +++ b/extend/guilds/plugin_guilds.go @@ -1,8 +1,8 @@ package main import ( - c "github.com/Azareal/Gosora/common" - guilds "github.com/Azareal/Gosora/extend/guilds/lib" + c "git.tuxpa.in/a/gosora/common" + guilds "git.tuxpa.in/a/gosora/extend/guilds/lib" ) // TODO: Add a better way of splitting up giant plugins like this diff --git a/extend/heytherejs/plugin.json b/extend/heytherejs/plugin.json index 5862681c..4ccf4f40 100644 --- a/extend/heytherejs/plugin.json +++ b/extend/heytherejs/plugin.json @@ -2,6 +2,6 @@ "UName":"heytherejs", "Name":"HeythereJS", "Author":"Azareal", - "URL":"https://github.com/Azareal/Gosora", + "URL":"https://git.tuxpa.in/a/gosora", "Main":"main.js" } \ No newline at end of file diff --git a/extend/plugin_adventure.go b/extend/plugin_adventure.go index 95d9ba75..0aa20ee6 100644 --- a/extend/plugin_adventure.go +++ b/extend/plugin_adventure.go @@ -1,23 +1,23 @@ // WIP - Experimental adventure plugin, this might find a new home soon, but it's here to stress test Gosora's extensibility for now package extend -import c "github.com/Azareal/Gosora/common" +import c "git.tuxpa.in/a/gosora/common" func init() { - c.Plugins.Add(&c.Plugin{ - UName: "adventure", - Name: "Adventure", - Tag: "WIP", - Author: "Azareal", - URL: "https://github.com/Azareal", - Init: initAdventure, - Deactivate: deactivateAdventure, - Install: installAdventure, - }) + c.Plugins.Add(&c.Plugin{ + UName: "adventure", + Name: "Adventure", + Tag: "WIP", + Author: "Azareal", + URL: "https://github.com/Azareal", + Init: initAdventure, + Deactivate: deactivateAdventure, + Install: installAdventure, + }) } func initAdventure(pl *c.Plugin) error { - return nil + return nil } // TODO: Change the signature to return an error? @@ -25,5 +25,5 @@ func deactivateAdventure(pl *c.Plugin) { } func installAdventure(pl *c.Plugin) error { - return nil + return nil } diff --git a/extend/plugin_bbcode.go b/extend/plugin_bbcode.go index 24f2df13..18eb0dd9 100644 --- a/extend/plugin_bbcode.go +++ b/extend/plugin_bbcode.go @@ -1,13 +1,13 @@ package extend import ( - "bytes" - "math/rand" - "regexp" - "strconv" - "time" + "bytes" + "math/rand" + "regexp" + "strconv" + "time" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) var bbcodeRandom *rand.Rand diff --git a/extend/plugin_heythere.go b/extend/plugin_heythere.go index 0d705945..9d989d58 100644 --- a/extend/plugin_heythere.go +++ b/extend/plugin_heythere.go @@ -1,26 +1,26 @@ package extend -import c "github.com/Azareal/Gosora/common" +import c "git.tuxpa.in/a/gosora/common" func init() { - c.Plugins.Add(&c.Plugin{UName: "heythere", Name: "Hey There", Author: "Azareal", URL: "https://github.com/Azareal", Init: initHeythere, Deactivate: deactivateHeythere}) + c.Plugins.Add(&c.Plugin{UName: "heythere", Name: "Hey There", Author: "Azareal", URL: "https://github.com/Azareal", Init: initHeythere, Deactivate: deactivateHeythere}) } // initHeythere is separate from init() as we don't want the plugin to run if the plugin is disabled func initHeythere(plugin *c.Plugin) error { - plugin.AddHook("topic_reply_row_assign", heythereReply) - return nil + plugin.AddHook("topic_reply_row_assign", heythereReply) + return nil } func deactivateHeythere(plugin *c.Plugin) { - plugin.RemoveHook("topic_reply_row_assign", heythereReply) + plugin.RemoveHook("topic_reply_row_assign", heythereReply) } func heythereReply(data ...interface{}) interface{} { - currentUser := data[0].(*c.TopicPage).Header.CurrentUser - reply := data[1].(*c.ReplyUser) - reply.Content = "Hey there, " + currentUser.Name + "!" - reply.ContentHtml = "Hey there, " + currentUser.Name + "!" - reply.Tag = "Auto" - return nil + currentUser := data[0].(*c.TopicPage).Header.CurrentUser + reply := data[1].(*c.ReplyUser) + reply.Content = "Hey there, " + currentUser.Name + "!" + reply.ContentHtml = "Hey there, " + currentUser.Name + "!" + reply.Tag = "Auto" + return nil } diff --git a/extend/plugin_hyperdrive.go b/extend/plugin_hyperdrive.go index 5a69ff71..d7d85cc4 100644 --- a/extend/plugin_hyperdrive.go +++ b/extend/plugin_hyperdrive.go @@ -2,18 +2,18 @@ package extend import ( - //"log" - "bytes" - "errors" - "net/http" - "net/http/httptest" - "strconv" - "strings" - "sync/atomic" - "time" + //"log" + "bytes" + "errors" + "net/http" + "net/http/httptest" + "strconv" + "strings" + "sync/atomic" + "time" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/routes" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/routes" ) var hyperspace *Hyperspace diff --git a/extend/plugin_markdown.go b/extend/plugin_markdown.go index 30776ba0..db551b1f 100644 --- a/extend/plugin_markdown.go +++ b/extend/plugin_markdown.go @@ -1,9 +1,9 @@ package extend import ( - "strings" + "strings" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) var markdownMaxDepth = 25 // How deep the parser will go when parsing Markdown strings diff --git a/extend/plugin_skeleton.go b/extend/plugin_skeleton.go index b15e2159..ebe98674 100644 --- a/extend/plugin_skeleton.go +++ b/extend/plugin_skeleton.go @@ -1,34 +1,34 @@ package extend -import c "github.com/Azareal/Gosora/common" +import c "git.tuxpa.in/a/gosora/common" func init() { - /* - The UName field should match the name in the URL minus plugin_ and the file extension. The same name as the map index. Please choose a unique name which won't clash with any other plugins. + /* + The UName field should match the name in the URL minus plugin_ and the file extension. The same name as the map index. Please choose a unique name which won't clash with any other plugins. - The Name field is for the friendly name of the plugin shown to the end-user. + The Name field is for the friendly name of the plugin shown to the end-user. - The Author field is the author of this plugin. The one who created it. + The Author field is the author of this plugin. The one who created it. - The URL field is for the URL pointing to the location where you can download this plugin. + The URL field is for the URL pointing to the location where you can download this plugin. - The Settings field points to the route for managing the settings for this plugin. Coming soon. + The Settings field points to the route for managing the settings for this plugin. Coming soon. - The Tag field is for providing a tiny snippet of information separate from the description. + The Tag field is for providing a tiny snippet of information separate from the description. - The Type field is for the type of the plugin. This gets changed to "go" automatically and we would suggest leaving "". + The Type field is for the type of the plugin. This gets changed to "go" automatically and we would suggest leaving "". - The Init field is for the initialisation handler which is called by the software to run this plugin. This expects a function. You should add your hooks, init logic, initial queries, etc. in said function. + The Init field is for the initialisation handler which is called by the software to run this plugin. This expects a function. You should add your hooks, init logic, initial queries, etc. in said function. - The Activate field is for the handler which is called by the software when the admin hits the Activate button in the control panel. This is separate from the Init handler which is called upon the start of the server and upon activation. Use nil if you don't have a handler for this. + The Activate field is for the handler which is called by the software when the admin hits the Activate button in the control panel. This is separate from the Init handler which is called upon the start of the server and upon activation. Use nil if you don't have a handler for this. - The Deactivate field is for the handler which is called by the software when the admin hits the Deactivate button in the control panel. You should clean-up any resources you have allocated, remove any hooks, close any statements, etc. within this handler. + The Deactivate field is for the handler which is called by the software when the admin hits the Deactivate button in the control panel. You should clean-up any resources you have allocated, remove any hooks, close any statements, etc. within this handler. - The Installation field is for one-off installation logic such as creating tables. You will need to run the separate uninstallation function for that. + The Installation field is for one-off installation logic such as creating tables. You will need to run the separate uninstallation function for that. - That Uninstallation field which is currently unused is for not only deactivating this plugin, but for purging any data associated with it such a new tables or data produced by the end-user. - */ - c.Plugins.Add(&c.Plugin{UName: "skeleton", Name: "Skeleton", Author: "Azareal", Init: initSkeleton, Activate: activateSkeleton, Deactivate: deactivateSkeleton}) + That Uninstallation field which is currently unused is for not only deactivating this plugin, but for purging any data associated with it such a new tables or data produced by the end-user. + */ + c.Plugins.Add(&c.Plugin{UName: "skeleton", Name: "Skeleton", Author: "Azareal", Init: initSkeleton, Activate: activateSkeleton, Deactivate: deactivateSkeleton}) } func initSkeleton(pl *c.Plugin) error { return nil } diff --git a/gen_mssql.go b/gen_mssql.go index 39fcb764..7759cfbe 100644 --- a/gen_mssql.go +++ b/gen_mssql.go @@ -1,3 +1,4 @@ +//go:build mssql // +build mssql // This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time. @@ -5,92 +6,92 @@ package main import "log" import "database/sql" -import "github.com/Azareal/Gosora/common" +import "git.tuxpa.in/a/gosora/common" // nolint type Stmts struct { - forumEntryExists *sql.Stmt - groupEntryExists *sql.Stmt - getForumTopics *sql.Stmt - addForumPermsToForum *sql.Stmt - updateEmail *sql.Stmt - setTempGroup *sql.Stmt - bumpSync *sql.Stmt - deleteActivityStreamMatch *sql.Stmt + forumEntryExists *sql.Stmt + groupEntryExists *sql.Stmt + getForumTopics *sql.Stmt + addForumPermsToForum *sql.Stmt + updateEmail *sql.Stmt + setTempGroup *sql.Stmt + bumpSync *sql.Stmt + deleteActivityStreamMatch *sql.Stmt - getActivityFeedByWatcher *sql.Stmt - getActivityCountByWatcher *sql.Stmt + getActivityFeedByWatcher *sql.Stmt + getActivityCountByWatcher *sql.Stmt - Mocks bool + Mocks bool } // nolint func _gen_mssql() (err error) { - common.DebugLog("Building the generated statements") - - common.DebugLog("Preparing forumEntryExists statement.") - stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") - if err != nil { - log.Print("Error in forumEntryExists statement.") - log.Print("Bad Query: ","SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") - return err - } - - common.DebugLog("Preparing groupEntryExists statement.") - stmts.groupEntryExists, err = db.Prepare("SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") - if err != nil { - log.Print("Error in groupEntryExists statement.") - log.Print("Bad Query: ","SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") - return err - } - - common.DebugLog("Preparing getForumTopics statement.") - stmts.getForumTopics, 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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") - if err != nil { - log.Print("Error in getForumTopics statement.") - log.Print("Bad Query: ","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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") - return err - } - - common.DebugLog("Preparing addForumPermsToForum statement.") - stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") - if err != nil { - log.Print("Error in addForumPermsToForum statement.") - log.Print("Bad Query: ","INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") - return err - } - - common.DebugLog("Preparing updateEmail statement.") - stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") - if err != nil { - log.Print("Error in updateEmail statement.") - log.Print("Bad Query: ","UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") - return err - } - - common.DebugLog("Preparing setTempGroup statement.") - stmts.setTempGroup, err = db.Prepare("UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") - if err != nil { - log.Print("Error in setTempGroup statement.") - log.Print("Bad Query: ","UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") - return err - } - - common.DebugLog("Preparing bumpSync statement.") - stmts.bumpSync, err = db.Prepare("UPDATE [sync] SET [last_update]= GETUTCDATE()") - if err != nil { - log.Print("Error in bumpSync statement.") - log.Print("Bad Query: ","UPDATE [sync] SET [last_update]= GETUTCDATE()") - return err - } - - common.DebugLog("Preparing deleteActivityStreamMatch statement.") - stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") - if err != nil { - log.Print("Error in deleteActivityStreamMatch statement.") - log.Print("Bad Query: ","DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") - return err - } - - return nil + common.DebugLog("Building the generated statements") + + common.DebugLog("Preparing forumEntryExists statement.") + stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") + if err != nil { + log.Print("Error in forumEntryExists statement.") + log.Print("Bad Query: ", "SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") + return err + } + + common.DebugLog("Preparing groupEntryExists statement.") + stmts.groupEntryExists, err = db.Prepare("SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") + if err != nil { + log.Print("Error in groupEntryExists statement.") + log.Print("Bad Query: ", "SELECT [gid] FROM [users_groups] WHERE [name] = '' ORDER BY gid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY") + return err + } + + common.DebugLog("Preparing getForumTopics statement.") + stmts.getForumTopics, 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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") + if err != nil { + log.Print("Error in getForumTopics statement.") + log.Print("Bad Query: ", "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] = ?1 ORDER BY topics.sticky DESC,topics.lastReplyAt DESC,topics.createdBy DESC") + return err + } + + common.DebugLog("Preparing addForumPermsToForum statement.") + stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") + if err != nil { + log.Print("Error in addForumPermsToForum statement.") + log.Print("Bad Query: ", "INSERT INTO [forums_permissions] ([gid],[fid],[preset],[permissions]) VALUES (?,?,?,?)") + return err + } + + common.DebugLog("Preparing updateEmail statement.") + stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") + if err != nil { + log.Print("Error in updateEmail statement.") + log.Print("Bad Query: ", "UPDATE [emails] SET [email]= ?,[uid]= ?,[validated]= ?,[token]= ? WHERE [email] = ?") + return err + } + + common.DebugLog("Preparing setTempGroup statement.") + stmts.setTempGroup, err = db.Prepare("UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") + if err != nil { + log.Print("Error in setTempGroup statement.") + log.Print("Bad Query: ", "UPDATE [users] SET [temp_group]= ? WHERE [uid] = ?") + return err + } + + common.DebugLog("Preparing bumpSync statement.") + stmts.bumpSync, err = db.Prepare("UPDATE [sync] SET [last_update]= GETUTCDATE()") + if err != nil { + log.Print("Error in bumpSync statement.") + log.Print("Bad Query: ", "UPDATE [sync] SET [last_update]= GETUTCDATE()") + return err + } + + common.DebugLog("Preparing deleteActivityStreamMatch statement.") + stmts.deleteActivityStreamMatch, err = db.Prepare("DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") + if err != nil { + log.Print("Error in deleteActivityStreamMatch statement.") + log.Print("Bad Query: ", "DELETE FROM [activity_stream_matches] WHERE [watcher] = ? AND [asid] = ?") + return err + } + + return nil } diff --git a/gen_mysql.go b/gen_mysql.go index 9bc78325..fdb14441 100644 --- a/gen_mysql.go +++ b/gen_mysql.go @@ -1,13 +1,18 @@ +//go:build !pgsql && !mssql // +build !pgsql,!mssql /* This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time. */ package main -import "log" -import "database/sql" -import "github.com/Azareal/Gosora/common" -//import "github.com/Azareal/Gosora/query_gen" +import ( + "database/sql" + "log" + + "git.tuxpa.in/a/gosora/common" +) + +//import "git.tuxpa.in/a/gosora/query_gen" // nolint type Stmts struct { diff --git a/gen_pgsql.go b/gen_pgsql.go index eee23d8a..740d9157 100644 --- a/gen_pgsql.go +++ b/gen_pgsql.go @@ -1,3 +1,4 @@ +//go:build pgsql // +build pgsql // This file was generated by Gosora's Query Generator. Please try to avoid modifying this file, as it might change at any time. @@ -5,52 +6,52 @@ package main import "log" import "database/sql" -import "github.com/Azareal/Gosora/common" +import "git.tuxpa.in/a/gosora/common" // nolint type Stmts struct { - addForumPermsToForum *sql.Stmt - updateEmail *sql.Stmt - setTempGroup *sql.Stmt - bumpSync *sql.Stmt + addForumPermsToForum *sql.Stmt + updateEmail *sql.Stmt + setTempGroup *sql.Stmt + bumpSync *sql.Stmt - getActivityFeedByWatcher *sql.Stmt - getActivityCountByWatcher *sql.Stmt + getActivityFeedByWatcher *sql.Stmt + getActivityCountByWatcher *sql.Stmt - Mocks bool + Mocks bool } // nolint func _gen_pgsql() (err error) { - common.DebugLog("Building the generated statements") - - common.DebugLog("Preparing addForumPermsToForum statement.") - stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO \"forums_permissions\"(\"gid\",\"fid\",\"preset\",\"permissions\") VALUES (?,?,?,?)") - if err != nil { - log.Print("Error in addForumPermsToForum statement.") - return err - } - - common.DebugLog("Preparing updateEmail statement.") - stmts.updateEmail, err = db.Prepare("UPDATE \"emails\" SET `email`= ?,`uid`= ?,`validated`= ?,`token`= ? WHERE `email` = ?") - if err != nil { - log.Print("Error in updateEmail statement.") - return err - } - - common.DebugLog("Preparing setTempGroup statement.") - stmts.setTempGroup, err = db.Prepare("UPDATE \"users\" SET `temp_group`= ? WHERE `uid` = ?") - if err != nil { - log.Print("Error in setTempGroup statement.") - return err - } - - common.DebugLog("Preparing bumpSync statement.") - stmts.bumpSync, err = db.Prepare("UPDATE \"sync\" SET `last_update`= LOCALTIMESTAMP()") - if err != nil { - log.Print("Error in bumpSync statement.") - return err - } - - return nil + common.DebugLog("Building the generated statements") + + common.DebugLog("Preparing addForumPermsToForum statement.") + stmts.addForumPermsToForum, err = db.Prepare("INSERT INTO \"forums_permissions\"(\"gid\",\"fid\",\"preset\",\"permissions\") VALUES (?,?,?,?)") + if err != nil { + log.Print("Error in addForumPermsToForum statement.") + return err + } + + common.DebugLog("Preparing updateEmail statement.") + stmts.updateEmail, err = db.Prepare("UPDATE \"emails\" SET `email`= ?,`uid`= ?,`validated`= ?,`token`= ? WHERE `email` = ?") + if err != nil { + log.Print("Error in updateEmail statement.") + return err + } + + common.DebugLog("Preparing setTempGroup statement.") + stmts.setTempGroup, err = db.Prepare("UPDATE \"users\" SET `temp_group`= ? WHERE `uid` = ?") + if err != nil { + log.Print("Error in setTempGroup statement.") + return err + } + + common.DebugLog("Preparing bumpSync statement.") + stmts.bumpSync, err = db.Prepare("UPDATE \"sync\" SET `last_update`= LOCALTIMESTAMP()") + if err != nil { + log.Print("Error in bumpSync statement.") + return err + } + + return nil } diff --git a/gen_router.go b/gen_router.go index 1c7011f0..bf176976 100644 --- a/gen_router.go +++ b/gen_router.go @@ -11,11 +11,11 @@ import ( "errors" "net/http" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - "github.com/Azareal/Gosora/uutils" - "github.com/Azareal/Gosora/routes" - "github.com/Azareal/Gosora/routes/panel" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + "git.tuxpa.in/a/gosora/uutils" + "git.tuxpa.in/a/gosora/routes" + "git.tuxpa.in/a/gosora/routes/panel" //"github.com/andybalholm/brotli" ) diff --git a/general_test.go b/general_test.go index ac97b9fc..cf7f4718 100644 --- a/general_test.go +++ b/general_test.go @@ -1,25 +1,25 @@ package main import ( - "bytes" - "database/sql" - "log" - "net/http" - "net/http/httptest" - "runtime" - "runtime/debug" - "strconv" - "strings" - "testing" - "time" + "bytes" + "database/sql" + "log" + "net/http" + "net/http/httptest" + "runtime" + "runtime/debug" + "strconv" + "strings" + "testing" + "time" - "github.com/pkg/errors" + "github.com/pkg/errors" - c "github.com/Azareal/Gosora/common" - e "github.com/Azareal/Gosora/extend" - "github.com/Azareal/Gosora/install" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/Azareal/Gosora/routes" + c "git.tuxpa.in/a/gosora/common" + e "git.tuxpa.in/a/gosora/extend" + "git.tuxpa.in/a/gosora/install" + qgen "git.tuxpa.in/a/gosora/query_gen" + "git.tuxpa.in/a/gosora/routes" ) //var dbTest *sql.DB diff --git a/go.mod b/go.mod index 89fc88fb..02c7c8e4 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Azareal/Gosora +module git.tuxpa.in/a/gosora require ( github.com/Azareal/gopsutil v0.0.0-20170716174751-0763ca4e911d diff --git a/install/install.go b/install/install.go index 4dff8bd9..b8f1e6a6 100644 --- a/install/install.go +++ b/install/install.go @@ -1,9 +1,9 @@ package install import ( - "fmt" + "fmt" - qgen "github.com/Azareal/Gosora/query_gen" + qgen "git.tuxpa.in/a/gosora/query_gen" ) var adapters = make(map[string]InstallAdapter) diff --git a/install/mssql.go b/install/mssql.go index 4c2023ea..55fa2279 100644 --- a/install/mssql.go +++ b/install/mssql.go @@ -7,165 +7,165 @@ package install import ( - "bytes" - "database/sql" - "fmt" - "io/ioutil" - "log" - "net/url" - "path/filepath" - "strconv" - "strings" + "bytes" + "database/sql" + "fmt" + "io/ioutil" + "log" + "net/url" + "path/filepath" + "strconv" + "strings" - "github.com/Azareal/Gosora/query_gen" - _ "github.com/denisenkom/go-mssqldb" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/denisenkom/go-mssqldb" ) func init() { - adapters["mssql"] = &MssqlInstaller{dbHost: ""} + adapters["mssql"] = &MssqlInstaller{dbHost: ""} } type MssqlInstaller struct { - db *sql.DB - dbHost string - dbUsername string - dbPassword string - dbName string - dbInstance string - dbPort string + db *sql.DB + dbHost string + dbUsername string + dbPassword string + dbName string + dbInstance string + dbPort string } func (ins *MssqlInstaller) SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string) { - ins.dbHost = dbHost - ins.dbUsername = dbUsername - ins.dbPassword = dbPassword - ins.dbName = dbName - ins.dbInstance = "" // You can't set this from the installer right now, it allows you to connect to a named instance instead of a port - ins.dbPort = dbPort + ins.dbHost = dbHost + ins.dbUsername = dbUsername + ins.dbPassword = dbPassword + ins.dbName = dbName + ins.dbInstance = "" // You can't set this from the installer right now, it allows you to connect to a named instance instead of a port + ins.dbPort = dbPort } func (ins *MssqlInstaller) Name() string { - return "mssql" + return "mssql" } func (ins *MssqlInstaller) DefaultPort() string { - return "1433" + return "1433" } func (ins *MssqlInstaller) InitDatabase() (err error) { - query := url.Values{} - query.Add("database", ins.dbName) - u := &url.URL{ - Scheme: "sqlserver", - User: url.UserPassword(ins.dbUsername, ins.dbPassword), - Host: ins.dbHost + ":" + ins.dbPort, - Path: ins.dbInstance, - RawQuery: query.Encode(), - } - log.Print("u.String() ", u.String()) + query := url.Values{} + query.Add("database", ins.dbName) + u := &url.URL{ + Scheme: "sqlserver", + User: url.UserPassword(ins.dbUsername, ins.dbPassword), + Host: ins.dbHost + ":" + ins.dbPort, + Path: ins.dbInstance, + RawQuery: query.Encode(), + } + log.Print("u.String() ", u.String()) - db, err := sql.Open("mssql", u.String()) - if err != nil { - return err - } + db, err := sql.Open("mssql", u.String()) + if err != nil { + return err + } - // Make sure that the connection is alive.. - err = db.Ping() - if err != nil { - return err - } - fmt.Println("Successfully connected to the database") + // Make sure that the connection is alive.. + err = db.Ping() + if err != nil { + return err + } + fmt.Println("Successfully connected to the database") - // TODO: Create the database, if it doesn't exist + // TODO: Create the database, if it doesn't exist - // Ready the query builder - ins.db = db - qgen.Builder.SetConn(db) - return qgen.Builder.SetAdapter("mssql") + // Ready the query builder + ins.db = db + qgen.Builder.SetConn(db) + return qgen.Builder.SetAdapter("mssql") } func (ins *MssqlInstaller) TableDefs() (err error) { - //fmt.Println("Creating the tables") - files, _ := ioutil.ReadDir("./schema/mssql/") - for _, f := range files { - if !strings.HasPrefix(f.Name(), "query_") { - continue - } + //fmt.Println("Creating the tables") + files, _ := ioutil.ReadDir("./schema/mssql/") + for _, f := range files { + if !strings.HasPrefix(f.Name(), "query_") { + continue + } - var table, ext string - table = strings.TrimPrefix(f.Name(), "query_") - ext = filepath.Ext(table) - if ext != ".sql" { - continue - } - table = strings.TrimSuffix(table, ext) + var table, ext string + table = strings.TrimPrefix(f.Name(), "query_") + ext = filepath.Ext(table) + if ext != ".sql" { + continue + } + table = strings.TrimSuffix(table, ext) - // ? - This is mainly here for tests, although it might allow the installer to overwrite a production database, so we might want to proceed with caution - _, err = ins.db.Exec("DROP TABLE IF EXISTS [" + table + "];") - if err != nil { - fmt.Println("Failed query:", "DROP TABLE IF EXISTS ["+table+"]") - return err - } + // ? - This is mainly here for tests, although it might allow the installer to overwrite a production database, so we might want to proceed with caution + _, err = ins.db.Exec("DROP TABLE IF EXISTS [" + table + "];") + if err != nil { + fmt.Println("Failed query:", "DROP TABLE IF EXISTS ["+table+"]") + return err + } - fmt.Println("Creating table '" + table + "'") - data, err := ioutil.ReadFile("./schema/mssql/" + f.Name()) - if err != nil { - return err - } - data = bytes.TrimSpace(data) + fmt.Println("Creating table '" + table + "'") + data, err := ioutil.ReadFile("./schema/mssql/" + f.Name()) + if err != nil { + return err + } + data = bytes.TrimSpace(data) - _, err = ins.db.Exec(string(data)) - if err != nil { - fmt.Println("Failed query:", string(data)) - return err - } - } - return nil + _, err = ins.db.Exec(string(data)) + if err != nil { + fmt.Println("Failed query:", string(data)) + return err + } + } + return nil } func (ins *MssqlInstaller) InitialData() (err error) { - //fmt.Println("Seeding the tables") - data, err := ioutil.ReadFile("./schema/mssql/inserts.sql") - if err != nil { - return err - } - data = bytes.TrimSpace(data) + //fmt.Println("Seeding the tables") + data, err := ioutil.ReadFile("./schema/mssql/inserts.sql") + if err != nil { + return err + } + data = bytes.TrimSpace(data) - statements := bytes.Split(data, []byte(";")) - for key, statement := range statements { - if len(statement) == 0 { - continue - } + statements := bytes.Split(data, []byte(";")) + for key, statement := range statements { + if len(statement) == 0 { + continue + } - fmt.Println("Executing query #" + strconv.Itoa(key) + " " + string(statement)) - _, err = ins.db.Exec(string(statement)) - if err != nil { - return err - } - } - return nil + fmt.Println("Executing query #" + strconv.Itoa(key) + " " + string(statement)) + _, err = ins.db.Exec(string(statement)) + if err != nil { + return err + } + } + return nil } func (ins *MssqlInstaller) CreateAdmin() error { - return createAdmin() + return createAdmin() } func (ins *MssqlInstaller) DBHost() string { - return ins.dbHost + return ins.dbHost } func (ins *MssqlInstaller) DBUsername() string { - return ins.dbUsername + return ins.dbUsername } func (ins *MssqlInstaller) DBPassword() string { - return ins.dbPassword + return ins.dbPassword } func (ins *MssqlInstaller) DBName() string { - return ins.dbName + return ins.dbName } func (ins *MssqlInstaller) DBPort() string { - return ins.dbPort + return ins.dbPort } diff --git a/install/mysql.go b/install/mysql.go index 16cb992c..efb40b64 100644 --- a/install/mysql.go +++ b/install/mysql.go @@ -7,177 +7,177 @@ package install import ( - "bytes" - "database/sql" - "fmt" - "io/ioutil" - "os" - "path/filepath" - "strconv" - "strings" + "bytes" + "database/sql" + "fmt" + "io/ioutil" + "os" + "path/filepath" + "strconv" + "strings" - "github.com/Azareal/Gosora/query_gen" - _ "github.com/go-sql-driver/mysql" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/go-sql-driver/mysql" ) //var dbCollation string = "utf8mb4_general_ci" func init() { - adapters["mysql"] = &MysqlInstaller{dbHost: ""} + adapters["mysql"] = &MysqlInstaller{dbHost: ""} } type MysqlInstaller struct { - db *sql.DB - dbHost string - dbUsername string - dbPassword string - dbName string - dbPort string + db *sql.DB + dbHost string + dbUsername string + dbPassword string + dbName string + dbPort string } func (ins *MysqlInstaller) SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string) { - ins.dbHost = dbHost - ins.dbUsername = dbUsername - ins.dbPassword = dbPassword - ins.dbName = dbName - ins.dbPort = dbPort + ins.dbHost = dbHost + ins.dbUsername = dbUsername + ins.dbPassword = dbPassword + ins.dbName = dbName + ins.dbPort = dbPort } func (ins *MysqlInstaller) Name() string { - return "mysql" + return "mysql" } func (ins *MysqlInstaller) DefaultPort() string { - return "3306" + return "3306" } func (ins *MysqlInstaller) dbExists(dbName string) (bool, error) { - var waste string - err := ins.db.QueryRow("SHOW DATABASES LIKE '" + dbName + "'").Scan(&waste) - if err != nil && err != sql.ErrNoRows { - return false, err - } else if err == sql.ErrNoRows { - return false, nil - } - return true, nil + var waste string + err := ins.db.QueryRow("SHOW DATABASES LIKE '" + dbName + "'").Scan(&waste) + if err != nil && err != sql.ErrNoRows { + return false, err + } else if err == sql.ErrNoRows { + return false, nil + } + return true, nil } func (ins *MysqlInstaller) InitDatabase() (err error) { - _dbPassword := ins.dbPassword - if _dbPassword != "" { - _dbPassword = ":" + _dbPassword - } - db, err := sql.Open("mysql", ins.dbUsername+_dbPassword+"@tcp("+ins.dbHost+":"+ins.dbPort+")/") - if err != nil { - return err - } + _dbPassword := ins.dbPassword + if _dbPassword != "" { + _dbPassword = ":" + _dbPassword + } + db, err := sql.Open("mysql", ins.dbUsername+_dbPassword+"@tcp("+ins.dbHost+":"+ins.dbPort+")/") + if err != nil { + return err + } - // Make sure that the connection is alive.. - err = db.Ping() - if err != nil { - return err - } - fmt.Println("Successfully connected to the database") + // Make sure that the connection is alive.. + err = db.Ping() + if err != nil { + return err + } + fmt.Println("Successfully connected to the database") - ins.db = db - ok, err := ins.dbExists(ins.dbName) - if err != nil { - return err - } + ins.db = db + ok, err := ins.dbExists(ins.dbName) + if err != nil { + return err + } - if !ok { - fmt.Println("Unable to find the database. Attempting to create it") - _, err = db.Exec("CREATE DATABASE IF NOT EXISTS " + ins.dbName) - if err != nil { - return err - } - fmt.Println("The database was successfully created") - } + if !ok { + fmt.Println("Unable to find the database. Attempting to create it") + _, err = db.Exec("CREATE DATABASE IF NOT EXISTS " + ins.dbName) + if err != nil { + return err + } + fmt.Println("The database was successfully created") + } - /*fmt.Println("Switching to database ", ins.dbName) - _, err = db.Exec("USE " + ins.dbName) - if err != nil { - return err - }*/ - db.Close() + /*fmt.Println("Switching to database ", ins.dbName) + _, err = db.Exec("USE " + ins.dbName) + if err != nil { + return err + }*/ + db.Close() - db, err = sql.Open("mysql", ins.dbUsername+_dbPassword+"@tcp("+ins.dbHost+":"+ins.dbPort+")/"+ins.dbName) - if err != nil { - return err - } + db, err = sql.Open("mysql", ins.dbUsername+_dbPassword+"@tcp("+ins.dbHost+":"+ins.dbPort+")/"+ins.dbName) + if err != nil { + return err + } - // Make sure that the connection is alive.. - err = db.Ping() - if err != nil { - return err - } - fmt.Println("Successfully connected to the database") + // Make sure that the connection is alive.. + err = db.Ping() + if err != nil { + return err + } + fmt.Println("Successfully connected to the database") - // Ready the query builder - ins.db = db - qgen.Builder.SetConn(db) - return qgen.Builder.SetAdapter("mysql") + // Ready the query builder + ins.db = db + qgen.Builder.SetConn(db) + return qgen.Builder.SetAdapter("mysql") } func (ins *MysqlInstaller) createTable(f os.FileInfo) error { - table := strings.TrimPrefix(f.Name(), "query_") - ext := filepath.Ext(table) - if ext != ".sql" { - return nil - } - table = strings.TrimSuffix(table, ext) + table := strings.TrimPrefix(f.Name(), "query_") + ext := filepath.Ext(table) + if ext != ".sql" { + return nil + } + table = strings.TrimSuffix(table, ext) - // ? - This is mainly here for tests, although it might allow the installer to overwrite a production database, so we might want to proceed with caution - q := "DROP TABLE IF EXISTS `" + table + "`;" - _, err := ins.db.Exec(q) - if err != nil { - fmt.Println("Failed query:", q) - fmt.Println("e:", err) - return err - } + // ? - This is mainly here for tests, although it might allow the installer to overwrite a production database, so we might want to proceed with caution + q := "DROP TABLE IF EXISTS `" + table + "`;" + _, err := ins.db.Exec(q) + if err != nil { + fmt.Println("Failed query:", q) + fmt.Println("e:", err) + return err + } - data, err := ioutil.ReadFile("./schema/mysql/" + f.Name()) - if err != nil { - return err - } - data = bytes.TrimSpace(data) + data, err := ioutil.ReadFile("./schema/mysql/" + f.Name()) + if err != nil { + return err + } + data = bytes.TrimSpace(data) - q = string(data) - _, err = ins.db.Exec(q) - if err != nil { - fmt.Println("Failed query:", q) - fmt.Println("e:", err) - return err - } - fmt.Printf("Created table '%s'\n", table) + q = string(data) + _, err = ins.db.Exec(q) + if err != nil { + fmt.Println("Failed query:", q) + fmt.Println("e:", err) + return err + } + fmt.Printf("Created table '%s'\n", table) - return nil + return nil } func (ins *MysqlInstaller) TableDefs() (err error) { - fmt.Println("Creating the tables") - files, err := ioutil.ReadDir("./schema/mysql/") - if err != nil { - return err - } + fmt.Println("Creating the tables") + files, err := ioutil.ReadDir("./schema/mysql/") + if err != nil { + return err + } - _, err = ins.db.Exec("SET FOREIGN_KEY_CHECKS = 0;") - if err != nil { - return err - } + _, err = ins.db.Exec("SET FOREIGN_KEY_CHECKS = 0;") + if err != nil { + return err + } - for _, f := range files { - if !strings.HasPrefix(f.Name(), "query_") { - continue - } - err := ins.createTable(f) - if err != nil { - return err - } - } + for _, f := range files { + if !strings.HasPrefix(f.Name(), "query_") { + continue + } + err := ins.createTable(f) + if err != nil { + return err + } + } - _, err = ins.db.Exec("SET FOREIGN_KEY_CHECKS = 1;") - return err + _, err = ins.db.Exec("SET FOREIGN_KEY_CHECKS = 1;") + return err } // ? - Moved this here since it was breaking the installer, we need to add this at some point @@ -185,50 +185,50 @@ func (ins *MysqlInstaller) TableDefs() (err error) { /*INSERT INTO settings(`name`,`content`,`type`) VALUES ('meta_desc','','html-attribute');*/ func (ins *MysqlInstaller) InitialData() error { - fmt.Println("Seeding the tables") - data, err := ioutil.ReadFile("./schema/mysql/inserts.sql") - if err != nil { - return err - } - data = bytes.TrimSpace(data) + fmt.Println("Seeding the tables") + data, err := ioutil.ReadFile("./schema/mysql/inserts.sql") + if err != nil { + return err + } + data = bytes.TrimSpace(data) - statements := bytes.Split(data, []byte(";")) - for key, sBytes := range statements { - statement := string(sBytes) - if statement == "" { - continue - } - statement += ";" + statements := bytes.Split(data, []byte(";")) + for key, sBytes := range statements { + statement := string(sBytes) + if statement == "" { + continue + } + statement += ";" - fmt.Println("Executing query #" + strconv.Itoa(key) + " " + statement) - _, err = ins.db.Exec(statement) - if err != nil { - return err - } - } - return nil + fmt.Println("Executing query #" + strconv.Itoa(key) + " " + statement) + _, err = ins.db.Exec(statement) + if err != nil { + return err + } + } + return nil } func (ins *MysqlInstaller) CreateAdmin() error { - return createAdmin() + return createAdmin() } func (ins *MysqlInstaller) DBHost() string { - return ins.dbHost + return ins.dbHost } func (ins *MysqlInstaller) DBUsername() string { - return ins.dbUsername + return ins.dbUsername } func (ins *MysqlInstaller) DBPassword() string { - return ins.dbPassword + return ins.dbPassword } func (ins *MysqlInstaller) DBName() string { - return ins.dbName + return ins.dbName } func (ins *MysqlInstaller) DBPort() string { - return ins.dbPort + return ins.dbPort } diff --git a/install/pgsql.go b/install/pgsql.go index 163bd493..36d7f31a 100644 --- a/install/pgsql.go +++ b/install/pgsql.go @@ -8,105 +8,105 @@ package install import ( - "database/sql" - "errors" - "fmt" - "strings" + "database/sql" + "errors" + "fmt" + "strings" - "github.com/Azareal/Gosora/query_gen" - _ "github.com/go-sql-driver/mysql" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/go-sql-driver/mysql" ) // We don't need SSL to run an installer... Do we? var dbSslmode = "disable" func init() { - adapters["pgsql"] = &PgsqlInstaller{dbHost: ""} + adapters["pgsql"] = &PgsqlInstaller{dbHost: ""} } type PgsqlInstaller struct { - db *sql.DB - dbHost string - dbUsername string - dbPassword string - dbName string - dbPort string + db *sql.DB + dbHost string + dbUsername string + dbPassword string + dbName string + dbPort string } func (ins *PgsqlInstaller) SetConfig(dbHost string, dbUsername string, dbPassword string, dbName string, dbPort string) { - ins.dbHost = dbHost - ins.dbUsername = dbUsername - ins.dbPassword = dbPassword - ins.dbName = dbName - ins.dbPort = dbPort + ins.dbHost = dbHost + ins.dbUsername = dbUsername + ins.dbPassword = dbPassword + ins.dbName = dbName + ins.dbPort = dbPort } func (ins *PgsqlInstaller) Name() string { - return "pgsql" + return "pgsql" } func (ins *PgsqlInstaller) DefaultPort() string { - return "5432" + return "5432" } func (ins *PgsqlInstaller) InitDatabase() (err error) { - _dbPassword := ins.dbPassword - if _dbPassword != "" { - _dbPassword = " password=" + pgEscapeBit(_dbPassword) - } - db, err := sql.Open("postgres", "host='"+pgEscapeBit(ins.dbHost)+"' port='"+pgEscapeBit(ins.dbPort)+"' user='"+pgEscapeBit(ins.dbUsername)+"' dbname='"+pgEscapeBit(ins.dbName)+"'"+_dbPassword+" sslmode='"+dbSslmode+"'") - if err != nil { - return err - } + _dbPassword := ins.dbPassword + if _dbPassword != "" { + _dbPassword = " password=" + pgEscapeBit(_dbPassword) + } + db, err := sql.Open("postgres", "host='"+pgEscapeBit(ins.dbHost)+"' port='"+pgEscapeBit(ins.dbPort)+"' user='"+pgEscapeBit(ins.dbUsername)+"' dbname='"+pgEscapeBit(ins.dbName)+"'"+_dbPassword+" sslmode='"+dbSslmode+"'") + if err != nil { + return err + } - // Make sure that the connection is alive.. - err = db.Ping() - if err != nil { - return err - } - fmt.Println("Successfully connected to the database") + // Make sure that the connection is alive.. + err = db.Ping() + if err != nil { + return err + } + fmt.Println("Successfully connected to the database") - // TODO: Create the database, if it doesn't exist + // TODO: Create the database, if it doesn't exist - // Ready the query builder - ins.db = db - qgen.Builder.SetConn(db) - return qgen.Builder.SetAdapter("pgsql") + // Ready the query builder + ins.db = db + qgen.Builder.SetConn(db) + return qgen.Builder.SetAdapter("pgsql") } func (ins *PgsqlInstaller) TableDefs() (err error) { - return errors.New("TableDefs() not implemented") + return errors.New("TableDefs() not implemented") } func (ins *PgsqlInstaller) InitialData() (err error) { - return errors.New("InitialData() not implemented") + return errors.New("InitialData() not implemented") } func (ins *PgsqlInstaller) CreateAdmin() error { - return createAdmin() + return createAdmin() } func (ins *PgsqlInstaller) DBHost() string { - return ins.dbHost + return ins.dbHost } func (ins *PgsqlInstaller) DBUsername() string { - return ins.dbUsername + return ins.dbUsername } func (ins *PgsqlInstaller) DBPassword() string { - return ins.dbPassword + return ins.dbPassword } func (ins *PgsqlInstaller) DBName() string { - return ins.dbName + return ins.dbName } func (ins *PgsqlInstaller) DBPort() string { - return ins.dbPort + return ins.dbPort } func pgEscapeBit(bit string) string { - // TODO: Write a custom parser, so that backslashes work properly in the sql.Open string. Do something similar for the database driver, if possible? - return strings.Replace(bit, "'", "\\'", -1) + // TODO: Write a custom parser, so that backslashes work properly in the sql.Open string. Do something similar for the database driver, if possible? + return strings.Replace(bit, "'", "\\'", -1) } diff --git a/main.go b/main.go index 6297c342..552bb46a 100644 --- a/main.go +++ b/main.go @@ -5,39 +5,39 @@ * */ // Package main contains the main initialisation logic for Gosora -package main // import "github.com/Azareal/Gosora" +package main // import "git.tuxpa.in/a/gosora" import ( - "bytes" - "crypto/tls" - "flag" - "fmt" - "io" - "log" - "mime" - "net/http" - "os" - "os/signal" - "runtime" - "runtime/debug" - "runtime/pprof" - "strconv" - "strings" - "syscall" - "time" + "bytes" + "crypto/tls" + "flag" + "fmt" + "io" + "log" + "mime" + "net/http" + "os" + "os/signal" + "runtime" + "runtime/debug" + "runtime/pprof" + "strconv" + "strings" + "syscall" + "time" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - meta "github.com/Azareal/Gosora/common/meta" - p "github.com/Azareal/Gosora/common/phrases" - _ "github.com/Azareal/Gosora/extend" - qgen "github.com/Azareal/Gosora/query_gen" - "github.com/Azareal/Gosora/routes" - "github.com/Azareal/Gosora/uutils" - "github.com/fsnotify/fsnotify" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + meta "git.tuxpa.in/a/gosora/common/meta" + p "git.tuxpa.in/a/gosora/common/phrases" + _ "git.tuxpa.in/a/gosora/extend" + qgen "git.tuxpa.in/a/gosora/query_gen" + "git.tuxpa.in/a/gosora/routes" + "git.tuxpa.in/a/gosora/uutils" + "github.com/fsnotify/fsnotify" - //"github.com/lucas-clemente/quic-go/http3" - "github.com/pkg/errors" + //"github.com/lucas-clemente/quic-go/http3" + "github.com/pkg/errors" ) var router *GenRouter diff --git a/misc_test.go b/misc_test.go index ca880d5f..7e6bc215 100644 --- a/misc_test.go +++ b/misc_test.go @@ -1,23 +1,23 @@ package main import ( - "bytes" - "database/sql" - "fmt" - "io/ioutil" - "net/http" - "net/http/httptest" - "os" - "runtime/debug" - "strconv" - "testing" - "time" + "bytes" + "database/sql" + "fmt" + "io/ioutil" + "net/http" + "net/http/httptest" + "os" + "runtime/debug" + "strconv" + "testing" + "time" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/gauth" - "github.com/Azareal/Gosora/common/phrases" - "github.com/Azareal/Gosora/routes" - "github.com/pkg/errors" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/gauth" + "git.tuxpa.in/a/gosora/common/phrases" + "git.tuxpa.in/a/gosora/routes" + "github.com/pkg/errors" ) func miscinit(t *testing.T) { diff --git a/mssql.go b/mssql.go index c270f186..8c6a14d2 100644 --- a/mssql.go +++ b/mssql.go @@ -1,3 +1,4 @@ +//go:build mssql // +build mssql /* @@ -9,89 +10,89 @@ package main import ( - "database/sql" - "net/url" + "database/sql" + "net/url" - "github.com/Azareal/Gosora/common" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" - _ "github.com/denisenkom/go-mssqldb" + "git.tuxpa.in/a/gosora/common" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/denisenkom/go-mssqldb" ) var dbInstance string = "" func init() { - dbAdapter = "mssql" - _initDatabase = initMSSQL + dbAdapter = "mssql" + _initDatabase = initMSSQL } func initMSSQL() (err error) { - // TODO: Move this bit to the query gen lib - query := url.Values{} - query.Add("database", common.DbConfig.Dbname) - u := &url.URL{ - Scheme: "sqlserver", - User: url.UserPassword(common.DbConfig.Username, common.DbConfig.Password), - Host: common.DbConfig.Host + ":" + common.DbConfig.Port, - Path: dbInstance, - RawQuery: query.Encode(), - } - db, err = sql.Open("mssql", u.String()) - if err != nil { - return err - } + // TODO: Move this bit to the query gen lib + query := url.Values{} + query.Add("database", common.DbConfig.Dbname) + u := &url.URL{ + Scheme: "sqlserver", + User: url.UserPassword(common.DbConfig.Username, common.DbConfig.Password), + Host: common.DbConfig.Host + ":" + common.DbConfig.Port, + Path: dbInstance, + RawQuery: query.Encode(), + } + db, err = sql.Open("mssql", u.String()) + if err != nil { + return err + } - // Make sure that the connection is alive - err = db.Ping() - if err != nil { - return err - } + // Make sure that the connection is alive + err = db.Ping() + if err != nil { + return err + } - // Set the number of max open connections - db.SetMaxOpenConns(64) - db.SetMaxIdleConns(32) + // Set the number of max open connections + db.SetMaxOpenConns(64) + db.SetMaxIdleConns(32) - // Only hold connections open for five seconds to avoid accumulating a large number of stale connections - //db.SetConnMaxLifetime(5 * time.Second) - db.SetConnMaxLifetime(c.DBTimeout()) + // Only hold connections open for five seconds to avoid accumulating a large number of stale connections + //db.SetConnMaxLifetime(5 * time.Second) + db.SetConnMaxLifetime(c.DBTimeout()) - // 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_mssql() - if err != nil { - return err - } + // 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_mssql() + if err != nil { + return err + } - // Ready the query builder - qgen.Builder.SetConn(db) - err = qgen.Builder.SetAdapter("mssql") - if err != nil { - return err - } + // Ready the query builder + qgen.Builder.SetConn(db) + err = qgen.Builder.SetAdapter("mssql") + if err != nil { + return err + } - setter, ok := qgen.Builder.GetAdapter().(qgen.SetPrimaryKeys) - if ok { - setter.SetPrimaryKeys(dbTablePrimaryKeys) - } + setter, ok := qgen.Builder.GetAdapter().(qgen.SetPrimaryKeys) + if ok { + setter.SetPrimaryKeys(dbTablePrimaryKeys) + } - // TODO: Is there a less noisy way of doing this for tests? - /*log.Print("Preparing getActivityFeedByWatcher statement.") - stmts.getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt 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] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT 16 ROWS ONLY") - if err != nil { - return err - } + // TODO: Is there a less noisy way of doing this for tests? + /*log.Print("Preparing getActivityFeedByWatcher statement.") + stmts.getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt 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] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT 16 ROWS ONLY") + if err != nil { + return err + } - log.Print("Preparing getActivityFeedByWatcher statement.") - stmts.getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt 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] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY") - if err != nil { - return err - } + log.Print("Preparing getActivityFeedByWatcher statement.") + stmts.getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID, activity_stream.createdAt 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] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY") + if err != nil { + return err + } - log.Print("Preparing getActivityCountByWatcher statement.") - stmts.getActivityCountByWatcherStmt, err = db.Prepare("SELECT count(*) 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 getActivityCountByWatcher statement.") + stmts.getActivityCountByWatcherStmt, err = db.Prepare("SELECT count(*) 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 + } + */ - return nil + return nil } diff --git a/mysql.go b/mysql.go index bc074360..1a282691 100644 --- a/mysql.go +++ b/mysql.go @@ -1,3 +1,4 @@ +//go:build !pgsql && !mssql // +build !pgsql,!mssql /* @@ -9,12 +10,12 @@ package main import ( - "log" + "log" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" - _ "github.com/go-sql-driver/mysql" - "github.com/pkg/errors" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/go-sql-driver/mysql" + "github.com/pkg/errors" ) var dbCollation = "utf8mb4_general_ci" diff --git a/old_router.go b/old_router.go index 07f0fe23..16ad7a0e 100644 --- a/old_router.go +++ b/old_router.go @@ -3,11 +3,11 @@ package main //import "fmt" import ( - "net/http" - "strings" - "sync" + "net/http" + "strings" + "sync" - "github.com/Azareal/Gosora/common" + "git.tuxpa.in/a/gosora/common" ) // TODO: Support the new handler signatures created by our efforts to move the PreRoute middleware into the generated router diff --git a/parser_test.go b/parser_test.go index 19973f8c..cf93f5a9 100644 --- a/parser_test.go +++ b/parser_test.go @@ -1,12 +1,12 @@ package main import ( - "fmt" - "strconv" - "strings" - "testing" + "fmt" + "strconv" + "strings" + "testing" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func TestPreparser(t *testing.T) { @@ -150,7 +150,7 @@ func TestParser(t *testing.T) { } l := &METriList{nil} - url := "github.com/Azareal/Gosora" + url := "git.tuxpa.in/a/gosora" eurl := "" + url + "" l.Add("", "") l.Add("haha", "haha") diff --git a/patcher/main.go b/patcher/main.go index 478fa0f8..18f01df7 100644 --- a/patcher/main.go +++ b/patcher/main.go @@ -1,19 +1,19 @@ package main import ( - "bufio" - "database/sql" - "encoding/json" - "fmt" - "io/ioutil" - "log" - "os" - "runtime/debug" - "strconv" + "bufio" + "database/sql" + "encoding/json" + "fmt" + "io/ioutil" + "log" + "os" + "runtime/debug" + "strconv" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" - _ "github.com/go-sql-driver/mysql" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/go-sql-driver/mysql" ) var patches = make(map[int]func(*bufio.Scanner) error) diff --git a/patcher/patches.go b/patcher/patches.go index 2006e4ab..335747ac 100644 --- a/patcher/patches.go +++ b/patcher/patches.go @@ -1,14 +1,14 @@ package main import ( - "bufio" - "database/sql" - "strconv" - "strings" - "unicode" + "bufio" + "database/sql" + "strconv" + "strings" + "unicode" - meta "github.com/Azareal/Gosora/common/meta" - qgen "github.com/Azareal/Gosora/query_gen" + meta "git.tuxpa.in/a/gosora/common/meta" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type tblColumn = qgen.DBTableColumn diff --git a/patcher/utils.go b/patcher/utils.go index 0403d9f1..bdeb05b2 100644 --- a/patcher/utils.go +++ b/patcher/utils.go @@ -1,14 +1,17 @@ package main -import "database/sql" -import "github.com/Azareal/Gosora/query_gen" +import ( + "database/sql" + + qgen "git.tuxpa.in/a/gosora/query_gen" +) func execStmt(stmt *sql.Stmt, err error) error { - if err != nil { - return err - } - _, err = stmt.Exec() - return err + if err != nil { + return err + } + _, err = stmt.Exec() + return err } /*func eachUserQuick(handle func(int)) error { @@ -32,13 +35,13 @@ func execStmt(stmt *sql.Stmt, err error) error { }*/ func eachUser(handle func(int) error) error { - err := qgen.NewAcc().Select("users").Cols("uid").Each(func(rows *sql.Rows) error { - var uid int - err := rows.Scan(&uid) - if err != nil { - return err - } - return handle(uid) - }) - return err + err := qgen.NewAcc().Select("users").Cols("uid").Each(func(rows *sql.Rows) error { + var uid int + err := rows.Scan(&uid) + if err != nil { + return err + } + return handle(uid) + }) + return err } diff --git a/pgsql.go b/pgsql.go index 8beff545..d5dcb5b1 100644 --- a/pgsql.go +++ b/pgsql.go @@ -1,3 +1,4 @@ +//go:build pgsql // +build pgsql /* Copyright Azareal 2016 - 2020 */ @@ -5,66 +6,66 @@ package main import ( - "database/sql" - "strings" + "database/sql" + "strings" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" - _ "github.com/lib/pq" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" + _ "github.com/lib/pq" ) // TODO: Add support for SSL for all database drivers, not just pgsql var dbSslmode = "disable" // verify-full func init() { - dbAdapter = "pgsql" - _initDatabase = initPgsql + dbAdapter = "pgsql" + _initDatabase = initPgsql } func initPgsql() (err error) { - // TODO: Investigate connect_timeout to see what it does exactly and whether it's relevant to us - var _dbpassword string - if c.DbConfig.Password != "" { - _dbpassword = " password='" + _escape_bit(c.DbConfig.Password) + "'" - } - // TODO: Move this bit to the query gen lib - db, err = sql.Open("postgres", "host='"+_escape_bit(c.DbConfig.Host)+"' port='"+_escape_bit(c.DbConfig.Port)+"' user='"+_escape_bit(c.DbConfig.Username)+"' dbname='"+_escape_bit(c.DbConfig.Dbname)+"'"+_dbpassword+" sslmode='"+dbSslmode+"'") - if err != nil { - return err - } + // TODO: Investigate connect_timeout to see what it does exactly and whether it's relevant to us + var _dbpassword string + if c.DbConfig.Password != "" { + _dbpassword = " password='" + _escape_bit(c.DbConfig.Password) + "'" + } + // TODO: Move this bit to the query gen lib + db, err = sql.Open("postgres", "host='"+_escape_bit(c.DbConfig.Host)+"' port='"+_escape_bit(c.DbConfig.Port)+"' user='"+_escape_bit(c.DbConfig.Username)+"' dbname='"+_escape_bit(c.DbConfig.Dbname)+"'"+_dbpassword+" sslmode='"+dbSslmode+"'") + if err != nil { + return err + } - // Make sure that the connection is alive - err = db.Ping() - if err != nil { - return err - } + // Make sure that the connection is alive + err = db.Ping() + if err != nil { + return err + } - // Set the number of max open connections. How many do we need? Might need to do some tests. - db.SetMaxOpenConns(64) - db.SetMaxIdleConns(32) + // Set the number of max open connections. How many do we need? Might need to do some tests. + db.SetMaxOpenConns(64) + db.SetMaxIdleConns(32) - // Only hold connections open for five seconds to avoid accumulating a large number of stale connections - //db.SetConnMaxLifetime(5 * time.Second) - db.SetConnMaxLifetime(c.DBTimeout()) + // Only hold connections open for five seconds to avoid accumulating a large number of stale connections + //db.SetConnMaxLifetime(5 * time.Second) + db.SetConnMaxLifetime(c.DBTimeout()) - err = _gen_pgsql() - if err != nil { - return err - } + err = _gen_pgsql() + if err != nil { + return err + } - // Ready the query builder - qgen.Builder.SetConn(db) - err = qgen.Builder.SetAdapter("pgsql") - if err != nil { - return err - } + // Ready the query builder + qgen.Builder.SetConn(db) + err = qgen.Builder.SetAdapter("pgsql") + if err != nil { + return err + } - // TO-DO Handle the queries which the query generator can't handle yet + // TO-DO Handle the queries which the query generator can't handle yet - return nil + return nil } func _escape_bit(bit string) string { - // TODO: Write a custom parser, so that backslashes work properly in the sql.Open string. Do something similar for the database driver, if possible? - return strings.Replace(bit, "'", "\\'", -1) + // TODO: Write a custom parser, so that backslashes work properly in the sql.Open string. Do something similar for the database driver, if possible? + return strings.Replace(bit, "'", "\\'", -1) } diff --git a/plugin_test.go b/plugin_test.go index 3f5e3e04..b2c49c02 100644 --- a/plugin_test.go +++ b/plugin_test.go @@ -1,11 +1,11 @@ package main import ( - "strconv" - "testing" + "strconv" + "testing" - c "github.com/Azareal/Gosora/common" - e "github.com/Azareal/Gosora/extend" + c "git.tuxpa.in/a/gosora/common" + e "git.tuxpa.in/a/gosora/extend" ) // go test -v @@ -68,9 +68,9 @@ func TestBBCodeRender(t *testing.T) { l.Add("[quote][b]h[/b][/quote]", "
h") l.Add("[quote][b][/b][/quote]", "
") l.Add("[url][/url]", "") - l.Add("[url]https://github.com/Azareal/Gosora[/url]", "https://github.com/Azareal/Gosora") - l.Add("[url]http://github.com/Azareal/Gosora[/url]", "http://github.com/Azareal/Gosora") - l.Add("[url]//github.com/Azareal/Gosora[/url]", "//github.com/Azareal/Gosora") + l.Add("[url]https://git.tuxpa.in/a/gosora[/url]", "https://git.tuxpa.in/a/gosora") + l.Add("[url]http://git.tuxpa.in/a/gosora[/url]", "http://git.tuxpa.in/a/gosora") + l.Add("[url]//git.tuxpa.in/a/gosora[/url]", "//git.tuxpa.in/a/gosora") l.Add("-你好-", "-你好-") l.Add("[i]-你好-[/i]", "-你好-") // TODO: More of these Unicode tests? Emoji, Chinese, etc.? diff --git a/public/trumbowyg/ui/trumbowyg.custom.css b/public/trumbowyg/ui/trumbowyg.custom.css index e2167621..c9d0f5a3 100644 --- a/public/trumbowyg/ui/trumbowyg.custom.css +++ b/public/trumbowyg/ui/trumbowyg.custom.css @@ -2,7 +2,7 @@ * Trumbowyg v2.8.1 - A lightweight WYSIWYG editor * Default stylesheet for Trumbowyg editor. Modified by Azareal. * ------------------------ - * @link http://alex-d.github.io/Trumbowyg & https://github.com/Azareal/Gosora + * @link http://alex-d.github.io/Trumbowyg & https://git.tuxpa.in/a/gosora * @license MIT * @author Alexandre Demode (Alex-D) * @author Azareal diff --git a/pubnot/trumbowyg/ui/trumbowyg.custom.css b/pubnot/trumbowyg/ui/trumbowyg.custom.css index e2167621..c9d0f5a3 100644 --- a/pubnot/trumbowyg/ui/trumbowyg.custom.css +++ b/pubnot/trumbowyg/ui/trumbowyg.custom.css @@ -2,7 +2,7 @@ * Trumbowyg v2.8.1 - A lightweight WYSIWYG editor * Default stylesheet for Trumbowyg editor. Modified by Azareal. * ------------------------ - * @link http://alex-d.github.io/Trumbowyg & https://github.com/Azareal/Gosora + * @link http://alex-d.github.io/Trumbowyg & https://git.tuxpa.in/a/gosora * @license MIT * @author Alexandre Demode (Alex-D) * @author Azareal diff --git a/query_gen/mssql.go b/query_gen/mssql.go index 326610fa..2194b04b 100644 --- a/query_gen/mssql.go +++ b/query_gen/mssql.go @@ -2,11 +2,11 @@ package qgen import ( - "database/sql" - "errors" - "log" - "strconv" - "strings" + "database/sql" + "errors" + "log" + "strconv" + "strings" ) func init() { @@ -1191,7 +1191,7 @@ package main import "log" import "database/sql" -import "github.com/Azareal/Gosora/common" +import "git.tuxpa.in/a/gosora/common" // nolint type Stmts struct { diff --git a/query_gen/mysql.go b/query_gen/mysql.go index ea2e8c21..b0f7705b 100644 --- a/query_gen/mysql.go +++ b/query_gen/mysql.go @@ -2,16 +2,16 @@ package qgen import ( - "database/sql" - "errors" + "database/sql" + "errors" - //"fmt" - "os" - "runtime" - "strconv" - "strings" + //"fmt" + "os" + "runtime" + "strconv" + "strings" - _ "github.com/go-sql-driver/mysql" + _ "github.com/go-sql-driver/mysql" ) var ErrNoCollation = errors.New("You didn't provide a collation") @@ -1397,8 +1397,8 @@ package main import( "log" "database/sql" - c "github.com/Azareal/Gosora/common" - //"github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + //"git.tuxpa.in/a/gosora/query_gen" ) // nolint diff --git a/query_gen/pgsql.go b/query_gen/pgsql.go index 6997fba3..51089b60 100644 --- a/query_gen/pgsql.go +++ b/query_gen/pgsql.go @@ -2,10 +2,10 @@ package qgen import ( - "database/sql" - "errors" - "strconv" - "strings" + "database/sql" + "errors" + "strconv" + "strings" ) func init() { @@ -489,7 +489,7 @@ package main import "log" import "database/sql" -import "github.com/Azareal/Gosora/common" +import "git.tuxpa.in/a/gosora/common" // nolint type Stmts struct { diff --git a/query_gen/querygen.go b/query_gen/querygen.go index 04c6d0a9..826a8927 100644 --- a/query_gen/querygen.go +++ b/query_gen/querygen.go @@ -1,12 +1,12 @@ /* WIP Under Construction */ -package qgen // import "github.com/Azareal/Gosora/query_gen" +package qgen // import "git.tuxpa.in/a/gosora/query_gen" import ( - "database/sql" - "errors" - "strconv" - "strings" - "sync" + "database/sql" + "errors" + "strconv" + "strings" + "sync" ) var Registry []Adapter diff --git a/router.go b/router.go index e5be96b4..25806fe8 100644 --- a/router.go +++ b/router.go @@ -2,17 +2,17 @@ package main import ( - "log" - "net/http" - "os" - "strconv" - "strings" - "sync" - "sync/atomic" - "time" + "log" + "net/http" + "os" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" ) // TODO: Stop spilling these into the package scope? diff --git a/router_gen/main.go b/router_gen/main.go index 92317667..813f2952 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -2,12 +2,12 @@ package main import ( - "bytes" - "log" - "os" - "strconv" - "strings" - "text/template" + "bytes" + "log" + "os" + "strconv" + "strings" + "text/template" ) type TmplVars struct { @@ -433,11 +433,11 @@ import ( "errors" "net/http" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - "github.com/Azareal/Gosora/uutils" - "github.com/Azareal/Gosora/routes" - "github.com/Azareal/Gosora/routes/panel" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + "git.tuxpa.in/a/gosora/uutils" + "git.tuxpa.in/a/gosora/routes" + "git.tuxpa.in/a/gosora/routes/panel" //"github.com/andybalholm/brotli" ) diff --git a/routes.go b/routes.go index 4fbc5188..2dd221c5 100644 --- a/routes.go +++ b/routes.go @@ -7,21 +7,21 @@ package main import ( - "crypto/sha256" - "encoding/hex" - "encoding/json" - "errors" - "io" - "log" - "net/http" - "strconv" - "strings" - "sync" - "time" - "unicode" + "crypto/sha256" + "encoding/hex" + "encoding/json" + "errors" + "io" + "log" + "net/http" + "strconv" + "strings" + "sync" + "time" + "unicode" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" ) // A blank list to fill out that parameter in Page for routes which don't use it diff --git a/routes/account.go b/routes/account.go index 03bccdd8..ecf70fc8 100644 --- a/routes/account.go +++ b/routes/account.go @@ -1,20 +1,20 @@ package routes import ( - "crypto/sha256" - "crypto/subtle" - "database/sql" - "encoding/hex" - "html" - "log" - "math" - "net/http" - "strconv" - "strings" + "crypto/sha256" + "crypto/subtle" + "database/sql" + "encoding/hex" + "html" + "log" + "math" + "net/http" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) // A blank list to fill out that parameter in Page for routes which don't use it diff --git a/routes/api.go b/routes/api.go index 83387397..3476fc4d 100644 --- a/routes/api.go +++ b/routes/api.go @@ -1,13 +1,13 @@ package routes import ( - "encoding/json" - "errors" - "net/http" - "strconv" - "strings" + "encoding/json" + "errors" + "net/http" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) // TODO: Make this a static file somehow? Is it possible for us to put this file somewhere else? diff --git a/routes/attachments.go b/routes/attachments.go index 8015a6a4..2b203c6c 100644 --- a/routes/attachments.go +++ b/routes/attachments.go @@ -1,13 +1,13 @@ package routes import ( - "database/sql" - "net/http" - "path/filepath" - "strconv" - "strings" + "database/sql" + "net/http" + "path/filepath" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) var maxAgeYear = "max-age=" + strconv.Itoa(int(c.Year)) diff --git a/routes/common.go b/routes/common.go index bed46926..20fdea4f 100644 --- a/routes/common.go +++ b/routes/common.go @@ -1,16 +1,16 @@ package routes import ( - //"fmt" - "net/http" - "strconv" - "strings" - "sync" - "time" + //"fmt" + "net/http" + "strconv" + "strings" + "sync" + "time" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - "github.com/Azareal/Gosora/uutils" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + "git.tuxpa.in/a/gosora/uutils" ) var successJSONBytes = []byte(`{"success":1}`) diff --git a/routes/convos.go b/routes/convos.go index cbd05243..7489426f 100644 --- a/routes/convos.go +++ b/routes/convos.go @@ -1,18 +1,18 @@ package routes import ( - "database/sql" - "errors" - "html" - "math/rand" - "net/http" - "strconv" - "strings" + "database/sql" + "errors" + "html" + "math/rand" + "net/http" + "strconv" + "strings" - //"log" + //"log" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) func convoNotice(h *c.Header) { diff --git a/routes/forum.go b/routes/forum.go index da0ceb81..18938671 100644 --- a/routes/forum.go +++ b/routes/forum.go @@ -1,13 +1,13 @@ package routes import ( - "database/sql" - "net/http" - "strconv" + "database/sql" + "net/http" + "strconv" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + p "git.tuxpa.in/a/gosora/common/phrases" ) // TODO: Retire this in favour of an alias for /topics/? diff --git a/routes/forum_list.go b/routes/forum_list.go index 3d9a40be..4889ff09 100644 --- a/routes/forum_list.go +++ b/routes/forum_list.go @@ -1,11 +1,11 @@ package routes import ( - "log" - "net/http" + "log" + "net/http" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" ) func ForumList(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError { diff --git a/routes/misc.go b/routes/misc.go index 9bf6e90d..a30d64c1 100644 --- a/routes/misc.go +++ b/routes/misc.go @@ -1,18 +1,18 @@ package routes import ( - "bytes" - "database/sql" - "io" - "net/http" - "strconv" - "strings" - "time" + "bytes" + "database/sql" + "io" + "net/http" + "strconv" + "strings" + "time" - //"fmt" + //"fmt" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" ) var cacheControlMaxAge = "max-age=" + strconv.Itoa(int(c.Day)) // TODO: Make this a c.Config value diff --git a/routes/moderate.go b/routes/moderate.go index b4a59a74..bede3f92 100644 --- a/routes/moderate.go +++ b/routes/moderate.go @@ -1,10 +1,10 @@ package routes import ( - "net/http" + "net/http" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" ) func IPSearch(w http.ResponseWriter, r *http.Request, u *c.User, h *c.Header) c.RouteError { diff --git a/routes/panel/analytics.go b/routes/panel/analytics.go index ea42b496..c84ac772 100644 --- a/routes/panel/analytics.go +++ b/routes/panel/analytics.go @@ -9,9 +9,9 @@ import ( "strings" "time" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) func analyticsTimeRange(rawTimeRange string) (*c.AnalyticsTimeRange, error) { diff --git a/routes/panel/backups.go b/routes/panel/backups.go index ab5df4c4..d5d9d2e9 100644 --- a/routes/panel/backups.go +++ b/routes/panel/backups.go @@ -7,7 +7,7 @@ import ( "path/filepath" "strconv" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func Backups(w http.ResponseWriter, r *http.Request, u *c.User, backupURL string) c.RouteError { diff --git a/routes/panel/common.go b/routes/panel/common.go index 3fb090a2..64f6b5cc 100644 --- a/routes/panel/common.go +++ b/routes/panel/common.go @@ -3,8 +3,8 @@ package panel import ( "net/http" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) // A blank list to fill out that parameter in Page for routes which don't use it diff --git a/routes/panel/dashboard.go b/routes/panel/dashboard.go index 69910ad5..edcba6d5 100644 --- a/routes/panel/dashboard.go +++ b/routes/panel/dashboard.go @@ -11,9 +11,9 @@ import ( "sync/atomic" "time" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" "github.com/Azareal/gopsutil/mem" "github.com/pkg/errors" ) diff --git a/routes/panel/debug.go b/routes/panel/debug.go index 134b3aed..0f23c4be 100644 --- a/routes/panel/debug.go +++ b/routes/panel/debug.go @@ -6,8 +6,8 @@ import ( "strconv" "time" - c "github.com/Azareal/Gosora/common" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + qgen "git.tuxpa.in/a/gosora/query_gen" ) func Debug(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/forums.go b/routes/panel/forums.go index 507bbe23..26e22726 100644 --- a/routes/panel/forums.go +++ b/routes/panel/forums.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) func Forums(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/groups.go b/routes/panel/groups.go index 7ee90442..35b01043 100644 --- a/routes/panel/groups.go +++ b/routes/panel/groups.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) func Groups(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/logs.go b/routes/panel/logs.go index d7d2945d..0957e897 100644 --- a/routes/panel/logs.go +++ b/routes/panel/logs.go @@ -7,8 +7,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) // TODO: Link the usernames for successful registrations to the profiles diff --git a/routes/panel/pages.go b/routes/panel/pages.go index 3c27b971..fedb1d06 100644 --- a/routes/panel/pages.go +++ b/routes/panel/pages.go @@ -5,7 +5,7 @@ import ( "net/http" "strconv" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func Pages(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/plugins.go b/routes/panel/plugins.go index 01292f08..688dd98f 100644 --- a/routes/panel/plugins.go +++ b/routes/panel/plugins.go @@ -5,7 +5,7 @@ import ( "log" "net/http" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func Plugins(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/settings.go b/routes/panel/settings.go index f35fc98a..c253987b 100644 --- a/routes/panel/settings.go +++ b/routes/panel/settings.go @@ -6,8 +6,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) func Settings(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/themes.go b/routes/panel/themes.go index c2f5ab3a..8e85d7a6 100644 --- a/routes/panel/themes.go +++ b/routes/panel/themes.go @@ -8,8 +8,8 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" - p "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + p "git.tuxpa.in/a/gosora/common/phrases" ) func Themes(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/users.go b/routes/panel/users.go index 20b6f0c8..77a9f704 100644 --- a/routes/panel/users.go +++ b/routes/panel/users.go @@ -7,7 +7,7 @@ import ( "net/url" "strconv" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func Users(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/panel/word_filters.go b/routes/panel/word_filters.go index ecf4e2c1..830e266b 100644 --- a/routes/panel/word_filters.go +++ b/routes/panel/word_filters.go @@ -7,7 +7,7 @@ import ( "strconv" "strings" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func WordFilters(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/poll.go b/routes/poll.go index 45b68782..114da6d9 100644 --- a/routes/poll.go +++ b/routes/poll.go @@ -1,13 +1,13 @@ package routes import ( - "bytes" - "database/sql" - "errors" - "net/http" - "strconv" + "bytes" + "database/sql" + "errors" + "net/http" + "strconv" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func PollVote(w http.ResponseWriter, r *http.Request, u *c.User, sPollID string) c.RouteError { diff --git a/routes/profile.go b/routes/profile.go index 651b468b..e67e61fb 100644 --- a/routes/profile.go +++ b/routes/profile.go @@ -1,14 +1,14 @@ package routes import ( - "database/sql" - "math" - "net/http" - "time" + "database/sql" + "math" + "net/http" + "time" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type ProfileStmts struct { diff --git a/routes/profile_reply.go b/routes/profile_reply.go index 5a20d552..37cb0d56 100644 --- a/routes/profile_reply.go +++ b/routes/profile_reply.go @@ -1,12 +1,12 @@ package routes import ( - "database/sql" - "net/http" - "strconv" + "database/sql" + "net/http" + "strconv" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" ) func ProfileReplyCreateSubmit(w http.ResponseWriter, r *http.Request, u *c.User) c.RouteError { diff --git a/routes/reply.go b/routes/reply.go index 75a74da7..b82c98b8 100644 --- a/routes/reply.go +++ b/routes/reply.go @@ -1,17 +1,17 @@ package routes import ( - "database/sql" - "encoding/json" - "errors" - "net/http" - "strconv" - "strings" + "database/sql" + "encoding/json" + "errors" + "net/http" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/counters" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/counters" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type ReplyStmts struct { diff --git a/routes/reports.go b/routes/reports.go index d5e91416..dcbd49e6 100644 --- a/routes/reports.go +++ b/routes/reports.go @@ -1,12 +1,12 @@ package routes import ( - "database/sql" - "net/http" - "strconv" + "database/sql" + "net/http" + "strconv" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/counters" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/counters" ) func ReportSubmit(w http.ResponseWriter, r *http.Request, user *c.User, sItemID string) c.RouteError { diff --git a/routes/topic.go b/routes/topic.go index 2e898674..f51a44b9 100644 --- a/routes/topic.go +++ b/routes/topic.go @@ -1,30 +1,30 @@ package routes import ( - "crypto/sha256" - "database/sql" - "encoding/hex" - "encoding/json" - "errors" - "io" + "crypto/sha256" + "database/sql" + "encoding/hex" + "encoding/json" + "errors" + "io" - "image" - "image/gif" - "image/jpeg" - "image/png" - "log" - "net/http" - "os" - "regexp" - "strconv" - "strings" + "image" + "image/gif" + "image/jpeg" + "image/png" + "log" + "net/http" + "os" + "regexp" + "strconv" + "strings" - "golang.org/x/image/tiff" + "golang.org/x/image/tiff" - c "github.com/Azareal/Gosora/common" - co "github.com/Azareal/Gosora/common/counters" - p "github.com/Azareal/Gosora/common/phrases" - qgen "github.com/Azareal/Gosora/query_gen" + c "git.tuxpa.in/a/gosora/common" + co "git.tuxpa.in/a/gosora/common/counters" + p "git.tuxpa.in/a/gosora/common/phrases" + qgen "git.tuxpa.in/a/gosora/query_gen" ) type TopicStmts struct { diff --git a/routes/topic_list.go b/routes/topic_list.go index 713521ca..272bcbba 100644 --- a/routes/topic_list.go +++ b/routes/topic_list.go @@ -1,14 +1,14 @@ package routes import ( - "database/sql" - "log" - "net/http" - "strconv" - "strings" + "database/sql" + "log" + "net/http" + "strconv" + "strings" - c "github.com/Azareal/Gosora/common" - "github.com/Azareal/Gosora/common/phrases" + c "git.tuxpa.in/a/gosora/common" + "git.tuxpa.in/a/gosora/common/phrases" ) func wsTopicList(topicList []*c.TopicsRow, lastPage int) *c.WsTopicList { diff --git a/routes/user.go b/routes/user.go index 1f2a7d96..02d3de6c 100644 --- a/routes/user.go +++ b/routes/user.go @@ -1,12 +1,12 @@ package routes import ( - "database/sql" - "net/http" - "strconv" - "time" + "database/sql" + "net/http" + "strconv" + "time" - c "github.com/Azareal/Gosora/common" + c "git.tuxpa.in/a/gosora/common" ) func BanUserSubmit(w http.ResponseWriter, r *http.Request, u *c.User, suid string) c.RouteError { diff --git a/templates/footer.html b/templates/footer.html index b8362c08..107fc93a 100644 --- a/templates/footer.html +++ b/templates/footer.html @@ -7,7 +7,7 @@ {{dock "footer" .Header}}