+47
-31
appview/pages/pages.go
+47
-31
appview/pages/pages.go
···
36
t map[string]*template.Template
37
}
38
39
-
40
-
41
func NewPages() *Pages {
42
templates := make(map[string]*template.Template)
43
-
fragmentPaths := []string{}
44
45
// First, collect all fragment paths
46
err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error {
47
if err != nil {
48
return err
49
}
50
51
-
if !d.IsDir() && strings.HasSuffix(path, ".html") && strings.Contains(path, "fragments/") {
52
-
fragmentPaths = append(fragmentPaths, path)
53
}
54
-
return nil
55
-
})
56
-
if err != nil {
57
-
log.Fatalf("walking template dir for fragments: %v", err)
58
-
}
59
60
-
// Load all fragments first
61
-
for _, path := range fragmentPaths {
62
name := strings.TrimPrefix(path, "templates/")
63
name = strings.TrimSuffix(name, ".html")
64
···
70
}
71
72
templates[name] = tmpl
73
log.Printf("loaded fragment: %s", name)
74
}
75
76
// Then walk through and setup the rest of the templates
···
79
return err
80
}
81
82
-
if !d.IsDir() && strings.HasSuffix(path, ".html") {
83
-
name := strings.TrimPrefix(path, "templates/")
84
-
name = strings.TrimSuffix(name, ".html")
85
86
-
// Skip fragments as they've already been loaded
87
-
if strings.Contains(path, "fragments/") {
88
-
return nil
89
-
}
90
91
-
// Load layouts and main templates
92
-
if !strings.HasPrefix(path, "templates/layouts/") {
93
-
// Add the page template on top of the base
94
-
tmpl, err := template.New(name).
95
-
Funcs(funcMap()).
96
-
ParseFS(Files, "templates/layouts/*.html", "templates/**/fragments/*.html", path)
97
-
if err != nil {
98
-
return fmt.Errorf("setting up template: %w", err)
99
-
}
100
101
-
templates[name] = tmpl
102
-
log.Printf("loaded template: %s", name)
103
-
}
104
}
105
return nil
106
})
107
if err != nil {
···
36
t map[string]*template.Template
37
}
38
39
func NewPages() *Pages {
40
templates := make(map[string]*template.Template)
41
42
+
var fragmentPaths []string
43
// First, collect all fragment paths
44
err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error {
45
if err != nil {
46
return err
47
}
48
49
+
if d.IsDir() {
50
+
return nil
51
}
52
+
53
+
if !strings.HasSuffix(path, ".html") {
54
+
return nil
55
+
}
56
+
57
+
if !strings.Contains(path, "fragments/") {
58
+
return nil
59
+
}
60
61
name := strings.TrimPrefix(path, "templates/")
62
name = strings.TrimSuffix(name, ".html")
63
···
69
}
70
71
templates[name] = tmpl
72
+
fragmentPaths = append(fragmentPaths, path)
73
log.Printf("loaded fragment: %s", name)
74
+
return nil
75
+
})
76
+
if err != nil {
77
+
log.Fatalf("walking template dir for fragments: %v", err)
78
}
79
80
// Then walk through and setup the rest of the templates
···
83
return err
84
}
85
86
+
if d.IsDir() {
87
+
return nil
88
+
}
89
90
+
if !strings.HasSuffix(path, "html") {
91
+
return nil
92
+
}
93
94
+
// Skip fragments as they've already been loaded
95
+
if strings.Contains(path, "fragments/") {
96
+
return nil
97
+
}
98
+
99
+
// Skip layouts
100
+
if strings.Contains(path, "layouts/") {
101
+
return nil
102
+
}
103
+
104
+
name := strings.TrimPrefix(path, "templates/")
105
+
name = strings.TrimSuffix(name, ".html")
106
107
+
// Add the page template on top of the base
108
+
allPaths := []string{}
109
+
allPaths = append(allPaths, "templates/layouts/*.html")
110
+
allPaths = append(allPaths, fragmentPaths...)
111
+
allPaths = append(allPaths, path)
112
+
tmpl, err := template.New(name).
113
+
Funcs(funcMap()).
114
+
ParseFS(Files, allPaths...)
115
+
if err != nil {
116
+
return fmt.Errorf("setting up template: %w", err)
117
}
118
+
119
+
templates[name] = tmpl
120
+
log.Printf("loaded template: %s", name)
121
return nil
122
})
123
if err != nil {
+1
-3
appview/pages/templates/repo/index.html
+1
-3
appview/pages/templates/repo/index.html
+2
-2
appview/pages/templates/repo/issues/fragments/issueComment.html
+2
-2
appview/pages/templates/repo/issues/fragments/issueComment.html
···
1
{{ define "repo/issues/fragments/issueComment" }}
2
{{ with .Comment }}
3
<div id="comment-container-{{.CommentId}}">
4
-
<div class="flex items-center gap-2 mb-2 text-gray-500 text-sm">
5
{{ $owner := index $.DidHandleMap .OwnerDid }}
6
<a href="/{{ $owner }}" class="no-underline hover:underline">{{ $owner }}</a>
7
8
<span class="before:content-['·']"></span>
9
<a
10
href="#{{ .CommentId }}"
11
-
class="text-gray-500 hover:text-gray-500 hover:underline no-underline"
12
id="{{ .CommentId }}">
13
{{ if .Deleted }}
14
deleted {{ .Deleted | timeFmt }}
···
1
{{ define "repo/issues/fragments/issueComment" }}
2
{{ with .Comment }}
3
<div id="comment-container-{{.CommentId}}">
4
+
<div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm">
5
{{ $owner := index $.DidHandleMap .OwnerDid }}
6
<a href="/{{ $owner }}" class="no-underline hover:underline">{{ $owner }}</a>
7
8
<span class="before:content-['·']"></span>
9
<a
10
href="#{{ .CommentId }}"
11
+
class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline"
12
id="{{ .CommentId }}">
13
{{ if .Deleted }}
14
deleted {{ .Deleted | timeFmt }}
+58
-45
tailwind.config.js
+58
-45
tailwind.config.js
···
2
const colors = require("tailwindcss/colors");
3
4
module.exports = {
5
-
content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"],
6
-
darkMode: "media",
7
-
theme: {
8
-
container: {
9
-
padding: "2rem",
10
-
center: true,
11
-
screens: {
12
-
sm: "500px",
13
-
md: "600px",
14
-
lg: "800px",
15
-
xl: "1000px",
16
-
"2xl": "1200px",
17
-
},
18
-
},
19
-
extend: {
20
-
fontFamily: {
21
-
sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"],
22
-
mono: [
23
-
"IBMPlexMono",
24
-
"ui-monospace",
25
-
"SFMono-Regular",
26
-
"Menlo",
27
-
"Monaco",
28
-
"Consolas",
29
-
"Liberation Mono",
30
-
"Courier New",
31
-
"monospace",
32
-
],
33
-
},
34
-
typography: {
35
-
DEFAULT: {
36
-
css: {
37
-
maxWidth: "none",
38
-
pre: {
39
-
backgroundColor: colors.gray[100],
40
-
color: colors.black,
41
-
"@apply dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border":
42
-
{},
43
-
},
44
-
},
45
-
},
46
-
},
47
-
},
48
-
},
49
-
plugins: [require("@tailwindcss/typography")],
50
};
···
2
const colors = require("tailwindcss/colors");
3
4
module.exports = {
5
+
content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"],
6
+
darkMode: "media",
7
+
theme: {
8
+
container: {
9
+
padding: "2rem",
10
+
center: true,
11
+
screens: {
12
+
sm: "500px",
13
+
md: "600px",
14
+
lg: "800px",
15
+
xl: "1000px",
16
+
"2xl": "1200px",
17
+
},
18
+
},
19
+
extend: {
20
+
fontFamily: {
21
+
sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"],
22
+
mono: [
23
+
"IBMPlexMono",
24
+
"ui-monospace",
25
+
"SFMono-Regular",
26
+
"Menlo",
27
+
"Monaco",
28
+
"Consolas",
29
+
"Liberation Mono",
30
+
"Courier New",
31
+
"monospace",
32
+
],
33
+
},
34
+
typography: {
35
+
DEFAULT: {
36
+
css: {
37
+
maxWidth: "none",
38
+
pre: {
39
+
backgroundColor: colors.gray[100],
40
+
color: colors.black,
41
+
"@apply font-normal text-black bg-gray-100 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border": {},
42
+
},
43
+
code: {
44
+
"@apply font-normal font-mono p-1 rounded text-black bg-gray-100 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700": {},
45
+
},
46
+
"code::before": {
47
+
content: '""',
48
+
"padding-left": "0.25rem"
49
+
},
50
+
"code::after": {
51
+
content: '""',
52
+
"padding-right": "0.25rem"
53
+
},
54
+
blockquote: {
55
+
quotes: "none",
56
+
},
57
+
},
58
+
},
59
+
},
60
+
},
61
+
},
62
+
plugins: [require("@tailwindcss/typography")],
63
};