Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom public files #782

Merged
merged 2 commits into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions cmd/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func newMacaron() *macaron.Macaron {
if setting.Protocol == setting.FCGI {
m.SetURLPrefix(setting.AppSubURL)
}
m.Use(public.Custom(
&public.Options{
SkipLogging: setting.DisableRouterLog,
},
))
m.Use(public.Static(
&public.Options{
Directory: path.Join(setting.StaticRootPath, "public"),
Expand Down
1 change: 0 additions & 1 deletion models/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Attachment struct {
CreatedUnix int64
}


// BeforeInsert is invoked from XORM before inserting an object of this type.
func (a *Attachment) BeforeInsert() {
a.CreatedUnix = time.Now().Unix()
Expand Down
5 changes: 2 additions & 3 deletions models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -953,9 +953,9 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) {

switch opts.IsPull {
case util.OptionalBoolTrue:
sess.And("issue.is_pull=?",true)
sess.And("issue.is_pull=?", true)
case util.OptionalBoolFalse:
sess.And("issue.is_pull=?",false)
sess.And("issue.is_pull=?", false)
}

sortIssuesSession(sess, opts.SortType)
Expand Down Expand Up @@ -1780,4 +1780,3 @@ func DeleteMilestoneByRepoID(repoID, id int64) error {
}
return sess.Commit()
}

2 changes: 1 addition & 1 deletion models/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"time"

"code.gitea.io/git"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/sync"
api "code.gitea.io/sdk/gitea"
"github.com/Unknwon/com"
"github.com/go-xorm/xorm"
"code.gitea.io/gitea/modules/base"
)

var pullRequestQueue = sync.NewUniqueQueue(setting.Repository.PullRequestQueueLength)
Expand Down
17 changes: 17 additions & 0 deletions modules/public/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

package public

import (
"path"

"code.gitea.io/gitea/modules/setting"
"gopkg.in/macaron.v1"
)

//go:generate go-bindata -tags "bindata" -ignore "\\.go|\\.less" -pkg "public" -o "bindata.go" ../../public/...
//go:generate go fmt bindata.go
//go:generate sed -i.bak s/..\/..\/public\/// bindata.go
Expand All @@ -14,3 +21,13 @@ type Options struct {
Directory string
SkipLogging bool
}

// Custom implements the macaron static handler for serving custom assets.
func Custom(opts *Options) macaron.Handler {
return macaron.Static(
path.Join(setting.CustomPath, "public"),
macaron.StaticOptions{
SkipLogging: opts.SkipLogging,
},
)
}
2 changes: 1 addition & 1 deletion routers/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import (
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/cron"
"code.gitea.io/gitea/modules/highlight"
"code.gitea.io/gitea/modules/indexer"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/mailer"
"code.gitea.io/gitea/modules/markdown"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/ssh"
macaron "gopkg.in/macaron.v1"
"code.gitea.io/gitea/modules/indexer"
)

func checkRunMode() {
Expand Down
1 change: 0 additions & 1 deletion routers/repo/attachment.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ func UploadAttachment(ctx *context.Context) {
"uuid": attach.UUID,
})
}

4 changes: 2 additions & 2 deletions routers/repo/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ func NewRelease(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.release.new_release")
ctx.Data["PageIsReleaseList"] = true
ctx.Data["tag_target"] = ctx.Repo.Repository.DefaultBranch
renderAttachmentSettings(ctx);
renderAttachmentSettings(ctx)
ctx.HTML(200, tplReleaseNew)
}

Expand Down Expand Up @@ -250,7 +250,7 @@ func EditRelease(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.release.edit_release")
ctx.Data["PageIsReleaseList"] = true
ctx.Data["PageIsEditRelease"] = true
renderAttachmentSettings(ctx);
renderAttachmentSettings(ctx)

tagName := ctx.Params("*")
rel, err := models.GetRelease(ctx.Repo.Repository.ID, tagName)
Expand Down