parent
e7b2333481
commit
1fe51768f0
|
@ -42,10 +42,10 @@ func NewSQLReplyStore(acc *qgen.Accumulator, cache ReplyCache) (*SQLReplyStore,
|
||||||
re := "replies"
|
re := "replies"
|
||||||
return &SQLReplyStore{
|
return &SQLReplyStore{
|
||||||
cache: cache,
|
cache: cache,
|
||||||
get: acc.Select(re).Columns("tid, content, createdBy, createdAt, lastEdit, lastEditBy, ip, likeCount, attachCount, actionType").Where("rid=?").Prepare(),
|
get: acc.Select(re).Columns("tid,content,createdBy,createdAt,lastEdit,lastEditBy,ip,likeCount,attachCount,actionType").Where("rid=?").Prepare(),
|
||||||
getAll: acc.Select(re).Columns("rid,tid,content,createdBy,createdAt,lastEdit,lastEditBy,ip,likeCount,attachCount,actionType").Prepare(),
|
getAll: acc.Select(re).Columns("rid,tid,content,createdBy,createdAt,lastEdit,lastEditBy,ip,likeCount,attachCount,actionType").Prepare(),
|
||||||
exists: acc.Exists(re, "rid").Prepare(),
|
exists: acc.Exists(re, "rid").Prepare(),
|
||||||
create: acc.Insert(re).Columns("tid, content, parsed_content, createdAt, lastUpdated, ip, words, createdBy").Fields("?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?").Prepare(),
|
create: acc.Insert(re).Columns("tid,content,parsed_content,createdAt,lastUpdated,ip,words,createdBy").Fields("?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?").Prepare(),
|
||||||
count: acc.Count(re).Prepare(),
|
count: acc.Count(re).Prepare(),
|
||||||
countUser: acc.Count(re).Where("createdBy=?").Prepare(),
|
countUser: acc.Count(re).Where("createdBy=?").Prepare(),
|
||||||
countWordUser: acc.Count(re).Where("createdBy=? AND words>=?").Prepare(),
|
countWordUser: acc.Count(re).Where("createdBy=? AND words>=?").Prepare(),
|
||||||
|
|
40
misc_test.go
40
misc_test.go
|
@ -1803,6 +1803,46 @@ func TestWordFilters(t *testing.T) {
|
||||||
// TODO: Any more tests we could do?
|
// TODO: Any more tests we could do?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMFAStore(t *testing.T) {
|
||||||
|
_, err := c.MFAstore.Get(-1)
|
||||||
|
recordMustNotExist(t, err, "mfa uid -1 should not exist")
|
||||||
|
_, err = c.MFAstore.Get(0)
|
||||||
|
recordMustNotExist(t, err, "mfa uid 0 should not exist")
|
||||||
|
_, err = c.MFAstore.Get(1)
|
||||||
|
recordMustNotExist(t, err, "mfa uid 1 should not exist")
|
||||||
|
|
||||||
|
secret := "test"
|
||||||
|
expectNilErr(t, c.MFAstore.Create(secret, 1))
|
||||||
|
_, err = c.MFAstore.Get(0)
|
||||||
|
recordMustNotExist(t, err, "mfa uid 0 should not exist")
|
||||||
|
var scratches []string
|
||||||
|
it, err := c.MFAstore.Get(1)
|
||||||
|
test := func(j int) {
|
||||||
|
expectNilErr(t, err)
|
||||||
|
expect(t, it.UID == 1, fmt.Sprintf("UID should be 1 not %d", it.UID))
|
||||||
|
expect(t, it.Secret == secret, fmt.Sprintf("Secret should be '%s' not %s", secret, it.Secret))
|
||||||
|
expect(t, len(it.Scratch) == 8, fmt.Sprintf("Scratch should be 8 not %d", len(it.Scratch)))
|
||||||
|
for i, scratch := range it.Scratch {
|
||||||
|
expect(t, scratch != "", fmt.Sprintf("scratch %d should not be empty", i))
|
||||||
|
if scratches != nil {
|
||||||
|
if j == i {
|
||||||
|
expect(t, scratches[i] != scratch, fmt.Sprintf("scratches[%d] should not be %s", i, scratches[i]))
|
||||||
|
} else {
|
||||||
|
expect(t, scratches[i] == scratch, fmt.Sprintf("scratches[%d] should be %s not %s", i, scratches[i], scratch))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
scratches = make([]string, 8)
|
||||||
|
copy(scratches, it.Scratch)
|
||||||
|
}
|
||||||
|
test(0)
|
||||||
|
for i := 0; i < len(scratches); i++ {
|
||||||
|
expectNilErr(t, it.BurnScratch(i))
|
||||||
|
it, err = c.MFAstore.Get(1)
|
||||||
|
test(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Expand upon the valid characters which can go in URLs?
|
// TODO: Expand upon the valid characters which can go in URLs?
|
||||||
func TestSlugs(t *testing.T) {
|
func TestSlugs(t *testing.T) {
|
||||||
l := &MEPairList{nil}
|
l := &MEPairList{nil}
|
||||||
|
|
|
@ -5,21 +5,21 @@
|
||||||
<div class="rowitem"><h1 itemprop="name">{{lang "forums_head"}}</h1></div>
|
<div class="rowitem"><h1 itemprop="name">{{lang "forums_head"}}</h1></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="rowblock forum_list">
|
<div class="rowblock forum_list">
|
||||||
{{range .ItemList}}<div id="forum_{{.ID}}" class="rowitem{{if (.Desc) or (.LastTopic.Title)}} datarow{{end}}" itemprop="itemListElement" itemscope
|
{{range .ItemList}}<div id="forum_{{.ID}}" class="rowitem{{if (.Desc) or (.LastTopic.Title)}} datarow{{end}}"itemprop="itemListElement" itemscope
|
||||||
itemtype="http://schema.org/ListItem">
|
itemtype="http://schema.org/ListItem">
|
||||||
<span class="forum_left shift_left">
|
<span class="forum_left shift_left">
|
||||||
<a href="{{.Link}}"itemprop="item">{{.Name}}</a><br>
|
<a href="{{.Link}}"itemprop="item">{{.Name}}</a><br>
|
||||||
{{if .Desc}}
|
{{if .Desc}}
|
||||||
<span class="rowsmall" itemprop="description">{{.Desc}}</span>
|
<span class="rowsmall"itemprop="description">{{.Desc}}</span>
|
||||||
{{else}}
|
{{else}}
|
||||||
<span class="rowsmall forum_nodesc">{{lang "forums_no_description"}}</span>
|
<span class="rowsmall forum_nodesc">{{lang "forums_no_description"}}</span>
|
||||||
{{end}}
|
{{end}}
|
||||||
</span>
|
</span>
|
||||||
<span class="forum_right shift_right">
|
<span class="forum_right shift_right">
|
||||||
{{if .LastReplyer.MicroAvatar}}<img class="extra_little_row_avatar"src="{{.LastReplyer.MicroAvatar}}" height=64 width=64 alt="Avatar"title="{{.LastReplyer.Name}}'s Avatar"aria-hidden="true">{{end}}
|
{{if .LastReplyer.MicroAvatar}}<img class="extra_little_row_avatar"src="{{.LastReplyer.MicroAvatar}}"height=64 width=64 alt="Avatar"title="{{.LastReplyer.Name}}'s Avatar"aria-hidden="true">{{end}}
|
||||||
<span>
|
<span>
|
||||||
<a {{if .LastTopic.Link}}href="{{.LastTopic.Link}}"{{else}}class="forum_no_poster"{{end}}>{{if .LastTopic.Title}}{{.LastTopic.Title}}{{else}}{{lang "forums_none"}}{{end}}</a>
|
<a {{if .LastTopic.Link}}href="{{.LastTopic.Link}}"{{else}}class="forum_no_poster"{{end}}>{{if .LastTopic.Title}}{{.LastTopic.Title}}{{else}}{{lang "forums_none"}}{{end}}</a>
|
||||||
{{if .LastTopicTime}}<br><span class="rowsmall" title="{{abstime .LastTopic.LastReplyAt}}">{{.LastTopicTime}}</span>{{end}}
|
{{if .LastTopicTime}}<br><span class="rowsmall"title="{{abstime .LastTopic.LastReplyAt}}">{{.LastTopicTime}}</span>{{end}}
|
||||||
</span>
|
</span>
|
||||||
</span><div style="clear:both;"></div>
|
</span><div style="clear:both;"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,16 +4,16 @@
|
||||||
<div class="userbit">
|
<div class="userbit">
|
||||||
<img src="{{.MicroAvatar}}"alt="Avatar"title="{{.CreatedByName}}'s Avatar"aria-hidden="true">
|
<img src="{{.MicroAvatar}}"alt="Avatar"title="{{.CreatedByName}}'s Avatar"aria-hidden="true">
|
||||||
<span class="nameAndTitle">
|
<span class="nameAndTitle">
|
||||||
<a href="{{.UserLink}}" class="real_username username">{{.CreatedByName}}</a>
|
<a href="{{.UserLink}}"class="real_username username">{{.CreatedByName}}</a>
|
||||||
{{if .Tag}}<a class="username hide_on_mobile user_tag" style="float:right;">{{.Tag}}</a>{{end}}
|
{{if .Tag}}<a class="username hide_on_mobile user_tag" style="float:right;">{{.Tag}}</a>{{end}}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<span class="controls">
|
<span class="controls">
|
||||||
{{if $.CurrentUser.IsMod}}
|
{{if $.CurrentUser.IsMod}}
|
||||||
<a href="/profile/reply/edit/submit/{{.ID}}?s={{$.CurrentUser.Session}}" class="mod_button" title="{{lang "profile.comments_edit_tooltip"}}" aria-label="{{lang "profile.comments_edit_aria"}}"><button class="username edit_item edit_label"></button></a>
|
<a href="/profile/reply/edit/submit/{{.ID}}?s={{$.CurrentUser.Session}}"class="mod_button"title="{{lang "profile.comments_edit_tooltip"}}" aria-label="{{lang "profile.comments_edit_aria"}}"><button class="username edit_item edit_label"></button></a>
|
||||||
<a href="/profile/reply/delete/submit/{{.ID}}?s={{$.CurrentUser.Session}}" class="mod_button" title="{{lang "profile.comments_delete_tooltip"}}" aria-label="{{lang "profile.comments_delete_aria"}}"><button class="username delete_item delete_label"></button></a>
|
<a href="/profile/reply/delete/submit/{{.ID}}?s={{$.CurrentUser.Session}}"class="mod_button"title="{{lang "profile.comments_delete_tooltip"}}" aria-label="{{lang "profile.comments_delete_aria"}}"><button class="username delete_item delete_label"></button></a>
|
||||||
{{end}}
|
{{end}}
|
||||||
<a class="mod_button" href="/report/submit/{{.ID}}?s={{$.CurrentUser.Session}}&type=user-reply"><button class="username report_item flag_label" title="{{lang "profile.comments_report_tooltip"}}" aria-label="{{lang "profile.comments_report_aria"}}"></button></a>
|
<a class="mod_button"href="/report/submit/{{.ID}}?s={{$.CurrentUser.Session}}&type=user-reply"><button class="username report_item flag_label"title="{{lang "profile.comments_report_tooltip"}}" aria-label="{{lang "profile.comments_report_aria"}}"></button></a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="content_column">
|
<div class="content_column">
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<span class="selector"></span>
|
<span class="selector"></span>
|
||||||
<a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar"title="{{.Creator.Name}}'s Avatar"aria-hidden="true"></a>
|
<a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar"title="{{.Creator.Name}}'s Avatar"aria-hidden="true"></a>
|
||||||
<span class="topic_inner_left">
|
<span class="topic_inner_left">
|
||||||
<a class="rowtopic"href="{{.Link}}"itemprop="itemListElement" title="{{.Title}}"><span>{{.Title}}</span></a> {{if .ForumName}}<a class="rowsmall parent_forum"href="{{.ForumLink}}"title="{{.ForumName}}">{{.ForumName}}</a>{{end}}
|
<a class="rowtopic"href="{{.Link}}"itemprop="itemListElement"title="{{.Title}}"><span>{{.Title}}</span></a> {{if .ForumName}}<a class="rowsmall parent_forum"href="{{.ForumLink}}"title="{{.ForumName}}">{{.ForumName}}</a>{{end}}
|
||||||
<br><a class="rowsmall starter"href="{{.Creator.Link}}"title="{{.Creator.Name}}">{{.Creator.Name}}</a>
|
<br><a class="rowsmall starter"href="{{.Creator.Link}}"title="{{.Creator.Name}}">{{.Creator.Name}}</a>
|
||||||
{{/** TODO: Avoid the double '|' when both .IsClosed and .Sticky are set to true. We could probably do this with CSS **/}}
|
{{/** TODO: Avoid the double '|' when both .IsClosed and .Sticky are set to true. We could probably do this with CSS **/}}
|
||||||
{{if .IsClosed}}<span class="rowsmall topic_status_e topic_status_closed"title="{{lang "status.closed_tooltip"}}"> | 🔒︎</span>{{end}}
|
{{if .IsClosed}}<span class="rowsmall topic_status_e topic_status_closed"title="{{lang "status.closed_tooltip"}}"> | 🔒︎</span>{{end}}
|
||||||
|
@ -24,10 +24,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="rowitem topic_right passive datarow">
|
<div class="rowitem topic_right passive datarow">
|
||||||
<div class="topic_right_inside">
|
<div class="topic_right_inside">
|
||||||
<a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}" height=64 alt="Avatar"title="{{.LastUser.Name}}'s Avatar" aria-hidden="true"></a>
|
<a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}"height=64 alt="Avatar"title="{{.LastUser.Name}}'s Avatar"aria-hidden="true"></a>
|
||||||
<span>
|
<span>
|
||||||
<a href="{{.LastUser.Link}}" class="lastName" title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br>
|
<a href="{{.LastUser.Link}}"class="lastName"title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br>
|
||||||
<a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}" class="rowsmall lastReplyAt" title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a>
|
<a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}"class="rowsmall lastReplyAt"title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<nav class="colstack_left" aria-label="{{lang "panel_menu_aria"}}">
|
<nav class="colstack_left"aria-label="{{lang "panel_menu_aria"}}">
|
||||||
<!--<div class="colstack_item colstack_head">
|
<!--<div class="colstack_item colstack_head">
|
||||||
<div class="rowitem back_to_site"><a href="/">Back to site</a></div>
|
<div class="rowitem back_to_site"><a href="/">Back to site</a></div>
|
||||||
</div>-->
|
</div>-->
|
||||||
|
|
Loading…
Reference in New Issue