From e93346ffa90f6c09a9a57b48c6607925dc7ff46e Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 16 Dec 2019 12:57:30 +0100 Subject: [PATCH] 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. --- README.md | 8 ++++---- server.go | 2 +- template.go | 4 ++-- {public/themes => themes}/sourcehut/Makefile | 0 {public/themes => themes}/sourcehut/assets/style.css | 0 {public/themes => themes}/sourcehut/caret-left.html | 0 {public/themes => themes}/sourcehut/compose.html | 0 {public/themes => themes}/sourcehut/head.html | 0 {public/themes => themes}/sourcehut/login.html | 0 {public/themes => themes}/sourcehut/mailbox.html | 0 {public/themes => themes}/sourcehut/message.html | 0 {public/themes => themes}/sourcehut/nav.html | 0 {public/themes => themes}/sourcehut/scss/main.scss | 0 themes/test/assets/style.css | 3 +++ themes/test/head.html | 8 ++++++++ 15 files changed, 18 insertions(+), 7 deletions(-) rename {public/themes => themes}/sourcehut/Makefile (100%) rename {public/themes => themes}/sourcehut/assets/style.css (100%) rename {public/themes => themes}/sourcehut/caret-left.html (100%) rename {public/themes => themes}/sourcehut/compose.html (100%) rename {public/themes => themes}/sourcehut/head.html (100%) rename {public/themes => themes}/sourcehut/login.html (100%) rename {public/themes => themes}/sourcehut/mailbox.html (100%) rename {public/themes => themes}/sourcehut/message.html (100%) rename {public/themes => themes}/sourcehut/nav.html (100%) rename {public/themes => themes}/sourcehut/scss/main.scss (100%) create mode 100644 themes/test/assets/style.css create mode 100644 themes/test/head.html diff --git a/README.md b/README.md index 1ca62d5..458b5a9 100644 --- a/README.md +++ b/README.md @@ -10,11 +10,11 @@ See `-h` for more information. ## Themes -They should be put in `public/themes//`. +They should be put in `themes//`. -Templates in `public/themes//*.html` override default templates in -`public/*.html`. Assets in `public/themes//assets/*` are served by the -HTTP server at `/themes//assets/*`. +Templates in `themes//*.html` override default templates in plugins. +Assets in `themes//assets/*` are served by the HTTP server at +`/themes//assets/*`. ## Plugins diff --git a/server.go b/server.go index f2d4c11..ab42684 100644 --- a/server.go +++ b/server.go @@ -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("")) diff --git a/template.go b/template.go index e5078c5..4f33e5e 100644 --- a/template.go +++ b/template.go @@ -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 } diff --git a/public/themes/sourcehut/Makefile b/themes/sourcehut/Makefile similarity index 100% rename from public/themes/sourcehut/Makefile rename to themes/sourcehut/Makefile diff --git a/public/themes/sourcehut/assets/style.css b/themes/sourcehut/assets/style.css similarity index 100% rename from public/themes/sourcehut/assets/style.css rename to themes/sourcehut/assets/style.css diff --git a/public/themes/sourcehut/caret-left.html b/themes/sourcehut/caret-left.html similarity index 100% rename from public/themes/sourcehut/caret-left.html rename to themes/sourcehut/caret-left.html diff --git a/public/themes/sourcehut/compose.html b/themes/sourcehut/compose.html similarity index 100% rename from public/themes/sourcehut/compose.html rename to themes/sourcehut/compose.html diff --git a/public/themes/sourcehut/head.html b/themes/sourcehut/head.html similarity index 100% rename from public/themes/sourcehut/head.html rename to themes/sourcehut/head.html diff --git a/public/themes/sourcehut/login.html b/themes/sourcehut/login.html similarity index 100% rename from public/themes/sourcehut/login.html rename to themes/sourcehut/login.html diff --git a/public/themes/sourcehut/mailbox.html b/themes/sourcehut/mailbox.html similarity index 100% rename from public/themes/sourcehut/mailbox.html rename to themes/sourcehut/mailbox.html diff --git a/public/themes/sourcehut/message.html b/themes/sourcehut/message.html similarity index 100% rename from public/themes/sourcehut/message.html rename to themes/sourcehut/message.html diff --git a/public/themes/sourcehut/nav.html b/themes/sourcehut/nav.html similarity index 100% rename from public/themes/sourcehut/nav.html rename to themes/sourcehut/nav.html diff --git a/public/themes/sourcehut/scss/main.scss b/themes/sourcehut/scss/main.scss similarity index 100% rename from public/themes/sourcehut/scss/main.scss rename to themes/sourcehut/scss/main.scss diff --git a/themes/test/assets/style.css b/themes/test/assets/style.css new file mode 100644 index 0000000..4d2bab2 --- /dev/null +++ b/themes/test/assets/style.css @@ -0,0 +1,3 @@ +body { + background-color: pink; +} diff --git a/themes/test/head.html b/themes/test/head.html new file mode 100644 index 0000000..35dda42 --- /dev/null +++ b/themes/test/head.html @@ -0,0 +1,8 @@ + + + + + koushin + + +