rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.48k stars 101 forks source link

Change url in CLOG wichout reloading page #234

Closed ebrasca closed 1 year ago

ebrasca commented 1 year ago

How to change the url without reloading the page?

Thank you!

rabbibotton commented 1 year ago

I added now (git pull for it):

(defgeneric url-rewrite (clog-window rewrite-url)
  (:documentation "Rewrite browser history and url with REWRITE-URL
no redirection of browser takes place. REWRITE-URL must be same domain."))

example:

(clog:url-rewrite (window *body*) "http://127.0.0.1:8080/newurl")
ebrasca commented 1 year ago

Thank you , it works.

Maybe it is a good idea to make a function to edit just the html arguments in the URL.

Have a nice day!

rabbibotton commented 1 year ago

You may want to look at source/clog-location.lisp (methods on the locaton object) there are many url editing functions there. Strangely rewriting the URL was not one of them (actually there are but they cause redirection).

ebrasca commented 1 year ago

I asked you after watching in that file. I like your library so far. I am learning it.

rabbibotton commented 1 year ago

Can you give me an example then of what you mean by url editing functions? Maybe worth adding.

ebrasca commented 1 year ago

For example: Image Viewer that displays all images in a directory I based it on https://github.com/rabbibotton/clog/blob/main/tutorial/27-tutorial.lisp When you click in the image I like it to also change url to be able to share the link to the same image. the url can become domain/?image-name=100.png When you open the page you read the html arguments an initialize the page with them.

I think something like this may be useful: (with-html-arguments (image-name arg2 arg3 &rest rest) (url-search (location body)) body)

(setf (url-search (location body)) (format nil "?image-name=~a" (value lbox))) Without reloading the page!

I am experimenting with what can be done with your library , I hope something may be useful.

Thank you!

rabbibotton commented 1 year ago

You may want to take a look at Quri (clog depends on it, so already there) - https://github.com/fukamachi/quri I'll read this through more carefully tomorrow.

rabbibotton commented 1 year ago

Too bleary eyed to look over but 2 votes :) means we have to do something nice.

rabbibotton commented 1 year ago

I modified tutorial 27 to use url-rewrite and to use load the img passed with ?img=x as long as x in our select box. Sorry took me so long to get to this.