spoiler fix, default search options

This commit is contained in:
Ryan Stafford 2023-07-16 13:45:40 -04:00
parent 0f4242e61e
commit 8c7aabab72
6 changed files with 8 additions and 8 deletions

View file

@ -140,7 +140,7 @@ var funcMap = template.FuncMap{
body = buf.String()
body = strings.Replace(body, `<img `, `<img loading="lazy" `, -1)
body = LemmyLinkRewrite(body, host, os.Getenv("LEMMY_DOMAIN"))
body = RegReplace(body, `::: spoiler (.*?)\n([\S\s]*?):::`, "<details><summary>$1</summary>$2</details>")
body = RegReplace(body, `::: ?spoiler (.*?)\n([\S\s]*?):::`, "<details><summary>$1</summary>$2</details>")
return template.HTML(body)
},
"rmmarkdown": func(body string) string {

View file

@ -544,7 +544,7 @@ func (state *State) Search(searchtype string) {
search := types.Search{
Q: state.Query,
Sort: types.NewOptional(types.SortType(state.Sort)),
ListingType: types.NewOptional(types.ListingType("All")),
ListingType: types.NewOptional(types.ListingType(state.Listing)),
Type: types.NewOptional(types.SearchType(searchtype)),
Limit: types.NewOptional(int64(25)),
Page: types.NewOptional(int64(state.Page)),

View file

@ -29,9 +29,7 @@
{{ template "nsfw.html" }}
{{ else }}
<main>
{{ if or (contains .Sort "Top") (and (not .PostID) (not .User) (not .Community) (not .Activities) (eq .Op ""))}}
{{ template "menu.html" . }}
{{ end}}
{{ template "menu.html" . }}
{{ if .Error }}
<div class="error">

View file

@ -27,12 +27,13 @@
{{ template "nsfw.html" }}
{{ else }}
<main>
{{ if or (contains .Sort "Top") (and (not .PostID) (not .User) (not .Community) (not .Activities) (eq .Op ""))}}
{{ if or (.Query) (.SearchType) (and (not .PostID) (not .User) (not .Activities) (eq .Op ""))}}
{{ template "menu.html" . }}
{{ end}}
{{ if or (ne .Query "") .Communities }}
<form class="search" method="GET">
<input type="hidden" name="sort" value="{{.Sort}}">
<div>search</div>
<div class="query">
<input type="text" name="q" value="{{.Query}}">

View file

@ -9,7 +9,7 @@
<a href="/{{$host}}/c/{{fullcname $c.Community}}">{{$c.Community.Name}}</a>
<span> - </span>
{{ end }}
<a href="/{{$host}}/search?searchtype=Communities" class="more">more »</a>
<a href="/{{$host}}/search?searchtype=Communities&sort=TopAll" class="more">more »</a>
</div>
<div class="right">
{{ if .Session }}
@ -48,7 +48,7 @@
<span>: search</span>
{{ end }}
<ul>
{{ if .User }}
{{ if and .User (not .Query)}}
<li {{if eq .Op "" }}class="selected"{{end}}><a href="?">overview</a></li>
{{ if and .Session (eq .User.PersonView.Person.ID .Session.UserID) }}
<li {{if eq .Op "Saved"}}class="selected"{{end}}><a href="?view=Saved">saved</a></li>

View file

@ -9,6 +9,7 @@
{{ else if .Community }}
<input type="hidden" name="communityname" value="{{fullcname .Community.CommunityView.Community}}">
{{ end }}
<input type="hidden" name="sort" value="New">
</form>
{{ end }}