RodrigoZepeda / d3lisp

A d3js interface for creating plots in LISP
https://rodrigozepeda.github.io/d3lisp/index.html
MIT License
3 stars 0 forks source link

Clean up browser handling #5

Open Symbolics opened 5 years ago

Symbolics commented 5 years ago

The previous version had the ability to display a plot by starting up an instance of the browser. The code was marked as having issues running elsewhere than MacOS/SBCL.

I propose to implement functionality to view a plot interactively from the REPL by:

Additional considerations:

Symbolics commented 5 years ago

I've got this working with a modification of the original code:

;; Browser variables
;; You will need to experiment with the values of *browser-options* to
;; tune the output as you like. In the Chrome example below, the
;; browser will open a new window, without any controls, address bar
;; or tabs. It is a view-only window for the plot. Firefox does not
;; have this option from the command line, instead requiring you to
;; configure a profile, and then pass the profile to Firefox on the
;; command line.

;;  (defparameter *browser* "C:\\Program Files (x86)\\Mozilla Firefox\\firefox.exe")
(defparameter *browser* "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe")
(defparameter *browser-options* "--app=")
  (uiop:run-program `(,*browser*
              ;; This is ugly. There must be a better way. Maybe make-pathname?
              ,(concatenate 'string *browser-options* "file:///" (namestring (merge-pathnames (concatenate 'string filename ".html")))))))

I suggest moving the defparameter statements into d3-init.lisp to hold things required to be configured by the user. The UIOP statement is so simple that it could be moved into create-plot and its execution controlled by the value of *create-instance* or a new parameter to create-plot (better -- don't rely on global variables unless necessary). This seems better than creating a wrapper function just to pop up a browser.

Symbolics commented 5 years ago

Reopening this and assigning to myself. Trivial-open-browser seems a cross-platform and better thought out way of doing this than what I came up with. Will investigate.

Symbolics commented 4 years ago

I had a look at this today. Trivial-open-browser (TOB) does not allow passing browser options. I've opened up a feature request in the TOB repository for this functionality to be added.

I also updated the title if this issue to reflect the real purpose: clean up browser handling. Using TOB is probably better then reinventing the wheel, but an alternative is to adopt its code and place it into a browser.lisp file within this repository.