mirror of
https://github.com/mxpv/podsync.git
synced 2024-05-11 05:55:04 +00:00
Minify scripts, update docker container
This commit is contained in:
@@ -17,6 +17,8 @@ type AppConfig struct {
|
||||
PostgresConnectionURL string `yaml:"postgresConnectionUrl"`
|
||||
RedisURL string `yaml:"redisUrl"`
|
||||
CookieSecret string `yaml:"cookieSecret"`
|
||||
AssetsPath string `yaml:"assetsPath"`
|
||||
TemplatesPath string `yaml:"templatesPath"`
|
||||
}
|
||||
|
||||
func ReadConfiguration() (cfg *AppConfig, err error) {
|
||||
@@ -39,6 +41,8 @@ func ReadConfiguration() (cfg *AppConfig, err error) {
|
||||
"postgresConnectionUrl": "POSTGRES_CONNECTION_URL",
|
||||
"redisUrl": "REDIS_CONNECTION_URL",
|
||||
"cookieSecret": "COOKIE_SECRET",
|
||||
"assetsPath": "ASSETS_PATH",
|
||||
"templatesPath": "TEMPLATES_PATH",
|
||||
}
|
||||
|
||||
for k, v := range envmap {
|
||||
|
@@ -17,6 +17,8 @@ patreonSecret: "4"
|
||||
postgresConnectionUrl: "5"
|
||||
cookieSecret: "6"
|
||||
patreonRedirectUrl: "7"
|
||||
assetsPath: "8"
|
||||
templatesPath: "9"
|
||||
`
|
||||
|
||||
func TestReadYaml(t *testing.T) {
|
||||
@@ -36,6 +38,8 @@ func TestReadYaml(t *testing.T) {
|
||||
require.Equal(t, "5", cfg.PostgresConnectionURL)
|
||||
require.Equal(t, "6", cfg.CookieSecret)
|
||||
require.Equal(t, "7", cfg.PatreonRedirectURL)
|
||||
require.Equal(t, "8", cfg.AssetsPath)
|
||||
require.Equal(t, "9", cfg.TemplatesPath)
|
||||
}
|
||||
|
||||
func TestReadEnv(t *testing.T) {
|
||||
@@ -49,6 +53,8 @@ func TestReadEnv(t *testing.T) {
|
||||
os.Setenv("POSTGRES_CONNECTION_URL", "55")
|
||||
os.Setenv("COOKIE_SECRET", "66")
|
||||
os.Setenv("PATREON_REDIRECT_URL", "77")
|
||||
os.Setenv("ASSETS_PATH", "88")
|
||||
os.Setenv("TEMPLATES_PATH", "99")
|
||||
|
||||
cfg, err := ReadConfiguration()
|
||||
require.NoError(t, err)
|
||||
@@ -60,4 +66,6 @@ func TestReadEnv(t *testing.T) {
|
||||
require.Equal(t, "55", cfg.PostgresConnectionURL)
|
||||
require.Equal(t, "66", cfg.CookieSecret)
|
||||
require.Equal(t, "77", cfg.PatreonRedirectURL)
|
||||
require.Equal(t, "88", cfg.AssetsPath)
|
||||
require.Equal(t, "99", cfg.TemplatesPath)
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"go/build"
|
||||
"log"
|
||||
"net/http"
|
||||
"path"
|
||||
@@ -39,9 +38,11 @@ func MakeHandlers(feed feed, cfg *config.AppConfig) http.Handler {
|
||||
|
||||
// Static files + HTML
|
||||
|
||||
if cfg.PatreonRedirectURL == "" {
|
||||
cfg.PatreonRedirectURL = "http://localhost:8080/patreon"
|
||||
}
|
||||
log.Printf("using assets path: %s", cfg.AssetsPath)
|
||||
r.Static("/assets", cfg.AssetsPath)
|
||||
|
||||
log.Printf("using templates path: %s", cfg.TemplatesPath)
|
||||
r.LoadHTMLGlob(path.Join(cfg.TemplatesPath, "*.html"))
|
||||
|
||||
conf := &oauth2.Config{
|
||||
ClientID: cfg.PatreonClientId,
|
||||
@@ -54,12 +55,6 @@ func MakeHandlers(feed feed, cfg *config.AppConfig) http.Handler {
|
||||
},
|
||||
}
|
||||
|
||||
rootDir := path.Join(build.Default.GOPATH, "src/github.com/mxpv/podsync")
|
||||
log.Printf("Using root directory: %s", rootDir)
|
||||
|
||||
r.Static("/assets", path.Join(rootDir, "assets"))
|
||||
r.LoadHTMLGlob(path.Join(rootDir, "templates/*.html"))
|
||||
|
||||
r.GET("/", func(c *gin.Context) {
|
||||
s := sessions.Default(c)
|
||||
|
||||
|
Reference in New Issue
Block a user