Markdown to html, generate page to awesome-go.com (#1127)
* initial version html generate After being made to change the master generate html based on markdown, ref #363 * change package name, repo to main * up port 80 on caddy server * install mux on travis build * generate sitemap * added robots.txt * set metatags on html page * update repo via exec get the most current readme * remove unnecessary lowdash assign * fix linter errors, remove unnecessary conversion, add binary to .gitignore * fix fonts, use domain-level assets
This commit is contained in:
committed by
Kirill Danshin
parent
ff219e23d9
commit
d6a65b74e1
42
repo.go
42
repo.go
@@ -1 +1,41 @@
|
||||
package repo
|
||||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"os/exec"
|
||||
"text/template"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/russross/blackfriday"
|
||||
)
|
||||
|
||||
type content struct {
|
||||
Body string
|
||||
}
|
||||
|
||||
func generateHTML() {
|
||||
// Update repo
|
||||
exec.Command("git", "checkout", "-f").Output()
|
||||
exec.Command("git", "pull").Output()
|
||||
|
||||
input, _ := ioutil.ReadFile("./README.md")
|
||||
body := string(blackfriday.MarkdownCommon(input))
|
||||
c := &content{Body: body}
|
||||
|
||||
t := template.Must(template.ParseFiles("tmpl/tmpl.html"))
|
||||
f, _ := os.Create("tmpl/index.html")
|
||||
t.Execute(f, c)
|
||||
}
|
||||
|
||||
func hookHandler(w http.ResponseWriter, r *http.Request) {
|
||||
go generateHTML()
|
||||
w.Write([]byte("Done!\n"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/hook", hookHandler)
|
||||
http.ListenAndServe(":9000", r)
|
||||
}
|
||||
|
Reference in New Issue
Block a user