gopher: some aesthetics.

char-rename
John Benediktsson 2016-10-26 19:50:00 -07:00
parent 3ce5146235
commit 920d693205
2 changed files with 4 additions and 5 deletions

View File

@ -49,8 +49,7 @@ PRIVATE>
ERROR: not-a-gopher-url url ;
: gopher ( url -- item-type byte-array )
dup url? [ >url ] unless
dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
>url dup protocol>> "gopher" = [ not-a-gopher-url ] unless {
[ host>> ]
[ port>> 70 or <inet> binary ]
[ path>> rest [ "1/" ] when-empty ]
@ -108,8 +107,7 @@ M: gopher-link >url
PRIVATE>
: gopher. ( url -- )
dup url? [ >url ] unless
[ path>> ] [ gopher swap ] bi {
>url [ path>> ] [ gopher swap ] bi {
{ A_TEXT [ gopher-text. ] }
{ A_MENU [ gopher-menu. ] }
{ A_INDEX [ gopher-menu. ] }

View File

@ -48,6 +48,7 @@ TUPLE: gopher-server < threaded-server
:: list-directory ( server path -- )
path server serving-directory>> ?head drop [
[ "/" ] when-empty
"i[%s]\t\terror.host\t1\r\n\r\n" sprintf
utf8 encode write
] [
@ -70,8 +71,8 @@ TUPLE: gopher-server < threaded-server
"%-40s %s %10s" sprintf
] [
path prepend-path
server serving-directory>> ?head drop
] bi
server serving-directory>> ?head drop
server serving-hostname>>
server insecure>>
"%s%s\t%s\t%s\t%d\r\n" sprintf