Changeset 3374

Show
Ignore:
Timestamp:
06/29/08 16:21:30 (6 months ago)
Author:
hans
Message:

implement m2-pdf

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/projects/bos/m2/bos.m2.asd

    r3166 r3374  
    2121                                        "geo-utm" 
    2222                                        "geometry")) 
     23               (:file "m2-pdf" :depends-on ("m2")) 
    2324               (:file "contract-expiry" :depends-on ("m2")) 
    2425               (:file "allocation" :depends-on ("m2")) 
  • trunk/projects/bos/m2/cert-daemon.lisp

    r2967 r3374  
    1212             (format nil "\"~A~{ ~A~}\"" program program-args) (process-exit-code process) error-message)))) 
    1313 
    14 (defun fill-form (fdf-pathname pdf-pathname output-pathname) 
     14(defun fill-form (fdf-pathname pdf-pathname m2-pdf-pathname output-pathname) 
    1515  (handler-case 
    16       (progn 
     16      (with-temporary-file (temporary-pdf-pathname :defaults #P"/tmp/.pdf") 
    1717        (cond 
    1818          ((namestring pdf-pathname) 
    1919           (run-tool "pdftk" (list (namestring pdf-pathname) 
    2020                                   "fill_form" (namestring fdf-pathname) 
    21                                    "output" (namestring output-pathname) 
     21                                   "output" (namestring temporary-pdf-pathname) 
    2222                                   "flatten")) 
     23           (run-tool "pdftk" (list (namestring m2-pdf-pathname) 
     24                                   "background" (namestring temporary-pdf-pathname) 
     25                                   "output" (namestring output-pathname))) 
    2326           (format t "; generated ~A~%" output-pathname)) 
    2427          (t 
     
    3336                                :key #'pathname-type)) 
    3437    (handler-case 
    35         (destructuring-bind (id &optional (country "en")) (split "-" (pathname-name fdf-pathname)) 
    36           (let ((language-specific-template-pathname (merge-pathnames (make-pathname :name (format nil "~A-~A" (pathname-name template-pathname) country)) 
    37                                                                       template-pathname)) 
     38        (destructuring-bind (id &optional (country "en")) 
     39            (split "-" (pathname-name fdf-pathname)) 
     40          (let ((language-specific-template-pathname (merge-pathnames 
     41                                                      (make-pathname :name (format nil "~A-~A" (pathname-name template-pathname) 
     42                                                                                   country)) 
     43                                                      template-pathname)) 
     44                (m2-pdf-pathname (merge-pathnames 
     45                                  (make-pathname :name (format nil "~A-m2s" id)) 
     46                                  fdf-pathname)) 
    3847                (output-pathname (merge-pathnames (make-pathname :name id :type "pdf") fdf-pathname))) 
    39             (fill-form fdf-pathname (if (probe-file language-specific-template-pathname) 
     48            (fill-form fdf-pathname 
     49                       (if (probe-file language-specific-template-pathname) 
    4050                                        language-specific-template-pathname 
    4151                                        template-pathname) 
     52                       m2-pdf-pathname 
    4253                       output-pathname))) 
    4354      (error (e) 
  • trunk/projects/bos/m2/m2-pdf.lisp

    r2644 r3374  
    99        (incf y 10)))) 
    1010 
    11 (defun contract-pdf (contract pdf-pathname
     11(defun make-m2-pdf (contract &key print
    1212  (pdf:with-document () 
    1313    (pdf:with-page () 
     
    2323                 (scale (/ 80 (max bb-width bb-height)))) 
    2424 
    25             (draw-coordinate 100 160 (m2-lon-lat first-m2)) 
     25            (draw-coordinate 110 160 (m2-lon-lat first-m2)) 
    2626 
    27             (draw-coordinate 180 40 (m2-lon-lat last-m2)) 
     27            (unless (eq first-m2 last-m2) 
     28              (draw-coordinate 190 40 (m2-lon-lat last-m2))) 
    2829 
    2930            (pdf:translate (+ 65.0 (if (>= bb-width bb-height) 0 
     
    5657                (pdf:line-to (1+ x) y) 
    5758                (pdf:line-to x y) 
    58                 (pdf:fill-and-stroke))))))) 
     59                (pdf:close-fill-and-stroke))))))) 
    5960 
    60     (with-open-file (f pdf-pathname :direction :output :if-exists :supersede) 
     61    (with-open-file (f (contract-m2-pdf-pathname contract :print print) :direction :output :if-exists :supersede) 
    6162      ;; cl-pdf does not really handle non-ascii characters in a very 
    6263      ;; usable manner.  In order to avoid having to deal with 
     
    6869             f)) 
    6970    t)) 
     71 
    7072#+(or) 
    71 (contract-pdf (random-elt (class-instances 'contract)) "/tmp/out.pdf"
     73(make-m2-pdf (random-elt (class-instances 'contract))
  • trunk/projects/bos/m2/m2.lisp

    r3161 r3374  
    310310                                  :type "fdf") 
    311311                   (if print *cert-mail-directory* *cert-download-directory*))) 
     312 
     313(defmethod contract-m2-pdf-pathname ((contract contract) &key print) 
     314  (merge-pathnames (make-pathname :name (format nil "~D-m2s" (store-object-id contract)) 
     315                                  :type "pdf") 
     316                   (if print bos.m2::*cert-mail-directory* bos.m2::*cert-download-directory*))) 
    312317 
    313318(defmethod contract-pdf-pathname ((contract contract) &key print) 
  • trunk/projects/bos/m2/make-certificate.lisp

    r2499 r3374  
    3434Download der Urkunde" 
    3535  (let ((sponsor (contract-sponsor contract))) 
     36    (make-m2-pdf contract :print print) 
    3637    (make-fdf-file (contract-fdf-pathname contract 
    3738                                          :language language 
     
    4243                   :sponsor-id (sponsor-id sponsor) 
    4344                   :master-code (sponsor-master-code sponsor) 
    44                    :sqm-count (length (contract-m2s contract)) 
    45                    ;; :sqm-ids (with-output-to-string (s) 
    46                    ;;                         (loop for group in (group-by (mapcar #'m2-num-string (contract-m2s contract)) *num-coords-per-line*) 
    47                    ;;                            do (loop for nums on group 
    48                    ;;                                  do (princ (car nums) s) 
    49                    ;;                                  do (princ (if (cdr nums) #\Tab #\Newline) s)))) 
    50                    ;; should later be called :sqm-coordinates 
    51                    :sqm-ids 
    52                    (flet ((format-point (stream x y) 
    53                             (apply #'geometry:format-lon-lat stream 
    54                                    (geo-utm:utm-x-y-to-lon-lat (+ +nw-utm-x+ x) 
    55                                                                (- +nw-utm-y+ y) +utm-zone+ t)))) 
    56                      (destructuring-bind (left top width height) 
    57                          (contract-bounding-box contract) 
    58                        (with-output-to-string (out) 
    59                          (format-point out left top) (terpri out)                         
    60                          (format-point out (+ left width) (+ top height)) (terpri out))))))) 
     45                   :sqm-count (length (contract-m2s contract))))) 
  • trunk/projects/bos/web/startup.lisp

    r3358 r3374  
    1212 
    1313(defvar *port*) 
    14 (defvar *listeners*) 
    1514(defvar *website-directory*) 
    1615(defvar *website-url*) 
  • trunk/projects/bos/web/webserver.lisp

    r3294 r3374  
    185185  (push (hunchentoot:create-folder-dispatcher-and-handler prefix destination) hunchentoot:*dispatch-table*)) 
    186186 
    187 (defun publish-website (&key website-directory website-url (worldpay-test-mode t) (vhosts :wild)
     187(defun publish-website (&key website-directory website-url (worldpay-test-mode t)
    188188  (setf *website-directory* website-directory) 
    189189 
     
    265265                 :site-logo-url "/images/bos-logo.gif" 
    266266                 :style-sheet-urls '("/static/cms.css") 
    267                  :javascript-urls '("/static/cms.js" "/static/tiny_mce/tiny_mce.js") 
    268                  :vhosts vhosts) 
     267                 :javascript-urls '("/static/cms.js" "/static/tiny_mce/tiny_mce.js")) 
    269268 
    270269  (publish-directory :prefix "/static/"