| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  | USING: calendar furnace furnace.validator io.files kernel | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  | namespaces sequences http.server.responders html math.parser rss | 
					
						
							| 
									
										
										
										
											2008-02-26 20:18:21 -05:00
										 |  |  | xml.writer xmode.code2html math calendar.format ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | IN: webapps.pastebin | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: pastebin pastes ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <pastebin> ( -- pastebin )
 | 
					
						
							|  |  |  |     V{ } clone pastebin construct-boa ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  | <pastebin> pastebin set-global
 | 
					
						
							| 
									
										
										
										
											2007-12-10 02:50:50 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  | TUPLE: paste | 
					
						
							|  |  |  | summary author channel mode contents date | 
					
						
							|  |  |  | annotations n ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  | : <paste> ( summary author channel mode contents -- paste )
 | 
					
						
							|  |  |  |     f V{ } clone f paste construct-boa ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  | TUPLE: annotation summary author mode contents ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | C: <annotation> annotation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : get-paste ( n -- paste )
 | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  |     pastebin get pastebin-pastes nth ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | : show-paste ( n -- )
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:22:35 -05:00
										 |  |  |     serving-html | 
					
						
							|  |  |  |     get-paste | 
					
						
							|  |  |  |     [ "show-paste" render-component ] with-html-stream ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | \ show-paste { { "n" v-number } } define-action | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : new-paste ( -- )
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:22:35 -05:00
										 |  |  |     serving-html | 
					
						
							|  |  |  |     [ "new-paste" render-template ] with-html-stream ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | \ new-paste { } define-action | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : paste-list ( -- )
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:22:35 -05:00
										 |  |  |     serving-html | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  |     [ | 
					
						
							|  |  |  |         [ show-paste ] "show-paste-quot" set
 | 
					
						
							|  |  |  |         [ new-paste ] "new-paste-quot" set
 | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  |         pastebin get "paste-list" render-component | 
					
						
							| 
									
										
										
										
											2007-12-06 00:22:35 -05:00
										 |  |  |     ] with-html-stream ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  | \ paste-list { } define-action | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 01:02:58 -05:00
										 |  |  | : paste-link ( paste -- link )
 | 
					
						
							|  |  |  |     paste-n number>string [ show-paste ] curry quot-link ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-01-09 01:33:51 -05:00
										 |  |  | : safe-head ( seq n -- seq' )
 | 
					
						
							|  |  |  |     over length min head ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 01:02:58 -05:00
										 |  |  | : paste-feed ( -- entries )
 | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  |     pastebin get pastebin-pastes <reversed> 20 safe-head [ | 
					
						
							| 
									
										
										
										
											2007-12-06 01:02:58 -05:00
										 |  |  |         { | 
					
						
							|  |  |  |             paste-summary | 
					
						
							|  |  |  |             paste-link | 
					
						
							|  |  |  |             paste-date | 
					
						
							| 
									
										
										
										
											2007-12-08 17:18:25 -05:00
										 |  |  |         } get-slots timestamp>rfc3339 f swap <entry> | 
					
						
							| 
									
										
										
										
											2007-12-06 01:02:58 -05:00
										 |  |  |     ] map ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : feed.xml ( -- )
 | 
					
						
							|  |  |  |     "text/xml" serving-content | 
					
						
							|  |  |  |     "pastebin" | 
					
						
							|  |  |  |     "http://pastebin.factorcode.org" | 
					
						
							|  |  |  |     paste-feed <feed> feed>xml write-xml ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \ feed.xml { } define-action | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | : add-paste ( paste pastebin -- )
 | 
					
						
							| 
									
										
										
										
											2007-12-08 17:18:25 -05:00
										 |  |  |     >r now over set-paste-date r> | 
					
						
							| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  |     pastebin-pastes 2dup length swap set-paste-n push ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:06:34 -05:00
										 |  |  | : submit-paste ( summary author channel mode contents -- )
 | 
					
						
							| 
									
										
										
										
											2008-01-30 00:06:27 -05:00
										 |  |  |     <paste> [ pastebin get add-paste ] keep
 | 
					
						
							|  |  |  |     paste-link permanent-redirect ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  | \ new-paste | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | \ submit-paste { | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  |     { "summary" v-required } | 
					
						
							|  |  |  |     { "author" v-required } | 
					
						
							|  |  |  |     { "channel" } | 
					
						
							|  |  |  |     { "mode" v-required } | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  |     { "contents" v-required } | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  | } define-form | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \ new-paste { | 
					
						
							|  |  |  |     { "channel" "#concatenative" } | 
					
						
							|  |  |  |     { "mode" "factor" } | 
					
						
							|  |  |  | } default-values | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 00:22:35 -05:00
										 |  |  | : annotate-paste ( n summary author mode contents -- )
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  |     <annotation> swap get-paste | 
					
						
							| 
									
										
										
										
											2008-02-01 00:21:06 -05:00
										 |  |  |     [ paste-annotations push ] keep
 | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  |     paste-link permanent-redirect ;
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  | [ "n" show-paste ] | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | \ annotate-paste { | 
					
						
							|  |  |  |     { "n" v-required v-number } | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  |     { "summary" v-required } | 
					
						
							|  |  |  |     { "author" v-required } | 
					
						
							|  |  |  |     { "mode" v-required } | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  |     { "contents" v-required } | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  | } define-form | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-18 03:24:05 -05:00
										 |  |  | \ show-paste { | 
					
						
							|  |  |  |     { "mode" "factor" } | 
					
						
							|  |  |  | } default-values | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-12-06 01:02:58 -05:00
										 |  |  | : style.css ( -- )
 | 
					
						
							|  |  |  |     "text/css" serving-content | 
					
						
							|  |  |  |     "style.css" send-resource ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | \ style.css { } define-action | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2007-11-07 15:01:42 -05:00
										 |  |  | "pastebin" "paste-list" "extra/webapps/pastebin" web-app |