2021-08-31 17:27:52 +00:00
|
|
|
package web
|
|
|
|
|
|
|
|
import (
|
2021-12-20 21:08:21 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
|
2021-08-31 17:27:52 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/gorilla/mux"
|
|
|
|
|
2021-09-06 17:46:34 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/l18n"
|
2021-08-31 17:27:52 +00:00
|
|
|
"github.com/bouncepaw/mycorrhiza/user"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/util"
|
|
|
|
"github.com/bouncepaw/mycorrhiza/views"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initBacklinks(r *mux.Router) {
|
|
|
|
r.PathPrefix("/backlinks/").HandlerFunc(handlerBacklinks)
|
|
|
|
}
|
|
|
|
|
|
|
|
// handlerBacklinks lists all backlinks to a hypha.
|
|
|
|
func handlerBacklinks(w http.ResponseWriter, rq *http.Request) {
|
2021-09-06 17:46:34 +00:00
|
|
|
var (
|
|
|
|
hyphaName = util.HyphaNameFromRq(rq, "backlinks")
|
|
|
|
lc = l18n.FromRequest(rq)
|
|
|
|
)
|
2022-03-20 21:24:40 +00:00
|
|
|
util.HTTP200Page(w, views.Base(
|
2021-09-06 17:46:34 +00:00
|
|
|
lc.Get("ui.backlinks_title", &l18n.Replacements{"query": util.BeautifulName(hyphaName)}),
|
2022-03-20 21:24:40 +00:00
|
|
|
views.Backlinks(hyphaName, backlinks.YieldHyphaBacklinks, lc),
|
2021-09-06 17:46:34 +00:00
|
|
|
lc,
|
2021-08-31 17:27:52 +00:00
|
|
|
user.FromRequest(rq)))
|
|
|
|
}
|