fix links

This commit is contained in:
Kirill Danshin 2016-10-11 04:30:20 +03:00
parent 16e952a3b4
commit 5fa7909eb1
No known key found for this signature in database
GPG Key ID: CDB433260D3A15F9

61
repo.go
View File

@ -11,27 +11,74 @@ import (
"github.com/russross/blackfriday"
)
// memory usage optimizations
const (
emtyStr = ""
git = "git"
checkout = "checkout"
force = "-f"
pull = "pull"
// options
readmePath = "./README.md"
tplPath = "tmpl/tmpl.html"
idxPath = "tmpl/index.html"
bfHTMLRendererOpts = 0 |
blackfriday.HTML_USE_XHTML |
blackfriday.HTML_USE_SMARTYPANTS |
blackfriday.HTML_SMARTYPANTS_FRACTIONS |
blackfriday.HTML_SMARTYPANTS_DASHES |
blackfriday.HTML_SMARTYPANTS_LATEX_DASHES
bfMDOpts = 0 |
blackfriday.EXTENSION_NO_INTRA_EMPHASIS |
blackfriday.EXTENSION_TABLES |
blackfriday.EXTENSION_FENCED_CODE |
blackfriday.EXTENSION_AUTOLINK |
blackfriday.EXTENSION_STRIKETHROUGH |
blackfriday.EXTENSION_SPACE_HEADERS |
blackfriday.EXTENSION_HEADER_IDS |
blackfriday.EXTENSION_BACKSLASH_LINE_BREAK |
blackfriday.EXTENSION_DEFINITION_LISTS |
blackfriday.EXTENSION_AUTO_HEADER_IDS
)
var (
doneResp = []byte("Done!\n")
)
type content struct {
Body string
}
func generateHTML() {
// Update repo
exec.Command("git", "checkout", "-f").Output()
exec.Command("git", "pull").Output()
exec.Command(git, checkout, force).Output()
exec.Command(git, pull).Output()
input, _ := ioutil.ReadFile("./README.md")
body := string(blackfriday.MarkdownCommon(input))
input, _ := ioutil.ReadFile(readmePath)
body := string(
blackfriday.Markdown(
input,
blackfriday.HtmlRenderer(
bfHTMLRendererOpts,
emtyStr,
emtyStr,
),
bfMDOpts,
),
)
c := &content{Body: body}
t := template.Must(template.ParseFiles("tmpl/tmpl.html"))
f, _ := os.Create("tmpl/index.html")
t := template.Must(template.ParseFiles(tplPath))
f, _ := os.Create(idxPath)
t.Execute(f, c)
}
func hookHandler(w http.ResponseWriter, r *http.Request) {
go generateHTML()
w.Write([]byte("Done!\n"))
w.Write(doneResp)
}
func main() {