(defpackage :crud (:use :cl :core-server :arnesi)) (in-package :crud) (defclass+ crud-application (http-application database) () (:metaclass http-application+) (:default-initargs :auto-start t)) (defclass+ user () ((username :host both) (email :host both) (password :host local))) (defcrud user) (defcomponent user-proxy () ((username :host both) (email :host both) (password :host remote))) (defcomponent crud-application-component () ((crud :initform (jobject user))) (set-attribute obj "ref-id" random-id) obj))) (user.list (component.application self)))) (defmethod/local save-it ((self crud-application-component) instance-id slots) (let ((instance (gethash instance-id (local-cache self)))) (break (list 'save-it instance slots)))) (defmethod/local add-it ((self crud-application-component) slots) (break (list 'add-it slots))) (defmethod/remote add-link ((self crud-application-component) e) (let ((slots (call-component (call/cc (crud self) (.get-element-by-id docuent "crud"))))) (let ((instance (add-it self slots))) (init self)))) ;; data JSComponent :: Object -> IO Object ;; call/cc :: JSComponent -> ;; ------------------------------------------------------------------------- ;; Javascript call/cc: (f &rest args) -> (apply #'f (append args (list k))) ;; ------------------------------------------------------------------------- ;; CRUD> (js ;; (progn ;; (defun usual-function () 1) ;; (defun/cc callcc-function () 2) ;; (defun manual-continuation () (k 3)) ;; (with-call/cc (usual-function)) ;; (with-call/cc (callcc-function)) ;; (with-call/cc (call/cc manual-continuation alert)))) ;; "function usualFunction() { ;; return 1; ;; }; ;; function callccFunction(k11991) { ;; k11991 = k11991 || window.k; ;; return k11991(2); ;; }; ;; function manualContinuation() { ;; return k(3); ;; }; ;; k(usualFunction()); ;; callccFunction(k); ;; manualContinuation(alert, k);" (defmethod/remote init ((self crud-application-component)) (setf window.core self) (let ((instances (get-instances self))) (debug instances) (make-web-thread (lambda () (let ((table (call/cc (table self) (extend (jobject :instances instances) (.get-element-by-id document "table"))))) (let ((selected (call-component table))) (debug selected) (let ((crud (call/cc (crud self) (extend (jobject :instance selected) (.get-element-by-id docuent "crud"))))) (let ((slots (call-component crud))) (save-it self selected slots))))))))) (defhandler "index2.html" ((self crud-application)) (<:html (<:head (<:script :type "text/javascript" :src "library.core") (crud-application-component)) (<:body (<:h1 "Data Crud:") (<:table :id "table") (<:a :id "add" :onclick "javascript:core.addLink()" "Add") (<:div :id "crud")))) ;; (defhandler "index.html" ((self crud-application)) ;; (let* ((crud (