Support for relative URIs for https + http access.
* tekuti/page-helpers.scm (ensure-uri): Rename from ensure-public-uri. A URI is absolute by definition. (ensure-uri-reference): New helper. Requires git guile. (respond): Use ensure-URI-reference to get the reference. (atom-header, atom-entry): Use ensure-uri. * tekuti/page.scm (atom-feed-from-posts): Pass the URI scheme from the request-uri when reconstructing * tekuti/config.scm (*public-scheme*): New config variable, defaulting to http.
This commit is contained in:
parent
c631aaf35c
commit
ab54aca59f
2 changed files with 19 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
;; Tekuti
|
;; Tekuti
|
||||||
;; Copyright (C) 2008, 2010, 2012 Andy Wingo <wingo at pobox dot com>
|
;; Copyright (C) 2008, 2010, 2012, 2014 Andy Wingo <wingo at pobox dot com>
|
||||||
|
|
||||||
;; This program is free software; you can redistribute it and/or
|
;; This program is free software; you can redistribute it and/or
|
||||||
;; modify it under the terms of the GNU General Public License as
|
;; modify it under the terms of the GNU General Public License as
|
||||||
|
@ -27,13 +27,14 @@
|
||||||
(define-module (tekuti config)
|
(define-module (tekuti config)
|
||||||
#:use-module (tekuti util)
|
#:use-module (tekuti util)
|
||||||
#:use-module ((sxml ssax) #:select (define-parsed-entity!))
|
#:use-module ((sxml ssax) #:select (define-parsed-entity!))
|
||||||
#:export (*public-host* *public-port* *public-path-base*
|
#:export (*public-scheme* *public-host* *public-port* *public-path-base*
|
||||||
*private-host* *private-port* *private-path-base*
|
*private-host* *private-port* *private-path-base*
|
||||||
*git-dir* *git* *debug* *admin-user* *admin-pass*
|
*git-dir* *git* *debug* *admin-user* *admin-pass*
|
||||||
*css-file* *navbar-links* *navbar-infix*
|
*css-file* *navbar-links* *navbar-infix*
|
||||||
*title* *subtitle* *name*
|
*title* *subtitle* *name*
|
||||||
*server-impl* *server-impl-args*))
|
*server-impl* *server-impl-args*))
|
||||||
|
|
||||||
|
(define *public-scheme* 'http)
|
||||||
(define *public-host* "127.0.0.1")
|
(define *public-host* "127.0.0.1")
|
||||||
(define *public-port* 8080)
|
(define *public-port* 8080)
|
||||||
(define *public-path-base* '())
|
(define *public-path-base* '())
|
||||||
|
|
|
@ -65,13 +65,23 @@
|
||||||
((_ tail)
|
((_ tail)
|
||||||
tail)))
|
tail)))
|
||||||
|
|
||||||
(define (ensure-public-uri x)
|
(define (ensure-uri x)
|
||||||
(cond
|
(cond
|
||||||
((uri? x) x)
|
((uri? x) x)
|
||||||
((string? x)
|
((string? x)
|
||||||
(build-uri 'http #:host *public-host* #:port *public-port* #:path x))
|
(build-uri *public-scheme* #:host *public-host* #:port *public-port*
|
||||||
|
#:path x))
|
||||||
((list? x)
|
((list? x)
|
||||||
(ensure-public-uri (relurl x)))
|
(ensure-uri (relurl x)))
|
||||||
|
(else (error "can't turn into a uri" x))))
|
||||||
|
|
||||||
|
(define (ensure-uri-reference x)
|
||||||
|
(cond
|
||||||
|
((uri? x) x)
|
||||||
|
((string? x)
|
||||||
|
(build-uri-reference #:path x))
|
||||||
|
((list? x)
|
||||||
|
(ensure-uri-reference (relurl x)))
|
||||||
(else (error "can't turn into a uri" x))))
|
(else (error "can't turn into a uri" x))))
|
||||||
|
|
||||||
(define* (respond #:optional body #:key
|
(define* (respond #:optional body #:key
|
||||||
|
@ -88,7 +98,7 @@
|
||||||
(values (build-response
|
(values (build-response
|
||||||
#:code status
|
#:code status
|
||||||
#:headers (build-headers
|
#:headers (build-headers
|
||||||
location (and=> redirect ensure-public-uri)
|
location (and=> redirect ensure-uri-reference)
|
||||||
last-modified last-modified
|
last-modified last-modified
|
||||||
content-type (cons content-type content-type-params)
|
content-type (cons content-type content-type-params)
|
||||||
date (current-date)
|
date (current-date)
|
||||||
|
@ -377,7 +387,7 @@
|
||||||
|
|
||||||
(define (atom-header last-modified)
|
(define (atom-header last-modified)
|
||||||
(define (relurl . tail)
|
(define (relurl . tail)
|
||||||
(uri->string (ensure-public-uri tail)))
|
(uri->string (ensure-uri tail)))
|
||||||
`(feed
|
`(feed
|
||||||
(@ (xmlns "http://www.w3.org/2005/Atom") (xml:base ,(relurl)))
|
(@ (xmlns "http://www.w3.org/2005/Atom") (xml:base ,(relurl)))
|
||||||
(title (@ (type "text")) ,*title*)
|
(title (@ (type "text")) ,*title*)
|
||||||
|
@ -396,7 +406,7 @@
|
||||||
|
|
||||||
(define (atom-entry post)
|
(define (atom-entry post)
|
||||||
(define (relurl . tail)
|
(define (relurl . tail)
|
||||||
(uri->string (ensure-public-uri tail)))
|
(uri->string (ensure-uri tail)))
|
||||||
`(entry
|
`(entry
|
||||||
(author (name ,*name*) (uri ,(relurl)))
|
(author (name ,*name*) (uri ,(relurl)))
|
||||||
(title (@ (type "text")) ,(post-title post))
|
(title (@ (type "text")) ,(post-title post))
|
||||||
|
|
Loading…
Reference in a new issue