From e800e674f5b0daa4f10350b4b3e094a56c2da986 Mon Sep 17 00:00:00 2001 From: Hraban Luyat Date: Thu, 4 Jul 2024 14:45:13 -0400 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20pass=20event=20and=20=E2=80=98this?= =?UTF-8?q?=E2=80=99=20to=20form=20event=20handler?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also makes the handlers overridable, which makes it easier to override and/or implement new behavior. Depends on https://github.com/40ants/reblocks/pull/57 --- src/form.lisp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/form.lisp b/src/form.lisp index 8dc4d1b..7a684fb 100644 --- a/src/form.lisp +++ b/src/form.lisp @@ -36,6 +36,9 @@ #:get-field-errors-count)) (in-package reblocks-ui/form) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defvar *js-default-action* "return initiateAction(\"~A\")") + (defvar *js-default-form-action* "return initiateFormAction(\"~A\", event, this)")) (serapeum:defvar-unbound *form-field-errors* "This variable will hold a hash-table where keys are field names and values @@ -174,7 +177,7 @@ $('~A').foundation(); extra-submit-code requires-confirmation-p (confirm-question "Are you sure?") - (submit-fn "initiateFormAction(\"~A\", $(this), \"~A\")") + (submit-fn *js-default-form-action*) ;; A hashmap with placeholders widgets error-placeholders) (let* ((action (if (functionp action) @@ -230,16 +233,9 @@ $('~A').foundation(); action)) (action-code (make-action action)) (on-submit (when use-ajax-p - (format nil "~@[~A~]~A; return false;" - extra-submit-code - (format nil submit-fn - (url-encode (or action-code "")) - ;; Function session-name-string-pair was removed - ;; during reblocks refactoring, so we just - ;; - "" - ;; (reblocks::session-name-string-pair) - )))) + (concatenate 'string + (or extra-submit-code "") + (format nil submit-fn (url-encode (or action-code "")))))) (popup-name (when requires-confirmation-p (symbol-name (gensym "popup")))) @@ -364,7 +360,6 @@ $('~A').foundation(); (t confirm-question)) env)))) - (defmacro with-html-form ((method-type action &key id @@ -374,7 +369,7 @@ $('~A').foundation(); extra-submit-code requires-confirmation-p (confirm-question "Are you sure?") - (submit-fn "initiateFormAction(\"~A\", $(this), \"~A\")")) + (submit-fn *js-default-form-action*)) &body body &environment env) "Wraps a body with (:form ...) using REBLOCKS/HTML:WITH-HTML. @@ -500,8 +495,7 @@ bot, crawling the internet will hit this action with GET request." (action-code (make-action action)) (url (make-action-url action-code)) (on-click (when ajaxp - (format nil "initiateAction(\"~A\"); return false;" - action-code)))) + (format nil *js-default-action* action-code)))) (with-html (:a :id id From 925cf0694f8dba2febe9fddb71bf88e13a398f8a Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 28 Jul 2024 20:31:32 +0300 Subject: [PATCH 2/6] Used eval-always instead of eval-when. --- src/form.lisp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/form.lisp b/src/form.lisp index 7a684fb..c710ce0 100644 --- a/src/form.lisp +++ b/src/form.lisp @@ -2,6 +2,9 @@ (:use #:cl) (:import-from #:log) (:import-from #:spinneret) + (:import-from #:serapeum + #:defvar-unbound + #:eval-always) (:import-from #:reblocks/actions #:make-action-url #:make-action) @@ -36,11 +39,12 @@ #:get-field-errors-count)) (in-package reblocks-ui/form) -(eval-when (:compile-toplevel :load-toplevel :execute) - (defvar *js-default-action* "return initiateAction(\"~A\")") +(defvar *js-default-action* "return initiateAction(\"~A\")") + +(eval-always (defvar *js-default-form-action* "return initiateFormAction(\"~A\", event, this)")) -(serapeum:defvar-unbound *form-field-errors* +(defvar-unbound *form-field-errors* "This variable will hold a hash-table where keys are field names and values are lists of strings of error messages.") From 8b6c80bd261dd03e6cbed7888dab9a1c6e685cfc Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 28 Jul 2024 20:33:14 +0300 Subject: [PATCH 3/6] Changelog was updated. --- docs/changelog.lisp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/changelog.lisp b/docs/changelog.lisp index ccb181d..febbc81 100644 --- a/docs/changelog.lisp +++ b/docs/changelog.lisp @@ -9,6 +9,13 @@ "JS" "UI" "40ANTS-DOC")) + (0.17.0 2024-07-28 + " +Fixed +===== + +- Code was fixed to work with latest changed to Reblocks, introduced in [PR 57](https://github.com/40ants/reblocks/pull/57). +") (0.16.0 2022-12-12 " Changed From d308fec3ae106e028175c07c88ce53e5c82306ca Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 28 Jul 2024 21:58:37 +0300 Subject: [PATCH 4/6] Update CI pipelines. --- .github/workflows/ci.yml | 72 +++++------------------------------ .github/workflows/docs.yml | 36 +++--------------- .github/workflows/release.yml | 2 +- 3 files changed, 16 insertions(+), 94 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d4f4cd..0ea6a55 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,41 +24,15 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v3" - }, - { - "name": "Grant All Perms to Make Cache Restoring Possible", - "run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin", - "shell": "bash" - }, - { - "name": "Get Current Month", - "id": "current-month", - "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", - "shell": "bash" - }, - { - "name": "Cache Roswell Setup", - "id": "cache", - "uses": "actions/cache@v3", - "with": { - "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", - "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}" - } - }, - { - "name": "Restore Path To Cached Files", - "run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH", - "shell": "bash", - "if": "steps.cache.outputs.cache-hit == 'true'" + "uses": "actions/checkout@v4" }, { "name": "Setup Common Lisp Environment", - "uses": "40ants/setup-lisp@v3", + "uses": "40ants/setup-lisp@v4", "with": { - "asdf-system": "reblocks-ui" - }, - "if": "steps.cache.outputs.cache-hit != 'true'" + "asdf-system": "reblocks-ui", + "cache": "true" + } }, { "name": "Change dist to Ultralisp if qlfile does not exist", @@ -92,41 +66,15 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v3" - }, - { - "name": "Grant All Perms to Make Cache Restoring Possible", - "run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin", - "shell": "bash" - }, - { - "name": "Get Current Month", - "id": "current-month", - "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", - "shell": "bash" - }, - { - "name": "Cache Roswell Setup", - "id": "cache", - "uses": "actions/cache@v3", - "with": { - "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", - "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}" - } - }, - { - "name": "Restore Path To Cached Files", - "run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH", - "shell": "bash", - "if": "steps.cache.outputs.cache-hit == 'true'" + "uses": "actions/checkout@v4" }, { "name": "Setup Common Lisp Environment", - "uses": "40ants/setup-lisp@v3", + "uses": "40ants/setup-lisp@v4", "with": { - "asdf-system": "reblocks-ui" - }, - "if": "steps.cache.outputs.cache-hit != 'true'" + "asdf-system": "reblocks-ui", + "cache": "true" + } }, { "name": "Change dist to Ultralisp", diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c3fba87..a6afa81 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -19,41 +19,15 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v3" - }, - { - "name": "Grant All Perms to Make Cache Restoring Possible", - "run": "sudo mkdir -p /usr/local/etc/roswell\n sudo chown \"${USER}\" /usr/local/etc/roswell\n # Here the ros binary will be restored:\n sudo chown \"${USER}\" /usr/local/bin", - "shell": "bash" - }, - { - "name": "Get Current Month", - "id": "current-month", - "run": "echo \"value=$(date -u \"+%Y-%m\")\" >> $GITHUB_OUTPUT", - "shell": "bash" - }, - { - "name": "Cache Roswell Setup", - "id": "cache", - "uses": "actions/cache@v3", - "with": { - "path": "qlfile\nqlfile.lock\n~/.cache/common-lisp/\n~/.roswell\n/usr/local/etc/roswell\n/usr/local/bin/ros\n/usr/local/Cellar/roswell\n.qlot", - "key": "a-${{ steps.current-month.outputs.value }}-${{ env.cache-name }}-ubuntu-latest-quicklisp-sbcl-bin-${{ hashFiles('qlfile.lock', '*.asd') }}" - } - }, - { - "name": "Restore Path To Cached Files", - "run": "echo $HOME/.roswell/bin >> $GITHUB_PATH\n echo .qlot/bin >> $GITHUB_PATH", - "shell": "bash", - "if": "steps.cache.outputs.cache-hit == 'true'" + "uses": "actions/checkout@v4" }, { "name": "Setup Common Lisp Environment", - "uses": "40ants/setup-lisp@v3", + "uses": "40ants/setup-lisp@v4", "with": { - "asdf-system": "reblocks-ui-docs" - }, - "if": "steps.cache.outputs.cache-hit != 'true'" + "asdf-system": "reblocks-ui-docs", + "cache": "true" + } }, { "name": "Build Docs", diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 954a253..4362396 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ "steps": [ { "name": "Checkout Code", - "uses": "actions/checkout@v3" + "uses": "actions/checkout@v4" }, { "name": "Create release tag", From 5a2a47476addd0c115f57e896d58fc97c04e4a0d Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 28 Jul 2024 21:59:34 +0300 Subject: [PATCH 5/6] Updated gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8a7730e..49eb990 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /.qlot/ .DS_Store *.fasl +*.~undo-tree~ From 01dd145980838aaaa0e23a1c68d70d1f6dae5c72 Mon Sep 17 00:00:00 2001 From: Alexander Artemenko Date: Sun, 28 Jul 2024 22:32:49 +0300 Subject: [PATCH 6/6] Updated qlfile.lock. --- qlfile.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qlfile.lock b/qlfile.lock index abd6458..7989cb2 100644 --- a/qlfile.lock +++ b/qlfile.lock @@ -1,8 +1,8 @@ ("quicklisp" . (:class qlot/source/dist:source-dist - :initargs (:distribution "http://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) + :initargs (:distribution "https://beta.quicklisp.org/dist/quicklisp.txt" :%version :latest) :version "2023-10-21")) ("ultralisp" . (:class qlot/source/dist:source-dist - :initargs (:distribution "http://dist.ultralisp.org" :%version :latest) - :version "20240303155001")) + :initargs (:distribution "https://dist.ultralisp.org" :%version :latest) + :version "20240723211501"))