Repair relative urls within static-rendered files in non-default settings

This commit is contained in:
Tony Garnock-Jones 2015-04-08 18:56:58 -04:00
parent f5ba9045c5
commit 316daca342
4 changed files with 29 additions and 20 deletions

View File

@ -11,6 +11,7 @@
bootstrap-page-stylesheets
bootstrap-page-scripts
bootstrap-cookies
bootstrap-inline-js
bootstrap-response
bootstrap-redirect
@ -35,6 +36,7 @@
(define bootstrap-page-stylesheets (make-parameter '()))
(define bootstrap-page-scripts (make-parameter '()))
(define bootstrap-cookies (make-parameter '()))
(define bootstrap-inline-js (make-parameter #f))
(define (static str)
(string-append (bootstrap-static-urlprefix) str))
@ -90,6 +92,7 @@
,title-element
,@body-contents)
(script ,@(cond [(bootstrap-inline-js) => list] [else '()]))
(script ((type "text/javascript") (src ,(static "/jquery.min.js"))))
(script ((type "text/javascript") (src ,(static "/jquery.tablesorter.min.js"))))
(script ((type "text/javascript") (src ,(static "/jquery-ui.min.js"))))

View File

@ -98,16 +98,18 @@
(authentication-wrap* #t request (lambda () body ...)))
(define-syntax-rule (with-site-config body ...)
(parameterize ((bootstrap-navbar-header navbar-header)
(bootstrap-navigation `((,nav-index ,(main-page-url))
(,nav-search ,(named-url search-page))
;; ((div ,(glyphicon 'download-alt)
;; " Download")
;; "http://download.racket-lang.org/")
))
(bootstrap-static-urlprefix (if (rendering-static-page?) static-urlprefix ""))
(jsonp-baseurl backend-baseurl))
body ...))
(let ((static-base (if (rendering-static-page?) static-urlprefix "")))
(parameterize ((bootstrap-navbar-header navbar-header)
(bootstrap-navigation `((,nav-index ,(main-page-url))
(,nav-search ,(named-url search-page))
;; ((div ,(glyphicon 'download-alt)
;; " Download")
;; "http://download.racket-lang.org/")
))
(bootstrap-static-urlprefix static-base)
(bootstrap-inline-js (format "PkgSiteBaseUrl = '~a/json/';" static-base))
(jsonp-baseurl backend-baseurl))
body ...)))
(define clear-session-cookie (make-cookie COOKIE
""
@ -579,7 +581,7 @@
(define (main-page request)
(parameterize ((bootstrap-active-navigation nav-index)
(bootstrap-page-scripts '("/searchbox.js")))
(bootstrap-page-scripts (list (string-append static-urlprefix "/searchbox.js"))))
(define package-name-list (package-search "" '((main-distribution #f))))
(authentication-wrap
#:request request

View File

@ -1,6 +1,6 @@
$(document).ready(function () {
$("#q").focus();
$.getJSON("/json/search-completions", function (searchCompletions) {
PkgSite.getJSON("search-completions", function (searchCompletions) {
searchCompletions.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#q")), searchCompletions);
});

View File

@ -25,6 +25,10 @@ PkgSite = (function () {
});
}
function getJSON(relative_url, k) {
return $.getJSON(PkgSiteJsonBaseUrl + relative_url, k);
}
return {
multiTermComplete: multiTermComplete,
preventTabMovingDuringSelection: preventTabMovingDuringSelection
@ -35,13 +39,13 @@ $(document).ready(function () {
$("table.sortable").tablesorter();
if ($("#tags").length) {
$.getJSON((document.body.className === "package-form")
? "/json/formal-tags"
: "/json/tag-search-completions",
function (completions) {
completions.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")),
completions);
});
PkgSite.getJSON((document.body.className === "package-form")
? "formal-tags"
: "tag-search-completions",
function (completions) {
completions.sort();
PkgSite.multiTermComplete(PkgSite.preventTabMovingDuringSelection($("#tags")),
completions);
});
}
});