Testing feature flags
This commit is contained in:
parent
6c4b1965c1
commit
81ab9d29b0
|
@ -124,7 +124,7 @@ const (
|
||||||
ThreadViewDebounceCooldown = 1 * time.Hour
|
ThreadViewDebounceCooldown = 1 * time.Hour
|
||||||
|
|
||||||
// Enable user-owned forums (feature flag)
|
// Enable user-owned forums (feature flag)
|
||||||
UserForumsEnabled = true
|
UserForumsEnabled = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// User-Owned Forums: Quota settings for how many forums a user can own.
|
// User-Owned Forums: Quota settings for how many forums a user can own.
|
||||||
|
|
|
@ -25,6 +25,8 @@ func Search() http.HandlerFunc {
|
||||||
searchTerm = r.FormValue("q")
|
searchTerm = r.FormValue("q")
|
||||||
byUsername = r.FormValue("username")
|
byUsername = r.FormValue("username")
|
||||||
postType = r.FormValue("type")
|
postType = r.FormValue("type")
|
||||||
|
inForum = r.FormValue("in")
|
||||||
|
categories = []string{}
|
||||||
sort = r.FormValue("sort")
|
sort = r.FormValue("sort")
|
||||||
sortOK bool
|
sortOK bool
|
||||||
)
|
)
|
||||||
|
@ -45,6 +47,14 @@ func Search() http.HandlerFunc {
|
||||||
postType = "all"
|
postType = "all"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// In forums
|
||||||
|
switch inForum {
|
||||||
|
case "official":
|
||||||
|
categories = config.ForumCategories
|
||||||
|
case "community":
|
||||||
|
categories = []string{""}
|
||||||
|
}
|
||||||
|
|
||||||
// Get the current user.
|
// Get the current user.
|
||||||
currentUser, err := session.CurrentUser(r)
|
currentUser, err := session.CurrentUser(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -80,7 +90,7 @@ func Search() http.HandlerFunc {
|
||||||
)
|
)
|
||||||
pager.ParsePage(r)
|
pager.ParsePage(r)
|
||||||
|
|
||||||
posts, err := models.SearchForum(currentUser, search, filters, pager)
|
posts, err := models.SearchForum(currentUser, categories, search, filters, pager)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
session.FlashError(w, r, "Couldn't search the forums: %s", err)
|
session.FlashError(w, r, "Couldn't search the forums: %s", err)
|
||||||
templates.Redirect(w, "/")
|
templates.Redirect(w, "/")
|
||||||
|
@ -109,6 +119,7 @@ func Search() http.HandlerFunc {
|
||||||
"SearchTerm": searchTerm,
|
"SearchTerm": searchTerm,
|
||||||
"ByUsername": byUsername,
|
"ByUsername": byUsername,
|
||||||
"Type": postType,
|
"Type": postType,
|
||||||
|
"InForum": inForum,
|
||||||
"Sort": sort,
|
"Sort": sort,
|
||||||
}
|
}
|
||||||
if err := tmpl.Execute(w, r, vars); err != nil {
|
if err := tmpl.Execute(w, r, vars); err != nil {
|
||||||
|
|
|
@ -81,7 +81,7 @@ type ForumSearchFilters struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SearchForum searches the forum.
|
// SearchForum searches the forum.
|
||||||
func SearchForum(user *User, search *Search, filters ForumSearchFilters, pager *Pagination) ([]*Comment, error) {
|
func SearchForum(user *User, categories []string, search *Search, filters ForumSearchFilters, pager *Pagination) ([]*Comment, error) {
|
||||||
var (
|
var (
|
||||||
coms = []*Comment{}
|
coms = []*Comment{}
|
||||||
query = (&Comment{}).Preload()
|
query = (&Comment{}).Preload()
|
||||||
|
@ -90,6 +90,11 @@ func SearchForum(user *User, search *Search, filters ForumSearchFilters, pager *
|
||||||
placeholders = []interface{}{}
|
placeholders = []interface{}{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if len(categories) > 0 {
|
||||||
|
wheres = append(wheres, "category IN ?")
|
||||||
|
placeholders = append(placeholders, categories)
|
||||||
|
}
|
||||||
|
|
||||||
// Hide explicit forum if user hasn't opted into it.
|
// Hide explicit forum if user hasn't opted into it.
|
||||||
if !user.Explicit && !user.IsAdmin {
|
if !user.Explicit && !user.IsAdmin {
|
||||||
wheres = append(wheres, "forums.explicit = false")
|
wheres = append(wheres, "forums.explicit = false")
|
||||||
|
|
|
@ -873,11 +873,11 @@
|
||||||
|
|
||||||
<h3 id="create-forums">Can I create my own forums?</h3>
|
<h3 id="create-forums">Can I create my own forums?</h3>
|
||||||
|
|
||||||
|
{{if .FeatureUserForumsEnabled}}
|
||||||
<p>
|
<p>
|
||||||
<span class="tag is-success">NEW: August 30, 2024</span>
|
<span class="tag is-success">NEW: August 30, 2024</span>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
{{if .FeatureUserForumsEnabled}}
|
|
||||||
<p>
|
<p>
|
||||||
<strong>Yes!</strong> As of August 30, 2024 (the two-year anniversary of {{PrettyTitle}}),
|
<strong>Yes!</strong> As of August 30, 2024 (the two-year anniversary of {{PrettyTitle}}),
|
||||||
we now have <strong>Community Forums</strong> where members are allowed to create their own
|
we now have <strong>Community Forums</strong> where members are allowed to create their own
|
||||||
|
|
|
@ -85,7 +85,7 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{if .CurrentUser.IsAdmin}}
|
{{if .CurrentUser.HasAdminScope "admin.forum.manage"}}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="category">
|
<label class="label" for="category">
|
||||||
Category
|
Category
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
|
|
||||||
<div class="column px-1">
|
<div class="column pr-1">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="type">Show:</label>
|
<label class="label" for="type">Show:</label>
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
|
@ -78,6 +78,24 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{if .FeatureUserForumsEnabled}}
|
||||||
|
<div class="column px-1">
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="in_forum">In forums:</label>
|
||||||
|
<div class="select is-fullwidth">
|
||||||
|
<select id="in_forum" name="in">
|
||||||
|
<option value="">All forums</option>
|
||||||
|
<option value="official"{{if eq .InForum "official"}} selected{{end}}>Official nonshy forums</option>
|
||||||
|
<option value="community"{{if eq .InForum "community"}} selected{{end}}>Community forums only</option>
|
||||||
|
{{if .CurrentUser.HasForumSubscriptions}}
|
||||||
|
<option value="followed"{{if eq .InForum "followed"}} selected{{end}}>My List</option>
|
||||||
|
{{end}}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
<div class="column px-1">
|
<div class="column px-1">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label" for="sort">Sort by:</label>
|
<label class="label" for="sort">Sort by:</label>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user