Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jun 13 01:16

    svetlyak40wt on gh-pages

    Update docs (compare)

  • May 04 13:10
    ebrasca opened #61
  • Apr 13 17:10
    heylisp commented #57
  • Mar 15 05:13
    C-Entropy commented #60
  • Mar 15 02:10
    C-Entropy edited #60
  • Mar 14 16:18
    C-Entropy commented #60
  • Mar 14 16:06
    C-Entropy commented #60
  • Mar 14 16:04
    C-Entropy commented #60
  • Mar 14 16:04
    C-Entropy commented #60
  • Mar 14 16:03
    C-Entropy commented #60
  • Mar 14 16:03
    C-Entropy commented #60
  • Mar 14 16:01
    C-Entropy commented #60
  • Mar 14 15:35
    svetlyak40wt commented #60
  • Mar 14 15:17
    C-Entropy edited #60
  • Mar 14 15:04
    C-Entropy opened #60
  • Mar 05 14:24
    C-Entropy closed #58
  • Mar 05 14:24
    C-Entropy commented #58
  • Mar 05 10:26
    C-Entropy commented #59
  • Mar 05 09:32
    C-Entropy commented #59
  • Mar 05 09:20
    C-Entropy commented #58
Mariano Montone
@mmontone
I think it is an interesting extension to try to integrate to the current forms system.
callback receives the submited value.
submit-form-action handles a form submit for some form button, making sure that no field values are lost in the process.
Let me know if you are interested in integrating something like this.
vindarel
@vindarel
+1!
Alexander Artemenko
@svetlyak40wt
Oh, this is really interesting. I'm working on new features for Ultralisp and there will be more forms with editable fields.
Mariano Montone
@mmontone
Ok, you can give a try perhaps. I implemented it because I have some complexity in my forms. It works perfectly so far, and it is very simple implementation.
You are going to need this changed weblocks function implementation:
(defun get-request-action (action-name &key (ignore-missing-actions *ignore-missing-actions*))
  "Gets an action from the request. If the request contains
*action-string* parameter, the action is looked up in the session and
appropriate function is returned. If no action is in the parameter,
returns nil. If the action isn't in the session (somehow invalid),
raises an assertion."
  (when action-name
    (let* ((app-wide-action (weblocks/app-actions:get-action action-name))
           (session-action (get-session-action action-name))
           (request-action (or app-wide-action session-action)))
      ;; TODO: rethink this form. May be throw a special condition instead of string
      (unless ignore-missing-actions
        (assert request-action (request-action)
                (concatenate 'string "Cannot find action: " action-name)))
      request-action)))
Just added that key parameter
As I didn't want to have to use a dynamic binding when calling that function.
bamboospirit
@bamboospirit
https://github.com/40ants/weblocks/blob/reblocks/src/routes.lisp#L42
what if I have to redefine a route which already exists? I have to restart the entire lisp system
bamboospirit
@bamboospirit
during interactive development, when using
(weblocks/server:serve-static-file "/static/gear.gif"
path
:content-type "image/gif")
for example.
Alexander Artemenko
@svetlyak40wt
No, you can call reset-routes(https://github.com/40ants/weblocks/blob/reblocks/src/routes.lisp#L55) and reload your system.
Fabien Pelletier
@fabienpelletier
just discovered this and went through the quickstart, and honestly it feels like magic. Thank you so much for this piece of software!
I've been procrastinating learning CL because any web stuff I do will have JS and I don't want to touch that.
Mariano Montone
@mmontone
Here is the latest version of Weblocks forms with callbacks support: https://gist.github.com/mmontone/ef332817abe2c99f8a46f54b74210297
Alexander Artemenko
@svetlyak40wt
:+1:
vindarel
@vindarel
@fabienpelletier Welcome! How did you avoid JS so far?
9 replies
bamboospirit
@bamboospirit
any idea how to achieve this Realtime effect using weblocks ? https://youtu.be/MZvmYaFkNJI?t=419
2 replies
naryl
@naryl

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).

3 replies
bamboospirit
@bamboospirit
is there a way to (update (weblocks/widgets/root:get)) for all sessions from within the repl ?
15 replies
bamboospirit
@bamboospirit
"Click on the "render many" button and wait for it to finish rendering.
Then click again on "render many" and without delay click on "render few"
You will see that AFTER "render few" (the last action from the UI) has finished doing its work,
the results will be replaced by an older action from the UI ...
How to avoid this? In a filtering widget for example, typing a word fast will result in the wrong filtration of a long list.
(after if finishes rendering the newest results according to the last input word, it will then render the previous results from the previous UI action when
the word was only partially typed into the box)"
https://justpaste.it/77h4x
2 replies
bamboospirit
@bamboospirit
related to the issue above is the fact that sbcl sometimes reports hash-table concurrent access error because make-js-action is called in render methods which are being executed concurrently
Alexander Artemenko
@svetlyak40wt
@bamboospirit please, create GitHub issues for all these problems. Will try to fix them in the new year.
1 reply
bamboospirit
@bamboospirit

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

C-Entropy
@C-Entropy
Hi, could anyone tell me where I'm wrong?

(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)

It just give "Hello" the first time I viewed.
Alexander Artemenko
@svetlyak40wt

@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)
C-Entropy
@C-Entropy
I see, it seems that defroutes accepts an instace and then use corresponding render to render it.
So I thik ("/" (with-html ...)) is wrong
The correct one should be ("/" (make-instance 'hello))
and (defmethod render ((hello hello)) (with-html (:h1 "Hello hello"))), am I right?
C-Entropy
@C-Entropy
it should be something like this
(defwidget task ()
  ())
(defroutes tasks-routes
    ("/?" (make-instance 'task)))

(defmethod render ((hello hello))
  (with-html (:h1 "Hello hello")))
Alexander Artemenko
@svetlyak40wt
C-Entropy
@C-Entropy
Thank you!
C-Entropy
@C-Entropy
Hi, is there anyway to render html-head for a single route/page?
Alexander Artemenko
@svetlyak40wt

Do you mean you want to make some page have a special header?

There is no easy way, but you might do the following:

  1. define a special variable like (defvar *additional-headers*)
  2. define an 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.
  3. define a custom render-headers :after method for https://github.com/40ants/weblocks/blob/reblocks/src/page.lisp#L59-L85 and render content of *additional-headers*.
  4. during rendering of the widget, add new pieces of header to *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.

C-Entropy
@C-Entropy
I am sorry that it is difficult for me to understand, do you have any example code? Right now I'm trying to write a new widget called page, wchich can be used to contain head stuff, and then rewrite router and page.lisp(or maybe just page.lisp? change (app app) to (page page) in render). But I don't know is this thinking reasonably. How do you say?
Bruno Cichon
@ebrasca
Can you upload files with something like this?
(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"))
In my case when I try to send a file I get: nil some-text
In hunchentoot I file is a list with tmp-pathname-of-file , file-name and file-type
Alexander Artemenko
@svetlyak40wt

Hi, @ebrasca !

I didn't try to upload files. Probably this is not supported or broken.

Right now I have no time to experiment with this. Could you please add such issue on the github just to be sure that this problem will receive attention some day?

Bruno Cichon
@ebrasca
Hi, @svetlyak40wt ! Issue done!
Alexander Artemenko
@svetlyak40wt
:+1:
Rolf Marvin Bøe Lindgren
@rolfmblindgren

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.

3 replies
Alexander Artemenko
@svetlyak40wt

Interesing. I need some time to recheck the tutorial on the latest Weblocks and SBCL.

By the way, just to be sure. Aren't you trying to call render task-1 from the REPL?

Rolf Marvin Bøe Lindgren
@rolfmblindgren
No, the formatter removes the *. :)