Merge pull request #668 from jmc265/adding-image-description
Adding image description to sidebar
This commit is contained in:
commit
d4f30795fd
|
@ -130,6 +130,7 @@ type ComplexityRoot struct {
|
||||||
Camera func(childComplexity int) int
|
Camera func(childComplexity int) int
|
||||||
Coordinates func(childComplexity int) int
|
Coordinates func(childComplexity int) int
|
||||||
DateShot func(childComplexity int) int
|
DateShot func(childComplexity int) int
|
||||||
|
Description func(childComplexity int) int
|
||||||
Exposure func(childComplexity int) int
|
Exposure func(childComplexity int) int
|
||||||
ExposureProgram func(childComplexity int) int
|
ExposureProgram func(childComplexity int) int
|
||||||
Flash func(childComplexity int) int
|
Flash func(childComplexity int) int
|
||||||
|
@ -739,6 +740,13 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in
|
||||||
|
|
||||||
return e.complexity.MediaEXIF.DateShot(childComplexity), true
|
return e.complexity.MediaEXIF.DateShot(childComplexity), true
|
||||||
|
|
||||||
|
case "MediaEXIF.description":
|
||||||
|
if e.complexity.MediaEXIF.Description == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return e.complexity.MediaEXIF.Description(childComplexity), true
|
||||||
|
|
||||||
case "MediaEXIF.exposure":
|
case "MediaEXIF.exposure":
|
||||||
if e.complexity.MediaEXIF.Exposure == nil {
|
if e.complexity.MediaEXIF.Exposure == nil {
|
||||||
break
|
break
|
||||||
|
@ -2088,6 +2096,8 @@ type Media {
|
||||||
type MediaEXIF {
|
type MediaEXIF {
|
||||||
id: ID!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
|
"The description of the image"
|
||||||
|
description: String
|
||||||
"The model name of the camera"
|
"The model name of the camera"
|
||||||
camera: String
|
camera: String
|
||||||
"The maker of the camera"
|
"The maker of the camera"
|
||||||
|
@ -4754,6 +4764,38 @@ func (ec *executionContext) _MediaEXIF_media(ctx context.Context, field graphql.
|
||||||
return ec.marshalNMedia2ᚖgithubᚗcomᚋphotoviewᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res)
|
return ec.marshalNMedia2ᚖgithubᚗcomᚋphotoviewᚋphotoviewᚋapiᚋgraphqlᚋmodelsᚐMedia(ctx, field.Selections, res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ec *executionContext) _MediaEXIF_description(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) {
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
ec.Error(ctx, ec.Recover(ctx, r))
|
||||||
|
ret = graphql.Null
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
fc := &graphql.FieldContext{
|
||||||
|
Object: "MediaEXIF",
|
||||||
|
Field: field,
|
||||||
|
Args: nil,
|
||||||
|
IsMethod: false,
|
||||||
|
IsResolver: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx = graphql.WithFieldContext(ctx, fc)
|
||||||
|
resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) {
|
||||||
|
ctx = rctx // use context from middleware stack in children
|
||||||
|
return obj.Description, nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
ec.Error(ctx, err)
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
if resTmp == nil {
|
||||||
|
return graphql.Null
|
||||||
|
}
|
||||||
|
res := resTmp.(*string)
|
||||||
|
fc.Result = res
|
||||||
|
return ec.marshalOString2ᚖstring(ctx, field.Selections, res)
|
||||||
|
}
|
||||||
|
|
||||||
func (ec *executionContext) _MediaEXIF_camera(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) {
|
func (ec *executionContext) _MediaEXIF_camera(ctx context.Context, field graphql.CollectedField, obj *models.MediaEXIF) (ret graphql.Marshaler) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
|
@ -11377,6 +11419,13 @@ func (ec *executionContext) _MediaEXIF(ctx context.Context, sel ast.SelectionSet
|
||||||
if out.Values[i] == graphql.Null {
|
if out.Values[i] == graphql.Null {
|
||||||
invalids++
|
invalids++
|
||||||
}
|
}
|
||||||
|
case "description":
|
||||||
|
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
|
return ec._MediaEXIF_description(ctx, field, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
out.Values[i] = innerFunc(ctx)
|
||||||
|
|
||||||
case "camera":
|
case "camera":
|
||||||
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
||||||
return ec._MediaEXIF_camera(ctx, field, obj)
|
return ec._MediaEXIF_camera(ctx, field, obj)
|
||||||
|
|
|
@ -6,6 +6,7 @@ import (
|
||||||
|
|
||||||
type MediaEXIF struct {
|
type MediaEXIF struct {
|
||||||
Model
|
Model
|
||||||
|
Description *string
|
||||||
Camera *string
|
Camera *string
|
||||||
Maker *string
|
Maker *string
|
||||||
Lens *string
|
Lens *string
|
||||||
|
|
|
@ -382,6 +382,8 @@ type Media {
|
||||||
type MediaEXIF {
|
type MediaEXIF {
|
||||||
id: ID!
|
id: ID!
|
||||||
media: Media!
|
media: Media!
|
||||||
|
"The description of the image"
|
||||||
|
description: String
|
||||||
"The model name of the camera"
|
"The model name of the camera"
|
||||||
camera: String
|
camera: String
|
||||||
"The maker of the camera"
|
"The maker of the camera"
|
||||||
|
|
|
@ -81,6 +81,13 @@ func (p *externalExifParser) ParseExif(media_path string) (returnExif *models.Me
|
||||||
newExif := models.MediaEXIF{}
|
newExif := models.MediaEXIF{}
|
||||||
found_exif := false
|
found_exif := false
|
||||||
|
|
||||||
|
// Get description
|
||||||
|
description, err := fileInfo.GetString("ImageDescription")
|
||||||
|
if err == nil {
|
||||||
|
found_exif = true
|
||||||
|
newExif.Description = &description
|
||||||
|
}
|
||||||
|
|
||||||
// Get camera model
|
// Get camera model
|
||||||
model, err := fileInfo.GetString("Model")
|
model, err := fileInfo.GetString("Model")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -44,6 +44,11 @@ func (p internalExifParser) ParseExif(media_path string) (returnExif *models.Med
|
||||||
|
|
||||||
newExif := models.MediaEXIF{}
|
newExif := models.MediaEXIF{}
|
||||||
|
|
||||||
|
description, err := p.readStringTag(exifTags, exif.ImageDescription, media_path)
|
||||||
|
if err == nil {
|
||||||
|
newExif.Description = description
|
||||||
|
}
|
||||||
|
|
||||||
model, err := p.readStringTag(exifTags, exif.Model, media_path)
|
model, err := p.readStringTag(exifTags, exif.Model, media_path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
newExif.Camera = model
|
newExif.Camera = model
|
||||||
|
|
|
@ -48,6 +48,7 @@ func TestExifParsers(t *testing.T) {
|
||||||
{
|
{
|
||||||
path: "./test_data/bird.jpg",
|
path: "./test_data/bird.jpg",
|
||||||
assert: func(t *testing.T, exif *models.MediaEXIF) {
|
assert: func(t *testing.T, exif *models.MediaEXIF) {
|
||||||
|
assert.EqualValues(t, *exif.Description, "Photo of a Bird")
|
||||||
assert.WithinDuration(t, *exif.DateShot, time.Unix(1336318784, 0).UTC(), time.Minute)
|
assert.WithinDuration(t, *exif.DateShot, time.Unix(1336318784, 0).UTC(), time.Minute)
|
||||||
assert.EqualValues(t, *exif.Camera, "Canon EOS 600D")
|
assert.EqualValues(t, *exif.Camera, "Canon EOS 600D")
|
||||||
assert.EqualValues(t, *exif.Maker, "Canon")
|
assert.EqualValues(t, *exif.Maker, "Canon")
|
||||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
|
@ -68,6 +68,7 @@ export const SHARE_ALBUM_QUERY = gql`
|
||||||
}
|
}
|
||||||
exif {
|
exif {
|
||||||
id
|
id
|
||||||
|
description
|
||||||
camera
|
camera
|
||||||
maker
|
maker
|
||||||
lens
|
lens
|
||||||
|
|
|
@ -49,6 +49,7 @@ export const SHARE_TOKEN_QUERY = gql`
|
||||||
}
|
}
|
||||||
exif {
|
exif {
|
||||||
id
|
id
|
||||||
|
description
|
||||||
camera
|
camera
|
||||||
maker
|
maker
|
||||||
lens
|
lens
|
||||||
|
|
|
@ -106,6 +106,10 @@ export interface SharePageToken_shareToken_media_exif_coordinates {
|
||||||
export interface SharePageToken_shareToken_media_exif {
|
export interface SharePageToken_shareToken_media_exif {
|
||||||
__typename: 'MediaEXIF'
|
__typename: 'MediaEXIF'
|
||||||
id: string
|
id: string
|
||||||
|
/**
|
||||||
|
* The description of the image
|
||||||
|
*/
|
||||||
|
description: string | null
|
||||||
/**
|
/**
|
||||||
* The model name of the camera
|
* The model name of the camera
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -120,6 +120,10 @@ export interface shareAlbumQuery_album_media_exif_coordinates {
|
||||||
export interface shareAlbumQuery_album_media_exif {
|
export interface shareAlbumQuery_album_media_exif {
|
||||||
__typename: 'MediaEXIF'
|
__typename: 'MediaEXIF'
|
||||||
id: string
|
id: string
|
||||||
|
/**
|
||||||
|
* The description of the image
|
||||||
|
*/
|
||||||
|
description: string | null
|
||||||
/**
|
/**
|
||||||
* The model name of the camera
|
* The model name of the camera
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -65,6 +65,7 @@ export const SIDEBAR_MEDIA_QUERY = gql`
|
||||||
}
|
}
|
||||||
exif {
|
exif {
|
||||||
id
|
id
|
||||||
|
description
|
||||||
camera
|
camera
|
||||||
maker
|
maker
|
||||||
lens
|
lens
|
||||||
|
|
|
@ -12,6 +12,7 @@ describe('ExifDetails', () => {
|
||||||
type: MediaType.Photo,
|
type: MediaType.Photo,
|
||||||
exif: {
|
exif: {
|
||||||
id: '0',
|
id: '0',
|
||||||
|
description: null,
|
||||||
camera: null,
|
camera: null,
|
||||||
maker: null,
|
maker: null,
|
||||||
lens: null,
|
lens: null,
|
||||||
|
@ -30,6 +31,7 @@ describe('ExifDetails', () => {
|
||||||
|
|
||||||
render(<ExifDetails media={media} />)
|
render(<ExifDetails media={media} />)
|
||||||
|
|
||||||
|
expect(screen.queryByText('Description')).not.toBeInTheDocument()
|
||||||
expect(screen.queryByText('Camera')).not.toBeInTheDocument()
|
expect(screen.queryByText('Camera')).not.toBeInTheDocument()
|
||||||
expect(screen.queryByText('Maker')).not.toBeInTheDocument()
|
expect(screen.queryByText('Maker')).not.toBeInTheDocument()
|
||||||
expect(screen.queryByText('Lens')).not.toBeInTheDocument()
|
expect(screen.queryByText('Lens')).not.toBeInTheDocument()
|
||||||
|
@ -50,6 +52,7 @@ describe('ExifDetails', () => {
|
||||||
type: MediaType.Photo,
|
type: MediaType.Photo,
|
||||||
exif: {
|
exif: {
|
||||||
id: '1666',
|
id: '1666',
|
||||||
|
description: "Media description",
|
||||||
camera: 'Canon EOS R',
|
camera: 'Canon EOS R',
|
||||||
maker: 'Canon',
|
maker: 'Canon',
|
||||||
lens: 'TAMRON SP 24-70mm F/2.8',
|
lens: 'TAMRON SP 24-70mm F/2.8',
|
||||||
|
@ -72,6 +75,8 @@ describe('ExifDetails', () => {
|
||||||
|
|
||||||
render(<ExifDetails media={media} />)
|
render(<ExifDetails media={media} />)
|
||||||
|
|
||||||
|
expect(screen.getByText('Description')).toBeInTheDocument()
|
||||||
|
|
||||||
expect(screen.getByText('Camera')).toBeInTheDocument()
|
expect(screen.getByText('Camera')).toBeInTheDocument()
|
||||||
expect(screen.getByText('Canon EOS R')).toBeInTheDocument()
|
expect(screen.getByText('Canon EOS R')).toBeInTheDocument()
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,7 @@ const ExifDetails = ({ media }: ExifDetailsProps) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const exifNameLookup = (t: TranslationFn): { [key: string]: string } => ({
|
const exifNameLookup = (t: TranslationFn): { [key: string]: string } => ({
|
||||||
|
description: t('sidebar.media.exif.description', 'Description'),
|
||||||
camera: t('sidebar.media.exif.name.camera', 'Camera'),
|
camera: t('sidebar.media.exif.name.camera', 'Camera'),
|
||||||
maker: t('sidebar.media.exif.name.maker', 'Maker'),
|
maker: t('sidebar.media.exif.name.maker', 'Maker'),
|
||||||
lens: t('sidebar.media.exif.name.lens', 'Lens'),
|
lens: t('sidebar.media.exif.name.lens', 'Lens'),
|
||||||
|
|
|
@ -85,6 +85,10 @@ export interface sidebarMediaQuery_media_exif_coordinates {
|
||||||
export interface sidebarMediaQuery_media_exif {
|
export interface sidebarMediaQuery_media_exif {
|
||||||
__typename: 'MediaEXIF'
|
__typename: 'MediaEXIF'
|
||||||
id: string
|
id: string
|
||||||
|
/**
|
||||||
|
* The description of the image
|
||||||
|
*/
|
||||||
|
description: string | null
|
||||||
/**
|
/**
|
||||||
* The model name of the camera
|
* The model name of the camera
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue