Skip to content
This repository has been archived by the owner on Oct 15, 2023. It is now read-only.

Commit

Permalink
v0.4.4: LatestRelease <- Development
Browse files Browse the repository at this point in the history
  • Loading branch information
lmbek authored Jan 1, 2023
2 parents b308837 + e9bac13 commit 0388e44
Show file tree
Hide file tree
Showing 13 changed files with 145 additions and 44 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ example/generate
*.android
*.linux
example/resource.syso
go.work.sum
118 changes: 118 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,120 @@
# go-local-web-example
(This readme is a duplicate of go-local-web-gui)

go-local-web (GOLW) is a simple framework made for developing localhosted software that can reuse chrome/chromium or embed chromium (in future releases). Both available in deployment for the applications.

This framework uses Chrome (Windows) or Chromium (Linux) as frontend by opening them with cmd/terminal and hosting a localhost webserver, while opening chrome/chromium with --app and --user-directory arguments. The frontend can be changed by the user in runtime, while the backend needs to be compiled/build. The API can be decoupled in future versions, so every part of the application is changeable - Sustainable development. Frontends is easy to change. Alternatives to this is embedding a chromium or webview framework into the project, which will require more space. I chose to depend on Chrome/Chromium, as they are market leaders and html/css/javascript technology frontrunners.

Feel free to use this piece of software, I will be happy to assist you

I am currently working on this project, it will be updated and maintained. I consider it production ready.

This project is used by Beksoft ApS for projects such as:
* BekCMS
* (name not announced yet) Password Manager
* PingPong Game made in Three.js
* Several local webbased software projects

Write to me at [email protected] if you want to have your project listed

## Requirements to developers
Go 1.19+
Chrome (Windows) or Chromium (Linux)

## Requirements for users
Chrome (Windows) or Chromium (Linux)

## How to use (download example project)
The best way to start using the project is to download the example project at:
https://github.com/NineNineFive/go-local-web-example

This example project uses this package and combines it with a local api
Then the Go api is being developed and customized by you together with the frontend (JavaScript, HTML, CSS)

## How to use (with go get)
first run the following in CMD (with go installed)
<code>go get github.com/NineNineFive/go-local-web-gui</code>
Example: how to add framework to main.go
<pre>
package main

import (
"github.com/NineNineFive/go-local-web-gui/fileserver"
"github.com/NineNineFive/go-local-web-gui/launcher"
"net/http"
"os"
"runtime"
)

// For windows we need a organisation name and project name
var organisationName = "NewOrganisationName" // put in organisation name
var projectName = "NewProjectName" // put in project name

var frontendPath = "./frontend" // this should be set to where frontend files is (frontend folder: html, css, javascript...)

// remember to change the ports to something unique
var chromeLauncher = launcher.ChromeLauncher{
Location: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
LocationCMD: "C:\\\"Program Files\"\\Google\\Chrome\\Application\\chrome.exe",
FrontendInstallLocation: os.Getenv("localappdata") + "\\Google\\Chrome\\InstalledApps\\" + organisationName + "\\" + projectName,
Domain: "localhost",
PortMin: 11430,
PreferredPort: 11451,
PortMax: 11500,
}

var chromiumLauncher = launcher.DefaultChromiumLauncher // default chrome or chromium launcher settings can be used like this
/* // Otherwise they can also be customized like this
var chromiumLauncher = launcher.ChromiumLauncher{
Location: "/var/lib/snapd/desktop/applications/chromium_chromium.desktop", // TODO: check if better location or can be customised
Domain: "localhost",
PortMin: 11430,
PreferredPort: 11451,
PortMax: 11500,
}
*/

func main() {
launchApp()
}

func initHTTPHandlers() {
// static fileserver
http.HandleFunc("/", fileserver.ServeFileServer)

// api (local api can be added)
//http.HandleFunc("/api/", api.ServeAPIUseGZip)
}

func launchApp() {
switch runtime.GOOS {
case "windows":
initHTTPHandlers()
launcher.StartFrontendAndBackendWindows(frontendPath, chromeLauncher)
return
case "darwin": // "mac"
panic("Darwin Not Supported Yet")
return
case "linux": // "linux"
initHTTPHandlers()
launcher.StartFrontendAndBackendLinux(frontendPath, chromiumLauncher)
return
default: // "freebsd", "openbsd", "netbsd"
initHTTPHandlers()
launcher.StartFrontendAndBackendLinux(frontendPath, chromiumLauncher)
return
}
}
</pre>

## How to run
<code>go run main.go</code>

## How to apply manifest and logo to executible
Use something like goversioninfo: https://github.com/josephspurrier/goversioninfo

## How to build
<code>go build -ldflags -H=windowsgui -o NewProjectName.exe</code>

## How to make setup file and update functionality
Coming later
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions backend/api/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module api
go 1.19 // go version should be minimum 1.18
File renamed without changes.
21 changes: 0 additions & 21 deletions backend/go-local-web-api/LICENSE

This file was deleted.

2 changes: 0 additions & 2 deletions backend/go-local-web-api/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions backend/go-local-web-api/go.mod

This file was deleted.

4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module go-local-web-gui
module GoLWExample

go 1.19

require github.com/NineNineFive/go-local-web-gui v0.4.3 // indirect
require github.com/NineNineFive/go-local-web-gui v0.4.9 // indirect
4 changes: 2 additions & 2 deletions go.work
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
use .
use ./backend/go-local-web-api/
use ./backend/go-local-web-api/example
use ./backend/api
use ./backend/api/example
34 changes: 20 additions & 14 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// ** Reason Of Framework Explained **
// This application is meant to find a port and launch a frontend in chrome (windows) or chromium (linux).
// Meanwhile, it will open a http localhost backend with an api.
// The API package at /development/backend/api/ can be replaced to fit another application,
// The API package at ./backend/api/ can be replaced to fit another application,
// if the framework is to be used for other applications.
// It is important to note, that the system will require a frontend directory and a data directory,
// when the application is tested and released, these will also need to be managed (other applications can be put in)
Expand All @@ -30,55 +30,61 @@ import (
"runtime"
)

var projectName = "NewProjectName"
var organisationName = "NewCompanyName"
// For windows we need a organisation name and project name
var organisationName = "NewOrganisationName" // put in organisation name
var projectName = "NewProjectName" // put in project name

// var address = "localhost:10995"
var frontendPath = "./frontend"
var frontendPath = "./frontend" // this should be set to where frontend files is (frontend folder: html, css, javascript...)

var chromeLauncher = launcher.ChromeLauncher{
Location: "C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe",
LocationCMD: "C:\\\"Program Files\"\\Google\\Chrome\\Application\\chrome.exe",
FrontendInstallLocation: os.Getenv("localappdata") + "\\Google\\Chrome\\InstalledApps\\" + organisationName + "\\" + projectName,
Domain: "localhost",
PortMin: 19430,
PreferredPort: 19451,
PortMax: 19500,
PortMin: 11430,
PreferredPort: 11451,
PortMax: 11500,
}

var chromiumLauncher = launcher.DefaultChromiumLauncher // default chrome or chromium launcher settings can be used like this
/* // Otherwise they can also be customized like this
var chromiumLauncher = launcher.ChromiumLauncher{
Location: "/var/lib/snapd/desktop/applications/chromium_chromium.desktop", // TODO: check if better location or can be customised
Domain: "localhost",
PortMin: 19430,
PreferredPort: 19451,
PortMax: 19500,
PortMin: 11430,
PreferredPort: 11451,
PortMax: 11500,
}
*/

func main() {
launchApp()
}

func initHTTPHandlers() {
// static fileserver
http.HandleFunc("/", fileserver.ServeFileServer)

// api (local api is at ./backend/api)
http.HandleFunc("/api/", api.ServeAPIUseGZip)
}

func launchApp() {
switch runtime.GOOS {
case "windows":
initHTTPHandlers()
launcher.StartFrontendAndBackendWindows(frontendPath, chromeLauncher)
launcher.StartOnWindows(frontendPath, chromeLauncher)
return
case "darwin": // "mac"
panic("Darwin Not Supported Yet")
return
case "linux": // "linux"
initHTTPHandlers()
launcher.StartFrontendAndBackendLinux(frontendPath, chromiumLauncher)
launcher.StartOnLinux(frontendPath, chromiumLauncher)
return
default: // "freebsd", "openbsd", "netbsd"
initHTTPHandlers()
launcher.StartFrontendAndBackendLinux(frontendPath, chromiumLauncher)
launcher.StartOnLinux(frontendPath, chromiumLauncher)
return
}
}

0 comments on commit 0388e44

Please sign in to comment.