Skip to content

Commit

Permalink
Added tests for versioning, gzipping, bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
simplyjt committed May 4, 2009
1 parent c615f04 commit d076276
Show file tree
Hide file tree
Showing 12 changed files with 319 additions and 106 deletions.
2 changes: 1 addition & 1 deletion examples/weblocks-demo/data/snapshot.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<HASH-TABLE ID="1" TEST="CL:EQ" SIZE="16"><ENTRY><KEY><SYMBOL>WEBLOCKS-DEMO::COMPANY</SYMBOL></KEY><VALUE><OBJECT ID="2" CLASS="WEBLOCKS-PREVALENCE::PERSISTENT-OBJECTS-OF-CLASS"><SLOT NAME="WEBLOCKS-PREVALENCE::OBJECTS-BY-ID"><HASH-TABLE ID="3" TEST="CL:EQL" SIZE="16"><ENTRY><KEY><INT>0</INT></KEY><VALUE><OBJECT ID="4" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>0</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Bar</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Entertainment</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><NULL/></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>1</INT></KEY><VALUE><OBJECT ID="5" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>1</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Church</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Spiritual</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><TRUE/></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>2</INT></KEY><VALUE><OBJECT ID="6" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>2</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Nuclear Plant</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Energy</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><NULL/></SLOT></OBJECT></VALUE></ENTRY></HASH-TABLE></SLOT><SLOT NAME="WEBLOCKS-PREVALENCE::NEXT-ID"><INT>2</INT></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><SYMBOL>WEBLOCKS-DEMO::EMPLOYEE</SYMBOL></KEY><VALUE><OBJECT ID="7" CLASS="WEBLOCKS-PREVALENCE::PERSISTENT-OBJECTS-OF-CLASS"><SLOT NAME="WEBLOCKS-PREVALENCE::OBJECTS-BY-ID"><HASH-TABLE ID="8" TEST="CL:EQL" SIZE="16"><ENTRY><KEY><INT>0</INT></KEY><VALUE><OBJECT ID="9" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>0</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Homer</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Simpson</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>50</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="10" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>12 Rose Ln.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><REF ID="6"/></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:FULL-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>1</INT></KEY><VALUE><OBJECT ID="11" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>1</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Moe</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Szyslak</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>55</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="12" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>14 Iris Ave.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><REF ID="4"/></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:FULL-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>2</INT></KEY><VALUE><OBJECT ID="13" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>2</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Ned</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Flanders</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>45</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="14" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>13 Violet St.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><REF ID="5"/></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:PART-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY></HASH-TABLE></SLOT><SLOT NAME="WEBLOCKS-PREVALENCE::NEXT-ID"><INT>2</INT></SLOT></OBJECT></VALUE></ENTRY></HASH-TABLE>
<HASH-TABLE ID="1" TEST="CL:EQ" SIZE="16"><ENTRY><KEY><SYMBOL>WEBLOCKS-DEMO::EMPLOYEE</SYMBOL></KEY><VALUE><OBJECT ID="2" CLASS="WEBLOCKS-PREVALENCE::PERSISTENT-OBJECTS-OF-CLASS"><SLOT NAME="WEBLOCKS-PREVALENCE::OBJECTS-BY-ID"><HASH-TABLE ID="3" TEST="CL:EQL" SIZE="16"><ENTRY><KEY><INT>2</INT></KEY><VALUE><OBJECT ID="4" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>2</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Ned</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Flanders</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>45</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="5" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>13 Violet St.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><OBJECT ID="6" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>1</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Church</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Spiritual</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><TRUE/></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:PART-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>1</INT></KEY><VALUE><OBJECT ID="7" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>1</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Moe</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Szyslak</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>55</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="8" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>14 Iris Ave.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><OBJECT ID="9" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>0</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Bar</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Entertainment</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><NULL/></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:FULL-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><INT>0</INT></KEY><VALUE><OBJECT ID="10" CLASS="WEBLOCKS-DEMO::EMPLOYEE"><SLOT NAME="WEBLOCKS::ID"><INT>0</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::FIRST-NAME"><STRING>Homer</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::LAST-NAME"><STRING>Simpson</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::AGE"><INT>50</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::ADDRESS"><OBJECT ID="11" CLASS="WEBLOCKS-DEMO::ADDRESS"><SLOT NAME="WEBLOCKS-DEMO::STREET"><STRING>12 Rose Ln.</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::CITY"><STRING>Springfield</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::STATE"><STRING>NJ</STRING></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::COMPANY"><OBJECT ID="12" CLASS="WEBLOCKS-DEMO::COMPANY"><SLOT NAME="WEBLOCKS::ID"><INT>2</INT></SLOT><SLOT NAME="WEBLOCKS-DEMO::NAME"><STRING>Nuclear Plant</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::INDUSTRY"><STRING>Energy</STRING></SLOT><SLOT NAME="WEBLOCKS-DEMO::NON-PROFIT"><NULL/></SLOT></OBJECT></SLOT><SLOT NAME="WEBLOCKS-DEMO::CONTRACT"><SYMBOL>:FULL-TIME</SYMBOL></SLOT></OBJECT></VALUE></ENTRY></HASH-TABLE></SLOT><SLOT NAME="WEBLOCKS-PREVALENCE::NEXT-ID"><INT>2</INT></SLOT></OBJECT></VALUE></ENTRY><ENTRY><KEY><SYMBOL>WEBLOCKS-DEMO::COMPANY</SYMBOL></KEY><VALUE><OBJECT ID="13" CLASS="WEBLOCKS-PREVALENCE::PERSISTENT-OBJECTS-OF-CLASS"><SLOT NAME="WEBLOCKS-PREVALENCE::OBJECTS-BY-ID"><HASH-TABLE ID="14" TEST="CL:EQL" SIZE="16"><ENTRY><KEY><INT>2</INT></KEY><VALUE><REF ID="12"/></VALUE></ENTRY><ENTRY><KEY><INT>1</INT></KEY><VALUE><REF ID="6"/></VALUE></ENTRY><ENTRY><KEY><INT>0</INT></KEY><VALUE><REF ID="9"/></VALUE></ENTRY></HASH-TABLE></SLOT><SLOT NAME="WEBLOCKS-PREVALENCE::NEXT-ID"><INT>2</INT></SLOT></OBJECT></VALUE></ENTRY></HASH-TABLE>
36 changes: 18 additions & 18 deletions src/bundling.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@

(defvar *initial-bundle-id* 1)

(defun get-bundle-tally ()
(defun get-bundle-tally (&key bundle-folder)
"Copy the tally file into a bundle-tally object"
(let* ((bundle-folder (merge-pathnames "bundles/" (compute-webapp-public-files-path (current-webapp))))
(tally-path (merge-pathnames "tally" bundle-folder))
(when (null bundle-folder)
(setf bundle-folder (merge-pathnames "bundles/" (compute-webapp-public-files-path (current-webapp)))))
(let* ((tally-path (merge-pathnames "tally" bundle-folder))
(file-data (when (cl-fad:file-exists-p tally-path)
(read-from-file tally-path)))
(last-bundle-id (if file-data (car file-data) (1- *initial-bundle-id*)))
Expand All @@ -50,38 +51,39 @@
(push (cons bundle-name file-list) composition-list)
(setf modified-p t)))


#|
(defun remove-from-tally (bundle-name tally)
(with-slots (composition-list modified-p) tally
(setf composition-list (remove-if #'(lambda (x) (string-equal (car x) bundle-name)) composition-list))
(setf composition-list (remove-if #'(lambda (x) (string-equal (car x) bundle-name))
composition-list))
(setf modified-p t)))
(defun delete-bundle-file (bundle-name tally)
(remove-from-tally bundle-name tally)
(delete-file (merge-pathnames bundle-name (bundle-folder tally))))
|#

(defun create-bundle-file (file-list type tally)
(let ((bundle-name (format nil "~A.~A"
(incf (last-bundle-id tally))
(ecase type
(stylesheet-dependency "css")
(script-dependency "js")))))
(add-to-tally bundle-name file-list tally)
(merge-files file-list (merge-pathnames bundle-name (bundle-folder tally)))
(merge-files-with-newline file-list (merge-pathnames bundle-name (bundle-folder tally)))
bundle-name))

(defun delete-bundle-file (bundle-name tally)
(remove-from-tally bundle-name tally)
(delete-file (merge-pathnames bundle-name (bundle-folder tally))))


(defun find-bundle (file-list tally)
"If the same files have already been bundled, return the bundle-name"
(car (find-if #'(lambda (x) (equalp (cdr x) file-list))
(composition-list tally))))

(defvar *bundle-dependencies-lock* (bordeaux-threads:make-lock))

(defun build-bundle (file-list type &key media)
(defun build-bundle (file-list type &key media bundle-folder)
(bordeaux-threads:with-lock-held (*bundle-dependencies-lock*)
(let* ((app (current-webapp))
(tally (get-bundle-tally))
(tally (get-bundle-tally :bundle-folder bundle-folder))
(bundle-name (find-bundle file-list tally)))
(when (null bundle-name)
(setf bundle-name (create-bundle-file file-list type tally)))
Expand All @@ -106,7 +108,7 @@
:local-path physical-path)))))))


(defun bundle-some-dependencies (dependency-list dependency-type)
(defun bundle-some-dependencies (dependency-list dependency-type &key bundle-folder)
(let (exceptions)
(when (listp dependency-type)
(setf exceptions (cdr dependency-type))
Expand All @@ -127,9 +129,7 @@
finally
(return (progn
(when imports
(setf main
(append imports main)))
(setf main (append imports main)))
(when main
(push (build-bundle main dependency-type)
others))
(push (build-bundle main dependency-type :bundle-folder bundle-folder) others))
others)))))
4 changes: 4 additions & 0 deletions src/debug-mode.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@

(declaim (special *maintain-last-session*))

(defvar *weblocks-global-debug* nil)

(defun enable-global-debugging ()
"Setup hooks for session maintenance and showing backtraces"
(setf *weblocks-global-debug* t)
;; Set hunchentoot defaults (for everyone)
(setf *show-lisp-errors-p* t)
;(setf *show-lisp-backtraces-p* t)
Expand All @@ -17,6 +20,7 @@

(defun disable-global-debugging ()
"A manual method for resetting global debugging state"
(setf *weblocks-global-debug* nil)
(setf *show-lisp-errors-p* nil)
;(setf *show-lisp-backtraces-p* nil)
(setf *maintain-last-session* nil))
Expand Down
60 changes: 9 additions & 51 deletions src/dependencies.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,15 @@ when new dependencies appeared in AJAX page updates.")
(defun sort-dependencies-by-type (dependency-list)
(sort dependency-list #'dependencies-lessp))

(defun bundle-dependencies (dependency-list)
(let ((types (bundle-dependency-types* (current-webapp))))
(when (find :stylesheet types)
(setf dependency-list (bundle-some-dependencies dependency-list 'stylesheet-dependency)))
(when (find :script types)
(setf dependency-list (bundle-some-dependencies dependency-list 'script-dependency)))
dependency-list))
(defun bundle-dependencies (dependency-list &key bundle-folder
(bundle-types (bundle-dependency-types* (current-webapp))))
(when (find :stylesheet bundle-types)
(setf dependency-list (bundle-some-dependencies dependency-list 'stylesheet-dependency
:bundle-folder bundle-folder)))
(when (find :script bundle-types)
(setf dependency-list (bundle-some-dependencies dependency-list 'script-dependency
:bundle-folder bundle-folder)))
dependency-list)


(defgeneric compact-dependencies (dependency-list)
Expand Down Expand Up @@ -189,50 +191,6 @@ when new dependencies appeared in AJAX page updates.")
(let ((new-path (format nil "~A.gz" original-path)))
(gzip-file original-path new-path))))

;;; Dealing with CSS import rules

(defun write-import-css (url stream)
(write-char #\Newline stream)
(write-string "@import url(" stream)
(princ url stream)
(write-string ");" stream))

(defun extract-import-urls (string)
(let (urls (start 0))
(loop
(multiple-value-bind (head tail) (cl-ppcre:scan "(?i)import url\(.*?\);" string :start start)
(if head
(progn
(push (subseq string (+ head 11) (- tail 2)) urls)
(setf start tail))
(return-from extract-import-urls urls))))))

(defun local-path-from-url (url &key (type :stylesheet))
(let* ((name (pathname-name url))
(relative (public-file-relative-path type name))
(webapp (current-webapp))
(local (princ-to-string (merge-pathnames relative
(compute-webapp-public-files-path webapp)))))
(when (cl-fad:file-exists-p local)
(values local
(princ-to-string (merge-pathnames relative
(maybe-add-trailing-slash (compute-webapp-public-files-uri-prefix webapp))))))))

(defun update-import-css-content (import-path)
(let ((urls (extract-import-urls (slurp-file import-path)))
(webapp (current-webapp)))
(with-file-write (stream import-path)
(dolist (url urls)
(multiple-value-bind (physical-path virtual-path) (local-path-from-url url)
(if physical-path
(progn
(when (find :stylesheet (version-dependency-types* webapp))
(multiple-value-setq (physical-path virtual-path)
(update-versioned-dependency-path physical-path virtual-path)))
(when (find :stylesheet (gzip-dependency-types* webapp))
(create-gziped-dependency-file physical-path))
(write-import-css virtual-path stream))
(write-import-css url stream)))))))

;; Dependency gathering

Expand Down
19 changes: 14 additions & 5 deletions src/utils/misc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -542,11 +542,20 @@ answering its result."
(read-sequence seq stream)
seq))

(defun merge-files (file-list saved-path)
(with-file-write (stream saved-path :element-type '(unsigned-byte 8))
(dolist (file file-list)
(write-sequence (slurp-file file :element-type '(unsigned-byte 8)) stream)
(write-byte 10 stream))))
(defun merge-files (file-list saved-path
&key (element-type '(unsigned-byte 8)) linkage-element-fn)
(with-file-write (stream saved-path :element-type element-type)
(write-sequence (slurp-file (car file-list) :element-type element-type)
stream)
(dolist (file (cdr file-list))
(when linkage-element-fn
(funcall linkage-element-fn stream))
(write-sequence (slurp-file file :element-type element-type)
stream))))

(defun merge-files-with-newline (file-list saved-path)
(merge-files file-list saved-path
:linkage-element-fn (lambda (stream) (write-byte 10 stream))))

(defun relative-path (full-path prefix-path)
(princ-to-string
Expand Down
48 changes: 47 additions & 1 deletion src/versioning.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,50 @@
(when (file-modified-p mod-record) (update-mod-record mod-record :versioning-p t))
(with-slots (last-version) mod-record
(values (make-versioned-path original-path last-version)
(make-versioned-path other-path last-version))))))
(make-versioned-path other-path last-version))))))


;;; Dealing with CSS import rules

(defun write-import-css (url stream)
(write-char #\Newline stream)
(write-string "@import url(" stream)
(princ url stream)
(write-string ");" stream))

(defun extract-import-urls (string)
(let (urls (start 0))
(loop
(multiple-value-bind (head tail) (cl-ppcre:scan "(?i)import url\(.*?\);" string :start start)
(if head
(progn
(push (subseq string (+ head 11) (- tail 2)) urls)
(setf start tail))
(return-from extract-import-urls urls))))))

(defun local-path-from-url (url &key (type :stylesheet))
(let* ((name (pathname-name url))
(relative (public-file-relative-path type name))
(webapp (current-webapp))
(local (princ-to-string (merge-pathnames relative
(compute-webapp-public-files-path webapp)))))
(when (cl-fad:file-exists-p local)
(values local
(princ-to-string (merge-pathnames relative
(maybe-add-trailing-slash (compute-webapp-public-files-uri-prefix webapp))))))))

(defun update-import-css-content (import-path &key (version-types (version-dependency-types* (current-webapp)))
(gzip-types (gzip-dependency-types* (current-webapp))))
(let ((urls (extract-import-urls (slurp-file import-path))))
(with-file-write (stream import-path)
(dolist (url (nreverse urls))
(multiple-value-bind (physical-path virtual-path) (local-path-from-url url)
(if physical-path
(progn
(when (find :stylesheet version-types)
(multiple-value-setq (physical-path virtual-path)
(update-versioned-dependency-path physical-path virtual-path)))
(when (find :stylesheet gzip-types)
(create-gziped-dependency-file physical-path))
(write-import-css virtual-path stream))
(write-import-css url stream)))))))
Loading

0 comments on commit d076276

Please sign in to comment.