From b548162628aa5be5f932287f2ebbb9e13d327c62 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Nov 2007 01:30:32 -0500 Subject: [PATCH 1/4] New network-clipboard tool --- .../network-clipboard.factor | 99 +++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 extra/network-clipboard/network-clipboard.factor diff --git a/extra/network-clipboard/network-clipboard.factor b/extra/network-clipboard/network-clipboard.factor new file mode 100644 index 0000000000..208de386bd --- /dev/null +++ b/extra/network-clipboard/network-clipboard.factor @@ -0,0 +1,99 @@ +! Copyright (C) 2007 Slava Pestov. +! See http://factorcode.org/license.txt for BSD license. +USING: io.server io.sockets io strings parser byte-arrays +namespaces ui.clipboards ui.gadgets.panes ui.gadgets.scrollers +ui.gadgets.buttons ui.gadgets.tracks ui.gadgets ui.operations +ui.commands ui kernel splitting combinators continuations +sequences io.streams.duplex models ; +IN: network-clipboard + +: clipboard-port 4444 ; + +: get-request + clipboard get clipboard-contents write ; + +: contents ( -- str ) + [ 1024 read dup ] [ ] [ drop ] unfold concat ; + +: set-request + contents clipboard get set-clipboard-contents ; + +: clipboard-server ( -- ) + clipboard-port internet-server "clip-server" [ + readln { + { "GET" [ get-request ] } + { "SET" [ set-request ] } + } case + ] with-server ; + +\ clipboard-server H{ + { +nullary+ t } + { +listener+ t } +} define-command + +: ( -- datagram ) + "0.0.0.0" 0 ; + +: with-client ( addrspec quot -- ) + >r r> with-stream ; inline + +: send-text ( text host -- ) + clipboard-port [ write ] with-client ; + +TUPLE: host name ; + +C: host + +M: string host-name ; + +: send-clipboard ( host -- ) + host-name + "SET\n" clipboard get clipboard-contents append swap send-text ; + +[ host? ] \ send-clipboard H{ } define-operation + +: ask-text ( text host -- ) + clipboard-port + [ write flush contents ] with-client ; + +: receive-clipboard ( host -- ) + host-name + "GET\n" swap ask-text + clipboard get set-clipboard-contents ; + +[ host? ] \ receive-clipboard H{ } define-operation + +: hosts. ( seq -- ) + "Hosts:" print + [ dup write-object nl ] each ; + +TUPLE: network-clipboard-tool ; + +\ network-clipboard-tool "toolbar" f { + { f clipboard-server } +} define-command-map + +: ( model -- gadget ) + \ network-clipboard-tool construct-empty [ + toolbar, + [ hosts. ] 1 track, + ] { 0 1 } build-track ; + +SYMBOL: network-clipboards + +{ } network-clipboards set-global + +: set-network-clipboards ( seq -- ) + network-clipboards get set-model ; + +: add-network-clipboard ( host -- ) + network-clipboards get [ swap add ] change-model ; + +: network-clipboard-tool ( -- ) + [ + network-clipboards get + + "Network clipboard" open-window + ] with-ui ; + +MAIN: network-clipboard-tool From 243caeb64ee87e0c2dca7e3dcdfafdb8aa525c21 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Nov 2007 01:30:38 -0500 Subject: [PATCH 2/4] Planet fix --- extra/webapps/planet/planet.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/webapps/planet/planet.factor b/extra/webapps/planet/planet.factor index 3f7fed6446..aaefa6d324 100644 --- a/extra/webapps/planet/planet.factor +++ b/extra/webapps/planet/planet.factor @@ -92,7 +92,7 @@ SYMBOL: cached-postings cached-postings get 4 head print-posting-summaries ; : planet-factor ( -- ) - [ + serving-html [ "resource:extra/webapps/planet/planet.fhtml" run-template-file ] with-html-stream ; From 6f19e210b32dc8161d127d9462354db5e7657ad8 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Nov 2007 01:56:40 -0500 Subject: [PATCH 3/4] Fix parent-directory on / --- core/io/files/files.factor | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/core/io/files/files.factor b/core/io/files/files.factor index efa9096791..2bbcab8f93 100755 --- a/core/io/files/files.factor +++ b/core/io/files/files.factor @@ -66,12 +66,14 @@ TUPLE: no-parent-directory path ; : parent-directory ( path -- parent ) trim-path-separators - dup root-directory? [ ] [ - dup last-path-separator drop [ - 1+ cut - special-directory? - [ no-parent-directory ] when - ] when* + dup empty? [ drop "/" ] [ + dup root-directory? [ ] [ + dup last-path-separator drop [ + 1+ cut + special-directory? + [ no-parent-directory ] when + ] when* + ] if ] if ; : file-name ( path -- string ) From 9ebd234e98a3b4ea922380bdf45c5e333351012e Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Mon, 12 Nov 2007 01:56:46 -0500 Subject: [PATCH 4/4] Fix planet USING: --- extra/webapps/planet/planet.factor | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/webapps/planet/planet.factor b/extra/webapps/planet/planet.factor index aaefa6d324..75302eb59c 100644 --- a/extra/webapps/planet/planet.factor +++ b/extra/webapps/planet/planet.factor @@ -1,7 +1,7 @@ USING: sequences rss arrays concurrency kernel sorting html.elements io assocs namespaces math threads vocabs html furnace http.server.templating calendar math.parser splitting -continuations debugger system ; +continuations debugger system http.server.responders ; IN: webapps.planet TUPLE: posting author title date link body ;