1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2025-01-07 02:10:26 +00:00

Move backlinks stuff to a separate module

This commit is contained in:
Timur Ismagilov 2021-12-21 00:08:21 +03:00
parent fbcbd0e445
commit 1f36af66a5
10 changed files with 136 additions and 126 deletions

View File

@ -1,14 +1,15 @@
package hyphae // Package backlinks maintains the index of backlinks and lets you update it and query it.
package backlinks
import ( import (
"github.com/bouncepaw/mycomarkup/v3/tools" "github.com/bouncepaw/mycorrhiza/hyphae"
"os"
"github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/util"
"os"
"github.com/bouncepaw/mycomarkup/v3" "github.com/bouncepaw/mycomarkup/v3"
"github.com/bouncepaw/mycomarkup/v3/links" "github.com/bouncepaw/mycomarkup/v3/links"
"github.com/bouncepaw/mycomarkup/v3/mycocontext" "github.com/bouncepaw/mycomarkup/v3/mycocontext"
"github.com/bouncepaw/mycomarkup/v3/tools"
) )
// Using set here seems like the most appropriate solution // Using set here seems like the most appropriate solution
@ -22,7 +23,7 @@ func toLinkSet(xs []string) linkSet {
return result return result
} }
func fetchText(h *Hypha) string { func fetchText(h *hyphae.Hypha) string {
if h.TextPath == "" { if h.TextPath == "" {
return "" return ""
} }
@ -70,7 +71,7 @@ type backlinkIndexDeletion struct {
Links []string Links []string
} }
// Apply changes backlink index respective to the operation data // apply changes backlink index respective to the operation data
func (op backlinkIndexDeletion) apply() { func (op backlinkIndexDeletion) apply() {
for _, link := range op.Links { for _, link := range op.Links {
if lSet, exists := backlinkIndex[link]; exists { if lSet, exists := backlinkIndex[link]; exists {
@ -105,7 +106,7 @@ var backlinkConveyor = make(chan backlinkIndexOperation, 64)
// IndexBacklinks traverses all text hyphae, extracts links from them and forms an initial index // IndexBacklinks traverses all text hyphae, extracts links from them and forms an initial index
func IndexBacklinks() { func IndexBacklinks() {
// It is safe to ignore the mutex, because there is only one worker. // It is safe to ignore the mutex, because there is only one worker.
src := FilterTextHyphae(YieldExistingHyphae()) src := hyphae.FilterTextHyphae(hyphae.YieldExistingHyphae())
for h := range src { for h := range src {
foundLinks := extractHyphaLinksFromContent(h.Name, fetchText(h)) foundLinks := extractHyphaLinksFromContent(h.Name, fetchText(h))
for _, link := range foundLinks { for _, link := range foundLinks {
@ -127,7 +128,7 @@ func RunBacklinksConveyor() {
} }
// BacklinksCount returns the amount of backlinks to the hypha. // BacklinksCount returns the amount of backlinks to the hypha.
func BacklinksCount(h *Hypha) int { func BacklinksCount(h *hyphae.Hypha) int {
if _, exists := backlinkIndex[h.Name]; exists { if _, exists := backlinkIndex[h.Name]; exists {
return len(backlinkIndex[h.Name]) return len(backlinkIndex[h.Name])
} }
@ -135,20 +136,20 @@ func BacklinksCount(h *Hypha) int {
} }
// BacklinksOnEdit is a creation/editing hook for backlinks index // BacklinksOnEdit is a creation/editing hook for backlinks index
func BacklinksOnEdit(h *Hypha, oldText string) { func BacklinksOnEdit(h *hyphae.Hypha, oldText string) {
oldLinks := extractHyphaLinksFromContent(h.Name, oldText) oldLinks := extractHyphaLinksFromContent(h.Name, oldText)
newLinks := extractHyphaLinks(h) newLinks := extractHyphaLinks(h)
backlinkConveyor <- backlinkIndexEdit{h.Name, oldLinks, newLinks} backlinkConveyor <- backlinkIndexEdit{h.Name, oldLinks, newLinks}
} }
// BacklinksOnDelete is a deletion hook for backlinks index // BacklinksOnDelete is a deletion hook for backlinks index
func BacklinksOnDelete(h *Hypha, oldText string) { func BacklinksOnDelete(h *hyphae.Hypha, oldText string) {
oldLinks := extractHyphaLinksFromContent(h.Name, oldText) oldLinks := extractHyphaLinksFromContent(h.Name, oldText)
backlinkConveyor <- backlinkIndexDeletion{h.Name, oldLinks} backlinkConveyor <- backlinkIndexDeletion{h.Name, oldLinks}
} }
// BacklinksOnRename is a renaming hook for backlinks index // BacklinksOnRename is a renaming hook for backlinks index
func BacklinksOnRename(h *Hypha, oldName string) { func BacklinksOnRename(h *hyphae.Hypha, oldName string) {
actualLinks := extractHyphaLinks(h) actualLinks := extractHyphaLinks(h)
backlinkConveyor <- backlinkIndexRenaming{oldName, h.Name, actualLinks} backlinkConveyor <- backlinkIndexRenaming{oldName, h.Name, actualLinks}
} }
@ -157,7 +158,7 @@ func BacklinksOnRename(h *Hypha, oldName string) {
func YieldHyphaBacklinks(query string) <-chan string { func YieldHyphaBacklinks(query string) <-chan string {
hyphaName := util.CanonicalName(query) hyphaName := util.CanonicalName(query)
out := make(chan string) out := make(chan string)
sorted := PathographicSort(out) sorted := hyphae.PathographicSort(out)
go func() { go func() {
backlinks, exists := backlinkIndex[hyphaName] backlinks, exists := backlinkIndex[hyphaName]
if exists { if exists {
@ -171,7 +172,7 @@ func YieldHyphaBacklinks(query string) <-chan string {
} }
// extractHyphaLinks extracts hypha links from a desired hypha // extractHyphaLinks extracts hypha links from a desired hypha
func extractHyphaLinks(h *Hypha) []string { func extractHyphaLinks(h *hyphae.Hypha) []string {
return extractHyphaLinksFromContent(h.Name, fetchText(h)) return extractHyphaLinksFromContent(h.Name, fetchText(h))
} }

View File

@ -26,8 +26,6 @@ func Index(path string) {
h.insert() h.insert()
} }
} }
IndexBacklinks()
log.Println("Indexed", Count(), "hyphae") log.Println("Indexed", Count(), "hyphae")
} }

View File

@ -6,6 +6,7 @@
package main package main
import ( import (
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"log" "log"
"os" "os"
@ -39,7 +40,8 @@ func main() {
// Init the subsystems: // Init the subsystems:
hyphae.Index(files.HyphaeDir()) hyphae.Index(files.HyphaeDir())
go hyphae.RunBacklinksConveyor() backlinks.IndexBacklinks()
go backlinks.RunBacklinksConveyor()
user.InitUserDatabase() user.InitUserDatabase()
history.Start() history.Start()
history.InitGitRepo() history.InitGitRepo()

View File

@ -2,6 +2,7 @@ package shroom
import ( import (
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/history"
"github.com/bouncepaw/mycorrhiza/hyphae" "github.com/bouncepaw/mycorrhiza/hyphae"
@ -25,7 +26,7 @@ func DeleteHypha(u *user.User, h *hyphae.Hypha, lc *l18n.Localizer) (hop *histor
WithUser(u). WithUser(u).
Apply() Apply()
if !hop.HasErrors() { if !hop.HasErrors() {
hyphae.BacklinksOnDelete(h, originalText) backlinks.BacklinksOnDelete(h, originalText)
h.Delete() h.Delete()
} }
return hop, "" return hop, ""

View File

@ -3,6 +3,7 @@ package shroom
import ( import (
"errors" "errors"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"regexp" "regexp"
"github.com/bouncepaw/mycorrhiza/history" "github.com/bouncepaw/mycorrhiza/history"
@ -74,7 +75,7 @@ func RenameHypha(h *hyphae.Hypha, newHypha *hyphae.Hypha, recursive bool, u *use
h.TextPath = replaceName(h.TextPath) h.TextPath = replaceName(h.TextPath)
h.BinaryPath = replaceName(h.BinaryPath) h.BinaryPath = replaceName(h.BinaryPath)
h.Unlock() h.Unlock()
hyphae.BacklinksOnRename(h, oldName) backlinks.BacklinksOnRename(h, oldName)
} }
} }
return hop, "" return hop, ""

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"errors" "errors"
"fmt" "fmt"
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"io" "io"
"log" "log"
"mime/multipart" "mime/multipart"
@ -105,7 +106,7 @@ func uploadHelp(h *hyphae.Hypha, hop *history.Op, ext string, data []byte, u *us
} }
*originalFullPath = fullPath *originalFullPath = fullPath
if hop.Type == history.TypeEditText { if hop.Type == history.TypeEditText {
hyphae.BacklinksOnEdit(h, originalText) backlinks.BacklinksOnEdit(h, originalText)
} }
return hop.WithFiles(fullPath).WithUser(u).Apply(), "" return hop.WithFiles(fullPath).WithUser(u).Apply(), ""
} }

View File

@ -1,5 +1,6 @@
{% import "net/http" %} {% import "net/http" %}
{% import "strings" %} {% import "strings" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae/backlinks" %}
{% import "github.com/bouncepaw/mycorrhiza/l18n" %} {% import "github.com/bouncepaw/mycorrhiza/l18n" %}
{% import "github.com/bouncepaw/mycorrhiza/user" %} {% import "github.com/bouncepaw/mycorrhiza/user" %}
{% import "github.com/bouncepaw/mycorrhiza/hyphae" %} {% import "github.com/bouncepaw/mycorrhiza/hyphae" %}
@ -16,7 +17,7 @@
{% code {% code
u := user.FromRequest(rq) u := user.FromRequest(rq)
lc := l18n.FromRequest(rq) lc := l18n.FromRequest(rq)
backs := hyphae.BacklinksCount(h) backs := backlinks.BacklinksCount(h)
%} %}
<nav class="hypha-info"> <nav class="hypha-info">
<ul class="hypha-info__list"> <ul class="hypha-info__list">

View File

@ -11,268 +11,271 @@ import "net/http"
import "strings" import "strings"
//line views/nav.qtpl:3 //line views/nav.qtpl:3
import "github.com/bouncepaw/mycorrhiza/l18n" import "github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
//line views/nav.qtpl:4 //line views/nav.qtpl:4
import "github.com/bouncepaw/mycorrhiza/user" import "github.com/bouncepaw/mycorrhiza/l18n"
//line views/nav.qtpl:5 //line views/nav.qtpl:5
import "github.com/bouncepaw/mycorrhiza/user"
//line views/nav.qtpl:6
import "github.com/bouncepaw/mycorrhiza/hyphae" import "github.com/bouncepaw/mycorrhiza/hyphae"
//line views/nav.qtpl:7 //line views/nav.qtpl:8
import ( import (
qtio422016 "io" qtio422016 "io"
qt422016 "github.com/valyala/quicktemplate" qt422016 "github.com/valyala/quicktemplate"
) )
//line views/nav.qtpl:7 //line views/nav.qtpl:8
var ( var (
_ = qtio422016.Copy _ = qtio422016.Copy
_ = qt422016.AcquireByteBuffer _ = qt422016.AcquireByteBuffer
) )
//line views/nav.qtpl:7 //line views/nav.qtpl:8
func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h *hyphae.Hypha, u *user.User, action, displayText string) { func streamhyphaInfoEntry(qw422016 *qt422016.Writer, h *hyphae.Hypha, u *user.User, action, displayText string) {
//line views/nav.qtpl:7 //line views/nav.qtpl:8
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:8 //line views/nav.qtpl:9
if u.CanProceed(action) { if u.CanProceed(action) {
//line views/nav.qtpl:8 //line views/nav.qtpl:9
qw422016.N().S(` qw422016.N().S(`
<li class="hypha-info__entry hypha-info__entry_`) <li class="hypha-info__entry hypha-info__entry_`)
//line views/nav.qtpl:9 //line views/nav.qtpl:10
qw422016.E().S(action) qw422016.E().S(action)
//line views/nav.qtpl:9 //line views/nav.qtpl:10
qw422016.N().S(`"> qw422016.N().S(`">
<a class="hypha-info__link" href="/`) <a class="hypha-info__link" href="/`)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.E().S(action) qw422016.E().S(action)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.N().S(`/`) qw422016.N().S(`/`)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.E().S(h.Name) qw422016.E().S(h.Name)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.N().S(`">`) qw422016.N().S(`">`)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.E().S(displayText) qw422016.E().S(displayText)
//line views/nav.qtpl:10 //line views/nav.qtpl:11
qw422016.N().S(`</a> qw422016.N().S(`</a>
</li> </li>
`) `)
//line views/nav.qtpl:12 //line views/nav.qtpl:13
} }
//line views/nav.qtpl:12 //line views/nav.qtpl:13
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
} }
//line views/nav.qtpl:13 //line views/nav.qtpl:14
func writehyphaInfoEntry(qq422016 qtio422016.Writer, h *hyphae.Hypha, u *user.User, action, displayText string) { func writehyphaInfoEntry(qq422016 qtio422016.Writer, h *hyphae.Hypha, u *user.User, action, displayText string) {
//line views/nav.qtpl:13 //line views/nav.qtpl:14
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
streamhyphaInfoEntry(qw422016, h, u, action, displayText) streamhyphaInfoEntry(qw422016, h, u, action, displayText)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
} }
//line views/nav.qtpl:13 //line views/nav.qtpl:14
func hyphaInfoEntry(h *hyphae.Hypha, u *user.User, action, displayText string) string { func hyphaInfoEntry(h *hyphae.Hypha, u *user.User, action, displayText string) string {
//line views/nav.qtpl:13 //line views/nav.qtpl:14
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:13 //line views/nav.qtpl:14
writehyphaInfoEntry(qb422016, h, u, action, displayText) writehyphaInfoEntry(qb422016, h, u, action, displayText)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:13 //line views/nav.qtpl:14
return qs422016 return qs422016
//line views/nav.qtpl:13 //line views/nav.qtpl:14
} }
//line views/nav.qtpl:15 //line views/nav.qtpl:16
func streamhyphaInfo(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha) { func streamhyphaInfo(qw422016 *qt422016.Writer, rq *http.Request, h *hyphae.Hypha) {
//line views/nav.qtpl:15 //line views/nav.qtpl:16
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:17 //line views/nav.qtpl:18
u := user.FromRequest(rq) u := user.FromRequest(rq)
lc := l18n.FromRequest(rq) lc := l18n.FromRequest(rq)
backs := hyphae.BacklinksCount(h) backs := backlinks.BacklinksCount(h)
//line views/nav.qtpl:20 //line views/nav.qtpl:21
qw422016.N().S(` qw422016.N().S(`
<nav class="hypha-info"> <nav class="hypha-info">
<ul class="hypha-info__list"> <ul class="hypha-info__list">
`) `)
//line views/nav.qtpl:23 //line views/nav.qtpl:24
streamhyphaInfoEntry(qw422016, h, u, "history", lc.Get("ui.history_link")) streamhyphaInfoEntry(qw422016, h, u, "history", lc.Get("ui.history_link"))
//line views/nav.qtpl:23 //line views/nav.qtpl:24
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:24 //line views/nav.qtpl:25
streamhyphaInfoEntry(qw422016, h, u, "rename-ask", lc.Get("ui.rename_link")) streamhyphaInfoEntry(qw422016, h, u, "rename-ask", lc.Get("ui.rename_link"))
//line views/nav.qtpl:24 //line views/nav.qtpl:25
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:25 //line views/nav.qtpl:26
streamhyphaInfoEntry(qw422016, h, u, "delete-ask", lc.Get("ui.delete_link")) streamhyphaInfoEntry(qw422016, h, u, "delete-ask", lc.Get("ui.delete_link"))
//line views/nav.qtpl:25 //line views/nav.qtpl:26
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:26 //line views/nav.qtpl:27
streamhyphaInfoEntry(qw422016, h, u, "text", lc.Get("ui.text_link")) streamhyphaInfoEntry(qw422016, h, u, "text", lc.Get("ui.text_link"))
//line views/nav.qtpl:26 //line views/nav.qtpl:27
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:27 //line views/nav.qtpl:28
streamhyphaInfoEntry(qw422016, h, u, "attachment", lc.Get("ui.attachment_link")) streamhyphaInfoEntry(qw422016, h, u, "attachment", lc.Get("ui.attachment_link"))
//line views/nav.qtpl:27 //line views/nav.qtpl:28
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:28 //line views/nav.qtpl:29
streamhyphaInfoEntry(qw422016, h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs)) streamhyphaInfoEntry(qw422016, h, u, "backlinks", lc.GetPlural("ui.backlinks_link", backs))
//line views/nav.qtpl:28 //line views/nav.qtpl:29
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
</nav> </nav>
`) `)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
} }
//line views/nav.qtpl:31 //line views/nav.qtpl:32
func writehyphaInfo(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha) { func writehyphaInfo(qq422016 qtio422016.Writer, rq *http.Request, h *hyphae.Hypha) {
//line views/nav.qtpl:31 //line views/nav.qtpl:32
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
streamhyphaInfo(qw422016, rq, h) streamhyphaInfo(qw422016, rq, h)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
} }
//line views/nav.qtpl:31 //line views/nav.qtpl:32
func hyphaInfo(rq *http.Request, h *hyphae.Hypha) string { func hyphaInfo(rq *http.Request, h *hyphae.Hypha) string {
//line views/nav.qtpl:31 //line views/nav.qtpl:32
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:31 //line views/nav.qtpl:32
writehyphaInfo(qb422016, rq, h) writehyphaInfo(qb422016, rq, h)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:31 //line views/nav.qtpl:32
return qs422016 return qs422016
//line views/nav.qtpl:31 //line views/nav.qtpl:32
} }
//line views/nav.qtpl:33 //line views/nav.qtpl:34
func streamsiblingHyphaeHTML(qw422016 *qt422016.Writer, siblings string, lc *l18n.Localizer) { func streamsiblingHyphaeHTML(qw422016 *qt422016.Writer, siblings string, lc *l18n.Localizer) {
//line views/nav.qtpl:33 //line views/nav.qtpl:34
qw422016.N().S(` qw422016.N().S(`
<aside class="sibling-hyphae layout-card"> <aside class="sibling-hyphae layout-card">
<h2 class="sibling-hyphae__title layout-card__title">`) <h2 class="sibling-hyphae__title layout-card__title">`)
//line views/nav.qtpl:35 //line views/nav.qtpl:36
qw422016.E().S(lc.Get("ui.sibling_hyphae")) qw422016.E().S(lc.Get("ui.sibling_hyphae"))
//line views/nav.qtpl:35 //line views/nav.qtpl:36
qw422016.N().S(`</h2> qw422016.N().S(`</h2>
`) `)
//line views/nav.qtpl:36 //line views/nav.qtpl:37
qw422016.N().S(siblings) qw422016.N().S(siblings)
//line views/nav.qtpl:36 //line views/nav.qtpl:37
qw422016.N().S(` qw422016.N().S(`
</aside> </aside>
`) `)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
} }
//line views/nav.qtpl:38 //line views/nav.qtpl:39
func writesiblingHyphaeHTML(qq422016 qtio422016.Writer, siblings string, lc *l18n.Localizer) { func writesiblingHyphaeHTML(qq422016 qtio422016.Writer, siblings string, lc *l18n.Localizer) {
//line views/nav.qtpl:38 //line views/nav.qtpl:39
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
streamsiblingHyphaeHTML(qw422016, siblings, lc) streamsiblingHyphaeHTML(qw422016, siblings, lc)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
} }
//line views/nav.qtpl:38 //line views/nav.qtpl:39
func siblingHyphaeHTML(siblings string, lc *l18n.Localizer) string { func siblingHyphaeHTML(siblings string, lc *l18n.Localizer) string {
//line views/nav.qtpl:38 //line views/nav.qtpl:39
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:38 //line views/nav.qtpl:39
writesiblingHyphaeHTML(qb422016, siblings, lc) writesiblingHyphaeHTML(qb422016, siblings, lc)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:38 //line views/nav.qtpl:39
return qs422016 return qs422016
//line views/nav.qtpl:38 //line views/nav.qtpl:39
} }
//line views/nav.qtpl:40 //line views/nav.qtpl:41
func StreamSubhyphaeHTML(qw422016 *qt422016.Writer, subhyphae string, lc *l18n.Localizer) { func StreamSubhyphaeHTML(qw422016 *qt422016.Writer, subhyphae string, lc *l18n.Localizer) {
//line views/nav.qtpl:40 //line views/nav.qtpl:41
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:41 //line views/nav.qtpl:42
if strings.TrimSpace(subhyphae) != "" { if strings.TrimSpace(subhyphae) != "" {
//line views/nav.qtpl:41 //line views/nav.qtpl:42
qw422016.N().S(` qw422016.N().S(`
<section class="subhyphae"> <section class="subhyphae">
<h2 class="subhyphae__title">`) <h2 class="subhyphae__title">`)
//line views/nav.qtpl:43 //line views/nav.qtpl:44
qw422016.E().S(lc.Get("ui.subhyphae")) qw422016.E().S(lc.Get("ui.subhyphae"))
//line views/nav.qtpl:43 //line views/nav.qtpl:44
qw422016.N().S(`</h2> qw422016.N().S(`</h2>
<nav class="subhyphae__nav"> <nav class="subhyphae__nav">
<ul class="subhyphae__list"> <ul class="subhyphae__list">
`) `)
//line views/nav.qtpl:46 //line views/nav.qtpl:47
qw422016.N().S(subhyphae) qw422016.N().S(subhyphae)
//line views/nav.qtpl:46 //line views/nav.qtpl:47
qw422016.N().S(` qw422016.N().S(`
</ul> </ul>
</nav> </nav>
</section> </section>
`) `)
//line views/nav.qtpl:50 //line views/nav.qtpl:51
} }
//line views/nav.qtpl:50 //line views/nav.qtpl:51
qw422016.N().S(` qw422016.N().S(`
`) `)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
} }
//line views/nav.qtpl:51 //line views/nav.qtpl:52
func WriteSubhyphaeHTML(qq422016 qtio422016.Writer, subhyphae string, lc *l18n.Localizer) { func WriteSubhyphaeHTML(qq422016 qtio422016.Writer, subhyphae string, lc *l18n.Localizer) {
//line views/nav.qtpl:51 //line views/nav.qtpl:52
qw422016 := qt422016.AcquireWriter(qq422016) qw422016 := qt422016.AcquireWriter(qq422016)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
StreamSubhyphaeHTML(qw422016, subhyphae, lc) StreamSubhyphaeHTML(qw422016, subhyphae, lc)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
qt422016.ReleaseWriter(qw422016) qt422016.ReleaseWriter(qw422016)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
} }
//line views/nav.qtpl:51 //line views/nav.qtpl:52
func SubhyphaeHTML(subhyphae string, lc *l18n.Localizer) string { func SubhyphaeHTML(subhyphae string, lc *l18n.Localizer) string {
//line views/nav.qtpl:51 //line views/nav.qtpl:52
qb422016 := qt422016.AcquireByteBuffer() qb422016 := qt422016.AcquireByteBuffer()
//line views/nav.qtpl:51 //line views/nav.qtpl:52
WriteSubhyphaeHTML(qb422016, subhyphae, lc) WriteSubhyphaeHTML(qb422016, subhyphae, lc)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
qs422016 := string(qb422016.B) qs422016 := string(qb422016.B)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
qt422016.ReleaseByteBuffer(qb422016) qt422016.ReleaseByteBuffer(qb422016)
//line views/nav.qtpl:51 //line views/nav.qtpl:52
return qs422016 return qs422016
//line views/nav.qtpl:51 //line views/nav.qtpl:52
} }

View File

@ -1,12 +1,12 @@
package web package web
import ( import (
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"io" "io"
"net/http" "net/http"
"github.com/gorilla/mux" "github.com/gorilla/mux"
"github.com/bouncepaw/mycorrhiza/hyphae"
"github.com/bouncepaw/mycorrhiza/l18n" "github.com/bouncepaw/mycorrhiza/l18n"
"github.com/bouncepaw/mycorrhiza/user" "github.com/bouncepaw/mycorrhiza/user"
"github.com/bouncepaw/mycorrhiza/util" "github.com/bouncepaw/mycorrhiza/util"
@ -26,7 +26,7 @@ func handlerBacklinks(w http.ResponseWriter, rq *http.Request) {
) )
util.HTTP200Page(w, views.BaseHTML( util.HTTP200Page(w, views.BaseHTML(
lc.Get("ui.backlinks_title", &l18n.Replacements{"query": util.BeautifulName(hyphaName)}), lc.Get("ui.backlinks_title", &l18n.Replacements{"query": util.BeautifulName(hyphaName)}),
views.BacklinksHTML(hyphaName, hyphae.YieldHyphaBacklinks, lc), views.BacklinksHTML(hyphaName, backlinks.YieldHyphaBacklinks, lc),
lc, lc,
user.FromRequest(rq))) user.FromRequest(rq)))
} }
@ -36,6 +36,6 @@ func handlerBacklinksJSON(w http.ResponseWriter, rq *http.Request) {
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)
_, _ = io.WriteString( _, _ = io.WriteString(
w, w,
views.TitleSearchJSON(hyphaName, hyphae.YieldHyphaBacklinks), views.TitleSearchJSON(hyphaName, backlinks.YieldHyphaBacklinks),
) )
} }

View File

@ -2,6 +2,7 @@ package web
// stuff.go is used for meta stuff about the wiki or all hyphae at once. // stuff.go is used for meta stuff about the wiki or all hyphae at once.
import ( import (
"github.com/bouncepaw/mycorrhiza/hyphae/backlinks"
"io" "io"
"log" "log"
"math/rand" "math/rand"
@ -109,6 +110,7 @@ func handlerReindex(w http.ResponseWriter, rq *http.Request) {
hyphae.ResetCount() hyphae.ResetCount()
log.Println("Reindexing hyphae in", files.HyphaeDir()) log.Println("Reindexing hyphae in", files.HyphaeDir())
hyphae.Index(files.HyphaeDir()) hyphae.Index(files.HyphaeDir())
backlinks.IndexBacklinks()
http.Redirect(w, rq, "/", http.StatusSeeOther) http.Redirect(w, rq, "/", http.StatusSeeOther)
} }