diff options
| author | Jamie Hannaford <jamie.hannaford@rackspace.com> | 2017-05-03 12:49:30 +0200 |
|---|---|---|
| committer | Jamie Hannaford <jamie.hannaford@rackspace.com> | 2017-05-16 12:23:44 +0200 |
| commit | 07082a21ea90a46c2b859b70a056df35e46f916c (patch) | |
| tree | 084c197a3eea70837beae96f707917aa952b7bd8 | |
| parent | ff667b86099ffcc9bd8bc67f8afad974b650af10 (diff) | |
Add footer template
| -rw-r--r-- | build/app.go | 47 | ||||
| -rw-r--r-- | build/footer.mustache | 1 | ||||
| -rw-r--r-- | build/sig_index.mustache | 12 | ||||
| -rw-r--r-- | build/sig_list.mustache | 10 |
4 files changed, 65 insertions, 5 deletions
diff --git a/build/app.go b/build/app.go index 43701fcd..b6b0e469 100644 --- a/build/app.go +++ b/build/app.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "log" "os" + "time" "github.com/cbroglie/mustache" "gopkg.in/yaml.v2" @@ -15,6 +16,7 @@ var ( templateDir = "build" indexTemplate = fmt.Sprintf("%s/sig_index.mustache", templateDir) listTemplate = fmt.Sprintf("%s/sig_list.mustache", templateDir) + footerTemplate = fmt.Sprintf("%s/footer.mustache", templateDir) sigListOutput = "sig-list.md" sigIndexOutput = "README.md" ) @@ -53,6 +55,10 @@ type SigEntries struct { Sigs []Sig } +type Page struct { + LastGenerated string +} + func dirExists(path string) (bool, error) { _, err := os.Stat(path) if err == nil { @@ -64,6 +70,27 @@ func dirExists(path string) (bool, error) { return true, err } +func constructFooter() (data string, err error) { + template, err := mustache.ParseFile(footerTemplate) + if err != nil { + return + } + + ctx := Page{LastGenerated: time.Now().Format("Mon Jan 2 2006 15:04:05")} + + data, err = template.Render(ctx) + if err != nil { + return + } + + err = ioutil.WriteFile(sigListOutput, []byte(data), 0644) + if err != nil { + return + } + + return +} + func createReadmeFiles(ctx SigEntries) error { template, err := mustache.ParseFile(indexTemplate) if err != nil { @@ -87,10 +114,18 @@ func createReadmeFiles(ctx SigEntries) error { } } - err = ioutil.WriteFile(fmt.Sprintf("%s/%s", sig.Dir, sigIndexOutput), []byte(data), 0644) + footer, err := constructFooter() if err != nil { return err } + + filePath := fmt.Sprintf("%s/%s", sig.Dir, sigIndexOutput) + err = ioutil.WriteFile(filePath, []byte(data+footer), 0644) + if err != nil { + return err + } + + fmt.Printf("Generated %s\n", filePath) } return nil @@ -107,11 +142,17 @@ func createListFile(ctx SigEntries) error { return err } - err = ioutil.WriteFile(sigListOutput, []byte(data), 0644) + footer, err := constructFooter() + if err != nil { + return err + } + + err = ioutil.WriteFile(sigListOutput, []byte(data+footer), 0644) if err != nil { return err } + fmt.Printf("Generated %s\n", sigListOutput) return nil } @@ -136,4 +177,6 @@ func main() { if err != nil { log.Fatal(err) } + + fmt.Println("Finished generation!") } diff --git a/build/footer.mustache b/build/footer.mustache new file mode 100644 index 00000000..5b4c6462 --- /dev/null +++ b/build/footer.mustache @@ -0,0 +1 @@ +Last generated: {{LastGenerated}} diff --git a/build/sig_index.mustache b/build/sig_index.mustache index d80f0719..46177bf3 100644 --- a/build/sig_index.mustache +++ b/build/sig_index.mustache @@ -1,15 +1,23 @@ +<!--- +This is an autogenerated file! + +Please do not edit this file directly, but instead make changes to the +sigs.yaml file in the project root. + +To understand how this file is generated, see build/README.md. +--> # {{Name}} SIG {{MissionStatement}} ## Meetings {{#Meetings}} -- [{{Day}}s at {{UTC}} UTC]({{MeetingURL}}) ({{Frequency}}) +* [{{Day}}s at {{UTC}} UTC]({{MeetingURL}}) ({{Frequency}}) {{/Meetings}} Meeting notes and Agenda can be found [here]({{MeetingArchiveURL}}). ## Leads {{#Leads}} -- [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}} +* [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}} {{/Leads}} ## Contact {{#Contact}} diff --git a/build/sig_list.mustache b/build/sig_list.mustache index 7637f192..9400cf59 100644 --- a/build/sig_list.mustache +++ b/build/sig_list.mustache @@ -1,3 +1,11 @@ +<!--- +This is an autogenerated file! + +Please do not edit this file directly, but instead make changes to the +sigs.yaml file in the project root. + +To understand how this file is generated, see build/README.md. +--> # SIGs and Working Groups Most community activity is organized into Special Interest Groups (SIGs), @@ -15,5 +23,5 @@ When the need arises, a [new SIG can be created](sig-creation-procedure.md) | Name | Leads | Contact | Meetings | |------|-------|---------|----------| {{#Sigs}} -|[{{ Name }}]({{ Dir }}/README.md)|{{#Leads}}- [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}<br>{{/Leads}}|{{#Contact}}- [Slack](https://kubernetes.slack.com/messages/{{Slack}})<br>- [Mailing List]({{MailingList}}){{/Contact}}|{{#Meetings}}- [{{Day}}s at {{UTC}} UTC ({{Frequency}})]({{MeetingURL}})<br>{{/Meetings}} +|[{{ Name }}]({{ Dir }}/README.md)|{{#Leads}}* [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}<br>{{/Leads}}|{{#Contact}}* [Slack](https://kubernetes.slack.com/messages/{{Slack}})<br>* [Mailing List]({{MailingList}}){{/Contact}}|{{#Meetings}}* [{{Day}}s at {{UTC}} UTC ({{Frequency}})]({{MeetingURL}})<br>{{/Meetings}} {{/Sigs}} |
