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/vfs" // TODO: ditch this once pkg http gets it
|
||||
"camli/schema"
|
||||
"camli/search"
|
||||
uistatic "camlistore.org/server/uistatic"
|
||||
)
|
||||
|
||||
|
@ -68,6 +69,7 @@ type UIHandler struct {
|
|||
|
||||
Storage blobserver.Storage // of BlobRoot
|
||||
Cache blobserver.Storage // or nil
|
||||
Search *search.Handler // or nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -134,6 +136,11 @@ func newUiFromConfig(ld blobserver.Loader, conf jsonconfig.Obj) (h http.Handler,
|
|||
ui.Cache = bs
|
||||
}
|
||||
|
||||
if ui.SearchRoot != "" {
|
||||
h, _ := ld.GetHandler(ui.SearchRoot)
|
||||
ui.Search = h.(*search.Handler)
|
||||
}
|
||||
|
||||
return ui, nil
|
||||
}
|
||||
|
||||
|
@ -213,11 +220,18 @@ func (ui *UIHandler) serveDiscovery(rw http.ResponseWriter, req *http.Request) {
|
|||
|
||||
pubRoots := map[string]interface{}{}
|
||||
for key, pubh := range ui.PublishRoots {
|
||||
pubRoots[pubh.RootName] = map[string]interface{}{
|
||||
m := map[string]interface{}{
|
||||
"name": pubh.RootName,
|
||||
"prefix": []string{key},
|
||||
// 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{}{
|
||||
|
|
|
@ -522,13 +522,28 @@ function buildPathsList() {
|
|||
var span = document.createElement("span");
|
||||
li.appendChild(span);
|
||||
|
||||
var a = document.createElement("a");
|
||||
a.href = ".?p=" + path.baseRef;
|
||||
a.innerText = path.baseRef;
|
||||
span.appendChild(a);
|
||||
var blobLink = document.createElement("a");
|
||||
blobLink.href = ".?p=" + path.baseRef;
|
||||
blobLink.innerText = path.baseRef;
|
||||
span.appendChild(blobLink);
|
||||
|
||||
var text = document.createTextNode(" - " + path.suffix);
|
||||
span.appendChild(text);
|
||||
span.appendChild(document.createTextNode(" - "));
|
||||
|
||||
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");
|
||||
del.className = "camli-del";
|
||||
|
|
Loading…
Reference in New Issue