diff --git a/pkg/search/handler.go b/pkg/search/handler.go index 7ebbc0604..c27091218 100644 --- a/pkg/search/handler.go +++ b/pkg/search/handler.go @@ -723,7 +723,14 @@ func (sh *Handler) serveDescribe(rw http.ResponseWriter, req *http.Request) { dr := sh.NewDescribeRequest() dr.Describe(br, 4) - dr.PopulateJSON(ret) + thumbSize := 0 + if req.FormValue("thumbnails") != "" { + thumbSize = 50 + if i, _ := strconv.Atoi(req.FormValue("thumbnails")); i >= 25 && i < 800 { + thumbSize = i + } + } + dr.populateJSONThumbnails(ret, thumbSize) } func (sh *Handler) serveFiles(rw http.ResponseWriter, req *http.Request) { diff --git a/server/camlistored/ui/camli.js b/server/camlistored/ui/camli.js index dc0f2d705..8a7bf70fb 100644 --- a/server/camlistored/ui/camli.js +++ b/server/camlistored/ui/camli.js @@ -92,8 +92,11 @@ function camliSigDiscovery(opts) { function camliDescribeBlob(blobref, opts) { var xhr = camliJsonXhr("camliDescribeBlob", opts); - var path = Camli.config.searchRoot + "camli/search/describe?blobref=" + - blobref; + var path = Camli.config.searchRoot + + "camli/search/describe?blobref=" + blobref; + if (opts.thumbnails != null) { + path = makeURL(path, {thumbnails: opts.thumbnails}); + } xhr.open("GET", path, true); xhr.send(); } @@ -320,12 +323,9 @@ function getQueryParam(key) { function camliGetRecentlyUpdatedPermanodes(opts) { // opts.thumbnails is the maximum size of the thumbnails we want, // or 0 if no thumbnail. - var path = ""; + var path = Camli.config.searchRoot + "camli/search/recent"; if (opts.thumbnails != null) { - path = makeURL(Camli.config.searchRoot + "camli/search/recent", - {thumbnails: opts.thumbnails}); - } else { - path = makeURL(Camli.config.searchRoot + "camli/search/recent"); + path = makeURL(path, {thumbnails: opts.thumbnails}); } var xhr = camliJsonXhr("camliGetRecentlyUpdatedPermanodes", opts); xhr.open("GET", path, true); diff --git a/server/camlistored/ui/permanode.js b/server/camlistored/ui/permanode.js index 5d09a683b..35a5152fc 100644 --- a/server/camlistored/ui/permanode.js +++ b/server/camlistored/ui/permanode.js @@ -332,6 +332,7 @@ function addMember(pn, des) { function buildPermanodeUi() { camliDescribeBlob(getPermanodeParam(), { + thumbnails: 200, // requested size success: onBlobDescribed, failure: function(msg) { alert("failed to get blob description: " + msg); @@ -406,7 +407,24 @@ function onBlobDescribed(jres) { c.appendChild(document.createTextNode("File: ")); var a = document.createElement("a"); a.href = "./?b=" + camliContent; - setTextContent(a, camliBlobTitle(camliContent, jres)); + var doThumb = false; + var thumbnailSrc = jres[permanode].thumbnailSrc; + var contentObject = jres[camliContent]; + if (thumbnailSrc && contentObject) { + var objectFile = contentObject.file; + if (objectFile) { + if (objectFile.mimeType.indexOf("image/") == 0) { + doThumb = true; + } + } + } + if (doThumb) { + var img = document.createElement("img"); + img.src = thumbnailSrc; + a.appendChild(img); + } else { + setTextContent(a, camliBlobTitle(camliContent, jres)); + } c.appendChild(a); } diff --git a/server/camlistored/ui/recent.js b/server/camlistored/ui/recent.js index 86e3fc896..683122c4d 100644 --- a/server/camlistored/ui/recent.js +++ b/server/camlistored/ui/recent.js @@ -15,7 +15,7 @@ limitations under the License. */ function indexOnLoad(e) { - camliGetRecentlyUpdatedPermanodes({ success: indexBuildRecentlyUpdatedPermanodes, thumbnails: true}); + camliGetRecentlyUpdatedPermanodes({success: indexBuildRecentlyUpdatedPermanodes, thumbnails: true}); } function indexBuildRecentlyUpdatedPermanodes(searchRes) { diff --git a/server/camlistored/ui/zembed_camli.js.go b/server/camlistored/ui/zembed_camli.js.go index f69e927a1..6ea89ac4a 100644 --- a/server/camlistored/ui/zembed_camli.js.go +++ b/server/camlistored/ui/zembed_camli.js.go @@ -101,8 +101,11 @@ func init() { "\n"+ "function camliDescribeBlob(blobref, opts) {\n"+ " var xhr = camliJsonXhr(\"camliDescribeBlob\", opts);\n"+ - " var path = Camli.config.searchRoot + \"camli/search/describe?blobref=\" +\n"+ - " blobref;\n"+ + " var path = Camli.config.searchRoot +\n"+ + " \"camli/search/describe?blobref=\" + blobref;\n"+ + " if (opts.thumbnails != null) {\n"+ + " path = makeURL(path, {thumbnails: opts.thumbnails});\n"+ + " }\n"+ " xhr.open(\"GET\", path, true);\n"+ " xhr.send();\n"+ "}\n"+ @@ -336,12 +339,9 @@ func init() { "function camliGetRecentlyUpdatedPermanodes(opts) {\n"+ " // opts.thumbnails is the maximum size of the thumbnails we want,\n"+ " // or 0 if no thumbnail.\n"+ - " var path = \"\";\n"+ + " var path = Camli.config.searchRoot + \"camli/search/recent\";\n"+ " if (opts.thumbnails != null) {\n"+ - " path = makeURL(Camli.config.searchRoot + \"camli/search/recent\",\n"+ - " {thumbnails: opts.thumbnails});\n"+ - " } else {\n"+ - " path = makeURL(Camli.config.searchRoot + \"camli/search/recent\");\n"+ + " path = makeURL(path, {thumbnails: opts.thumbnails});\n"+ " }\n"+ " var xhr = camliJsonXhr(\"camliGetRecentlyUpdatedPermanodes\", opts);\n"+ " xhr.open(\"GET\", path, true);\n"+ @@ -508,5 +508,5 @@ func init() { " changeAttribute(permanode, \"del-attribute\", attribute, value, opts);\n"+ "}\n"+ "\n"+ - "", time.Unix(0, 1352486005211518273)) + "", time.Unix(0, 1352496670831866384)) } diff --git a/server/camlistored/ui/zembed_permanode.js.go b/server/camlistored/ui/zembed_permanode.js.go index 6e1d11292..e6d9b7e91 100644 --- a/server/camlistored/ui/zembed_permanode.js.go +++ b/server/camlistored/ui/zembed_permanode.js.go @@ -345,6 +345,7 @@ func init() { "\n"+ "function buildPermanodeUi() {\n"+ " camliDescribeBlob(getPermanodeParam(), {\n"+ + " thumbnails: 200, // requested size\n"+ " success: onBlobDescribed,\n"+ " failure: function(msg) {\n"+ " alert(\"failed to get blob description: \" + msg);\n"+ @@ -420,7 +421,24 @@ func init() { " c.appendChild(document.createTextNode(\"File: \"));\n"+ " var a = document.createElement(\"a\");\n"+ " a.href = \"./?b=\" + camliContent;\n"+ - " setTextContent(a, camliBlobTitle(camliContent, jres));\n"+ + " var doThumb = false;\n"+ + " var thumbnailSrc = jres[permanode].thumbnailSrc;\n"+ + " var contentObject = jres[camliContent];\n"+ + " if (thumbnailSrc && contentObject) {\n"+ + " var objectFile = contentObject.file;\n"+ + " if (objectFile) {\n"+ + " if (objectFile.mimeType.indexOf(\"image/\") == 0) {\n"+ + " doThumb = true;\n"+ + " }\n"+ + " }\n"+ + " }\n"+ + " if (doThumb) {\n"+ + " var img = document.createElement(\"img\");\n"+ + " img.src = thumbnailSrc;\n"+ + " a.appendChild(img);\n"+ + " } else {\n"+ + " setTextContent(a, camliBlobTitle(camliContent, jres));\n"+ + " }\n"+ " c.appendChild(a);\n"+ " }\n"+ "\n"+ @@ -671,5 +689,5 @@ func init() { "}\n"+ "\n"+ "window.addEventListener(\"load\", permanodePageOnLoad);\n"+ - "", time.Unix(0, 1352107488430325498)) + "", time.Unix(0, 1352502107206351256)) } diff --git a/server/camlistored/ui/zembed_recent.js.go b/server/camlistored/ui/zembed_recent.js.go index 851653e80..6d3e7a0f8 100644 --- a/server/camlistored/ui/zembed_recent.js.go +++ b/server/camlistored/ui/zembed_recent.js.go @@ -22,8 +22,8 @@ func init() { "*/\n"+ "\n"+ "function indexOnLoad(e) {\n"+ - " camliGetRecentlyUpdatedPermanodes({ success: indexBuildRecentlyUpdatedPermanodes"+ - ", thumbnails: true});\n"+ + " camliGetRecentlyUpdatedPermanodes({success: indexBuildRecentlyUpdatedPermanodes,"+ + " thumbnails: true});\n"+ "}\n"+ "\n"+ "function indexBuildRecentlyUpdatedPermanodes(searchRes) {\n"+ @@ -47,5 +47,5 @@ func init() { "}\n"+ "\n"+ "window.addEventListener(\"load\", indexOnLoad);\n"+ - "", time.Unix(0, 1352486501031517614)) + "", time.Unix(0, 1352494795012737952)) }