From 6adec5105142a6a746a08ad715bd5467a1a1db55 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Sat, 13 Apr 2024 15:18:19 -0600 Subject: initial html --- .gitignore | 1 + gen.go | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ go.mod | 5 ++++ go.sum | 8 ++++++ plan.html.tmpl | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ plan.yml | 48 +++++++++++++++++++--------------- 6 files changed, 198 insertions(+), 21 deletions(-) create mode 100644 .gitignore create mode 100644 gen.go create mode 100644 go.sum create mode 100644 plan.html.tmpl diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2c656a5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/plan.html diff --git a/gen.go b/gen.go new file mode 100644 index 0000000..39180ec --- /dev/null +++ b/gen.go @@ -0,0 +1,81 @@ +package main + +import ( + "bytes" + _ "embed" + "fmt" + "os" + "sigs.k8s.io/yaml" + "strings" + + "github.com/yuin/goldmark" + "html/template" +) + +type Plan struct { + Tags map[string]TagInfo `json:"tags"` + Contributions []Contribution `json:"contributions"` +} + +type TagInfo struct { + PrettyName string `json:"prettyName"` + Desc string `json:"desc"` +} + +type Contribution struct { + URLs []string `json:"urls"` + Tags []string `json:"tags"` + SponsoredBy string `json:"sponsored-by"` + Desc string `json:"desc"` +} + +func ReadPlan(filename string) (Plan, error) { + bs, err := os.ReadFile(filename) + if err != nil { + return Plan{}, err + } + var ret Plan + if err := yaml.UnmarshalStrict(bs, &ret); err != nil { + return Plan{}, err + } + return ret, nil +} + +func MarkdownToHTML(md string) (template.HTML, error) { + var html strings.Builder + if err := goldmark.Convert([]byte(md), &html); err != nil { + return template.HTML(""), err + } + return template.HTML(html.String()), nil +} + +func main() { + if err := mainWithError(); err != nil { + fmt.Fprintf(os.Stderr, "%s: error: %v\n", os.Args[0], err) + os.Exit(1) + } +} + +//go:embed plan.html.tmpl +var embedPlanHTMLTmpl string + +var tmpl = template.Must(template.New("plan.html"). + Funcs(template.FuncMap{ + "md2html": MarkdownToHTML, + }). + Parse(embedPlanHTMLTmpl)) + +func mainWithError() error { + plan, err := ReadPlan("plan.yml") + if err != nil { + return err + } + var out bytes.Buffer + if err := tmpl.Execute(&out, plan); err != nil { + return err + } + if err := os.WriteFile("plan.html", out.Bytes(), 0666); err != nil { + return err + } + return nil +} diff --git a/go.mod b/go.mod index c60e021..4bcd940 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,8 @@ module git.lukeshu.com/imworkingon go 1.22.2 + +require ( + github.com/yuin/goldmark v1.7.1 + sigs.k8s.io/yaml v1.4.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..6157653 --- /dev/null +++ b/go.sum @@ -0,0 +1,8 @@ +github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/yuin/goldmark v1.7.1 h1:3bajkSilaCbjdKVsKdZjZCLBNPL9pYzrCakKaf4U49U= +github.com/yuin/goldmark v1.7.1/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E= +sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY= diff --git a/plan.html.tmpl b/plan.html.tmpl new file mode 100644 index 0000000..d1d1696 --- /dev/null +++ b/plan.html.tmpl @@ -0,0 +1,76 @@ + + + + + Luke is working on + + + +
+

Luke is working on...

+

... improving the GNU/Linux ecosystem.

+ {{- range $tagName, $tagInfo := .Tags }} +
+

#{{ $tagName }} : {{ $tagInfo.PrettyName }}

+
{{ $tagInfo.Desc | md2html }}
+
+ {{- end }} +
+
+

... by contributing...

+ {{- range $contrib := .Contributions }} +
+
+ {{- range $url := $contrib.URLs }} + {{ $url }}
+ {{- end }} +
+
+ {{- range $tag := $contrib.Tags }} + #{{ $tag }} {{/* */}} + {{- end }} +
+
{{ $contrib.Desc | md2html }}
+
+ {{- end }} +
+ + diff --git a/plan.yml b/plan.yml index bc4fd62..b576bb4 100644 --- a/plan.yml +++ b/plan.yml @@ -1,25 +1,31 @@ tags: - docs: | - I'm working to improve documentation for GNU/Linux, but more than - that I'm working to improve the forms of documentation that more - skilled technical writers might be afraid or incapable of working - on: `--help` text, generated documentation, and auditing - documentation against the source code to make sure that it is - accurate and complete. - GI: | - "GObject Introspection" (which is a terrible name for what it is, - btw) is a cross-(language-runtime) object system. GObject was an - object system for C that game out of GTK+, and then GObject - Introspection was created as a way to specify the ABI for working - with an object, so that GObjects could be used from other - languages. I think that GObject Introspection is a really cool - technology that can be the basis of reducing friction between - languages, but it needs better/more-ubiquitous tooling. - ARM: | - Not that folks can't use GNU/Linux on ARM (obviously, the - Raspberry Pi has been a huge success), but there's still a lot - more friction to using GNU/Linux on ARM compared to x86. I'm - working on that. + docs: + prettyName: Documentation + desc: | + I'm working to improve documentation for GNU/Linux, but more + than that I'm working to improve the forms of documentation that + more skilled technical writers might be afraid or incapable of + working on: `--help` text, generated documentation, and auditing + documentation against the source code to make sure that it is + accurate and complete. + ARM: + prettyName: ARM support + desc: | + Not that folks can't use GNU/Linux on ARM (obviously, the + Raspberry Pi has been a huge success), but there's still a lot + more friction to using GNU/Linux on ARM compared to x86. I'm + working on that. + GI: + prettyName: GObject Introspection + desc: | + GObject Introspection (which is a terrible name for what it is, + btw) is a cross-(language-runtime) object system. GObject was + an object system for C that game out of GTK+, and then GObject + Introspection was created as a way to specify the ABI for + working with an object, so that GObjects could be used from + other languages. I think that GObject Introspection is a really + cool technology that can be the basis of reducing friction + between languages, but it needs better/more-ubiquitous tooling. contributions: - urls: [https://github.com/flori/json/pull/567] -- cgit v1.2.3-2-g168b