Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 05 11:27

    svetlyak40wt on reblocks

    Added a warning about deprecate… (compare)

  • Jan 05 11:23
    svetlyak40wt transferred #19
  • Jan 05 11:23
    svetlyak40wt transferred #20
  • Jan 05 11:23
    svetlyak40wt transferred #27
  • Jan 05 11:22
    svetlyak40wt transferred #28
  • Jan 05 11:22
    svetlyak40wt transferred #37
  • Jan 05 11:22
    svetlyak40wt transferred #49
  • Jan 05 11:22
    svetlyak40wt transferred #50
  • Jan 05 11:22
    svetlyak40wt transferred #51
  • Jan 05 11:22
    svetlyak40wt transferred #52
  • Jan 05 11:21
    svetlyak40wt transferred #53
  • Jan 05 11:21
    svetlyak40wt transferred #54
  • Jan 05 11:21
    svetlyak40wt transferred #55
  • Jan 05 11:21
    svetlyak40wt transferred #57
  • Jan 05 11:20
    svetlyak40wt transferred #59
  • Jan 05 10:25
    svetlyak40wt transferred #60
  • Jan 05 10:24
    svetlyak40wt closed #62
  • Jan 05 10:24

    svetlyak40wt on reblocks

    A note in the readme. (compare)

  • Dec 09 2021 20:20
    svetlyak40wt synchronize #62
  • Dec 09 2021 20:20

    svetlyak40wt on new-documentation

    Added a welcome screen on "/" t… base: show a more friendly erro… Removed weblocks-scripts system. and 10 more (compare)

Fabien Pelletier
@fabienpelletier
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.

6 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 *. :)
bamboospirit
@bamboospirit
(weblocks/widgets/root:get) is global for all apps running on the same server (for example under port 40000) . But that means you can't render different apps (with the same hostnames , but different prefixes, let's say), since if the prefix for app1 is first opened in the browser, then (handle-request app1) https://github.com/40ants/weblocks/blob/reblocks/src/request-handler.lisp#L371 will set a root widget in the session , then when you want to access the prefix for app2 , it will still render then widget for app1
bamboospirit
@bamboospirit

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)

3 replies
vindarel
@vindarel
Hey. An important widget of my web apps is an ajax-based typeahead, like this one: https://github.com/twitter/typeahead.js/
How would you approach this in Weblocks?
It is a widget very much client-based, tied to HTML and JS. To make it async, we need an ajax call to an API. So I suppose as soon as we do this, we loose the link to Weblocks' components. I wonder if it would be possible to tie the ajax call to a Lisp function.
I should study the typeahead internals in more depth.
1 reply
Alexander Artemenko
@svetlyak40wt
reblocks-outliner-demo6-autocompletion.gif
@vindarel take a look at the demo above. This is the first prototype of the Reblocks Typeahead widget!

Here is the code of this prototype:

This is only an MVP now, I'll extract it into a separate ASDF system soon.

vindarel
@vindarel
This is so cool, and what a coincidence indeed! I'm looking at everything (I am following the projects so I saw the commits).
You're the best ;) :]
Kevin Diale
@powersurge360
I was exploring the reblocks documentation and it looks like the heroku app powering the demos has an error
seems to be failing and is asking to check the logs
Alexander Artemenko
@svetlyak40wt

Interesring. For me examples are working. And I can't see historical logs showing error you've got.

@powersurge360 can you reproduce this error?

Kevin Diale
@powersurge360
@svetlyak40wt it looks as though it's back up now. I suppose it could have been a blip on heroku's side.
I had an empty white box for a long time and eventually realized that it was probably not loading and inspected it to see that there was a frame there and looked at that on another page and it hung for ages and ages and had a heroku level error message that said to check the logs. Since I can't reproduce it, I don't have anything significant to contribute.
I haven't used frames in ages, but I wonder if there's a way to detect if it receives a 500 error to catch a whiff of the smoke if it busts up again. If this is the first/only time this has been reported to you, may just be a fluke. On the other hand, I had to do a couple of steps to see the error message, it didn't show up in the frame, so it could just be a confusing failure that people don't alert you on and it happens more frequently
Alexander Artemenko
@svetlyak40wt

Usually iframe shows any error page without problems. Slow Heroku response is because it starts apps on demand and puts it back to sleep, when there is no requests for some period of time.

Nobody else did not report such problems.

deeznaughts
@deeznaughts
Hey guys. New lisper here - I know this is a weblocks chat, bear with me :). Between this framework and caveman2, which one would you recommend someone who just learnt scheme before trying to do a mid-size app on lisp?
2 replies