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