Add footer template
This commit is contained in:
parent
ff667b8609
commit
07082a21ea
47
build/app.go
47
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!")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
Last generated: {{LastGenerated}}
|
||||
|
|
@ -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}}
|
||||
|
|
|
|||
|
|
@ -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}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue