From 0305571cb331c5acb66bc505a4967da2f9bea404 Mon Sep 17 00:00:00 2001 From: Azareal Date: Wed, 15 Aug 2018 17:02:57 +1000 Subject: [PATCH] Eliminated some JS errors for guests on Cosora. Fixed the build tags for the alt database engines. Tweaked the quotes on the PgSQL adapter. Still not functional. Removed the SQLite build tag as it's unlikely that it'll ever be implemented. --- gen_mysql.go | 2 +- gen_pgsql.go | 16 +++--- mssql.go | 29 +++++----- mysql.go | 2 +- pgsql.go | 4 +- query_gen/lib/mysql.go | 2 +- query_gen/lib/pgsql.go | 8 +-- schema/pgsql/query_activity_stream.sql | 2 +- .../pgsql/query_activity_stream_matches.sql | 2 +- schema/pgsql/query_activity_subscriptions.sql | 2 +- schema/pgsql/query_administration_logs.sql | 2 +- schema/pgsql/query_attachments.sql | 2 +- schema/pgsql/query_emails.sql | 2 +- schema/pgsql/query_forums.sql | 2 +- schema/pgsql/query_forums_permissions.sql | 2 +- schema/pgsql/query_likes.sql | 2 +- schema/pgsql/query_menu_items.sql | 2 +- schema/pgsql/query_menus.sql | 2 +- schema/pgsql/query_moderation_logs.sql | 2 +- schema/pgsql/query_pages.sql | 2 +- schema/pgsql/query_plugins.sql | 2 +- schema/pgsql/query_polls.sql | 2 +- schema/pgsql/query_polls_options.sql | 2 +- schema/pgsql/query_polls_voters.sql | 5 -- schema/pgsql/query_polls_votes.sql | 2 +- schema/pgsql/query_postchunks.sql | 2 +- schema/pgsql/query_registration_logs.sql | 2 +- schema/pgsql/query_replies.sql | 2 +- schema/pgsql/query_revisions.sql | 2 +- schema/pgsql/query_settings.sql | 2 +- schema/pgsql/query_sync.sql | 2 +- schema/pgsql/query_themes.sql | 2 +- schema/pgsql/query_topicchunks.sql | 2 +- schema/pgsql/query_topics.sql | 2 +- schema/pgsql/query_users.sql | 2 +- schema/pgsql/query_users_2fa_keys.sql | 2 +- schema/pgsql/query_users_avatar_queue.sql | 2 +- schema/pgsql/query_users_groups.sql | 2 +- schema/pgsql/query_users_groups_scheduler.sql | 2 +- schema/pgsql/query_users_replies.sql | 2 +- schema/pgsql/query_viewchunks.sql | 2 +- schema/pgsql/query_viewchunks_agents.sql | 2 +- schema/pgsql/query_viewchunks_forums.sql | 2 +- schema/pgsql/query_viewchunks_langs.sql | 2 +- schema/pgsql/query_viewchunks_referrers.sql | 2 +- schema/pgsql/query_viewchunks_systems.sql | 2 +- schema/pgsql/query_widgets.sql | 2 +- schema/pgsql/query_word_filters.sql | 2 +- themes/cosora/public/misc.js | 57 ++++++++++--------- 49 files changed, 102 insertions(+), 103 deletions(-) delete mode 100644 schema/pgsql/query_polls_voters.sql diff --git a/gen_mysql.go b/gen_mysql.go index 28b4eab5..9b74205f 100644 --- a/gen_mysql.go +++ b/gen_mysql.go @@ -1,4 +1,4 @@ -// +build !pgsql, !sqlite, !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. */ diff --git a/gen_pgsql.go b/gen_pgsql.go index cad5b5cd..8030eb66 100644 --- a/gen_pgsql.go +++ b/gen_pgsql.go @@ -33,56 +33,56 @@ 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 (?,?,?,?)") + 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 addTheme statement.") - stmts.addTheme, err = db.Prepare("INSERT INTO "themes"("uname","default") VALUES (?,?)") + stmts.addTheme, err = db.Prepare("INSERT INTO \"themes\"(\"uname\",\"default\") VALUES (?,?)") if err != nil { log.Print("Error in addTheme statement.") return err } common.DebugLog("Preparing updateTheme statement.") - stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?") + stmts.updateTheme, err = db.Prepare("UPDATE \"themes\" SET `default` = ? WHERE `uname` = ?") if err != nil { log.Print("Error in updateTheme statement.") return err } common.DebugLog("Preparing updateGroupPerms statement.") - stmts.updateGroupPerms, err = db.Prepare("UPDATE `users_groups` SET `permissions` = ? WHERE `gid` = ?") + stmts.updateGroupPerms, err = db.Prepare("UPDATE \"users_groups\" SET `permissions` = ? WHERE `gid` = ?") if err != nil { log.Print("Error in updateGroupPerms statement.") return err } common.DebugLog("Preparing updateGroup statement.") - stmts.updateGroup, err = db.Prepare("UPDATE `users_groups` SET `name` = ?,`tag` = ? WHERE `gid` = ?") + stmts.updateGroup, err = db.Prepare("UPDATE \"users_groups\" SET `name` = ?,`tag` = ? WHERE `gid` = ?") if err != nil { log.Print("Error in updateGroup statement.") return err } common.DebugLog("Preparing updateEmail statement.") - stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?") + 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` = ?") + 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()") + stmts.bumpSync, err = db.Prepare("UPDATE \"sync\" SET `last_update` = LOCALTIMESTAMP()") if err != nil { log.Print("Error in bumpSync statement.") return err diff --git a/mssql.go b/mssql.go index f1f4fb16..dcde2cba 100644 --- a/mssql.go +++ b/mssql.go @@ -3,7 +3,7 @@ /* * * Gosora MSSQL Interface -* Copyright Azareal 2016 - 2018 +* Copyright Azareal 2016 - 2019 * */ package main @@ -13,6 +13,7 @@ import ( "log" "net/url" + "./common" "./query_gen/lib" _ "github.com/denisenkom/go-mssqldb" ) @@ -27,11 +28,11 @@ func init() { func initMSSQL() (err error) { // TODO: Move this bit to the query gen lib query := url.Values{} - query.Add("database", dbConfig.Dbname) + query.Add("database", common.DbConfig.Dbname) u := &url.URL{ Scheme: "sqlserver", - User: url.UserPassword(dbConfig.Username, dbConfig.Password), - Host: dbConfig.Host + ":" + dbConfig.Port, + User: url.UserPassword(common.DbConfig.Username, common.DbConfig.Password), + Host: common.DbConfig.Host + ":" + common.DbConfig.Port, Path: dbInstance, RawQuery: query.Encode(), } @@ -72,42 +73,42 @@ func initMSSQL() (err error) { } // TODO: Is there a less noisy way of doing this for tests? - log.Print("Preparing getActivityFeedByWatcher statement.") - getActivityFeedByWatcherStmt, err = db.Prepare("SELECT activity_stream_matches.asid, activity_stream.actor, activity_stream.targetUser, activity_stream.event, activity_stream.elementType, activity_stream.elementID FROM [activity_stream_matches] INNER JOIN [activity_stream] ON activity_stream_matches.asid = activity_stream.asid AND activity_stream_matches.watcher != activity_stream.actor WHERE [watcher] = ? ORDER BY activity_stream.asid DESC OFFSET 0 ROWS FETCH NEXT 8 ROWS ONLY") + /*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 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 8 ROWS ONLY") if err != nil { return err } log.Print("Preparing getActivityCountByWatcher statement.") - 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] = ?") + 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 todaysPostCount statement.") - todaysPostCountStmt, err = db.Prepare("select count(*) from replies where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") + stmts.todaysPostCountStmt, err = db.Prepare("select count(*) from replies where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") if err != nil { return err } log.Print("Preparing todaysTopicCount statement.") - todaysTopicCountStmt, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") + stmts.todaysTopicCountStmt, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") if err != nil { return err - } + }*/ log.Print("Preparing todaysTopicCountByForum statement.") // TODO: Stop hard-coding this query - todaysTopicCountByForum, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE()) and parentID = ?") + stmts.todaysTopicCountByForum, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE()) and parentID = ?") if err != nil { return err } - log.Print("Preparing todaysNewUserCount statement.") - todaysNewUserCountStmt, err = db.Prepare("select count(*) from users where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") + /*log.Print("Preparing todaysNewUserCount statement.") + stmts.todaysNewUserCountStmt, err = db.Prepare("select count(*) from users where createdAt >= DATEADD(DAY, -1, GETUTCDATE())") if err != nil { return err - } + }*/ return nil } diff --git a/mysql.go b/mysql.go index e904e221..05af7047 100644 --- a/mysql.go +++ b/mysql.go @@ -1,4 +1,4 @@ -// +build !pgsql, !sqlite, !mssql +// +build !pgsql,!mssql /* * diff --git a/pgsql.go b/pgsql.go index f956869c..6745cb98 100644 --- a/pgsql.go +++ b/pgsql.go @@ -24,11 +24,11 @@ func init() { 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 dbpassword != "" { + if common.DbConfig.Password != "" { _dbpassword = " password='" + _escape_bit(common.DbConfig.Password) + "'" } // TODO: Move this bit to the query gen lib - db, err = sql.Open("postgres", "host='"+_escape_bit(common.DbConfig.Host)+"' port='"+_escape_bit(common.DbConfig.Port)+"' user='"+_escape_bit(common.DbConfig.Username)+"' dbname='"+_escape_bit(common.Config.Dbname)+"'"+_dbpassword+" sslmode='"+dbSslmode+"'") + db, err = sql.Open("postgres", "host='"+_escape_bit(common.DbConfig.Host)+"' port='"+_escape_bit(common.DbConfig.Port)+"' user='"+_escape_bit(common.DbConfig.Username)+"' dbname='"+_escape_bit(common.DbConfig.Dbname)+"'"+_dbpassword+" sslmode='"+dbSslmode+"'") if err != nil { return err } diff --git a/query_gen/lib/mysql.go b/query_gen/lib/mysql.go index 5f2eef80..e2547899 100644 --- a/query_gen/lib/mysql.go +++ b/query_gen/lib/mysql.go @@ -719,7 +719,7 @@ func (adapter *MysqlAdapter) Write() error { } // TODO: Move these custom queries out of this file - out := `// +build !pgsql, !sqlite, !mssql + out := `// +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. */ diff --git a/query_gen/lib/pgsql.go b/query_gen/lib/pgsql.go index a803b318..5501bdcf 100644 --- a/query_gen/lib/pgsql.go +++ b/query_gen/lib/pgsql.go @@ -67,7 +67,7 @@ func (adapter *PgsqlAdapter) CreateTable(name string, table string, charset stri return "", errors.New("You can't have a table with no columns") } - var querystr = "CREATE TABLE `" + table + "` (" + var querystr = "CREATE TABLE \"" + table + "\" (" for _, column := range columns { if column.AutoIncrement { column.Type = "serial" @@ -222,7 +222,8 @@ func (adapter *PgsqlAdapter) SimpleUpdate(name string, table string, set string, if set == "" { return "", errors.New("You need to set data in this update statement") } - var querystr = "UPDATE `" + table + "` SET " + + var querystr = "UPDATE \"" + table + "\" SET " for _, item := range processSet(set) { querystr += "`" + item.Column + "` =" for _, token := range item.Expr { @@ -243,7 +244,6 @@ func (adapter *PgsqlAdapter) SimpleUpdate(name string, table string, set string, } querystr += "," } - // Remove the trailing comma querystr = querystr[0 : len(querystr)-1] @@ -414,7 +414,7 @@ func (adapter *PgsqlAdapter) Write() error { stmts += "\t" + name + " *sql.Stmt\n" body += ` common.DebugLog("Preparing ` + name + ` statement.") - stmts.` + name + `, err = db.Prepare("` + stmt.Contents + `") + stmts.` + name + `, err = db.Prepare("` + strings.Replace(stmt.Contents, "\"", "\\\"", -1) + `") if err != nil { log.Print("Error in ` + name + ` statement.") return err diff --git a/schema/pgsql/query_activity_stream.sql b/schema/pgsql/query_activity_stream.sql index ddbeaaa7..00fe25dc 100644 --- a/schema/pgsql/query_activity_stream.sql +++ b/schema/pgsql/query_activity_stream.sql @@ -1,4 +1,4 @@ -CREATE TABLE `activity_stream` ( +CREATE TABLE "activity_stream" ( `asid` serial not null, `actor` int not null, `targetUser` int not null, diff --git a/schema/pgsql/query_activity_stream_matches.sql b/schema/pgsql/query_activity_stream_matches.sql index d4139a9b..3efddb73 100644 --- a/schema/pgsql/query_activity_stream_matches.sql +++ b/schema/pgsql/query_activity_stream_matches.sql @@ -1,4 +1,4 @@ -CREATE TABLE `activity_stream_matches` ( +CREATE TABLE "activity_stream_matches" ( `watcher` int not null, `asid` int not null ); \ No newline at end of file diff --git a/schema/pgsql/query_activity_subscriptions.sql b/schema/pgsql/query_activity_subscriptions.sql index 9ae31495..f6d6dbaa 100644 --- a/schema/pgsql/query_activity_subscriptions.sql +++ b/schema/pgsql/query_activity_subscriptions.sql @@ -1,4 +1,4 @@ -CREATE TABLE `activity_subscriptions` ( +CREATE TABLE "activity_subscriptions" ( `user` int not null, `targetID` int not null, `targetType` varchar (50) not null, diff --git a/schema/pgsql/query_administration_logs.sql b/schema/pgsql/query_administration_logs.sql index 73f59cf6..3035a418 100644 --- a/schema/pgsql/query_administration_logs.sql +++ b/schema/pgsql/query_administration_logs.sql @@ -1,4 +1,4 @@ -CREATE TABLE `administration_logs` ( +CREATE TABLE "administration_logs" ( `action` varchar (100) not null, `elementID` int not null, `elementType` varchar (100) not null, diff --git a/schema/pgsql/query_attachments.sql b/schema/pgsql/query_attachments.sql index 11ec6798..4669a2da 100644 --- a/schema/pgsql/query_attachments.sql +++ b/schema/pgsql/query_attachments.sql @@ -1,4 +1,4 @@ -CREATE TABLE `attachments` ( +CREATE TABLE "attachments" ( `attachID` serial not null, `sectionID` int DEFAULT 0 not null, `sectionTable` varchar (200) DEFAULT 'forums' not null, diff --git a/schema/pgsql/query_emails.sql b/schema/pgsql/query_emails.sql index 85ff2f7c..fbf0606b 100644 --- a/schema/pgsql/query_emails.sql +++ b/schema/pgsql/query_emails.sql @@ -1,4 +1,4 @@ -CREATE TABLE `emails` ( +CREATE TABLE "emails" ( `email` varchar (200) not null, `uid` int not null, `validated` boolean DEFAULT 0 not null, diff --git a/schema/pgsql/query_forums.sql b/schema/pgsql/query_forums.sql index 081c2be8..171a5458 100644 --- a/schema/pgsql/query_forums.sql +++ b/schema/pgsql/query_forums.sql @@ -1,4 +1,4 @@ -CREATE TABLE `forums` ( +CREATE TABLE "forums" ( `fid` serial not null, `name` varchar (100) not null, `desc` varchar (200) not null, diff --git a/schema/pgsql/query_forums_permissions.sql b/schema/pgsql/query_forums_permissions.sql index d5f41a4c..9954e7e7 100644 --- a/schema/pgsql/query_forums_permissions.sql +++ b/schema/pgsql/query_forums_permissions.sql @@ -1,4 +1,4 @@ -CREATE TABLE `forums_permissions` ( +CREATE TABLE "forums_permissions" ( `fid` int not null, `gid` int not null, `preset` varchar (100) DEFAULT '' not null, diff --git a/schema/pgsql/query_likes.sql b/schema/pgsql/query_likes.sql index 142b396c..0680339d 100644 --- a/schema/pgsql/query_likes.sql +++ b/schema/pgsql/query_likes.sql @@ -1,4 +1,4 @@ -CREATE TABLE `likes` ( +CREATE TABLE "likes" ( `weight` tinyint DEFAULT 1 not null, `targetItem` int not null, `targetType` varchar (50) DEFAULT 'replies' not null, diff --git a/schema/pgsql/query_menu_items.sql b/schema/pgsql/query_menu_items.sql index ddfea98a..0b8c260d 100644 --- a/schema/pgsql/query_menu_items.sql +++ b/schema/pgsql/query_menu_items.sql @@ -1,4 +1,4 @@ -CREATE TABLE `menu_items` ( +CREATE TABLE "menu_items" ( `miid` serial not null, `mid` int not null, `name` varchar (200) not null, diff --git a/schema/pgsql/query_menus.sql b/schema/pgsql/query_menus.sql index 8f731373..620d8aad 100644 --- a/schema/pgsql/query_menus.sql +++ b/schema/pgsql/query_menus.sql @@ -1,4 +1,4 @@ -CREATE TABLE `menus` ( +CREATE TABLE "menus" ( `mid` serial not null, primary key(`mid`) ); \ No newline at end of file diff --git a/schema/pgsql/query_moderation_logs.sql b/schema/pgsql/query_moderation_logs.sql index b3d192b1..77250c4b 100644 --- a/schema/pgsql/query_moderation_logs.sql +++ b/schema/pgsql/query_moderation_logs.sql @@ -1,4 +1,4 @@ -CREATE TABLE `moderation_logs` ( +CREATE TABLE "moderation_logs" ( `action` varchar (100) not null, `elementID` int not null, `elementType` varchar (100) not null, diff --git a/schema/pgsql/query_pages.sql b/schema/pgsql/query_pages.sql index dfbf4cbc..4b13251e 100644 --- a/schema/pgsql/query_pages.sql +++ b/schema/pgsql/query_pages.sql @@ -1,4 +1,4 @@ -CREATE TABLE `pages` ( +CREATE TABLE "pages" ( `pid` serial not null, `name` varchar (200) not null, `title` varchar (200) not null, diff --git a/schema/pgsql/query_plugins.sql b/schema/pgsql/query_plugins.sql index a457c43f..958be5e7 100644 --- a/schema/pgsql/query_plugins.sql +++ b/schema/pgsql/query_plugins.sql @@ -1,4 +1,4 @@ -CREATE TABLE `plugins` ( +CREATE TABLE "plugins" ( `uname` varchar (180) not null, `active` boolean DEFAULT 0 not null, `installed` boolean DEFAULT 0 not null, diff --git a/schema/pgsql/query_polls.sql b/schema/pgsql/query_polls.sql index 811eec1b..7b818358 100644 --- a/schema/pgsql/query_polls.sql +++ b/schema/pgsql/query_polls.sql @@ -1,4 +1,4 @@ -CREATE TABLE `polls` ( +CREATE TABLE "polls" ( `pollID` serial not null, `parentID` int DEFAULT 0 not null, `parentTable` varchar (100) DEFAULT 'topics' not null, diff --git a/schema/pgsql/query_polls_options.sql b/schema/pgsql/query_polls_options.sql index 95bf84c3..592f1416 100644 --- a/schema/pgsql/query_polls_options.sql +++ b/schema/pgsql/query_polls_options.sql @@ -1,4 +1,4 @@ -CREATE TABLE `polls_options` ( +CREATE TABLE "polls_options" ( `pollID` int not null, `option` int DEFAULT 0 not null, `votes` int DEFAULT 0 not null diff --git a/schema/pgsql/query_polls_voters.sql b/schema/pgsql/query_polls_voters.sql deleted file mode 100644 index ff249360..00000000 --- a/schema/pgsql/query_polls_voters.sql +++ /dev/null @@ -1,5 +0,0 @@ -CREATE TABLE `polls_voters` ( - `pollID` int not null, - `uid` int not null, - `option` int DEFAULT 0 not null -); \ No newline at end of file diff --git a/schema/pgsql/query_polls_votes.sql b/schema/pgsql/query_polls_votes.sql index 6344e232..df709c36 100644 --- a/schema/pgsql/query_polls_votes.sql +++ b/schema/pgsql/query_polls_votes.sql @@ -1,4 +1,4 @@ -CREATE TABLE `polls_votes` ( +CREATE TABLE "polls_votes" ( `pollID` int not null, `uid` int not null, `option` int DEFAULT 0 not null, diff --git a/schema/pgsql/query_postchunks.sql b/schema/pgsql/query_postchunks.sql index b6ee2dd3..f78bd054 100644 --- a/schema/pgsql/query_postchunks.sql +++ b/schema/pgsql/query_postchunks.sql @@ -1,4 +1,4 @@ -CREATE TABLE `postchunks` ( +CREATE TABLE "postchunks" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null ); \ No newline at end of file diff --git a/schema/pgsql/query_registration_logs.sql b/schema/pgsql/query_registration_logs.sql index 59970699..178bb48c 100644 --- a/schema/pgsql/query_registration_logs.sql +++ b/schema/pgsql/query_registration_logs.sql @@ -1,4 +1,4 @@ -CREATE TABLE `registration_logs` ( +CREATE TABLE "registration_logs" ( `rlid` serial not null, `username` varchar (100) not null, `email` varchar (100) not null, diff --git a/schema/pgsql/query_replies.sql b/schema/pgsql/query_replies.sql index 4139cb79..6af1fbae 100644 --- a/schema/pgsql/query_replies.sql +++ b/schema/pgsql/query_replies.sql @@ -1,4 +1,4 @@ -CREATE TABLE `replies` ( +CREATE TABLE "replies" ( `rid` serial not null, `tid` int not null, `content` text not null, diff --git a/schema/pgsql/query_revisions.sql b/schema/pgsql/query_revisions.sql index 3e164e99..750d244c 100644 --- a/schema/pgsql/query_revisions.sql +++ b/schema/pgsql/query_revisions.sql @@ -1,4 +1,4 @@ -CREATE TABLE `revisions` ( +CREATE TABLE "revisions" ( `reviseID` serial not null, `content` text not null, `contentID` int not null, diff --git a/schema/pgsql/query_settings.sql b/schema/pgsql/query_settings.sql index afd0fe7e..258a58a5 100644 --- a/schema/pgsql/query_settings.sql +++ b/schema/pgsql/query_settings.sql @@ -1,4 +1,4 @@ -CREATE TABLE `settings` ( +CREATE TABLE "settings" ( `name` varchar (180) not null, `content` varchar (250) not null, `type` varchar (50) not null, diff --git a/schema/pgsql/query_sync.sql b/schema/pgsql/query_sync.sql index ac13e7c9..ae7f9cc9 100644 --- a/schema/pgsql/query_sync.sql +++ b/schema/pgsql/query_sync.sql @@ -1,3 +1,3 @@ -CREATE TABLE `sync` ( +CREATE TABLE "sync" ( `last_update` timestamp not null ); \ No newline at end of file diff --git a/schema/pgsql/query_themes.sql b/schema/pgsql/query_themes.sql index 6899ce85..0045c53b 100644 --- a/schema/pgsql/query_themes.sql +++ b/schema/pgsql/query_themes.sql @@ -1,4 +1,4 @@ -CREATE TABLE `themes` ( +CREATE TABLE "themes" ( `uname` varchar (180) not null, `default` boolean DEFAULT 0 not null, unique(`uname`) diff --git a/schema/pgsql/query_topicchunks.sql b/schema/pgsql/query_topicchunks.sql index 13253a19..c9192f09 100644 --- a/schema/pgsql/query_topicchunks.sql +++ b/schema/pgsql/query_topicchunks.sql @@ -1,4 +1,4 @@ -CREATE TABLE `topicchunks` ( +CREATE TABLE "topicchunks" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null ); \ No newline at end of file diff --git a/schema/pgsql/query_topics.sql b/schema/pgsql/query_topics.sql index bf93f1b8..2f48b175 100644 --- a/schema/pgsql/query_topics.sql +++ b/schema/pgsql/query_topics.sql @@ -1,4 +1,4 @@ -CREATE TABLE `topics` ( +CREATE TABLE "topics" ( `tid` serial not null, `title` varchar (100) not null, `content` text not null, diff --git a/schema/pgsql/query_users.sql b/schema/pgsql/query_users.sql index f57f8acc..9719b321 100644 --- a/schema/pgsql/query_users.sql +++ b/schema/pgsql/query_users.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users` ( +CREATE TABLE "users" ( `uid` serial not null, `name` varchar (100) not null, `password` varchar (100) not null, diff --git a/schema/pgsql/query_users_2fa_keys.sql b/schema/pgsql/query_users_2fa_keys.sql index d9e48a22..3b410a27 100644 --- a/schema/pgsql/query_users_2fa_keys.sql +++ b/schema/pgsql/query_users_2fa_keys.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users_2fa_keys` ( +CREATE TABLE "users_2fa_keys" ( `uid` int not null, `secret` varchar (100) not null, `scratch1` varchar (50) not null, diff --git a/schema/pgsql/query_users_avatar_queue.sql b/schema/pgsql/query_users_avatar_queue.sql index bd8eaf90..58fc0f18 100644 --- a/schema/pgsql/query_users_avatar_queue.sql +++ b/schema/pgsql/query_users_avatar_queue.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users_avatar_queue` ( +CREATE TABLE "users_avatar_queue" ( `uid` int not null, primary key(`uid`) ); \ No newline at end of file diff --git a/schema/pgsql/query_users_groups.sql b/schema/pgsql/query_users_groups.sql index 56757e83..454100d7 100644 --- a/schema/pgsql/query_users_groups.sql +++ b/schema/pgsql/query_users_groups.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users_groups` ( +CREATE TABLE "users_groups" ( `gid` serial not null, `name` varchar (100) not null, `permissions` text not null, diff --git a/schema/pgsql/query_users_groups_scheduler.sql b/schema/pgsql/query_users_groups_scheduler.sql index 87e7d5bd..e73e8f68 100644 --- a/schema/pgsql/query_users_groups_scheduler.sql +++ b/schema/pgsql/query_users_groups_scheduler.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users_groups_scheduler` ( +CREATE TABLE "users_groups_scheduler" ( `uid` int not null, `set_group` int not null, `issued_by` int not null, diff --git a/schema/pgsql/query_users_replies.sql b/schema/pgsql/query_users_replies.sql index 5ae47e19..9c4abdc0 100644 --- a/schema/pgsql/query_users_replies.sql +++ b/schema/pgsql/query_users_replies.sql @@ -1,4 +1,4 @@ -CREATE TABLE `users_replies` ( +CREATE TABLE "users_replies" ( `rid` serial not null, `uid` int not null, `content` text not null, diff --git a/schema/pgsql/query_viewchunks.sql b/schema/pgsql/query_viewchunks.sql index 5177bdc8..99036cb3 100644 --- a/schema/pgsql/query_viewchunks.sql +++ b/schema/pgsql/query_viewchunks.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks` ( +CREATE TABLE "viewchunks" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `route` varchar (200) not null diff --git a/schema/pgsql/query_viewchunks_agents.sql b/schema/pgsql/query_viewchunks_agents.sql index b74921cf..dc0ce312 100644 --- a/schema/pgsql/query_viewchunks_agents.sql +++ b/schema/pgsql/query_viewchunks_agents.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks_agents` ( +CREATE TABLE "viewchunks_agents" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `browser` varchar (200) not null diff --git a/schema/pgsql/query_viewchunks_forums.sql b/schema/pgsql/query_viewchunks_forums.sql index 60d539a0..7dc64ae3 100644 --- a/schema/pgsql/query_viewchunks_forums.sql +++ b/schema/pgsql/query_viewchunks_forums.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks_forums` ( +CREATE TABLE "viewchunks_forums" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `forum` int not null diff --git a/schema/pgsql/query_viewchunks_langs.sql b/schema/pgsql/query_viewchunks_langs.sql index ee29a462..927a7599 100644 --- a/schema/pgsql/query_viewchunks_langs.sql +++ b/schema/pgsql/query_viewchunks_langs.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks_langs` ( +CREATE TABLE "viewchunks_langs" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `lang` varchar (200) not null diff --git a/schema/pgsql/query_viewchunks_referrers.sql b/schema/pgsql/query_viewchunks_referrers.sql index 74fc9bc0..b67a8236 100644 --- a/schema/pgsql/query_viewchunks_referrers.sql +++ b/schema/pgsql/query_viewchunks_referrers.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks_referrers` ( +CREATE TABLE "viewchunks_referrers" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `domain` varchar (200) not null diff --git a/schema/pgsql/query_viewchunks_systems.sql b/schema/pgsql/query_viewchunks_systems.sql index 7ae425a7..ce41eeb5 100644 --- a/schema/pgsql/query_viewchunks_systems.sql +++ b/schema/pgsql/query_viewchunks_systems.sql @@ -1,4 +1,4 @@ -CREATE TABLE `viewchunks_systems` ( +CREATE TABLE "viewchunks_systems" ( `count` int DEFAULT 0 not null, `createdAt` timestamp not null, `system` varchar (200) not null diff --git a/schema/pgsql/query_widgets.sql b/schema/pgsql/query_widgets.sql index 2267e83d..9b110701 100644 --- a/schema/pgsql/query_widgets.sql +++ b/schema/pgsql/query_widgets.sql @@ -1,4 +1,4 @@ -CREATE TABLE `widgets` ( +CREATE TABLE "widgets" ( `position` int not null, `side` varchar (100) not null, `type` varchar (100) not null, diff --git a/schema/pgsql/query_word_filters.sql b/schema/pgsql/query_word_filters.sql index 64595157..95297345 100644 --- a/schema/pgsql/query_word_filters.sql +++ b/schema/pgsql/query_word_filters.sql @@ -1,4 +1,4 @@ -CREATE TABLE `word_filters` ( +CREATE TABLE "word_filters" ( `wfid` serial not null, `find` varchar (200) not null, `replacement` varchar (200) not null, diff --git a/themes/cosora/public/misc.js b/themes/cosora/public/misc.js index b4088362..8723bd15 100644 --- a/themes/cosora/public/misc.js +++ b/themes/cosora/public/misc.js @@ -1,36 +1,39 @@ "use strict" $(document).ready(function(){ - // Is there we way we can append instead? Maybe, an editor plugin? - attachItemCallback = function(attachItem) { - let currentContent = $('#input_content').trumbowyg('html'); - $('#input_content').trumbowyg('html', currentContent); - } + let loggedIn = document.head.querySelector("[property='x-loggedin']").content; + if(loggedIn) { + // Is there we way we can append instead? Maybe, an editor plugin? + attachItemCallback = function(attachItem) { + let currentContent = $('#input_content').trumbowyg('html'); + $('#input_content').trumbowyg('html', currentContent); + } - $(".topic_name_row").click(function(){ - $(".topic_create_form").addClass("selectedInput"); - }); - //$.trumbowyg.svgPath = false; + $(".topic_name_row").click(function(){ + $(".topic_create_form").addClass("selectedInput"); + }); + //$.trumbowyg.svgPath = false; - // TODO: Bind this to the viewport resize event - var btnlist = []; - if(document.documentElement.clientWidth > 550) { - btnlist = [['viewHTML'],['undo','redo'],['formatting'],['strong','em','del'],['link'],['insertImage'],['unorderedList','orderedList'],['removeformat']]; - } else { - btnlist = [['viewHTML'],['strong','em','del'],['link'],['insertImage'],['unorderedList','orderedList'],['removeformat']]; - } + // TODO: Bind this to the viewport resize event + var btnlist = []; + if(document.documentElement.clientWidth > 550) { + btnlist = [['viewHTML'],['undo','redo'],['formatting'],['strong','em','del'],['link'],['insertImage'],['unorderedList','orderedList'],['removeformat']]; + } else { + btnlist = [['viewHTML'],['strong','em','del'],['link'],['insertImage'],['unorderedList','orderedList'],['removeformat']]; + } - $('.topic_create_form #input_content').trumbowyg({ - btns: btnlist, - }); - $('.topic_reply_form #input_content').trumbowyg({ - btns: btnlist, - autogrow: true, - }); - $('#profile_comments_form .topic_reply_form .input_content').trumbowyg({ - btns: [['viewHTML'],['strong','em','del'],['link'],['insertImage'],['removeformat']], - autogrow: true, - }); + $('.topic_create_form #input_content').trumbowyg({ + btns: btnlist, + }); + $('.topic_reply_form #input_content').trumbowyg({ + btns: btnlist, + autogrow: true, + }); + $('#profile_comments_form .topic_reply_form .input_content').trumbowyg({ + btns: [['viewHTML'],['strong','em','del'],['link'],['insertImage'],['removeformat']], + autogrow: true, + }); + } // TODO: Refactor this to use `each` less $('.button_menu').click(function(){