https://github.com/promignis/knack
cross platform framework using web technologies
https://github.com/promignis/knack
Last synced: about 1 year ago
JSON representation
cross platform framework using web technologies
- Host: GitHub
- URL: https://github.com/promignis/knack
- Owner: Promignis
- Created: 2018-08-05T21:15:12.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-12T10:30:49.000Z (over 7 years ago)
- Last Synced: 2025-04-04T22:51:14.378Z (over 1 year ago)
- Language: Go
- Homepage:
- Size: 4.56 MB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Knack
Knack is a framework to build cross platform applications using the web stack -
HTML, CSS and Javascript.
It is built using https://github.com/zserge/webview as the webview.
The size is much smaller compared to electron.
It is under development.
`go get github.com/promignis/knack`
Current usage(**it will change**)
html/svg files in views folder (will pick index.html by default)
css files in styles folder
js files in js folder
image files in images folder
### Inject
```js
window.onRuntimeLoad = function() {
_runtime.loadView("contacts.html") // replaces the current html with ./views/contacts.html
_runtime.loadCss("filename.css") // injects from ./styles/filename.css
_runtime.loadJs("bundle.js") // injects from ./js/bundle.js
_runtime.loadImage("test.png", "test") // injects ./images/test.png to img tag with id "test"
}
```
### Files
Open file and get data in callback(will open native file browser)
```js
_runtime.openFile((fileData) => {
// do something with file data
})
```
if callback not present returns Promise
```js
_runtime.openFile().then(fileData => {
})
```
Save file with `fileData`
```js
_runtime.saveFile(fileData)
```
### Fuzzy match
Do fuzzy match over a any dictionary
```js
// dict, word, levenshtein_distance, callback
_runtime.fuzzyMatch(["asd", "abc"], "ab", 1, (results) => {
// returns array of results
// in this case "abc" as 1 distance away from "ab"
})
```
if callback not present it returns Promise
```js
_runtime.fuzzyMatch(["asd", "abc"], "ab", 1).then(results => {
// output
})
```
### Examples
Fuzzy search on files
```js
_runtime.getFileWalker("../", (fileList) => {
let fileDict = JSON.parse(fileList).map(file => file.name)
_runtime.fuzzyMatch(fileDict, "main.g", 3, (fuzzyResults) => {
})
})
```
if you have [babel-async-await](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-async-to-generator) setup
```js
_runtime.getFileWalker("../", async (fileList) => {
let fileDict = JSON.parse(fileList).map(file => file.name)
let fuzzyResults = await _runtime.fuzzyMatch(fileDict, "main.g", 3)
})
```
better use via Promises
`getFileWalker is planned to return Promise in future`
## OSX
### Build
`./build-app.sh`
### Run
`./run-app.sh`