Index: modules/twiki/twiki-mod.scm ================================================================== --- modules/twiki/twiki-mod.scm +++ modules/twiki/twiki-mod.scm @@ -6,11 +6,11 @@ ;; This program is distributed WITHOUT ANY WARRANTY; without even the ;; implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ;; PURPOSE. ;; twiki module -(require-extension sqlite3 regex posix md5 base64) +(require-extension sqlite3 regex posix md5 message-digest base64) (import (prefix base64 base64:)) ;; TODO ;; ;; * Inline tiddlers [inline[TiddlerName]] @@ -36,22 +36,27 @@ (let* ((create-ok (if (null? create-not-ok) #t (car create-not-ok))) (fdat (twiki:key->fname key)) (basepath (sdat-get-twikidir s:session)) (fpath (car fdat)) (fname (cadr fdat)) - (fullname (conc basepath "/" fpath "/" fname)) + (fulldir (conc basepath "/" fpath)) + (fullname (let ((fn (conc fulldir "/" fname))) + (if (sdat-get-debugmode s:session)(s:log "\ntwikipath: " fn)) + fn)) (fexists (file-exists? fullname)) (db (if fexists (dbi:open 'sqlite3 (list (cons 'dbname fullname))) #f))) (if (and (not db) (not create-ok)) (exit 100) (begin (if (not fexists) (begin ;; (print "fullname: " fullname) + (if (sdat-get-debugmode s:session) + (s:log "\ncreating fulldir: " fulldir)) (twiki:register-wiki key fullname) - (system (conc "mkdir -p " fpath)) ;; create the path + (system (conc "mkdir -p " fulldir)) ;; create the path (if (file-exists? fpath) (s:log "OK: dir " fpath " has been made") (s:log "ERROR: Failed to make the path for the twiki")) (set! db (dbi:open 'sqlite3 (list (cons 'dbname fullname)))) (for-each @@ -99,11 +104,11 @@ (keypath (twiki:web64enc key)) (delta (quotient (string-length keypath) 3)) ;; (p1 (substring keypath 0 delta)) ;; 0 8)) (p2 (substring keypath delta (* delta 2)));; 8 16)) (p3 (substring keypath (* delta 2) (* delta 3)))) ;; 16 24)) - (list (string-intersperse (list "twikis" p1 p2 p3) "/") keypath))) + (list (string-intersperse (list "dbs" p1 p2 p3) "/") keypath))) ;; look up the wid based on the keys, this is used for sub wikis only. I.e. a wiki instantiated inside another wiki ;; giving a separate namespace to all the tiddlers (define (twiki:name->wid db name) (let ((wid (dbi:get-one db "SELECT id FROM wikis WHERE name=?;" name))) @@ -177,14 +182,17 @@ ;;====================================================================== ;; these can be overridden by end user (just create a new routine by the same name) (define (twiki:open-registry) - (let* ((basepath (sdat-get-sroot s:session)) - (regfile (conc basepath "/twikis/registry.db")) + (let* ((basepath (sdat-get-twikidir s:session)) + (regfile (conc basepath "/registry.db")) (regexists (file-exists? regfile)) - (db (dbi:open 'sqlite3 (list (cons 'dbname regfile))))) + (db #f)) + (if (sdat-get-debugmode s:session) + (s:log "regfile: " regfile " regexists: " regexists " db: " db)) + (set! db (dbi:open 'sqlite3 (list (cons 'dbname regfile)))) (if regexists db (begin (for-each (lambda (stmt)(dbi:exec db stmt)) (list "CREATE TABLE wikis (key TEXT PRIMARY KEY,path TEXT,creation_date INTEGER,creator_id INTEGER);")) @@ -353,11 +361,11 @@ #t) ;; success #f)) ;; non-success ;; text=0, jpg=1, png=2 (define (twiki:save-dat db dat type) - (let* ((md5sum (md5-digest dat)) + (let* ((md5sum (message-digest-string (md5-primitive) dat)) ;; (md5-digest dat)) (datid (twiki:dat-exists? db md5sum type)) (datblob (if (string? dat) (string->blob dat) dat))) (if datid Index: session.scm ================================================================== --- session.scm +++ session.scm @@ -164,17 +164,19 @@ (logfile (s:find-param 'logfile configdat)) (dbtype (s:find-param 'dbtype configdat)) (dbinit (s:find-param 'dbinit configdat)) (domain (s:find-param 'domain configdat)) (twikidir (s:find-param 'twikidir configdat)) - (page-dir (s:find-param 'page-dir-style configdat))) + (page-dir (s:find-param 'page-dir-style configdat)) + (debugmode (s:find-param 'debugmode configdat))) (if sroot (sdat-set-sroot! self sroot)) (if logfile (sdat-set-logfile! self logfile)) (if dbtype (sdat-set-dbtype! self dbtype)) (if dbinit (sdat-set-dbinit! self dbinit)) (if domain (sdat-set-domain! self domain)) (if twikidir (sdat-set-twikidir! self twikidir)) + (if debugmode (sdat-set-debugmode! self debugmode)) (sdat-set-page-dir-style! self page-dir) ;; (print "configdat: ")(pp configdat) ;;(session:log self "sroot: " sroot " logfile: " logfile " dbtype: " dbtype ;; " dbinit: " dbinit " domain: " domain " page-dir-style: " page-dir) )