{"id":18258702,"url":"https://github.com/maaarcocr/webview_ruby","last_synced_at":"2025-04-04T19:31:59.106Z","repository":{"id":56898030,"uuid":"458328125","full_name":"Maaarcocr/webview_ruby","owner":"Maaarcocr","description":"WebViewRuby is a library that provide bindings for webview/webview a tiny tiny cross-platform webview library to build modern cross-platform GUIs","archived":false,"fork":false,"pushed_at":"2023-04-03T14:15:17.000Z","size":48,"stargazers_count":45,"open_issues_count":3,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-31T13:59:43.435Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Maaarcocr.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-11T20:17:04.000Z","updated_at":"2024-10-21T19:14:56.000Z","dependencies_parsed_at":"2022-08-21T02:20:30.443Z","dependency_job_id":null,"html_url":"https://github.com/Maaarcocr/webview_ruby","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fwebview_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fwebview_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fwebview_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Maaarcocr%2Fwebview_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Maaarcocr","download_url":"https://codeload.github.com/Maaarcocr/webview_ruby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223154337,"owners_count":17096730,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-05T10:34:01.682Z","updated_at":"2024-11-05T10:34:02.348Z","avatar_url":"https://github.com/Maaarcocr.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WebviewRuby\n\nWebViewRuby is a library that provide bindings for [webview/webview](https://github.com/webview/webview) a tiny tiny cross-platform webview library to build modern cross-platform GUIs. Webview uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and Edge on Windows 10.\n\nIMPORTANT: Compilation may not work on windows right now. Follow the progress [here](https://github.com/Maaarcocr/webview_ruby/issues/1)\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'webview_ruby'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install webview_ruby\n\n## Usage\n\n### Hello World\n\nCreate a new Webview instance \n\n```ruby\nwebview = WebviewRuby::Webview.new\n```\n\nSet the size and the title of the window\n\n```ruby\nwebview.set_title(\"Example\")\nwebview.set_size(480, 360)\n```\n\nNavigate to a specific webpage\n\n```ruby\nwebview.navigate(\"https://en.m.wikipedia.org/wiki/Main_Page\")\n```\n\nThen run the main loop till its terminated (remember to always destroy the webview after it stops running)\n\n```ruby\nwebview.run\nwebview.destroy\n```\n\n### Run ruby code from JS\n\nYou can bind a ruby function to a JavaScript one before the webview is in running state. To do so use the `bind` method like:\n\n```ruby\nwebview.bind(\"exampleFunc\") do\n  print(\"got called by js\")\nend\n```\n\nNow you can use `exampleFunc` as any other JS function, you can call it from the javascript that has been loaded in the webview or\nfrom the html. If you want to make a function take some parameters, just add parameters to the `do` block like so: \n\n```ruby\nwebview.bind(\"exampleFunc\") do |arg1, arg2|\n  print(\"got called by js with #{arg1} and #{arg2}\")\nend\n```\n\nYou can only use positional arguments, keyword ones wouldn't work.\n\n### Run JS code from ruby\n\nYou can invoke JS code to be run asynchrounously (the result of the execution won't be returned to you) by running\n\n```ruby\nwebview.eval(\"console.log('Called from ruby')\")\n```\n\n### Terminate the main loop\n\n```\nwebview.terminate\n```\n\n### Run JS code at initialisation\n\nIf you want to inject JavaScript code at the initialization of the new page, such that every time the webview will open a the new page - this initialization code will be executed, then you can use\n\n```ruby\nwebview.init(\"console.log('running at initialisation')\")\n```\n\nIt is guaranteed that code is executed before window.onload.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Maaarcocr/webview_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/webview_ruby/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the WebviewRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/webview_ruby/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaaarcocr%2Fwebview_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaaarcocr%2Fwebview_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaaarcocr%2Fwebview_ruby/lists"}