2021-01-19 16:35:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2021 A Bunch Tell LLC.
|
|
|
|
*
|
|
|
|
* This file is part of text-pic.
|
|
|
|
*
|
|
|
|
* text-pic is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, included
|
|
|
|
* in the LICENSE file in this source code package.
|
|
|
|
*/
|
|
|
|
|
|
|
|
package textpic
|
|
|
|
|
2021-01-19 17:36:16 +00:00
|
|
|
var fonts = map[string]string{
|
|
|
|
"norm": "Lora",
|
|
|
|
"serif": "Lora",
|
|
|
|
"sans": "OpenSans",
|
|
|
|
"mono": "Hack",
|
|
|
|
"wrap": "Hack",
|
|
|
|
}
|
|
|
|
|
2021-01-19 16:35:44 +00:00
|
|
|
type ContentOptions struct {
|
|
|
|
// Author information
|
|
|
|
Instance string
|
|
|
|
Username string
|
|
|
|
|
|
|
|
// Write.as-only option
|
|
|
|
IsSubdomain bool // UNIMPLEMENTED
|
|
|
|
|
|
|
|
// Content
|
2021-01-19 17:36:16 +00:00
|
|
|
UserFont string
|
|
|
|
Content string
|
2021-01-19 16:35:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func NewContentOptions(instance, username string, isSubdomain bool, font, content string) *ContentOptions {
|
|
|
|
opt := &ContentOptions{
|
|
|
|
Instance: instance,
|
|
|
|
Username: username,
|
|
|
|
IsSubdomain: isSubdomain,
|
2021-01-19 17:36:16 +00:00
|
|
|
UserFont: font,
|
2021-01-19 16:35:44 +00:00
|
|
|
Content: content,
|
|
|
|
}
|
|
|
|
if opt.Instance == "" {
|
|
|
|
opt.Instance = "write.as"
|
|
|
|
}
|
|
|
|
if opt.Content == "" {
|
|
|
|
opt.Content = "Hello, world!"
|
|
|
|
}
|
|
|
|
return opt
|
|
|
|
}
|
2021-01-19 17:36:16 +00:00
|
|
|
|
|
|
|
func IsValidFont(f string) bool {
|
|
|
|
_, valid := fonts[f]
|
|
|
|
return valid
|
|
|
|
}
|