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"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/cbroglie/mustache"
|
"github.com/cbroglie/mustache"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
|
|
@ -15,6 +16,7 @@ var (
|
||||||
templateDir = "build"
|
templateDir = "build"
|
||||||
indexTemplate = fmt.Sprintf("%s/sig_index.mustache", templateDir)
|
indexTemplate = fmt.Sprintf("%s/sig_index.mustache", templateDir)
|
||||||
listTemplate = fmt.Sprintf("%s/sig_list.mustache", templateDir)
|
listTemplate = fmt.Sprintf("%s/sig_list.mustache", templateDir)
|
||||||
|
footerTemplate = fmt.Sprintf("%s/footer.mustache", templateDir)
|
||||||
sigListOutput = "sig-list.md"
|
sigListOutput = "sig-list.md"
|
||||||
sigIndexOutput = "README.md"
|
sigIndexOutput = "README.md"
|
||||||
)
|
)
|
||||||
|
|
@ -53,6 +55,10 @@ type SigEntries struct {
|
||||||
Sigs []Sig
|
Sigs []Sig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Page struct {
|
||||||
|
LastGenerated string
|
||||||
|
}
|
||||||
|
|
||||||
func dirExists(path string) (bool, error) {
|
func dirExists(path string) (bool, error) {
|
||||||
_, err := os.Stat(path)
|
_, err := os.Stat(path)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -64,6 +70,27 @@ func dirExists(path string) (bool, error) {
|
||||||
return true, err
|
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 {
|
func createReadmeFiles(ctx SigEntries) error {
|
||||||
template, err := mustache.ParseFile(indexTemplate)
|
template, err := mustache.ParseFile(indexTemplate)
|
||||||
if err != nil {
|
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 {
|
if err != nil {
|
||||||
return err
|
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
|
return nil
|
||||||
|
|
@ -107,11 +142,17 @@ func createListFile(ctx SigEntries) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = ioutil.WriteFile(sigListOutput, []byte(data), 0644)
|
footer, err := constructFooter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = ioutil.WriteFile(sigListOutput, []byte(data+footer), 0644)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Printf("Generated %s\n", sigListOutput)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,4 +177,6 @@ func main() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
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
|
# {{Name}} SIG
|
||||||
|
|
||||||
{{MissionStatement}}
|
{{MissionStatement}}
|
||||||
## Meetings
|
## Meetings
|
||||||
{{#Meetings}}
|
{{#Meetings}}
|
||||||
- [{{Day}}s at {{UTC}} UTC]({{MeetingURL}}) ({{Frequency}})
|
* [{{Day}}s at {{UTC}} UTC]({{MeetingURL}}) ({{Frequency}})
|
||||||
{{/Meetings}}
|
{{/Meetings}}
|
||||||
Meeting notes and Agenda can be found [here]({{MeetingArchiveURL}}).
|
Meeting notes and Agenda can be found [here]({{MeetingArchiveURL}}).
|
||||||
|
|
||||||
## Leads
|
## Leads
|
||||||
{{#Leads}}
|
{{#Leads}}
|
||||||
- [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}
|
* [{{Name}}](https://github.com/{{GitHub}}){{#Company}}, {{Company}}{{/Company}}
|
||||||
{{/Leads}}
|
{{/Leads}}
|
||||||
## Contact
|
## Contact
|
||||||
{{#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
|
# SIGs and Working Groups
|
||||||
|
|
||||||
Most community activity is organized into Special Interest Groups (SIGs),
|
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 |
|
| Name | Leads | Contact | Meetings |
|
||||||
|------|-------|---------|----------|
|
|------|-------|---------|----------|
|
||||||
{{#Sigs}}
|
{{#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}}
|
{{/Sigs}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue