mirror of https://github.com/statping/statping
92 lines
2.6 KiB
Go
92 lines
2.6 KiB
Go
![]() |
// +build ignore
|
||
|
|
||
|
// Statup
|
||
|
// Copyright (C) 2018. Hunter Long and the project contributors
|
||
|
// Written by Hunter Long <info@socialeck.com> and the project contributors
|
||
|
//
|
||
|
// https://github.com/hunterlong/statup
|
||
|
//
|
||
|
// The licenses for most software and other practical works are designed
|
||
|
// to take away your freedom to share and change the works. By contrast,
|
||
|
// the GNU General Public License is intended to guarantee your freedom to
|
||
|
// share and change all versions of a program--to make sure it remains free
|
||
|
// software for all its users.
|
||
|
//
|
||
|
// You should have received a copy of the GNU General Public License
|
||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/hunterlong/statping/utils"
|
||
|
"io/ioutil"
|
||
|
"log"
|
||
|
"os"
|
||
|
"strings"
|
||
|
"text/template"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
wikiUrl = "http://assets.statping.com/wiki/"
|
||
|
)
|
||
|
|
||
|
func replaceDash(s string) string {
|
||
|
return strings.Replace(s, "-", " ", -1)
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
var compiled string
|
||
|
|
||
|
utils.InitLogs()
|
||
|
utils.Command("git clone https://github.com/hunterlong/statping.wiki.git")
|
||
|
|
||
|
pages := []string{"Types-of-Monitoring", "Features", "Start-Statping", "Linux", "Mac", "Windows", "AWS-EC2", "Docker", "Mobile-App", "Heroku", "API", "Makefile",
|
||
|
"Notifiers", "Notifier-Events", "Notifier-Example", "Prometheus-Exporter", "SSL", "Static-Export", "Statping-Plugins", "Statuper", "PGP-Signature", "Testing"}
|
||
|
newPages := map[string]string{}
|
||
|
|
||
|
for _, v := range pages {
|
||
|
compiled += "<a class=\"scrollclick\" href=\"#\" data-id=\"page_" + v + "\">" + replaceDash(v) + "</a><br>"
|
||
|
}
|
||
|
|
||
|
for _, v := range pages {
|
||
|
sc, _ := ioutil.ReadFile("statping.wiki/" + v + ".md")
|
||
|
newPages[v] = string(sc)
|
||
|
compiled += "\n\n<div class=\"mt-5\" id=\"page_" + v + "\"><h1>" + replaceDash(v) + "</h1></div>\n" + string(sc)
|
||
|
}
|
||
|
|
||
|
utils.DeleteDirectory("./statping.wiki")
|
||
|
utils.DeleteDirectory("./logs")
|
||
|
|
||
|
f, err := os.Create("wiki.go")
|
||
|
die(err)
|
||
|
defer f.Close()
|
||
|
|
||
|
packageTemplate.Execute(f, struct {
|
||
|
Timestamp time.Time
|
||
|
URL string
|
||
|
Compiled string
|
||
|
Pages map[string]string
|
||
|
}{
|
||
|
Timestamp: time.Now(),
|
||
|
URL: "ok",
|
||
|
Compiled: compiled,
|
||
|
Pages: newPages,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func die(err error) {
|
||
|
if err != nil {
|
||
|
log.Fatal(err)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
var packageTemplate = template.Must(template.New("").Parse(`// Code generated by go generate; DO NOT EDIT.
|
||
|
// This file was generated by robots at
|
||
|
// {{ .Timestamp }}
|
||
|
//
|
||
|
// This contains the most recently Markdown source for the Statping Wiki.
|
||
|
package source
|
||
|
|
||
|
// CompiledWiki contains all of the Statping Wiki pages from the Github Wiki repo.
|
||
|
var CompiledWiki = []byte({{printf "%q" .Compiled}})`))
|