From a65750ae2122850722d0ea4f7b49d7f8df265003 Mon Sep 17 00:00:00 2001 From: Evan Reichard Date: Wed, 10 Jan 2024 20:23:36 -0500 Subject: [PATCH] [chore] rename package, [chore] rename vars --- api/api.go | 4 ++-- api/app-routes.go | 49 ++++++++++++++++++++-------------------- api/auth.go | 2 +- api/common.go | 4 ++-- api/ko-routes.go | 8 +++---- api/opds-routes.go | 4 ++-- api/utils.go | 4 ++-- database/manager.go | 2 +- database/manager_test.go | 2 +- go.mod | 6 ++--- main.go | 2 +- server/server.go | 6 ++--- 12 files changed, 46 insertions(+), 47 deletions(-) diff --git a/api/api.go b/api/api.go index 667b238..f89ab4e 100644 --- a/api/api.go +++ b/api/api.go @@ -17,8 +17,8 @@ import ( "github.com/gin-gonic/gin" "github.com/microcosm-cc/bluemonday" log "github.com/sirupsen/logrus" - "reichard.io/bbank/config" - "reichard.io/bbank/database" + "reichard.io/antholume/config" + "reichard.io/antholume/database" ) type API struct { diff --git a/api/app-routes.go b/api/app-routes.go index 5cfb4b8..303a762 100644 --- a/api/app-routes.go +++ b/api/app-routes.go @@ -21,33 +21,33 @@ import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "golang.org/x/exp/slices" - "reichard.io/bbank/database" - "reichard.io/bbank/metadata" - "reichard.io/bbank/search" - "reichard.io/bbank/utils" + "reichard.io/antholume/database" + "reichard.io/antholume/metadata" + "reichard.io/antholume/search" + "reichard.io/antholume/utils" ) -type AdminAction string +type adminAction string const ( - AA_IMPORT AdminAction = "IMPORT" - AA_BACKUP AdminAction = "BACKUP" - AA_RESTORE AdminAction = "RESTORE" - AA_METADATA_MATCH AdminAction = "METADATA_MATCH" + adminImport adminAction = "IMPORT" + adminBackup adminAction = "BACKUP" + adminRestore adminAction = "RESTORE" + adminMetadataMatch adminAction = "METADATA_MATCH" ) -type ImportType string +type importType string const ( - IMPORT_TYPE_DIRECT ImportType = "DIRECT" - IMPORT_TYPE_COPY ImportType = "COPY" + importDirect importType = "DIRECT" + importCopy importType = "COPY" ) -type BackupType string +type backupType string const ( - BACKUP_TYPE_COVERS BackupType = "COVERS" - BACKUP_TYPE_DOCUMENTS BackupType = "DOCUMENTS" + backupCovers backupType = "COVERS" + backupDocuments backupType = "DOCUMENTS" ) type queryParams struct { @@ -78,14 +78,14 @@ type requestDocumentEdit struct { } type requestAdminAction struct { - Action AdminAction `form:"action"` + Action adminAction `form:"action"` // Import Action ImportDirectory *string `form:"import_directory"` - ImportType *ImportType `form:"import_type"` + ImportType *importType `form:"import_type"` // Backup Action - BackupTypes []BackupType `form:"backup_types"` + BackupTypes []backupType `form:"backup_types"` // Restore Action RestoreFile *multipart.FileHeader `form:"restore_file"` @@ -320,7 +320,6 @@ func (api *API) appGetSettings(c *gin.Context) { func (api *API) appGetAdmin(c *gin.Context) { templateVars := api.getBaseTemplateVars("admin", c) - c.HTML(http.StatusOK, "page/admin", templateVars) } @@ -355,19 +354,19 @@ func (api *API) appPerformAdminAction(c *gin.Context) { } switch rAdminAction.Action { - case AA_IMPORT: + case adminImport: // TODO - case AA_METADATA_MATCH: + case adminMetadataMatch: // TODO // 1. Documents xref most recent metadata table? // 2. Select all / deselect? - case AA_RESTORE: + case adminRestore: // TODO // 1. Consume backup ZIP // 2. Move existing to "backup" folder (db, wal, shm, covers, documents) // 3. Extract backup zip // 4. Restart server? - case AA_BACKUP: + case adminBackup: // Get File Paths fileName := fmt.Sprintf("%s.db", api.Config.DBName) dbLocation := path.Join(api.Config.ConfigPath, fileName) @@ -420,10 +419,10 @@ func (api *API) appPerformAdminAction(c *gin.Context) { // Backup Covers & Documents for _, item := range rAdminAction.BackupTypes { - if item == BACKUP_TYPE_COVERS { + if item == backupCovers { filepath.WalkDir(path.Join(api.Config.DataPath, "covers"), exportWalker) - } else if item == BACKUP_TYPE_DOCUMENTS { + } else if item == backupDocuments { filepath.WalkDir(path.Join(api.Config.DataPath, "documents"), exportWalker) } } diff --git a/api/auth.go b/api/auth.go index 775decf..45d308e 100644 --- a/api/auth.go +++ b/api/auth.go @@ -11,7 +11,7 @@ import ( "github.com/gin-contrib/sessions" "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" - "reichard.io/bbank/database" + "reichard.io/antholume/database" ) // Authorization Data diff --git a/api/common.go b/api/common.go index 2a0a12f..7d6074b 100644 --- a/api/common.go +++ b/api/common.go @@ -7,8 +7,8 @@ import ( "net/http" "os" "path/filepath" - "reichard.io/bbank/database" - "reichard.io/bbank/metadata" + "reichard.io/antholume/database" + "reichard.io/antholume/metadata" ) func (api *API) downloadDocument(c *gin.Context) { diff --git a/api/ko-routes.go b/api/ko-routes.go index e6063a0..46f96c0 100644 --- a/api/ko-routes.go +++ b/api/ko-routes.go @@ -18,8 +18,8 @@ import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" "golang.org/x/exp/slices" - "reichard.io/bbank/database" - "reichard.io/bbank/metadata" + "reichard.io/antholume/database" + "reichard.io/antholume/metadata" ) type activityItem struct { @@ -173,11 +173,11 @@ func (api *API) koSetProgress(c *gin.Context) { } // Update Statistic - log.Info("[koSetProgress] UpdateDocumentUserStatistic Running...") + start := time.Now() if err := api.DB.UpdateDocumentUserStatistic(rPosition.DocumentID, auth.UserName); err != nil { log.Error("[koSetProgress] UpdateDocumentUserStatistic Error:", err) } - log.Info("[koSetProgress] UpdateDocumentUserStatistic Complete") + log.Debug("[koSetProgress] UpdateDocumentUserStatistic Performance: ", time.Since(start)) c.JSON(http.StatusOK, gin.H{ "document": progress.DocumentID, diff --git a/api/opds-routes.go b/api/opds-routes.go index 2ae1ffe..ddd0762 100644 --- a/api/opds-routes.go +++ b/api/opds-routes.go @@ -8,8 +8,8 @@ import ( "github.com/gin-gonic/gin" log "github.com/sirupsen/logrus" - "reichard.io/bbank/database" - "reichard.io/bbank/opds" + "reichard.io/antholume/database" + "reichard.io/antholume/opds" ) var mimeMapping map[string]string = map[string]string{ diff --git a/api/utils.go b/api/utils.go index 553b290..6eaf290 100644 --- a/api/utils.go +++ b/api/utils.go @@ -5,8 +5,8 @@ import ( "fmt" "math" - "reichard.io/bbank/database" - "reichard.io/bbank/graph" + "reichard.io/antholume/database" + "reichard.io/antholume/graph" ) type UTCOffset struct { diff --git a/database/manager.go b/database/manager.go index fa25240..722b654 100644 --- a/database/manager.go +++ b/database/manager.go @@ -8,7 +8,7 @@ import ( log "github.com/sirupsen/logrus" _ "modernc.org/sqlite" "path" - "reichard.io/bbank/config" + "reichard.io/antholume/config" ) type DBManager struct { diff --git a/database/manager_test.go b/database/manager_test.go index 0388c6a..4e82381 100644 --- a/database/manager_test.go +++ b/database/manager_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "reichard.io/bbank/config" + "reichard.io/antholume/config" ) type databaseTest struct { diff --git a/go.mod b/go.mod index d80925c..dfdbb82 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module reichard.io/bbank +module reichard.io/antholume go 1.19 @@ -11,10 +11,10 @@ require ( github.com/gin-gonic/gin v1.9.1 github.com/microcosm-cc/bluemonday v1.0.25 github.com/sirupsen/logrus v1.9.3 + github.com/snowzach/rotatefilehook v0.0.0-20220211133110-53752135082d github.com/taylorskalyo/goreader v0.0.0-20230626212555-e7f5644f8115 github.com/urfave/cli/v2 v2.25.7 golang.org/x/exp v0.0.0-20230905200255-921286631fa9 - golang.org/x/net v0.15.0 modernc.org/sqlite v1.26.0 ) @@ -47,13 +47,13 @@ require ( github.com/pelletier/go-toml/v2 v2.1.0 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect - github.com/snowzach/rotatefilehook v0.0.0-20220211133110-53752135082d // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.11 // indirect github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect golang.org/x/arch v0.4.0 // indirect golang.org/x/crypto v0.13.0 // indirect golang.org/x/mod v0.12.0 // indirect + golang.org/x/net v0.15.0 // indirect golang.org/x/sys v0.12.0 // indirect golang.org/x/text v0.13.0 // indirect golang.org/x/tools v0.13.0 // indirect diff --git a/main.go b/main.go index 889e89f..9b7fd62 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/urfave/cli/v2" - "reichard.io/bbank/server" + "reichard.io/antholume/server" ) //go:embed templates/* assets/* diff --git a/server/server.go b/server/server.go index ecbaaca..9466c5a 100644 --- a/server/server.go +++ b/server/server.go @@ -11,9 +11,9 @@ import ( log "github.com/sirupsen/logrus" - "reichard.io/bbank/api" - "reichard.io/bbank/config" - "reichard.io/bbank/database" + "reichard.io/antholume/api" + "reichard.io/antholume/config" + "reichard.io/antholume/database" ) type Server struct {