/
path.go
40 lines (30 loc) · 895 Bytes
/
path.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
package ldsorg
import (
"os"
"path"
"github.com/duckbrain/ldss/lib"
)
// The server to access the Gospel Library catalog and language lists from
var GospelLibraryServer = "https://tech.lds.org/glweb"
const mkdirMode = os.ModeDir | os.ModePerm
const platformID = 17
// Local Paths
func mkdirAndGetFile(paths ...string) string {
os.MkdirAll(path.Join(paths[:len(paths)-1]...), mkdirMode)
return path.Join(paths...)
}
func languagesPath() string {
return mkdirAndGetFile(lib.DataDirectory, "languages.json")
}
func catalogPath(lang lib.Lang) string {
return mkdirAndGetFile(lib.DataDirectory, lang.Code(), "catalog.json")
}
func bookPath(book *book) string {
return mkdirAndGetFile(lib.DataDirectory,
book.catalog.Lang().Code(),
book.Path(), "contents.sqlite")
}
// Server Paths
func getServerAction(action string) string {
return GospelLibraryServer + "?action=" + action
}