flounder

A simple gemini site builder
git clone git://git.alexwennerberg.com/flounder
Log | Files | Refs | README | LICENSE

config.go (1153B) - raw


      1 package main
      2 
      3 import (
      4 	"path/filepath"
      5 
      6 	"github.com/BurntSushi/toml"
      7 )
      8 
      9 const HiddenFolder = ".hidden"
     10 const GemlogFolder = "gemlog"
     11 
     12 type Config struct {
     13 	FilesDirectory     string
     14 	TemplatesDirectory string
     15 	Host               string
     16 	HttpPort           int
     17 	SiteTitle          string
     18 	Debug              bool
     19 	Hack               bool // No one else uses this code. I will try to box hacks within this bool
     20 	SecretKey          string
     21 	DBFile             string
     22 	AnalyticsDBFile    string
     23 	LogFile            string
     24 	GeminiCertStore    string
     25 	CookieStoreKey     string
     26 	OkExtensions       []string
     27 	MaxFileBytes       int
     28 	MaxFilesPerUser    int
     29 	MaxUserBytes       int64
     30 	SMTPServer         string
     31 	SMTPUsername       string
     32 	SMTPPassword       string
     33 	EnableSFTP         bool
     34 	HostKeyPath        string
     35 }
     36 
     37 func getConfig(filename string) (Config, error) {
     38 	var config Config
     39 	// Attempt to overwrite defaults from file
     40 	_, err := toml.DecodeFile(filename, &config)
     41 	if err != nil {
     42 		return config, err
     43 	}
     44 	// Workaround for how some of my path fns are written
     45 	config.FilesDirectory, _ = filepath.Abs(config.FilesDirectory)
     46 	return config, nil
     47 }