svetlyak40wt on reblocks
Added a warning about deprecate… (compare)
svetlyak40wt on reblocks
A note in the readme. (compare)
svetlyak40wt on new-documentation
Added a welcome screen on "/" t… base: show a more friendly erro… Removed weblocks-scripts system. and 10 more (compare)
Hello! I'm using Weblocks to make a webcomic website for a friend and I'm infinitely grateful for a way to create nice modern websites while completely avoiding Javascript. :)
Now, to the problem I'm having. The big picture: toasts.
The currently smaller picture: Making them disappear on timer.
I'll send a link to what I have now in a few minutes. It doesn't remove toasts on timer, and it asks the server to render them all every time one is created or closed (which is not a big deal really since it's the server code which creates the toasts anyway).
calling (update mywidget) from a new thread
How to make a new thread aware of the *session'* it was created from ?
executable code to illustrate the problem: https://gist.github.com/bamboospirit/e6ad95503ec40d2c7649f4aa14ad4979#file-thr-update-lisp
github issue 40ants/weblocks#54
(defmacro define-attic (attic-name routes &key (prefix "/"))
(with-gensyms (app route-name)
`(progn
(defapp ,attic-name :prefix ,prefix)
(defroutes ,route-name
,@routes)
(defmethod weblocks/session:init ((,app ,attic-name))
(declare (ignorable ,app))
(,(alexandria:symbolicate :make- route-name))))))
(defun start-attic (port)
(weblocks/server:start :port port))
(define-attic attic
(("/" (with-html (:h1 "Hello")))))
(start-attic 40002)
@C-Entropy I suggest you to create an app's prototype without all this macrology first. When it will work, start creating an abstractions.
Also, please, provide a full reproducable piece of code with the package definition. This way it will be easier to help you.
And use triple backticks ` to post formatted code like this:
(defmacro define-attic (attic-name routes &key (prefix "/"))
(with-gensyms (app route-name)
`(progn
(defapp ,attic-name :prefix ,prefix)
(defroutes ,route-name
,@routes)
(defmethod weblocks/session:init ((,app ,attic-name))
(declare (ignorable ,app))
(,(alexandria:symbolicate :make- route-name))))))
(defun start-attic (port)
(weblocks/server:start :port port))
(define-attic attic
(("/" (with-html (:h1 "Hello")))))
(start-attic 40002)
("/" (with-html ...))
is wrong
("/" (make-instance 'hello))
(defmethod render ((hello hello))
(with-html (:h1 "Hello hello")))
, am I right?
Yes, this is how it should be used.
Here is the real world example: https://github.com/ultralisp/ultralisp/blob/f2cb634fb302d3fec98c1ad98e6759e4f6060af3/src/widgets/main.lisp#L43-L69
Do you mean you want to make some page have a special header?
There is no easy way, but you might do the following:
(defvar *additional-headers*)
render :around
method to wrap this one: https://github.com/40ants/weblocks/blob/reblocks/src/page.lisp#L103-L129. In this method you need to bind *additional-headers*
to NIL
.render-headers :after
method for https://github.com/40ants/weblocks/blob/reblocks/src/page.lisp#L59-L85 and render content of *additional-headers*
.*additional-headers*
.This way you will be able to extend header from widgets, rendered to the page.
But this will work only for the initial loading of the page. When some widgets will be updated o replaced/created by AJAX, header will not change.
If you want to modify a visible header, then the best way will be to make it as a widget and to update it as any other widget.
(with-html-form (:POST
(lambda (&key file text &allow-other-keys)
(format t "~a ~a~%" file text))
:enctype "multipart/form-data")
(:p "Please choose a file:")
(:input :type "file"
:name "file")
(:input :type "text"
:name "text")
(:input :type "submit"
:value "Upload"))
Sooo … I'm on https://40ants.com/weblocks/quickstart.html
(render task-1) gives the error message
<DEBUG> [17:25:01] weblocks/widgets/render-methods render-methods.lisp (render :around) -
debugger invoked on a SIMPLE-ERROR in thread
#<THREAD "main thread" RUNNING {70052141F3}>:
Please, use push-dependency in code, wrapped with with-collected-dependencies macro.
and the web app is not interactive. The debugger says
<ERROR> [17:27:03] weblocks/request-handler request-handler.lisp (handle-request :around app h0) -
Unhandled exception
<WARN> [17:27:03] weblocks/request-handler request-handler.lisp (handle-request :around app h0) -
Invoking interactive debugger because Weblocks is in the debug mode
Any help with this, please?
I'm on sbcl 2.1.5 on an m1 MacBook Pro.
why is root widget session-wise global ? why is it not restricted to a single app: the root widget of that specific app.
https://github.com/40ants/weblocks/blob/reblocks/src/widgets/root.lisp#L11
(weblocks/widgets/root:get)
Here is the code of this prototype:
This is only an MVP now, I'll extract it into a separate ASDF system soon.