mirror of
https://github.com/Starlio-app/StarlioX.git
synced 2025-04-07 03:35:27 +01:00
removing unnecessary functionality
This commit is contained in:
parent
2e28df3010
commit
fd20891d71
3 changed files with 24 additions and 140 deletions
|
@ -1,67 +0,0 @@
|
||||||
package controllers
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/gofiber/fiber/v2"
|
|
||||||
"os"
|
|
||||||
"os/user"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/Redume/EveryNasa/api/utils"
|
|
||||||
"github.com/Redume/EveryNasa/functions"
|
|
||||||
)
|
|
||||||
|
|
||||||
var Startup = func(c *fiber.Ctx) error {
|
|
||||||
startup := c.FormValue("startup")
|
|
||||||
if startup == "" {
|
|
||||||
utils.Respond(c, utils.Message(false, "All fields are required."))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
if startup == "1" {
|
|
||||||
SetStartup(c)
|
|
||||||
} else if startup == "0" {
|
|
||||||
RemoveStartup(c)
|
|
||||||
} else {
|
|
||||||
utils.Respond(c, utils.Message(false, "Invalid field."))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var SetStartup = func(c *fiber.Ctx) error {
|
|
||||||
u, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
dir, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
dir = strings.Replace(dir, "\\", "\\\\", -1) + "\\EveryNasa.exe"
|
|
||||||
|
|
||||||
err = functions.CreateLnk(dir, strings.Replace(u.HomeDir, "\\", "\\\\", -1)+"\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\EveryNasa.lnk")
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.Respond(c, utils.Message(true, "The settings have been applied successfully."))
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var RemoveStartup = func(c *fiber.Ctx) error {
|
|
||||||
u, err := user.Current()
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
err = os.Remove(strings.Replace(u.HomeDir, "\\", "\\\\", -1) + "\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\EveryNasa.lnk")
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
utils.Respond(c, utils.Message(true, "The settings have been applied successfully."))
|
|
||||||
return nil
|
|
||||||
}
|
|
|
@ -1,55 +0,0 @@
|
||||||
package functions
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/go-ole/go-ole"
|
|
||||||
"github.com/go-ole/go-ole/oleutil"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CreateLnk(src, dst string) error {
|
|
||||||
err := ole.CoInitializeEx(0, ole.COINIT_APARTMENTTHREADED|ole.COINIT_SPEED_OVER_MEMORY)
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
oleShellObject, err := oleutil.CreateObject("WScript.Shell")
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
defer oleShellObject.Release()
|
|
||||||
wshell, err := oleShellObject.QueryInterface(ole.IID_IDispatch)
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
defer wshell.Release()
|
|
||||||
cs, err := oleutil.CallMethod(wshell, "CreateShortcut", dst)
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
idispatch := cs.ToIDispatch()
|
|
||||||
_, err = oleutil.PutProperty(idispatch, "TargetPath", src)
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
dir, err := os.Getwd()
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = oleutil.PutProperty(idispatch, "WorkingDirectory", dir)
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
_, err = oleutil.CallMethod(idispatch, "Save")
|
|
||||||
if err != nil {
|
|
||||||
Logger(err.Error())
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
42
main.go
42
main.go
|
@ -4,7 +4,6 @@ import (
|
||||||
"github.com/Redume/EveryNasa/api/controllers"
|
"github.com/Redume/EveryNasa/api/controllers"
|
||||||
"github.com/Redume/EveryNasa/functions"
|
"github.com/Redume/EveryNasa/functions"
|
||||||
"github.com/Redume/EveryNasa/web/page"
|
"github.com/Redume/EveryNasa/web/page"
|
||||||
|
|
||||||
"github.com/getlantern/systray"
|
"github.com/getlantern/systray"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/cors"
|
"github.com/gofiber/fiber/v2/middleware/cors"
|
||||||
|
@ -16,6 +15,22 @@ func main() {
|
||||||
go functions.StartWallpaper()
|
go functions.StartWallpaper()
|
||||||
|
|
||||||
app := fiber.New()
|
app := fiber.New()
|
||||||
|
app = fiber.New(fiber.Config{
|
||||||
|
ErrorHandler: func(ctx *fiber.Ctx, err error) error {
|
||||||
|
code := fiber.StatusInternalServerError
|
||||||
|
|
||||||
|
if e, ok := err.(*fiber.Error); ok {
|
||||||
|
code = e.Code
|
||||||
|
}
|
||||||
|
|
||||||
|
if code == fiber.StatusNotFound {
|
||||||
|
return ctx.SendFile("./web/errors/404.html")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
app.Static("/static", "./web/static")
|
app.Static("/static", "./web/static")
|
||||||
app.Use(cors.New())
|
app.Use(cors.New())
|
||||||
|
|
||||||
|
@ -29,31 +44,22 @@ func main() {
|
||||||
return page.About(c)
|
return page.About(c)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Post("/api/update/settings", func(c *fiber.Ctx) error {
|
api := app.Group("/api")
|
||||||
|
|
||||||
|
update := api.Group("/update")
|
||||||
|
get := api.Group("/get")
|
||||||
|
|
||||||
|
update.Post("/settings", func(c *fiber.Ctx) error {
|
||||||
return controllers.SettingsUpdate(c)
|
return controllers.SettingsUpdate(c)
|
||||||
})
|
})
|
||||||
app.Post("/api/update/wallpaper", func(c *fiber.Ctx) error {
|
update.Post("/wallpaper", func(c *fiber.Ctx) error {
|
||||||
return controllers.WallpaperUpdate(c)
|
return controllers.WallpaperUpdate(c)
|
||||||
})
|
})
|
||||||
app.Post("/api/update/startup", func(c *fiber.Ctx) error {
|
|
||||||
return controllers.Startup(c)
|
|
||||||
})
|
|
||||||
app.Post("/api/create/label", func(c *fiber.Ctx) error {
|
|
||||||
return controllers.CreateLabel(c)
|
|
||||||
})
|
|
||||||
|
|
||||||
app.Get("/api/get/settings", func(c *fiber.Ctx) error {
|
get.Get("/settings", func(c *fiber.Ctx) error {
|
||||||
return controllers.SettingsGet(c)
|
return controllers.SettingsGet(c)
|
||||||
})
|
})
|
||||||
|
|
||||||
app.Use(func(c *fiber.Ctx) error {
|
|
||||||
err := c.SendStatus(404)
|
|
||||||
if err != nil {
|
|
||||||
functions.Logger(err.Error())
|
|
||||||
}
|
|
||||||
return c.SendFile("./web/errors/404.html")
|
|
||||||
})
|
|
||||||
|
|
||||||
err := app.Listen(":3000")
|
err := app.Listen(":3000")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Add table
Reference in a new issue