Publii icon indicating copy to clipboard operation
Publii copied to clipboard

"Preview your changes" opens Sublime Text and not a browser

Open Prinzhorn opened this issue 3 years ago • 3 comments

I'm on Ubuntu and my default application for HTML files is Sublime Text, which makes this line open Sublime Text when I want to preview my changes:

https://github.com/GetPublii/Publii/blob/d3d2c759c112a271007d5640c49a53aeca1ea345/app/back-end/events/preview.js#L161

I see at least three solutions

  1. Allow me to specify an application to use for the preview somewhere in the settings (or maybe even detect my default browser?)
  2. Don't use file:/// but launch a web server. shell.openExternal should then open my default browser when given an http:// url. This would also have other benefits, as file:/// has certain limitations (e.g. I'm getting "Unsafe attempt to load URL" errors in the web console)
  3. Use Electron? Why not open a new BrowserWindow and keep it around for previewing? Either via the server from 2 or sth. like https://www.npmjs.com/package/electron-serve . This would completely eliminate all cross platform issues and give the Publii developers full control over the preview process (think of all the things a preload script can do).

I'm currently evaluating Publii as a static CMS to be used by non-technical people. And clicking this button was one of the very first interactions I had with Publii and it would probably throw non-technical people off. I think it would be great if such a core component could be made more robust and user-friendly (this rules out solution 1 as it requires understand the problem which a regular user would definitely not).

Prinzhorn avatar Oct 05 '20 09:10 Prinzhorn

The same thing happens to me in deepin (Distribution based on debian). The text editor opens. This needs to be improved in some way...

wuniversales avatar Oct 05 '20 10:10 wuniversales

Hi @Prinzhorn

  1. Unfortunately it is impossible to specify a program for openExternal

  2. An idea of launching super-light local webserver sounds good, and also it will solve the problem with point 1. because it will use http protocol which will run default browser

  3. We have abandon an idea of the preview window built in the app, because there is a lot of issues with <webview> and also there is absolutely no need to replicate features of the available browsers for the preview purpose. Also this solution is limited to the Chromium-based engines, which can be quite problematic for the developers who prefers Firefox during development.

I will check what we can do with including simple webserver inside the Publii - because it will solve two issues:

  • always opening preview in the web browser
  • problem with loading SVG maps (we have solution for that, but it needs an additional work)

dziudek avatar Oct 05 '20 20:10 dziudek