rabbibotton / clog

CLOG - The Common Lisp Omnificent GUI
Other
1.53k stars 106 forks source link

Change static-root path #147

Closed timoteipalade closed 2 years ago

timoteipalade commented 2 years ago

Hi! This project is really cool! You put a lot of love into it, and it shows at every step. 🥇

My issue is the following. I want to change the static-root path. Here is what I have tried so far, which does not work:

(defpackage #:playground
  (:use #:cl #:clog))

(in-package :playground)

(defun on-new-window (body) 
  "On-new-window handler."
  (set-on-load-script
   (html-document body)
   (lambda (obj data)
     (js-execute body "console.log('Hi')"))
   :one-time t)
  (load-script (html-document body) "plotly-2.12.1.min.js")
  (let ((plot-div (create-div body :html-id "plot")))
    (setf (attribute plot-div "style") "width:600px;height:250px;"))
  (js-execute body "Plotly.newPlot( document.getElementById('plot'), [{ x: [1, 2, 3, 4, 5], y: [1, 2, 4, 8, 16] }], {margin: { t: 0 } } );")
  (js-execute body "console.log('Hi');"))

(defun start-playground ()
  "Start tutorial."        
  (initialize
   #'on-new-window
   :static-root #P"/Users/me/Documents/Developer/Lisp/CandlesAndSticks/static-files/")
  (open-browser))
rabbibotton commented 2 years ago

Any time you change the static path you have to clog:shutdown and then clog:initialize again. Otherwise if that path exists looks ok to me. Let me know if that works

timoteipalade commented 2 years ago

It worked! 🚀 The path changed:

Screenshot 2022-06-19 at 19 58 07

But I ran into another head scratcher. I copied the files under clog/static-files to my static-files folder.

Screenshot 2022-06-19 at 20 05 57

It is complaining that it cannot load jQuery, which is really weird, since it exists. Tried clog:shutdown and then initialize again. Also restarted inferior lisp. Here is what I see in the console:

Screenshot 2022-06-19 at 20 01 17

Somehow only boot.js gets loaded 🤔 :

Screenshot 2022-06-19 at 20 02 17
rabbibotton commented 2 years ago

By default if boot.js is missing it uses a compiled version. You can see if you have access to jQuery by typing http://127.0.0.1:8080/js/jquery.min.js

Btw you can do the following: (ql:quickload :clog/tools) (clog-tools:clog-new-app)

to use a template to setup a new project. You may find that easier.

timoteipalade commented 2 years ago

Thanks!

I found the issue. Forward slash was missing at the end of my path:

OLD: #P"/Users/paladetimotei/Documents/Developer/Lisp/CandlesAndSticks/static-files NEW: #P"/Users/paladetimotei/Documents/Developer/Lisp/CandlesAndSticks/static-files/

🤯 😆

Maybe we can add a message warning people not to forget that forward slash 🤔

rabbibotton commented 2 years ago

Awsome :)