mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-11-22 13:45:19 +00:00
Merge branch 'dev' of github.com:gogits/gogs into dev
This commit is contained in:
commit
bbadbbdf68
2
gogs.go
2
gogs.go
|
@ -19,7 +19,7 @@ import (
|
|||
// Test that go1.2 tag above is included in builds. main.go refers to this definition.
|
||||
const go12tag = true
|
||||
|
||||
const APP_VER = "0.2.0.0401 Alpha"
|
||||
const APP_VER = "0.2.0.0402 Alpha"
|
||||
|
||||
func init() {
|
||||
base.AppVer = APP_VER
|
||||
|
|
|
@ -56,6 +56,25 @@ func GetBranches(userName, repoName string) ([]string, error) {
|
|||
return brs, nil
|
||||
}
|
||||
|
||||
// GetTags returns all tags of given repository.
|
||||
func GetTags(userName, repoName string) ([]string, error) {
|
||||
repo, err := git.OpenRepository(RepoPath(userName, repoName))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
refs, err := repo.AllTags()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
tags := make([]string, len(refs))
|
||||
for i, ref := range refs {
|
||||
tags[i] = ref.Name
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func IsBranchExist(userName, repoName, branchName string) bool {
|
||||
repo, err := git.OpenRepository(RepoPath(userName, repoName))
|
||||
if err != nil {
|
||||
|
|
|
@ -74,6 +74,7 @@ type Repository struct {
|
|||
NumStars int
|
||||
NumForks int
|
||||
NumIssues int
|
||||
NumReleases int `xorm:"NOT NULL"`
|
||||
NumClosedIssues int
|
||||
NumOpenIssues int `xorm:"-"`
|
||||
IsPrivate bool
|
||||
|
@ -513,6 +514,7 @@ func NotifyWatchers(act *Action) error {
|
|||
continue
|
||||
}
|
||||
|
||||
act.Id = 0
|
||||
act.UserId = watches[i].UserId
|
||||
if _, err = orm.InsertOne(act); err != nil {
|
||||
return errors.New("repo.NotifyWatchers(create action): " + err.Error())
|
||||
|
|
|
@ -92,8 +92,8 @@ func SendActiveMail(r *middleware.Render, user *models.User) {
|
|||
}
|
||||
|
||||
// SendNotifyMail sends mail notification of all watchers.
|
||||
func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content string) error {
|
||||
watches, err := models.GetWatches(repoId)
|
||||
func SendNotifyMail(user, owner *models.User, repo *models.Repository, issue *models.Issue) error {
|
||||
watches, err := models.GetWatches(repo.Id)
|
||||
if err != nil {
|
||||
return errors.New("mail.NotifyWatchers(get watches): " + err.Error())
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content s
|
|||
tos := make([]string, 0, len(watches))
|
||||
for i := range watches {
|
||||
uid := watches[i].UserId
|
||||
if userId == uid {
|
||||
if user.Id == uid {
|
||||
continue
|
||||
}
|
||||
u, err := models.GetUserById(uid)
|
||||
|
@ -115,7 +115,10 @@ func SendNotifyMail(userId, repoId int64, userName, repoName, subject, content s
|
|||
return nil
|
||||
}
|
||||
|
||||
msg := NewMailMessageFrom(tos, userName, subject, content)
|
||||
subject := fmt.Sprintf("[%s] %s", repo.Name, issue.Name)
|
||||
content := fmt.Sprintf("%s<br>-<br> <a href=\"%s%s/%s/issues/%d\">View it on Gogs</a>.",
|
||||
issue.Content, base.AppUrl, owner.Name, repo.Name, issue.Index)
|
||||
msg := NewMailMessageFrom(tos, user.Name, subject, content)
|
||||
msg.Info = fmt.Sprintf("Subject: %s, send notify emails", subject)
|
||||
SendAsync(&msg)
|
||||
return nil
|
||||
|
|
|
@ -79,6 +79,7 @@ func RepoAssignment(redirect bool, args ...bool) martini.Handler {
|
|||
ctx.Handle(404, "RepoAssignment", err)
|
||||
return
|
||||
}
|
||||
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
|
||||
ctx.Repo.Repository = repo
|
||||
|
||||
ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
|
||||
|
|
|
@ -1235,9 +1235,9 @@ html, body {
|
|||
/* admin dashboard/configuration */
|
||||
|
||||
.admin-dl-horizontal > dt {
|
||||
width: 320px;
|
||||
width: 220px;
|
||||
}
|
||||
|
||||
.admin-dl-horizontal > dd {
|
||||
margin-left: 340px;
|
||||
margin-left: 240px;
|
||||
}
|
||||
|
|
BIN
public/js/ZeroClipboard.swf
Normal file
BIN
public/js/ZeroClipboard.swf
Normal file
Binary file not shown.
|
@ -159,6 +159,7 @@ var Gogits = {
|
|||
$tabs.tab("show");
|
||||
$tabs.find("li:eq(0) a").tab("show");
|
||||
};
|
||||
|
||||
// fix dropdown inside click
|
||||
Gogits.initDropDown = function () {
|
||||
$('.dropdown-menu.no-propagation').on('click', function (e) {
|
||||
|
@ -166,6 +167,7 @@ var Gogits = {
|
|||
});
|
||||
};
|
||||
|
||||
|
||||
// render markdown
|
||||
Gogits.renderMarkdown = function () {
|
||||
var $md = $('.markdown');
|
||||
|
@ -192,6 +194,7 @@ var Gogits = {
|
|||
});
|
||||
};
|
||||
|
||||
// render code view
|
||||
Gogits.renderCodeView = function () {
|
||||
function selectRange($list, $select, $from) {
|
||||
$list.removeClass('active');
|
||||
|
@ -255,6 +258,43 @@ var Gogits = {
|
|||
}).trigger('hashchange');
|
||||
};
|
||||
|
||||
// copy utils
|
||||
Gogits.bindCopy = function (selector) {
|
||||
if ($(selector).hasClass('js-copy-bind')) {
|
||||
return;
|
||||
}
|
||||
$(selector).zclip({
|
||||
path: "/js/ZeroClipboard.swf",
|
||||
copy: function () {
|
||||
var t = $(this).data("copy-val");
|
||||
var to = $($(this).data("copy-from"));
|
||||
var str = "";
|
||||
if (t == "txt") {
|
||||
str = to.text();
|
||||
}
|
||||
if (t == 'val') {
|
||||
str = to.val();
|
||||
}
|
||||
if (t == 'html') {
|
||||
str = to.html();
|
||||
}
|
||||
return str;
|
||||
},
|
||||
afterCopy: function () {
|
||||
var $this = $(this);
|
||||
$this.tooltip('hide')
|
||||
.attr('data-original-title', 'Copied OK');
|
||||
setTimeout(function () {
|
||||
$this.tooltip("show");
|
||||
}, 200);
|
||||
setTimeout(function () {
|
||||
$this.tooltip('hide')
|
||||
.attr('data-original-title', 'Copy to Clipboard');
|
||||
}, 3000);
|
||||
}
|
||||
}).addClass("js-copy-bind");
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
|
||||
// ajax utils
|
||||
|
@ -343,7 +383,10 @@ function initRepository() {
|
|||
$clone.find('span.clone-url').text($this.data('link'));
|
||||
}
|
||||
}).eq(0).trigger("click");
|
||||
// todo copy to clipboard
|
||||
$("#repo-clone").on("shown.bs.dropdown",function () {
|
||||
Gogits.bindCopy("[data-init=copy]");
|
||||
});
|
||||
Gogits.bindCopy("[data-init=copy]:visible");
|
||||
}
|
||||
})();
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -31,7 +31,8 @@ func Issues(ctx *middleware.Context) {
|
|||
ctx.Data["IssueCreatedCount"] = 0
|
||||
|
||||
var posterId int64 = 0
|
||||
if ctx.Query("type") == "created_by" {
|
||||
isCreatedBy := ctx.Query("type") == "created_by"
|
||||
if isCreatedBy {
|
||||
if !ctx.IsSigned {
|
||||
ctx.SetCookie("redirect_to", "/"+url.QueryEscape(ctx.Req.RequestURI))
|
||||
ctx.Redirect("/user/login/", 302)
|
||||
|
@ -53,6 +54,7 @@ func Issues(ctx *middleware.Context) {
|
|||
}
|
||||
var createdByCount int
|
||||
|
||||
showIssues := make([]models.Issue, 0, len(issues))
|
||||
// Get posters.
|
||||
for i := range issues {
|
||||
u, err := models.GetUserById(issues[i].PosterId)
|
||||
|
@ -60,15 +62,19 @@ func Issues(ctx *middleware.Context) {
|
|||
ctx.Handle(200, "issue.Issues(get poster): %v", err)
|
||||
return
|
||||
}
|
||||
issues[i].Poster = u
|
||||
if isCreatedBy && u.Id != posterId {
|
||||
continue
|
||||
}
|
||||
if u.Id == posterId {
|
||||
createdByCount++
|
||||
}
|
||||
issues[i].Poster = u
|
||||
showIssues = append(showIssues, issues[i])
|
||||
}
|
||||
|
||||
ctx.Data["Issues"] = issues
|
||||
ctx.Data["Issues"] = showIssues
|
||||
ctx.Data["IssueCount"] = ctx.Repo.Repository.NumIssues
|
||||
ctx.Data["OpenCount"] = ctx.Repo.Repository.NumIssues - ctx.Repo.Repository.NumClosedIssues
|
||||
ctx.Data["OpenCount"] = ctx.Repo.Repository.NumOpenIssues
|
||||
ctx.Data["ClosedCount"] = ctx.Repo.Repository.NumClosedIssues
|
||||
ctx.Data["IssueCreatedCount"] = createdByCount
|
||||
ctx.Data["IsShowClosed"] = ctx.Query("state") == "closed"
|
||||
|
@ -107,7 +113,7 @@ func CreateIssue(ctx *middleware.Context, params martini.Params, form auth.Creat
|
|||
|
||||
// Mail watchers.
|
||||
if base.Service.NotifyMail {
|
||||
if err = mailer.SendNotifyMail(ctx.User.Id, ctx.Repo.Repository.Id, ctx.User.Name, ctx.Repo.Repository.Name, issue.Name, issue.Content); err != nil {
|
||||
if err = mailer.SendNotifyMail(ctx.User, ctx.Repo.Owner, ctx.Repo.Repository, issue); err != nil {
|
||||
ctx.Handle(200, "issue.CreateIssue", err)
|
||||
return
|
||||
}
|
||||
|
|
22
routers/repo/release.go
Normal file
22
routers/repo/release.go
Normal file
|
@ -0,0 +1,22 @@
|
|||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package repo
|
||||
|
||||
import (
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/middleware"
|
||||
)
|
||||
|
||||
func Releases(ctx *middleware.Context) {
|
||||
ctx.Data["Title"] = "Releases"
|
||||
ctx.Data["IsRepoToolbarReleases"] = true
|
||||
tags, err := models.GetTags(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
|
||||
if err != nil {
|
||||
ctx.Handle(404, "repo.Releases(GetTags)", err)
|
||||
return
|
||||
}
|
||||
ctx.Data["Releases"] = tags
|
||||
ctx.HTML(200, "release/list")
|
||||
}
|
10
templates/release/list.tmpl
Normal file
10
templates/release/list.tmpl
Normal file
|
@ -0,0 +1,10 @@
|
|||
{{template "base/head" .}}
|
||||
{{template "base/navbar" .}}
|
||||
{{template "repo/nav" .}}
|
||||
{{template "repo/toolbar" .}}
|
||||
<div id="body" class="container">
|
||||
{{range .Releases}}
|
||||
{{.}}
|
||||
{{end}}
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
|
@ -18,9 +18,9 @@
|
|||
<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" value="" readonly/>
|
||||
<input type="text" class="form-control clone-group-url" value="" readonly id="repo-clone-ipt"/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"><i class="fa fa-copy" data-toggle="tooltip" title="copy to clipboard" data-placement="top"></i></button>
|
||||
<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="#repo-clone-ipt"><i class="fa fa-copy"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
<p class="help-block text-center">Need help cloning? Visit <a href="#">Help</a>!</p>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
</span>
|
||||
<input type="text" class="form-control clone-group-url" id="guide-clone-url" value="" readonly/>
|
||||
<span class="input-group-btn">
|
||||
<button class="btn btn-default" type="button"><i class="fa fa-copy" data-toggle="tooltip" title="copy to clipboard" data-placement="top"></i></button>
|
||||
<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>
|
||||
|
|
|
@ -8,18 +8,15 @@
|
|||
<li class="{{if .IsRepoToolbarCommits}}active{{end}}"><a href="{{.RepoLink}}/commits/{{if .BranchName}}{{.BranchName}}{{else}}master{{end}}">Commits</a></li>
|
||||
<!-- <li class="{{if .IsRepoToolbarBranches}}active{{end}}"><a href="{{.RepoLink}}/branches">Branches</a></li> -->
|
||||
<!-- <li class="{{if .IsRepoToolbarPulls}}active{{end}}"><a href="{{.RepoLink}}/pulls">Pull Requests</a></li> -->
|
||||
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="{{.RepoLink}}/issues">Issues <!--<span class="badge">42</span>--></a></li>
|
||||
<li class="{{if .IsRepoToolbarIssues}}active{{end}}"><a href="{{.RepoLink}}/issues">{{if .Repository.NumOpenIssues}}<span class="badge">{{.Repository.NumOpenIssues}}</span> {{end}}Issues <!--<span class="badge">42</span>--></a></li>
|
||||
{{if .IsRepoToolbarIssues}}
|
||||
<li class="tmp">{{if .IsRepoToolbarIssuesList}}<a href="{{.RepoLink}}/issues/new">
|
||||
<button class="btn btn-primary btn-sm">New Issue</button>
|
||||
</a>{{else}}<a href="{{.RepoLink}}/issues">
|
||||
<button class="btn btn-primary btn-sm">Issues List</button>
|
||||
</a>{{end}}</li>
|
||||
<li class="tmp">{{if .IsRepoToolbarIssuesList}}<a href="{{.RepoLink}}/issues/new"><button class="btn btn-primary btn-sm">New Issue</button>
|
||||
</a>{{else}}<a href="{{.RepoLink}}/issues"><button class="btn btn-primary btn-sm">Issues List</button></a>{{end}}</li>
|
||||
{{end}}
|
||||
<li class="{{if .IsRepoToolbarReleases}}active{{end}}"><a href="{{.RepoLink}}/releases">{{if .Repository.NumReleases}}<span class="badge">{{.Repository.NumReleases}}</span> {{end}}Releases</a></li>
|
||||
<!-- <li class="dropdown">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">More <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="{{.RepoLink}}/release">Release</a></li>
|
||||
<li><a href="{{.RepoLink}}/wiki">Wiki</a></li>
|
||||
</ul>
|
||||
</li> -->{{end}}
|
||||
|
|
25
web.go
25
web.go
|
@ -11,8 +11,8 @@ import (
|
|||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/go-martini/martini"
|
||||
"github.com/martini-contrib/oauth2"
|
||||
"github.com/martini-contrib/sessions"
|
||||
// "github.com/martini-contrib/oauth2"
|
||||
// "github.com/martini-contrib/sessions"
|
||||
|
||||
"github.com/gogits/binding"
|
||||
|
||||
|
@ -60,15 +60,15 @@ func runWeb(*cli.Context) {
|
|||
// Middlewares.
|
||||
m.Use(middleware.Renderer(middleware.RenderOptions{Funcs: []template.FuncMap{base.TemplateFuncs}}))
|
||||
|
||||
scope := "https://api.github.com/user"
|
||||
oauth2.PathCallback = "/oauth2callback"
|
||||
m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123"))))
|
||||
m.Use(oauth2.Github(&oauth2.Options{
|
||||
ClientId: "09383403ff2dc16daaa1",
|
||||
ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5",
|
||||
RedirectURL: base.AppUrl + oauth2.PathCallback,
|
||||
Scopes: []string{scope},
|
||||
}))
|
||||
// scope := "https://api.github.com/user"
|
||||
// oauth2.PathCallback = "/oauth2callback"
|
||||
// m.Use(sessions.Sessions("my_session", sessions.NewCookieStore([]byte("secret123"))))
|
||||
// m.Use(oauth2.Github(&oauth2.Options{
|
||||
// ClientId: "09383403ff2dc16daaa1",
|
||||
// ClientSecret: "5f6e7101d30b77952aab22b75eadae17551ea6b5",
|
||||
// RedirectURL: base.AppUrl + oauth2.PathCallback,
|
||||
// Scopes: []string{scope},
|
||||
// }))
|
||||
|
||||
m.Use(middleware.InitContext())
|
||||
|
||||
|
@ -92,7 +92,7 @@ func runWeb(*cli.Context) {
|
|||
m.Get("/avatar/:hash", avt.ServeHTTP)
|
||||
|
||||
m.Group("/user", func(r martini.Router) {
|
||||
r.Any("/login/github", user.SocialSignIn)
|
||||
// r.Any("/login/github", user.SocialSignIn)
|
||||
r.Any("/login", binding.BindIgnErr(auth.LogInForm{}), user.SignIn)
|
||||
r.Any("/sign_up", binding.BindIgnErr(auth.RegisterForm{}), user.SignUp)
|
||||
}, reqSignOut)
|
||||
|
@ -147,6 +147,7 @@ func runWeb(*cli.Context) {
|
|||
m.Group("/:username/:reponame", func(r martini.Router) {
|
||||
r.Get("/issues", repo.Issues)
|
||||
r.Get("/issues/:index", repo.ViewIssue)
|
||||
r.Get("/releases", repo.Releases)
|
||||
r.Get("/pulls", repo.Pulls)
|
||||
r.Get("/branches", repo.Branches)
|
||||
}, ignSignIn, middleware.RepoAssignment(true))
|
||||
|
|
Loading…
Reference in a new issue