-
Notifications
You must be signed in to change notification settings - Fork 1
/
struts.go
135 lines (115 loc) · 2.75 KB
/
struts.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
package mfGalleryMetaCreatorGo
import (
"fmt"
"path"
"strconv"
"strings"
)
type IntList []int
func (i *IntList) String() string {
return fmt.Sprintf("%d", *i)
}
func (i *IntList) Set(value string) error {
tmp, err := strconv.ParseUint(value, 10, 16)
if err != nil {
*i = append(*i, 0)
} else {
*i = append(*i, int(tmp))
}
return nil
}
type FolderContent struct {
FullPath string
Name string
Time *int64
Title string
Config FolderConfig
Files []string
ImageMetadata map[string]MetaJsonImage
Folder []FolderContent
}
func (fc *FolderContent) GetFullPathFile(file string) string {
return path.Join(fc.FullPath, file)
}
func (fc *FolderContent) GetFolderTitle() string {
if len(fc.Config.Title) > 0 {
return fc.Config.Title
}
return fc.Title
}
func (fc *FolderContent) String() string {
return fc.StringWithIntent(0)
}
func (fc *FolderContent) StringWithIntent(intention int) string {
var sub string = ""
for _, subFolder := range fc.Folder {
sub = sub + subFolder.StringWithIntent(intention+4)
}
intent := strings.Repeat(" ", intention)
return fmt.Sprintf(`%sfullPath: %s
%sfolderName: %s
%sconfig: %s
%sfiles: len -> %d
%stime: %d
%stitle: %s
%sfolder:
%s`, intent, fc.FullPath,
intent, fc.Name,
intent, fc.Config,
intent, len(fc.Files),
intent, fc.Time,
intent, fc.Title,
intent,
sub)
}
type FolderConfig struct {
// sets the title of the album. The default is the folder name.
Title string
// description of the folder. The default is none.
Description string
// sets the cover image for the album. The default is the first image in the album.
Cover string
}
type MetaJson struct {
Meta MetaJsonMeta `json:"meta"`
Images []MetaJsonImage `json:"images"`
SubDirs []MetaJsonSubDir `json:"subDirs"`
}
type MetaJsonMeta struct {
Title string `json:"title"`
Time *int64 `json:"time"`
Description string `json:"description"`
}
type RotationAction int
const (
NO_ROTATION = iota
ROTATE_90
ROTATE_180
ROTATE_270
)
type MetaJsonImage struct {
Filename string `json:"filename"`
Width int `json:"width"`
Height int `json:"height"`
Exif metaJsonExif `json:"exif"`
Rotate RotationAction `json:"-"`
}
type MetaJsonSubDir struct {
FolderName string `json:"foldername"`
Title string `json:"title"`
Time *int64 `json:"time"`
Cover *string `json:"cover"`
ImageCount int `json:"imageCount"`
}
type metaJsonExif struct {
// all values are optional
Make *string `json:"make"`
Model *string `json:"model"`
Time *int64 `json:"time"`
}
type ChromecastImage struct {
Filename string `json:"filename"`
Width int `json:"width"`
Height int `json:"height"`
Time *int64 `json:"time"`
}