diff options
Diffstat (limited to 'pkg/handler/git')
| -rw-r--r-- | pkg/handler/git/handler.go | 25 | 
1 files changed, 22 insertions, 3 deletions
| diff --git a/pkg/handler/git/handler.go b/pkg/handler/git/handler.go index 899f61e..25505ba 100644 --- a/pkg/handler/git/handler.go +++ b/pkg/handler/git/handler.go @@ -33,6 +33,7 @@ type (  		GetHead(name string) (*plumbing.Reference, error)  		GetTree(name, ref, path string) (*object.Tree, error)  		GetFileContent(name, ref, path string) (string, error) +		GetAbout(name string) (string, error)  		ListTags(name string) ([]*plumbing.Reference, error)  		ListBranches(name string) ([]*plumbing.Reference, error)  	} @@ -126,10 +127,28 @@ func (g *GitHandler) About(w http.ResponseWriter, r *http.Request) error {  	if err != nil {  		return err  	} + +	file, err := g.gitService.GetAbout(name) +	if err != nil { +		return err +	} + +	extensions := parser.CommonExtensions | parser.AutoHeadingIDs | parser.NoEmptyLineBeforeBlock +	p := parser.NewWithExtensions(extensions) +	doc := p.Parse([]byte(file)) + +	htmlFlag := markdownhtml.CommonFlags | markdownhtml.HrefTargetBlank +	opts := markdownhtml.RendererOptions{Flags: htmlFlag} +	renderer := markdownhtml.NewRenderer(opts) + +	bs := markdown.Render(doc, renderer) +  	gitList := &templates.GitItemPage{ -		Name:        name, -		Ref:         ref.Name().Short(), -		GitItemBase: &templates.GitItemAboutPage{}, +		Name: name, +		Ref:  ref.Name().Short(), +		GitItemBase: &templates.GitItemAboutPage{ +			About: bs, +		},  	}  	templates.WritePageTemplate(w, gitList)  	return nil | 
