Giter Site home page Giter Site logo

wtfiscrq / webview Goto Github PK

View Code? Open in Web Editor NEW
23.0 1.0 0.0 45 KB

Build cross platform desktop apps with Elixir and web technologies.

License: MIT License

Elixir 7.56% Makefile 0.81% C 91.63%
elixir nif webview cross-platform-desktop javascript html css

webview's Introduction

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.

webview's People

Contributors

wtfiscrq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

webview's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.