aboutsummaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorslene <vslene@gmail.com>2014-03-20 13:31:24 +0800
committerslene <vslene@gmail.com>2014-03-20 13:31:24 +0800
commit24678d73f59abd46141ef6fece7966e1f9c5c8f3 (patch)
tree703b9cf24bcd7af41be88ef4134c8d21e94bd1fc /templates
parent805732fdc76c55659a3ee4b9d1a655ba3c9a0abc (diff)
downloadgitea-24678d73f59abd46141ef6fece7966e1f9c5c8f3.tar.gz
gitea-24678d73f59abd46141ef6fece7966e1f9c5c8f3.zip
read single file
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/single.tmpl91
-rw-r--r--templates/repo/single_file.tmpl20
-rw-r--r--templates/repo/single_list.tmpl54
3 files changed, 85 insertions, 80 deletions
diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl
index e18f79c293..60247898e2 100644
--- a/templates/repo/single.tmpl
+++ b/templates/repo/single.tmpl
@@ -8,104 +8,35 @@
Need to fill in some guide.
{{else}}
<div class="source-toolbar">
- {{ $username := .Username}}
- {{ $reponame := .Reponame}}
- {{ $branchname := .Branchname}}
- {{ $treenames := .Treenames}}
- {{ $repoLink := .RepositoryLink}}
- {{ $n := len $treenames}}
- <button class="btn btn-default pull-right"><i class="fa fa-plus-square"></i>Add File</button>
+ {{ $n := len .Treenames}}
+ {{if not .IsFile}}<button class="btn btn-default pull-right"><i class="fa fa-plus-square"></i>Add File</button>{{end}}
<div class="dropdown branch-switch">
- <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chain"></i>{{$branchname}}&nbsp;&nbsp;
+ <a href="#" class="btn btn-success dropdown-toggle" data-toggle="dropdown"><i class="fa fa-chain"></i>{{.Branchname}}&nbsp;&nbsp;
<b class="caret"></b></a>
<ul class="dropdown-menu">
{{range .Branches}}
- <li><a {{if eq . $branchname}}class="current" {{end}}href="/{{$repoLink}}/tree/{{.}}">{{.}}</a></li>
+ <li><a {{if eq . $.Branchname}}class="current" {{end}}href="{{$.BranchLink}}">{{.}}</a></li>
{{end}}
</ul>
</div>
- {{$paths := .Paths}}
{{ $l := Subtract $n 1}}
<ol class="breadcrumb">
<li class="root dir">
- <a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}">{{.Repository.Name}}</a></li>
- {{range $i, $v := $treenames}}
+ <a href="{{.BranchLink}}">{{.Repository.Name}}</a></li>
+ {{range $i, $v := .Treenames}}
<li class="dir">
{{if eq $i $l}}{{$v}}
{{else}}
- <a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}/{{index $paths $i}}">{{$v}}</a>&nbsp;
+ <a href="{{$.BranchLink}}/{{index $.Paths $i}}">{{$v}}</a>&nbsp;
{{end}}
</li>
{{end}}
</ol>
</div>
-
- <div class="panel panel-default info-box">
- <div class="panel-heading info-head">
- <a href="/{{$username}}/{{$reponame}}/commit/{{.LastCommit.Oid.String}}">{{.LastCommit.Message}}</a>
- </div>
- <div class="panel-body info-content">
- <a href="/user/{{.LastCommit.Author.Name}}">{{.LastCommit.Author.Name}}</a> <span class="text-muted">{{TimeSince .LastCommit.Author.When}}</span>
- </div>
- <table class="panel-footer table file-list">
- <thead class="hidden">
- <tr>
- <th class="icon"></th>
- <th class="name">Filename</th>
- <th class="text">Message</th>
- <th class="date">Date modified</th>
- </tr>
- </thead>
- <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}}
- <tr
- {{if .IsDir}}class="is-dir"{{end}}>
- <td class="icon">
- <i class="fa {{if .IsDir}}fa-folder{{else}}fa-file-text-o{{end}}"></i>
- </td>
- <td class="name">
- <span class="wrap">
- {{if .IsDir}}
- <a href="/{{$username}}/{{$reponame}}/tree/{{$branchname}}/{{.Path}}">{{.Name}}</a>
- {{else}}
- <a href="/{{$username}}/{{$reponame}}/blob/{{$branchname}}/{{.Name}}">{{.Name}}</a>
- {{end}}
- </span>
- </td>
- <td class="text">
- <span class="wrap"><a href="/{{$username}}/{{$reponame}}/commit/{{.Commit.Oid}}">{{.Commit.Message}}</a></span>
- </td>
- <td class="date">
- <span class="wrap">{{TimeSince .Commit.Committer.When}}</span>
- </td>
- </tr>
- {{end}}
- </tbody>
- </table>
- </div>
- {{if .ReadmeExist}}
- <div class="panel panel-default file-content">
- <div class="panel-heading file-head">
- <i class="icon fa fa-book"></i> README.md
- </div>
- {{if .FileIsLarge}}
- <div class="panel-footer">
- Large file size 1000kb
- </div>
- {{else}}
- <div class="panel-body file-body markdown">
- {{.ReadmeContent|str2html}}
- </div>
- {{end}}
- </div>
+ {{if .IsFile}}
+ {{template "repo/single_file" .}}
+ {{else}}
+ {{template "repo/single_list" .}}
{{end}}
{{end}}
</div>
diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl
new file mode 100644
index 0000000000..f74e09de09
--- /dev/null
+++ b/templates/repo/single_file.tmpl
@@ -0,0 +1,20 @@
+<div class="panel panel-default file-content">
+ <div class="panel-heading file-head">
+ <i class="icon fa fa-book"></i> {{.FileName}}
+ </div>
+ {{if .FileIsLarge}}
+ <div class="panel-footer">
+ Large file size 1000kb
+ </div>
+ {{else}}
+ {{if .ReadmeExist}}
+ <div class="panel-body file-body markdown">
+ {{.FileContent|str2html}}
+ </div>
+ {{else}}
+ <div class="panel-body file-body markdown">
+ <pre><code>{{.FileContent|str2html}}</code></pre>
+ </div>
+ {{end}}
+ {{end}}
+</div> \ No newline at end of file
diff --git a/templates/repo/single_list.tmpl b/templates/repo/single_list.tmpl
new file mode 100644
index 0000000000..b0c31d1e44
--- /dev/null
+++ b/templates/repo/single_list.tmpl
@@ -0,0 +1,54 @@
+<div class="panel panel-default info-box">
+ <div class="panel-heading info-head">
+ <a href="/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Oid.String}}">{{.LastCommit.Message}}</a>
+ </div>
+ <div class="panel-body info-content">
+ <a href="/user/{{.LastCommit.Author.Name}}">{{.LastCommit.Author.Name}}</a> <span class="text-muted">{{TimeSince .LastCommit.Author.When}}</span>
+ </div>
+ <table class="panel-footer table file-list">
+ <thead class="hidden">
+ <tr>
+ <th class="icon"></th>
+ <th class="name">Filename</th>
+ <th class="text">Message</th>
+ <th class="date">Date modified</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{if .HasParentPath}}
+ <tr class="has-parent">
+ <td class="icon"><a href="{{.BranchLink}}{{.ParentPath}}"><i class="fa fa-reply"></i></a></td>
+ <td class="name"><a href="{{.BranchLink}}{{.ParentPath}}">..</a></td>
+ <td class="text"></td>
+ <td class="date"></td>
+ </tr>
+ {{end}}
+ {{range .Files}}
+ <tr
+ {{if .IsDir}}class="is-dir"{{end}}>
+ <td class="icon">
+ <i class="fa {{if .IsDir}}fa-folder{{else}}fa-file-text-o{{end}}"></i>
+ </td>
+ <td class="name">
+ <span class="wrap">
+ {{if .IsDir}}
+ <a href="{{$.BranchLink}}/{{.Path}}">{{.Name}}</a>
+ {{else}}
+ <a href="{{$.BranchLink}}/{{.Path}}">{{.Name}}</a>
+ {{end}}
+ </span>
+ </td>
+ <td class="text">
+ <span class="wrap"><a href="/{{$.Username}}/{{$.Reponame}}/commit/{{.Commit.Oid}}">{{.Commit.Message}}</a></span>
+ </td>
+ <td class="date">
+ <span class="wrap">{{TimeSince .Commit.Committer.When}}</span>
+ </td>
+ </tr>
+ {{end}}
+ </tbody>
+ </table>
+</div>
+{{if .ReadmeExist}}
+ {{template "repo/single_file" .}}
+{{end}} \ No newline at end of file