mirror of https://github.com/perkeep/perkeep.git
ui: Linkify paths on permanode page.
Change-Id: I056896715b174bd3abd91799a86c73f3a8d83d3f
This commit is contained in:
parent
df7b13578c
commit
5b84668e1d
|
@ -38,6 +38,7 @@ import (
|
||||||
"camli/misc/resize"
|
"camli/misc/resize"
|
||||||
"camli/misc/vfs" // TODO: ditch this once pkg http gets it
|
"camli/misc/vfs" // TODO: ditch this once pkg http gets it
|
||||||
"camli/schema"
|
"camli/schema"
|
||||||
|
"camli/search"
|
||||||
uistatic "camlistore.org/server/uistatic"
|
uistatic "camlistore.org/server/uistatic"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ type UIHandler struct {
|
||||||
|
|
||||||
Storage blobserver.Storage // of BlobRoot
|
Storage blobserver.Storage // of BlobRoot
|
||||||
Cache blobserver.Storage // or nil
|
Cache blobserver.Storage // or nil
|
||||||
|
Search *search.Handler // or nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -134,6 +136,11 @@ func newUiFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler,
|
||||||
ui.Cache = bs
|
ui.Cache = bs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ui.SearchRoot != "" {
|
||||||
|
h, _ := ld.GetHandler(ui.SearchRoot)
|
||||||
|
ui.Search = h.(*search.Handler)
|
||||||
|
}
|
||||||
|
|
||||||
return ui, nil
|
return ui, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,11 +220,18 @@ func (ui *UIHandler) serveDiscovery(rw http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
pubRoots := map[string]interface{}{}
|
pubRoots := map[string]interface{}{}
|
||||||
for key, pubh := range ui.PublishRoots {
|
for key, pubh := range ui.PublishRoots {
|
||||||
pubRoots[pubh.RootName] = map[string]interface{}{
|
m := map[string]interface{}{
|
||||||
"name": pubh.RootName,
|
"name": pubh.RootName,
|
||||||
"prefix": []string{key},
|
"prefix": []string{key},
|
||||||
// TODO: include gpg key id
|
// TODO: include gpg key id
|
||||||
}
|
}
|
||||||
|
if ui.Search != nil {
|
||||||
|
pn, err := ui.Search.Index().PermanodeOfSignerAttrValue(ui.Search.Owner(), "camliRoot", pubh.RootName)
|
||||||
|
if err == nil {
|
||||||
|
m["currentPermanode"] = pn.String()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pubRoots[pubh.RootName] = m
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes, _ := json.Marshal(map[string]interface{}{
|
bytes, _ := json.Marshal(map[string]interface{}{
|
||||||
|
|
|
@ -522,13 +522,28 @@ function buildPathsList() {
|
||||||
var span = document.createElement("span");
|
var span = document.createElement("span");
|
||||||
li.appendChild(span);
|
li.appendChild(span);
|
||||||
|
|
||||||
var a = document.createElement("a");
|
var blobLink = document.createElement("a");
|
||||||
a.href = ".?p=" + path.baseRef;
|
blobLink.href = ".?p=" + path.baseRef;
|
||||||
a.innerText = path.baseRef;
|
blobLink.innerText = path.baseRef;
|
||||||
span.appendChild(a);
|
span.appendChild(blobLink);
|
||||||
|
|
||||||
var text = document.createTextNode(" - " + path.suffix);
|
span.appendChild(document.createTextNode(" - "));
|
||||||
span.appendChild(text);
|
|
||||||
|
var pathLink = document.createElement("a");
|
||||||
|
pathLink.href = "";
|
||||||
|
pathLink.innerText = path.suffix;
|
||||||
|
for (var key in Camli.config.publishRoots) {
|
||||||
|
var root = Camli.config.publishRoots[key];
|
||||||
|
if (root.currentPermanode == path.baseRef) {
|
||||||
|
// Prefix should include a trailing slash.
|
||||||
|
pathLink.href = root.prefix[0] + path.suffix;
|
||||||
|
// TODO: Check if we're the latest permanode
|
||||||
|
// for this path and display some "old" notice
|
||||||
|
// if not.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
span.appendChild(pathLink);
|
||||||
|
|
||||||
var del = document.createElement("span");
|
var del = document.createElement("span");
|
||||||
del.className = "camli-del";
|
del.className = "camli-del";
|
||||||
|
|
Loading…
Reference in New Issue