all repos — homestead @ 08487ad57405c6e9e0673bdcf042a13c5639fdc2

Code for my website

move template files

Alan Pearce
commit

08487ad57405c6e9e0673bdcf042a13c5639fdc2

parent

82424b77fba708e4450c1a0cec5b0c7967b13d7b

M domain/content/builder/builder.godomain/content/builder/builder.go
@@ -11,12 +11,13 @@ "time"
"alin.ovh/homestead/domain/content" "alin.ovh/homestead/domain/content/builder/template" + ctemplates "alin.ovh/homestead/domain/content/templates" "alin.ovh/homestead/domain/indieweb/sitemap" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/buffer" "alin.ovh/homestead/shared/config" "alin.ovh/homestead/shared/storage" "alin.ovh/homestead/shared/vcs" - "alin.ovh/homestead/templates" "alin.ovh/x/log" "github.com/Southclaws/fault"
@@ -100,7 +101,7 @@ for _, post := range cc.Posts {
log.Debug("rendering post", "post", post.Basename) sitemap.AddPath(post.URL, post.Date) buf.Reset() - if err := templates.PostPage(siteSettings, post).Render(buf); err != nil { + if err := ctemplates.PostPage(siteSettings, post).Render(buf); err != nil { return fault.Wrap(err, fmsg.With("could not render post")) }
@@ -111,7 +112,7 @@ }
log.Debug("rendering tags list") buf.Reset() - if err := templates.TagsPage(siteSettings, templates.TagsPageVars{ + if err := ctemplates.TagsPage(siteSettings, ctemplates.TagsPageVars{ Title: "Tags", Tags: mapset.Sorted(cc.Tags), }).Render(buf); err != nil {
@@ -132,7 +133,7 @@ }
log.Debug("rendering tags page", "tag", tag) url := path.Join("/tags", tag) + "/" buf.Reset() - if err := templates.TagPage(siteSettings, templates.TagPageVars{ + if err := ctemplates.TagPage(siteSettings, ctemplates.TagPageVars{ Tag: tag, Posts: matchingPosts, }).Render(buf); err != nil {
@@ -173,7 +174,7 @@ }
log.Debug("rendering list page") buf.Reset() - if err := templates.ListPage(siteSettings, templates.ListPageVars{ + if err := ctemplates.ListPage(siteSettings, ctemplates.ListPageVars{ Posts: cc.Posts, }).Render(buf); err != nil { return fault.Wrap(err)
@@ -222,7 +223,7 @@ for _, post := range cc.Pages {
buf.Reset() log.Debug("rendering page", "source", post.Input, "path", post.URL) if post.URL == "/" { - if err := templates.Homepage(siteSettings, templates.HomepageVars{ + if err := ctemplates.Homepage(siteSettings, ctemplates.HomepageVars{ Email: config.PublicEmail, Me: config.RelMe, Posts: cc.Posts,
@@ -230,7 +231,7 @@ }, post).Render(buf); err != nil {
return fault.Wrap(err) } } else { - if err := templates.Page(siteSettings, post).Render(buf); err != nil { + if err := ctemplates.Page(siteSettings, post).Render(buf); err != nil { return fault.Wrap(err) } }
@@ -280,7 +281,7 @@
log.Debug("rendering go packages") for _, p := range config.Go.Packages { buf.Reset() - if err := templates.GoPackagePage(siteSettings, &config.Go, p).Render(buf); err != nil { + if err := ctemplates.GoPackagePage(siteSettings, &config.Go, p).Render(buf); err != nil { return fault.Wrap(err) } if err := stor.Write(fmt.Sprintf("/go/%s.html", p), siteSettings.Title, buf); err != nil {
@@ -289,7 +290,7 @@ }
} buf.Reset() - if err := templates.GoPackageListPage(siteSettings, &config.Go).Render(buf); err != nil { + if err := ctemplates.GoPackageListPage(siteSettings, &config.Go).Render(buf); err != nil { return fault.Wrap(err) } if err := stor.Write("/go/", siteSettings.Title, buf); err != nil {
M domain/content/builder/template/template.godomain/content/builder/template/template.go
@@ -8,8 +8,8 @@ "text/template"
"alin.ovh/homestead/domain/content" "alin.ovh/homestead/domain/indieweb/atom" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/config" - "alin.ovh/homestead/templates" "github.com/PuerkitoBio/goquery" "github.com/Southclaws/fault"
M domain/content/publisher/app.godomain/content/publisher/app.go
@@ -9,8 +9,8 @@ "go.hacdias.com/indielib/indieauth"
ihttp "alin.ovh/homestead/domain/web/middleware" "alin.ovh/homestead/domain/web/server" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/config" - "alin.ovh/homestead/templates" "alin.ovh/x/log" )
M domain/content/publisher/mux.godomain/content/publisher/mux.go
@@ -5,7 +5,7 @@ "net/http"
pubtpl "alin.ovh/homestead/domain/content/publisher/templates" ihttp "alin.ovh/homestead/domain/web/middleware" - "alin.ovh/homestead/templates" + "alin.ovh/homestead/domain/web/templates" ) func (app *App) Index(w http.ResponseWriter, _ *http.Request) *ihttp.Error {
M domain/content/publisher/templates/index.godomain/content/publisher/templates/index.go
@@ -2,7 +2,7 @@ package templates
import ( g "alin.ovh/gomponents" - base "alin.ovh/homestead/templates" + base "alin.ovh/homestead/domain/web/templates" ) func IndexPage(site base.SiteSettings, page base.PageSettings) g.Node {
M domain/content/publisher/templates/layout.godomain/content/publisher/templates/layout.go
@@ -1,7 +1,7 @@
package templates import ( - base "alin.ovh/homestead/templates" + base "alin.ovh/homestead/domain/web/templates" g "alin.ovh/gomponents" c "alin.ovh/gomponents/components"
M domain/web/mux.godomain/web/mux.go
@@ -8,9 +8,10 @@ "regexp"
"slices" "strings" + calendar "alin.ovh/homestead/domain/calendar/templates" ihttp "alin.ovh/homestead/domain/web/middleware" "alin.ovh/homestead/domain/web/server" - "alin.ovh/homestead/templates" + "alin.ovh/homestead/domain/web/templates" "github.com/kevinpollet/nego" )
@@ -102,7 +103,7 @@ }
func (website *Website) Calendar(w http.ResponseWriter, r *http.Request) *ihttp.Error { website.counter.Count(r, "Calendar") - err := templates.CalendarPage(*website.siteSettings, templates.PageSettings{ + err := calendar.CalendarPage(*website.siteSettings, templates.PageSettings{ Title: "Calendar", TitleAttrs: templates.Attrs{}, BodyAttrs: templates.Attrs{},
M domain/web/website.godomain/web/website.go
@@ -16,12 +16,12 @@ "alin.ovh/homestead/domain/calendar"
"alin.ovh/homestead/domain/content/fetcher" ihttp "alin.ovh/homestead/domain/web/middleware" "alin.ovh/homestead/domain/web/server" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/config" "alin.ovh/homestead/shared/events" "alin.ovh/homestead/shared/file" "alin.ovh/homestead/shared/storage" "alin.ovh/homestead/shared/storage/sqlite" - "alin.ovh/homestead/templates" "alin.ovh/x/log" "github.com/Southclaws/fault" "github.com/Southclaws/fault/fmsg"
M kodata/feed-styles.xslkodata/feed-styles.xsl
@@ -1,1 +1,1 @@
-../templates/feed-styles.xsl+../domain/indieweb/templates/feed-styles.xsl
M kodata/robots.tmplkodata/robots.tmpl
@@ -1,1 +1,1 @@
-../templates/robots.tmpl+../domain/web/templates/robots.tmpl
M kodata/style.csskodata/style.css
@@ -1,1 +1,1 @@
-../templates/style.css+../domain/web/templates/style.css
M shared/storage/sqlite/writer.goshared/storage/sqlite/writer.go
@@ -3,13 +3,13 @@
import ( "context" "database/sql" + _ "embed" "encoding/json" "fmt" "hash/fnv" "io" "mime" "net/http" - "os" "path/filepath" "time"
@@ -28,6 +28,9 @@ _ "modernc.org/sqlite" // import registers db/SQL driver
) var encodings = []string{"gzip", "br", "zstd"} + +//go:embed schema.sql +var schema string type Writer struct { options *Options
@@ -57,12 +60,7 @@ return db, nil
} func NewWriter(conn *sql.DB, logger *log.Logger, opts *Options) (*Writer, error) { - q, err := os.ReadFile("schema.sql") - if err != nil { - return nil, fault.Wrap(err) - } - - _, err = conn.Exec(string(q)) + _, err := conn.Exec(schema) if err != nil { return nil, fault.Wrap(err, fmsg.With("creating tables")) }
M templates/calendar.godomain/calendar/templates/calendar.go
@@ -10,17 +10,18 @@ . "alin.ovh/gomponents/html"
"vimagination.zapto.org/ics" "alin.ovh/homestead/domain/calendar" + "alin.ovh/homestead/domain/web/templates" ) func CalendarPage( - site SiteSettings, - page PageSettings, + site templates.SiteSettings, + page templates.PageSettings, cal calendar.Calendar, ) g.Node { - return Layout(site, page, Calendar(site, cal)) + return templates.Layout(site, page, Calendar(site, cal)) } -func Calendar(site SiteSettings, cal calendar.Calendar) g.Node { +func Calendar(site templates.SiteSettings, cal calendar.Calendar) g.Node { past := true dates, err := cal.Availability(2) if err != nil {
M templates/gopkg.godomain/content/templates/gopkg.go
@@ -6,6 +6,7 @@ "net/url"
g "alin.ovh/gomponents" . "alin.ovh/gomponents/html" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/config" )
@@ -15,10 +16,10 @@ Domain config.URL
Forge config.URL } -func GoPackageListPage(site SiteSettings, cfg *config.GoPackagesConfig) g.Node { - return Layout(site, PageSettings{ +func GoPackageListPage(site templates.SiteSettings, cfg *config.GoPackagesConfig) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: site.Title, - TitleAttrs: Attrs{"class": "p-author h-card"}, + TitleAttrs: templates.Attrs{"class": "p-author h-card"}, }, Table( THead(
@@ -41,10 +42,10 @@ ),
) } -func GoPackagePage(site SiteSettings, cfg *config.GoPackagesConfig, pkg string) g.Node { - return Layout(site, PageSettings{ +func GoPackagePage(site templates.SiteSettings, cfg *config.GoPackagesConfig, pkg string) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: site.Title, - TitleAttrs: Attrs{"class": "p-author h-card"}, + TitleAttrs: templates.Attrs{"class": "p-author h-card"}, HeadExtra: g.Group{ Meta(Name("go-import"), Content(importString(cfg, pkg))), Meta(Name("go-source"), Content(sourceString(cfg, pkg))),
M templates/homepage.godomain/content/templates/homepage.go
@@ -2,6 +2,7 @@ package templates
import ( "alin.ovh/homestead/domain/content" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/config" g "alin.ovh/gomponents"
@@ -14,11 +15,11 @@ Me []config.MenuItem
Posts []*content.Post } -func Homepage(site SiteSettings, vars HomepageVars, content g.Node) g.Node { - return Layout(site, PageSettings{ +func Homepage(site templates.SiteSettings, vars HomepageVars, content g.Node) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: site.Title, - TitleAttrs: Attrs{"class": "p-name u-url"}, - BodyAttrs: Attrs{"class": "h-card"}, + TitleAttrs: templates.Attrs{"class": "p-name u-url"}, + BodyAttrs: templates.Attrs{"class": "h-card"}, }, Div( ID("content"),
M templates/list.godomain/content/templates/list.go
@@ -2,6 +2,7 @@ package templates
import ( "alin.ovh/homestead/domain/content" + "alin.ovh/homestead/domain/web/templates" g "alin.ovh/gomponents" . "alin.ovh/gomponents/html"
@@ -12,10 +13,10 @@ Tag string
Posts []*content.Post } -func TagPage(site SiteSettings, vars TagPageVars) g.Node { - return Layout(site, PageSettings{ +func TagPage(site templates.SiteSettings, vars TagPageVars) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: vars.Tag, - TitleAttrs: Attrs{"class": "p-author h-card"}, + TitleAttrs: templates.Attrs{"class": "p-author h-card"}, }, Div( ID("content"), Div(Class("filter"),
@@ -32,10 +33,10 @@ type ListPageVars struct {
Posts []*content.Post } -func ListPage(site SiteSettings, vars ListPageVars) g.Node { - return Layout(site, PageSettings{ +func ListPage(site templates.SiteSettings, vars ListPageVars) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: site.Title, - TitleAttrs: Attrs{"class": "p-author h-card"}, + TitleAttrs: templates.Attrs{"class": "p-author h-card"}, }, Div( ID("content"),
M templates/page.godomain/content/templates/page.go
@@ -2,15 +2,16 @@ package templates
import ( "alin.ovh/homestead/domain/content" + "alin.ovh/homestead/domain/web/templates" g "alin.ovh/gomponents" . "alin.ovh/gomponents/html" ) -func Page(site SiteSettings, page *content.Post) g.Node { - return Layout(site, PageSettings{ +func Page(site templates.SiteSettings, page *content.Post) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: page.Title, - TitleAttrs: Attrs{"class": "h-card", "rel": "author"}, + TitleAttrs: templates.Attrs{"class": "h-card", "rel": "author"}, }, Article( Header( H1(Class("p-name"), g.Text(page.Title)),
M templates/post.godomain/content/templates/post.go
@@ -4,17 +4,18 @@ import (
"time" "alin.ovh/homestead/domain/content" + "alin.ovh/homestead/domain/web/templates" "alin.ovh/homestead/shared/vcs" g "alin.ovh/gomponents" . "alin.ovh/gomponents/html" ) -func PostPage(site SiteSettings, post *content.Post) g.Node { - return Layout(site, PageSettings{ +func PostPage(site templates.SiteSettings, post *content.Post) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: post.Title, - TitleAttrs: Attrs{"class": "p-author h-card", "rel": "author"}, - BodyAttrs: Attrs{"class": "h-entry"}, + TitleAttrs: templates.Attrs{"class": "p-author h-card", "rel": "author"}, + BodyAttrs: templates.Attrs{"class": "h-entry"}, }, Article( Header( H1(Class("p-name"), g.Text(post.Title)),
M templates/tags.godomain/content/templates/tags.go
@@ -3,6 +3,8 @@
import ( g "alin.ovh/gomponents" . "alin.ovh/gomponents/html" + + "alin.ovh/homestead/domain/web/templates" ) type TagsPageVars struct {
@@ -10,8 +12,8 @@ Title string
Tags []string } -func TagsPage(site SiteSettings, vars TagsPageVars) g.Node { - return Layout(site, PageSettings{ +func TagsPage(site templates.SiteSettings, vars TagsPageVars) g.Node { + return templates.Layout(site, templates.PageSettings{ Title: vars.Title, }, Div( H3(Class("filter"), g.Text("Tags")),