all repos — honk @ 57f1c9fc1fd1d432c07d71d7f72138e87f6c5841

my fork of honk

experimental: pretty @urls
Anirudh Oppiliappan x@icyphox.sh
Tue, 15 Nov 2022 18:38:34 +0530
commit

57f1c9fc1fd1d432c07d71d7f72138e87f6c5841

parent

8062001fdc374d1a90298b60b933f85d4349ec34

2 files changed, 22 insertions(+), 3 deletions(-)

jump to
M activity.goactivity.go

@@ -1598,7 +1598,7 @@ }

if user.ID > 0 { j["type"] = "Person" - j["url"] = user.URL + j["url"] = fmt.Sprintf("https://%s/@%s", serverName, user.Name) j["followers"] = user.URL + "/followers" j["following"] = user.URL + "/following" a := junk.New()
M web.goweb.go

@@ -26,6 +26,7 @@ "net/http"

"net/url" "os" "os/signal" + "path" "regexp" "sort" "strconv"

@@ -2212,14 +2213,20 @@ return nil, false

} j := junk.New() + pretty := fmt.Sprintf("https://%s/@%s", serverName, name) j["subject"] = fmt.Sprintf("acct:%s@%s", user.Name, masqName) - j["aliases"] = []string{user.URL} + j["aliases"] = []string{pretty, user.URL} l := junk.New() l["rel"] = "self" l["type"] = `application/activity+json` l["href"] = user.URL j["links"] = []junk.Junk{l} return j.ToBytes(), true + l2 := junk.New() + l2["rel"] = "http://webfinger.net/rel/profile-page" + l2["type"] = "text/html" + l2["href"] = pretty + j["links"] = []junk.Junk{l, l2} }}) func fingerlicker(w http.ResponseWriter, r *http.Request) {

@@ -2631,6 +2638,17 @@ return allemus[i].Name < allemus[j].Name

}) } +func redirectPretty(w http.ResponseWriter, r *http.Request) { + last := path.Base(r.URL.Path) + name := mux.Vars(r)["name"] + aturl := "/@" + name + + if last == name { + last = "" + } + http.Redirect(w, r, path.Join(aturl, last), http.StatusMovedPermanently) +} + func serve() { db := opendatabase() login.Init(login.InitArgs{Db: db, Logger: ilog, Insecure: develMode, SameSiteStrict: !develMode})

@@ -2699,7 +2717,8 @@ getters.HandleFunc("/front", homepage)

getters.HandleFunc("/events", homepage) getters.HandleFunc("/robots.txt", nomoroboto) getters.HandleFunc("/rss", showrss) - getters.HandleFunc("/"+userSep+"/{name:[\\pL[:digit:]]+}", showuser) + getters.HandleFunc("/@{name:[\\pL[:digit:]]+}", showuser) + getters.HandleFunc("/"+userSep+"/{name:[\\pL[:digit:]]+}", redirectPretty) getters.HandleFunc("/"+userSep+"/{name:[\\pL[:digit:]]+}/"+honkSep+"/{xid:[\\pL[:digit:]]+}", showonehonk) getters.HandleFunc("/"+userSep+"/{name:[\\pL[:digit:]]+}/rss", showrss) posters.HandleFunc("/"+userSep+"/{name:[\\pL[:digit:]]+}/inbox", inbox)