diff --git a/common/pages.go b/common/pages.go index 15a9f883..30a6b535 100644 --- a/common/pages.go +++ b/common/pages.go @@ -17,9 +17,10 @@ type HeaderVars struct { Themes map[string]*Theme // TODO: Use a slice containing every theme instead of the main map for speed? Theme *Theme //TemplateName string // TODO: Use this to move template calls to the router rather than duplicating them over and over and over? - Zone string - Writer http.ResponseWriter - ExtData ExtData + Zone string + MetaDesc string + Writer http.ResponseWriter + ExtData ExtData } // TODO: Add this to routes which don't use templates. E.g. Json APIs. diff --git a/misc_test.go b/misc_test.go index 4f158b6a..df3a1c7b 100644 --- a/misc_test.go +++ b/misc_test.go @@ -129,6 +129,7 @@ func userStoreTest(t *testing.T, newUserID int) { if !ok { t.Error("We couldn't find UID #1 in the returned map") t.Error("userList", userList) + return } expect(t, user.ID == 1, fmt.Sprintf("user.ID does not match the requested UID. Got '%d' instead.", user.ID)) @@ -600,8 +601,26 @@ func TestForumStore(t *testing.T) { expect(t, !ok, "FID #0 shouldn't exist") ok = common.Forums.Exists(1) expect(t, ok, "FID #1 should exist") + ok = common.Forums.Exists(2) + expect(t, ok, "FID #2 should exist") + ok = common.Forums.Exists(3) + expect(t, !ok, "FID #3 shouldn't exist") - // TODO: Test forum creation + fid, err := common.Forums.Create("Test Forum", "", true, "all") + expectNilErr(t, err) + expect(t, fid == 3, "The first forum we create should have an ID of 3") + ok = common.Forums.Exists(3) + expect(t, ok, "FID #2 should exist") + + forum, err = common.Forums.Get(3) + recordMustExist(t, err, "Couldn't find FID #3") + + expect(t, forum.ID == 2, fmt.Sprintf("The FID should be 3 not %d", forum.ID)) + expect(t, forum.Name == "Test Forum", fmt.Sprintf("The name of the forum should be 'Test Forum' not '%s'", forum.Name)) + expect(t, forum.Active, fmt.Sprintf("The test forum should be active")) + expect(t, forum.Desc == "", fmt.Sprintf("The forum description should be blank not '%s'", expectDesc, forum.Desc)) + + // TODO: More forum creation tests // TODO: Test forum deletion // TODO: Test forum update } diff --git a/query_gen/main.go b/query_gen/main.go index f2f77028..487ebdb2 100644 --- a/query_gen/main.go +++ b/query_gen/main.go @@ -115,6 +115,7 @@ func seedTables(adapter qgen.Adapter) error { qgen.Install.SimpleInsert("settings", "name, content, type, constraints", "'activation_type','1','list','1-3'") qgen.Install.SimpleInsert("settings", "name, content, type", "'bigpost_min_words','250','int'") qgen.Install.SimpleInsert("settings", "name, content, type", "'megapost_min_words','1000','int'") + qgen.Install.SimpleInsert("settings", "name, content, type", "'meta_desc','','html-attribute'") qgen.Install.SimpleInsert("themes", "uname, default", "'tempra-simple',1") qgen.Install.SimpleInsert("emails", "email, uid, validated", "'admin@localhost',1,1") // ? - Use a different default email or let the admin input it during installation? diff --git a/routes.go b/routes.go index 87f8bc2f..e8b00891 100644 --- a/routes.go +++ b/routes.go @@ -133,6 +133,7 @@ func routeTopics(w http.ResponseWriter, r *http.Request, user common.User) commo return ferr } headerVars.Zone = "topics" + headerVars.MetaDesc = headerVars.Settings["meta_desc"].(string) // TODO: Add a function for the qlist stuff var qlist string @@ -316,6 +317,7 @@ func routeForum(w http.ResponseWriter, r *http.Request, user common.User, sfid s return common.InternalError(err, w, r) } headerVars.Zone = "view_forum" + headerVars.MetaDesc = headerVars.Settings["meta_desc"].(string) // Calculate the offset var offset int diff --git a/schema/mssql/inserts.sql b/schema/mssql/inserts.sql index 4b794aec..92c49c5b 100644 --- a/schema/mssql/inserts.sql +++ b/schema/mssql/inserts.sql @@ -3,6 +3,7 @@ INSERT INTO [settings] ([name],[content],[type]) VALUES ('url_tags','1','bool'); INSERT INTO [settings] ([name],[content],[type],[constraints]) VALUES ('activation_type','1','list','1-3'); INSERT INTO [settings] ([name],[content],[type]) VALUES ('bigpost_min_words','250','int'); INSERT INTO [settings] ([name],[content],[type]) VALUES ('megapost_min_words','1000','int'); +INSERT INTO [settings] ([name],[content],[type]) VALUES ('meta_desc','','html-attribute'); INSERT INTO [themes] ([uname],[default]) VALUES ('tempra-simple',1); INSERT INTO [emails] ([email],[uid],[validated]) VALUES ('admin@localhost',1,1); INSERT INTO [users_groups] ([name],[permissions],[plugin_perms],[is_mod],[is_admin],[tag]) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}','{}',1,1,'Admin'); diff --git a/schema/mysql/inserts.sql b/schema/mysql/inserts.sql index 6a48d6e6..afc9b0f4 100644 --- a/schema/mysql/inserts.sql +++ b/schema/mysql/inserts.sql @@ -3,6 +3,7 @@ INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('url_tags','1','bool'); INSERT INTO `settings`(`name`,`content`,`type`,`constraints`) VALUES ('activation_type','1','list','1-3'); INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('bigpost_min_words','250','int'); INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('megapost_min_words','1000','int'); +INSERT INTO `settings`(`name`,`content`,`type`) VALUES ('meta_desc','','html-attribute'); INSERT INTO `themes`(`uname`,`default`) VALUES ('tempra-simple',1); INSERT INTO `emails`(`email`,`uid`,`validated`) VALUES ('admin@localhost',1,1); INSERT INTO `users_groups`(`name`,`permissions`,`plugin_perms`,`is_mod`,`is_admin`,`tag`) VALUES ('Administrator','{"BanUsers":true,"ActivateUsers":true,"EditUser":true,"EditUserEmail":true,"EditUserPassword":true,"EditUserGroup":true,"EditUserGroupSuperMod":true,"EditUserGroupAdmin":false,"EditGroup":true,"EditGroupLocalPerms":true,"EditGroupGlobalPerms":true,"EditGroupSuperMod":true,"EditGroupAdmin":false,"ManageForums":true,"EditSettings":true,"ManageThemes":true,"ManagePlugins":true,"ViewAdminLogs":true,"ViewIPs":true,"UploadFiles":true,"ViewTopic":true,"LikeItem":true,"CreateTopic":true,"EditTopic":true,"DeleteTopic":true,"CreateReply":true,"EditReply":true,"DeleteReply":true,"PinTopic":true,"CloseTopic":true}','{}',1,1,'Admin'); diff --git a/schema/pgsql/inserts.sql b/schema/pgsql/inserts.sql index 136d3909..04b01d3a 100644 --- a/schema/pgsql/inserts.sql +++ b/schema/pgsql/inserts.sql @@ -27,3 +27,4 @@ ; ; ; +; diff --git a/template_forum.go b/template_forum.go index e03a0aea..95267661 100644 --- a/template_forum.go +++ b/template_forum.go @@ -3,9 +3,9 @@ // Code generated by Gosora. More below: /* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */ package main +import "strconv" import "net/http" import "./common" -import "strconv" // nolint func init() { @@ -44,10 +44,16 @@ w.Write([]byte(tmpl_forum_vars.CurrentUser.Session)) w.Write(header_10) w.Write([]byte(tmpl_forum_vars.Header.Site.URL)) w.Write(header_11) -if !tmpl_forum_vars.CurrentUser.IsSuperMod { +if tmpl_forum_vars.Header.MetaDesc != "" { w.Write(header_12) -} +w.Write([]byte(tmpl_forum_vars.Header.MetaDesc)) w.Write(header_13) +} +w.Write(header_14) +if !tmpl_forum_vars.CurrentUser.IsSuperMod { +w.Write(header_15) +} +w.Write(header_16) w.Write(menu_0) w.Write(menu_1) w.Write([]byte(tmpl_forum_vars.Header.Site.ShortName)) @@ -62,16 +68,16 @@ w.Write(menu_5) w.Write(menu_6) } w.Write(menu_7) -w.Write(header_14) +w.Write(header_17) if tmpl_forum_vars.Header.Widgets.RightSidebar != "" { -w.Write(header_15) +w.Write(header_18) } -w.Write(header_16) +w.Write(header_19) if len(tmpl_forum_vars.Header.NoticeList) != 0 { for _, item := range tmpl_forum_vars.Header.NoticeList { -w.Write(header_17) +w.Write(header_20) w.Write([]byte(item)) -w.Write(header_18) +w.Write(header_21) } } if tmpl_forum_vars.Page > 1 { diff --git a/template_forums.go b/template_forums.go index 02914019..045b8e66 100644 --- a/template_forums.go +++ b/template_forums.go @@ -43,10 +43,16 @@ w.Write([]byte(tmpl_forums_vars.CurrentUser.Session)) w.Write(header_10) w.Write([]byte(tmpl_forums_vars.Header.Site.URL)) w.Write(header_11) -if !tmpl_forums_vars.CurrentUser.IsSuperMod { +if tmpl_forums_vars.Header.MetaDesc != "" { w.Write(header_12) -} +w.Write([]byte(tmpl_forums_vars.Header.MetaDesc)) w.Write(header_13) +} +w.Write(header_14) +if !tmpl_forums_vars.CurrentUser.IsSuperMod { +w.Write(header_15) +} +w.Write(header_16) w.Write(menu_0) w.Write(menu_1) w.Write([]byte(tmpl_forums_vars.Header.Site.ShortName)) @@ -61,16 +67,16 @@ w.Write(menu_5) w.Write(menu_6) } w.Write(menu_7) -w.Write(header_14) +w.Write(header_17) if tmpl_forums_vars.Header.Widgets.RightSidebar != "" { -w.Write(header_15) +w.Write(header_18) } -w.Write(header_16) +w.Write(header_19) if len(tmpl_forums_vars.Header.NoticeList) != 0 { for _, item := range tmpl_forums_vars.Header.NoticeList { -w.Write(header_17) +w.Write(header_20) w.Write([]byte(item)) -w.Write(header_18) +w.Write(header_21) } } w.Write(forums_0) diff --git a/template_guilds_guild_list.go b/template_guilds_guild_list.go index 7b575ba2..db7f9283 100644 --- a/template_guilds_guild_list.go +++ b/template_guilds_guild_list.go @@ -3,10 +3,10 @@ // Code generated by Gosora. More below: /* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */ package main -import "net/http" -import "./common" import "./extend/guilds/lib" import "strconv" +import "net/http" +import "./common" // nolint func init() { @@ -42,10 +42,16 @@ w.Write([]byte(tmpl_guilds_guild_list_vars.CurrentUser.Session)) w.Write(header_10) w.Write([]byte(tmpl_guilds_guild_list_vars.Header.Site.URL)) w.Write(header_11) -if !tmpl_guilds_guild_list_vars.CurrentUser.IsSuperMod { +if tmpl_guilds_guild_list_vars.Header.MetaDesc != "" { w.Write(header_12) -} +w.Write([]byte(tmpl_guilds_guild_list_vars.Header.MetaDesc)) w.Write(header_13) +} +w.Write(header_14) +if !tmpl_guilds_guild_list_vars.CurrentUser.IsSuperMod { +w.Write(header_15) +} +w.Write(header_16) w.Write(menu_0) w.Write(menu_1) w.Write([]byte(tmpl_guilds_guild_list_vars.Header.Site.ShortName)) @@ -60,16 +66,16 @@ w.Write(menu_5) w.Write(menu_6) } w.Write(menu_7) -w.Write(header_14) +w.Write(header_17) if tmpl_guilds_guild_list_vars.Header.Widgets.RightSidebar != "" { -w.Write(header_15) +w.Write(header_18) } -w.Write(header_16) +w.Write(header_19) if len(tmpl_guilds_guild_list_vars.Header.NoticeList) != 0 { for _, item := range tmpl_guilds_guild_list_vars.Header.NoticeList { -w.Write(header_17) +w.Write(header_20) w.Write([]byte(item)) -w.Write(header_18) +w.Write(header_21) } } w.Write(guilds_guild_list_0) diff --git a/template_list.go b/template_list.go index 4f08e252..bf7f9a45 100644 --- a/template_list.go +++ b/template_list.go @@ -30,11 +30,15 @@ var header_11 = []byte(`"; + `) +var header_12 = []byte(``) +var header_14 = []byte(`
+var header_15 = []byte(`.supermod_only { display: none !important; }`) +var header_16 = []byte(`