diff options
Diffstat (limited to 'vrsite/page.go')
| -rw-r--r-- | vrsite/page.go | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/vrsite/page.go b/vrsite/page.go index cca0c58..1570d45 100644 --- a/vrsite/page.go +++ b/vrsite/page.go @@ -17,7 +17,7 @@ type page struct { Site *Site Title string Kind string // index | file | files | notes | note | jj | change | session - Root string // static: relative prefix; live: "/" + Root string // static: relative prefix; live: route prefix ending in "/" Live bool Rev string // revision being browsed ("" = the change the log points at) ChangeID string // resolved change id for Rev — what pages name and link @@ -63,6 +63,7 @@ type page struct { // JJView is one rendered jj query: what was asked, and what came back. type JJView struct { + Root string Kind string // log | op Revset string AtOp string @@ -95,7 +96,7 @@ func (p *page) paramsWith(scope string) string { func (p *page) ScopeHref(scope string) string { path := p.Path if path == "" { - path = "/" + path = p.liveRoot() } return path + p.paramsWith(scope) } @@ -118,7 +119,21 @@ func (p *page) JumpPath() string { return p.Path } } - return "/files" + return p.liveRoot() + "files" +} + +func (p *page) liveRoot() string { + root := p.Root + if root == "" { + return "/" + } + if !strings.HasPrefix(root, "/") { + root = "/" + root + } + if !strings.HasSuffix(root, "/") { + root += "/" + } + return root } // Href maps a logical destination to a URL for this page's mode. Kinds the @@ -129,29 +144,38 @@ func (p *page) Href(kind string, arg ...string) string { a = arg[0] } if p.Live { + root := p.liveRoot() switch kind { case "": - return "/" + p.params() + return root + p.params() case "notes": - return "/notes" + p.params() + return root + "notes" + p.params() + case "notes-list": + return root + "notes/list" + p.params() case "files": - return "/files" + p.params() + return root + "files" + p.params() case "tree": - return "/tree" + p.params() + return root + "tree" + p.params() case "jj": - return "/jj" + return root + "jj" + case "jj-log": + return root + "jj/log" + case "jj-op": + return root + "jj/op" + case "activity": + return root + "activity" case "code": - return "/code/" + escPath(a) + p.params() + return root + "code/" + escPath(a) + p.params() case "note": - return "/note/" + a + return root + "note/" + a case "change": - return "/change/" + a + return root + "change/" + a case "session": - return "/session/" + escPath(a) + return root + "session/" + escPath(a) case "asset": - return "/" + a + return root + a } - return "/" + return root } switch kind { case "": |
