Common subdirectories: ht-ajax_0.0.7/doc and /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/doc diff -uN ht-ajax_0.0.7/ht-ajax.asd /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/ht-ajax.asd --- ht-ajax_0.0.7/ht-ajax.asd 2007-03-08 11:45:18.000000000 -0300 +++ /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/ht-ajax.asd 2008-05-31 13:53:56.000000000 -0300 @@ -22,6 +22,7 @@ (:file "processor-prototype") (:file "processor-dojo") (:file "processor-yui") + (:file "processor-jquery") ) :depends-on (:hunchentoot :cl-ppcre)) diff -uN ht-ajax_0.0.7/ht-ajax.lisp /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/ht-ajax.lisp --- ht-ajax_0.0.7/ht-ajax.lisp 2007-03-08 11:45:18.000000000 -0300 +++ /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/ht-ajax.lisp 2008-05-31 14:41:20.000000000 -0300 @@ -209,7 +209,7 @@ (defun make-ajax-processor (&rest rest &key (type :simple) &allow-other-keys) "Creates an ajax-processor object. Parameters: TYPE - selects the kind of ajax-processor to use (should be - one of:SIMPLE or :LOKRIS, :PROTOTYPE, :YUI or :DOJO) (required) + one of:SIMPLE or :LOKRIS, :PROTOTYPE, :YUI, :DOJO or :JQUERY) (required) SERVER-URI - url that the ajax function calls will use (required) JS-FILE-URIS - a list of URLs on your server of the .js files that the used library requires , such as lokris.js or prototype.js diff -uN ht-ajax_0.0.7/processor-jquery.lisp /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/processor-jquery.lisp --- ht-ajax_0.0.7/processor-jquery.lisp 1969-12-31 21:00:00.000000000 -0300 +++ /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/processor-jquery.lisp 2008-05-31 15:37:31.000000000 -0300 @@ -0,0 +1,120 @@ +;;; -*- Mode: LISP; Syntax: COMMON-LISP; Base: 10 -*- +;;; +;;; Copyright (c) 2007, Ury Marshak +;;; The code comes with a BSD-style license, so you can basically do +;;; with it whatever you want. See the file LICENSE for details. +;;; + +(in-package #:ht-ajax) + +(declaim #.*optimization*) +;; + + +;;; This is the AJAX processor interfacing to the jQuery library +;;; ( http://jquery.com ) + + +(defclass jquery-ajax-processor (library-ajax-processor) + ()) + +(defmethod default-library-file-names ((processor jquery-ajax-processor)) + (declare (ignore processor)) + + '("jquery.js")) + +;; + + +(defun prepare-js-jquery-ajax-preamble (server-uri) + "Output a string containing the call functions." + (concatenate 'string + " +var ajax_server_uri = '" server-uri "'; + +function ajax_call_uri(func, callback_spec, args) { + var uri = ajax_server_uri; + var i; + + if (uri.indexOf('?') == -1) + uri = uri + '?'; + else + uri = uri + '&'; + + uri = uri + ajax_encode_args(func, args); + var callbacks = ajax_parse_callbacks(callback_spec); + + var greq = null; + $.ajax({ + url: uri, + type: 'GET', + beforeSend: function(request) { + greq = request; + }, + success: function (data, textStatus) { + ajax_call_maybe_evaluate_json(callbacks[0], data, greq.getResponseHeader('Content-Type')); + }, + error: function (request, textStatus, errorThrown) { + if (callbacks[1]) { + callbacks[1](textStatus); + } else { + debug_alert(textStatus); + } + } + }); +} + +function ajax_post_uri(func, callback_spec, args) { + var uri = ajax_server_uri; + var params = ajax_encode_args(func, args); + var callbacks = ajax_parse_callbacks(callback_spec); + + var greq = null; + $.ajax({ + url: uri, + type: 'POST', + data: params, + processData: false, + beforeSend: function(request) { + greq = request; + }, + success: function (data, textStatus) { + ajax_call_maybe_evaluate_json(callbacks[0], data, greq.getResponseHeader('Content-Type')); + }, + error: function (request, textStatus, errorThrown) { + if (callbacks[1]) { + callbacks[1](textStatus); + } else { + debug_alert(textStatus); + } + } + }); +}")) + + + +(defmethod %generate-js-code ((processor jquery-ajax-processor)) + (concatenate 'string + (apply #'concatenate 'string + (prepare-js-debug-function processor) + (prepare-js-ajax-encode-args) + (prepare-js-parse-callbacks) + (prepare-js-ajax-is-json) + (prepare-js-ajax-call-maybe-evaluate-json) + (prepare-js-jquery-ajax-preamble (maybe-rewrite-url-for-session + (server-uri processor))) + + + (loop + for fun-name being the hash-keys + in (exported-funcs processor) + collect (apply #'prepare-js-ajax-function + processor + fun-name + (js-function-name processor fun-name) + (gethash fun-name (exported-funcs processor)))) + ))) + + + + diff -uN ht-ajax_0.0.7/processor-prototype.lisp /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/processor-prototype.lisp --- ht-ajax_0.0.7/processor-prototype.lisp 2007-03-08 11:45:19.000000000 -0300 +++ /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/processor-prototype.lisp 2008-05-31 14:36:52.000000000 -0300 @@ -65,10 +65,11 @@ } function ajax_post_uri(func, callback_spec, args) { + var uri = ajax_server_uri; var params = ajax_encode_args(func, args); var callbacks = ajax_parse_callbacks(callback_spec); - new Ajax.Request(ajax_server_uri, + new Ajax.Request(uri, { method:'post', parameters: params, Common subdirectories: ht-ajax_0.0.7/static and /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/static Common subdirectories: ht-ajax_0.0.7/test and /Users/lucindo/.sbcl/site/ht-ajax_0.0.7/test