|
- #|
-
- This is probably a complete waste of time, but this is a WIDGET class
- that encapsulates doing stuff with web widgets.
-
- See the [reblocks Quickstart](https://40ants.com/reblocks/quickstart/) for more information on how this is intended to be structured and used.
-
- There are no guarantees that any of this is sane or useful.
-
- #+BEGIN_SRC
- CLASS ztf_handler DEFINITION
- TYPES t_sap_tables TYPE STANDARD TABLE OF dd02t WITH EMPTY KEY.
-
- DATA path TYPE string.
- DATA searched_string TYPE string.
- DATA page TYPE i.
-
- METHODS html_page RETURNING VALUE(html) TYPE string.
- METHODS html_shellbar RETURNING VALUE(html) TYPE string.
- METHODS html_searchbar RETURNING VALUE(html) TYPE string.
- METHODS html_table RETURNING VALUE(html) TYPE string.
- METHODS html_table_rows RETURNING VALUE(html) TYPE string.
-
- METHODS sap_table_getcount RETURNING VALUE(count) TYPE i.
- METHODS sap_table_getlist RETURNING VALUE(sap_tables) TYPE t_sap_tables.
- #+END_SRC
- |#
-
- (defpackage #:cl-deck-builder2.web.widget
- (:use #:cl
- #:caveman2)
- (:import-from #:cl-deck-builder2.web
- #:render-with-env))
-
- (in-package #:cl-deck-builder2.web.widget)
-
- (defclass widget-base (standard-object)
- ((tables :accessor widget-tables
- :initarg :tables
- :initform '())
- ;; Hash table of registered templates. Mapping :PAGE to #P"page.html"
- (templates :accessor widget-templates
- :initform (make-hash-table)))
- (:documentation "The WIDGET-BASE is the base class for other WIDGET objects. We have the minimum info: the environment TABLES and the template PATH."))
-
- (defmethod widget-path ((obj widget-base) tag)
- (gethash tag (widget-templates obj)))
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defmethod html-page ((obj widget-base) tag)
- (render-with-env
- (widget-path obj tag)
- (list (widget-tables obj))))
-
- (defmethod html-shellbar ((obj widget-bells))
- (render-with-env (widget-search-path obj)
- (list (widget-tables obj))))
-
- (in-package #:cl-deck-builder2.web)
-
- (defparameter *w* (make-instance 'cl-deck-builder2.web.widget::widget-bells
- :path #P"workbench/tabs.html"
- :search-path #P"workbench/test.html"))
-
- (defroute ("/test" :method :GET) (&key _parsed)
- (declare (ignore _parsed))
- (cl-deck-builder2.web.widget::html-page *w*))
-
- (defroute ("/test2" :method :GET) (&key _parsed)
- (declare (ignore _parsed))
- (cl-deck-builder2.web.widget::html-shellbar *w*))
|