Working auth and photo json endpoint
Signed-off-by: Kris Nóva <kris@nivenly.com>
This commit is contained in:
parent
ef275f97f4
commit
e4323b6047
2032 changed files with 821464 additions and 52 deletions
0
vendor/github.com/dsoprea/go-photoshop-info-format/.MODULE_ROOT
generated
vendored
Normal file
0
vendor/github.com/dsoprea/go-photoshop-info-format/.MODULE_ROOT
generated
vendored
Normal file
14
vendor/github.com/dsoprea/go-photoshop-info-format/.travis.yml
generated
vendored
Normal file
14
vendor/github.com/dsoprea/go-photoshop-info-format/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
language: go
|
||||
go:
|
||||
- master
|
||||
- stable
|
||||
- "1.13"
|
||||
- "1.12"
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
install:
|
||||
- go get -t ./...
|
||||
- go get github.com/mattn/goveralls
|
||||
script:
|
||||
- go test -v ./...
|
||||
- goveralls -v -service=travis-ci
|
21
vendor/github.com/dsoprea/go-photoshop-info-format/LICENSE
generated
vendored
Normal file
21
vendor/github.com/dsoprea/go-photoshop-info-format/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Dustin Oprea
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
8
vendor/github.com/dsoprea/go-photoshop-info-format/README.md
generated
vendored
Normal file
8
vendor/github.com/dsoprea/go-photoshop-info-format/README.md
generated
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
[](https://travis-ci.org/dsoprea/go-photoshop-info-format)
|
||||
[](https://coveralls.io/github/dsoprea/go-photoshop-info-format?branch=master)
|
||||
[](https://goreportcard.com/report/github.com/dsoprea/go-photoshop-info-format)
|
||||
[](https://godoc.org/github.com/dsoprea/go-photoshop-info-format)
|
||||
|
||||
# Overview
|
||||
|
||||
This is a minimal Photoshop format implementation to allow IPTC data to be extracted from a JPEG image. This project primarily services [go-jpeg-image-structure](https://github.com/dsoprea/go-jpeg-image-structure).
|
5
vendor/github.com/dsoprea/go-photoshop-info-format/go.mod
generated
vendored
Normal file
5
vendor/github.com/dsoprea/go-photoshop-info-format/go.mod
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
module github.com/dsoprea/go-photoshop-info-format
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/dsoprea/go-logging v0.0.0-20200517223158-a10564966e9d
|
10
vendor/github.com/dsoprea/go-photoshop-info-format/go.sum
generated
vendored
Normal file
10
vendor/github.com/dsoprea/go-photoshop-info-format/go.sum
generated
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
github.com/dsoprea/go-logging v0.0.0-20200517223158-a10564966e9d h1:F/7L5wr/fP/SKeO5HuMlNEX9Ipyx2MbH2rV9G4zJRpk=
|
||||
github.com/dsoprea/go-logging v0.0.0-20200517223158-a10564966e9d/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
|
||||
github.com/go-errors/errors v1.0.2 h1:xMxH9j2fNg/L4hLn/4y3M0IUsn0M6Wbu/Uh9QlOfBh4=
|
||||
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 h1:WQ8q63x+f/zpC8Ac1s9wLElVoHhm32p6tudrU72n1QA=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
119
vendor/github.com/dsoprea/go-photoshop-info-format/info.go
generated
vendored
Normal file
119
vendor/github.com/dsoprea/go-photoshop-info-format/info.go
generated
vendored
Normal file
|
@ -0,0 +1,119 @@
|
|||
package photoshopinfo
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"encoding/binary"
|
||||
|
||||
log "github.com/dsoprea/go-logging"
|
||||
)
|
||||
|
||||
var (
|
||||
defaultByteOrder = binary.BigEndian
|
||||
)
|
||||
|
||||
// Photoshop30InfoRecord is the data for one parsed Photoshop-info record.
|
||||
type Photoshop30InfoRecord struct {
|
||||
// RecordType is the record-type.
|
||||
RecordType string
|
||||
|
||||
// ImageResourceId is the image resource-ID.
|
||||
ImageResourceId uint16
|
||||
|
||||
// Name is the name of the record. It is optional and will be an empty-
|
||||
// string if not present.
|
||||
Name string
|
||||
|
||||
// Data is the raw record data.
|
||||
Data []byte
|
||||
}
|
||||
|
||||
// String returns a descriptive string.
|
||||
func (pir Photoshop30InfoRecord) String() string {
|
||||
return fmt.Sprintf("RECORD-TYPE=[%s] IMAGE-RESOURCE-ID=[0x%04x] NAME=[%s] DATA-SIZE=(%d)", pir.RecordType, pir.ImageResourceId, pir.Name, len(pir.Data))
|
||||
}
|
||||
|
||||
// ReadPhotoshop30InfoRecord parses a single photoshop-info record.
|
||||
func ReadPhotoshop30InfoRecord(r io.Reader) (pir Photoshop30InfoRecord, err error) {
|
||||
defer func() {
|
||||
if state := recover(); state != nil {
|
||||
err = log.Wrap(state.(error))
|
||||
}
|
||||
}()
|
||||
|
||||
recordType := make([]byte, 4)
|
||||
_, err = io.ReadFull(r, recordType)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
return pir, err
|
||||
}
|
||||
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
// TODO(dustin): Move BigEndian to constant/config.
|
||||
|
||||
irId := uint16(0)
|
||||
err = binary.Read(r, defaultByteOrder, &irId)
|
||||
log.PanicIf(err)
|
||||
|
||||
nameSize := uint8(0)
|
||||
err = binary.Read(r, defaultByteOrder, &nameSize)
|
||||
log.PanicIf(err)
|
||||
|
||||
// Add an extra byte if the two length+data size is odd to make the total
|
||||
// bytes read even.
|
||||
doAddPadding := (1+nameSize)%2 == 1
|
||||
if doAddPadding == true {
|
||||
nameSize++
|
||||
}
|
||||
|
||||
name := make([]byte, nameSize)
|
||||
_, err = io.ReadFull(r, name)
|
||||
log.PanicIf(err)
|
||||
|
||||
// If the last byte is padding, truncate it.
|
||||
if doAddPadding == true {
|
||||
name = name[:nameSize-1]
|
||||
}
|
||||
|
||||
dataSize := uint32(0)
|
||||
err = binary.Read(r, defaultByteOrder, &dataSize)
|
||||
log.PanicIf(err)
|
||||
|
||||
data := make([]byte, dataSize+dataSize%2)
|
||||
_, err = io.ReadFull(r, data)
|
||||
log.PanicIf(err)
|
||||
|
||||
data = data[:dataSize]
|
||||
|
||||
pir = Photoshop30InfoRecord{
|
||||
RecordType: string(recordType),
|
||||
ImageResourceId: irId,
|
||||
Name: string(name),
|
||||
Data: data,
|
||||
}
|
||||
|
||||
return pir, nil
|
||||
}
|
||||
|
||||
// ReadPhotoshop30Info parses a sequence of photoship-info records from the stream.
|
||||
func ReadPhotoshop30Info(r io.Reader) (pirIndex map[uint16]Photoshop30InfoRecord, err error) {
|
||||
pirIndex = make(map[uint16]Photoshop30InfoRecord)
|
||||
|
||||
for {
|
||||
pir, err := ReadPhotoshop30InfoRecord(r)
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
break
|
||||
}
|
||||
|
||||
log.Panic(err)
|
||||
}
|
||||
|
||||
pirIndex[pir.ImageResourceId] = pir
|
||||
}
|
||||
|
||||
return pirIndex, nil
|
||||
}
|
73
vendor/github.com/dsoprea/go-photoshop-info-format/testing_common.go
generated
vendored
Normal file
73
vendor/github.com/dsoprea/go-photoshop-info-format/testing_common.go
generated
vendored
Normal file
|
@ -0,0 +1,73 @@
|
|||
package photoshopinfo
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
log "github.com/dsoprea/go-logging"
|
||||
)
|
||||
|
||||
var (
|
||||
testDataRelFilepath = "photoshop.data"
|
||||
)
|
||||
|
||||
var (
|
||||
moduleRootPath = ""
|
||||
assetsPath = ""
|
||||
)
|
||||
|
||||
// GetModuleRootPath returns the root-path of the module.
|
||||
func GetModuleRootPath() string {
|
||||
if moduleRootPath == "" {
|
||||
moduleRootPath = os.Getenv("PHOTOSHOPINFO_MODULE_ROOT_PATH")
|
||||
if moduleRootPath != "" {
|
||||
return moduleRootPath
|
||||
}
|
||||
|
||||
currentWd, err := os.Getwd()
|
||||
log.PanicIf(err)
|
||||
|
||||
currentPath := currentWd
|
||||
visited := make([]string, 0)
|
||||
|
||||
for {
|
||||
tryStampFilepath := path.Join(currentPath, ".MODULE_ROOT")
|
||||
|
||||
_, err := os.Stat(tryStampFilepath)
|
||||
if err != nil && os.IsNotExist(err) != true {
|
||||
log.Panic(err)
|
||||
} else if err == nil {
|
||||
break
|
||||
}
|
||||
|
||||
visited = append(visited, tryStampFilepath)
|
||||
|
||||
currentPath = path.Dir(currentPath)
|
||||
if currentPath == "/" {
|
||||
log.Panicf("could not find module-root: %v", visited)
|
||||
}
|
||||
}
|
||||
|
||||
moduleRootPath = currentPath
|
||||
}
|
||||
|
||||
return moduleRootPath
|
||||
}
|
||||
|
||||
// GetTestAssetsPath returns the path of the test-assets.
|
||||
func GetTestAssetsPath() string {
|
||||
if assetsPath == "" {
|
||||
moduleRootPath := GetModuleRootPath()
|
||||
assetsPath = path.Join(moduleRootPath, "assets")
|
||||
}
|
||||
|
||||
return assetsPath
|
||||
}
|
||||
|
||||
// GetTestDataFilepath returns the file-path of the common test-data.
|
||||
func GetTestDataFilepath() string {
|
||||
assetsPath := GetTestAssetsPath()
|
||||
filepath := path.Join(assetsPath, testDataRelFilepath)
|
||||
|
||||
return filepath
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue