anchor.diff:  (in-package #:plaster)
   
   (defparameter *pastes-per-page* 25)
  +(defparameter *default-api-amount* 50)
  +(defparameter *maximum-api-amount* 100)
   (defparameter *password-salt* "Something ˢᵉᶜʳᵉᵗ")
   
   (define-trigger db:connected ()
  
positive.code:                                 (dm:id paste)))
                :fragment (princ-to-string (dm:id paste)))))
  
  (defun api-paste-output (paste)
    (cond ((string= "true" (post/get "browser"))
           (redirect (paste-url paste)))
          (T
           (api-output (loop for field in (dm:fields paste)
                             collect (cons field (dm:field paste field)))))))
  
  (defun call-with-password-protection (function paste &optional (password (post/get "password")))
    (cond ((or (not (eql 3 (dm:field paste "visibility")))
  
negative.code:                         :amount *pastes-per-page*)))
      (r-clip:process T :pastes pastes)))
  
  (define-api plaster/view (id &optional current-password include-annotations) ()
    (let ((paste (ensure-paste id)))
      (check-permission 'view paste)
      (with-password-protection (paste current-password)
        (api-output (reformat-paste paste :include-annotations (or* include-annotations))))))
  
  (define-api plaster/list (&optional author skip amount include-annotations) ()
    (check-permission 'list)
    (let ((amount (if amount (parse-integer amount) *default-api-amount*))
          (skip (if skip (parse-integer skip) 0)))
      (unless (<= 0 amount *maximum-api-amount*)
        (error 'api-argument-invalid :argument "amount"
                                     :message (format NIL "Amount must be within [0,~a]" amount)))
      (let ((query (cond ((and (auth:current) (equalp author (user:username (auth:current))))
                          (db:query (:= 'author author)))
                         (author
                          (db:query (:and (:= 'visibility 1)
                                          (:= 'author author))))
                         (T
                          (db:query (:= 'visibility 1))))))
        (api-output
         (loop for paste in (dm:get 'plaster-pastes query
                                    :sort '((time :DESC))
                                    :amount amount
                                    :skip skip)
               collect (reformat-paste paste :include-annotations include-annotations))))))
  
  (define-api plaster/new (text &optional title parent visibility password current-password) ()
    (check-permission 'new)
  