aboutsummaryrefslogtreecommitdiffstats
path: root/services/context/context.go
Commit message (Collapse)AuthorAgeFilesLines
* Enable addtional linters (#34085)TheFox0x76 days1-1/+1
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor cache-control (#33861)wxiaoguang2025-03-131-1/+1
| | | And fix #21391
* Improve "generate new access token" form (#33730)Guillaume2025-02-271-4/+7
| | | | | | | | | | | | | | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/33519 As discussed in [PR #33614](https://github.com/go-gitea/gitea/pull/33614), the ScopedAccessTokenSelector Vue component is not particularly useful. This PR removes the component and reverts to using HTML templates. It also introduces some (hopefully) useful refactoring. The Vue component was causing the UX bug reported in the linked issue. Required form fields are now properly working, as expected (see screenshot). ![Screenshot from 2025-02-25 22-00-28](https://github.com/user-attachments/assets/41167854-0718-48b0-a3ee-75ca3a7b8b20) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Avoid duplicate SetContextValue call (#33564)wxiaoguang2025-02-121-1/+0
| | | And fix FIXME and TODO
* Fix context usage (#33554)wxiaoguang2025-02-111-4/+5
| | | | | | | | | Some old code use direct type-casting to get context, it causes problems. This PR fixes all legacy problems and use correct `ctx.Value` to get low-level contexts. Fix #33518
* Feature: Support workflow event dispatch via API (#33545)wxiaoguang2025-02-111-1/+4
| | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Refactor context flash msg and global variables (#33375)wxiaoguang2025-01-251-11/+3
| | | | | | 1. add `GetSiteCookieFlashMessage` to help to parse flash message 2. clarify `handleRepoHomeFeed` logic 3. remove unnecessary global variables, use `sync.OnceValue` instead 4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
* Refactor request context (#32956)wxiaoguang2024-12-241-10/+2
| | | | | | | | | | | Introduce RequestContext: is a short-lived context that is used to store request-specific data. RequestContext could be used to clean form tmp files, close context git repo, and do some tracing in the future. Then a lot of legacy code could be removed or improved. For example: most `ctx.Repo.GitRepo.Close()` could be removed because the git repo could be closed when the request is done.
* Refactor template & test related code (#32938)wxiaoguang2024-12-221-1/+1
| | | Move some legacy code from "base" package to proper packages.
* Fix LFS route mock, realm, middleware names (#32488)wxiaoguang2024-11-131-0/+3
| | | | | | | | | | 1. move "internal-lfs" route mock to "common-lfs" 2. fine tune tests 3. fix "realm" strings, according to RFC: https://datatracker.ietf.org/doc/html/rfc2617: * realm = "realm" "=" realm-value * realm-value = quoted-string 4. clarify some names of the middlewares, rename `ignXxx` to `optXxx` to match `reqXxx`, and rename ambiguous `requireSignIn` to `reqGitSignIn`
* Refactor template ctx and render utils (#32422)wxiaoguang2024-11-051-1/+4
| | | Clean up the templates
* Refactor DateUtils and merge TimeSince (#32409)wxiaoguang2024-11-041-1/+0
| | | Follow #32383 and #32402
* Replace DateTime with DateUtils (#32383)wxiaoguang2024-11-021-0/+1
|
* Refactor CSRF protector (#32057)wxiaoguang2024-09-181-5/+1
| | | | | | Remove unused CSRF options, decouple "new csrf protector" and "prepare" logic, do not redirect to home page if CSRF validation falis (it shouldn't happen in daily usage, if it happens, redirecting to home doesn't help either but just makes the problem more complex for "fetch")
* Refactor repo unit "disabled" check (#31389)wxiaoguang2024-06-181-8/+1
| | | | | | | | 1. There are already global "unit consts", no need to use context data, which is fragile 2. Remove the "String()" method from "unit", it would only cause rendering problems in templates --------- Co-authored-by: silverwind <me@silverwind.io>
* Improve oauth2 client "preferred username field" logic and the error ↵wxiaoguang2024-04-251-3/+2
| | | | | | | | | | | | | handling (#30622) Follow #30454 And fix #24957 When using "preferred_username", if no such field, `extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an error. All other USERNAME options do not return such error. And fine tune some logic and error messages, make code more stable and more friendly to end users.
* Initial support for colorblindness-friendly themes (#30625)wxiaoguang2024-04-241-0/+1
| | | | | | | Initial support for #25680 This PR only adds some simple styles from GitHub, it is big enough and it focuses on adding the necessary framework-level supports. More styles could be fine-tuned later.
* Refactor web routes (#30519)wxiaoguang2024-04-171-0/+12
| | | | | | | Re-organize the routes in web.go and use ctx constants instead of `context.UnitTypes()` --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Rewrite and restyle reaction selector and enable no-sizzle eslint rule (#30453)silverwind2024-04-141-0/+1
| | | | | | | | | | | Enable `no-sizzle` lint rule, there was only one use in `initCompReactionSelector` and: - Remove all jQuery except the necessary fomantic dropdown init - Remove the recursion, instead bind event listeners to common parent container nodes --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor cache and disable go-chi cache (#30417)wxiaoguang2024-04-131-4/+3
| | | use built-in cache package to wrap external go-chi cache package
* Move context from modules to services (#29440)Lunny Xiao2024-02-271-0/+257
Since `modules/context` has to depend on `models` and many other packages, it should be moved from `modules/context` to `services/context` according to design principles. There is no logic code change on this PR, only move packages. - Move `code.gitea.io/gitea/modules/context` to `code.gitea.io/gitea/services/context` - Move `code.gitea.io/gitea/modules/contexttest` to `code.gitea.io/gitea/services/contexttest` because of depending on context - Move `code.gitea.io/gitea/modules/upload` to `code.gitea.io/gitea/services/context/upload` because of depending on context