Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 26 13:52
    heylisp commented #57
  • Jan 25 10:34
    svetlyak40wt commented #57
  • Jan 25 09:10
    heylisp opened #57
  • Jan 24 01:10

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 24 01:07

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 17 01:10

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 17 01:05

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 12 22:30

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 12 22:29

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 12 22:09

    svetlyak40wt on reblocks

    Changed a library used to log u… Merge pull request #56 from 40a… (compare)

  • Jan 12 22:09
    svetlyak40wt closed #56
  • Jan 12 20:46
    svetlyak40wt opened #56
  • Jan 12 20:44

    svetlyak40wt on move-to-log4cl-extras

    Changed a library used to log u… (compare)

  • Jan 10 15:35
    svetlyak40wt opened #55
  • Jan 10 01:13

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 10 01:06

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 03 01:12

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 03 01:06

    svetlyak40wt on gh-pages

    Update docs (compare)

  • Jan 01 16:39
    bamboospirit commented #53
  • Jan 01 16:38
    bamboospirit commented #53
Alexander Artemenko
@svetlyak40wt
2020-09-24 23.08.21.gif
What is amazing is that this example needs only a one line of JavaScript code:
initiateActionWithArgs(\"~A\", \"\", {\"value\": this.value})
Alexander Artemenko
@svetlyak40wt

I definitely need to refactor this part of the Weblocks a little bit and to write a good documentation chapter.

If only I had more time to work on it! :(

Alexander Artemenko
@svetlyak40wt
By the way, interesting consequence of the server-side rendering is that autocompletion list remains opened in the same state, when you reload the page :-D
bamboospirit
@bamboospirit
In a weblocks app how to serve a static folder , so that I can include files from it in the html mainpage-widget renders? like this:
(:link :rel "stylesheet" :type "text/css" :href "css/style.css" )
tried this:
(push (hunchentoot:create-folder-dispatcher-and-handler "/css/" "/lisp/app/css/") hunchentoot:*dispatch-table*)
bamboospirit
@bamboospirit
but it doesn't work
Alexander Artemenko
@svetlyak40wt

@bamboospirit you can call weblocks/server:serve-static-file method somewhere in the init-session.

Here is an example:

https://github.com/ultralisp/ultralisp/blob/0d01b7b3eea796bb6451a9c2ab914a8afc07cb2f/src/widgets/spinner.lisp#L42

13 replies
bamboospirit
@bamboospirit
If anyone happens to have a Username+Password simple authentication example for weblocks please share
Alexander Artemenko
@svetlyak40wt
Do you mean Basic Auth?
bamboospirit
@bamboospirit
no, session/cookie based authentication
Alexander Artemenko
@svetlyak40wt
bamboospirit
@bamboospirit
ok. to use it I have to extend the generic methods?
Alexander Artemenko
@svetlyak40wt

Here you will find examples how to use it:

https://github.com/ultralisp/ultralisp/search?q=weblocks-auth

I definitely need to add more documentation :(
bamboospirit
@bamboospirit
Can weblocks/routes (defroutes) easily be extended to have something like Role Based authentication? I already have some roles in the db: guest,user,admin and some users: user1 , admin1 and some access_levels: public (means any guest, user or admin can access it), user (means only users and admins can access it), admin (means only admins can access it)
the machinery for this is easy, just a bitmask needs to be checked when the user accesses the route . (the session cookie is checked to figure out what role the currently logged in user has )
so in the end I just need to add a keyword to the defroutes
(defroutes_enchanced tasks-routes
  ("/tasks/\\d+" (make-task-page) :access_level 'admin)
  ("/tasks/" (make-task-list)) :access_level 'public)
Alexander Artemenko
@svetlyak40wt

Currently weblocks-auth does not support roles.

I implement this on appication level by making links (in database) between weblocks-auth/models:user and application models.

Feel free to experiment with role models. Probably we could incorporate it into the weblocks-auth library.

bamboospirit
@bamboospirit
so it's not difficult to implement it at application level, on top of it, right ? I'll experiment
Alexander Artemenko
@svetlyak40wt
Yes, let me know if you'll need some help!
bamboospirit
@bamboospirit
Okay
Mariano Montone
@mmontone
Hello! I've implemented an extension to forms that handles callbacks per field, like Seaside does.
It makes very easy to handle complicated forms.
(weblocks/forms:with-form
          (:post (lambda (&rest args)
                   #+nil(apply #'update-entity-action
                               entity
                               args)
                   )
           :class "card")
        (:div :class "card-body"
              (:div :class "form-group"
                    (:label :class "form-label" "Name")
                    (:input :name (callback (value)
                                    (setf (dbapp::entity-name entity) value))
                            :class "form-control" :type "text"
                            :value (dbapp::entity-name entity)))

              (:div :class "form-group"
                    (:label :class "form-label" "Description")
                    (:textarea :name (callback (value)
                                       (setf (dbapp::entity-description entity) value))
                               :class "form-control"
                               (dbapp::entity-description entity)))

              (:div :class "form-group"
                    (:label :class "form-label" "Attributes")
                    (loop for attribute in (dbapp::attributes (entity widget))
                          do (render (make-instance 'attribute-editor :attribute attribute))
                          (:button :type "button"
                             :class "btn btn-secondary"
                             :onclick (submit-form-action ()
                                        (setf (dbapp::attributes entity)
                                              (delete attribute (dbapp::attributes entity)))
                                         (update widget))
                             (:i :class "fa fa-trash")))
                    (:button :type "button"
                             :class "btn btn-secondary"
                             :onclick (submit-form-action ()
                                        (push (make-instance 'dbapp::attribute
                                                              :name ""
                                                              :type (make-instance 'dbapp::string-attribute-type))
                                               (cdr (last (dbapp::attributes entity))))
                                         (update widget))

                             (:i :class "fa fa-plus"))))
        (:div :class "card-footer"
              (:input :type "submit" :value "Update")))
Like that, see callback and submit-form-action.
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.
Mariano Montone
@mmontone
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