From 67f92c9d47f6e89a9c332f9e938815eac86d0295 Mon Sep 17 00:00:00 2001 From: slene Date: Thu, 20 Mar 2014 00:08:20 +0800 Subject: [PATCH] add parent folder link in file list --- routers/repo/single.go | 5 +++++ templates/repo/single.tmpl | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/routers/repo/single.go b/routers/repo/single.go index 171b0952..1c4de34a 100644 --- a/routers/repo/single.go +++ b/routers/repo/single.go @@ -87,6 +87,11 @@ func Single(ctx *middleware.Context, params martini.Params) { for i, _ := range treenames { Paths = append(Paths, strings.Join(treenames[0:i+1], "/")) } + + ctx.Data["HasParentPath"] = true + if len(Paths)-2 >= 0 { + ctx.Data["ParentPath"] = "/" + Paths[len(Paths)-2] + } } // Get latest commit according username and repo name diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl index f1674446..e18f79c2 100644 --- a/templates/repo/single.tmpl +++ b/templates/repo/single.tmpl @@ -57,6 +57,14 @@ + {{if .HasParentPath}} + + + .. + + + + {{end}} {{range .Files}}