commit a1dc08af2953ba98b211734481607e08c52ad25f
parent 7c2c44102926ee0cab7fd8722bb0516e45cffc33
Author: gearsix <gearsix@tuta.io>
Date: Wed, 31 Aug 2022 14:25:41 +0100
formatting fixes
Diffstat:
4 files changed, 13 insertions(+), 14 deletions(-)
diff --git a/content.go b/content.go
@@ -4,20 +4,21 @@ import (
"bufio"
"bytes"
"fmt"
- "github.com/yuin/goldmark"
- goldmarkext "github.com/yuin/goldmark/extension"
- goldmarkparse "github.com/yuin/goldmark/parser"
- goldmarkhtml "github.com/yuin/goldmark/renderer/html"
"io"
"io/ioutil"
"mime"
- "notabug.org/gearsix/suti"
"os"
"os/exec"
"path/filepath"
"sort"
"strings"
"time"
+
+ "github.com/yuin/goldmark"
+ goldmarkext "github.com/yuin/goldmark/extension"
+ goldmarkparse "github.com/yuin/goldmark/parser"
+ goldmarkhtml "github.com/yuin/goldmark/renderer/html"
+ "notabug.org/gearsix/suti"
)
// Content is the converted HTML string of a Content file
@@ -108,12 +109,9 @@ func LoadContentDir(dir string) (p []Page, e error) {
dmeta := make(map[string]Meta)
e = filepath.Walk(dir, func(fpath string, info os.FileInfo, err error) error {
- if err != nil {
+ if err != nil || ignoreFile(fpath) {
return err
}
- if ignoreFile(fpath) {
- return nil
- }
if info.IsDir() {
path := pagePath(dir, fpath)
@@ -168,7 +166,7 @@ func loadContentFile(p Page, def map[string]Meta, fpath string, ppath string) (P
p.Assets.All = append(p.Assets.All, a)
ref := &p.Assets.All[len(p.Assets.All)-1]
mimetype := mime.TypeByExtension(filepath.Ext(fpath))
- if strings.Contains(mimetype, "image/") {
+ if strings.Contains(mimetype, "image") {
p.Assets.Image = append(p.Assets.Image, ref)
} else if strings.Contains(mimetype, "video") {
p.Assets.Video = append(p.Assets.Video, ref)
diff --git a/page.go b/page.go
@@ -3,11 +3,12 @@ package main
import (
"bytes"
"io/ioutil"
- "notabug.org/gearsix/suti"
"os"
"path/filepath"
"strings"
"time"
+
+ "notabug.org/gearsix/suti"
)
const timefmt = "2006-01-02"
@@ -27,7 +28,7 @@ func pagePath(root, path string) string {
if len(path) == 0 {
path = "/"
} else {
- path = filepath.ToSlash(path)
+ path = filepath.ToSlash(strings.TrimSuffix(path, filepath.Ext(path)))
}
return path
}
diff --git a/pagr.go b/pagr.go
@@ -119,7 +119,7 @@ func findPageTemplate(p Page, t []suti.Template) (tmpl suti.Template) {
func copyAssets() (count int) {
for _, asset := range config.Assets {
asset = filepath.Clean(asset)
- if _, err := os.Stat(asset); err != nil {
+ if _, err := os.Stat(asset); err != nil {
continue
}
filepath.Walk(asset,
diff --git a/pagr_test.go b/pagr_test.go
@@ -68,7 +68,7 @@ p3
`
var contents = map[string]string{
- "": contentsTxt,
+ "": contentsTxt,
".txt": contentsTxt,
".html": contentsHtml,
".md": contentsMd,