| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  | ! Copyright (c) 2008 Slava Pestov | 
					
						
							|  |  |  | ! See http://factorcode.org/license.txt for BSD license. | 
					
						
							|  |  |  | USING: accessors kernel sequences assocs io.files io.sockets | 
					
						
							|  |  |  | io.sockets.secure io.servers.connection | 
					
						
							|  |  |  | namespaces db db.tuples db.sqlite smtp urls | 
					
						
							|  |  |  | logging.insomniac | 
					
						
							|  |  |  | http.server | 
					
						
							|  |  |  | http.server.dispatchers | 
					
						
							|  |  |  | http.server.redirection | 
					
						
							|  |  |  | furnace.alloy | 
					
						
							|  |  |  | furnace.auth.login | 
					
						
							|  |  |  | furnace.auth.providers.db | 
					
						
							|  |  |  | furnace.auth.features.edit-profile | 
					
						
							|  |  |  | furnace.auth.features.recover-password | 
					
						
							|  |  |  | furnace.auth.features.registration | 
					
						
							| 
									
										
										
										
											2008-06-18 04:26:50 -04:00
										 |  |  | furnace.auth.features.deactivate-user | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  | furnace.boilerplate | 
					
						
							|  |  |  | furnace.redirection | 
					
						
							|  |  |  | webapps.blogs | 
					
						
							|  |  |  | webapps.pastebin | 
					
						
							|  |  |  | webapps.planet | 
					
						
							|  |  |  | webapps.todo | 
					
						
							|  |  |  | webapps.wiki | 
					
						
							|  |  |  | webapps.wee-url | 
					
						
							|  |  |  | webapps.user-admin ;
 | 
					
						
							|  |  |  | IN: websites.concatenative | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-08 17:15:51 -04:00
										 |  |  | : test-db ( -- params db ) "resource:test.db" sqlite-db ;
 | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : init-factor-db ( -- )
 | 
					
						
							|  |  |  |     test-db [ | 
					
						
							|  |  |  |         init-furnace-tables | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         { | 
					
						
							|  |  |  |             post comment | 
					
						
							|  |  |  |             paste annotation | 
					
						
							|  |  |  |             blog posting | 
					
						
							|  |  |  |             todo | 
					
						
							|  |  |  |             short-url | 
					
						
							|  |  |  |             article revision | 
					
						
							|  |  |  |         } ensure-tables | 
					
						
							|  |  |  |     ] with-db ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | TUPLE: factor-website < dispatcher ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : <factor-website> ( -- responder )
 | 
					
						
							|  |  |  |     factor-website new-dispatcher | 
					
						
							|  |  |  |         <blogs> "blogs" add-responder | 
					
						
							|  |  |  |         <todo-list> "todo" add-responder | 
					
						
							|  |  |  |         <pastebin> "pastebin" add-responder | 
					
						
							| 
									
										
										
										
											2008-07-08 16:22:44 -04:00
										 |  |  |         <planet> "planet" add-responder | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  |         <wiki> "wiki" add-responder | 
					
						
							|  |  |  |         <wee-url> "wee-url" add-responder | 
					
						
							|  |  |  |         <user-admin> "user-admin" add-responder | 
					
						
							|  |  |  |         URL" /wiki/view/Front Page" <redirect-responder> "" add-responder | 
					
						
							|  |  |  |     "Factor website" <login-realm> | 
					
						
							|  |  |  |         "Factor website" >>name | 
					
						
							|  |  |  |         allow-registration | 
					
						
							|  |  |  |         allow-password-recovery | 
					
						
							|  |  |  |         allow-edit-profile | 
					
						
							| 
									
										
										
										
											2008-06-18 04:26:50 -04:00
										 |  |  |         allow-deactivation | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  |     <boilerplate> | 
					
						
							|  |  |  |         { factor-website "page" } >>template | 
					
						
							|  |  |  |     test-db <alloy> ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-18 04:40:05 -04:00
										 |  |  | SYMBOL: key-password | 
					
						
							|  |  |  | SYMBOL: key-file | 
					
						
							|  |  |  | SYMBOL: dh-file | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : common-configuration ( -- )
 | 
					
						
							|  |  |  |     "concatenative.org" 25 <inet> smtp-server set-global
 | 
					
						
							| 
									
										
										
										
											2008-06-18 03:54:11 -04:00
										 |  |  |     "noreply@concatenative.org" lost-password-from set-global
 | 
					
						
							|  |  |  |     "website@concatenative.org" insomniac-sender set-global
 | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  |     "slava@factorcode.org" insomniac-recipients set-global
 | 
					
						
							| 
									
										
										
										
											2008-06-18 04:40:05 -04:00
										 |  |  |     <factor-website> main-responder set-global
 | 
					
						
							|  |  |  |     init-factor-db ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : init-testing ( -- )
 | 
					
						
							|  |  |  |     "resource:extra/openssl/test/dh1024.pem" dh-file set-global
 | 
					
						
							|  |  |  |     "resource:extra/openssl/test/server.pem" key-file set-global
 | 
					
						
							|  |  |  |     "password" key-password set-global
 | 
					
						
							|  |  |  |     common-configuration ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | : init-production ( -- )
 | 
					
						
							|  |  |  |     "/home/slava/cert/host.pem" key-file set-global
 | 
					
						
							|  |  |  |     common-configuration ;
 | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : <factor-secure-config> ( -- config )
 | 
					
						
							|  |  |  |     <secure-config> | 
					
						
							| 
									
										
										
										
											2008-06-18 04:40:05 -04:00
										 |  |  |         key-file get >>key-file | 
					
						
							|  |  |  |         dh-file get >>dh-file | 
					
						
							|  |  |  |         key-password get >>password ;
 | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | : <factor-website-server> ( -- threaded-server )
 | 
					
						
							|  |  |  |     <http-server> | 
					
						
							|  |  |  |         <factor-secure-config> >>secure-config | 
					
						
							|  |  |  |         8080 >>insecure | 
					
						
							|  |  |  |         8431 >>secure ;
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-18 04:40:05 -04:00
										 |  |  | : start-website ( -- )
 | 
					
						
							| 
									
										
										
										
											2008-06-17 01:10:46 -04:00
										 |  |  |     test-db start-expiring | 
					
						
							|  |  |  |     test-db start-update-task | 
					
						
							|  |  |  |     http-insomniac | 
					
						
							|  |  |  |     <factor-website-server> start-server ;
 |