+ {{template "orphaned hyphae"}}
+ {{block "orphan description" .}}Hyphae which have no backlinks are listed here.{{end}}
+
+ {{range .Orphans}}
+ -
+ {{beautifulName .}}
+
+ {{end}}
+
+
+{{end}}
\ No newline at end of file
diff --git a/backlinks/web.go b/backlinks/web.go
index f79edd3..f998e00 100644
--- a/backlinks/web.go
+++ b/backlinks/web.go
@@ -3,19 +3,25 @@ package backlinks
import (
"embed"
"github.com/bouncepaw/mycorrhiza/cfg"
+ "github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/util"
"github.com/bouncepaw/mycorrhiza/viewutil"
"github.com/gorilla/mux"
"log"
"net/http"
+ "sort"
"text/template"
)
func InitHandlers(rtr *mux.Router) {
rtr.PathPrefix("/backlinks/").HandlerFunc(handlerBacklinks)
- chain = viewutil.
+ rtr.PathPrefix("/orphans").HandlerFunc(handlerOrphans)
+ chainBacklinks = viewutil.
En(viewutil.CopyEnWith(fs, "view_backlinks.html")).
Ru(template.Must(viewutil.CopyRuWith(fs, "view_backlinks.html").Parse(ruTranslation)))
+ chainOrphans = viewutil.
+ En(viewutil.CopyEnWith(fs, "view_orphans.html")).
+ Ru(template.Must(viewutil.CopyRuWith(fs, "view_orphans.html").Parse(ruTranslation)))
}
// handlerBacklinks lists all backlinks to a hypha.
@@ -30,6 +36,17 @@ func handlerBacklinks(w http.ResponseWriter, rq *http.Request) {
viewBacklinks(viewutil.MetaFrom(w, rq), hyphaName, backlinks)
}
+func handlerOrphans(w http.ResponseWriter, rq *http.Request) {
+ var orphans []string
+ for h := range hyphae.YieldExistingHyphae() {
+ if BacklinksCount(h) == 0 {
+ orphans = append(orphans, h.CanonicalName())
+ }
+ }
+ sort.Strings(orphans)
+ viewOrphans(viewutil.MetaFrom(w, rq), orphans)
+}
+
var (
//go:embed *.html
fs embed.FS
@@ -37,8 +54,11 @@ var (
{{define "backlinks to text"}}Обратные ссылки на {{.}}{{end}}
{{define "backlinks to link"}}Обратные ссылки на