rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.51k stars 104 forks source link

Tutorial 12, missing "No dice!" #64

Closed nnoodle closed 2 years ago

nnoodle commented 3 years ago

The default router never gets to say "No Dice!". On tutorial 12, when going to a route that is not /tutorial/tut-11.html nor any of the other handled paths like /page1, it instead says "Not Found".

rabbibotton commented 3 years ago

Sorry for delay. I am not sure what the issue is? CLOG generally deals with all routing beyond routes static-files/ Is there something you are looking to accomplish?

nnoodle commented 3 years ago

Thanks for the reply! What I want to accomplish is being able to route things in a way much like easy-routes, so that I could define a route like /foo/:x/:y and get whatever is :x and :y was, and it looked like using the "default" path was the entry point to do that.

But I wasn't able to get my default handler to do its thing, so I looked to the tutorial. What the on-default handler looks like it does if none of the other paths match is: it'll run on-tutorial11 if the pathname is "/tutorial/tut-11.html", or display "No dice!" if it isn't. It works as expected when I go to "/tutorial/tut-11.html", but I did not get "No dice!" when I tried something like "/not-a-real-path", instead I just got "Not found".

Apologies if I completely misunderstood what "default" is suppose to do since its documentation mentions using boot-file.

rabbibotton commented 2 years ago

Routing currently in CLOG is based on what path you associate with you handler is SET-ON-NEW-WINDOW. If you set :PATH to "" than that handler is called if there is no other path to a handler is set. It is possible in that handler (the default handler) to do your own routing by using the functions in clog-location.lisp to look at the url and then just call the handler function you want with the body parameter.

rabbibotton commented 2 years ago

For some reason I think I overlooked your issue, and didn't fully understand it or your issue. My deepest apologies. My focus for next release is on "website" development were previously it was on the GUI side predominantly.

The current concept of a "default" route as in tutorial 12 is about a very different situation, and my documentation should have been more clear (fixing). It is the default in a case where a static html file includes the boot.js file but there is no route to specify which on-new-window-handler should handle on the lisp side that page, a far more limited situation.

What you are looking for and now I am working on is a way to handle default URL paths, a far more common website situation.

rabbibotton commented 2 years ago

I have pushed some updates to tutorial 12 and other files with better documentation. I am still working on default url paths.

rabbibotton commented 2 years ago

I have added "extended-routing" on initializing clog, when enabled allows routes to be extended such that /page1 would also handle /page1/any/thing/you/want

I may still in the future added something similar to easy-routes but the same thing is easily accomplished now by pattern matching on (path-name (location body)) in the handler.