Groups lines from pages in backrefs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
465ebcb8cb
commit
0380238e00
10
backref.go
10
backref.go
|
@ -66,7 +66,7 @@ func processBackrefs(fp *FilePages) error {
|
|||
return err
|
||||
}
|
||||
|
||||
func loadBackrefs(fp *FilePages, p string) ([]Backref, error) {
|
||||
func loadBackrefs(fp *FilePages, p string) (map[string][]Backref, error) {
|
||||
refs := make(Refs)
|
||||
p = strings.Replace(p, " ", "_", -1)
|
||||
|
||||
|
@ -82,11 +82,15 @@ func loadBackrefs(fp *FilePages, p string) ([]Backref, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var result []Backref
|
||||
result := make(map[string][]Backref)
|
||||
|
||||
for _, ref := range refs[p] {
|
||||
title := strings.Replace(ref.Name, "_", " ", -1)
|
||||
result = append(result, Backref{
|
||||
if _, e := result[ref.Name]; !e {
|
||||
result[ref.Name] = nil
|
||||
}
|
||||
|
||||
result[ref.Name] = append(result[ref.Name], Backref{
|
||||
Name: ref.Name,
|
||||
Title: title,
|
||||
Line: strings.TrimLeft(ref.Link.Line, " *"),
|
||||
|
|
6
main.go
6
main.go
|
@ -47,7 +47,7 @@ type Page struct {
|
|||
|
||||
Content string
|
||||
|
||||
Refs []Backref
|
||||
Refs map[string][]Backref
|
||||
}
|
||||
|
||||
type DiffPage struct {
|
||||
|
@ -85,7 +85,7 @@ type indexPage struct {
|
|||
Title string
|
||||
Name string
|
||||
Content template.HTML
|
||||
Backrefs []Backref
|
||||
Backrefs map[string][]Backref
|
||||
}
|
||||
|
||||
type editPage struct {
|
||||
|
@ -94,7 +94,7 @@ type editPage struct {
|
|||
Content string
|
||||
Name string
|
||||
Editor template.HTML
|
||||
Backrefs []Backref
|
||||
Backrefs map[string][]Backref
|
||||
}
|
||||
|
||||
type historyPage struct {
|
||||
|
|
|
@ -13,10 +13,12 @@
|
|||
<div class="backrefs content">
|
||||
<h3>Linked references</h3>
|
||||
<ul>
|
||||
{{ range $ref := .Backrefs }}
|
||||
<li><a href="/{{ $ref.Name }}">{{ $ref.Title }}</a>
|
||||
{{ range $name, $refs := .Backrefs }}
|
||||
<li><a href="/{{ $name }}">{{ (index $refs 0).Title }}</a>
|
||||
<ul>
|
||||
<li>{{ $ref.Line }}</li>
|
||||
{{ range $ref := $refs }}
|
||||
<li>{{ $ref.Line }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</li>
|
||||
{{ end }}
|
||||
|
|
|
@ -7,10 +7,12 @@
|
|||
<div class="backrefs content">
|
||||
<h3>Backrefs</h3>
|
||||
<ul>
|
||||
{{ range $ref := .Backrefs }}
|
||||
<li><a href="/{{ $ref.Name }}">{{ $ref.Title }}</a>
|
||||
{{ range $name, $refs := .Backrefs }}
|
||||
<li><a href="/{{ $name }}">{{ $name }}</a>
|
||||
<ul>
|
||||
<li>{{ $ref.Line }}</li>
|
||||
{{ range $ref := $refs }}
|
||||
<li>{{ $ref.Line }}</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
</li>
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue
Block a user