mirror of
https://github.com/avelino/awesome-go.git
synced 2024-11-13 11:14:37 -05:00
d6a65b74e1
* 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
41 lines
766 B
Go
41 lines
766 B
Go
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)
|
|
}
|