Skip to content

Commit

Permalink
feat: fix currency converter and remove auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
ventsislav-georgiev committed Nov 24, 2023
1 parent ea2b7d3 commit 42c42a3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 61 deletions.
42 changes: 0 additions & 42 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,61 +4,19 @@ import (
_ "embed"
"flag"
"os"
"path/filepath"
"runtime"
"strings"
"time"

"github.com/jpillora/overseer"
"github.com/jpillora/overseer/fetcher"
"github.com/pkg/profile"
"github.com/ventsislav-georgiev/prosper/pkg/core"
"github.com/ventsislav-georgiev/prosper/pkg/global"
"github.com/ventsislav-georgiev/prosper/pkg/helpers/archh"
)

//go:embed Icon.png
var icon []byte

func main() {
withUpdater := true

dir, err := os.UserHomeDir()
if err == nil {
_, err := os.Stat(filepath.Join(dir, ".prosper-no-updates"))
withUpdater = err != nil
}

if !withUpdater || os.Getenv("ENV") == "local" {
core.Run(icon)
return
}

overseer.Run(overseer.Config{
Program: app,
Address: "localhost:13003",
Fetcher: &fetcher.Github{
User: "ventsislav-georgiev",
Repo: "prosper",
Interval: 15 * time.Minute,
Asset: func(filename string) bool {
binName := "bin-" + runtime.GOOS + "-" + archh.Arch
return strings.HasPrefix(filename, binName)
},
},
})
}

func app(state overseer.State) {
if prof := profileIfRequested(); prof != nil {
defer prof()
}

go func() {
<-state.GracefulShutdown
global.Quit()
}()

core.Run(icon)
}

Expand Down
4 changes: 0 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ require (
github.com/groob/plist v0.0.0-20220217120414-63fa881b19a5
github.com/hashicorp/golang-lru v0.5.1
github.com/iineva/bom v0.0.0-20210605043415-7d45ba1bcca3
github.com/jpillora/overseer v1.1.6
github.com/parsiya/golnk v0.0.0-20200515071614-5db3107130ce
github.com/pkg/profile v1.7.0
github.com/sahilm/fuzzy v0.1.0
Expand All @@ -33,7 +32,6 @@ require (

require (
fyne.io/systray v1.10.1-0.20221115204952-d16a6177e6f1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/bcicen/bfstree v1.0.0 // indirect
github.com/benoitkugler/textlayout v0.3.0 // indirect
github.com/blacktop/lzfse-cgo v1.1.17-0.20210807041049-183fba3c3f10 // indirect
Expand All @@ -45,14 +43,12 @@ require (
github.com/fyne-io/glfw-js v0.0.0-20220120001248-ee7290d23504 // indirect
github.com/fyne-io/image v0.0.0-20220602074514-4956b0afb3d2 // indirect
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-text/typesetting v0.0.0-20221212183139-1eb938670a1f // indirect
github.com/godbus/dbus/v5 v5.1.0 // indirect
github.com/goki/freetype v0.0.0-20220119013949-7a161fd3728c // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/pprof v0.0.0-20230131232505-5a9e8f65f08f // indirect
github.com/gopherjs/gopherjs v1.17.2 // indirect
github.com/jpillora/s3 v1.1.4 // indirect
github.com/jsummers/gobmp v0.0.0-20151104160322-e2ba15ffa76e // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
Expand Down
14 changes: 0 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbi
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
github.com/akavel/rsrc v0.10.2/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o=
Expand Down Expand Up @@ -106,9 +103,6 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk=
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM=
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
github.com/go-text/typesetting v0.0.0-20221212183139-1eb938670a1f h1:cWE//ddvZ7bZAYGtNi3+SPGvUFTeTRUL/TQ9LUnQOP0=
github.com/go-text/typesetting v0.0.0-20221212183139-1eb938670a1f/go.mod h1:/cmOXaoTiO+lbCwkTZBgCvevJpbFsZ5reXIpEJVh5MI=
Expand Down Expand Up @@ -221,10 +215,6 @@ github.com/ianlancetaylor/demangle v0.0.0-20210905161508-09a460cdf81d/go.mod h1:
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jackmordaunt/icns/v2 v2.2.1/go.mod h1:6aYIB9eSzyfHHMKqDf17Xrs1zetQPReAkiUSHzdw4cI=
github.com/josephspurrier/goversioninfo v1.4.0/go.mod h1:JWzv5rKQr+MmW+LvM412ToT/IkYDZjaclF2pKDss8IY=
github.com/jpillora/overseer v1.1.6 h1:3ygYfNcR3FfOr22miu3vR1iQcXKMHbmULBh98rbkIyo=
github.com/jpillora/overseer v1.1.6/go.mod h1:aPXQtxuVb9PVWRWTXpo+LdnC/YXQ0IBLNXqKMJmgk88=
github.com/jpillora/s3 v1.1.4 h1:YCCKDWzb/Ye9EBNd83ATRF/8wPEy0xd43Rezb6u6fzc=
github.com/jpillora/s3 v1.1.4/go.mod h1:yedE603V+crlFi1Kl/5vZJaBu9pUzE9wvKegU/lF2zs=
github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
Expand Down Expand Up @@ -302,11 +292,7 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/shurcooL/vfsgen v0.0.0-20200824052919-0d455de96546/go.mod h1:TrYk7fJVaAttu97ZZKrO9UbRa8izdowaMIZcxYMbVaw=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.0.1 h1:voD4ITNjPL5jjBfgR/r8fPIIBrliWrWHeiJApdr3r4w=
github.com/smartystreets/assertions v1.0.1/go.mod h1:kHHU4qYBaI3q23Pp3VPrmWhuIUrLW/7eUrw0BU5VaoM=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/gunit v1.1.3 h1:32x+htJCu3aMswhPw3teoJ+PnWPONqdNgaGs6Qt8ZaU=
github.com/smartystreets/gunit v1.1.3/go.mod h1:EH5qMBab2UclzXUcpR8b93eHsIlp9u+pDQIRp5DZNzQ=
github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I=
github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.2.1/go.mod h1:ExllRjgxM/piMAM+3tAZvg8fsklGAf3tPfi+i8t68Nk=
Expand Down
8 changes: 7 additions & 1 deletion pkg/currency/eval.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package currency

import (
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -35,7 +36,12 @@ func Eval(expr string) (s string, icon []byte, onEnter func(), err error) {
return "", nil, nil, helpers.ErrSkip
}

resp, err := http.DefaultClient.Get(fmt.Sprintf("https://api.exchangerate.host/convert?from=%s&to=%s&amount=%s", parts[1], parts[3], parts[0]))
key, err := base64.StdEncoding.DecodeString("Yjk4YTFhZDA4MzJmNDE3NDFlMGFhNDcxYWU0NDliYzk=")
if err != nil {
return err.Error(), nil, nil, nil
}

resp, err := http.DefaultClient.Get(fmt.Sprintf("http://api.exchangerate.host/convert?from=%s&to=%s&amount=%s&access_key=%s", parts[1], parts[3], parts[0], key))
if err != nil {
return err.Error(), nil, nil, nil
}
Expand Down

0 comments on commit 42c42a3

Please sign in to comment.