From 3060cf7abdf23777f80f0e2e65f9d422d71f7f5e Mon Sep 17 00:00:00 2001 From: Sandro Turriate Date: Fri, 22 Jan 2021 14:38:38 -0800 Subject: [PATCH] Add explanation for the fork --- README.md | 71 ++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 7946d79..223cbf6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,58 @@ # Lorca +## Sandro Fork + +This fork was created to provide access to the absolute path of uploaded files by evaluating a provided [FileList](https://developer.mozilla.org/en-US/docs/Web/API/FileList). + +### Example + +This example shows a file upload field. Javascript binds to the `change` event of the field to add the provided files to a globally accessible array variable (`window.files`), then passes that variable to our Go program. + +Our Go program queries the path for each file in `window.files` then returns the absolute paths to javascript. + +```go +ui, _ := lorca.New("data:text/html,"+url.PathEscape(` + +Hello + + + + + +`), "", 480, 320) +defer ui.Close() + +ui.Bind("filesAdded", func(listVar string, length int) []string { + paths := make([]string, length) + for i := 0; i < length; i++ { + tm, err := ui.EvalRaw(fmt.Sprintf("window.%s[%d]", listVar, i)) + if err != nil { + log.Printf("error evaluating window.%s. err: %s\n", listVar, err) + } + path, err := lorca.GetFilePath(ui, tm.Result.Result.ObjectID) + if err != nil { + log.Println(err) + } else { + paths[i] = path + } + } + return paths +}) + +// Wait for the browser window to be closed +<-ui.Done() +``` + [![Build Status](https://img.shields.io/github/workflow/status/zserge/lorca/CI%20Pipeline)](https://github.com/zserge/lorca) [![GoDoc](https://godoc.org/github.com/zserge/lorca?status.svg)](https://godoc.org/github.com/zserge/lorca) [![Go Report Card](https://goreportcard.com/badge/github.com/zserge/lorca)](https://goreportcard.com/report/github.com/zserge/lorca) @@ -8,11 +61,11 @@ Lorca

- A very small library to build modern HTML5 desktop apps in Go. It uses Chrome - browser as a UI layer. Unlike Electron it doesn't bundle Chrome into the app - package, but rather reuses the one that is already installed. Lorca - establishes a connection to the browser window and allows calling Go code - from the UI and manipulating UI from Go in a seamless manner. + A very small library to build modern HTML5 desktop apps in Go. It uses Chrome + browser as a UI layer. Unlike Electron it doesn't bundle Chrome into the app + package, but rather reuses the one that is already installed. Lorca + establishes a connection to the browser window and allows calling Go code + from the UI and manipulating UI from Go in a seamless manner.


@@ -23,7 +76,7 @@ * Pure Go library (no cgo) with a very simple API * Small application size (normally 5-10MB) * Best of both worlds - the whole power of HTML/CSS to make your UI look - good, combined with Go performance and ease of development + good, combined with Go performance and ease of development * Expose Go functions/methods and call them from JavaScript * Call arbitrary JavaScript code from Go * Asynchronous flow between UI and main app in both languages (async/await and Goroutines) @@ -32,15 +85,15 @@ * Supports testing your app with the UI in the headless mode * Supports multiple app windows * Supports packaging and branding (e.g. custom app icons). Packaging for all - three OS can be done on a single machine using GOOS and GOARCH variables. + three OS can be done on a single machine using GOOS and GOARCH variables. Also, limitations by design: * Requires Chrome/Chromium >= 70 to be installed. * No control over the Chrome window yet (e.g. you can't remove border, make it - transparent, control position or size). + transparent, control position or size). * No window menu (tray menus and native OS dialogs are still possible via - 3rd-party libraries) + 3rd-party libraries) If you want to have more control of the browser window - consider using [webview](https://github.com/zserge/webview) library with a similar API, so