A tool for archiving & converting scans of postcards, and information about them.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 125 lines 2.6 kB view raw
1package testhelpers 2 3import ( 4 "embed" 5 "fmt" 6 "image" 7 _ "image/png" 8 "math/big" 9 "time" 10 11 "github.com/jphastings/dotpostcard/types" 12) 13 14var ( 15 //go:embed *.png 16 testImagesData embed.FS 17 18 TestImages = make(map[string]image.Image) 19) 20 21func init() { 22 files, err := testImagesData.ReadDir(".") 23 if err != nil { 24 panic("couldn't read from embedded filesystem") 25 } 26 27 for _, de := range files { 28 f, err := testImagesData.Open(de.Name()) 29 if err != nil { 30 panic(fmt.Sprintf("couldn't read '%s' from embedded filesystem: %v", de.Name(), err)) 31 } 32 33 img, _, err := image.Decode(f) 34 if err != nil { 35 panic(fmt.Sprintf("embedded test image couldn't be read: %v", err)) 36 } 37 38 TestImages[de.Name()] = img 39 } 40} 41 42var SamplePostcard = types.Postcard{ 43 Name: "some-postcard", 44 Meta: types.Metadata{ 45 Locale: "en-GB", 46 Location: types.Location{ 47 Name: "Front, Italy", 48 Latitude: &([]float64{45.28}[0]), 49 Longitude: &([]float64{7.66}[0]), 50 CountryCode: "ITA", 51 }, 52 Flip: types.FlipBook, 53 SentOn: &types.Date{ 54 Time: time.Date(2006, time.January, 2, 0, 0, 0, 0, time.UTC), 55 }, 56 Sender: types.Person{ 57 Name: "Alice", 58 Uri: "https://alice.example.com", 59 }, 60 Recipient: types.Person{ 61 Name: "Bob", 62 Uri: "https://bob.example.org", 63 }, 64 Front: types.Side{ 65 Description: "The word 'Front' in large blue letters", 66 Transcription: types.AnnotatedText{ 67 Text: "Front", 68 }, 69 Secrets: []types.Polygon{{ 70 Points: []types.Point{ 71 {0.3, 0.6}, 72 {0.4, 0.6}, 73 {0.4, 0.8}, 74 {0.3, 0.8}, 75 }, 76 }}, 77 }, 78 Back: types.Side{ 79 Description: "The word 'Back' in large red letters", 80 Transcription: types.AnnotatedText{ 81 Text: "Back", 82 Annotations: []types.Annotation{{ 83 Type: types.ATLocale, 84 Value: "en-GB", 85 Start: 0, 86 End: 4, 87 }}, 88 }, 89 Secrets: []types.Polygon{{ 90 Points: []types.Point{ 91 {0, 0}, 92 {0.1, 0}, 93 {0.1, 0.4}, 94 {0, 0.4}, 95 }, 96 }}, 97 }, 98 Context: types.Context{ 99 Author: types.Person{ 100 Name: "Carol", 101 Uri: "https://carol.example.net", 102 }, 103 Description: "This is a sample postcard, with all fields expressed.", 104 }, 105 106 Physical: types.Physical{ 107 FrontDimensions: types.Size{ 108 PxWidth: 1480, 109 PxHeight: 1050, 110 CmWidth: big.NewRat(148, 10), 111 CmHeight: big.NewRat(105, 10), 112 }, 113 ThicknessMM: 0.4, 114 CardColor: &types.Color{R: 230, G: 230, B: 217, A: 255}, 115 }, 116 }, 117 Front: TestImages["sample-front.png"], 118 Back: TestImages["sample-back.png"], 119} 120 121//go:embed sample-meta.xmp 122var SampleXMP []byte 123 124//go:embed sample-meta.yaml 125var SampleYAML []byte