refactored project layout
This commit is contained in:
parent
e8fe5b2e11
commit
d9ba0da94b
@ -1,3 +1,11 @@
|
||||
// Chrome browser module.
|
||||
//
|
||||
// Chrome bookmarks are stored in a json file normally called Bookmarks.
|
||||
// The bookmarks file is updated atomically by chrome for each change to the
|
||||
// bookmark entries by the user.
|
||||
//
|
||||
// Changes are detected by watching the parent directory for fsnotify.Create
|
||||
// events on the bookmark file. On linux this is done by using fsnotify.
|
||||
package chrome
|
||||
|
||||
import (
|
||||
@ -14,16 +22,17 @@ import (
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/hooks"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/watch"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/watch"
|
||||
)
|
||||
|
||||
var (
|
||||
log = logging.GetLogger("Chrome")
|
||||
)
|
||||
|
||||
// Type of the func used recursively on each json node entry by [jsonparser.ArrayEach]
|
||||
type ParseChildJSONFunc func([]byte, jsonparser.ValueType, int, error)
|
||||
type RecursiveParseJSONFunc func([]byte, []byte, jsonparser.ValueType, int) error
|
||||
|
||||
@ -36,7 +45,7 @@ var jsonNodePaths = struct {
|
||||
Type, Children, URL string
|
||||
}{"type", "children", "url"}
|
||||
|
||||
// stores json nodes in memory
|
||||
// type used to store json nodes in memory for parsing.
|
||||
type RawNode struct {
|
||||
name []byte
|
||||
nType []byte
|
@ -1,9 +1,9 @@
|
||||
package chrome
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
)
|
||||
|
||||
const (
|
@ -6,9 +6,9 @@ import (
|
||||
"fmt"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/cmd"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/browsers/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
@ -4,8 +4,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/cmd"
|
||||
"git.blob42.xyz/gomark/gosuki/config"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
|
||||
"github.com/gobuffalo/flect"
|
||||
"github.com/urfave/cli/v2"
|
@ -6,13 +6,13 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/browsers/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
"github.com/mitchellh/mapstructure"
|
@ -13,15 +13,15 @@ import (
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/hooks"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/browsers/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
|
||||
// "git.blob42.xyz/gomark/gosuki/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/watch"
|
||||
// "git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/watch"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
@ -9,15 +9,15 @@ import (
|
||||
"github.com/chenhg5/collection"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/database"
|
||||
"git.blob42.xyz/gomark/gosuki/index"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/index"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/browsers/mozilla"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
)
|
||||
|
||||
var ff Firefox
|
||||
@ -36,7 +36,7 @@ func setupFirefox() {
|
||||
Name: "firefox",
|
||||
Type: modules.TFirefox,
|
||||
BkFile: mozilla.PlacesFile,
|
||||
BkDir: "../mozilla/testdata",
|
||||
BkDir: "../pkg/browsers/mozilla/testdata",
|
||||
BufferDB: &database.DB{},
|
||||
URLIndex: index.NewIndex(),
|
||||
NodeTree: &tree.Node{Name: mozilla.RootName, Parent: nil, Type: tree.RootNode},
|
BIN
browsers/firefox/places
Normal file
BIN
browsers/firefox/places
Normal file
Binary file not shown.
BIN
browsers/firefox/places-shm
Normal file
BIN
browsers/firefox/places-shm
Normal file
Binary file not shown.
0
browsers/firefox/places-wal
Normal file
0
browsers/firefox/places-wal
Normal file
@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/config"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
|
||||
"github.com/kr/pretty"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
40
cmd/gosuki/config.go
Normal file
40
cmd/gosuki/config.go
Normal file
@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/internal/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
)
|
||||
|
||||
func initDefaultConfig() {
|
||||
//TODO: handle chrome
|
||||
println("Creating default config: config.toml")
|
||||
|
||||
err := config.InitConfigFile()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
log.Debugf("gosuki init config")
|
||||
|
||||
// Check if config file exists
|
||||
exists, err := utils.CheckFileExists(config.ConfigFile)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if !exists {
|
||||
// Initialize default initConfig
|
||||
//NOTE: if custom flags are passed before config.toml exists, falg
|
||||
//options will not be saved to the initial config.toml, this means
|
||||
//command line flags have higher priority than config.toml
|
||||
initDefaultConfig()
|
||||
} else {
|
||||
err = config.LoadFromTomlFile()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
167
cmd/gosuki/daemon.go
Normal file
167
cmd/gosuki/daemon.go
Normal file
@ -0,0 +1,167 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/internal/api"
|
||||
db "git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/watch"
|
||||
|
||||
"git.blob42.xyz/sp4ke/gum"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
||||
var startDaemonCmd = &cli.Command{
|
||||
Name: "daemon",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "run browser watchers",
|
||||
// Category: "daemon"
|
||||
Action: startDaemon,
|
||||
}
|
||||
|
||||
// Runs the module by calling the setup
|
||||
func runModule(c *cli.Context,
|
||||
browserMod modules.BrowserModule,
|
||||
p *profiles.Profile) (error) {
|
||||
mod := browserMod.ModInfo()
|
||||
// Create context
|
||||
modContext := &modules.Context{
|
||||
Cli: c,
|
||||
}
|
||||
//Create a browser instance
|
||||
browser, ok := mod.New().(modules.BrowserModule)
|
||||
if !ok {
|
||||
log.Criticalf("module <%s> is not a BrowserModule", mod.ID)
|
||||
}
|
||||
log.Debugf("created browser instance <%s>", browser.Config().Name)
|
||||
|
||||
// shutdown logic
|
||||
s, isShutdowner := browser.(modules.Shutdowner)
|
||||
if !isShutdowner {
|
||||
log.Warningf("browser <%s> does not implement modules.Shutdowner", browser.Config().Name)
|
||||
}
|
||||
|
||||
log.Debugf("new browser <%s> instance", browser.Config().Name)
|
||||
|
||||
|
||||
//TODO!: call with custom profile
|
||||
if p != nil {
|
||||
bpm, ok := browser.(profiles.ProfileManager)
|
||||
if !ok {
|
||||
err := fmt.Errorf("<%s> does not implement profiles.ProfileManager",
|
||||
browser.Config().Name)
|
||||
log.Critical(err)
|
||||
return err
|
||||
}
|
||||
if err := bpm.UseProfile(*p); err != nil {
|
||||
log.Criticalf("could not use profile <%s>", p.Name)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// calls the setup logic for each browser instance which
|
||||
// includes the browsers.Initializer and browsers.Loader interfaces
|
||||
err := modules.Setup(browser, modContext)
|
||||
if err != nil {
|
||||
log.Errorf("setting up <%s> %v", browser.Config().Name, err)
|
||||
if isShutdowner {
|
||||
handleShutdown(browser.Config().Name, s)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
runner, ok := browser.(watch.WatchRunner)
|
||||
if !ok {
|
||||
err = fmt.Errorf("<%s> must implement watch.WatchRunner interface", browser.Config().Name)
|
||||
log.Critical(err)
|
||||
return err
|
||||
}
|
||||
|
||||
log.Infof("start watching <%s>", runner.Watch().ID)
|
||||
watch.SpawnWatcher(runner)
|
||||
return nil
|
||||
}
|
||||
|
||||
func startDaemon(c *cli.Context) error {
|
||||
defer utils.CleanFiles()
|
||||
manager := gum.NewManager()
|
||||
manager.ShutdownOn(os.Interrupt)
|
||||
|
||||
api := api.NewApi()
|
||||
manager.AddUnit(api)
|
||||
|
||||
go manager.Run()
|
||||
|
||||
// Initialize sqlite database available in global `cacheDB` variable
|
||||
db.InitDB()
|
||||
|
||||
registeredBrowsers := modules.GetBrowserModules()
|
||||
|
||||
// instanciate all browsers
|
||||
for _, browserMod := range registeredBrowsers {
|
||||
|
||||
mod := browserMod.ModInfo()
|
||||
|
||||
//Create a temporary browser instance to check if it implements
|
||||
// the ProfileManager interface
|
||||
browser, ok := mod.New().(modules.BrowserModule)
|
||||
if !ok {
|
||||
log.Criticalf("module <%s> is not a BrowserModule", mod.ID)
|
||||
}
|
||||
|
||||
// if the module is a profile manager and is watching all profiles
|
||||
// call runModule for each profile
|
||||
bpm, ok := browser.(profiles.ProfileManager)
|
||||
if ok {
|
||||
if bpm.WatchAllProfiles() {
|
||||
profs, err := bpm.GetProfiles()
|
||||
if err != nil {
|
||||
log.Critical("could not get profiles")
|
||||
continue
|
||||
}
|
||||
for _, p := range profs {
|
||||
log.Debugf("profile: <%s>", p.Name)
|
||||
err = runModule(c, browserMod, p)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
err := runModule(c, browserMod, nil)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.Warningf("module <%s> does not implement profiles.ProfileManager",
|
||||
browser.Config().Name)
|
||||
if err := runModule(c, browserMod, nil); err != nil {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
// register defer shutdown logic
|
||||
s, isShutdowner := browser.(modules.Shutdowner)
|
||||
if isShutdowner {
|
||||
defer handleShutdown(browser.Config().Name, s)
|
||||
}
|
||||
}
|
||||
|
||||
<-manager.Quit
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func handleShutdown(id string, s modules.Shutdowner) {
|
||||
err := s.Shutdown()
|
||||
if err != nil {
|
||||
log.Panicf("<%s> could not shutdown: %s", id, err)
|
||||
}
|
||||
}
|
126
cmd/gosuki/main.go
Normal file
126
cmd/gosuki/main.go
Normal file
@ -0,0 +1,126 @@
|
||||
// Main command line entry point for gosuki
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/internal/config"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/cmd"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
// Load firefox browser modules
|
||||
_ "git.blob42.xyz/gomark/gosuki/browsers/firefox"
|
||||
|
||||
// Load chrome browser module
|
||||
_ "git.blob42.xyz/gomark/gosuki/browsers/chrome"
|
||||
)
|
||||
|
||||
var log = logging.GetLogger("")
|
||||
|
||||
|
||||
func main() {
|
||||
|
||||
app := cli.NewApp()
|
||||
|
||||
|
||||
app.Name = "gosuki"
|
||||
app.Version = utils.Version()
|
||||
|
||||
flags := []cli.Flag{
|
||||
|
||||
&cli.StringFlag{
|
||||
Name: "config-file",
|
||||
Value: config.ConfigFile,
|
||||
Usage: "TOML config `FILE` path",
|
||||
},
|
||||
|
||||
&cli.IntFlag{
|
||||
Name: "debug",
|
||||
Aliases: []string{"d"},
|
||||
EnvVars: []string{logging.EnvGosukiDebug},
|
||||
Action: func (c *cli.Context, val int) error {
|
||||
logging.SetMode(val)
|
||||
return nil
|
||||
},
|
||||
|
||||
},
|
||||
}
|
||||
|
||||
flags = append(flags, config.SetupGlobalFlags()...)
|
||||
app.Flags = append(app.Flags, flags...)
|
||||
|
||||
app.Before = func(c *cli.Context) error {
|
||||
|
||||
|
||||
// get all registered browser modules
|
||||
modules := modules.GetModules()
|
||||
for _, mod := range modules {
|
||||
|
||||
// Run module's hooks that should run before context is ready
|
||||
// for example setup flags management
|
||||
modinfo := mod.ModInfo()
|
||||
hook := cmd.BeforeHook(string(modinfo.ID))
|
||||
if hook != nil {
|
||||
if err := cmd.BeforeHook(string(modinfo.ID))(c); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Execute config hooks
|
||||
//TODO: better doc for what are Conf hooks ???
|
||||
config.RunConfHooks(c)
|
||||
|
||||
initConfig()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
// Browser modules can register commands through cmd.RegisterModCommand.
|
||||
// registered commands will be appended here
|
||||
app.Commands = []*cli.Command{
|
||||
// main entry point
|
||||
startDaemonCmd,
|
||||
cmd.ConfigCmds,
|
||||
cmd.ProfileCmds,
|
||||
cmd.ModuleCmds,
|
||||
}
|
||||
|
||||
// Add global flags from registered modules
|
||||
// we use GetModules to handle all types of modules
|
||||
modules := modules.GetModules()
|
||||
log.Debugf("loading %d modules", len(modules))
|
||||
for _, mod := range modules {
|
||||
modID := string(mod.ModInfo().ID)
|
||||
log.Debugf("loading module <%s>", modID)
|
||||
|
||||
// for each registered module, register own flag management
|
||||
modFlags := cmd.GlobalFlags(modID)
|
||||
if len(modFlags) != 0 {
|
||||
app.Flags = append(app.Flags, modFlags...)
|
||||
}
|
||||
|
||||
// Add all browser module registered commands
|
||||
cmds := cmd.RegisteredModCommands(modID)
|
||||
for _, cmd := range cmds {
|
||||
app.Commands = append(app.Commands, cmd)
|
||||
}
|
||||
}
|
||||
|
||||
if err := app.Run(os.Args); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
||||
//TODO: watch all profiles (handled at browser level for now)
|
||||
// config.RegisterGlobalOption("all-profiles", false)
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
)
|
||||
|
||||
// map cmd Name to *cli.Command
|
||||
|
@ -3,8 +3,8 @@ package cmd
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/modules"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
|
@ -1,6 +0,0 @@
|
||||
-- gosuki does not scan the title to FFBookmark struct
|
||||
SELECT id,type,IFNULL(fk, -1) AS fk ,parent,IFNULL(title, '') AS title from moz_bookmarks
|
||||
WHERE(lastModified > 1663875146551061
|
||||
AND lastModified < strftime('%s', 'now')*1000*1000
|
||||
AND NOT id IN (1,4)
|
||||
)
|
Binary file not shown.
@ -1,7 +1,7 @@
|
||||
package hooks
|
||||
// Global available hooks for browsers to use
|
||||
|
||||
import "git.blob42.xyz/gomark/gosuki/parsing"
|
||||
import "git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
|
||||
var Predefined = map[string]Hook{
|
||||
"tags_from_name": {
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
|
||||
"github.com/0xAX/notificator"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
)
|
||||
|
||||
// Hook that sends a system notification using notify-send (Linux).
|
||||
|
@ -10,7 +10,7 @@
|
||||
package hooks
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
)
|
||||
|
||||
// A Hook is a function that takes a *Node as input and is called on a bookmark
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
|
||||
"git.blob42.xyz/sp4ke/gum"
|
||||
"github.com/gin-gonic/gin"
|
||||
|
@ -5,7 +5,7 @@ package config
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/urfave/cli/v2"
|
@ -3,8 +3,8 @@ package database
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
)
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
|
||||
"github.com/teris-io/shortid"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
)
|
||||
|
||||
|
||||
|
@ -9,8 +9,8 @@ import (
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
sqlite3 "github.com/mattn/go-sqlite3"
|
||||
|
@ -3,7 +3,7 @@ package database
|
||||
import (
|
||||
"path/filepath"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
)
|
||||
|
||||
func InitDB() {
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
"path"
|
||||
"path/filepath"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
)
|
||||
|
||||
var (
|
16
log.go
16
log.go
@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
)
|
||||
|
||||
var (
|
||||
// global logger
|
||||
log = logging.GetLogger("")
|
||||
fflog = logging.GetLogger("FF")
|
||||
)
|
||||
|
||||
func init() {
|
||||
//logging.SetLogger("FF", logging.WARNING)
|
||||
//logging.UseLogger("STATS", nil)
|
||||
}
|
3
modules/entry.go
Normal file
3
modules/entry.go
Normal file
@ -0,0 +1,3 @@
|
||||
// TODO: gosuki modules that are not browsers
|
||||
package modules
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
)
|
||||
|
||||
// Constants representing the meaning if IDs defined in the table
|
@ -7,16 +7,16 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/profiles"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
_debug "git.blob42.xyz/gomark/gosuki/pkg/profiles"
|
||||
|
||||
"github.com/go-ini/ini"
|
||||
)
|
||||
|
||||
// ProfileManager interface
|
||||
type ProfileManager = profiles.ProfileManager
|
||||
type INIProfileLoader = profiles.INIProfileLoader
|
||||
type PathGetter = profiles.PathGetter
|
||||
type ProfileManager = _debug.ProfileManager
|
||||
type INIProfileLoader = _debug.INIProfileLoader
|
||||
type PathGetter = _debug.PathGetter
|
||||
|
||||
const (
|
||||
ProfilesFile = "profiles.ini"
|
||||
@ -55,7 +55,7 @@ func (pm *MozProfileManager) loadProfile() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (pm *MozProfileManager) GetProfiles() ([]*profiles.Profile, error) {
|
||||
func (pm *MozProfileManager) GetProfiles() ([]*_debug.Profile, error) {
|
||||
err := pm.loadProfile()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -63,12 +63,12 @@ func (pm *MozProfileManager) GetProfiles() ([]*profiles.Profile, error) {
|
||||
|
||||
sections := pm.ProfilesFile.Sections()
|
||||
var filtered []*ini.Section
|
||||
var result []*profiles.Profile
|
||||
var result []*_debug.Profile
|
||||
for _, section := range sections {
|
||||
if ReIniProfiles.MatchString(section.Name()) {
|
||||
filtered = append(filtered, section)
|
||||
|
||||
p := &profiles.Profile{
|
||||
p := &_debug.Profile{
|
||||
Id: section.Name(),
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ func (pm *MozProfileManager) GetProfilePath(name string) (string, error) {
|
||||
// Eval symlinks
|
||||
}
|
||||
|
||||
func (pm *MozProfileManager) GetProfileByName(name string) (*profiles.Profile, error) {
|
||||
func (pm *MozProfileManager) GetProfileByName(name string) (*_debug.Profile, error) {
|
||||
profs, err := pm.GetProfiles()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -117,7 +117,7 @@ func (pm *MozProfileManager) GetProfileByName(name string) (*profiles.Profile, e
|
||||
}
|
||||
|
||||
// TEST:
|
||||
func (pm *MozProfileManager) GetDefaultProfile() (*profiles.Profile, error) {
|
||||
func (pm *MozProfileManager) GetDefaultProfile() (*_debug.Profile, error) {
|
||||
profs, err := pm.GetProfiles()
|
||||
if err != nil {
|
||||
return nil, err
|
@ -3,8 +3,8 @@ package mozilla
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/database"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
"github.com/gchaincl/dotsql"
|
||||
_ "github.com/kr/pretty"
|
||||
"github.com/swithek/dotsqlx"
|
@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"path"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
)
|
||||
|
||||
const (
|
@ -7,13 +7,13 @@ import (
|
||||
"time"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/internal/database"
|
||||
"git.blob42.xyz/gomark/gosuki/index"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/index"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/parsing"
|
||||
"git.blob42.xyz/gomark/gosuki/hooks"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/watch"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/watch"
|
||||
)
|
||||
|
||||
type BrowserType uint8
|
@ -1,9 +1,10 @@
|
||||
// Modules allow gosuki to be extended in the future.
|
||||
// This file should live on it's own package or on the core pacakge
|
||||
// The goal is to allow a generic interface Module that would allow anything to
|
||||
// register as a Gosuki module.
|
||||
// Modules allow the extension of gosuki to handle other types of browsers or
|
||||
// source of data that can be turned into bookmarks.
|
||||
//
|
||||
// # Module Types
|
||||
//
|
||||
// Browsers would need to register as gosuki Module and as Browser interfaces
|
||||
// 1. Browsers MUST implement the [BrowserModule] interface.
|
||||
// 2. Simple modules MUST implement the [Module] interface.
|
||||
package modules
|
||||
|
||||
import (
|
@ -3,8 +3,8 @@ package parsing
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/tree"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/tree"
|
||||
)
|
||||
|
||||
type Node = tree.Node
|
@ -3,10 +3,10 @@ package tree
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.blob42.xyz/gomark/gosuki/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/index"
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/utils"
|
||||
"git.blob42.xyz/gomark/gosuki/pkg/bookmarks"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/index"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/utils"
|
||||
"github.com/kr/pretty"
|
||||
|
||||
"github.com/xlab/treeprint"
|
@ -1,7 +1,7 @@
|
||||
package watch
|
||||
|
||||
import (
|
||||
"git.blob42.xyz/gomark/gosuki/logging"
|
||||
"git.blob42.xyz/gomark/gosuki/internal/logging"
|
||||
|
||||
"github.com/fsnotify/fsnotify"
|
||||
)
|
Loading…
Reference in New Issue
Block a user