]> source.dussan.org Git - gitea.git/commitdiff
Add raw, history file button, and other mirror fixes
authorUnknwon <joe2010xtmf@163.com>
Sat, 11 Oct 2014 22:02:48 +0000 (18:02 -0400)
committerUnknwon <joe2010xtmf@163.com>
Sat, 11 Oct 2014 22:02:48 +0000 (18:02 -0400)
21 files changed:
README.md
README_ZH.md
conf/locale/locale_en-US.ini
conf/locale/locale_zh-CN.ini
gogs.go
models/repo.go
models/user.go
modules/middleware/context.go
public/ng/css/ui.css
public/ng/less/ui/form.less
routers/repo/commit.go
routers/repo/view.go
templates/.VERSION
templates/admin/monitor.tmpl
templates/repo/home.tmpl
templates/repo/single.tmpl [deleted file]
templates/repo/single_bare.tmpl [deleted file]
templates/repo/single_file.tmpl [deleted file]
templates/repo/single_list.tmpl [deleted file]
templates/repo/view_file.tmpl
templates/repo/view_list.tmpl

index 44c6264997ac35dca967ae30f712f965cd3009d2..b6dd1ea5fdc21ff217d10bfcecfbfa73935b7833 100644 (file)
--- a/README.md
+++ b/README.md
@@ -38,6 +38,7 @@ The goal of this project is to make the easiest, fastest and most painless way t
 - Create/migrate/mirror/delete/watch/rename/transfer public/private repository
 - Repository viewer/release/issue tracker
 - Repository and Organization level webhooks
+- Repository Git hooks
 - Add/remove repository collaborators
 - Gravatar and cache support
 - Mail service(register, issue)
index 9581faf78a8264133156c8132d5d026ae6ab63a4..a8cefa44f9290a5f7ed60c963a7b754e7f6a7c8e 100644 (file)
@@ -24,14 +24,15 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
 - 支持 SSH/HTTP(S) 协议
 - 支持 SMTP/LDAP/反向代理 用户认证
 - 支持反向代理子路径
-- 注册/删除/重命名 用户
-- 创建/管理/删除 组织以及团队管理功能
-- 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库
-- 仓库 浏览/发布/工单管理
-- 仓库和组织级别 Web 钩子
-- 添加/删除 仓库协作者
-- Gravatar 以及缓存支持
-- 邮件服务(注册、Issue)
+- 支持 注册/删除/重命名 用户
+- 支持 创建/管理/删除 组织以及团队管理功能
+- 支持 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库
+- 支持仓库 浏览/发布/工单管理
+- 支持仓库和组织级别 Web 钩子
+- 支持仓库 Git 钩子
+- 支持 添加/删除 仓库协作者
+- 支持 Gravatar 以及本地缓存
+- 支持邮件服务(注册、Issue)
 - 管理员面板
 - Slack Web 钩子集成
 - 支持 MySQL、PostgreSQL 以及 SQLite3 数据库
index 7452fb735ffa92328b16f011052a0634a4f4fc49..e0a5066503f6b5be3b1c9f40ab95b3645f92fe57 100644 (file)
@@ -273,6 +273,9 @@ tags = Tags
 issues = Issues
 commits = Commits
 releases = Releases
+file_raw = Raw
+file_history = History
+file_view_raw = View Raw
 
 commits.commits = Commits
 commits.search = Search commits
index aeed47561687ee2e9eefe53810eb9741cd9f626e..c704ad2051695b12896519a6bf50af047a837b47 100644 (file)
@@ -273,6 +273,9 @@ tags = 标签列表
 issues = 工单管理
 commits = 提交历史
 releases = 版本发布
+file_raw = 原始文件
+file_history = 文件历史
+file_view_raw = 查看原始文件
 
 commits.commits = 次代码提交
 commits.search = 搜索提交历史
diff --git a/gogs.go b/gogs.go
index 05fcd2cd9c356d803e4bebca84b4323d78d4be69..85a5626cf98ca5747b8fc7ef57bd581ab7d46ec5 100644 (file)
--- a/gogs.go
+++ b/gogs.go
@@ -17,7 +17,7 @@ import (
        "github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.5.5.1010 Beta"
+const APP_VER = "0.5.5.1011 Beta"
 
 func init() {
        runtime.GOMAXPROCS(runtime.NumCPU())
index c3329951985c1f3719fe572e12e9e7ade419977a..419d034c66d0776b64a3732bf0b85bac1669067b 100644 (file)
@@ -663,7 +663,7 @@ func RepoPath(userName, repoName string) string {
 func TransferOwnership(u *User, newOwner string, repo *Repository) error {
        newUser, err := GetUserByName(newOwner)
        if err != nil {
-               return err
+               return fmt.Errorf("fail to get new owner(%s): %v", newOwner, err)
        }
 
        // Check if new owner has repository with same name.
index ee8f8586d591f91e18ee0a9558b057574a1a892d..dc9b052ca8f35662a68b20df0fdaf732688f0de6 100644 (file)
@@ -488,7 +488,7 @@ func GetUserByName(name string) (*User, error) {
        return user, nil
 }
 
-// GetUserEmailsByNames returns a slice of e-mails corresponds to names.
+// GetUserEmailsByNames returns a list of e-mails corresponds to names.
 func GetUserEmailsByNames(names []string) []string {
        mails := make([]string, 0, len(names))
        for _, name := range names {
index 1d9f57389853543c71f253c7312add47ed40722c..86e98c907196047cfd464fb15c4b5d298d76d82f 100644 (file)
@@ -75,12 +75,6 @@ type Context struct {
        }
 }
 
-// Query querys form parameter.
-func (ctx *Context) Query(name string) string {
-       ctx.Req.ParseForm()
-       return ctx.Req.Form.Get(name)
-}
-
 // HasError returns true if error occurs in form validation.
 func (ctx *Context) HasApiError() bool {
        hasErr, ok := ctx.Data["HasError"]
index cc1a277fa923bfaa5ffa15136cdd809c1a39189b..5aa1490f7a7b3ab001bafdadff717a6227baeeeb 100644 (file)
@@ -457,6 +457,9 @@ dt {
   box-sizing: content-box;
   text-align: center;
 }
+.btn-comb {
+  margin-left: -1px;
+}
 .btn-disabled {
   opacity: .6;
   cursor: not-allowed;
index b3de4273c850e9d128e2ced0c5545a1196f757f3..6e33e606b851c0d91c23302f0d75935b7f339c97 100644 (file)
     box-sizing: content-box;
     text-align: center;
 }
+.btn-comb {
+    margin-left: -1px;
+}
 
 .btn-disabled {
   opacity: .6;
index 4c5bcf0cbd83b91e7a8fb40cdcd99b9b31905be4..b2c2e0f9ac057084f00ca26386aa07999acf169e 100644 (file)
@@ -276,13 +276,15 @@ func FileHistory(ctx *middleware.Context) {
                nextPage = 0
        }
 
-       ctx.Data["Commits"], err = ctx.Repo.GitRepo.CommitsByFileAndRange(
+       commits, err := ctx.Repo.GitRepo.CommitsByFileAndRange(
                branchName, fileName, page)
        if err != nil {
                ctx.Handle(500, "repo.FileHistory(CommitsByRange)", err)
                return
        }
+       commits = models.ValidateCommitsWithEmails(commits)
 
+       ctx.Data["Commits"] = commits
        ctx.Data["Username"] = userName
        ctx.Data["Reponame"] = repoName
        ctx.Data["FileName"] = fileName
index ba76a6adaeafbcdd5abe8fbc292225b6f35b6175..26fa0b4c764517e418d1232d5f547e910d261342 100644 (file)
@@ -166,7 +166,7 @@ func Home(ctx *middleware.Context) {
                }
 
                if readmeFile != nil {
-                       ctx.Data["ReadmeInHome"] = true
+                       ctx.Data["ReadmeInList"] = true
                        ctx.Data["ReadmeExist"] = true
                        if dataRc, err := readmeFile.Data(); err != nil {
                                ctx.Handle(404, "repo.SinglereadmeFile.LookupBlob", err)
index d62a81b607736e68bc461fef29ac187382cd8c32..3f42d63cf32c2535b0cbf1f3a0e6b736e43f37b3 100644 (file)
@@ -1 +1 @@
-0.5.5.1010 Beta
\ No newline at end of file
+0.5.5.1011 Beta
\ No newline at end of file
index 5da8f48eb524e8a20dcf918df3fe5d962b2fdf1e..a7942e09c35bbf162238fecfaeff18d2ae542e93 100644 (file)
@@ -58,7 +58,7 @@
                                             <td>{{.Pid}}</td>
                                             <td>{{.Description}}</td>
                                             <td>{{.Start}}</td>
-                                            <td>{{TimeSince .Start .i18n.Lang}}</td>
+                                            <td>{{TimeSince .Start $.Lang}}</td>
                                         </tr>
                                         {{end}}
                                     </tbody>
index e7d4c45dc750d8bde57feea6204cf9dc12e93638..49bf1fd14af6b006b59a2017fface6378cbd826b 100644 (file)
                         {{end}}
                     {{end}}
                 </li>
-                <!-- <li id="repo-commits-jump" class="repo-jump right">
+                <li id="repo-commits-jump" class="repo-jump right">
                     <a href="#">
                         <button class="btn btn-small btn-gray btn-right-radius"><i class="octicon octicon-git-commit"></i></button>
                     </a>
                 </li>
                 <li id="repo-find-jump" class="repo-jump right">
                     <a href="#">
-                        <button class="btn btn-small btn-gray btn-left-radius"><i class="octicon octicon-list-unordered"></i></button>
+                        <button class="btn btn-small btn btn-small btn-gray btn-left-radius"><i class="octicon octicon-list-unordered"></i></button>
                     </a>
-                </li> -->
+                </li>
             </ul>
             {{if .IsFile}}
                 {{template "repo/view_file" .}}
diff --git a/templates/repo/single.tmpl b/templates/repo/single.tmpl
deleted file mode 100644 (file)
index d640fb0..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-{{template "base/head" .}}
-{{template "base/navbar" .}}
-{{template "repo/nav" .}}
-{{template "repo/toolbar" .}}
-<div id="body" class="container">
-    <div id="source">
-        <div class="source-toolbar">
-            {{ $n := len .Treenames}}
-            {{if not .IsFile}}<button class="btn btn-default pull-right hidden"><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>{{if .IsBranch}}{{.BranchName}}{{else}}{{ShortSha .CommitId}}{{end}}&nbsp;&nbsp;
-                    <b class="caret"></b></a>
-                <ul class="dropdown-menu">
-                    {{range .Branches}}
-                    <li><a {{if eq . $.BranchName}}class="current" {{end}}href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/src/{{.}}">{{.}}</a></li>
-                    {{end}}
-                </ul>
-            </div>
-            {{ $l := Subtract $n 1}}
-            <ol class="breadcrumb">
-                <li class="root dir">
-                    <a href="{{.BranchLink}}">{{.Repository.Name}}</a></li>
-                {{range $i, $v := .Treenames}}
-                <li class="dir">
-                    {{if eq $i $l}}{{$v}}
-                    {{else}}
-                    <a href="{{$.BranchLink}}/{{index $.Paths $i}}">{{$v}}</a>&nbsp;
-                    {{end}}
-                </li>
-                {{end}}
-            </ol>
-        </div>
-        {{if .IsFile}}
-            {{template "repo/single_file" .}}
-        {{else}}
-            {{template "repo/single_list" .}}
-        {{end}}
-    </div>
-</div>
-{{template "base/footer" .}}
diff --git a/templates/repo/single_bare.tmpl b/templates/repo/single_bare.tmpl
deleted file mode 100644 (file)
index f2b1956..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-{{template "base/head" .}}
-{{template "base/navbar" .}}
-{{template "repo/nav" .}}
-{{template "repo/toolbar" .}}
-<div id="body" class="container">
-    <div id="source">
-        <div class="panel panel-default guide-box clone-group-btn">
-            <div class="panel-heading guide-head">
-                <h4>Quick Guide</h4>
-            </div>
-            <div class="panel-body guide-content text-center">
-                <h3>Clone this repository</h3>
-                <div class="input-group col-md-8 col-md-offset-2 guide-buttons">
-                    <span class="input-group-btn">
-                        <button class="btn btn-default" data-link="{{.CloneLink.SSH}}" type="button">SSH</button>
-                        <button class="btn btn-default" data-link="{{.CloneLink.HTTPS}}" type="button">HTTPS</button>
-                    </span>
-                    <input type="text" class="form-control clone-group-url" id="guide-clone-url" value="" readonly/>
-                    <span class="input-group-btn" style="position: relative">
-                        <button class="btn btn-default" type="button" data-toggle="tooltip" title="copy to clipboard" data-placement="top" data-init="copy" data-copy-val="val" data-copy-from="#guide-clone-url"><i class="fa fa-copy"></i></button>
-                    </span>
-                </div>
-                <p>We recommend every repository include a <strong>README</strong>, <strong>LICENSE</strong>, and <strong>.gitignore</strong>.</p>
-                <hr/>
-                <h3>Create a new repository on the command line</h3>
-                    <pre class="text-left"><code>touch README.md
-git init
-git add README.md
-git commit -m "first commit"
-git remote add origin <span class="clone-url"></span>
-git push -u origin master</code></pre>
-                <hr/>
-                <h3>Push an existing repository from the command line</h3>
-                <pre class="text-left"><code>git remote add origin <span class="clone-url"></span>
-git push -u origin master</code></pre>
-            </div>
-        </div>
-    </div>
-</div>
-{{template "base/footer" .}}
diff --git a/templates/repo/single_file.tmpl b/templates/repo/single_file.tmpl
deleted file mode 100644 (file)
index 0ce04e1..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<div class="panel panel-default file-content">
-    <div class="panel-heading file-head">
-        {{if .ReadmeExist}}
-            <i class="icon fa fa-book"></i>
-            {{if .ReadmeInSingle}}
-            {{.FileName}}
-            {{else}}
-            {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span>
-            {{end}}
-        {{else}}
-            <i class="icon fa fa-file-text-o"></i>
-            {{.FileName}} <span class="file-size">{{FileSize .FileSize}}</span>
-        {{end}}
-        {{if not .ReadmeInSingle}}
-        <div class="btn-group pull-right">
-            <a class="btn btn-default hidden" href="#">Edit</a>
-            <a class="btn btn-default" href="{{.FileLink}}" rel="nofollow">Raw</a>
-            <a class="btn btn-default hidden" href="#">Blame</a>
-            <a class="btn btn-default" href="{{.RepoLink}}/commits/{{.BranchName}}/{{.TreeName}}">History</a>
-            <a class="btn btn-danger hidden" href="#">Delete</a>
-        </div>
-        {{end}}
-    </div>
-
-    {{if not .FileIsText}}
-    <div class="panel-body file-body file-code code-view">
-        {{if .IsImageFile}}
-            <img src="{{.FileLink}}">
-        {{else}}
-            <a href="{{.FileLink}}" rel="nofollow" class="btn btn-default">View Raw</a>
-        {{end}}
-    </div>
-    {{else}}
-    {{if .ReadmeExist}}
-    <div class="panel-body file-body markdown">
-        {{.FileContent|str2html}}
-    </div>
-    {{else}}
-    <div class="panel-body file-body file-code code-view">
-        <table>
-            <tbody>
-                <tr>
-                    <td class="lines-num"></td>
-                    <td class="lines-code markdown"><pre class="prettyprint linenums{{if .FileExt}} lang-{{.FileExt}}{{end}}">{{.FileContent}}</pre></td>
-                </tr>
-            </tbody>
-        </table>
-    </div>
-    {{end}}
-    {{end}}
-</div>
diff --git a/templates/repo/single_list.tmpl b/templates/repo/single_list.tmpl
deleted file mode 100644 (file)
index 03511a8..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<div class="panel panel-default info-box">
-    <div class="panel-heading info-head">
-        <a href="{{AppSubUrl}}/{{.Username}}/{{.Reponame}}/commit/{{.LastCommit.Id}}" rel="nofollow">{{.LastCommit.Summary}}</a>
-    </div>
-    <div class="panel-body info-content">
-        <a href="{{AppSubUrl}}/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 $item := .Files}}
-                {{$entry := index $item 0}}
-                {{$commit := index $item 1}}
-                <tr {{if $entry.IsDir}}class="is-dir"{{end}}>
-                    <td class="icon">
-                        <i class="fa {{if $entry.IsDir}}fa-folder{{else}}fa-file-text-o{{end}}"></i>
-                    </td>
-                    <td class="name">
-                        <span class="wrap">
-                            <a href="{{$.BranchLink}}/{{$.TreePath}}{{$entry.Name}}">{{$entry.Name}}</a>
-                        </span>
-                    </td>
-                    <td class="text">
-                        <span class="wrap"><a rel="nofollow" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}">{{$commit.Summary}}</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}}
index 228d10cd99d0756e21bdbd196920abce08c39d66..4e2d4fc64c98af257cb00c7cdaa5e5aa6f65c472 100644 (file)
@@ -2,15 +2,23 @@
     <p class="panel-header">
         {{if .ReadmeExist}}
             <i class="icon fa fa-book fa-lg"></i>
-               {{if .ReadmeInHome}}
+               {{if .ReadmeInList}}
                <strong class="file-name">{{.FileName}}</strong>
                {{else}}
                <strong>{{.FileName}}</strong><span class="file-size">{{FileSize .FileSize}}</span>
                {{end}}
            {{else}}
-        <i class="icon fa fa-file-text-o"></i>
-        <strong class="file-name">{{.FileName}}</strong><span class="file-size">{{FileSize .FileSize}}</span>
+            <i class="icon fa fa-file-text-o"></i>
+            <strong class="file-name">{{.FileName}}</strong><span class="file-size">{{FileSize .FileSize}}</span>
            {{end}}
+        {{if not .ReadmeInList}}
+            <a class="right" href="{{.RepoLink}}/commits/{{.BranchName}}/{{.TreeName}}">
+                <button class="btn btn-medium btn-gray btn-right-radius btn-comb">{{.i18n.Tr "repo.file_history"}}</button>
+            </a>
+            <a class="right" href="{{.FileLink}}">
+                <button class="btn btn-medium btn-gray btn-left-radius btn-comb">{{.i18n.Tr "repo.file_raw"}}</button>
+            </a>
+        {{end}}
     </p>
     <div class="{{if .ReadmeExist}}panel-content markdown{{end}} code-view" id="repo-code-view">
        {{if .ReadmeExist}}
@@ -20,7 +28,7 @@
             {{if .IsImageFile}}
             <img src="{{.FileLink}}">
             {{else}}
-            <a href="{{.FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">View Raw</a>
+            <a href="{{.FileLink}}" rel="nofollow" class="btn btn-gray btn-radius">{{.i18n.Tr "repo.file_view_raw"}}</a>
             {{end}}
         </div>
        {{else if .FileSize}}
index e6c43d9e40dd67d61ebaeb42f8fec76825002135..032b9e0f1bb81a5bea77df24e956d910e5e78b88 100644 (file)
@@ -10,7 +10,7 @@
                 <strong>{{ShortSha .LastCommit.Id.String}}</strong></a>
                 <span class="text-truncate">{{.LastCommit.Summary}}</span>
             </span>
-            <span class="age right">{{TimeSince .LastCommit.Author.When .i18n.Lang}}</span>
+            <span class="age right">{{TimeSince .LastCommit.Author.When $.Lang}}</span>
         </th>
     </tr>
     </thead>
@@ -45,7 +45,7 @@
                 <td class="msg">
                     <a class="text-truncate" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{$commit.Id}}" rel="nofollow">{{$commit.Summary}}</a>
                 </td>
-                <td class="age">{{TimeSince $commit.Committer.When $.i18n.Lang}}</td>
+                <td class="age">{{TimeSince $commit.Committer.When $.Lang}}</td>
             </tr>
         {{end}}
     </tbody>