Skip to content

Commit

Permalink
update wails & json editor
Browse files Browse the repository at this point in the history
  • Loading branch information
lyimmi committed Sep 8, 2022
1 parent 0ed4269 commit f9abe76
Show file tree
Hide file tree
Showing 33 changed files with 930 additions and 1,006 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
!/build/windows/icon.ico
!/build/appicon.png
node_modules/
.idea
.idea
frontend/dist
15 changes: 12 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

## About

This template uses vanilla JS / HTML and CSS.
This is a simple json enditor made with [wails](https://wails.io) and [jsoneditor](https://github.com/josdejong/jsoneditor)

You can configure the project by editing `wails.json`. More information about the project settings can be found
here: https://wails.io/docs/reference/project-config
jsoneditor has nice features, so this is a wrapper around it, can be used to open json files as default appication.


## Desktop file & default application

Change the json-editor.desktop file and copy it to `~/.local/share/applications`.


If you would like to use it as default for *.json, add a new line `application/json=json-editor.desktop` to `~/.local/share/applications/defaults.list`

Sould be able to register it on first start, maybe this could be added later.

## Live Development

Expand Down
10 changes: 4 additions & 6 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package main

import (
"context"
"io/ioutil"
"log"
"os"
"path/filepath"

Expand Down Expand Up @@ -45,7 +43,7 @@ func (a *App) startup(ctx context.Context) {
if len(args) > 0 {
a.jsonFilePath = args[0]
a.jsonFileName = filepath.Base(a.jsonFilePath)
a.jsonFile, err = ioutil.ReadFile(a.jsonFilePath)
a.jsonFile, err = os.ReadFile(a.jsonFilePath)
if err != nil {
runtime.EventsEmit(a.ctx, "error", err.Error())
}
Expand Down Expand Up @@ -183,7 +181,7 @@ func (a *App) Open() bool {
}

a.jsonFileName = filepath.Base(a.jsonFilePath)
a.jsonFile, err = ioutil.ReadFile(a.jsonFilePath)
a.jsonFile, err = os.ReadFile(a.jsonFilePath)
if err != nil {
runtime.EventsEmit(a.ctx, "error", err.Error())
}
Expand Down Expand Up @@ -214,9 +212,9 @@ func (a *App) Save() bool {
}
}

log.Println(a.jsonFilePath)
// log.Println(a.jsonFilePath)

err = ioutil.WriteFile(a.jsonFilePath, a.jsonFile, 0644)
err = os.WriteFile(a.jsonFilePath, a.jsonFile, 0644)
if err != nil {
runtime.EventsEmit(a.ctx, "error", err.Error())
return false
Expand Down
14 changes: 14 additions & 0 deletions frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE HTML>
<html lang="en">

<head>
<!-- when using the mode "code", it's important to specify charset utf-8 -->
<meta charset="utf-8">
</head>

<body>
<div id="jsoneditor"></div>
<script src="./src/main.js" type="module"></script>
</body>

</html>
Loading

0 comments on commit f9abe76

Please sign in to comment.