Open Symbolics opened 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.
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.
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.
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:
*browser-executable*
and*browser-options*
to indicate user specific browser optionsplot
that will use UIOP to launch the browser and display the HTML generated bycreateplot
*create-instance*
variable as a flag to enable this functionalityplot
symbol as the user accessible APIAdditional considerations:
plot/
directory just below the main directory for default plots. This can be overridden by the user on a per-project basis.*browser-options*
, since they are browser-specific. The example/default will use Google Chrome, since doing this with Firefox is somewhat challenging.