summaryrefslogtreecommitdiffstats
path: root/modules/public
Commit message (Collapse)AuthorAgeFilesLines
* Use a general approach to access custom/static/builtin assets (#24022)wxiaoguang2023-04-123-115/+58
| | | | | | | | | | | | | | | | | | | The idea is to use a Layered Asset File-system (modules/assetfs/layered.go) For example: when there are 2 layers: "custom", "builtin", when access to asset "my/page.tmpl", the Layered Asset File-system will first try to use "custom" assets, if not found, then use "builtin" assets. This approach will hugely simplify a lot of code, make them testable. Other changes: * Simplify the AssetsHandlerFunc code * Simplify the `gitea embedded` sub-command code --------- Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix incorrect CORS failure detection logic (#23844)wxiaoguang2023-03-311-5/+5
| | | | | | Regression of #23495 Fixes #23838 Fixes #23850
* Introduce path Clean/Join helper functions (#23495)wxiaoguang2023-03-211-18/+8
| | | | | | | | | | | | | | | Since #23493 has conflicts with latest commits, this PR is my proposal for fixing #23371 Details are in the comments And refactor the `modules/options` module, to make it always use "filepath" to access local files. Benefits: * No need to do `util.CleanPath(strings.ReplaceAll(p, "\\", "/"))), "/")` any more (not only one before) * The function behaviors are clearly defined
* Use CleanPath instead of path.Clean (#23371)Lunny Xiao2023-03-081-2/+2
| | | As title.
* Implement FSFE REUSE for golang files (#21840)flynnnnnnnnnn2022-11-276-12/+6
| | | | | | | | | Change all license headers to comply with REUSE specification. Fix #16132 Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github> Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Add generic set type (#21408)KN4CK3R2022-10-123-16/+12
| | | | | This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove legacy `+build:` constraint (#19582)wxiaoguang2022-05-023-3/+0
| | | Go 1.17 and later use modern `//go:build` constraints, the old `// +build:` constraints should be removed.
* Fix mime-type detection for HTTP server (#18370)wxiaoguang2022-01-234-20/+61
| | | Bypass the unstable behavior of Golang's mime.TypeByExtension
* format with gofumpt (#18184)65432022-01-203-4/+4
| | | | | | | | | | | * gofumpt -w -l . * gofumpt -w -l -extra . * Add linter * manual fix * change make fmt
* Refactor Router Logger (#17308)wxiaoguang2022-01-201-46/+43
| | | | | | Make router logger more friendly, show the related function name/file/line. [BREAKING] This PR substantially changes the logging format of the router logger. If you use this logging for monitoring e.g. fail2ban you will need to update this to match the new format.
* Remove golang vendored directory (#18277)techknowlogick2022-01-141-1/+1
| | | | | | | * rm go vendor * fix drone yaml * add to gitignore
* Fix various typos (#18219)luzpaz2022-01-101-1/+1
| | | | | Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon` Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Don't store assets modified time into generated files (#18193)Lunny Xiao2022-01-062-1/+7
|
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-221-2/+1
| | | | | | | | | The io/ioutil package has been deprecated as of Go 1.16, see https://golang.org/doc/go1.16#ioutil. This commit replaces the existing io/ioutil functions with their new definitions in io and os packages. Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add bundle download for repository (#14538)John Olheiser2021-08-243-5/+8
| | | | | | | | | | | | | | | | | * Add bundle download Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix fmt Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix build tags Signed-off-by: jolheiser <john.olheiser@gmail.com> * Download specific commit Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Improve assets handler middleware (#15961)Lunny Xiao2021-05-303-124/+76
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use route to serve assets but not middleware * Fix build error with bindata tag * convert path to absolute * fix build * reduce function stack * Add tests for assets * Remove test for assets because they are not generated * Use a http function to serve assets * Still use middleware to serve assets then less middleware stack for assets * Move serveContent to original position * remove unnecessary blank line change * Fix bug for /assets* requests * clean code Co-authored-by: zeripath <art27@cantab.net>
* add `/assets` as root dir of public files (#15219)a10121127962021-04-281-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | * add `/assets` as root dir of public files Signed-off-by: a1012112796 <1012112796@qq.com> * move serviceworker.js * make fmt * fix some link * fix test * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> * Apply suggestions from code review Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
* Add ETag header (#15370)KN4CK3R2021-04-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | * Add ETag header. * Comply with RFC 7232. * Moved logic into httpcache.go * Changed name. * Lint * Implemented If-None-Match list. * Fixed missing header on * * Removed weak etag support. * Removed * support. * Added unit test. * Lint Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* add 'fonts' into 'KnownPublicEntries' (#15188)a10121127962021-03-301-0/+1
| | | | | | | fix #15184 Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Update docs and comments to remove macaron (#14491)Lunny Xiao2021-01-293-4/+4
|
* When visit /favicon.ico but the static file is not exist return 404 but not ↵Lunny Xiao2021-01-011-0/+1
| | | | | continue to handle the route (#14211) Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Improve vfsgen to not unzip bindata files but send to browser directly (#7109)Lunny Xiao2020-12-244-2/+102
| | | | | | | | | | | | | | | * Don't unzip files from bindata but send to browser directly * remove dependent for httpgzip * Add tests for parseAcceptEncoding * Update docs for ENABLE_GZIP * Fix bug * Fix bug Co-authored-by: zeripath <art27@cantab.net>
* HTTP cache rework and enable caching for storage assets (#13569)silverwind2020-11-171-23/+5
| | | | | | | | | | This enabled HTTP time-based cache for storage assets, primarily avatars. I have not observed If-Modified-Since from browsers during tests but I guess it's good to support regardless. It introduces a new generic httpcache module that can handle both time-based and etag-based caching. Additionally, manifest.json and robots.txt are now also cachable.
* Introduce go chi web framework as frontend of macaron, so that we can move ↵Lunny Xiao2020-11-133-43/+42
| | | | | | | | | routes from macaron to chi step by step (#7420) * When route cannot be found on chi, go to macaron * Stick chi version to 1.5.0 * Follow router log setting
* fix go1.15 lint error in modules/public/public.go (#12707)65432020-09-041-1/+1
| | | Co-authored-by: Lauris BH <lauris@nix.lv>
* go1.15 (#12475)techknowlogick2020-08-131-1/+2
| | | | | | | | | | | | | * go1.15 * update makefile xgo version * fix vet issue * update docs to version of go in use * add TODO for asyncpreemptoff Co-authored-by: Lauris BH <lauris@nix.lv>
* Move fomantic and jQuery to main webpack bundle (#11997)silverwind2020-06-271-1/+0
| | | | | | | | | | | | | | This saves around 3 MB binary size by not including useless fomantic files in the build. Also, this allows us to move jQuery into the main bundle as well which eliminates a few HTTP requests. Also included are webpack config changes: - split less and css loaders to speed up compliation - enable css sourcemaps - switch css minfier plugin to cssnano-webpack-plugin which works better for sourcemaps than the previous plugin Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Add serviceworker.js to KnownPublicEntries (#11992)silverwind2020-06-201-3/+4
| | | | | | | Fixes a wrong 302 redirect to the login page, see https://github.com/go-gitea/gitea/issues/11989. Also made it so the reserved username list is extended with those known entries so we avoid code duplication. Should be backported to 1.12.
* Send 404 immediately for known public requests (#11117)silverwind2020-04-181-0/+22
| | | | | | | Instead of further handling requests to public which causes issues like #11088, immediately terminate requests to directories js, css, fomantic if no file is found which is checked against a hardcoded list. Maybe there is a way to retrieve the top-level entries below public in a dynamic fashion. I also added fomantic to the reserved usernames and sorted the list. Fixes: #11088
* Rename scripts to build and add revive command as a new build tool command ↵Lunny Xiao2020-04-031-1/+1
| | | | | (#10942) Co-authored-by: techknowlogick <techknowlogick@gitea.io>
* Implement "embedded" command to extract static resources (#9982)guillep2k2020-02-021-0/+33
| | | | | | | | | | | | | | | | | | | | | | | * draft * Implement extract command * Fix nits and force args on extract * Add !bindata stub, support Windows, fmt * fix vendored flag * Remove leading slash for matching * Add docs * Fix typos * Add embedded view command Co-authored-by: zeripath <art27@cantab.net> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Generate Bindata iff TAGS="bindata" and not up-to-date (#10004)zeripath2020-01-273-25/+9
| | | | | | | | | | | | | | | | | | | | | | * Only generate bindata if necessary * Only generate bindata if they are not up-to-date * generate a hash of the fileinfo and use that to keep up-to-date * Newer test is redundant * handle missing bindata and clean * Only update hash after successful write * switch to sha1 hash * Apply suggestions from code review Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com> Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* Use gitea forked macaron (#7933)Tamal Saha2019-08-233-3/+4
| | | Signed-off-by: Tamal Saha <tamal@appscode.com>
* remove unnecessary fmt on generate bindata (#7706)Lunny Xiao2019-08-011-1/+0
|
* Use vfsgen instead of go-bindata (#7080)Lunny Xiao2019-06-033-11/+25
| | | | | | | | | | * use vfsgen instead of go-bindata * fix templates * fix fmt * vendor vsfgen
* When redirecting clean the path to avoid redirecting to //www.othersite.com ↵zeripath2019-01-091-1/+1
| | | | | | | (#5669) Fix #5627 Signed-off-by: Andrew Thornton <art27@cantab.net>
* Enable caching on assets and avatars (#3376)Morgan Bazalgette2018-02-043-25/+143
| | | | | | | | | | | | | | * Enable caching on assets and avatars Fixes #3323 * Only set avatar in user BeforeUpdate when there is no avatar set * add error checking after stat * gofmt * Change cache time for avatars to an hour
* Allow custom public files (#782)Thomas Boerger2017-01-281-0/+17
| | | | | | * Allow custom public files * Gofmt code, lots of places not related to this pr
* Integrate templates into bindata optionally (#314)Thomas Boerger2016-12-062-1/+3
| | | Integrated optional bindata for the templates
* Integrate public as bindata optionally (#293)Thomas Boerger2016-11-303-0/+64
* Dropped unused codekit config * Integrated dynamic and static bindata for public * Ignore public bindata * Add a general generate make task * Integrated flexible public assets into web command * Updated vendoring, added all missiong govendor deps * Made the linter happy with the bindata and dynamic code * Moved public bindata definition to modules directory * Ignoring the new bindata path now * Updated to the new public modules import path * Updated public bindata command and drop the new prefix