forked from tangled.org/core
this repo has no description

appview: pages: fix fragments glob

Changed files
+108 -81
appview
pages
templates
repo
issues
fragments
+47 -31
appview/pages/pages.go
···
t map[string]*template.Template
}
-
-
func NewPages() *Pages {
templates := make(map[string]*template.Template)
-
fragmentPaths := []string{}
+
var fragmentPaths []string
// First, collect all fragment paths
err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
-
if !d.IsDir() && strings.HasSuffix(path, ".html") && strings.Contains(path, "fragments/") {
-
fragmentPaths = append(fragmentPaths, path)
+
if d.IsDir() {
+
return nil
}
-
return nil
-
})
-
if err != nil {
-
log.Fatalf("walking template dir for fragments: %v", err)
-
}
+
+
if !strings.HasSuffix(path, ".html") {
+
return nil
+
}
+
+
if !strings.Contains(path, "fragments/") {
+
return nil
+
}
-
// Load all fragments first
-
for _, path := range fragmentPaths {
name := strings.TrimPrefix(path, "templates/")
name = strings.TrimSuffix(name, ".html")
···
}
templates[name] = tmpl
+
fragmentPaths = append(fragmentPaths, path)
log.Printf("loaded fragment: %s", name)
+
return nil
+
})
+
if err != nil {
+
log.Fatalf("walking template dir for fragments: %v", err)
}
// Then walk through and setup the rest of the templates
···
return err
}
-
if !d.IsDir() && strings.HasSuffix(path, ".html") {
-
name := strings.TrimPrefix(path, "templates/")
-
name = strings.TrimSuffix(name, ".html")
+
if d.IsDir() {
+
return nil
+
}
-
// Skip fragments as they've already been loaded
-
if strings.Contains(path, "fragments/") {
-
return nil
-
}
+
if !strings.HasSuffix(path, "html") {
+
return nil
+
}
-
// Load layouts and main templates
-
if !strings.HasPrefix(path, "templates/layouts/") {
-
// Add the page template on top of the base
-
tmpl, err := template.New(name).
-
Funcs(funcMap()).
-
ParseFS(Files, "templates/layouts/*.html", "templates/**/fragments/*.html", path)
-
if err != nil {
-
return fmt.Errorf("setting up template: %w", err)
-
}
+
// Skip fragments as they've already been loaded
+
if strings.Contains(path, "fragments/") {
+
return nil
+
}
+
+
// Skip layouts
+
if strings.Contains(path, "layouts/") {
+
return nil
+
}
+
+
name := strings.TrimPrefix(path, "templates/")
+
name = strings.TrimSuffix(name, ".html")
-
templates[name] = tmpl
-
log.Printf("loaded template: %s", name)
-
}
+
// Add the page template on top of the base
+
allPaths := []string{}
+
allPaths = append(allPaths, "templates/layouts/*.html")
+
allPaths = append(allPaths, fragmentPaths...)
+
allPaths = append(allPaths, path)
+
tmpl, err := template.New(name).
+
Funcs(funcMap()).
+
ParseFS(Files, allPaths...)
+
if err != nil {
+
return fmt.Errorf("setting up template: %w", err)
}
+
+
templates[name] = tmpl
+
log.Printf("loaded template: %s", name)
return nil
})
if err != nil {
+1 -3
appview/pages/templates/repo/index.html
···
<a
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
-
>{{ slice .Hash.String 0 8 }}</a
-
>
-
</span>
+
>{{ slice .Hash.String 0 8 }}</a></span>
<span
class="mx-2 before:content-['·'] before:select-none"
></span>
+2 -2
appview/pages/templates/repo/issues/fragments/issueComment.html
···
{{ define "repo/issues/fragments/issueComment" }}
{{ with .Comment }}
<div id="comment-container-{{.CommentId}}">
-
<div class="flex items-center gap-2 mb-2 text-gray-500 text-sm">
+
<div class="flex items-center gap-2 mb-2 text-gray-500 dark:text-gray-400 text-sm">
{{ $owner := index $.DidHandleMap .OwnerDid }}
<a href="/{{ $owner }}" class="no-underline hover:underline">{{ $owner }}</a>
<span class="before:content-['·']"></span>
<a
href="#{{ .CommentId }}"
-
class="text-gray-500 hover:text-gray-500 hover:underline no-underline"
+
class="text-gray-500 dark:text-gray-400 hover:text-gray-500 dark:hover:text-gray-400 hover:underline no-underline"
id="{{ .CommentId }}">
{{ if .Deleted }}
deleted {{ .Deleted | timeFmt }}
+58 -45
tailwind.config.js
···
const colors = require("tailwindcss/colors");
module.exports = {
-
content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"],
-
darkMode: "media",
-
theme: {
-
container: {
-
padding: "2rem",
-
center: true,
-
screens: {
-
sm: "500px",
-
md: "600px",
-
lg: "800px",
-
xl: "1000px",
-
"2xl": "1200px",
-
},
-
},
-
extend: {
-
fontFamily: {
-
sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"],
-
mono: [
-
"IBMPlexMono",
-
"ui-monospace",
-
"SFMono-Regular",
-
"Menlo",
-
"Monaco",
-
"Consolas",
-
"Liberation Mono",
-
"Courier New",
-
"monospace",
-
],
-
},
-
typography: {
-
DEFAULT: {
-
css: {
-
maxWidth: "none",
-
pre: {
-
backgroundColor: colors.gray[100],
-
color: colors.black,
-
"@apply dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border":
-
{},
-
},
-
},
-
},
-
},
-
},
-
},
-
plugins: [require("@tailwindcss/typography")],
+
content: ["./appview/pages/templates/**/*.html", "./appview/pages/chroma.go"],
+
darkMode: "media",
+
theme: {
+
container: {
+
padding: "2rem",
+
center: true,
+
screens: {
+
sm: "500px",
+
md: "600px",
+
lg: "800px",
+
xl: "1000px",
+
"2xl": "1200px",
+
},
+
},
+
extend: {
+
fontFamily: {
+
sans: ["InterVariable", "system-ui", "sans-serif", "ui-sans-serif"],
+
mono: [
+
"IBMPlexMono",
+
"ui-monospace",
+
"SFMono-Regular",
+
"Menlo",
+
"Monaco",
+
"Consolas",
+
"Liberation Mono",
+
"Courier New",
+
"monospace",
+
],
+
},
+
typography: {
+
DEFAULT: {
+
css: {
+
maxWidth: "none",
+
pre: {
+
backgroundColor: colors.gray[100],
+
color: colors.black,
+
"@apply font-normal text-black bg-gray-100 dark:bg-gray-900 dark:text-gray-300 dark:border-gray-700 dark:border": {},
+
},
+
code: {
+
"@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": {},
+
},
+
"code::before": {
+
content: '""',
+
"padding-left": "0.25rem"
+
},
+
"code::after": {
+
content: '""',
+
"padding-right": "0.25rem"
+
},
+
blockquote: {
+
quotes: "none",
+
},
+
},
+
},
+
},
+
},
+
},
+
plugins: [require("@tailwindcss/typography")],
};