From 01c8df01ec0608f1f25b2f1444adabb98fa5ee8a Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 24 Oct 2019 01:51:46 -0700 Subject: internal: move packages under this directory (#5836) * Rename pkg -> internal * Rename routes -> route * Move route -> internal/route * Rename models -> db * Move db -> internal/db * Fix route2 -> route * Move cmd -> internal/cmd * Bump version --- pkg/context/notice.go | 62 --------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 pkg/context/notice.go (limited to 'pkg/context/notice.go') diff --git a/pkg/context/notice.go b/pkg/context/notice.go deleted file mode 100644 index 191441f1..00000000 --- a/pkg/context/notice.go +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2019 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 context - -import ( - "os" - "path" - - "github.com/unknwon/com" - log "gopkg.in/clog.v1" - - "gogs.io/gogs/pkg/markup" - "gogs.io/gogs/pkg/setting" - "gogs.io/gogs/pkg/tool" -) - -// renderNoticeBanner checks if a notice banner file exists and loads the message to display -// on all pages. -func (c *Context) renderNoticeBanner() { - fpath := path.Join(setting.CustomPath, "notice", "banner.md") - if !com.IsExist(fpath) { - return - } - - f, err := os.Open(fpath) - if err != nil { - log.Error(2, "Failed to open file %q: %v", fpath, err) - return - } - defer f.Close() - - fi, err := f.Stat() - if err != nil { - log.Error(2, "Failed to stat file %q: %v", fpath, err) - return - } - - // Limit size to prevent very large messages from breaking pages - var maxSize int64 = 1024 - - if fi.Size() > maxSize { // Refuse to print very long messages - log.Warn("Notice banner file %q size too large [%d > %d]: refusing to render", fpath, fi.Size(), maxSize) - return - } - - buf := make([]byte, maxSize) - n, err := f.Read(buf) - if err != nil { - log.Error(2, "Failed to read file %q: %v", fpath, err) - return - } - buf = buf[:n] - - if !tool.IsTextFile(buf) { - log.Warn("Notice banner file %q does not appear to be a text file: aborting", fpath) - return - } - - c.Data["ServerNotice"] = string(markup.RawMarkdown(buf, "")) -} -- cgit v1.2.3