Skip to content

wtfiscrq/webview

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WebView

Installation | Usage | Documentation | License

Build cross platform desktop apps with Elixir and web technologies.

This library provides Elixir bindings for the webview library to allow easy creation of cross platform Elixir desktop apps with GUIs based on web technologies.

The webview library uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and MSHTML (IE10/11) on Windows, making this a good alternative to Electron.

Check the NIF project to track the implementation progress.

It's recommended to also read the webview readme for a better understanding of how the library works behind the scenes. You'll also find a list of bindings in other languages there.

Disclaimer: this is work in progress (early development) and breaking changes will most probably occur without notice, currently not production-ready.

Installation

WebView can be installed by adding webview to your list of dependencies in mix.exs:

def deps do
  [
    {:webview, github: "und0ck3d/webview"}
  ]
end

Will be published on Hex when 0.1.0 is released.

Usage

Starting WebView

iex> opts = [title: "Hello, WebView!", url: "https://elixir-lang.org"]
iex> WebView.start(opts)

Alternatively you may add WebView to a supervision tree:

webview_config = [title: "Hello, WebView!", url: "https://elixir-lang.org"]

children = [
  {WebView, webview_config}
]

Manipulating WebView

(after having started WebView)

Set the title:

WebView.set_title("Elixir is awesome!")

Set fullscreen:

WebView.set_fullscreen(true) # Turns fullscreen on
WebView.set_fullscreen(false) # Turns fullscreen off

Evaluate JavaScript code:

WebView.eval("console.log('Hi, from Elixir!')")

Injectg CSS styles:

WebView.inject_css("body { background: #000; color: #fff; }")

Currently it isn't possible to update neither the page's URL nor the HTML directly using zserge/webview because the library doesn't have support for it. Those and other additional features will be added to WebView in the future to easily allow different use cases (such as update the HTML directly, implement navigation on back-end, use a web server such as Phoenix, SPAs and more).

For more examples, please check the examples directory.

Documentation

Documentation isn't available online. You can generate it locally with:

$ mix docs

Contributing

Contributions are very welcome, specially improvements to the NIF and the Makefile to support cross platform.

For now, simply fork this repository and make the changes, open an issue and create a pull request. Don't forget to run mix format before committing, please.

License

Both und0ck3d/webview and zserge/webview projects are released under the MIT license.

About

Build cross platform desktop apps with Elixir and web technologies.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published