Repos / s4g / ac668e0cc2
commit ac668e0cc2f2bfef3950c906e6cd77b34edffdf4
Author: Nhân <hi@imnhan.com>
Date: Tue Jul 4 14:52:04 2023 +0700
cleaner copyright notice with start-end years
diff --git a/main.go b/main.go
index 99596a2..fa79a7b 100644
--- a/main.go
+++ b/main.go
@@ -40,17 +40,19 @@ func main() {
return posts[i].Meta.PostedAt.Compare(posts[j].Meta.PostedAt) > 0
})
+ startYear := posts[len(posts)-1].Meta.PostedAt.Year()
+
fmt.Printf("Found %d posts, %d pages:\n", len(posts), len(pages))
for _, a := range posts {
fmt.Println(">", a.Path, "-", a.Meta.Title)
- a.WriteHtmlFile(&site, pages)
+ a.WriteHtmlFile(&site, pages, startYear)
}
for _, a := range pages {
fmt.Println(">", a.Path, "-", a.Meta.Title)
- a.WriteHtmlFile(&site, pages)
+ a.WriteHtmlFile(&site, pages, startYear)
}
- WriteHomePage(fsys, site, posts, pages)
+ WriteHomePage(fsys, site, posts, pages, startYear)
fsys.WriteFile(FEED_PATH, generateFeed(site, posts, site.HomePath+FEED_PATH))
@@ -101,7 +103,7 @@ type ArticleMetadata struct {
PostedAt time.Time
}
-func (a *Article) WriteHtmlFile(site *SiteMetadata, pages []Article) {
+func (a *Article) WriteHtmlFile(site *SiteMetadata, pages []Article, startYear int) {
// First generate the main content in html
contentHtml := djot.ToHtml(a.DjotBody)
@@ -115,21 +117,23 @@ func (a *Article) WriteHtmlFile(site *SiteMetadata, pages []Article) {
),
)
err := tmpl.Execute(&buf, struct {
- Site *SiteMetadata
- Content template.HTML
- Title string
- Post *Article
- Pages []Article
- Feed string
- Now time.Time
+ Site *SiteMetadata
+ Content template.HTML
+ Title string
+ Post *Article
+ Pages []Article
+ Feed string
+ Now time.Time
+ StartYear int
}{
- Site: site,
- Content: template.HTML(contentHtml),
- Title: fmt.Sprintf("%s | %s", a.Meta.Title, site.Name),
- Post: a,
- Pages: pages,
- Feed: site.HomePath + FEED_PATH,
- Now: time.Now(),
+ Site: site,
+ Content: template.HTML(contentHtml),
+ Title: fmt.Sprintf("%s | %s", a.Meta.Title, site.Name),
+ Post: a,
+ Pages: pages,
+ Feed: site.HomePath + FEED_PATH,
+ Now: time.Now(),
+ StartYear: startYear,
})
if err != nil {
fmt.Println("Error in WriteHtmlFile:", err)
@@ -144,7 +148,12 @@ func (a *Article) WriteHtmlFile(site *SiteMetadata, pages []Article) {
}
}
-func WriteHomePage(fsys WritableFS, site SiteMetadata, posts, pages []Article) {
+func WriteHomePage(
+ fsys WritableFS,
+ site SiteMetadata,
+ posts, pages []Article,
+ startYear int,
+) {
var buf bytes.Buffer
tmpl := template.Must(
template.ParseFS(
@@ -154,19 +163,21 @@ func WriteHomePage(fsys WritableFS, site SiteMetadata, posts, pages []Article) {
),
)
err := tmpl.Execute(&buf, struct {
- Site *SiteMetadata
- Title string
- Posts []Article
- Pages []Article
- Feed string
- Now time.Time
+ Site *SiteMetadata
+ Title string
+ Posts []Article
+ Pages []Article
+ Feed string
+ Now time.Time
+ StartYear int
}{
- Site: &site,
- Title: fmt.Sprintf("%s - %s", site.Name, site.Tagline),
- Posts: posts,
- Pages: pages,
- Feed: site.HomePath + FEED_PATH,
- Now: time.Now(),
+ Site: &site,
+ Title: fmt.Sprintf("%s - %s", site.Name, site.Tagline),
+ Posts: posts,
+ Pages: pages,
+ Feed: site.HomePath + FEED_PATH,
+ Now: time.Now(),
+ StartYear: startYear,
})
if err != nil {
fmt.Println("Error in WriteHtmlFile:", err)
diff --git a/www/_theme/base.tmpl b/www/_theme/base.tmpl
index 499adcc..703f97f 100644
--- a/www/_theme/base.tmpl
+++ b/www/_theme/base.tmpl
@@ -20,8 +20,8 @@
{{if not .Site.DisableFooter}}
<footer>
-Copyright {{.Now.Year}} {{.Site.Author.Name}}. All rights reserved.<br>
-Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>.
+© {{if eq .StartYear .Now.Year}}{{.StartYear}}{{else}}{{.StartYear}}–{{.Now.Year}}{{end}} {{.Site.Author.Name}}<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
</footer>
<style>
footer {
diff --git a/www/about/index.html b/www/about/index.html
index ce31568..8ae1104 100644
--- a/www/about/index.html
+++ b/www/about/index.html
@@ -53,8 +53,8 @@ <h2>No really</h2>
<footer>
-Copyright 2023 Coolio McCool. All rights reserved.<br>
-Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>.
+© 2022–2023 Coolio McCool<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
</footer>
<style>
footer {
diff --git a/www/hello/index.html b/www/hello/index.html
index 839d5b1..e64369e 100644
--- a/www/hello/index.html
+++ b/www/hello/index.html
@@ -52,8 +52,8 @@ <h1 class="post-title">Hello</h1>
<footer>
-Copyright 2023 Coolio McCool. All rights reserved.<br>
-Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>.
+© 2022–2023 Coolio McCool<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
</footer>
<style>
footer {
diff --git a/www/index.html b/www/index.html
index 4b4b344..61c0688 100644
--- a/www/index.html
+++ b/www/index.html
@@ -88,8 +88,8 @@ <h1 class="site-title">CoolZone</h1>
<footer>
-Copyright 2023 Coolio McCool. All rights reserved.<br>
-Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>.
+© 2022–2023 Coolio McCool<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
</footer>
<style>
footer {
diff --git a/www/mfws.html b/www/mfws.html
index 8c7eee6..1bfcdf6 100644
--- a/www/mfws.html
+++ b/www/mfws.html
@@ -141,8 +141,8 @@ <h2>Epilogue</h2>
<footer>
-Copyright 2023 Coolio McCool. All rights reserved.<br>
-Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>.
+© 2022–2023 Coolio McCool<br>
+Made with <a href="https://github.com/nhanb/webmaker2000">WebMaker2000</a>
</footer>
<style>
footer {