Skip to content

Commit

Permalink
moved internal packages to handler for more useful path logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
bengarrett committed Sep 2, 2024
1 parent aedff49 commit a87c85d
Show file tree
Hide file tree
Showing 33 changed files with 42 additions and 40 deletions.
10 changes: 5 additions & 5 deletions handler/app/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ import (
"github.com/Defacto2/releaser/initialism"
"github.com/Defacto2/server/handler/app/internal/mfs"
"github.com/Defacto2/server/handler/app/internal/remote"
"github.com/Defacto2/server/handler/cache"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/download"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/handler/sess"
"github.com/Defacto2/server/internal/cache"
"github.com/Defacto2/server/handler/site"
"github.com/Defacto2/server/handler/sixteen"
"github.com/Defacto2/server/internal/config"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/internal/postgres"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/internal/site"
"github.com/Defacto2/server/internal/sixteen"
"github.com/Defacto2/server/internal/tags"
"github.com/Defacto2/server/model"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion handler/app/dirs.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import (
"github.com/Defacto2/server/handler/app/internal/mf"
"github.com/Defacto2/server/handler/app/internal/readme"
"github.com/Defacto2/server/handler/app/internal/str"
"github.com/Defacto2/server/handler/render"
"github.com/Defacto2/server/handler/sess"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/render"
"github.com/Defacto2/server/internal/tags"
"github.com/Defacto2/server/model"
"github.com/dustin/go-humanize"
Expand Down
2 changes: 1 addition & 1 deletion handler/app/internal/mf/mf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"github.com/Defacto2/server/handler/app/internal/exts"
"github.com/Defacto2/server/handler/app/internal/readme"
"github.com/Defacto2/server/handler/app/internal/str"
"github.com/Defacto2/server/internal/jsdos/msdos"
"github.com/Defacto2/server/handler/jsdos/msdos"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/tags"
"github.com/Defacto2/server/model"
Expand Down
2 changes: 1 addition & 1 deletion handler/app/internal/readme/readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
uni "unicode"

"github.com/Defacto2/magicnumber"
"github.com/Defacto2/server/handler/render"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/render"
)

// Suggest returns a suggested readme file name for the record.
Expand Down
4 changes: 2 additions & 2 deletions handler/app/internal/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"github.com/Defacto2/archive"
"github.com/Defacto2/helper"
"github.com/Defacto2/server/handler/app/internal/str"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/model"
"github.com/labstack/echo/v4"
"github.com/volatiletech/null/v8"
Expand Down
6 changes: 3 additions & 3 deletions handler/app/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ import (
"github.com/Defacto2/releaser/name"
"github.com/Defacto2/server/handler/app/internal/mf"
"github.com/Defacto2/server/handler/app/internal/str"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/form"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/config"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/internal/form"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/internal/tags"
"github.com/volatiletech/null/v8"
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"

"github.com/Defacto2/helper"
"github.com/Defacto2/server/internal/cache"
"github.com/Defacto2/server/handler/cache"
)

func TestCache(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion internal/demozoo/demozoo.go → handler/demozoo/demozoo.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ var (

const (
ProdURL = "https://demozoo.org/api/v1/productions/" // ProdURL is the base URL for the Demozoo production API.
Timeout = 10 * time.Second // HTTP client timeout, Demozoo replies can be slow.
Sanity = 450000 // Sanity is to check the maximum permitted production ID.
Timeout = 10 * time.Second // HTTP client timeout, Demozoo replies can be slow.
firstID = 1 // firstID is the first production ID on Pouet.
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package demozoo_test
import (
"testing"

"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/handler/demozoo"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/form/form_test.go → handler/form/form_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/Defacto2/server/internal/form"
"github.com/Defacto2/server/handler/form"
"github.com/stretchr/testify/assert"
)

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions handler/htmx/artifact.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import (
"github.com/Defacto2/helper"
"github.com/Defacto2/releaser"
"github.com/Defacto2/server/handler/app"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/form"
"github.com/Defacto2/server/handler/jsdos"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/command"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/internal/form"
"github.com/Defacto2/server/internal/jsdos"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/model"
"github.com/labstack/echo/v4"
"go.uber.org/zap"
Expand Down
6 changes: 3 additions & 3 deletions handler/htmx/htmx.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"github.com/Defacto2/helper"
"github.com/Defacto2/releaser/initialism"
"github.com/Defacto2/server/internal/cache"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/handler/cache"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/postgres"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/model"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
Expand Down
6 changes: 3 additions & 3 deletions handler/htmx/transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"github.com/Defacto2/helper"
"github.com/Defacto2/magicnumber"
"github.com/Defacto2/server/handler/app"
"github.com/Defacto2/server/handler/demozoo"
"github.com/Defacto2/server/handler/form"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/handler/sess"
"github.com/Defacto2/server/internal/command"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/internal/form"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/internal/tags"
"github.com/Defacto2/server/model"
"github.com/google/uuid"
Expand Down
2 changes: 1 addition & 1 deletion internal/jsdos/jsdos.go → handler/jsdos/jsdos.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sort"
"strings"

"github.com/Defacto2/server/internal/jsdos/msdos"
"github.com/Defacto2/server/handler/jsdos/msdos"
)

const AudioRate = "44100" // AudioRate is the sample rate of the audio that is emulated.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package jsdos_test
import (
"testing"

"github.com/Defacto2/server/internal/jsdos"
"github.com/Defacto2/server/handler/jsdos"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/subpop/go-ini"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"testing"

"github.com/Defacto2/helper"
"github.com/Defacto2/server/handler/render"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/render"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/volatiletech/null/v8"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion internal/site/site_test.go → handler/site/site_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package site_test
import (
"testing"

"github.com/Defacto2/server/internal/site"
"github.com/Defacto2/server/handler/site"
"github.com/stretchr/testify/assert"
)

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion model/html3/html3.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"unicode/utf8"

"github.com/Defacto2/helper"
"github.com/Defacto2/server/internal/ext"
"github.com/Defacto2/server/handler/html3/ext"
"github.com/Defacto2/server/internal/postgres"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/model/expr"
Expand Down
5 changes: 2 additions & 3 deletions model/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import (
"net/url"
"time"

"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/pouet"
"github.com/google/uuid"
"github.com/volatiletech/null/v8"
"github.com/volatiletech/sqlboiler/v4/boil"
Expand All @@ -24,7 +23,7 @@ func InsertDemozoo(ctx context.Context, exec boil.ContextExecutor, id int64) (in
if exec == nil {
return 0, "", ErrDB
}
if id < startID || id > demozoo.Sanity {
if id < startID || id > DemozooSanity {
return 0, "", fmt.Errorf("%w: %d", ErrID, id)
}

Expand Down
8 changes: 6 additions & 2 deletions model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"path/filepath"
"strings"

"github.com/Defacto2/server/internal/jsdos"
"github.com/Defacto2/server/internal/jsdos/msdos"
"github.com/Defacto2/server/handler/jsdos"
"github.com/Defacto2/server/handler/jsdos/msdos"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/subpop/go-ini"
)
Expand Down Expand Up @@ -57,6 +57,10 @@ const ClauseOldDate = "date_issued_year ASC NULLS LAST, " +
// ClauseNoSoftDel is the clause to exclude soft deleted records.
const ClauseNoSoftDel = "deletedat IS NULL"

const (
DemozooSanity = 450000 // Sanity is to check the maximum permitted production ID.
)

func calc(o, l int) int {
if o < 1 {
o = 1
Expand Down
5 changes: 2 additions & 3 deletions model/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@ import (

"github.com/Defacto2/helper"
"github.com/Defacto2/releaser"
"github.com/Defacto2/server/internal/demozoo"
"github.com/Defacto2/server/handler/pouet"
"github.com/Defacto2/server/internal/postgres/models"
"github.com/Defacto2/server/internal/pouet"
"github.com/Defacto2/server/internal/tags"
"github.com/volatiletech/null/v8"
"github.com/volatiletech/sqlboiler/v4/boil"
Expand Down Expand Up @@ -323,7 +322,7 @@ func UpdateInt64From(db *sql.DB, column int64From, id int64, val string) error {
case i64 == 0 && column == pouetProd:
f.WebIDPouet = null.Int64FromPtr(nil)
case column == demozooProd:
invalid = i64 < 0 || i64 > demozoo.Sanity
invalid = i64 < 0 || i64 > DemozooSanity
f.WebIDDemozoo = null.Int64From(i64)
case column == pouetProd:
invalid = i64 < 0 || i64 > pouet.Sanity
Expand Down

0 comments on commit a87c85d

Please sign in to comment.