diff --git a/internal/domain/resource.go b/internal/domain/resource.go index ff96a60..a855fbf 100644 --- a/internal/domain/resource.go +++ b/internal/domain/resource.go @@ -15,15 +15,14 @@ import ( ) type Resource struct { - File Path - modTime time.Time - params map[string]any // TODO(toby3d): set from Page configuration + params map[string]any + File Path mediaType MediaType key string - name string // TODO(toby3d): set from Page configuration - title string // TODO(toby3d): set from Page configuration + name string resourceType ResourceType + title string image image.Config } @@ -69,13 +68,13 @@ func (r Resource) MediaType() MediaType { } // Width returns width if current r is an image. -func (r Resource) Width() int { - return r.image.Width +func (r Resource) Width() uint { + return uint(r.image.Width) } // Height returns height if current r is an image. -func (r Resource) Height() int { - return r.image.Height +func (r Resource) Height() uint { + return uint(r.image.Height) } func (r Resource) ResourceType() ResourceType { diff --git a/internal/resource/repository.go b/internal/resource/repository.go index a1042cf..8258f13 100644 --- a/internal/resource/repository.go +++ b/internal/resource/repository.go @@ -6,26 +6,10 @@ import ( "source.toby3d.me/toby3d/home/internal/domain" ) -type ( - Repository interface { - // Get returns Resource on path if exists. - Get(ctx context.Context, path string) (*domain.Resource, error) +type Repository interface { + // Get returns Resource on path if exists. + Get(ctx context.Context, path string) (*domain.Resource, error) - // Fetch returns all resources from dir recursevly. - Fetch(ctx context.Context, pattern string) (domain.Resources, int, error) - } - - dummyRepository struct{} -) - -func NewDummyRepository() dummyRepository { - return dummyRepository{} -} - -func (dummyRepository) Get(ctx context.Context, path string) (*domain.Resource, error) { - return nil, nil -} - -func (dummyRepository) Fetch(ctx context.Context, pattern string) (domain.Resources, int, error) { - return nil, 0, nil + // Fetch returns all resources from dir recursevly. + Fetch(ctx context.Context, pattern string) (domain.Resources, int, error) } diff --git a/internal/resource/repository/dummy/dummy_resource.go b/internal/resource/repository/dummy/dummy_resource.go new file mode 100644 index 0000000..be373b3 --- /dev/null +++ b/internal/resource/repository/dummy/dummy_resource.go @@ -0,0 +1,21 @@ +package dummy + +import ( + "context" + + "source.toby3d.me/toby3d/home/internal/domain" +) + +type dummyResourceRepository struct{} + +func NewDummyResourceRepository() dummyResourceRepository { + return dummyResourceRepository{} +} + +func (dummyResourceRepository) Get(_ context.Context, _ string) (*domain.Resource, error) { + return nil, nil +} + +func (dummyResourceRepository) Fetch(_ context.Context, _ string) (domain.Resources, int, error) { + return nil, 0, nil +} diff --git a/internal/resource/repository/fs/fs_resource.go b/internal/resource/repository/fs/fs_resource.go index 9413e47..ab25d3d 100644 --- a/internal/resource/repository/fs/fs_resource.go +++ b/internal/resource/repository/fs/fs_resource.go @@ -3,14 +3,8 @@ package fs import ( "context" "fmt" - _ "image/gif" - _ "image/jpeg" - _ "image/png" "io/fs" - _ "golang.org/x/image/bmp" - _ "golang.org/x/image/webp" - "source.toby3d.me/toby3d/home/internal/domain" "source.toby3d.me/toby3d/home/internal/resource" ) diff --git a/internal/static/repository/fs/fs_static.go b/internal/static/repository/fs/fs_static.go index 83c4a6e..d4221b6 100644 --- a/internal/static/repository/fs/fs_static.go +++ b/internal/static/repository/fs/fs_static.go @@ -5,17 +5,11 @@ import ( "context" "errors" "fmt" - _ "image/gif" - _ "image/jpeg" - _ "image/png" "io" "io/fs" "os" "path/filepath" - _ "golang.org/x/image/bmp" - _ "golang.org/x/image/webp" - "source.toby3d.me/toby3d/home/internal/domain" "source.toby3d.me/toby3d/home/internal/static" )