Remove the public/ directory

Now that all templates are provided by plugins, there's no need to have
a public/ directory. Themes can be in /themes instead of /public/themes.
This commit is contained in:
Simon Ser 2019-12-16 12:57:30 +01:00
parent d897eeee5c
commit e93346ffa9
No known key found for this signature in database
GPG key ID: 0FDE7BE0E88F5E48
15 changed files with 18 additions and 7 deletions

View file

@ -10,11 +10,11 @@ See `-h` for more information.
## Themes
They should be put in `public/themes/<name>/`.
They should be put in `themes/<name>/`.
Templates in `public/themes/<name>/*.html` override default templates in
`public/*.html`. Assets in `public/themes/<name>/assets/*` are served by the
HTTP server at `/themes/<name>/assets/*`.
Templates in `themes/<name>/*.html` override default templates in plugins.
Assets in `themes/<name>/assets/*` are served by the HTTP server at
`/themes/<name>/assets/*`.
## Plugins

View file

@ -196,7 +196,7 @@ func New(e *echo.Echo, options *Options) error {
}
})
e.Static("/themes", "public/themes")
e.Static("/themes", "themes")
for _, p := range s.Plugins {
p.SetRoutes(e.Group(""))

View file

@ -10,7 +10,7 @@ import (
"github.com/labstack/echo/v4"
)
const themesDir = "public/themes"
const themesDir = "themes"
// GlobalRenderData contains data available in all templates.
type GlobalRenderData struct {
@ -76,7 +76,7 @@ func loadTheme(name string, base *template.Template) (*template.Template, error)
return nil, err
}
theme, err = theme.ParseGlob("public/themes/" + name + "/*.html")
theme, err = theme.ParseGlob(themesDir + "/" + name + "/*.html")
if err != nil {
return nil, err
}

View file

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 241 B

View file

@ -0,0 +1,3 @@
body {
background-color: pink;
}

8
themes/test/head.html Normal file
View file

@ -0,0 +1,8 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>koushin</title>
<link rel="stylesheet" href="/assets/style.css">
</head>
<body>