Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few changes #45

Merged
merged 4 commits into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/actions.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,10 @@ situation (e.g. redirect, signal an error, etc.)."))
(reblocks/request:get-parameters)))
(params (list* (cons *action-string*
action-code)
old-params)))
(remove *action-string*
old-params
:key #'car
:test #'string-equal))))
(concatenate 'string
(get-path) ;; Current URL path
"?"
Expand Down
18 changes: 18 additions & 0 deletions src/doc/changelog.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@
"REBLOCKS/SESSION:INIT")
:external-links (("Ultralisp" . "https://ultralisp.org"))
:external-docs ("https://40ants.com/log4cl-extras/"))
(0.54.0 2023-10-22
"""
Added
=====

Function REBLOCKS/REQUEST:GET-REMOTE-IP was added.

Fixed
=====

Now function REBLOCKS/ACTIONS:MAKE-ACTION-URL removed old `action` argument if it is present in the
current URL. This fixes the case when you want to make an action url from the callback processing
another action.

JavaScript function `initiateFormAction` now does not overwrites whole options.args object,
but only replaces the keys corresponding to a form data fields.

""")
(0.53.0 2023-06-20
"""
Changed
Expand Down
2 changes: 2 additions & 0 deletions src/doc/request.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"HTTP"
"AJAX"
"HTML"
"IP"
"JSON"
"URL"))
"""
Expand All @@ -38,6 +39,7 @@
(reblocks/request:remove-header function)
(reblocks/request:get-uri function)
(reblocks/request:get-path function)
(reblocks/request:get-remote-ip function)
(reblocks/request-handler:handle-request generic-function)
(reblocks/request-handler:handle-ajax-request generic-function)
(reblocks/request-handler:*request-timeout* variable)
Expand Down
2 changes: 1 addition & 1 deletion src/js/jquery/jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function initiateFormAction(actionCode, form, options) {
var action_arguments = form.serializeObjectWithSubmit();
delete(action_arguments['action']);

options['args'] = action_arguments;
options['args'] = Object.assign({}, options.args || {}, action_arguments);
options['method'] = options['method'] || form.attr('method');
initiateAction(actionCode, options);
}
Expand Down
12 changes: 11 additions & 1 deletion src/request.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
(:import-from #:quri)
(:import-from #:str
#:split)
(:import-from #:lack.request
#:request-remote-addr)

(:export #:get-parameters
#:get-parameter
Expand All @@ -42,7 +44,8 @@
#:get-path
#:with-request
#:pure-request-p
#:get-cookie))
#:get-cookie
#:get-remote-ip))
(in-package #:reblocks/request)


Expand Down Expand Up @@ -234,3 +237,10 @@ if there is an action involved (even if the user hits refresh)."
,result)))


(defun get-remote-ip (&key (request *request*))
"Returns a possible user's IP.

Note, it may not be reliable, because user might try to set these headers manually."
(or (get-header "x-real-ip" :request request)
(get-header "x-forwarded-for" :request request)
(request-remote-addr request)))