mirror of
https://github.com/avelino/awesome-go.git
synced 2024-12-12 17:13:58 +00:00
fix links
This commit is contained in:
parent
16e952a3b4
commit
5fa7909eb1
61
repo.go
61
repo.go
@ -11,27 +11,74 @@ import (
|
|||||||
"github.com/russross/blackfriday"
|
"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 {
|
type content struct {
|
||||||
Body string
|
Body string
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateHTML() {
|
func generateHTML() {
|
||||||
// Update repo
|
// Update repo
|
||||||
exec.Command("git", "checkout", "-f").Output()
|
exec.Command(git, checkout, force).Output()
|
||||||
exec.Command("git", "pull").Output()
|
exec.Command(git, pull).Output()
|
||||||
|
|
||||||
input, _ := ioutil.ReadFile("./README.md")
|
input, _ := ioutil.ReadFile(readmePath)
|
||||||
body := string(blackfriday.MarkdownCommon(input))
|
body := string(
|
||||||
|
blackfriday.Markdown(
|
||||||
|
input,
|
||||||
|
blackfriday.HtmlRenderer(
|
||||||
|
bfHTMLRendererOpts,
|
||||||
|
emtyStr,
|
||||||
|
emtyStr,
|
||||||
|
),
|
||||||
|
bfMDOpts,
|
||||||
|
),
|
||||||
|
)
|
||||||
c := &content{Body: body}
|
c := &content{Body: body}
|
||||||
|
|
||||||
t := template.Must(template.ParseFiles("tmpl/tmpl.html"))
|
t := template.Must(template.ParseFiles(tplPath))
|
||||||
f, _ := os.Create("tmpl/index.html")
|
f, _ := os.Create(idxPath)
|
||||||
t.Execute(f, c)
|
t.Execute(f, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func hookHandler(w http.ResponseWriter, r *http.Request) {
|
func hookHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
go generateHTML()
|
go generateHTML()
|
||||||
w.Write([]byte("Done!\n"))
|
w.Write(doneResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user