Skip to content

Commit

Permalink
Release 0.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
aceberg committed Sep 20, 2024
1 parent 9b6b5da commit 77b8270
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 472 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# These are supported funding model platforms

custom: https://aceberg.github.io/MyDocs/sponsor
custom: ['https://boosty.to/aceberg/donate', 'https://github.com/aceberg#donate']
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION=0.1.4
VERSION=0.1.5
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## [0.1.5] - 2024-09-20
### Added
- Theme `dark` and `light` option
- Local Node modules option

## [0.1.4] - 2023-05-20
### Changed
- Log page update
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fmt:
go fmt ./...

lint:
# golangci-lint run
golangci-lint run
golint ./...

check: fmt lint
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ You can do all configuration through web interface. Config files paths are liste
```
`config.yaml` example:
```yaml
color: light
host: 0.0.0.0
nodepath: ""
port: "8844"
theme: cosmo
```
Expand All @@ -103,6 +105,7 @@ theme: cosmo
| -------- | ----------- | ------- | --- | --- |
| -c | Path to GUI config file |./config.yaml| $HOME/.config/git-syr/config.yaml | /etc/git-syr/config.yaml |
| -l | Path to log file | ./git-syr.log | $HOME/.config/git-syr/git-syr.log | /var/log/git-syr.log |
| -n | Path to [local node modules](/~https://github.com/aceberg/my-dockerfiles/tree/main/node-bootstrap) | | | |
| -r | Path to repos yaml file |./repos.yaml| $HOME/.config/git-syr/repos.yaml | /etc/git-syr/repos.yaml |
| -w | Launch without web gui | false | | |

Expand Down
4 changes: 3 additions & 1 deletion cmd/git-syr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (
const confPath = "config.yaml"
const yamlPath = "repos.yaml"
const logPath = "git-syr.log"
const nodePath = ""

func main() {
confPtr := flag.String("c", confPath, "Path to config yaml file")
logPtr := flag.String("l", logPath, "Path to log file")
nodePtr := flag.String("n", nodePath, "Path to local node modules")
yamlPtr := flag.String("r", yamlPath, "Path to repos yaml file")
webPtr := flag.Bool("w", false, "Launch without web gui")
flag.Parse()
Expand All @@ -32,6 +34,6 @@ func main() {
if *webPtr {
cli.Start(*yamlPtr)
} else {
web.Gui(*confPtr, *yamlPtr, *logPtr)
web.Gui(*confPtr, *yamlPtr, *logPtr, *nodePtr)
}
}
25 changes: 15 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
module github.com/aceberg/git-syr

go 1.20
go 1.23.1

require (
github.com/spf13/viper v1.15.0
github.com/spf13/viper v1.19.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
github.com/spf13/afero v1.9.3 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
golang.org/x/sys v0.3.0 // indirect
golang.org/x/text v0.5.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
)
500 changes: 47 additions & 453 deletions go.sum

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions internal/conf/getconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func Get(path string) models.Conf {
viper.SetDefault("HOST", "0.0.0.0")
viper.SetDefault("PORT", "8844")
viper.SetDefault("THEME", "journal")
viper.SetDefault("THEME", "light")
viper.SetDefault("NODEPATH", "")

viper.SetConfigFile(path)
viper.SetConfigType("yaml")
Expand All @@ -25,6 +27,8 @@ func Get(path string) models.Conf {
config.Host, _ = viper.Get("HOST").(string)
config.Port, _ = viper.Get("PORT").(string)
config.Theme, _ = viper.Get("THEME").(string)
config.Color, _ = viper.Get("COLOR").(string)
config.NodePath, _ = viper.Get("NODEPATH").(string)

return config
}
Expand All @@ -38,6 +42,8 @@ func Write(path string, config models.Conf) {
viper.Set("host", config.Host)
viper.Set("port", config.Port)
viper.Set("theme", config.Theme)
viper.Set("color", config.Color)
viper.Set("nodepath", config.NodePath)

err := viper.WriteConfig()
check.IfError(err)
Expand Down
2 changes: 2 additions & 0 deletions internal/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ type Conf struct {
Host string
Port string
Theme string
Color string
Icon string
ConfPath string
YamlPath string
LogPath string
NodePath string
Quit chan bool
}

Expand Down
5 changes: 4 additions & 1 deletion internal/web/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ func configHandler(w http.ResponseWriter, r *http.Request) {

guiData.Config = AppConfig

guiData.Themes = []string{"cerulean", "cosmo", "cyborg", "darkly", "flatly", "journal", "litera", "lumen", "lux", "materia", "minty", "morph", "pulse", "quartz", "sandstone", "simplex", "sketchy", "slate", "solar", "spacelab", "superhero", "united", "vapor", "yeti", "zephyr"}
guiData.Themes = []string{"cerulean", "cosmo", "cyborg", "darkly", "emerald", "flatly", "grass", "grayscale", "journal", "litera", "lumen", "lux", "materia", "minty", "morph", "ocean", "pulse", "quartz", "sand", "sandstone", "simplex", "sketchy", "slate", "solar", "spacelab", "superhero", "united", "vapor", "wood", "yeti", "zephyr"}

execTemplate(w, "config", guiData)
}
Expand All @@ -22,6 +22,9 @@ func saveConfigHandler(w http.ResponseWriter, r *http.Request) {
AppConfig.Host = r.FormValue("host")
AppConfig.Port = r.FormValue("port")
AppConfig.Theme = r.FormValue("theme")
AppConfig.Color = r.FormValue("color")
AppConfig.NodePath = r.FormValue("nodepath")

conf.Write(AppConfig.ConfPath, AppConfig)

http.Redirect(w, r, r.Header.Get("Referer"), 302)
Expand Down
12 changes: 12 additions & 0 deletions internal/web/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@
{{ end }}
</select></td>
</tr>
<tr>
<td>Color</td>
<td><select name="color" class="form-select">
<option selected>{{ .Config.Color }}</option>
<option value="light">light</option>
<option value="dark">dark</option>
</select></td>
</tr>
<tr>
<td>NodePath</td>
<td><input name="nodepath" type="text" class="form-control" value="{{ .Config.NodePath }}"></td>
</tr>
<tr>
<td><button type="submit" class="btn btn-primary">Save</button></td>
<td></td>
Expand Down
11 changes: 8 additions & 3 deletions internal/web/templates/header.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
{{ define "header"}}

<!DOCTYPE html>
<html lang="en">
<html lang="en" data-bs-theme="{{ .Config.Color }}">
<head>
<title>Sync Your Repos</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--Favicon-->
<link href="data:image/x-icon;base64, {{ .Config.Icon }}" rel="icon" type="image/x-icon" />
{{ if eq .Config.NodePath "" }}
<!-- Font for icons -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.css">
<!-- Bootstrap and theme -->
<link href="https://cdn.jsdelivr.net/npm/bootswatch@5.2.0/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/aceberg-bootswatch-fork@v5.3.3-2/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
{{ else }} <!-- Local node_modules -->
<link rel="stylesheet" href="{{ .Config.NodePath }}/node_modules/bootstrap-icons/font/bootstrap-icons.css">
<link href="{{ .Config.NodePath }}/node_modules/bootswatch/dist/{{ .Config.Theme }}/bootstrap.min.css" rel="stylesheet">
{{ end }}
</head>
<body>
<nav class="navbar navbar-expand-sm navbar-dark bg-primary">
Expand Down
3 changes: 2 additions & 1 deletion internal/web/webgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ import (
)

// Gui - start web server
func Gui(confPath, yamlPath, logPath string) {
func Gui(confPath, yamlPath, logPath, nodePath string) {

AppConfig = conf.Get(confPath)
AppConfig.ConfPath = confPath
AppConfig.YamlPath = yamlPath
AppConfig.LogPath = logPath
AppConfig.NodePath = nodePath
AppConfig.Icon = Icon
log.Println("INFO: starting web gui with config", AppConfig.ConfPath)

Expand Down

0 comments on commit 77b8270

Please sign in to comment.