Index: Makefile ================================================================== --- Makefile +++ Makefile @@ -16,19 +16,20 @@ 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 +$(TARGDIR)/stmlrun : stmlrun stml.so install stmlrun $(TARGDIR) chmod a+rx $(TARGDIR)/stmlrun $(TARGDIR)/modules : mkdir -p $(TARGDIR)/modules @@ -37,12 +38,15 @@ cp $< $@ stmlrun : $(OFILES) stmlrun.scm requirements.scm stmlcommon.scm csc $(OFILES) stmlrun.scm -o stmlrun -stml.so : $(OFILES) stmlmodule.scm requirements.scm stmlcommon.scm - csc $(OFILES) -s stml.scm +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) Index: rollup-pages.scm ================================================================== --- rollup-pages.scm +++ rollup-pages.scm @@ -18,14 +18,14 @@ (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\")")) - (if (hash-table-ref/default lookup (conc page "_ctrl") #f) - (print "(include \"pages/" page "_ctrl.scm\")")) (print ")\n")) pages)))) Index: session.scm ================================================================== --- session.scm +++ session.scm @@ -572,93 +572,70 @@ ((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 ... -(define (session:call-parts self page parts) +;; page-dir-style is: +;; 'stored => stored in executable +;; 'flat => pages flat directory +;; 'dir => directory tree pages//{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 ;; (equal? (sdat-get-page-dir-style self) "onedir")) ;; flag #t for onedir, #f for old style - (sdat-get-page-dir-style self)) - (dir (string-append (sdat-get-sroot self) - (if dir-style - (conc "/pages/") - (conc "/pages/" page)))) - (control (string-append dir (if dir-style - (conc page "_ctrl.scm") - "/control.scm"))) - (view (string-append dir (if dir-style - (conc page "_view.scm") - "/view.scm"))) - (load-view (and (file-exists? view) - (or (eq? parts 'both)(eq? parts 'view)))) - (load-control (and (file-exists? control) - (or (eq? parts 'both)(eq? parts 'control)))) - (view-dat '())) - ;; (session:log self "dir-style: " dir-style) - ;; (sugar "/home/matt/kiatoa/stml/sugar.scm" )) - ;; (print "dir=" dir " control=" control " view=" view " load-view=" load-view " load=control=" load-control) - (if load-control - (begin - (load control) - (session:set-called! self page))) - ;; move this to where it gets exectuted only once - ;; - ;;(s:log "s:b yields " (s:b "blah")) - (if load-view - ;; option one: - ;; - ;; (let ((inp (open-input-string - ;; (files-read->string "/home/matt/kiatoa/stml/sugar.scm" - ;; view)))) - ;; (map - ;; (lambda (x) - ;; (cond - ;; ((list? x) x) - ;; ((string? x) x) - ;; (else '()))) - ;; (port-map eval (lambda () - ;; (read inp))))) - ;; - ;; option two: - ;; - (let* (;; (inps (map open-input-file (list view))) ;; sugar view))) - (p (open-input-file view)) ;; (apply make-concatenated-port inps)) - (dat (process-port p))) - ;;(map - ;; (lambda (x) - ;; (cond - ;; ((list? x) x) - ;; ((string? x) x) - ;; (else '()))) - ;; (port-map eval (lambda ()(read p)))))) - ;; (map close-input-port inps) - (close-input-port p) - dat) - (list "

Page not found " page "

")))) - -;;(define (session:call self page) -;; (session:call-parts self page 'both)) + (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 "

Page not found " page "

")))) + ((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: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 "
")))