From 56d7869b60cca57df7be70338d7b95a85eb43f55 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Thu, 1 Nov 2007 15:20:11 -0500 Subject: [PATCH 1/5] Fix error printing for dlopen on windows --- vm/os-windows.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/vm/os-windows.c b/vm/os-windows.c index 6e39422134..421d90b223 100755 --- a/vm/os-windows.c +++ b/vm/os-windows.c @@ -51,8 +51,7 @@ void ffi_dlopen (F_DLL *dll, bool error) { dll->dll = NULL; if(error) - general_error(ERROR_FFI,F,F, - (void*)tag_object(get_error_message())); + general_error(ERROR_FFI,F,tag_object(get_error_message()),NULL); else return; } From a609d192b6b6b3f4f485d027cbb57900f268591b Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 6 Nov 2007 08:56:54 -0600 Subject: [PATCH 2/5] Fix typo in installer script --- misc/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/install.sh b/misc/install.sh index baf05192ec..006a7cf604 100755 --- a/misc/install.sh +++ b/misc/install.sh @@ -112,7 +112,7 @@ check_ret wget if [[ $OS == windows-nt ]] ; then wget http://factorcode.org/dlls/freetype6.dll check_ret - wget http://factorcode.org/dlls/zlib1.dla + wget http://factorcode.org/dlls/zlib1.dll check_ret fi From e5b4177487e7af28bd98056cb8bb985f8b02d6e7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 6 Nov 2007 15:51:50 -0600 Subject: [PATCH 3/5] Port alarms to the new modules system --- extra/alarms/alarms.factor | 87 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 extra/alarms/alarms.factor diff --git a/extra/alarms/alarms.factor b/extra/alarms/alarms.factor new file mode 100644 index 0000000000..4842f8b7ae --- /dev/null +++ b/extra/alarms/alarms.factor @@ -0,0 +1,87 @@ +! Copyright (C) 2007 Doug Coleman. +! See http://factorcode.org/license.txt for BSD license. +USING: arrays calendar combinators concurrency generic +init kernel math namespaces sequences threads ; +IN: alarms + +TUPLE: alarm time quot ; + +C: alarm + + 0 > ] curry* subset ; + +: unexpired-alarms ( -- seq ) + now alarms get-global + [ alarm-time <=> 0 <= ] curry* subset ; + +: call-alarm ( alarm -- ) + alarm-quot spawn drop ; + +: do-alarms ( -- ) + expired-alarms [ call-alarm ] each + unexpired-alarms alarms set-global ; + +: alarm-receive-loop ( -- ) + receive dup alarm? [ handle-alarm ] [ drop ] if + alarm-receive-loop ; + +: start-alarm-receiver ( -- ) + [ + alarm-receive-loop + ] spawn alarm-receiver set-global ; + +: alarm-loop ( -- ) + alarms get-global empty? [ + do-alarms + ] unless 100 sleep alarm-loop ; + +: start-alarm-looper ( -- ) + [ + alarm-loop + ] spawn alarm-looper set-global ; + +: send-alarm ( str alarm -- ) + over set-delegate + alarm-receiver get-global send ; + +: start-alarm-daemon ( -- ) + alarms get-global [ V{ } clone alarms set-global ] unless + start-alarm-looper + start-alarm-receiver ; + +[ start-alarm-daemon ] "alarms" add-init-hook +PRIVATE> + +: register-alarm ( alarm -- ) + "register" send-alarm ; + +: unregister-alarm ( alarm -- ) + "unregister" send-alarm ; + +: change-alarm ( alarm-old alarm-new -- ) + "register" send-alarm + "unregister" send-alarm ; + +! Example: +! 5 seconds from-now [ "hi" print flush ] register-alarm From 028668cc094720f71bb25af4129fe2ca9da5afa7 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Tue, 6 Nov 2007 21:04:01 -0600 Subject: [PATCH 4/5] Remove debugging print --- extra/concurrency/concurrency.factor | 1 - 1 file changed, 1 deletion(-) diff --git a/extra/concurrency/concurrency.factor b/extra/concurrency/concurrency.factor index 426ef617ca..1e9b769823 100644 --- a/extra/concurrency/concurrency.factor +++ b/extra/concurrency/concurrency.factor @@ -43,7 +43,6 @@ TUPLE: thread timeout continuation continued? ; : (mailbox-block-if-empty) ( mailbox timeout -- mailbox2 ) over mailbox-empty? [ [ swap mailbox-threads push stop ] callcc0 - "(mailbox-block-if-empty)" print flush (mailbox-block-if-empty) ] [ drop From 415ee37e064570bf617162e64ae822e108faed45 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Wed, 7 Nov 2007 14:01:42 -0600 Subject: [PATCH 5/5] Updated the pastebin --- extra/webapps/pastebin/annotate-paste.furnace | 28 ++++++ extra/webapps/pastebin/annotation.furnace | 11 +++ extra/webapps/pastebin/new-paste.furnace | 27 ++++++ extra/webapps/pastebin/paste-list.furnace | 7 ++ extra/webapps/pastebin/paste-summary.furnace | 9 ++ extra/webapps/pastebin/pastebin.factor | 93 +++++++++++++++++++ extra/webapps/pastebin/show-paste.furnace | 15 +++ 7 files changed, 190 insertions(+) create mode 100644 extra/webapps/pastebin/annotate-paste.furnace create mode 100644 extra/webapps/pastebin/annotation.furnace create mode 100644 extra/webapps/pastebin/new-paste.furnace create mode 100644 extra/webapps/pastebin/paste-list.furnace create mode 100644 extra/webapps/pastebin/paste-summary.furnace create mode 100644 extra/webapps/pastebin/pastebin.factor create mode 100644 extra/webapps/pastebin/show-paste.furnace diff --git a/extra/webapps/pastebin/annotate-paste.furnace b/extra/webapps/pastebin/annotate-paste.furnace new file mode 100644 index 0000000000..c963e2f88f --- /dev/null +++ b/extra/webapps/pastebin/annotate-paste.furnace @@ -0,0 +1,28 @@ +<% USING: io math math.parser namespaces ; %> + +

Annotate

+ +
+ + + +string write %>" /> + + + + + + + + + + + + + + + +
Your name:
Summary:
Contents:
+ + +
diff --git a/extra/webapps/pastebin/annotation.furnace b/extra/webapps/pastebin/annotation.furnace new file mode 100644 index 0000000000..ed1bdac845 --- /dev/null +++ b/extra/webapps/pastebin/annotation.furnace @@ -0,0 +1,11 @@ +<% USING: namespaces io ; %> + +

Annotation: <% "summary" get write %>

+ + + + + +
Annotation by:<% "author" get write %>
Channel:<% "channel" get write %>
Created:<% "date" get write %>
+ +
<% "contents" get write %>
diff --git a/extra/webapps/pastebin/new-paste.furnace b/extra/webapps/pastebin/new-paste.furnace new file mode 100644 index 0000000000..8a2544e801 --- /dev/null +++ b/extra/webapps/pastebin/new-paste.furnace @@ -0,0 +1,27 @@ +
+ + + + + + + + + + + + + + + + + + + + + + +
Your name:
Summary:
Channel:
Contents:
+ + +
diff --git a/extra/webapps/pastebin/paste-list.furnace b/extra/webapps/pastebin/paste-list.furnace new file mode 100644 index 0000000000..7a25ae2f50 --- /dev/null +++ b/extra/webapps/pastebin/paste-list.furnace @@ -0,0 +1,7 @@ +<% USING: namespaces furnace sequences ; %> + + +<% "new-paste-quot" get "New paste" render-link %> + +<% "pastes" get [ "paste-summary" render-template ] each %>
 Summary:Paste by:LinkDate
+ diff --git a/extra/webapps/pastebin/paste-summary.furnace b/extra/webapps/pastebin/paste-summary.furnace new file mode 100644 index 0000000000..f5c156a27e --- /dev/null +++ b/extra/webapps/pastebin/paste-summary.furnace @@ -0,0 +1,9 @@ +<% USING: continuations namespaces io kernel math math.parser furnace ; %> + + +<% "n" get number>string write %> +<% "summary" get write %> +<% "author" get write %> +<% "n" get number>string "show-paste-quot" get curry "Show" render-link %> +<% "date" get print %> + diff --git a/extra/webapps/pastebin/pastebin.factor b/extra/webapps/pastebin/pastebin.factor new file mode 100644 index 0000000000..f592f96448 --- /dev/null +++ b/extra/webapps/pastebin/pastebin.factor @@ -0,0 +1,93 @@ +USING: calendar furnace furnace.validator io.files kernel namespaces +sequences store ; +IN: webapps.pastebin + +TUPLE: pastebin pastes ; + +: ( -- pastebin ) + V{ } clone pastebin construct-boa ; + +TUPLE: paste n summary article author channel contents date annotations ; + +: ( summary author channel contents -- paste ) + V{ } clone + { + set-paste-summary + set-paste-author + set-paste-channel + set-paste-contents + set-paste-annotations + } paste construct ; + +TUPLE: annotation summary author contents ; + +C: annotation + + +SYMBOL: store + +"pastebin.store" resource-path load-store store set-global + + \ pastebin store get store-variable + +: get-paste ( n -- paste ) + pastebin get pastebin-pastes nth ; + +: show-paste ( n -- ) + get-paste "show-paste" "Paste" render-page ; + +\ show-paste { { "n" v-number } } define-action + +: new-paste ( -- ) + f "new-paste" "New paste" render-page ; + +\ new-paste { } define-action + +: paste-list ( -- ) + [ + [ show-paste ] "show-paste-quot" set + [ new-paste ] "new-paste-quot" set + pastebin get "paste-list" "Pastebin" render-page + ] with-scope ; + +\ paste-list { } define-action + + + +: save-pastebin-store ( -- ) + store get-global save-store ; + +: add-paste ( paste pastebin -- ) + >r now timestamp>http-string over set-paste-date r> + pastebin-pastes + [ length over set-paste-n ] keep push ; + +: submit-paste ( summary author channel contents -- ) + + \ pastebin get-global add-paste + save-pastebin-store ; + +\ submit-paste { + { "summary" v-required } + { "author" v-required } + { "channel" "#concatenative" v-default } + { "contents" v-required } +} define-action + +\ submit-paste [ paste-list ] define-redirect + +: annotate-paste ( n summary author contents -- ) + swap get-paste + paste-annotations push + save-pastebin-store ; + +\ annotate-paste { + { "n" v-required v-number } + { "summary" v-required } + { "author" v-required } + { "contents" v-required } +} define-action + +\ annotate-paste [ "n" show-paste ] define-redirect + +"pastebin" "paste-list" "extra/webapps/pastebin" web-app diff --git a/extra/webapps/pastebin/show-paste.furnace b/extra/webapps/pastebin/show-paste.furnace new file mode 100644 index 0000000000..b3b4e99b6e --- /dev/null +++ b/extra/webapps/pastebin/show-paste.furnace @@ -0,0 +1,15 @@ +<% USING: namespaces io furnace sequences ; %> + +

Paste: <% "summary" get write %>

+ + + + + +
Paste by:<% "author" get write %>
Channel:<% "channel" get write %>
Created:<% "date" get write %>
+ +
<% "contents" get write %>
+ +<% "annotations" get [ "annotation" render-template ] each %> + +<% model get "annotate-paste" render-template %>