Changes In Branch selfcontained Through [2da502548b] Excluding Merge-Ins
This is equivalent to a diff from 18e7e965e2 to 2da502548b
2015-04-14
| ||
04:45 | Merged selfcontained back to trunk check-in: d3fdfad50d user: matt tags: trunk | |
2013-05-19
| ||
07:03 | Added some missing files check-in: 154b67c8ea user: matt tags: selfcontained | |
07:01 | Self contained approach now working check-in: 2da502548b user: matt tags: selfcontained | |
2013-05-18
| ||
21:13 | Added utility to rollup pages check-in: 136be142e4 user: matt tags: selfcontained | |
2013-05-17
| ||
07:08 | refactor for selfcontained executables (incomplete) check-in: 55a8152be6 user: matt tags: selfcontained | |
2013-02-03
| ||
05:25 | Added additional verbage for debug and setup easing check-in: 18e7e965e2 user: matt tags: trunk | |
2013-01-09
| ||
06:20 | Fixed output of error in error page check-in: 60f784c4db user: matt tags: trunk | |
Modified Makefile from [90d147b144] to [943370488e].
1 2 3 4 5 6 7 8 9 10 11 | # Copyright 2007-2008, Matthew Welland. # # This program is made available under the GNU GPL version 2.0 or # greater. See the accompanying file COPYING for details. # # This program is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. include install.cfg | | > | | > > > > > > | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # Copyright 2007-2008, Matthew Welland. # # This program is made available under the GNU GPL version 2.0 or # greater. See the accompanying file COPYING for details. # # This program is distributed WITHOUT ANY WARRANTY; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. include install.cfg SRCFILES = stml.scm misc-stml.scm session.scm sqltbl.scm formdat.scm setup.scm keystore.scm html-filter.scm cookie.scm MODULEFILES = $(wildcard modules/*/*-mod.scm) SOFILES = $(MODULEFILES:%.scm=%.so) CFILES = $(MODULEFILES:%.scm=%.c) OFILES = $(SRCFILES:%.scm=%.o) TARGFILES = $(notdir $(SOFILES)) MODULES = $(addprefix $(TARGDIR)/modules/,$(TARGFILES)) install : $(TARGDIR)/stmlrun $(LOGDIR) $(MODULES) chicken-install all : $(SOFILES) # stmlrun : stmlrun.scm formdat.scm misc-stml.scm session.scm stml.scm \ # setup.scm html-filter.scm requirements.scm keystore.scm \ # cookie.scm sqltbl.scm # csc stmlrun.scm $(TARGDIR)/stmlrun : stmlrun stml.so install stmlrun $(TARGDIR) chmod a+rx $(TARGDIR)/stmlrun $(TARGDIR)/modules : mkdir -p $(TARGDIR)/modules $(MODULES) : $(SOFILES) $(TARGDIR)/modules cp $< $@ stmlrun : $(OFILES) stmlrun.scm requirements.scm stmlcommon.scm csc $(OFILES) stmlrun.scm -o stmlrun stml.so : stmlmodule.so cp stmlmodule.so stml.so stmlmodule.so : $(OFILES) stmlmodule.scm requirements.scm stmlcommon.scm csc $(OFILES) -s stmlmodule.scm # logging currently relies on this # $(LOGDIR) : mkdir -p $(LOGDIR) chmod a+rwx $(LOGDIR) |
︙ | ︙ |
Modified misc-stml.scm from [9d5a337236] to [805de087f1].
︙ | ︙ | |||
168 169 170 171 172 173 174 | (res '())) (if (eof-object? l) (s:log res) (loop (read-line p)(cons (list l "<BR>") res))))) #t)))) (define (s:validate-inputs) | > | | | | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | (res '())) (if (eof-object? l) (s:log res) (loop (read-line p)(cons (list l "<BR>") res))))) #t)))) (define (s:validate-inputs) (if (not (s:validate-uri)) (begin (s:error-page "Bad URI" (let ((ref (get-environment-variable "HTTP_REFERER"))) (if ref (list "referred from" ref) ""))) (exit)))) ;; anything except a list is converted to a string!!! (define (s:any->string val) (cond ((string? val) val) ((number? val) (number->string val)) ((symbol? val) (symbol->string val)) |
︙ | ︙ |
Added rollup-pages.scm version [a76b5d67f0].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | (use regex posix srfi-69 srfi-1) (define extract-rx (regexp "pages\\/(.*)_(view|ctrl).scm")) (let* ((views (glob "pages/*_view.scm")) (ctrls (glob "pages/*_ctrl.scm")) (all (append views ctrls)) (lookup (make-hash-table)) (pages (delete-duplicates (map (lambda (x) (let* ((res (string-match extract-rx x)) (page (cadr res)) (type (caddr res))) (hash-table-set! lookup (conc page "_" type) #t) (cadr res))) all)))) (if (null? all)(begin (print "No page files matching pages/*_(view|ctrl).scm")(exit))) (print "Pages: " pages) (with-output-to-file "all_pages.scm" (lambda () (for-each (lambda (page) (print "(define (pages:" page ")") (if (hash-table-ref/default lookup (conc page "_ctrl") #f) (print "(include \"pages/" page "_ctrl.scm\")")) (if (hash-table-ref/default lookup (conc page "_view") #f) (print "(include \"pages/" page "_view.scm\")")) (print ")\n")) pages)))) |
Modified session.scm from [c4e9fdabd2] to [b7ff27d8a3].
︙ | ︙ | |||
91 92 93 94 95 96 97 | (define (sdat-set-curr-err! vec val)(vector-set! vec 27 val)) (define (sdat-set-log-port! vec val)(vector-set! vec 28 val)) (define (sdat-set-logfile! vec val)(vector-set! vec 29 val)) (define (sdat-set-seen-pages! vec val)(vector-set! vec 30 val)) (define (sdat-set-page-dir-style! vec val)(vector-set! vec 31 val)) (define (sdat-set-debugmode! vec val)(vector-set! vec 32 val)) | < < < < < < < | < < < < < < < < | < < < < < < < < < < < < < < < < < | 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | (define (sdat-set-curr-err! vec val)(vector-set! vec 27 val)) (define (sdat-set-log-port! vec val)(vector-set! vec 28 val)) (define (sdat-set-logfile! vec val)(vector-set! vec 29 val)) (define (sdat-set-seen-pages! vec val)(vector-set! vec 30 val)) (define (sdat-set-page-dir-style! vec val)(vector-set! vec 31 val)) (define (sdat-set-debugmode! vec val)(vector-set! vec 32 val)) ;; The global session (define s:session (make-sdat)) ;; SPLIT INTO STRAIGHT FORWARD INIT AND COMPLEX INIT (define (session:initialize self) (sdat-set-dbtype! self 'pg) (sdat-set-page! self "home") ;; these are defaults (sdat-set-curr-page! self "home") (sdat-set-content-type! self "Content-type: text/html; charset=iso-8859-1\n\n") |
︙ | ︙ | |||
448 449 450 451 452 453 454 | (define (session:page-get self key) (hash-table-ref/default (sdat-get-pagevars self) key #f)) ;; get session vars for a specified page ;; (define (session:get self page key) (let ((ht (session:get-page-hash self page))) | | | | 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 | (define (session:page-get self key) (hash-table-ref/default (sdat-get-pagevars self) key #f)) ;; get session vars for a specified page ;; (define (session:get self page key) (let ((ht (session:get-page-hash self page))) (hash-table-ref/default ht (s:any->string key) #f))) ;; delete a session var for a specified page ;; (define (session:del! self page key) (let ((ht (session:get-page-hash self page))) (hash-table-delete! ht (s:any->string key)))) ;; get ALL keys for this page and store in the session pagevars hash ;; (define (session:get-vars self) (let ((session-id (sdat-get-session-id self))) (if (not session-id) (err:log "ERROR: No session id in session object! session:get-vars") |
︙ | ︙ | |||
602 603 604 605 606 607 608 609 610 611 612 | (cond ((list? x) x) ((string? x) x) (else '()))) (port-map (lambda (s) (eval s e)) (lambda ()(read p)))))) ;; May 2011, putting all pages into one directory for the following reasons: ;; 1. want filename to reflect page name (emacs limitation) ;; 2. that's it! no other reason. could make it configurable ... | > > > > > > > > > > > > > > | | | < | | | | | < | | < < < < < < < < < < < | | < < < < < < < | > | | | < | | | | < < < < < < < | < < < < < < < < < < | | | < > | | | | | | | | | | | 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | (cond ((list? x) x) ((string? x) x) (else '()))) (port-map (lambda (s) (eval s e)) (lambda ()(read p)))))) (define (session:process-file f) (let* ((p (open-input-file f)) (dat (process-port p))) (close-input-port p) dat)) ;; May 2011, putting all pages into one directory for the following reasons: ;; 1. want filename to reflect page name (emacs limitation) ;; 2. that's it! no other reason. could make it configurable ... ;; page-dir-style is: ;; 'stored => stored in executable ;; 'flat => pages flat directory ;; 'dir => directory tree pages/<pagename>/{view,control}.scm ;; parts: ;; 'both => load control and view (anything other than view or control ;; 'view => load view only ;; 'control => load control only (define (session:call-parts self page #!key (parts 'both)) (sdat-set-curr-page! self page) (session:log self "page-dir-style: " (sdat-get-page-dir-style self)) (let* ((dir-style (sdat-get-page-dir-style self));; (equal? (sdat-get-page-dir-style self) "onedir")) ;; flag #t for onedir, #f for old style (dir (string-append (sdat-get-sroot self) (if dir-style (conc "/pages/") (conc "/pages/" page))))) (case dir-style ;; NB// Stored always loads both control and view ((stored)((eval (string->symbol (conc "pages:" page))))) ((dir) ;; first the control (let ((control-file (conc "pages/" page "_ctrl.scm")) (view-file (conc "pages/" page "_view.scm"))) (if (and (file-exists? control-file) (not (eq? parts 'view))) (begin (session:set-called! self page) (load control-file))) (if (file-exists? view-file) (if (not (eq? parts 'control)) (session:process-file view-file)) (list "<p>Page not found " page " </p>")))) ((flat)) (else (list "ERROR: page-dir-style must be stored, dir or flat, got " dir-style))))) (define (session:call self page parts) (session:call-parts self page 'both)) ;; (define (session:load-model self model) ;; (let ((model.scm (string-append (sdat-get-sroot self) "/models/" model ".scm")) ;; (model.so (string-append (sdat-get-sroot self) "/models/" model ".so"))) ;; (if (file-exists? model.so) ;; (load model.so) ;; (if (file-exists? model.scm) ;; (load model.scm) ;; (s:log "ERROR: model " model.scm " not found"))))) ;; (define (session:model-path self model) ;; (string-append (sdat-get-sroot self) "/models/" model ".scm")) (define (session:pp-formdat self) (let ((dat (formdat:all->strings (sdat-get-formdat self)))) (string-intersperse dat "<br> "))) (define (session:param->string params) ;; (err:log "params=" params) |
︙ | ︙ |
Modified setup.scm from [f3ad64511f] to [73ece1fa1d].
︙ | ︙ | |||
8 9 10 11 12 13 14 | ;; PURPOSE. (declare (unit setup)) (declare (uses session)) (require-extension srfi-69) (require-extension regex) | < < < < < < < < | 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ;; PURPOSE. (declare (unit setup)) (declare (uses session)) (require-extension srfi-69) (require-extension regex) ;; use this for getting data from page to page when scope and evals ;; get in the way (define s:local-vars (make-hash-table)) (define (s:local-set! k v) (hash-table-set! s:local-vars k v)) (define (s:local-get k) (hash-table-ref/default s:local-vars k #f)) (define (s:log . msg) (apply session:log s:session msg)) (define (s:set-err . args) (sdat-set-curr-err! s:session args)) ;; Usage: (s:get-err s:big) (define (s:get-err wrapperfunc) (let ((errmsg (sdat-get-curr-err s:session))) (if errmsg ((if wrapperfunc |
︙ | ︙ |
Added stmlcommon.scm version [722378235d].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | ;; Copyright 2007-2011, Matthew Welland. ;; ;; This program is made available under the GNU GPL version 2.0 or ;; greater. See the accompanying file COPYING for details. ;; ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; (require-extension syntax-case) ;; (declare (run-time-macros)) (include "requirements.scm") (declare (uses cookie)) (declare (uses html-filter)) (declare (uses misc-stml)) (declare (uses formdat)) (declare (uses stml)) (declare (uses session)) (declare (uses setup)) ;; s:session gets created here (declare (uses sqltbl)) (declare (uses keystore)) (define (stml:cgi-session session) (session:initialize session) (session:setup session) (session:get-vars session) (sdat-set-log-port! session ;; (current-error-port)) (open-output-file (sdat-get-logfile session) #:append)) (s:validate-inputs) (session:run-actions session) (sdat-set-pagedat! session (append (sdat-get-pagedat session) (s:call (sdat-get-toppage session)))) (if (eq? (sdat-get-page-type session) 'html) ;; default is html. (session:cgi-out session) (session:alt-out session)) (session:save-vars session) (session:close session)) (define (stml:main proc) (handle-exceptions exn (begin (print "Content-type: text/html") (print "") (print "<html> <head> <title>EXCEPTION</title> </head> <body>") (print " QUERY_STRING is: <b> " (get-environment-variable "QUERY_STRING") " </b> <br>") (print "<pre>") ;; (print " EXCEPTION: " ((condition-property-accessor 'exn 'message) exn)) (print-error-message exn) (print-call-chain) (print "</pre>") (print "<table>") (for-each (lambda (var) (print "<tr><td>" (car var) "</td><td>" (cdr var) "</td></tr>")) (get-environment-variables)) (print "</table>") (print "</body></html>")) (if proc (proc s:session) (stml:cgi-session s:session)) ;; (raise-error) ;; (exit) )) |
Modified stmlrun.scm from [ced526ca73] to [ab2a64d7c8].
︙ | ︙ | |||
8 9 10 11 12 13 14 | ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; (require-extension syntax-case) ;; (declare (run-time-macros)) | < < < < < < < < < < < < < < < < < < | < < < < | < < < < | < < < < < < < < < < < < | < < | 8 9 10 11 12 13 14 15 16 17 18 | ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; (require-extension syntax-case) ;; (declare (run-time-macros)) ;; (include "stmlcommon.scm") (require-library stml) (stml:main #f) |