Added support for meta descriptions. You can configure this from the Control Panel's Setting Manager.

Added tests for forum creation.
This commit is contained in:
Azareal 2017-12-25 06:12:19 +00:00
parent e492088b97
commit e919812ee2
16 changed files with 137 additions and 64 deletions

View File

@ -18,6 +18,7 @@ type HeaderVars struct {
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
MetaDesc string
Writer http.ResponseWriter
ExtData ExtData
}

View File

@ -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
}

View File

@ -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?

View File

@ -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

View File

@ -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');

View File

@ -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');

View File

@ -27,3 +27,4 @@
;
;
;
;

View File

@ -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 {

View File

@ -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)

View File

@ -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)

View File

@ -30,11 +30,15 @@ var header_11 = []byte(`";
</script>
<script type="text/javascript" src="/static/global.js"></script>
<meta name="viewport" content="width=device-width,initial-scale = 1.0, maximum-scale=1.0,user-scalable=no" />
`)
var header_12 = []byte(`<meta name="description" content="`)
var header_13 = []byte(`" />`)
var header_14 = []byte(`
</head>
<body>
<style>`)
var header_12 = []byte(`.supermod_only { display: none !important; }`)
var header_13 = []byte(`</style>
var header_15 = []byte(`.supermod_only { display: none !important; }`)
var header_16 = []byte(`</style>
<div class="container">
`)
var menu_0 = []byte(`<nav class="nav">
@ -73,13 +77,13 @@ var menu_7 = []byte(`
<div style="clear: both;"></div>
</nav>
`)
var header_14 = []byte(`
var header_17 = []byte(`
<div id="back"><div id="main" `)
var header_15 = []byte(`class="shrink_main"`)
var header_16 = []byte(`>
var header_18 = []byte(`class="shrink_main"`)
var header_19 = []byte(`>
`)
var header_17 = []byte(`<div class="alert">`)
var header_18 = []byte(`</div>`)
var header_20 = []byte(`<div class="alert">`)
var header_21 = []byte(`</div>`)
var topic_0 = []byte(`
<form id="edit_topic_form" action='/topic/edit/submit/`)

View File

@ -44,10 +44,16 @@ w.Write([]byte(tmpl_profile_vars.CurrentUser.Session))
w.Write(header_10)
w.Write([]byte(tmpl_profile_vars.Header.Site.URL))
w.Write(header_11)
if !tmpl_profile_vars.CurrentUser.IsSuperMod {
if tmpl_profile_vars.Header.MetaDesc != "" {
w.Write(header_12)
}
w.Write([]byte(tmpl_profile_vars.Header.MetaDesc))
w.Write(header_13)
}
w.Write(header_14)
if !tmpl_profile_vars.CurrentUser.IsSuperMod {
w.Write(header_15)
}
w.Write(header_16)
w.Write(menu_0)
w.Write(menu_1)
w.Write([]byte(tmpl_profile_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_profile_vars.Header.Widgets.RightSidebar != "" {
w.Write(header_15)
w.Write(header_18)
}
w.Write(header_16)
w.Write(header_19)
if len(tmpl_profile_vars.Header.NoticeList) != 0 {
for _, item := range tmpl_profile_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(profile_0)

View File

@ -44,10 +44,16 @@ w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(header_10)
w.Write([]byte(tmpl_topic_vars.Header.Site.URL))
w.Write(header_11)
if !tmpl_topic_vars.CurrentUser.IsSuperMod {
if tmpl_topic_vars.Header.MetaDesc != "" {
w.Write(header_12)
}
w.Write([]byte(tmpl_topic_vars.Header.MetaDesc))
w.Write(header_13)
}
w.Write(header_14)
if !tmpl_topic_vars.CurrentUser.IsSuperMod {
w.Write(header_15)
}
w.Write(header_16)
w.Write(menu_0)
w.Write(menu_1)
w.Write([]byte(tmpl_topic_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_topic_vars.Header.Widgets.RightSidebar != "" {
w.Write(header_15)
w.Write(header_18)
}
w.Write(header_16)
w.Write(header_19)
if len(tmpl_topic_vars.Header.NoticeList) != 0 {
for _, item := range tmpl_topic_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(topic_0)

View File

@ -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_topic_alt_vars.CurrentUser.Session))
w.Write(header_10)
w.Write([]byte(tmpl_topic_alt_vars.Header.Site.URL))
w.Write(header_11)
if !tmpl_topic_alt_vars.CurrentUser.IsSuperMod {
if tmpl_topic_alt_vars.Header.MetaDesc != "" {
w.Write(header_12)
}
w.Write([]byte(tmpl_topic_alt_vars.Header.MetaDesc))
w.Write(header_13)
}
w.Write(header_14)
if !tmpl_topic_alt_vars.CurrentUser.IsSuperMod {
w.Write(header_15)
}
w.Write(header_16)
w.Write(menu_0)
w.Write(menu_1)
w.Write([]byte(tmpl_topic_alt_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_topic_alt_vars.Header.Widgets.RightSidebar != "" {
w.Write(header_15)
w.Write(header_18)
}
w.Write(header_16)
w.Write(header_19)
if len(tmpl_topic_alt_vars.Header.NoticeList) != 0 {
for _, item := range tmpl_topic_alt_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_topic_alt_vars.Page > 1 {

View File

@ -44,10 +44,16 @@ w.Write([]byte(tmpl_topics_vars.CurrentUser.Session))
w.Write(header_10)
w.Write([]byte(tmpl_topics_vars.Header.Site.URL))
w.Write(header_11)
if !tmpl_topics_vars.CurrentUser.IsSuperMod {
if tmpl_topics_vars.Header.MetaDesc != "" {
w.Write(header_12)
}
w.Write([]byte(tmpl_topics_vars.Header.MetaDesc))
w.Write(header_13)
}
w.Write(header_14)
if !tmpl_topics_vars.CurrentUser.IsSuperMod {
w.Write(header_15)
}
w.Write(header_16)
w.Write(menu_0)
w.Write(menu_1)
w.Write([]byte(tmpl_topics_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_topics_vars.Header.Widgets.RightSidebar != "" {
w.Write(header_15)
w.Write(header_18)
}
w.Write(header_16)
w.Write(header_19)
if len(tmpl_topics_vars.Header.NoticeList) != 0 {
for _, item := range tmpl_topics_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(topics_0)

View File

@ -16,6 +16,7 @@
</script>
<script type="text/javascript" src="/static/global.js"></script>
<meta name="viewport" content="width=device-width,initial-scale = 1.0, maximum-scale=1.0,user-scalable=no" />
{{if .Header.MetaDesc}}<meta name="description" content="{{.Header.MetaDesc}}" />{{end}}
</head>
<body>
<style>{{if not .CurrentUser.IsSuperMod}}.supermod_only { display: none !important; }{{end}}</style>