mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 21:09:05 +00:00
Adding image description to sidebar
This commit is contained in:
@@ -130,6 +130,7 @@ type ComplexityRoot struct {
|
||||
Camera func(childComplexity int) int
|
||||
Coordinates func(childComplexity int) int
|
||||
DateShot func(childComplexity int) int
|
||||
Description func(childComplexity int) int
|
||||
Exposure func(childComplexity int) int
|
||||
ExposureProgram 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
|
||||
|
||||
case "MediaEXIF.description":
|
||||
if e.complexity.MediaEXIF.Description == nil {
|
||||
break
|
||||
}
|
||||
|
||||
return e.complexity.MediaEXIF.Description(childComplexity), true
|
||||
|
||||
case "MediaEXIF.exposure":
|
||||
if e.complexity.MediaEXIF.Exposure == nil {
|
||||
break
|
||||
@@ -2088,6 +2096,8 @@ type Media {
|
||||
type MediaEXIF {
|
||||
id: ID!
|
||||
media: Media!
|
||||
"The description of the image"
|
||||
description: String
|
||||
"The model name of the camera"
|
||||
camera: String
|
||||
"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)
|
||||
}
|
||||
|
||||
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) {
|
||||
defer func() {
|
||||
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 {
|
||||
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":
|
||||
innerFunc := func(ctx context.Context) (res graphql.Marshaler) {
|
||||
return ec._MediaEXIF_camera(ctx, field, obj)
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
|
||||
type MediaEXIF struct {
|
||||
Model
|
||||
Description *string
|
||||
Camera *string
|
||||
Maker *string
|
||||
Lens *string
|
||||
|
||||
@@ -382,6 +382,8 @@ type Media {
|
||||
type MediaEXIF {
|
||||
id: ID!
|
||||
media: Media!
|
||||
"The description of the image"
|
||||
description: String
|
||||
"The model name of the camera"
|
||||
camera: String
|
||||
"The maker of the camera"
|
||||
|
||||
@@ -81,6 +81,13 @@ func (p *externalExifParser) ParseExif(media_path string) (returnExif *models.Me
|
||||
newExif := models.MediaEXIF{}
|
||||
found_exif := false
|
||||
|
||||
// Get description
|
||||
description, err := fileInfo.GetString("ImageDescription")
|
||||
if err == nil {
|
||||
found_exif = true
|
||||
newExif.Description = &description
|
||||
}
|
||||
|
||||
// Get camera model
|
||||
model, err := fileInfo.GetString("Model")
|
||||
if err == nil {
|
||||
|
||||
@@ -44,6 +44,11 @@ func (p internalExifParser) ParseExif(media_path string) (returnExif *models.Med
|
||||
|
||||
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)
|
||||
if err == nil {
|
||||
newExif.Camera = model
|
||||
|
||||
@@ -48,6 +48,7 @@ func TestExifParsers(t *testing.T) {
|
||||
{
|
||||
path: "./test_data/bird.jpg",
|
||||
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.EqualValues(t, *exif.Camera, "Canon EOS 600D")
|
||||
assert.EqualValues(t, *exif.Maker, "Canon")
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Reference in New Issue
Block a user