Add auto-detect home directory

This commit is contained in:
Unknown 2014-03-28 17:34:07 -04:00
parent 9047cadcd3
commit a55941ff83
5 changed files with 25 additions and 18 deletions

View File

@ -7,7 +7,7 @@ RUN_USER = git
RUN_MODE = dev RUN_MODE = dev
[repository] [repository]
ROOT = /Users/%(RUN_USER)s/git/gogs-repositories ROOT =
LANG_IGNS = Google Go|C|C++|Python|Ruby|C Sharp LANG_IGNS = Google Go|C|C++|Python|Ruby|C Sharp
LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|BSD (3-Clause) License LICENSES = Apache v2 License|GPL v2|MIT License|Affero GPL|Artistic License 2.0|BSD (3-Clause) License

View File

@ -291,9 +291,14 @@ func NewConfigContext() {
PictureService = Cfg.MustValue("picture", "SERVICE") PictureService = Cfg.MustValue("picture", "SERVICE")
// Determine and create root git reposiroty path. // Determine and create root git reposiroty path.
RepoRootPath = Cfg.MustValue("repository", "ROOT") homeDir, err := com.HomeDir()
if err != nil {
fmt.Printf("Fail to get home directory): %v\n", err)
os.Exit(2)
}
RepoRootPath = Cfg.MustValue("repository", "ROOT", filepath.Join(homeDir, "git/gogs-repositories"))
if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil { if err = os.MkdirAll(RepoRootPath, os.ModePerm); err != nil {
fmt.Printf("models.init(fail to create RepoRootPath(%s)): %v\n", RepoRootPath, err) fmt.Printf("Fail to create RepoRootPath(%s): %v\n", RepoRootPath, err)
os.Exit(2) os.Exit(2)
} }
} }

View File

@ -231,6 +231,12 @@ func Comment(ctx *middleware.Context, params martini.Params) {
return return
} }
content := ctx.Query("content")
if len(content) == 0 {
ctx.Redirect(fmt.Sprintf("/%s/%s/issues/%d", ctx.User.Name, ctx.Repo.Repository.Name, index))
return
}
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index)) issue, err := models.GetIssueByIndex(ctx.Repo.Repository.Id, int64(index))
if err != nil { if err != nil {
if err == models.ErrIssueNotExist { if err == models.ErrIssueNotExist {
@ -241,12 +247,6 @@ func Comment(ctx *middleware.Context, params martini.Params) {
return return
} }
content := ctx.Query("content")
if len(content) == 0 {
ctx.Handle(404, "issue.Comment", err)
return
}
switch params["action"] { switch params["action"] {
case "new": case "new":
if err = models.CreateComment(ctx.User.Id, issue.Id, 0, 0, content); err != nil { if err = models.CreateComment(ctx.User.Id, issue.Id, 0, 0, content); err != nil {

View File

@ -133,7 +133,7 @@
<hr/> <hr/>
<div class="form-group text-center"> <div class="form-group text-center">
<!-- <button class="btn btn-primary btn-lg">Test Configuration</button> --> <button class="btn btn-primary btn-lg">Test Configuration</button>
<button class="btn btn-danger btn-lg">Install Gogs</button> <button class="btn btn-danger btn-lg">Install Gogs</button>
<button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#advance-options-modal"> <button class="btn btn-default btn-sm" type="button" data-toggle="modal" data-target="#advance-options-modal">
Advanced Options Advanced Options

View File

@ -11,7 +11,7 @@
<h1 class="title pull-left">{{.Issue.Name}}</h1> <h1 class="title pull-left">{{.Issue.Name}}</h1>
<input id="issue-edit-title" class="form-control input-lg pull-left hidden" type="text" value="{issue.title}" data-ajax-rel="issue-save"/> <input id="issue-edit-title" class="form-control input-lg pull-left hidden" type="text" value="{issue.title}" data-ajax-rel="issue-save"/>
<p class="info pull-left"> <p class="info pull-left">
<a class="btn btn-default pull-right issue-edit" href="#" id="issue-edit-btn">Edit</a> <!-- <a class="btn btn-default pull-right issue-edit" href="#" id="issue-edit-btn">Edit</a> -->
<a class="btn btn-danger pull-right issue-edit-cancel hidden" href="#">Cancel</a> <a class="btn btn-danger pull-right issue-edit-cancel hidden" href="#">Cancel</a>
<a class="btn btn-primary pull-right issue-edit-save hidden" href="#" data-ajax="{issue.save.link}" data-ajax-name="issue-save">Save</a> <a class="btn btn-primary pull-right issue-edit-save hidden" href="#" data-ajax="{issue.save.link}" data-ajax-name="issue-save">Save</a>
<span class="status label label-{{if .Issue.IsClosed}}danger{{else}}success{{end}}">{{if .Issue.IsClosed}}Closed{{else}}Open{{end}}</span> <span class="status label label-{{if .Issue.IsClosed}}danger{{else}}success{{end}}">{{if .Issue.IsClosed}}Closed{{else}}Open{{end}}</span>
@ -34,8 +34,8 @@
<div class="issue-content panel panel-default"> <div class="issue-content panel panel-default">
<div class="panel-heading"> <div class="panel-heading">
<a href="/user/{{.Poster.Name}}" class="user">{{.Poster.Name}}</a> commented <span class="time">{{TimeSince .Created}}</span> <a href="/user/{{.Poster.Name}}" class="user">{{.Poster.Name}}</a> commented <span class="time">{{TimeSince .Created}}</span>
<a class="issue-comment-del pull-right issue-action" href="#" title="Edit Comment"><i class="fa fa-times-circle"></i></a> <!-- <a class="issue-comment-del pull-right issue-action" href="#" title="Edit Comment"><i class="fa fa-times-circle"></i></a>
<a class="issue-comment-edit pull-right issue-action" href="#" title="Remove Comment" data-url="{remove-link}"><i class="fa fa-edit"></i></a> <a class="issue-comment-edit pull-right issue-action" href="#" title="Remove Comment" data-url="{remove-link}"><i class="fa fa-edit"></i></a> -->
<span class="role label label-default pull-right">Owner</span> <span class="role label label-default pull-right">Owner</span>
</div> </div>
<div class="panel-body markdown"> <div class="panel-body markdown">
@ -44,7 +44,7 @@
</div> </div>
</div> </div>
{{end}} {{end}}
<div class="issue-child issue-closed"> <!-- <div class="issue-child issue-closed">
<a class="user pull-left" href="{user.link}"><img class="avatar" src="{user.avatar}" alt=""/></a> <a class="user pull-left" href="{user.link}"><img class="avatar" src="{user.avatar}" alt=""/></a>
<div class="issue-content"> <div class="issue-content">
<a class="user pull-left" href="{user.link}">{user.name}</a> <a class="user pull-left" href="{user.link}">{user.name}</a>
@ -59,7 +59,7 @@
<span class="btn btn-success">Reopened</span> this <span class="btn btn-success">Reopened</span> this
<span class="time">{close.time}</span> <span class="time">{close.time}</span>
</div> </div>
</div> </div> -->
<hr class="issue-line"/> <hr class="issue-line"/>
<div class="issue-child issue-reply"> <div class="issue-child issue-reply">
<a class="user pull-left" href="/user/{{.SignedUser.Name}}"><img class="avatar" src="{{.SignedUser.AvatarLink}}" alt=""/></a> <a class="user pull-left" href="/user/{{.SignedUser.Name}}"><img class="avatar" src="{{.SignedUser.AvatarLink}}" alt=""/></a>
@ -86,9 +86,11 @@
</div> </div>
<div class="text-right"> <div class="text-right">
<div class="form-group"> <div class="form-group">
<input type="hidden" value="id" name="repo-id"/> {{if .Issue.IsClosed}}
<button class="btn-default btn issue-open" id="issue-open-btn" data-origin="Re-Open" data-text="Re-Open & Comment">Open</button>&nbsp;&nbsp; <input type="hidden" value="reopen" name="change_status"/>
<button class="btn-default btn issue-close" id="issue-close-btn" data-origin="Close" data-text="Close & Comment">Close</button>&nbsp;&nbsp; <button class="btn-default btn issue-open" id="issue-open-btn" data-origin="Re-Open" data-text="Re-Open & Comment">Reopen</button>{{else}}
<input type="hidden" value="close" name="change_status"/>
<button class="btn-default btn issue-close" id="issue-close-btn" data-origin="Close" data-text="Close & Comment">Close</button>{{end}}&nbsp;&nbsp;
<button class="btn-success btn" id="issue-reply-btn">Comment</button> <button class="btn-success btn" id="issue-reply-btn">Comment</button>
</div> </div>
</div> </div>