[Gd-chatter] r11329 - trunk/libraries/network/koala/sources/koala
turbo24prg at gwydiondylan.org
turbo24prg at gwydiondylan.org
Sun May 6 01:44:05 CEST 2007
Author: turbo24prg
Date: Sun May 6 01:44:02 2007
New Revision: 11329
Modified:
trunk/libraries/network/koala/sources/koala/dsp-taglib.dylan
trunk/libraries/network/koala/sources/koala/dsp.dylan
trunk/libraries/network/koala/sources/koala/library-unix.dylan
trunk/libraries/network/koala/sources/koala/library.dylan
trunk/libraries/network/koala/sources/koala/urls.dylan
Log:
Job: koala
some convenience methods and bugfixes
Modified: trunk/libraries/network/koala/sources/koala/dsp-taglib.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/dsp-taglib.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/dsp-taglib.dylan Sun May 6 01:44:02 2007
@@ -164,6 +164,15 @@
end;
end;
+define tag show-query-value in dsp
+ (page :: <dylan-server-page>, response :: <response>)
+ (name :: <string>)
+ let value = get-query-value(name);
+ if (value)
+ format(output-stream(response), "%s", value);
+ end if;
+end;
+
//// Date Tags
Modified: trunk/libraries/network/koala/sources/koala/dsp.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/dsp.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/dsp.dylan Sun May 6 01:44:02 2007
@@ -124,6 +124,16 @@
respond-to-head(page, request, response);
end;
+// convenience
+
+define method post (page :: <page>)
+ respond-to(#"post", page, current-request(), current-response());
+end;
+
+define method get (page :: <page>)
+ respond-to(#"get", page, current-request(), current-response());
+end;
+
// Applications should call this to register a page for a particular URL.
define function register-page
(url :: <string>, page :: <page>, #key replace?, prefix?)
@@ -1027,7 +1037,7 @@
iff(~tlib,
parse-error("Invalid taglib directive in template %=. "
"The tag library named %= was not found.",
- tlib-name),
+ page.source-location, tlib-name),
add!(taglibs, pair(tlib-prefix | tlib-name, tlib)));
end;
body-start
Modified: trunk/libraries/network/koala/sources/koala/library-unix.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library-unix.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/library-unix.dylan Sun May 6 01:44:02 2007
@@ -122,7 +122,7 @@
log, log-raw,
log-level, log-level-setter,
as-common-logfile-date;
-
+
end module utilities;
@@ -163,8 +163,10 @@
count-query-values,
count-form-values,
application-error,
+ current-url,
decode-url,
- encode-url;
+ encode-url,
+ redirect-to;
// Virtual hosts
create
@@ -380,10 +382,13 @@
<static-page>,
register-page, // Register a page for a given URL
url-to-page,
- respond-to-get, // Implement this for your page to handle GET requests
- respond-to-post, // Implement this for your page to handle POST requests
- respond-to-head, // Implement this for your page to handle HEAD requests
- respond-to,
+ respond-to-get, // outdated
+ respond-to-post, // outdated
+ respond-to-head, // outdated
+ respond-to, // Implement this for you page to handle a request
+ get, post, // convenience
+
+
page-source,
page-source-setter,
Modified: trunk/libraries/network/koala/sources/koala/library.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/library.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/library.dylan Sun May 6 01:44:02 2007
@@ -164,7 +164,8 @@
count-form-values,
application-error,
decode-url,
- encode-url;
+ encode-url,
+ redirect-to;
// Virtual hosts
create
Modified: trunk/libraries/network/koala/sources/koala/urls.dylan
==============================================================================
--- trunk/libraries/network/koala/sources/koala/urls.dylan (original)
+++ trunk/libraries/network/koala/sources/koala/urls.dylan Sun May 6 01:44:02 2007
@@ -31,6 +31,11 @@
=> (str :: <byte-string>)
// Note: n accumulates how many chars are NOT needed in the copy.
iterate count (pos :: <integer> = bpos, n :: <integer> = 0)
+ let plus-position = char-position('+', str, pos, epos);
+ if (plus-position)
+ str[plus-position] := ' ';
+ end if;
+
let pos = char-position('%', str, pos, epos);
if (pos)
if (pos + 3 <= epos)
@@ -117,7 +122,18 @@
#f
end;
end parse-url;
-
+
+define function current-url (#key escaped?)
+ => (uri :: <string>);
+ let request = current-request();
+ concatenate(if (escaped?)
+ encode-url(request.request-url, reserved?: #t)
+ else
+ current-request().request-url
+ end if, if (~empty?(request.request-query-string))
+ concatenate("?", request.request-query-string)
+ else "" end if);
+end;
define function parse-http-server (str :: <byte-string>,
net-beg :: <integer>,
@@ -168,4 +184,11 @@
end iterate;
end parse-url-path;
+define open generic redirect-to (object :: <object>, #key);
+
+define method redirect-to (url :: <string>, #key #all-keys)
+ let headers = current-response().response-headers;
+ add-header(headers, "Location", url);
+ see-other-redirect(headers: headers);
+end;
More information about the chatter
mailing list