Hammerspoon: Load javascript file from local file://, instead of local web server

Created on 9 Apr 2019  路  6Comments  路  Source: Hammerspoon/hammerspoon

Hi:

It that possible to load javascript from local storage like <script src="file://abc/def/ghi/jkl.js"></script> instead of local web server inside hs.webview:html?

I already read the documents and search all issues about local files webview before asking.

I try to figure it out, but no lucks. :(

https://github.com/asmagill/hammerspoon-config/blob/bf186c7636c73eaab43467711712c6191c274320/utils/_keys/cheatsheet.lua#L232

All 6 comments

You definitely can... I use Resty to make templating easier:

https://dev.commandpost.io/bundled-extensions/resty

@latenitefilms Thanks, would you mind give me more detail examples about how to include javascript from local directory through resty template?

Take @asmagill's configuration for example, what's the difference if I generate the HTML string directly or compiled through the resty template engine?

Sorry, I鈥檓 on the road, so just quickly replying on my phone. Here鈥檚 how we鈥檙e using it:

https://github.com/CommandPost/CommandPost/blob/develop/src/plugins/finalcutpro/hud/manager/init.lua

In @asmagill鈥檚 example he鈥檚 firing up a web server via Hammerspoon and accessing the JS file through that via the webview.

See https://github.com/asmagill/hammerspoon-config/issues/5 for my solution to get around requiring a local web server

@asmagill Thanks for your help, I already follow your method and use the javascript from local directory through webview.usercontent.

@latenitefilms Thanks for help, I am still reading your code, and try to figure how you solve issue. through resty template engine.

I'll close this issue, and thanks for all of your help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

franzwr picture franzwr  路  3Comments

aaronjensen picture aaronjensen  路  3Comments

iliyang picture iliyang  路  4Comments

fent picture fent  路  3Comments

latenitefilms picture latenitefilms  路  4Comments