~erock/pico

pico/pastes/config.go -rw-r--r-- 1.7 KiB
0c813f80Eric Bower chore: reference github instead of sr.ht 4 days ago
                                                                                
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
package pastes

import (
	"fmt"

	"github.com/picosh/pico/shared"
	"github.com/picosh/pico/wish/cms/config"
)

func NewConfigSite() *shared.ConfigSite {
	debug := shared.GetEnv("PASTES_DEBUG", "0")
	domain := shared.GetEnv("PASTES_DOMAIN", "pastes.sh")
	email := shared.GetEnv("PASTES_EMAIL", "hello@pastes.sh")
	subdomains := shared.GetEnv("PASTES_SUBDOMAINS", "0")
	customdomains := shared.GetEnv("PASTES_CUSTOMDOMAINS", "0")
	port := shared.GetEnv("PASTES_WEB_PORT", "3000")
	dbURL := shared.GetEnv("DATABASE_URL", "")
	protocol := shared.GetEnv("PASTES_PROTOCOL", "https")
	allowRegister := shared.GetEnv("PASTES_ALLOW_REGISTER", "1")
	storageDir := shared.GetEnv("IMGS_STORAGE_DIR", ".storage")
	minioURL := shared.GetEnv("MINIO_URL", "")
	minioUser := shared.GetEnv("MINIO_ROOT_USER", "")
	minioPass := shared.GetEnv("MINIO_ROOT_PASSWORD", "")

	intro := "To get started, enter a username.\n"
	intro += "Then create a folder locally (e.g. ~/pastes).\n"
	intro += "Then write your paste post (e.g. feature.patch).\n"
	intro += "Finally, send your files to us:\n\n"
	intro += fmt.Sprintf("scp ~/pastes/* %s:/", domain)

	return &shared.ConfigSite{
		Debug:                debug == "1",
		SubdomainsEnabled:    subdomains == "1",
		CustomdomainsEnabled: customdomains == "1",
		ConfigCms: config.ConfigCms{
			Domain:        domain,
			Port:          port,
			Protocol:      protocol,
			Email:         email,
			DbURL:         dbURL,
			StorageDir:    storageDir,
			MinioURL:      minioURL,
			MinioUser:     minioUser,
			MinioPass:     minioPass,
			Description:   "a pastebin for hackers.",
			IntroText:     intro,
			Space:         "pastes",
			Logger:        shared.CreateLogger(),
			AllowRegister: allowRegister == "1",
		},
	}
}