Skip to content

Commit

Permalink
cataloghtml: wire up css.
Browse files Browse the repository at this point in the history
Just a dummy file, but correctly wired.
  • Loading branch information
warpfork committed Sep 13, 2022
1 parent 4b745bc commit 90edaf3
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cataloghtml/catalogIndex.tmpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

*/ -}}
<html>
<head>
<link rel="stylesheet" href="{{ (url "css.css") }}" />
</head>
<body>
<div style="border: 1px solid; padding 0.5em;">
<h1 style="display:inline">catalog</h1>
</div>
Expand All @@ -19,4 +23,5 @@ <h2>modules</h2>
<li><a href="{{ (url (string $moduleName) "_module.html") }}">{{ $moduleName }}</a></li>
{{- end }}
</ul>
</body>
</html>
5 changes: 5 additions & 0 deletions pkg/cataloghtml/catalogModule.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<html>
<head>
<link rel="stylesheet" href="{{ (url "css.css") }}" />
</head>
<body>
<div style="border: 1px solid; padding 0.5em;">
<i>module:</i>
<h1 style="display:inline">{{ .Name }}</h1>
Expand All @@ -15,4 +19,5 @@ <h2>metadata</h2>
{{- range $metadataKey := .Metadata.Keys }}
<dt>{{ $metadataKey }}</dt><dd>{{ index $dot.Metadata.Values $metadataKey }}</dd>
{{- end }}
</body>
</html>
5 changes: 5 additions & 0 deletions pkg/cataloghtml/catalogRelease.tmpl.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<html>
<head>
<link rel="stylesheet" href="{{ (url "css.css") }}" />
</head>
<body>
<div style="border: 1px solid; padding 0.5em;">
<i>module:</i>
<h1 style="display:inline">{{ .Module.Name }}</h1>
Expand All @@ -17,4 +21,5 @@ <h2>metadata</h2>
{{- range $metadataKey := .Release.Metadata.Keys }}
<dt>{{ $metadataKey }}</dt><dd>{{ index $dot.Metadata.Values $metadataKey }}</dd>
{{- end }}
</body>
</html>
11 changes: 11 additions & 0 deletions pkg/cataloghtml/cataloghtml.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var (
//go:embed catalogRelease.tmpl.html
catalogReleaseTemplate string

//go:embed css.css
cssBody []byte

// FUTURE: consider the use of `embed.FS` and `template.ParseFS()`, if there grow to be many files here.
// It has slightly less compile-time safety checks on filenames, though.
)
Expand Down Expand Up @@ -61,6 +64,8 @@ func (cfg SiteConfig) tfuncs() map[string]interface{} {

// CatalogAndChildrenToHtml performs CatalogToHtml, and also
// procedes to invoke the html'ing of all modules within.
// Additionally, it does all the other "once" things
// (namely, outputs a copy of the css).
//
// Errors:
//
Expand All @@ -69,9 +74,15 @@ func (cfg SiteConfig) tfuncs() map[string]interface{} {
// - warpforge-error-catalog-invalid -- in case the catalog data is invalid.
// - warpforge-error-catalog-parse -- in case the catalog data failed to parse entirely.
func (cfg SiteConfig) CatalogAndChildrenToHtml() error {
// Emit catalog index.
if err := cfg.CatalogToHtml(); err != nil {
return err
}
// Emit the "once" stuff.
if err := os.WriteFile(filepath.Join(cfg.OutputPath, "css.css"), cssBody, 0644); err != nil {
return wfapi.ErrorIo("couldn't open file for css as part of cataloghtml emission", nil, err)
}
// Emit all modules within.
modNames := cfg.Cat_dab.Modules()
for _, modName := range modNames {
catMod, err := cfg.Cat_dab.GetModule(wfapi.CatalogRef{modName, "", ""})
Expand Down
5 changes: 5 additions & 0 deletions pkg/cataloghtml/css.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
body {
color: #F00;
}
*/

0 comments on commit 90edaf3

Please sign in to comment.