mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2025-12-07 18:18:07 -06:00
new styling for frontpage, update login and authorize templates
This commit is contained in:
parent
82d9f88e42
commit
bcf9fe41c2
18 changed files with 873 additions and 60 deletions
|
|
@ -170,6 +170,11 @@ func (c *Config) ParseCLIFlags(f KeyedFlags) error {
|
|||
c.TemplateConfig.BaseDir = f.String(fn.TemplateBaseDir)
|
||||
}
|
||||
|
||||
// template flags
|
||||
if c.TemplateConfig.AssetBaseDir == "" || f.IsSet(fn.AssetBaseDir) {
|
||||
c.TemplateConfig.AssetBaseDir = f.String(fn.AssetBaseDir)
|
||||
}
|
||||
|
||||
// accounts flags
|
||||
if f.IsSet(fn.AccountsOpenRegistration) {
|
||||
c.AccountsConfig.OpenRegistration = f.Bool(fn.AccountsOpenRegistration)
|
||||
|
|
@ -283,6 +288,7 @@ type Flags struct {
|
|||
DbDatabase string
|
||||
|
||||
TemplateBaseDir string
|
||||
AssetBaseDir string
|
||||
|
||||
AccountsOpenRegistration string
|
||||
AccountsApprovalRequired string
|
||||
|
|
@ -326,6 +332,7 @@ type Defaults struct {
|
|||
DbDatabase string
|
||||
|
||||
TemplateBaseDir string
|
||||
AssetBaseDir string
|
||||
|
||||
AccountsOpenRegistration bool
|
||||
AccountsRequireApproval bool
|
||||
|
|
@ -371,6 +378,7 @@ func GetFlagNames() Flags {
|
|||
DbDatabase: "db-database",
|
||||
|
||||
TemplateBaseDir: "template-basedir",
|
||||
AssetBaseDir: "asset-basedir",
|
||||
|
||||
AccountsOpenRegistration: "accounts-open-registration",
|
||||
AccountsApprovalRequired: "accounts-approval-required",
|
||||
|
|
@ -417,6 +425,7 @@ func GetEnvNames() Flags {
|
|||
DbDatabase: "GTS_DB_DATABASE",
|
||||
|
||||
TemplateBaseDir: "GTS_TEMPLATE_BASEDIR",
|
||||
AssetBaseDir: "GTS_ASSET_BASEDIR",
|
||||
|
||||
AccountsOpenRegistration: "GTS_ACCOUNTS_OPEN_REGISTRATION",
|
||||
AccountsApprovalRequired: "GTS_ACCOUNTS_APPROVAL_REQUIRED",
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ func TestDefault() *Config {
|
|||
},
|
||||
TemplateConfig: &TemplateConfig{
|
||||
BaseDir: defaults.TemplateBaseDir,
|
||||
AssetBaseDir: defaults.AssetBaseDir,
|
||||
},
|
||||
AccountsConfig: &AccountsConfig{
|
||||
OpenRegistration: defaults.AccountsOpenRegistration,
|
||||
|
|
@ -72,6 +73,7 @@ func Default() *Config {
|
|||
},
|
||||
TemplateConfig: &TemplateConfig{
|
||||
BaseDir: defaults.TemplateBaseDir,
|
||||
AssetBaseDir: defaults.AssetBaseDir,
|
||||
},
|
||||
AccountsConfig: &AccountsConfig{
|
||||
OpenRegistration: defaults.AccountsOpenRegistration,
|
||||
|
|
@ -124,6 +126,7 @@ func GetDefaults() Defaults {
|
|||
DbDatabase: "postgres",
|
||||
|
||||
TemplateBaseDir: "./web/template/",
|
||||
AssetBaseDir: "./web/assets/",
|
||||
|
||||
AccountsOpenRegistration: true,
|
||||
AccountsRequireApproval: true,
|
||||
|
|
|
|||
|
|
@ -22,4 +22,6 @@ package config
|
|||
type TemplateConfig struct {
|
||||
// Directory from which gotosocial will attempt to load html templates (.tmpl files).
|
||||
BaseDir string `yaml:"baseDir"`
|
||||
// Directory from which static files are served
|
||||
AssetBaseDir string `yaml:"assetDir"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -151,6 +151,22 @@ func New(config *config.Config, logger *logrus.Logger) (Router, error) {
|
|||
logger.Debugf("loading templates from %s", tmPath)
|
||||
engine.LoadHTMLGlob(tmPath)
|
||||
|
||||
// serve static files from /assets
|
||||
// FIXME: why doesn't this config var work??
|
||||
// assetPath := filepath.Join(cwd, config.TemplateConfig.AssetBaseDir);
|
||||
engine.Static("/assets", "./web/assets");
|
||||
|
||||
// FIXME: actual variables
|
||||
engine.GET("/", func(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "index.tmpl", gin.H{
|
||||
"instancename": "GoToSocial Test Instance",
|
||||
"countUsers": 3,
|
||||
"countStatuses": 42069,
|
||||
"version": "1.0.0",
|
||||
"adminUsername": "@admin",
|
||||
})
|
||||
});
|
||||
|
||||
// create the actual http server here
|
||||
s := &http.Server{
|
||||
Handler: engine,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue