Skip to content

Commit

Permalink
Corrected a typo.
Browse files Browse the repository at this point in the history
  • Loading branch information
IoIxD committed Sep 22, 2023
1 parent dae2ae9 commit e62f7dc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ require (
github.com/pkg/errors v0.9.1 // indirect
go4.org v0.0.0-20200411211856-f5505b9728dd // indirect
golang.org/x/crypto v0.12.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
)

Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g=
golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -186,6 +188,8 @@ golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM=
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0 h1:CM0HF96J0hcLAwsHPJZjfdNzs0gftsLfgKt57wWHJ0o=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
Expand Down
2 changes: 1 addition & 1 deletion resources/templates/searchforum.gohtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{template "header.gohtml"}}

{{$title := print "Searching" .Forum.Name " forum on " .Guild.Name}}
{{$title := print "Searching " .Forum.Name " forum on " .Guild.Name}}
<title>{{$title}}</title>
<meta property="og:title" content="{{$title}}">
<meta property="og:type" content="website">
Expand Down
19 changes: 16 additions & 3 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/diamondburned/arikawa/v3/utils/httputil"
"github.com/go-chi/chi/v5"
"github.com/go-chi/chi/v5/middleware"
"golang.org/x/exp/slices"
)

type server struct {
Expand Down Expand Up @@ -342,7 +343,13 @@ func (s *server) searchForum(w http.ResponseWriter, r *http.Request) {
}
arr := strings.Split(query," ")

if query == "" {
// Show blank page.
s.executeTemplate(w, r, "searchforum.gohtml", ctx)
return
}
var posts []Post
titles := []string{}
for _, thread := range channels {
if thread.ParentID != forum.ID ||
thread.Type != discord.GuildPublicThread {
Expand All @@ -356,13 +363,20 @@ func (s *server) searchForum(w http.ResponseWriter, r *http.Request) {
}
}
}
if strings.Contains(strings.ToLower(post.Channel.Name),strings.ToLower(query)) {
if slices.Contains(titles, post.Channel.Name) {
continue;
}
if strings.Contains(strings.ToLower(post.Channel.Name),query) {
posts = append(posts, post)
titles = append(titles, post.Channel.Name)
} else {
for _, str := range(arr) {
if len(str) <= 1 {
continue;
}
if strings.Contains(strings.ToLower(post.Channel.Name),strings.ToLower(str)) {
posts = append(posts, post)
continue;
titles = append(titles, post.Channel.Name)
}
}
}
Expand Down Expand Up @@ -581,7 +595,6 @@ func (s *server) getPost(w http.ResponseWriter, r *http.Request) {
if restrictRole != 0 {
goodToGo := false
for _, rl := range auth.OtherRoles {
fmt.Println(rl.ID, restrictRole)
if int(rl.ID) == restrictRole {
goodToGo = true
break
Expand Down

0 comments on commit e62f7dc

Please sign in to comment.