Move favicons to server public directory, see #50

This commit is contained in:
Michael Mayer 2018-12-21 04:05:14 +01:00
parent a6e4944821
commit cc44c3e580
9 changed files with 40 additions and 37 deletions

View file

@ -12,8 +12,8 @@ install-bin:
install-assets:
mkdir -p /srv/photoprism/photos
mkdir -p /srv/photoprism/cache
mkdir -p /srv/photoprism/database
cp -r assets/server /srv/photoprism
mkdir -p /srv/photoprism/server/database
cp -r assets/server/public assets/server/templates /srv/photoprism/server
cp -r assets/tensorflow /srv/photoprism
find /srv/photoprism -name '.*' -type f -delete
install-config:

View file

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

Before

Width:  |  Height:  |  Size: 510 KiB

After

Width:  |  Height:  |  Size: 510 KiB

View file

@ -21,9 +21,9 @@
<meta name="author" content="PhotoPrism.org">
<meta name="description" content="Personal photo management powered by Go and Google TensorFlow. Free and open-source. Made with ❤️ in Berlin." />
<link rel="apple-touch-icon" href="/favicon.png">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="icon" type="image/png" href="/favicon.png" />
<link rel="apple-touch-icon" href="/assets/favicons/favicon.png">
<link rel="icon" type="image/png" href="/assets/favicons/favicon.png" />
<link rel="stylesheet" href="/assets/build/app.css?{{ .cssHash }}">

View file

@ -35,17 +35,17 @@ type Config struct {
appCopyright string
debug bool
configFile string
sqlServerHost string
sqlServerPort uint
dbServerPath string
httpServerHost string
httpServerPort int
serverMode string
assetsPath string
cachePath string
originalsPath string
importPath string
exportPath string
sqlServerHost string
sqlServerPort uint
sqlServerPath string
httpServerHost string
httpServerPort int
httpServerMode string
darktableCli string
databaseDriver string
databaseDsn string
@ -90,8 +90,8 @@ func (c *Config) SetValuesFromFile(fileName string) error {
c.sqlServerPort = uint(sqlServerPort)
}
if dbServerPath, err := yamlConfig.Get("db-path"); err == nil {
c.dbServerPath = dbServerPath
if sqlServerPath, err := yamlConfig.Get("sql-path"); err == nil {
c.sqlServerPath = sqlServerPath
}
if httpServerHost, err := yamlConfig.Get("http-host"); err == nil {
@ -103,7 +103,7 @@ func (c *Config) SetValuesFromFile(fileName string) error {
}
if serverMode, err := yamlConfig.Get("http-mode"); err == nil {
c.serverMode = serverMode
c.httpServerMode = serverMode
}
if assetsPath, err := yamlConfig.Get("assets-path"); err == nil {
@ -188,8 +188,8 @@ func (c *Config) SetValuesFromCliContext(ctx *cli.Context) error {
c.sqlServerPort = ctx.Uint("sql-port")
}
if ctx.IsSet("db-path") || c.dbServerPath == "" {
c.dbServerPath = ctx.String("db-path")
if ctx.IsSet("sql-path") || c.sqlServerPath == "" {
c.sqlServerPath = ctx.String("sql-path")
}
if ctx.IsSet("http-host") || c.httpServerHost == "" {
@ -200,8 +200,8 @@ func (c *Config) SetValuesFromCliContext(ctx *cli.Context) error {
c.httpServerPort = ctx.Int("http-port")
}
if ctx.IsSet("http-mode") || c.serverMode == "" {
c.serverMode = ctx.String("http-mode")
if ctx.IsSet("http-mode") || c.httpServerMode == "" {
c.httpServerMode = ctx.String("http-mode")
}
return nil
@ -331,6 +331,15 @@ func (c *Config) SqlServerPort() uint {
return c.sqlServerPort
}
// SqlServerPath returns the database storage path for TiDB.
func (c *Config) SqlServerPath() string {
if c.sqlServerPath != "" {
return c.sqlServerPath
}
return c.ServerPath() + "/database"
}
// HttpServerHost returns the built-in HTTP server host name or IP address (empty for all interfaces).
func (c *Config) HttpServerHost() string {
return c.httpServerHost
@ -343,7 +352,7 @@ func (c *Config) HttpServerPort() int {
// HttpServerMode returns the server mode.
func (c *Config) HttpServerMode() string {
return c.serverMode
return c.httpServerMode
}
// OriginalsPath returns the originals.
@ -396,29 +405,24 @@ func (c *Config) TensorFlowModelPath() string {
return c.AssetsPath() + "/tensorflow"
}
// SqlServerPath returns the database storage path (e.g. for SQLite or Bleve).
func (c *Config) SqlServerPath() string {
return c.AssetsPath() + "/database"
}
// HttpAssetsPath returns the server assets path (public files, favicons, templates,...).
func (c *Config) HttpAssetsPath() string {
// ServerPath returns the server assets path (public files, favicons, templates,...).
func (c *Config) ServerPath() string {
return c.AssetsPath() + "/server"
}
// HttpTemplatesPath returns the server templates path.
func (c *Config) HttpTemplatesPath() string {
return c.HttpAssetsPath() + "/templates"
return c.ServerPath() + "/templates"
}
// HttpFaviconsPath returns the favicons path.
func (c *Config) HttpFaviconsPath() string {
return c.HttpAssetsPath() + "/favicons"
return c.HttpPublicPath() + "/favicons"
}
// HttpPublicPath returns the public server path (//server/assets/*).
func (c *Config) HttpPublicPath() string {
return c.HttpAssetsPath() + "/public"
return c.ServerPath() + "/public"
}
// HttpPublicBuildPath returns the public build path (//server/assets/build/*).

View file

@ -29,7 +29,7 @@ type Config interface {
HttpServerHost() string
HttpServerPort() int
HttpServerMode() string
HttpAssetsPath() string
ServerPath() string
HttpTemplatesPath() string
HttpFaviconsPath() string
HttpPublicPath() string

View file

@ -9,9 +9,8 @@ import (
)
func registerRoutes(app *gin.Engine, conf photoprism.Config) {
// Favicon images
// Favicon
app.StaticFile("/favicon.ico", conf.HttpFaviconsPath()+"/favicon.ico")
app.StaticFile("/favicon.png", conf.HttpFaviconsPath()+"/favicon.png")
// Static assets like js and css files
app.Static("/assets", conf.HttpPublicPath())

View file

@ -255,27 +255,27 @@ func (c *Config) TensorFlowModelPath() string {
// SqlServerPath returns the database storage path (e.g. for SQLite or Bleve).
func (c *Config) SqlServerPath() string {
return c.AssetsPath() + "/database"
return c.ServerPath() + "/database"
}
// HttpAssetsPath returns the server assets path (public files, favicons, templates,...).
func (c *Config) HttpAssetsPath() string {
// ServerPath returns the server assets path (public files, favicons, templates,...).
func (c *Config) ServerPath() string {
return c.AssetsPath() + "/server"
}
// HttpTemplatesPath returns the server templates path.
func (c *Config) HttpTemplatesPath() string {
return c.HttpAssetsPath() + "/templates"
return c.ServerPath() + "/templates"
}
// HttpFaviconsPath returns the favicons path.
func (c *Config) HttpFaviconsPath() string {
return c.HttpAssetsPath() + "/favicons"
return c.HttpPublicPath() + "/favicons"
}
// HttpPublicPath returns the public server path (//server/assets/*).
func (c *Config) HttpPublicPath() string {
return c.HttpAssetsPath() + "/public"
return c.ServerPath() + "/public"
}
// HttpPublicBuildPath returns the public build path (//server/assets/build/*).