-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedad.go
67 lines (55 loc) · 1.21 KB
/
medad.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
package medad
import (
"context"
"html/template"
"io"
"github.com/janstoon/toolbox/bricks"
)
type (
// LangCode is ISO 639-1 two-letter code
LangCode string
Language struct {
Title string
Rtl bool
}
)
var (
LangCodeEnglish LangCode = "en"
LangCodePersian LangCode = "fa"
Languages = map[LangCode]Language{
LangCodeEnglish: {
Title: "English",
Rtl: false,
},
LangCodePersian: {
Title: "فارسی",
Rtl: true,
},
}
)
// Article contains a multilingual content
type Article struct {
Name string
Content map[LangCode]io.ReadCloser
}
// Loader loads articles from sources
type Loader interface {
Load(ctx context.Context, sources ...string) bricks.Bag[Article]
}
// Compiler converts articles and writes output (files) into destination (directory)
type Compiler interface {
Compile(ctx context.Context, tpl *template.Template, destination string, sources bricks.Bag[Article]) error
}
type Uploader interface {
Upload(ctx context.Context, local, remote string) error
}
type Settings struct {
ArticlesGlob string
TemplatesGlob string
DistDirectory string
FtpHost string
FtpPort string
FtpUsername string
FtpPassword string
RemoteDirectory string
}