Renamed src/lib Parenscript library files, got rid of Parenscript CSS system.
authorVladimir Sedach <vsedach@gmail.com>
Wed, 26 Dec 2007 03:08:10 +0000 (03:08 +0000)
committerVladimir Sedach <vsedach@gmail.com>
Wed, 26 Dec 2007 03:08:10 +0000 (03:08 +0000)
docs/reference.lisp
parenscript.asd
src/lib/css.lisp [deleted file]
src/lib/ps-html.lisp [moved from src/lib/js-html.lisp with 85% similarity]
src/lib/ps-macro-lib.lisp [moved from src/lib/js-utils.lisp with 100% similarity]
src/lib/ps-runtime-lib.lisp [moved from src/lib/js-lib.lisp with 100% similarity]
src/package.lisp
src/utils.lisp
t/ps-tests.lisp
t/reference-tests.lisp

index 57a1ea0..cd05acb 100644 (file)
@@ -924,9 +924,6 @@ a-variable  => aVariable
 ;;;# The HTML Generator
 ;;;t \index{PS-HTML}
 ;;;t \index{HTML generation}
-;;;t \index{CSS}
-;;;t \index{CSS generation}
-
 
 ; (PS-HTML html-expression)
 
@@ -965,22 +962,6 @@ a-variable  => aVariable
         + (disabled || !authorized ? ' disabled=\"' + 'disabled' + '\"' : '')
         + '>Edit me</textarea>';
 
-; (CSS-INLINE css-expression)
-
-;;; Stylesheets can also be created in ParenScript.
-
-(css-inline :color "red"
-            :font-size "x-small")
-  => 'color:red;font-size:x-small'
-
-(defun make-color-div(color-name)
-    (return (ps-html ((:div :style (css-inline :color color-name))
-                   color-name " looks like this."))))
-  => function makeColorDiv(colorName) {
-       return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
-         + ' looks like this.</div>';
-     }
-
 ;;;# Macrology
 ;;;t \index{macro}
 ;;;t \index{macrology}
index 4404478..63f792e 100644 (file)
@@ -12,7 +12,7 @@
   :author "Manuel Odendahl <manuel@bl0rg.net>"
   :maintainer "Vladimir Sedach <vsedach@gmail.com>"
   :licence "BSD"
-  :description "Parenscript is a lispy language that compiles to Javascript."
+  :description "Parenscript is a Lispy language that compiles to JavaScript."
   :components ((:static-file "parenscript.asd")
                (:module :src
                         :serial t
                                      (:file "deprecated-interface")
                                      ;; standard library
                                      (:module :lib
-                                              :components ((:static-file "functional.lisp")
-                                                           (:file "js-html")
-                                                           (:file "css"    )
-                                                           (:file "js-utils")
-                                                           (:file "js-lib"))
+                                              :components ((:file "ps-html")
+                                                           (:file "ps-macro-lib")
+                                                           (:file "ps-runtime-lib"))
                                               :depends-on ("compilation-interface")))))
   :depends-on ())
 
diff --git a/src/lib/css.lisp b/src/lib/css.lisp
deleted file mode 100644 (file)
index 5fd470a..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-(in-package :parenscript)
-
-(defun make-css-rule (selectors properties)
-  (list (mapcar #'val-to-string
-               (if (atom selectors)
-                   (list selectors)
-                   selectors))
-       properties))
-
-(defun css-rule-selectors (css-rule)
-  (first css-rule))
-
-(defun css-rule-properties (css-rule)
-  (second css-rule))
-
-(defmacro css-rule (selectors &rest properties)
-  `(make-css-rule ',selectors ',properties))
-
-(defun propval-to-string (propval)
-  (format nil "~A:~A" (val-to-string (first propval))
-         (val-to-string (second propval))))
-
-(defun css-rule-to-string (css-rule)
-  (format nil "~A {~%~{~A;~%~}}~%~%"
-         (string-join (css-rule-selectors css-rule) ",")
-         (loop for propval on (css-rule-properties css-rule) by #'cddr
-                   collect (concatenate 'string "   " (propval-to-string propval)))))
-
-(defun css-to-string (rules)
-  (string-join (mapcar #'css-rule-to-string rules) "; "))
-
-(defmacro css (&rest rules)
-  `((:style :type "text/css")
-    (:princ #\Newline "<!--" #\Newline)
-    (:princ ,@(mapcar #'(lambda (rule) `(css-rule-to-string (css-rule ,@rule))) rules))
-    (:princ "-->" #\Newline)))
-
-(defun css-inline-func (proplist)
-  (string-join (loop for propval on proplist by #'cddr
-                    collect (propval-to-string propval))
-              ";"))
-
-(defmacro css-inline (&rest propvals)
-  `(parenscript::css-inline-func ,propvals))
-
-(defmacro css-file (&rest rules)
-  `(html
-    (:princ
-     ,@(mapcar #'(lambda (rule) `(css-rule-to-string (css-rule ,@rule))) rules))))
-
-;;; examples
-
-;;; generate a CSS file
-#+nil
-(html-stream *standard-output*
-      (css-file (* :border "1px solid black")
-           (div.bl0rg :font-family "serif")
-           (("a:active" "a:hoover") :color "black" :size "200%")))
-
-
-;;; generate an inline CSS spec in a HTML head element
-#+nil
-(html-stream *standard-output*
-  (html
-   (:html
-    (:head
-     (css (* :border "1px solid black")
-         (div.bl0rg :font-family "serif")
-         (("a:active" "a:hoover") :color "black" :size "200%"))))))
-
-;;; generate a style attribute for a DIV element
-#+nil
-(html-stream *standard-output*
-      (html (:html (:body ((:div :style (css-inline :border "1px solid black"))
-                          "foobar")))))
-
similarity index 85%
rename from src/lib/js-html.lisp
rename to src/lib/ps-html.lisp
index 40366fa..b28127b 100644 (file)
   (declare (ignore expecting))
   (compile-parenscript-form (process-html-forms forms)))
 
-(defun process-css-forms (proplist)
-  (optimize-string-list (butlast
-                         (loop for propval on proplist by #'cddr appending
-                              (list (string-downcase (symbol-name (first propval)))
-                                    ":"
-                                    (second propval)
-                                    ";")))))
-
-
-(define-ps-special-form css-inline (expecting &rest forms)
-  (declare (ignore expecting))
-  (compile-parenscript-form (cons '+ (process-css-forms forms))))
index 496a1f3..4b9a435 100644 (file)
       #:while
        
       ;; v v v STUFF WE SHOULD PROBABLY MOVE TO OTHER LIBS v v v
-       
-      ;; CSS
-      #:css
-      #:css-to-string
-      #:css-inline
-      #:css-file
 
       ;; html generator for javascript
       #:ps-html
index 9be823c..51cbaf8 100644 (file)
       (when keep-separators (push (string (char string i)) res))
       (setf last (1+ i)))))
 
+(defun concat-constant-strings (list)
+  (reverse (reduce (lambda (optimized-list next-obj)
+                     (if (and (or (numberp next-obj) (stringp next-obj)) (stringp (car optimized-list)))
+                         (cons (format nil "~a~a" (car optimized-list) next-obj) (cdr optimized-list))
+                         (cons next-obj optimized-list)))
+                   (cons () list))))
+
 (defparameter *special-chars*
   '((#\! . "Bang")
     (#\? . "What")
index 6830475..4d5a7ec 100644 (file)
@@ -74,20 +74,6 @@ x = 2 + sideEffect() + x + 5;")
          (a-parenthesis #\)))
     (is (char= char-before a-parenthesis))))
 
-;; A problem with long nested operator, when the statement spanned several rows
-;; the rows would not be joined together correctly.
-(test-ps-js bug-dwim-join
-   (alert (ps-html ((:div :id 777
-                          :style (css-inline :border "1pxsssssssssss"
-                                             :font-size "x-small"
-                                             :height (* 2 200)
-                                             :width (* 2 300))))))
-   "alert('<div id=\"777\" style=\"'
- + ('border:1pxsssssssssss;font-size:x-small;height:' + 2 * 200 + ';width:'
- + 2 * 300)
- + '\"></div>')") ;";This line should start with a plus character.
-
-
 (test-ps-js simple-slot-value
   (let* ((foo (create :a 1)))
    (alert (slot-value foo 'a)))
index 48a724d..a90792e 100644 (file)
@@ -509,17 +509,3 @@ _js2.style.left = _js1;")
    + (disabled || !authorized ? ' disabled=\"' + 'disabled' + '\"' : '')
    + '>Edit me</textarea>';")
 
-(test-ps-js the-html-generator-5
-  (css-inline :color "red"
-            :font-size "x-small")
-  "'color:red;font-size:x-small'")
-
-(test-ps-js the-html-generator-6
-  (defun make-color-div(color-name)
-    (return (ps-html ((:div :style (css-inline :color color-name))
-                   color-name " looks like this."))))
-  "function makeColorDiv(colorName) {
-  return '<div style=\"' + ('color:' + colorName) + '\">' + colorName
-    + ' looks like this.</div>';
-}")
-