gogs/pkg
Achilleas Koutsou dc13eb6df0 pkg/context: Render live notice banner from file (#5750)
* pkg/context: Render live notice banner from file

- Contexter checks if there is a file called 'notice' under the
GOGS_CUSTOM directory and loads it.
- The first line is treated as a header/title and everything else as the
message body.
- Message body is rendered as HTML (tags allowed).
- File size is limited to 1024 bytes.
- File mime type must be text.
- Notice is rendered in head.tmpl for all pages.

* pkg/context: Rename maxlen to maxSize

Rename maxlen to maxSize for the maximum size (in bytes) of the notice
file to render.
Define the variable when needed to avoid instantiating it when the file
doesn't exist.

Co-Authored-By: ᴊ. ᴄʜᴇɴ <u@gogs.io>

* pkg/context: Package name after license header

Co-Authored-By: ᴊ. ᴄʜᴇɴ <u@gogs.io>

* pkg/context: Don't print 'Found notice file'

Becomes too verbose as it prints on every page load when the file
exists.

* pkg/context: Match project conventions

Import order and grouping

Variable names:
    fileloc -> fpath
    fp -> f
    finfo -> fi

* pkg/context: Remove empty line

Co-Authored-By: ᴊ. ᴄʜᴇɴ <u@gogs.io>

* pkg/context: Render notice as markdown

Server notice file should be named 'notice.md'.  The contents of the
file are treated as markdown and rendered as a warning message at the
top of every page.

* Update notice.go


Co-authored-by: ᴊ. ᴄʜᴇɴ <u@gogs.io>
2019-07-27 23:47:35 -07:00
..
auth auth: coding style and glitches fixes for GitHub login source (#5340) 2018-12-18 16:46:50 -05:00
avatar Refactoring: rename modules -> pkg 2017-04-04 19:29:59 -04:00
bindata locale: sync from Crowdin 2019-06-27 08:32:59 -04:00
context pkg/context: Render live notice banner from file (#5750) 2019-07-27 23:47:35 -07:00
cron *: rename "gogits" to "gogs" 2018-05-27 08:53:48 +08:00
form auth: coding style and glitches fixes for GitHub login source (#5340) 2018-12-18 16:46:50 -05:00
httplib *: use jsoniter to replace encoding/json 2018-06-09 17:32:58 +08:00
mailer pkg/mailer/mail: render markdown in issue related emails (#5629) 2019-02-20 17:54:27 -05:00
markup pkg/markup: support data URL of base64 encoded images (#5391) 2018-12-10 23:53:08 -05:00
process pkg/process: fix potential race condition 2017-06-11 02:28:08 -04:00
setting pkg/mailer: support plaintext alt for HTML emails (#5568) 2018-12-25 10:08:00 -05:00
ssh pkg/ssh: specify ssh-keygen to always generate PEM format 2018-12-19 08:31:22 -05:00
sync Refactoring: rename modules -> pkg 2017-04-04 19:29:59 -04:00
template templates: rename template function Str2html -> Str2HTML 2018-12-10 22:23:56 -05:00
tool pkg/tool/path: use IsMaliciousPath to replace SanitizePath (#5558) 2018-12-25 09:47:33 -05:00
user Refactoring: rename modules -> pkg 2017-04-04 19:29:59 -04:00