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
|
package studip
import (
"fmt"
"path/filepath"
"runtime"
"github.com/rclone/rclone/fs"
"github.com/rclone/rclone/fs/config"
"github.com/rclone/rclone/lib/encoder"
)
func init() {
fs.Register(&fs.RegInfo{
Name: "Stud.IP",
Prefix: "studip",
Description: "Stud.IP",
NewFs: NewFs,
Options: []fs.Option{{
Name: "base_url",
Help: "Base URL of the Stud.IP JSON API v1 endpoint",
Default: "https://elearning.uni-bremen.de/jsonapi.php/v1/",
Required: true,
}, {
Name: "username",
Help: "Stud.IP username used for login",
Required: true,
}, {
Name: "password",
Help: "Stud.IP password used for login",
IsPassword: true,
Required: true,
}, {
Name: "course_id",
Help: "Stud.IP course ID (e.g. 59e88658b39093836455413bd1f24f29)",
Required: true,
}, {
Name: "license",
Help: "License ID applied to uploaded files",
Required: true,
Default: "UNDEF_LICENSE",
Examples: fs.OptionExamples{
fs.OptionExample{
Value: "FREE_LICENSE",
Help: "Works that have been published under a free license, i.e. the distribution and usually also modification of which is permitted without license costs, may be made available for teaching without restrictions. \n\nTypical examples are:\n- Open Access publications \n- Open Educational Resources (OER) \n- Works under Creative Commons licenses (e.g. Wikipedia content) \n\nAttention: Make sure on a case-by-case basis what restrictions on distribution and modification the respective license may contain.",
},
fs.OptionExample{
Value: "SELFMADE_NONPUB",
Help: "Self-authored, unpublished work",
},
fs.OptionExample{
Value: "NON_TEXTUAL",
Help: "Copyright-protected and published works",
},
fs.OptionExample{
Value: "TEXT_NO_LICENSE",
Help: "Published texts without an acquired license or separate permission",
},
fs.OptionExample{
Value: "WITH_LICENSE",
Help: "Permission of use or license exists",
},
fs.OptionExample{
Value: "UNDEF_LICENSE",
Help: "Unclear License",
},
},
}, {
Name: config.ConfigEncoding,
Help: config.ConfigEncodingHelp,
Advanced: true,
Default: (encoder.Base |
encoder.EncodeLeftSpace |
encoder.EncodeRightSpace |
encoder.EncodeCrLf |
encoder.EncodeLeftCrLfHtVt |
encoder.EncodeRightCrLfHtVt |
encoder.EncodeInvalidUtf8),
},
},
})
}
type Options struct {
BaseURL string `config:"base_url"`
Username string `config:"username"`
Password string `config:"password"`
CourseID string `config:"course_id"`
License string `config:"license"`
Enc encoder.MultiEncoder `config:"encoding"`
}
var (
_ fs.Fs = &Fs{}
_ fs.Object = &Object{}
_ fs.Purger = &Fs{}
_ fs.Mover = &Fs{}
_ fs.DirMover = &Fs{}
_ fs.MimeTyper = &Object{}
_ fs.Directory = &Directory{}
)
func Assert(cond bool, msg string) {
if cond {
return
}
if msg == "" {
msg = "condition is false"
}
pc, file, line, ok := runtime.Caller(1)
if !ok {
panic("assert failed: " + msg)
}
fnName := "<unknown>"
if fn := runtime.FuncForPC(pc); fn != nil {
fnName = fn.Name()
}
panic(fmt.Sprintf(
"assert failed at %s:%d (%s): %s",
filepath.Base(file),
line,
fnName,
msg,
))
}
|