Changeset 18030 in project


Ignore:
Timestamp:
05/10/10 00:11:28 (9 years ago)
Author:
mario
Message:

Updated docs for awful 0.18.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/awful

    r17929 r18030  
    1010
    1111* Straightforward interface to databases (currently supported are postgresql and sqlite3)
     12* Page dispatching via regular expressions
    1213* Easy access to query string and body request variables from HTTP requests
    1314* Ajax support via JQuery
     
    4546<enscript highlight=scheme>
    4647  (use awful)
    47  
     48
    4849  (define-page (main-page-path)
    4950    (lambda ()
     
    7475
    7576(use awful)
    76  
     77
    7778(define-page (main-page-path)
    7879  (lambda ()
     
    9192<enscript highlight=scheme>
    9293  (use awful)
    93  
     94
    9495  (define-page (main-page-path)
    9596    (lambda ()
     
    130131<enscript highlight=scheme>
    131132  (use awful)
    132  
     133
    133134  (enable-ajax #t)
    134  
     135
    135136  (define-page (main-page-path)
    136137    (lambda ()
     
    144145<enscript highlight=scheme>
    145146  (use awful)
    146  
     147
    147148  (enable-ajax #t)
    148  
     149
    149150  (define-page (main-page-path)
    150151    (lambda ()
     
    175176<enscript highlight=scheme>
    176177  (use awful)
    177  
     178
    178179  (enable-ajax #t)
    179  
     180
    180181  (define-page (main-page-path)
    181182    (lambda ()
     
    195196<enscript highlight=scheme>
    196197  (use awful)
    197  
     198
    198199  (enable-ajax #t)
    199  
     200
    200201  (define-page (main-page-path)
    201202    (lambda ()
     
    227228<enscript highlight=scheme>
    228229  (use awful awful-postgresql)
    229  
     230
    230231  (enable-db)
    231232  (db-credentials '((dbname . "my-db")
     
    233234                    (password . "secret")
    234235                    (host . "localhost")))
    235  
     236
    236237  (define-page "db-example"
    237238    (lambda ()
     
    288289<enscript highlight=scheme>
    289290  (use awful)
    290  
     291
    291292  (enable-session #t)
    292  
    293   (define-login-trampoline "/login-trampoline")   
    294  
     293
     294  (define-login-trampoline "/login-trampoline")
     295
    295296  (valid-password?
    296297    (lambda (user password)
    297298      (equal? user password)))
    298  
     299
    299300  (define-page (main-page-path)
    300301    (lambda ()
    301302      "Hello world!"))
    302  
     303
    303304  (define-page (login-page-path)
    304305    (lambda ()
     
    371372<enscript highlight=scheme>
    372373  (use awful)
    373  
     374
    374375  (enable-session #t)
    375  
     376
    376377  (define-login-trampoline "/login-trampoline")
    377    
     378
    378379  (valid-password?
    379380   (lambda (user password)
    380381     (equal? user password)))
    381  
     382
    382383  (page-access-control
    383384   (lambda (path)
    384385     (and (equal? ($ 'user) "mario")
    385386          (equal? path (main-page-path)))))
    386    
     387
    387388  (define-page (main-page-path)
    388389    (lambda ()
    389390      "Hello world"))
    390  
     391
    391392  (define-page (login-page-path)
    392393    (lambda ()
     
    500501<parameter>(page-charset [boolean or string])</parameter>
    501502
    502 The page charset to be used by all pages defined by {{define-page}}.  Can be overwritten by {{define-page}}'s {{charset}} keyword parameter. 
     503The page charset to be used by all pages defined by {{define-page}}.  Can be overwritten by {{define-page}}'s {{charset}} keyword parameter.
    503504The default value is {{#f}} (no explicit charset).
    504505
     
    757758<procedure>(define-page path contents #!key css title doctype headers charset no-ajax no-template no-session no-db no-javascript-compression)</procedure>
    758759
    759 Define an awful page. The {{css}}, {{title}}, {{doctype}}, {{headers}} and {{charset}} keyword parameters have the same meaning as [[http://chicken.wiki.br/eggref/4/html-utils]]'s {{html-page}}.
     760Define an awful page.
     761
     762{{path}} is the path to the page.  It can be represented by two types: a string and a regular expression object.  If it is a string, the path used in the URI will be bound to the given no-argument procedure {{contents}}.  If it is a regular expression object, any request whose URL path matches the regular expression will br handled by the one-argument procedure {{contents}}.  This procedure will be given the requested path.
     763
     764The {{css}}, {{title}}, {{doctype}}, {{headers}} and {{charset}} keyword parameters have the same meaning as [[http://chicken.wiki.br/eggref/4/html-utils]]'s {{html-page}}.
    760765
    761766If {{no-ajax}} is {{#t}}, it means that the page won't use ajax.
     
    769774If {{no-javascript-compression}} is {{#t}} the javascript code for the page is not compressed, even when {{enable-javascript-compression}} is not {{#f}}.
    770775
     776Examples:
     777
     778<enscript highlight=scheme>
     779
     780(use srfi-1 ;; for filter-map
     781     regex) ;; for regexp
     782
     783;; http://host:port/foo => "bar"
     784(define-page "/foo"
     785  (lambda ()
     786    "bar"))
     787
     788;; http://host:port/add/1/2/3 => 6
     789(define-page (regexp "/add/.*")
     790  (lambda (path)
     791    (let ((numbers (filter-map string->number (string-split path "/"))))
     792      (number->string (apply + numbers)))))
     793
     794</enscript>
    771795
    772796<procedure>(define-session-page path contents . rest)</procedure>
     
    10361060
    10371061=== Version history
     1062; 0.18:
     1063* support for regex-based page paths (see {{define-page}})
     1064* {{define-page}} checks whether the second arg is a procedure.
     1065* use {{-O3 -lambda-lift}} instead of {{-O2}} for compilation
     1066* {{main-page-path}} redirection made with code stolen from [[http://chicken.wiki.br/eggref/4/spiffy|spiffy]]'s {{send-response}}
     1067
    10381068; 0.17 : .meta bug fix.  postgresql is not required as a dependency (thanks to Stephen Pedrosa Eilert for pointing this issue).
    10391069; 0.16 :
Note: See TracChangeset for help on using the changeset viewer.