|
;;; Copyright (c) 2004, Bill Clementson. All rights reserved. See ;;; license.txt for the details of the license. (in-package #:cl-user) (defpackage :resume-html (:use :common-lisp :xmls :lml2 :xml-xform)) (in-package :resume-html) (defvar *xml-file* "resume.xml" "XML file to process") (defvar *output-file* "resume.html" "File to output") (defvar *output-detail-file* "resume-detail.html" "File to output") (defvar *print-detail* nil) (defvar *css* "p { } p.ssma, p.t, p.d { font-family: Arial; font-size: 11px } p.b, p.c, li { font-size: 12px } p.b { font-weight: bold } p.d { color: #666666 } p.section { font-family: Arial; font-size: 12px; color: #666666 }" "Style sheet for resume") (defun xform (&optional detail) (let ((root-xml nil) (resume-file (if detail *output-detail-file* *output-file*))) (setq *print-detail* (if detail t nil)) (with-open-file (p *xml-file*) (setq root-xml (parse p))) (with-open-file (s resume-file :direction :output :if-exists :supersede) (let ((*html-stream* s)) (process-node root-xml))))) (defmethod node-xform (node (name (eql 'resume))) (html (:html (:head (:title "Resumé") ((:style type "text/css") (:princ *css*))) ((:body bgcolor "#9BA882") (:br) ((:table width "90%" align "center" border "0" cellpadding "0" cellspacing "0") ((:tr bgcolor "white") ((:td width "5%")" ") ((:td width "75%") (:br) (:br) (:br) (process-child "person" node) (process-child "backgr" node) (process-child "work" node) (if *print-detail* (process-child "non-work" node)) (process-child "misc" node) (process-child "current" node) (:br) (:br) (:br)) ((:td width "10%") " "))) (:br) (:br))))) (defmethod node-xform (node (name (eql 'person))) (html ((:table border "0" width "100%" cellpadding "0" cellspacing "0") (:tr ((:td valign "bottom") ((:font size "+2" face "arial") (:br) (:br) (:b (process-child "name" node)))))) ((:hr width "100%" size "3" color "0" align "right")) (:br))) (defmethod node-xform (node (name (eql 'backgr))) (html ((:p class "b" align "justify") (process-all-children node)) (:br))) (defmethod node-xform (node (name (eql 'work))) (html ((:p class "section") (:princ " WORK EXPERIENCE") ((:hr width "100%" color "acacac" align "right")) (process-child "company" node)))) (defmethod node-xform (node (name (eql 'non-work))) (html ((:p class "section") (:princ " NON-WORK EXPERIENCE") ((:hr width "100%" color "acacac" align "right")) (:ul (process-all-children node)) (:br)))) (defmethod node-xform (node (name (eql 'company))) (html ((:table width "100%" border "0") (:tr ((:td width "20%" align "right" valign "top") ((:p class "b") (process-child "role" node))) ((:td width "2%") " ") ((:td width "80%" valign "top") ((:table width "100%" border "0") (:tr ((:td width "33%" valign "top") ((:p class "d") (process-child "date" node))) ((:td width "33%" valign "top" align "center") ((:p class "d") (process-child "name" node))) ((:td width "33%" valign "top" align "right") ((:p class "d") (process-child "www" node)))) (:tr ((:td colspan "3") ;;(:br) (if *print-detail* (html (:b "Summary:") (:br))) (process-child "summary" node) (if *print-detail* (html (:b "Detail:") (process-child "detail" node))) (:br))))))))) (defmethod node-xform (node (name (eql 'summary))) (html (process-child "comment" node))) (defmethod node-xform (node (name (eql 'detail))) (html (process-all-children node))) (defmethod node-xform (node (name (eql 'role))) (html (process-all-children node))) (defmethod node-xform (node (name (eql 'comment))) (html ((:p align "justify" class "c") (process-all-children node)))) (defmethod node-xform (node (name (eql 'computers))) (html ((:p align "justify" class "c") (:b "Computers: ") (process-all-children node)))) (defmethod node-xform (node (name (eql 'languages))) (html ((:p align "justify" class "c") (:b "Languages: ") (process-all-children node)))) (defmethod node-xform (node (name (eql 'utilities))) (html ((:p align "justify" class "c") (:b "Utilities: ") (process-all-children node)))) (defmethod node-xform (node (name (eql 'list))) (html (:ul (process-child "item" node)))) (defmethod node-xform (node (name (eql 'item))) (html (:li (process-all-children node)))) (defmethod node-xform (node (name (eql 'misc))) (html ((:p class "section") (:princ " SKILLS/EDUCATION/AFFILIATIONS") ((:hr width "100%" color "acacac" align "right")) (:ul (process-child "skills" node) (process-child "affiliations" node) (process-child "education" node))) (:br))) (defmethod node-xform (node (name (eql 'skills))) (process-child "skills-grp" node)) (defmethod node-xform (node (name (eql 'skills-grp))) (html (:li (process-all-children node)))) (defmethod node-xform (node (name (eql 'education))) (html (:li "Post-secondary Education:" (:ul (process-child "institution" node)))) (if *print-detail* (process-child "awards" node))) (defmethod node-xform (node (name (eql 'affiliations))) (process-all-children node)) (defmethod node-xform (node (name (eql 'institution))) (process-child "pos" node)) (defmethod node-xform (node (name (eql 'pos))) (html (:li (process-all-children node)))) (defmethod node-xform (node (name (eql 'awards))) (html (:li "Academic Awards:" (:ul (process-child "item" node))))) (defmethod node-xform (node (name (eql 'current))) (html ((:table width "100%") (:tr ((:td align "center") ((:font face "arial" size "-2" color "666666") (process-child "addr" node) (:br) (:princ "Phone: ") (process-child "phone" node) (:br) (:princ "Email: ") (process-child "mail" node) (:br) (:princ "WWW:") (process-child "www" node))))))) (defmethod node-xform (node (name (eql 'mail))) (let ((node (list "a" (list (list "href" (concatenate 'string "mailto:" (third node)))) (third node)))) (process-node node))) (defmethod node-xform (node (name (eql 'www))) (let* ((description (if (and (> (length (third node)) 7) (equal "http://" (subseq (third node) 0 7))) (subseq (third node) 7) (third node))) (node (list "a" (list (list "href" (third node))) description))) (process-node node))) (defmethod node-xform (node (name (eql 'a))) (let ((href (node-attr-value "href" node))) (html (:princ " <a href=\"") (:princ href) (:princ "\">") (:princ (third node)) (:princ "</a> ")))) (defmethod node-xform (node name) (let ((node-value (car (node-children node)))) (if (and node-value (atom node-value)) (html (:princ node-value)) (html (:princ (format t "***Node not handled: ~A***~%" name)))))) (defmethod process-node-value (node) (html (:princ node))) |