mirror of https://github.com/statping/statping
generate Help.vue from Wiki go:generate task
parent
3067bc085a
commit
5f774b732a
|
@ -4,7 +4,7 @@
|
|||
- Added "Update Available" alert on the top of Settings if new version is available
|
||||
- Added Version and Github Commit hash to left navigation on Settings page
|
||||
- Added "reason" for failures (will be used for more custom notification messages) [regex, lookup, timeout, connection, close, status_code]
|
||||
- Added Help page that will be generated from Statping's Wiki repo
|
||||
- Added Help page that is generated from Statping's Wiki repo on build
|
||||
|
||||
# 0.90.63 (08-17-2020)
|
||||
- Modified build process to use xgo for all arch builds
|
||||
|
|
8
Makefile
8
Makefile
|
@ -420,5 +420,13 @@ check:
|
|||
# sentry-cli releases set-commits --auto $VERSION
|
||||
# sentry-cli releases files $VERSION upload-sourcemaps dist
|
||||
|
||||
gen_help:
|
||||
for file in ./statping.wiki/*.md
|
||||
do
|
||||
# convert each file to html and place it in the html directory
|
||||
# --gfm == use github flavoured markdown
|
||||
marked -o html/$file.html $file --gfm
|
||||
done
|
||||
|
||||
.PHONY: all check build certs multiarch install-darwin go-build build-all buildx-base buildx-dev buildx-latest build-alpine test-all test test-api docker frontend up down print_details lite sentry-release snapcraft build-linux build-mac build-win build-all postman
|
||||
.SILENT: travis_s3_creds
|
||||
|
|
|
@ -14,18 +14,21 @@
|
|||
<li @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/services" class="nav-link">{{ $t('top_nav.services') }}</router-link>
|
||||
</li>
|
||||
<li v-if="$store.state.admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<li v-if="admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/users" class="nav-link">{{ $t('top_nav.users') }}</router-link>
|
||||
</li>
|
||||
<li @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/messages" class="nav-link">{{ $t('top_nav.announcements') }}</router-link>
|
||||
</li>
|
||||
<li v-if="$store.state.admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<li v-if="admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/settings" class="nav-link">{{ $t('top_nav.settings') }}</router-link>
|
||||
</li>
|
||||
<li v-if="$store.state.admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/logs" class="nav-link">{{ $t('top_nav.logs') }}</router-link>
|
||||
</li>
|
||||
<li v-if="admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/logs" class="nav-link">{{ $t('top_nav.logs') }}</router-link>
|
||||
</li>
|
||||
<li v-if="admin" @click="navopen = !navopen" class="nav-item navbar-item">
|
||||
<router-link to="/dashboard/help" class="nav-link">{{ $t('top_nav.help') }}</router-link>
|
||||
</li>
|
||||
</ul>
|
||||
<span class="navbar-text">
|
||||
<a href="#" class="nav-link" @click.prevent="logout">{{ $t('top_nav.logout') }}</a>
|
||||
|
@ -45,6 +48,11 @@
|
|||
navopen: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
admin() {
|
||||
return this.$store.state.admin
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async logout () {
|
||||
await Api.logout()
|
||||
|
|
|
@ -7,6 +7,7 @@ const english = {
|
|||
announcements: "Announcements",
|
||||
settings: "Settings",
|
||||
logs: "Logs",
|
||||
help: "Help",
|
||||
logout: 'Logout',
|
||||
},
|
||||
setup: {
|
||||
|
|
|
@ -7,6 +7,7 @@ const french = {
|
|||
announcements: "Announcements",
|
||||
settings: "Settings",
|
||||
logs: "Logs",
|
||||
help: "Help",
|
||||
logout: 'Logout',
|
||||
},
|
||||
setup: {
|
||||
|
|
|
@ -7,6 +7,7 @@ const german = {
|
|||
announcements: "Announcements",
|
||||
settings: "Settings",
|
||||
logs: "Logs",
|
||||
help: "Help",
|
||||
logout: 'Logout',
|
||||
},
|
||||
setup: {
|
||||
|
|
|
@ -7,6 +7,7 @@ const russian = {
|
|||
announcements: "Announcements",
|
||||
settings: "Settings",
|
||||
logs: "Logs",
|
||||
help: "Help",
|
||||
logout: 'Logout',
|
||||
},
|
||||
setup: {
|
||||
|
|
|
@ -7,6 +7,7 @@ const spanish = {
|
|||
announcements: "Announcements",
|
||||
settings: "Settings",
|
||||
logs: "Logs",
|
||||
help: "Help",
|
||||
logout: 'Logout',
|
||||
},
|
||||
setup: {
|
||||
|
|
File diff suppressed because it is too large
Load Diff
2
go.mod
2
go.mod
|
@ -12,6 +12,7 @@ require (
|
|||
github.com/fsnotify/fsnotify v1.4.9 // indirect
|
||||
github.com/getsentry/sentry-go v0.5.1
|
||||
github.com/go-mail/mail v2.3.1+incompatible
|
||||
github.com/gomarkdown/markdown v0.0.0-20200817091206-6efd7696db82
|
||||
github.com/gorilla/mux v1.7.4
|
||||
github.com/hako/durafmt v0.0.0-20200605151348-3a43fc422dd9
|
||||
github.com/jinzhu/gorm v1.9.12
|
||||
|
@ -28,6 +29,7 @@ require (
|
|||
github.com/spf13/viper v1.6.3
|
||||
github.com/stretchr/testify v1.5.1
|
||||
github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1
|
||||
github.com/tdewolff/minify/v2 v2.8.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
|
||||
|
|
12
go.sum
12
go.sum
|
@ -114,6 +114,7 @@ github.com/cenkalti/backoff/v4 v4.0.2/go.mod h1:eEew/i+1Q6OrCDZh3WiXYv3+nJwBASZ8
|
|||
github.com/census-instrumentation/opencensus-proto v0.2.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cheekybits/is v0.0.0-20150225183255-68e9c0620927/go.mod h1:h/aW8ynjgkuj+NQRlZcDbAbM1ORAbXjXX77sX7T289U=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
|
@ -253,6 +254,8 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
|||
github.com/golang/protobuf v1.4.0 h1:oOuy+ugB+P/kBdUnG5QaMXSIyJ1q38wWSojYCb3z5VQ=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/snappy v0.0.0-20180518054509-2e65f85255db/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/gomarkdown/markdown v0.0.0-20200817091206-6efd7696db82 h1:2EHQMBglPpettuq2LG+2NRGHhVaRYhxgwPTcgpXVXz8=
|
||||
github.com/gomarkdown/markdown v0.0.0-20200817091206-6efd7696db82/go.mod h1:aii0r/K0ZnHv7G0KF7xy1v0A7s2Ljrb5byB7MO5p6TU=
|
||||
github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
|
@ -397,6 +400,7 @@ github.com/liquidweb/liquidweb-go v1.6.1/go.mod h1:UDcVnAMDkZxpw4Y7NOHkqoeiGacVL
|
|||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/magiconair/properties v1.8.1 h1:ZC2Vc7/ZFkGmsVC9KvOjumD+G5lXy2RtTKyzRKO2BQ4=
|
||||
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/matryer/try v0.0.0-20161228173917-9ac251b645a2/go.mod h1:0KeJpeMD6o+O4hW7qJOT7vyQPKrWmj26uf5wMc/IiIs=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
|
@ -574,6 +578,13 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
|
|||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||
github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1 h1:HGVkRrwDCbmSP6h1CoBDj6l/mhnvsP5JbYaQ4ss0R6o=
|
||||
github.com/t-tiger/gorm-bulk-insert/v2 v2.0.1/go.mod h1:I3xbaE9ud9/TEXzehwkHx86SyJwqeSNsX2X5oV61jIg=
|
||||
github.com/tdewolff/minify v1.1.0 h1:nxHQi1ML+g3ZbZHffiZ6eC7vMqNvSRfX3KB5Y5y/kfw=
|
||||
github.com/tdewolff/minify v2.3.6+incompatible h1:2hw5/9ZvxhWLvBUnHE06gElGYz+Jv9R4Eys0XUzItYo=
|
||||
github.com/tdewolff/minify/v2 v2.8.0 h1:t3tOPWkTpKhsgxm3IM9Sy8hE2eIt30Oaa+2havJGGIE=
|
||||
github.com/tdewolff/minify/v2 v2.8.0/go.mod h1:6zN8VLhMfFxNrwHROcboYNo2+huPNu4SV8DPh3PUQ8E=
|
||||
github.com/tdewolff/parse/v2 v2.4.4 h1:uMdbQRtYbKR/msP9CbI7li9wK6pionYiH6s7ipltyGY=
|
||||
github.com/tdewolff/parse/v2 v2.4.4/go.mod h1:WzaJpRSbwq++EIQHYIRTpbYKNA3gn9it1Ik++q4zyho=
|
||||
github.com/tdewolff/test v1.0.6/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7 h1:CpHxIaZzVy26GqJn8ptRyto8fuoYOd1v0fXm9bG3wQ8=
|
||||
github.com/timewasted/linode v0.0.0-20160829202747-37e84520dcf7/go.mod h1:imsgLplxEC/etjIhdr3dNzV3JeT27LbVu5pYWm0JCBY=
|
||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
|
||||
|
@ -623,6 +634,7 @@ go.uber.org/ratelimit v0.0.0-20180316092928-c15da0234277/go.mod h1:2X8KaoNd1J0lZ
|
|||
go.uber.org/ratelimit v0.1.0 h1:U2AruXqeTb4Eh9sYQSTrMhH8Cb7M0Ian2ibBOnBcnAw=
|
||||
go.uber.org/ratelimit v0.1.0/go.mod h1:2X8KaoNd1J0lZV+PxJk/5+DGbO/tpwLR1m++a7FnB/Y=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
golang.org/dl v0.0.0-20190829154251-82a15e2f2ead/go.mod h1:IUMfjQLJQd4UTqG1Z90tenwKoCX93Gn3MAQJMOSBsDQ=
|
||||
golang.org/x/crypto v0.0.0-20180621125126-a49355c7e3f8/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
|
|
|
@ -0,0 +1,182 @@
|
|||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/gomarkdown/markdown"
|
||||
"github.com/gomarkdown/markdown/html"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const wikiUrl = "https://github.com/statping/statping.wiki"
|
||||
|
||||
var vue = `<template>
|
||||
<div class="col-12">
|
||||
<div class="row mb-4">
|
||||
{{ range .Categories }}
|
||||
<div class="col">
|
||||
<h4 class="h4 mb-2">{{ .String }}</h4>
|
||||
{{ range .Pages }}
|
||||
<a @click.prevent='tab="{{.String}}"' class="d-block mb-1 text-link" href="#">{{.String}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="col-12" v-if='tab === "Home"'>
|
||||
<div v-pre>
|
||||
{{html .Home.Data}}
|
||||
</div>
|
||||
</div>
|
||||
{{ range .Pages }}
|
||||
<div class="col-12" v-if='tab === "{{.String}}"'>
|
||||
<h1 class="h1 mt-5 mb-5 text-muted">{{ .String }}</h1>
|
||||
<span class="spacer"></span>
|
||||
<div v-pre>
|
||||
{{html .Data}}
|
||||
</div>
|
||||
</div>
|
||||
{{end}}
|
||||
|
||||
<div class="col-12 shadow-md mt-5">
|
||||
<div class="text-dim" v-pre>
|
||||
{{html .Footer.Data}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center small text-dim" v-pre>
|
||||
Automatically generated from Statping's Wiki on {{.CreatedAt}}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
name: 'Help',
|
||||
data () {
|
||||
return {
|
||||
tab: "Home",
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
IMG {
|
||||
max-width: 80%;
|
||||
alignment: center;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
`
|
||||
|
||||
var temp *template.Template
|
||||
|
||||
type Category struct {
|
||||
String string
|
||||
Pages []*Page
|
||||
}
|
||||
|
||||
type Page struct {
|
||||
String string
|
||||
Data string
|
||||
}
|
||||
|
||||
type Render struct {
|
||||
Categories []*Category
|
||||
Pages []*Page
|
||||
Home *Page
|
||||
Footer *Page
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("\n\nGenerating Help.vue from Statping's Wiki")
|
||||
fmt.Println("Cloning ", wikiUrl)
|
||||
cmd := exec.Command("git", "clone", wikiUrl)
|
||||
cmd.Start()
|
||||
cmd.Wait()
|
||||
|
||||
fmt.Println("Generating Help view from Wiki")
|
||||
|
||||
d, _ := ioutil.ReadFile("statping.wiki/_Sidebar.md")
|
||||
|
||||
var cats []*Category
|
||||
var pages []*Page
|
||||
scanner := bufio.NewScanner(strings.NewReader(string(d)))
|
||||
var thisCategory *Category
|
||||
for scanner.Scan() {
|
||||
txt := scanner.Text()
|
||||
if txt == "" {
|
||||
continue
|
||||
}
|
||||
if txt[0:1] == "#" {
|
||||
newCate := &Category{
|
||||
String: txt[2:len(txt)],
|
||||
}
|
||||
if txt[2:len(txt)] == "Contact" || txt[2:len(txt)] == "Badges" {
|
||||
continue
|
||||
}
|
||||
thisCategory = newCate
|
||||
cats = append(cats, newCate)
|
||||
}
|
||||
if txt[0:2] == "[[" {
|
||||
file := "statping.wiki/" + txt[2:len(txt)-2] + ".md"
|
||||
file = strings.ReplaceAll(file, " ", "-")
|
||||
page := &Page{
|
||||
String: txt[2 : len(txt)-2],
|
||||
Data: open(file),
|
||||
}
|
||||
pages = append(pages, page)
|
||||
thisCategory.Pages = append(thisCategory.Pages, page)
|
||||
}
|
||||
}
|
||||
|
||||
home := &Page{
|
||||
String: "Home",
|
||||
Data: open("statping.wiki/Home.md"),
|
||||
}
|
||||
|
||||
footer := &Page{
|
||||
String: "Footer",
|
||||
Data: open("statping.wiki/_Footer.md"),
|
||||
}
|
||||
|
||||
w := bytes.NewBufferString("")
|
||||
temp = template.New("wiki")
|
||||
temp.Funcs(template.FuncMap{
|
||||
"html": func(val string) template.HTML {
|
||||
return template.HTML(val)
|
||||
},
|
||||
"fake": func(val string) template.HTML {
|
||||
return template.HTML(`{{` + val + `}}`)
|
||||
},
|
||||
})
|
||||
temp, _ = temp.Parse(vue)
|
||||
temp.ExecuteTemplate(w, "wiki", Render{Categories: cats, Pages: pages, Home: home, Footer: footer, CreatedAt: time.Now().UTC()})
|
||||
|
||||
fmt.Println("Saving wiki page to: ./frontend/src/pages/Home.vue")
|
||||
ioutil.WriteFile("../frontend/src/pages/Help.vue", w.Bytes(), os.FileMode(0755))
|
||||
|
||||
fmt.Println("Deleting statping wiki repo")
|
||||
os.RemoveAll("statping.wiki")
|
||||
}
|
||||
|
||||
func open(filename string) string {
|
||||
htmlFlags := html.CommonFlags | html.HrefTargetBlank
|
||||
opts := html.RendererOptions{Flags: htmlFlags}
|
||||
renderer := html.NewRenderer(opts)
|
||||
|
||||
d, _ := ioutil.ReadFile(filename)
|
||||
output := markdown.ToHTML(d, nil, renderer)
|
||||
return string(output)
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package source
|
||||
|
||||
//go:generate go run generate_help.go
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/GeertJohan/go.rice"
|
||||
|
|
Loading…
Reference in New Issue