diff --git a/clog-element-common.lisp b/clog-element-common.lisp index 6529e61..ab55ec5 100644 --- a/clog-element-common.lisp +++ b/clog-element-common.lisp @@ -8,6 +8,74 @@ (cl:in-package :clog) +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Implementation - clog-a +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defclass clog-a (clog-element)() + (:documentation "CLOG A, anchor, Objects.")) + +;;;;;;;;;;;;;; +;; create-a ;; +;;;;;;;;;;;;;; + +(defgeneric create-a (clog-obj &key link content target auto-place) + (:documentation "Create a new CLOG-A as child of CLOG-OBJ with :LINK and +:CONTENT (default \"\") and :TARGET (\"_self\") and if :AUTO-PLACE (default t) +place-inside-bottom-of CLOG-OBJ. + + Target of link, name of a frame or: + _blank = new window + _top = top most frame (full browser window) + _parent = parent frame or window + _self = current frame or window")) + +(defmethod create-a ((obj clog-obj) + &key (link "") + (content "") + (target "_self") + (auto-place t)) + (create-child obj (format nil "~A" + (escape-string target) + (escape-string link) + (escape-string content)) + :clog-type 'clog-a + :auto-place auto-place)) + +;;;;;;;;;; +;; link ;; +;;;;;;;;;; + +(defgeneric link (clog-a) + (:documentation "Get/Setf the HREF link of the anchor.")) + +(defmethod link ((obj clog-a)) + (property obj "href")) + +(defgeneric set-link (clog-a value) + (:documentation "Set link VALUE for CLOG-A")) + +(defmethod set-link ((obj clog-a) value) + (setf (property obj "href") value)) +(defsetf link set-link) + +;;;;;;;;;;;; +;; target ;; +;;;;;;;;;;;; + +(defgeneric target (clog-a) + (:documentation "Get/Setf the link target of the anchor.")) + +(defmethod target ((obj clog-a)) + (property obj "target")) + +(defgeneric set-target (clog-a value) + (:documentation "Set target VALUE for CLOG-A")) + +(defmethod set-target ((obj clog-a) value) + (setf (property obj "target") value)) +(defsetf target set-target) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-br ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -19,13 +87,49 @@ ;; create-br ;; ;;;;;;;;;;;;;;; -(defgeneric create-br (clog-obj &key content auto-place) +(defgeneric create-br (clog-obj &key auto-place) (:documentation "Create a new CLOG-BR as child of CLOG-OBJ that creates a line break and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) -(defmethod create-br ((obj clog-obj) &key (content "") (auto-place t)) - (create-child obj (format nil "
" (escape-string content)) - :clog-type 'clog-br)) +(defmethod create-br ((obj clog-obj) &key (auto-place t)) + (create-child obj "
" :clog-type 'clog-br :auto-place auto-place)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Implementation - clog-button +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defclass clog-button (clog-element)() + (:documentation "CLOG Button Objects.")) + +;;;;;;;;;;;;;;;;;;; +;; create-button ;; +;;;;;;;;;;;;;;;;;;; + +(defgeneric create-button (clog-obj &key content auto-place) + (:documentation "Create a new CLOG-Button as child of CLOG-OBJ with :CONTENT +(default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of +CLOG-OBJ")) + +(defmethod create-button ((obj clog-obj) &key (content "") (auto-place t)) + (create-child obj (format nil "" (escape-string content)) + :clog-type 'clog-button :auto-place auto-place)) + +;;;;;;;;;;;;;;; +;; disabledp ;; +;;;;;;;;;;;;;;; + +(defgeneric disabledp (clog-button) + (:documentation "Get/Setf disabled status of button.")) + +(defmethod disabledp ((obj clog-button)) + (js-true-p (property obj "disabled"))) + +(defgeneric set-disabledp (clog-button value) + (:documentation "Set editable VALUE for CLOG-BUTTON")) + +(defmethod set-disabledp ((obj clog-button) value) + (setf (property obj "disabled") (p-true-js value))) +(defsetf disabledp set-editable) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-div @@ -45,7 +149,7 @@ CLOG-OBJ")) (defmethod create-div ((obj clog-obj) &key (content "") (auto-place t)) (create-child obj (format nil "
~A
" (escape-string content)) - :clog-type 'clog-div)) + :clog-type 'clog-div :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-hr @@ -58,14 +162,53 @@ CLOG-OBJ")) ;; create-hr ;; ;;;;;;;;;;;;;;; -(defgeneric create-hr (clog-obj &key content auto-place) +(defgeneric create-hr (clog-obj &key auto-place) (:documentation "Create a new CLOG-HR as child of CLOG-OBJ that creates a horizontal rule (line) and if :AUTO-PLACE (default t) place-inside-bottom-of CLOG-OBJ")) -(defmethod create-hr ((obj clog-obj) &key (content "") (auto-place t)) - (create-child obj (format nil "
" (escape-string content)) - :clog-type 'clog-hr)) +(defmethod create-hr ((obj clog-obj) &key (auto-place t)) + (create-child obj "
" :clog-type 'clog-hr :auto-place auto-place)) + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;; Implementation - clog-img +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defclass clog-img (clog-element)() + (:documentation "CLOG Img Objects.")) + +;;;;;;;;;;;;;;;; +;; create-img ;; +;;;;;;;;;;;;;;;; + +(defgeneric create-img (clog-obj &key url-src alt-text auto-place) + (:documentation "Create a new CLOG-Img as child of CLOG-OBJ with :CONTENT +(default \"\") and if :AUTO-PLACE (default t) place-inside-bottom-of +CLOG-OBJ. Use width and height properties before placing image to constrain +image size.")) + +(defmethod create-img ((obj clog-obj) &key (url-src "") (alt-text "") (auto-place t)) + (create-child obj (format nil "~A)" + (escape-string url-src) + (escape-string alt-text)) + :clog-type 'clog-img :auto-place auto-place)) + +;;;;;;;;;;;;; +;; url-src ;; +;;;;;;;;;;;;; + +(defgeneric url-src (clog-img) + (:documentation "Get/Setf the url-src of the img.")) + +(defmethod url-src ((obj clog-img)) + (property obj "src")) + +(defgeneric set-url-src (clog-img value) + (:documentation "Set url-src VALUE for CLOG-IMG")) + +(defmethod set-url-src ((obj clog-img) value) + (setf (property obj "src") value)) +(defsetf url-src set-url-src) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Implementation - clog-p @@ -85,7 +228,7 @@ CLOG-OBJ")) (defmethod create-p ((obj clog-obj) &key (content "") (auto-place t)) (create-child obj (format nil "

~A

" (escape-string content)) - :clog-type 'clog-p)) + :clog-type 'clog-p :auto-place auto-place)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; @@ -106,5 +249,5 @@ CLOG-OBJ")) (defmethod create-span ((obj clog-obj) &key (content "") (auto-place t)) (create-child obj (format nil "~A" (escape-string content)) - :clog-type 'clog-span)) + :clog-type 'clog-span :auto-place auto-place)) diff --git a/clog.lisp b/clog.lisp index f0416a4..803b442 100644 --- a/clog.lisp +++ b/clog.lisp @@ -232,10 +232,26 @@ application." (first-child generic-function) (next-sibling generic-function)) -(defsection @clog-element (:title "Common CLOG Elements") +(defsection @clog-element-common (:title "Common CLOG Elements") + "CLOG-A - Class for CLOG Anchors" + (clog-a class) + (create-a generic-function) + (link generic-function) + (target generic-function) + "CLOG-BR - Class for CLOG Line Breaks" (clog-br class) (create-br generic-function) + + "CLOG-BUTTON - Class for CLOG Buttons" + (clog-button class) + (create-button generic-function) + (disabledp generic-function) + + "CLOG-IMG - Class for CLOG Imgs" + (clog-img class) + (create-img generic-function) + (url-src generic-function) "CLOG-Div - Class for CLOG Divs" (clog-div class) diff --git a/doc/clog-manual.html b/doc/clog-manual.html index 8ce2581..c2989ff 100644 --- a/doc/clog-manual.html +++ b/doc/clog-manual.html @@ -39,11 +39,12 @@
  • 3 CLOG Utilities
  • 4 CLOG Objects
  • 5 CLOG Elements
  • -
  • 6 CLOG Body Objects
  • -
  • 7 CLOG Window Objects
  • -
  • 8 CLOG Document Objects
  • -
  • 9 CLOG Location Objects
  • -
  • 10 CLOG Navigator Objects
  • +
  • 6 Common CLOG Elements
  • +
  • 7 CLOG Body Objects
  • +
  • 8 CLOG Window Objects
  • +
  • 9 CLOG Document Objects
  • +
  • 10 CLOG Location Objects
  • +
  • 11 CLOG Navigator Objects
  • [in package CLOG]
    @@ -525,7 +526,7 @@ is nil unbind the event.

    -

    +

    5 CLOG Elements

    @@ -545,19 +546,20 @@ element objects.

    CLOG-Element - Placement

    @@ -1502,11 +1504,215 @@ html id than Element_Type will have an ID of undefined and therefore attached to no actual HTML elemen.

    +

    + +

    + +

    6 Common CLOG Elements

    + +

    CLOG-A - Class for CLOG Anchors

    + +

    + + + +

    + + + +

    + + + +

    + + + +

    CLOG-BR - Class for CLOG Line Breaks

    + +

    + + + +

    + + + +

    CLOG-BUTTON - Class for CLOG Buttons

    + +

    + + + +

    + + + +

    + + + +

    CLOG-IMG - Class for CLOG Imgs

    + +

    + + + +

    + + + +

    + + + +

    CLOG-Div - Class for CLOG Divs

    + +

    + + + +

    + + + +

    CLOG-HR - Class for CLOG Hortizontal Rules

    + +

    + + + +

    + + + +

    CLOG-P - Class for CLOG Paragraphs

    + +

    + + + +

    + + + +

    CLOG-Span - Class for CLOG Spans

    + +

    + + + +

    + + +

    -

    +

    -

    6 CLOG Body Objects

    +

    7 CLOG Body Objects

    CLOG-Body - CLOG Body Objects

    @@ -1556,7 +1762,7 @@ to no actual HTML elemen.

    -

    7 CLOG Window Objects

    +

    8 CLOG Window Objects

    CLOG-Window - CLOG Window Objects

    @@ -1866,7 +2072,7 @@ If ON-ORIENTATION-CHANGE-HANDLER is nil unbind the event.

    -

    8 CLOG Document Objects

    +

    9 CLOG Document Objects

    CLOG-Document - CLOG Document Objects

    @@ -2000,7 +2206,7 @@ If ON-ORIENTATION-CHANGE-HANDLER is nil unbind the event.

    -

    9 CLOG Location Objects

    +

    10 CLOG Location Objects

    CLOG-Location - CLOG Location Objects

    @@ -2116,7 +2322,7 @@ If ON-ORIENTATION-CHANGE-HANDLER is nil unbind the event.

    -

    10 CLOG Navigator Objects

    +

    11 CLOG Navigator Objects

    CLOG-Navigator - CLOG Navigator Objects

    diff --git a/test/test-clog.lisp b/test/test-clog.lisp index 39a6b29..44ee627 100644 --- a/test/test-clog.lisp +++ b/test/test-clog.lisp @@ -49,9 +49,11 @@ (create-br win) (create-span win :content "Hello World! span") (create-hr win) - + (create-a win :link "http://www.google.com" :content "Link" :target "new") (setf (title (html-document win)) "CLOG Test App") (print (title (html-document win))) + (create-img win :url-src "https://common-lisp.net/static/imgs/lisplogo_flag2_128.png" + :alt-text "Lisp Flag") )) (defun test ()