Procházet zdrojové kódy

add parent folder link in file list

slene před 11 roky
rodič
revize
67f92c9d47
2 změnil soubory, kde provedl 13 přidání a 0 odebrání
  1. 5 0
      routers/repo/single.go
  2. 8 0
      templates/repo/single.tmpl

+ 5 - 0
routers/repo/single.go

@@ -87,6 +87,11 @@ func Single(ctx *middleware.Context, params martini.Params) {
 		for i, _ := range treenames {
 		for i, _ := range treenames {
 			Paths = append(Paths, strings.Join(treenames[0:i+1], "/"))
 			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
 	// Get latest commit according username and repo name

+ 8 - 0
templates/repo/single.tmpl

@@ -57,6 +57,14 @@
                 </tr>
                 </tr>
                 </thead>
                 </thead>
                 <tbody>
                 <tbody>
+                {{if .HasParentPath}}
+                    <tr class="has-parent">
+                        <td class="icon"><a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}{{.ParentPath}}"><i class="fa fa-reply"></i></a></td>
+                        <td class="name"><a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}{{.ParentPath}}">..</a></td>
+                        <td class="text"></td>
+                        <td class="date"></td>
+                    </tr>
+                {{end}}
                 {{range .Files}}
                 {{range .Files}}
                 <tr
                 <tr
                 {{if .IsDir}}class="is-dir"{{end}}>
                 {{if .IsDir}}class="is-dir"{{end}}>