search can now load posts

This commit is contained in:
Ted Unangst 2023-03-27 12:47:48 -04:00
parent 10bca44dc5
commit 664f319b28
4 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,9 @@
changelog changelog
=== next
+ search can now load external posts
=== 0.9.91 One More Time === 0.9.91 One More Time
+ Swallow a follow bug. + Swallow a follow bug.

View File

@ -170,6 +170,7 @@ The
page lists recently seen honkers that are not otherwise tracked. page lists recently seen honkers that are not otherwise tracked.
It also allows the import of external objects via URL, either individual It also allows the import of external objects via URL, either individual
posts or actor URLs, in which case their recent outbox is imported. posts or actor URLs, in which case their recent outbox is imported.
Probably easier to use the search box for this.
.Ss Account .Ss Account
It's all about you. It's all about you.
An avatar may be selected from the An avatar may be selected from the

View File

@ -4,7 +4,7 @@
<form action="/ximport" method="POST"> <form action="/ximport" method="POST">
<input type="hidden" name="CSRF" value="{{ .XCSRF }}"> <input type="hidden" name="CSRF" value="{{ .XCSRF }}">
<p><span class="title">import</span> <p><span class="title">import</span>
<p><input tabindex=1 type="text" name="xid" autocomplete=off> - xid <p><input tabindex=1 type="text" name="q" autocomplete=off> - xid
<p><button tabindex=1 name="fetch" value="fetch">fetch</button> <p><button tabindex=1 name="fetch" value="fetch">fetch</button>
</form> </form>
</div> </div>

6
web.go
View File

@ -549,7 +549,7 @@ func serveractor(w http.ResponseWriter, r *http.Request) {
func ximport(w http.ResponseWriter, r *http.Request) { func ximport(w http.ResponseWriter, r *http.Request) {
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
xid := strings.TrimSpace(r.FormValue("xid")) xid := strings.TrimSpace(r.FormValue("q"))
xonk := getxonk(u.UserID, xid) xonk := getxonk(u.UserID, xid)
if xonk == nil { if xonk == nil {
p, _ := investigate(xid) p, _ := investigate(xid)
@ -788,6 +788,10 @@ func showconvoy(w http.ResponseWriter, r *http.Request) {
} }
func showsearch(w http.ResponseWriter, r *http.Request) { func showsearch(w http.ResponseWriter, r *http.Request) {
q := r.FormValue("q") q := r.FormValue("q")
if strings.HasPrefix(q, "https://") {
ximport(w, r)
return
}
u := login.GetUserInfo(r) u := login.GetUserInfo(r)
honks := gethonksbysearch(u.UserID, q, 0) honks := gethonksbysearch(u.UserID, q, 0)
templinfo := getInfo(r) templinfo := getInfo(r)