Use the public field of notes to show or hide them from being listed.
This commit is contained in:
parent
14e0267b50
commit
c0ebd3876f
|
@ -12,7 +12,7 @@
|
|||
note-name note-title note-author note-date note-content note-licence note-public?
|
||||
; Operations
|
||||
new-note update-note remove-note
|
||||
get-note-by-name get-all-notes
|
||||
get-note-by-name get-all-notes get-public-notes
|
||||
format-note
|
||||
; Init repo
|
||||
note-init-repository
|
||||
|
@ -113,6 +113,10 @@
|
|||
(define (get-all-notes)
|
||||
(list-instances notepadnote))
|
||||
|
||||
; Get all public notes
|
||||
(define (get-public-notes)
|
||||
(find-instances notepadnote '((public . #t))))
|
||||
|
||||
; Format a note
|
||||
(define (format-note nt)
|
||||
; Recursive parsing function
|
||||
|
|
|
@ -104,13 +104,15 @@
|
|||
(define connected-usr (get-user param))
|
||||
(define secured? (check-secured? param))
|
||||
(define can-edit? (and connected-usr secured?))
|
||||
(define notes (get-all-notes))
|
||||
(define notes (if can-edit? (get-all-notes) (get-public-notes)))
|
||||
`(article
|
||||
,@(if (null? notes)
|
||||
'("Pas de notes.")
|
||||
(map
|
||||
(lambda (n)
|
||||
`(div (a ((href ,(note-link 'show (note-name n)))) ,(note-title n))))
|
||||
`(div (a ((href ,(note-link 'show (note-name n))))
|
||||
,(if (note-public? n) "" "🔒︎ ")
|
||||
,(note-title n))))
|
||||
notes))
|
||||
,@(if can-edit?
|
||||
'((hr)
|
||||
|
@ -169,6 +171,7 @@
|
|||
(define title (or (and note (note-title note)) ""))
|
||||
(define content (or (and note (note-content note)) ""))
|
||||
(define page-name (or page "SansNom"))
|
||||
(define public? (and note (note-public? note)))
|
||||
( (pages:template
|
||||
#:title (string-append "Édition de la note '" page-name "'")
|
||||
#:author (user-name connected-usr)
|
||||
|
@ -184,6 +187,9 @@
|
|||
(input ((id "pagename")(name "pagename")(type "text")(value ,page-name))) (br)
|
||||
(label ((for "pagetitle")) "Titre de la note") (br)
|
||||
(input ((id "pagetitle")(name "pagetitle")(type "text")(value ,title))) (br)
|
||||
(input ((id "pagepublic")(name "pagepublic")(type "checkbox")(value "on")
|
||||
,@(if public? '((checked "true")) '())))
|
||||
(label ((for "pagepublic")) "Note publique") (br)
|
||||
(label ((for "pagecontent")) "Contenu de la note") (br)
|
||||
(textarea ((rows "10")(cols "80")(id "pagecontent")(name "pagecontent"))
|
||||
,content) (br)
|
||||
|
@ -200,6 +206,7 @@
|
|||
(define new-note-content (weblet-parameter-ref param 'pagecontent #f))
|
||||
(define new-note-name (or (and (not (equal? "" page-name)) page-name)
|
||||
page))
|
||||
(define new-note-public? (equal? "on" (weblet-parameter-ref param 'pagepublic #f)))
|
||||
; Check validity
|
||||
(cond
|
||||
( (and new-note-name (not (equal? new-note-name "")))
|
||||
|
@ -208,7 +215,8 @@
|
|||
#:name new-note-name
|
||||
#:title new-note-title
|
||||
#:content new-note-content
|
||||
#:author connected-usr)
|
||||
#:author connected-usr
|
||||
#:public? new-note-public?)
|
||||
; Redirect
|
||||
(redirect-to
|
||||
(note-link (if continue? 'edit 'show) new-note-name)
|
||||
|
|
Loading…
Reference in New Issue