Differences From Artifact [8375211898]:

To Artifact [705f97d8d5]:


16
17
18
19
20
21
22








23
24
25
26
27
28
29
;; * Pics            [pic X Y[picname.jpg]]
;; * Move twiki parsing/expanding to mattsutils as loadable module

;; Routines intended to be overridden by end users
;;  (twiki:access keys wiki-name user-id)
;; search the code for "override" for more.









;; This is the currently supported mechanism. Postgres will be added later -mrw- 7/26/2009
;;
(define (twiki:open-db key . create-not-ok)
  ;; (s:log "Got to twiki:open-db with key: " key)
  (let* ((create-ok (if (null? create-not-ok) #t (car create-not-ok)))
	 (fdat      (twiki:key->fname key))
	 (basepath  (slot-ref s:session 'twikidir))







>
>
>
>
>
>
>
>







16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;; * Pics            [pic X Y[picname.jpg]]
;; * Move twiki parsing/expanding to mattsutils as loadable module

;; Routines intended to be overridden by end users
;;  (twiki:access keys wiki-name user-id)
;; search the code for "override" for more.

;; twiki css
;; =========
;; Block                tag
;; -----                ---
;; twiki                twiki
;; twiki body div       twiki-node
;; twiki main menu      twiki-main-menu

;; This is the currently supported mechanism. Postgres will be added later -mrw- 7/26/2009
;;
(define (twiki:open-db key . create-not-ok)
  ;; (s:log "Got to twiki:open-db with key: " key)
  (let* ((create-ok (if (null? create-not-ok) #t (car create-not-ok)))
	 (fdat      (twiki:key->fname key))
	 (basepath  (slot-ref s:session 'twikidir))
207
208
209
210
211
212
213

214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238

239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
;; (define-inline (twiki:tiddler-set-owner_id!    vec val)(vector-set! vec 5 val))

;;======================================================================
;; Routines for displaying, editing, browsing etc. tiddlers
;;======================================================================	

;; should change this to take a tiddler structure?

(define (twiki:view dat  tkey wid tiddler wiki) ;; close, close others, edit, more
  (let ((is-not-main  (not (equal? "MainMenu" (twiki:tiddler-get-name tiddler))))
	(edit-allowed (member 'w (twiki:wiki-get-perms wiki))))
    (s:div 'class "node" ;; "node"
	   ;; (s:hr  " ")
	   ;; (s:p 'class (if is-not-main "float-left" "float-left-menu")
	;;    (s:p 'class (if is-not-main "float-left" "float-right")
	;; 	(if is-not-main
	;; 	    (s:big (s:b (twiki:tiddler-get-name tiddler)))
	;; 	    (s:small ;; (s:b "Menu")
	;; 		     (if edit-allowed
	;; 			 (list "("
	;; 			       (s:a "edit" 'href
	;; 				    (s:link-to (twiki:get-link-back-to-current)
	;; 					       'edit_tiddler (twiki:tiddler-get-id tiddler))) ")")
	;; 			 '()))))
	   (s:div 'class "tiddler"
	    (s:p 'class "tiddlercommands"
		    (if (equal? "MainMenu" (twiki:tiddler-get-name tiddler))
			(if edit-allowed
			    (list (s:a "edit" 'href
				       (s:link-to (twiki:get-link-back-to-current)
						  'edit_tiddler (twiki:tiddler-get-id tiddler))))
			    '())
			(list 

			 (s:a "close" 'href (s:link-to (twiki:get-link-back-to-current) 'close_tiddler (twiki:tiddler-get-id tiddler))) "."
			 (s:a "close others" 'href (s:link-to (twiki:get-link-back-to-current) 'close_other_tiddlers (twiki:tiddler-get-id tiddler))) "."
			 (if edit-allowed
			     (s:a "edit"  'href (s:link-to (twiki:get-link-back-to-current) 'edit_tiddler (twiki:tiddler-get-id tiddler)))
			     '()))))
	    ;; (s:p 'class "tiddler-skip-par" "-")
	    ;; (s:p ".")
	    ;; (s:p  (twiki:dat->html dat wiki) (s:br))))))
	    (s:p (twiki:dat->html dat wiki))))))
;; 	     (let ((twhtml (twiki:dat->html dat wiki))) ;; let's try to force a minimum of one paragraph
;; 	      (if (< (length twhtml) 2)
;; 		  (s:p twhtml (s:br))
;; 		  twhtml))))))

(define (twiki:view-tiddler db  tkey wid tiddler wiki)
  (let* ((dat-id (twiki:tiddler-get-dat-id tiddler))
	 (dat    (twiki:get-dat db dat-id))
	 (tnum   (twiki:tiddler-get-id tiddler)))
    ;; (s:log "twid: " dat-id " dat: " dat)
    (twiki:view dat  tkey wid tiddler wiki)))







>



|
<
<
<
<
<
<
<
<
<
<
<
<
|
<
|
|
|
|
|
|
<
>
|
|
|
|
|
<
<
<
|
<
<
<
<







215
216
217
218
219
220
221
222
223
224
225
226












227

228
229
230
231
232
233

234
235
236
237
238
239



240




241
242
243
244
245
246
247
;; (define-inline (twiki:tiddler-set-owner_id!    vec val)(vector-set! vec 5 val))

;;======================================================================
;; Routines for displaying, editing, browsing etc. tiddlers
;;======================================================================	

;; should change this to take a tiddler structure?
;; This is the display of a single tiddler
(define (twiki:view dat  tkey wid tiddler wiki) ;; close, close others, edit, more
  (let ((is-not-main  (not (equal? "MainMenu" (twiki:tiddler-get-name tiddler))))
	(edit-allowed (member 'w (twiki:wiki-get-perms wiki))))
    (s:div 'class "tiddler"












	   (s:div 'class "tiddler-menu"

		  (if (equal? "MainMenu" (twiki:tiddler-get-name tiddler))
		      (if edit-allowed
			  (list (s:a "edit" 'href
				     (s:link-to (twiki:get-link-back-to-current)
						'edit_tiddler (twiki:tiddler-get-id tiddler))))
			  '())

		      (s:div 'class "tiddler-menu-internal"
		       (s:a "close" 'href (s:link-to (twiki:get-link-back-to-current) 'close_tiddler (twiki:tiddler-get-id tiddler))) "."
		       (s:a "close others" 'href (s:link-to (twiki:get-link-back-to-current) 'close_other_tiddlers (twiki:tiddler-get-id tiddler))) "."
		       (if edit-allowed
			   (s:a "edit"  'href (s:link-to (twiki:get-link-back-to-current) 'edit_tiddler (twiki:tiddler-get-id tiddler)))
			   '()))))



	    (s:p (twiki:dat->html dat wiki)))))





(define (twiki:view-tiddler db  tkey wid tiddler wiki)
  (let* ((dat-id (twiki:tiddler-get-dat-id tiddler))
	 (dat    (twiki:get-dat db dat-id))
	 (tnum   (twiki:tiddler-get-id tiddler)))
    ;; (s:log "twid: " dat-id " dat: " dat)
    (twiki:view dat  tkey wid tiddler wiki)))
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
		  (else (vector-ref res 0)))
		#f)))
      #f))

(define (twiki:maint_area tdb wid tkey wiki)
  (let ((maint (s:get-param 'twiki_maint))
	(write-perm (member 'w (twiki:wiki-get-perms wiki))))
    (s:div ;; 'class "node" 
     (if write-perm
	 (list (s:a "Orphans"  'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 1))(s:br)
	       (s:a "Pics"     'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 2))(s:br)
	       (s:a "Help"     'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 4))(s:br))
	 '())
     (s:a "Search"   'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 3))(s:br)
     (case maint







|







379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
		  (else (vector-ref res 0)))
		#f)))
      #f))

(define (twiki:maint_area tdb wid tkey wiki)
  (let ((maint (s:get-param 'twiki_maint))
	(write-perm (member 'w (twiki:wiki-get-perms wiki))))
    (s:div 'class "twiki-menu-internal"
     (if write-perm
	 (list (s:a "Orphans"  'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 1))(s:br)
	       (s:a "Pics"     'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 2))(s:br)
	       (s:a "Help"     'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 4))(s:br))
	 '())
     (s:a "Search"   'href (s:link-to (twiki:get-link-back-to-current) 'twiki_maint 3))(s:br)
     (case maint
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
    (if (null? lmenu)
	(begin
	  (twiki:save-tiddler tdb "MainMenu" "" "" wid (twiki:get-id))
	  (set! lmenu (twiki:get-tiddlers tdb wid (list "MainMenu")))))
    
    ;; get the tiddlers from the db now
    (set! result
	  (s:table
	   ;; ;; A header row MainMenu   WikiName    Other
	   ;; (s:tr
	   ;;  (s:td
	   ;;   (let ((main-menu-tnum  (twiki:tiddler-name->id tdb "MainMenu")))
	   ;;     (if edit-tmenu-id
	   ;;         "MainMenu"
	   ;;         (s:a "MainMenu" 'href (s:link-to (twiki:get-link-back-to-current) 'edit_tmenu main-menu-tnum)))))
	   ;;  (s:td (twiki:key->fname tkey))    
	   ;;  (s:td ""))
	   (s:tr
	    ;; The menu column (must do all this with css some time)
	    ;; July 5, 2010, attempting to switch to a top menu
	    ;; (s:td 'class "col1-tiddler" (twiki:view-tiddler tdb  tkey wid (car lmenu) wikidat))
	    (s:td 'class "col2-tiddler" (twiki:view-tiddler tdb  tkey wid (car lmenu) wikidat) 'colspan "2"))
	   (s:tr
	    (s:td 'class "col2-tiddler" 
		  ;; this is probably not needed as there is no reason to create tiddlers this way
		  ;; (if (eq? tnumedit -1)(twiki:edit-tiddler tdb tkey wid tnumedit) '())
		  ;; insert the picture editor window if enabled
		  (if (equal? (s:get-param "twiki_maint") "2")(twiki:pic_mgmt tdb wid tkey) '())
		  (if (equal? (s:get-param "twiki_maint") "4")(twiki:help 1) '())
		  (if (not (null? tdlrs))
		      (map (lambda (tdlr)
			     (let ((tnum  (twiki:tiddler-get-id tdlr)))
			       (s:log "tnum: " tnum " tnumedit: " tnumedit)
			       (if (and tnumedit (not tedited) (equal? tnumedit tnum))
				   (begin
				     (set! tedited #t) ;; only allow editing one tiddler at a time
				     (twiki:edit-tiddler tdb tkey wid tnum))
				   (twiki:view-tiddler tdb  tkey wid tdlr wikidat))))
			   tdlrs)
		      '()))
	    (s:td  'valign "top" 'class "tiddler-top" (twiki:maint_area tdb wid tkey wikidat)))))
    (dbi:close tdb)
    result))

;; should do a single more efficient query but this is good enough
(define (twiki:get-tiddlers db wid tnames)
  (apply twiki:get-tiddlers-by-name db wid tnames))
;;   (let* ((tdlrs '())







|
<
|
<
|
<
<
<
<
<
<
<
<
|
<
<
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<







668
669
670
671
672
673
674
675

676

677








678



679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694

695
696
697
698
699
700
701
    (if (null? lmenu)
	(begin
	  (twiki:save-tiddler tdb "MainMenu" "" "" wid (twiki:get-id))
	  (set! lmenu (twiki:get-tiddlers tdb wid (list "MainMenu")))))
    
    ;; get the tiddlers from the db now
    (set! result
	  (s:div 'class "twiki"

	   ;; float to the right the control menu

	   (s:div 'class "twiki-main-menu" (twiki:maint_area tdb wid tkey wikidat))








	   (twiki:view-tiddler tdb  tkey wid (car lmenu) wikidat)



	   ;; this is probably not needed as there is no reason to create tiddlers this way
	   ;; (if (eq? tnumedit -1)(twiki:edit-tiddler tdb tkey wid tnumedit) '())
	   ;; insert the picture editor window if enabled
	   (if (equal? (s:get-param "twiki_maint") "2")(twiki:pic_mgmt tdb wid tkey) '())
	   (if (equal? (s:get-param "twiki_maint") "4")(twiki:help 1) '())
	   (if (not (null? tdlrs))
	       (map (lambda (tdlr)
		      (let ((tnum  (twiki:tiddler-get-id tdlr)))
			(s:log "tnum: " tnum " tnumedit: " tnumedit)
			(if (and tnumedit (not tedited) (equal? tnumedit tnum))
			    (begin
			      (set! tedited #t) ;; only allow editing one tiddler at a time
			      (twiki:edit-tiddler tdb tkey wid tnum))
			    (twiki:view-tiddler tdb  tkey wid tdlr wikidat))))
		    tdlrs)
	       '())))

    (dbi:close tdb)
    result))

;; should do a single more efficient query but this is good enough
(define (twiki:get-tiddlers db wid tnames)
  (apply twiki:get-tiddlers-by-name db wid tnames))
;;   (let* ((tdlrs '())