mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Refactor: Moved Go app to the root and fixed links.
This commit is contained in:
parent
d1de67910d
commit
7157d43168
28 changed files with 100 additions and 164 deletions
17
.air.toml
Normal file
17
.air.toml
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Working directory
|
||||
root = "."
|
||||
|
||||
# The main Go file
|
||||
main = "main.go"
|
||||
|
||||
bin = "tmp/main.exe"
|
||||
|
||||
# Watching all Go files, excluding certain directories
|
||||
[build]
|
||||
cmd = "go build -o ./tmp/main.exe main.go"
|
||||
include_ext = ["go"]
|
||||
exclude_dir = ["fe", "panels", "builds"]
|
||||
|
||||
# Restart on file changes
|
||||
[log]
|
||||
time = true
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
|
|
@ -1,9 +1,11 @@
|
|||
.env
|
||||
config.js
|
||||
|
||||
be/devices/*
|
||||
be/tmp/
|
||||
be/log.txt
|
||||
devices/*
|
||||
tmp/
|
||||
log.txt
|
||||
|
||||
Macrame.exe
|
||||
|
||||
public
|
||||
macros/*
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
package app
|
||||
|
||||
import (
|
||||
"be/app/helper"
|
||||
"macrame/app/helper"
|
||||
"mime"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
|
|
@ -45,7 +45,7 @@ func ApiCORS(w http.ResponseWriter, r *http.Request) (http.ResponseWriter, *http
|
|||
}
|
||||
|
||||
func ApiGet(w http.ResponseWriter, r *http.Request) {
|
||||
root, err := filepath.Abs("../public")
|
||||
root, err := filepath.Abs("public")
|
||||
if err != nil {
|
||||
MCRMLog("ApiGet Abs Error: ", err)
|
||||
return
|
||||
|
|
@ -22,10 +22,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
package app
|
||||
|
||||
import (
|
||||
"be/app/helper"
|
||||
"be/app/structs"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"macrame/app/helper"
|
||||
"macrame/app/structs"
|
||||
"math/rand"
|
||||
"net"
|
||||
"net/http"
|
||||
|
|
@ -28,8 +28,8 @@ import (
|
|||
"net/http"
|
||||
"strings"
|
||||
|
||||
"be/app/structs"
|
||||
. "be/app/structs"
|
||||
"macrame/app/structs"
|
||||
. "macrame/app/structs"
|
||||
)
|
||||
|
||||
func EndpointAccess(w http.ResponseWriter, r *http.Request) (bool, string, error) {
|
||||
|
|
@ -30,9 +30,10 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
var configPath = "../public/config.js"
|
||||
var configPath = "public/config.js"
|
||||
|
||||
func EnvGet(key string) string {
|
||||
|
||||
if !configFileExists() {
|
||||
CreateConfigFile(configPath)
|
||||
CheckFeDevDir()
|
||||
|
|
@ -64,9 +65,10 @@ func configFileExists() bool {
|
|||
|
||||
func CheckFeDevDir() {
|
||||
log.Println("Checking FE dev directory...")
|
||||
_, err := os.Stat("../fe")
|
||||
_, err := os.Stat("fe")
|
||||
|
||||
if err != nil {
|
||||
log.Println("Error checking FE dev directory:", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -74,14 +76,14 @@ func CheckFeDevDir() {
|
|||
}
|
||||
|
||||
func copyConfigToFe() {
|
||||
data, err := os.ReadFile("../public/config.js")
|
||||
data, err := os.ReadFile(configPath)
|
||||
|
||||
if err != nil {
|
||||
log.Println("Error reading config.js:", err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := os.WriteFile("../fe/config.js", data, 0644); err != nil {
|
||||
if err := os.WriteFile("fe/config.js", data, 0644); err != nil {
|
||||
log.Println("Error writing config.js:", err)
|
||||
}
|
||||
}
|
||||
|
|
@ -31,8 +31,8 @@ import (
|
|||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"be/app/helper"
|
||||
"be/app/structs"
|
||||
"macrame/app/helper"
|
||||
"macrame/app/structs"
|
||||
)
|
||||
|
||||
func CheckMacro(w http.ResponseWriter, r *http.Request) {
|
||||
|
|
@ -47,7 +47,7 @@ func CheckMacro(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var filename = helper.FormatMacroFileName(req.Macro)
|
||||
|
||||
macroFile, err := helper.ReadMacroFile(fmt.Sprintf("../macros/%s.json", filename))
|
||||
macroFile, err := helper.ReadMacroFile(fmt.Sprintf("macros/%s.json", filename))
|
||||
|
||||
if macroFile != nil && err == nil {
|
||||
json.NewEncoder(w).Encode(true)
|
||||
|
|
@ -85,7 +85,7 @@ func SaveMacro(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
err = os.WriteFile("../macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644)
|
||||
err = os.WriteFile("macros/"+helper.FormatMacroFileName(newMacro.Name)+".json", stepsJSON, 0644)
|
||||
if err != nil {
|
||||
MCRMLog("SaveMacro WriteFile Error: ", err)
|
||||
return
|
||||
|
|
@ -117,7 +117,7 @@ func simplifyMacro(step structs.Step) map[string]interface{} {
|
|||
}
|
||||
|
||||
func ListMacros(w http.ResponseWriter, r *http.Request) {
|
||||
dir := "../macros"
|
||||
dir := "macros"
|
||||
files, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
MCRMLog("ListMacros ReadDir Error: ", err)
|
||||
|
|
@ -154,7 +154,7 @@ func DeleteMacro(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
var filename = helper.FormatMacroFileName(req.Macro)
|
||||
|
||||
err = os.Remove("../macros/" + filename + ".json")
|
||||
err = os.Remove("macros/" + filename + ".json")
|
||||
|
||||
if err != nil {
|
||||
MCRMLog("DeleteMacro Remove Error: ", err)
|
||||
|
|
@ -180,7 +180,7 @@ func PlayMacro(data string, w http.ResponseWriter, r *http.Request) {
|
|||
MCRMLog("Playing Macro: ", macro)
|
||||
|
||||
var filename = helper.FormatMacroFileName(macro)
|
||||
var filepath = fmt.Sprintf("../macros/%s.json", filename)
|
||||
var filepath = fmt.Sprintf("macros/%s.json", filename)
|
||||
|
||||
macroFile, err := helper.ReadMacroFile(filepath)
|
||||
if err != nil {
|
||||
|
|
@ -208,7 +208,7 @@ func OpenMacro(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
macroFile, err := helper.ReadMacroFile(fmt.Sprintf("../macros/%s.json", req.Macro))
|
||||
macroFile, err := helper.ReadMacroFile(fmt.Sprintf("macros/%s.json", req.Macro))
|
||||
|
||||
if err != nil {
|
||||
MCRMLog("OpenMacro ReadMacroFile Error: ", err)
|
||||
|
|
@ -22,17 +22,17 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|||
package app
|
||||
|
||||
import (
|
||||
"be/app/helper"
|
||||
"be/app/structs"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"macrame/app/helper"
|
||||
"macrame/app/structs"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func PanelList(w http.ResponseWriter, r *http.Request) {
|
||||
panelDirs, err := os.ReadDir("../panels")
|
||||
panelDirs, err := os.ReadDir("panels")
|
||||
if err != nil {
|
||||
MCRMLog("PanelList ReadDir Error: ", err)
|
||||
json.NewEncoder(w).Encode(false)
|
||||
|
|
@ -59,7 +59,7 @@ func PanelList(w http.ResponseWriter, r *http.Request) {
|
|||
func getPanelInfo(dirname string) structs.PanelInfo {
|
||||
var panelInfo structs.PanelInfo
|
||||
|
||||
jsonFile, err := os.ReadFile("../panels/" + dirname + "/panel.json")
|
||||
jsonFile, err := os.ReadFile("panels/" + dirname + "/panel.json")
|
||||
|
||||
if err != nil {
|
||||
panelInfo.Name = strings.Replace(dirname, "_", " ", -1)
|
||||
|
|
@ -86,7 +86,7 @@ func getPanelThumb(dirname string) string {
|
|||
|
||||
for _, ext := range extensions {
|
||||
filename := "thumbnail" + ext
|
||||
file, err := os.Open("../panels/" + dirname + "/" + filename)
|
||||
file, err := os.Open("panels/" + dirname + "/" + filename)
|
||||
if err != nil {
|
||||
MCRMLog("getPanelThumb Open Error: ", err)
|
||||
continue
|
||||
|
|
@ -100,8 +100,8 @@ func getPanelThumb(dirname string) string {
|
|||
}
|
||||
|
||||
func getPanelCode(dirname string) (html string, css string) {
|
||||
htmlBytes, _ := os.ReadFile("../panels/" + dirname + "/index.html")
|
||||
cssBytes, _ := os.ReadFile("../panels/" + dirname + "/output.css")
|
||||
htmlBytes, _ := os.ReadFile("panels/" + dirname + "/index.html")
|
||||
cssBytes, _ := os.ReadFile("panels/" + dirname + "/output.css")
|
||||
|
||||
return string(htmlBytes), string(cssBytes)
|
||||
}
|
||||
|
|
@ -153,7 +153,7 @@ func SavePanelJSON(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
filePath := "../panels/" + req.Dir + "/panel.json"
|
||||
filePath := "panels/" + req.Dir + "/panel.json"
|
||||
|
||||
req.Dir = ""
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package app
|
||||
|
||||
import (
|
||||
"be/app/helper"
|
||||
"macrame/app/helper"
|
||||
"os"
|
||||
|
||||
"github.com/getlantern/systray"
|
||||
52
be/.air.toml
52
be/.air.toml
|
|
@ -1,52 +0,0 @@
|
|||
root = "."
|
||||
testdata_dir = "testdata"
|
||||
tmp_dir = "tmp"
|
||||
|
||||
[build]
|
||||
args_bin = []
|
||||
bin = "tmp\\main.exe"
|
||||
cmd = "go build -o ./tmp/main.exe ."
|
||||
delay = 1000
|
||||
exclude_dir = ["assets", "tmp", "vendor", "testdata"]
|
||||
exclude_file = []
|
||||
exclude_regex = ["_test.go"]
|
||||
exclude_unchanged = false
|
||||
follow_symlink = false
|
||||
full_bin = ""
|
||||
include_dir = []
|
||||
include_ext = ["go", "tpl", "tmpl", "html"]
|
||||
include_file = []
|
||||
kill_delay = "0s"
|
||||
log = "build-errors.log"
|
||||
poll = false
|
||||
poll_interval = 0
|
||||
post_cmd = []
|
||||
pre_cmd = []
|
||||
rerun = false
|
||||
rerun_delay = 500
|
||||
send_interrupt = false
|
||||
stop_on_error = false
|
||||
|
||||
[color]
|
||||
app = ""
|
||||
build = "yellow"
|
||||
main = "magenta"
|
||||
runner = "green"
|
||||
watcher = "cyan"
|
||||
|
||||
[log]
|
||||
main_only = false
|
||||
silent = false
|
||||
time = false
|
||||
|
||||
[misc]
|
||||
clean_on_exit = false
|
||||
|
||||
[proxy]
|
||||
app_port = 0
|
||||
enabled = false
|
||||
proxy_port = 0
|
||||
|
||||
[screen]
|
||||
clear_on_rebuild = false
|
||||
keep_scroll = true
|
||||
BIN
be/Macrame.exe
BIN
be/Macrame.exe
Binary file not shown.
BIN
be/Setup.exe
BIN
be/Setup.exe
Binary file not shown.
BIN
be/main.exe
BIN
be/main.exe
Binary file not shown.
|
|
@ -1,31 +0,0 @@
|
|||
/*
|
||||
Macrame is a program that enables the user to create keyboard macros and button panels.
|
||||
The macros are saved as simple JSON files and can be linked to the button panels. The panels can
|
||||
be created with HTML and CSS.
|
||||
|
||||
Copyright (C) 2025 Jesse Malotaux
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import "be/app/helper"
|
||||
|
||||
func main() {
|
||||
helper.CreateConfigFile("../public/config.js")
|
||||
helper.CheckFeDevDir()
|
||||
|
||||
return
|
||||
}
|
||||
|
Before Width: | Height: | Size: 191 KiB After Width: | Height: | Size: 191 KiB |
|
|
@ -1,8 +1,11 @@
|
|||
module be
|
||||
module macrame
|
||||
|
||||
go 1.24.0
|
||||
go 1.24.1
|
||||
|
||||
require github.com/go-vgo/robotgo v0.110.7
|
||||
require (
|
||||
github.com/getlantern/systray v1.2.2
|
||||
github.com/go-vgo/robotgo v0.110.7
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dblohm7/wingoes v0.0.0-20240820181039-f2b84150679e // indirect
|
||||
|
|
@ -14,7 +17,6 @@ require (
|
|||
github.com/getlantern/hex v0.0.0-20190417191902-c6586a6fe0b7 // indirect
|
||||
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
|
||||
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
|
||||
github.com/getlantern/systray v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||
github.com/go-stack/stack v1.8.0 // indirect
|
||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||
|
|
@ -25,16 +25,15 @@ import (
|
|||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"be/app"
|
||||
"be/app/helper"
|
||||
"macrame/app"
|
||||
"macrame/app/helper"
|
||||
)
|
||||
|
||||
func main() {
|
||||
app.MCRMLogInit()
|
||||
|
||||
switchToBeDir()
|
||||
switchDir()
|
||||
|
||||
if helper.EnvGet("MCRM__PORT") == "" {
|
||||
app.MCRMLog("Error: MCRM__PORT is not set")
|
||||
|
|
@ -53,17 +52,14 @@ func main() {
|
|||
app.MCRMLog(http.ListenAndServe(":"+helper.EnvGet("MCRM__PORT"), nil))
|
||||
}
|
||||
|
||||
func switchToBeDir() {
|
||||
func switchDir() {
|
||||
cwd, err := os.Getwd()
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
if !strings.HasSuffix(cwd, "be") {
|
||||
err := os.Chdir("be")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
log.Println(cwd)
|
||||
}
|
||||
|
||||
func apiInit(w http.ResponseWriter, r *http.Request) {
|
||||
Loading…
Add table
Add a link
Reference in a new issue