This commit is contained in:
Unknown 2014-04-07 14:24:58 -04:00
parent 7776f407b6
commit 22feddf804
2 changed files with 17 additions and 11 deletions

View file

@ -138,11 +138,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
IsPrivate: private, IsPrivate: private,
IsBare: repoLang == "" && license == "" && !initReadme, IsBare: repoLang == "" && license == "" && !initReadme,
} }
repoPath := RepoPath(user.Name, repoName) repoPath := RepoPath(user.Name, repoName)
if err = initRepository(repoPath, user, repo, initReadme, repoLang, license); err != nil {
return nil, err
}
sess := orm.NewSession() sess := orm.NewSession()
defer sess.Close() defer sess.Close()
sess.Begin() sess.Begin()
@ -207,6 +204,10 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
log.Error("repo.CreateRepository(WatchRepo): %v", err) log.Error("repo.CreateRepository(WatchRepo): %v", err)
} }
if err = initRepository(repoPath, user, repo, initReadme, repoLang, license); err != nil {
return nil, err
}
return repo, nil return repo, nil
} }
@ -332,6 +333,11 @@ func initRepository(f string, user *User, repo *Repository, initReadme bool, rep
return nil return nil
} }
// for update use
os.Setenv("userName", user.Name)
os.Setenv("userId", base.ToStr(user.Id))
os.Setenv("repoName", repo.Name)
// Apply changes and commit. // Apply changes and commit.
return initRepoCommit(tmpDir, user.NewGitSig()) return initRepoCommit(tmpDir, user.NewGitSig())
} }

View file

@ -133,8 +133,8 @@ func RenderSpecialLink(rawBytes []byte, urlPrefix string) []byte {
} }
func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte { func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte {
body := RenderSpecialLink(rawBytes, urlPrefix) // body := RenderSpecialLink(rawBytes, urlPrefix)
fmt.Println(string(body)) // fmt.Println(string(body))
htmlFlags := 0 htmlFlags := 0
// htmlFlags |= gfm.HTML_USE_XHTML // htmlFlags |= gfm.HTML_USE_XHTML
// htmlFlags |= gfm.HTML_USE_SMARTYPANTS // htmlFlags |= gfm.HTML_USE_SMARTYPANTS
@ -146,10 +146,10 @@ func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte {
htmlFlags |= gfm.HTML_GITHUB_BLOCKCODE htmlFlags |= gfm.HTML_GITHUB_BLOCKCODE
htmlFlags |= gfm.HTML_OMIT_CONTENTS htmlFlags |= gfm.HTML_OMIT_CONTENTS
// htmlFlags |= gfm.HTML_COMPLETE_PAGE // htmlFlags |= gfm.HTML_COMPLETE_PAGE
// renderer := &CustomRender{ renderer := &CustomRender{
// Renderer: gfm.HtmlRenderer(htmlFlags, "", ""), Renderer: gfm.HtmlRenderer(htmlFlags, "", ""),
// urlPrefix: urlPrefix, urlPrefix: urlPrefix,
// } }
// set up the parser // set up the parser
extensions := 0 extensions := 0
@ -162,7 +162,7 @@ func RenderMarkdown(rawBytes []byte, urlPrefix string) []byte {
extensions |= gfm.EXTENSION_SPACE_HEADERS extensions |= gfm.EXTENSION_SPACE_HEADERS
extensions |= gfm.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK extensions |= gfm.EXTENSION_NO_EMPTY_LINE_BEFORE_BLOCK
// body = gfm.Markdown(body, renderer, extensions) body := gfm.Markdown(rawBytes, renderer, extensions)
// fmt.Println(string(body)) // fmt.Println(string(body))
return body return body
} }