-
Notifications
You must be signed in to change notification settings - Fork 39
/
licences.go
89 lines (85 loc) · 2.63 KB
/
licences.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
package common
import (
"io/ioutil"
"log"
"path/filepath"
)
// Add the default licences
func AddDefaultLicences() (err error) {
// The default licences to load into the system
type licenceInfo struct {
DisplayOrder int
FileFormat string
FullName string
Path string
URL string
}
licences := map[string]licenceInfo{
"Not specified": {
DisplayOrder: 100,
FileFormat: "text",
FullName: "No licence specified",
Path: "",
URL: ""},
"CC0": {
DisplayOrder: 200,
FileFormat: "text",
FullName: "Creative Commons Zero 1.0",
Path: "CC0-1.0.txt",
URL: "https://creativecommons.org/publicdomain/zero/1.0/"},
"CC-BY-4.0": {
DisplayOrder: 300,
FileFormat: "text",
FullName: "Creative Commons Attribution 4.0 International",
Path: "CC-BY-4.0.txt",
URL: "https://creativecommons.org/licenses/by/4.0/"},
"CC-BY-SA-4.0": {
DisplayOrder: 400,
FileFormat: "text",
FullName: "Creative Commons Attribution-ShareAlike 4.0 International",
Path: "CC-BY-SA-4.0.txt",
URL: "https://creativecommons.org/licenses/by-sa/4.0/"},
"CC-BY-NC-4.0": {
DisplayOrder: 500,
FileFormat: "text",
FullName: "Creative Commons Attribution-NonCommercial 4.0 International",
Path: "CC-BY-NC-4.0.txt",
URL: "https://creativecommons.org/licenses/by-nc/4.0/"},
"CC-BY-IGO-3.0": {
DisplayOrder: 600,
FileFormat: "html",
FullName: "Creative Commons Attribution 3.0 IGO",
Path: "CC-BY-IGO-3.0.html",
URL: "https://creativecommons.org/licenses/by/3.0/igo/"},
"ODbL-1.0": {
DisplayOrder: 700,
FileFormat: "text",
FullName: "Open Data Commons Open Database License 1.0",
Path: "ODbL-1.0.txt",
URL: "https://opendatacommons.org/licenses/odbl/1.0/"},
"UK-OGL-3": {
DisplayOrder: 800,
FileFormat: "html",
FullName: "United Kingdom Open Government Licence 3",
Path: "UK-OGL3.html",
URL: "https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/"},
}
// Add the default licences to PostgreSQL
for lName, l := range licences {
txt := []byte{}
if l.Path != "" {
// Read the file contents
txt, err = ioutil.ReadFile(filepath.Join(Conf.Licence.LicenceDir, l.Path))
if err != nil {
return err
}
}
// Save the licence text, sha256, and friendly name in the database
err = StoreLicence("default", lName, txt, l.URL, l.DisplayOrder, l.FullName, l.FileFormat)
if err != nil {
return err
}
}
log.Println("Default licences added")
return nil
}