aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1/misc
Commit message (Collapse)AuthorAgeFilesLines
* Add nodeinfo endpoint for federation purposes (#16953)techknowlogick2021-09-281-0/+45
| | | | | | | | | | | | | | | | Nodeinfo is a way to expose certain metadata about a server for use of discovery regarding functionality of its federation capabilities. Two endpoints are required: 1. `/.well-known/nodeinfo` which informs client where it can find the location of the location of its metadata (including which version of the schema is used) 2. the endpoint which exposes the metadata in json format according to schema. Notes: * `openRegistrations` is a required field, but I propose to set to false as default in case someone writes a crawler to discover "open" gitea instances * to limit data leakage I also propose to not include the `usage` field (note it is required so it should be included, but left as empty). More info: https://github.com/jhass/nodeinfo https://github.com/jhass/nodeinfo/tree/main/schemas/2.1 http://nodeinfo.diaspora.software/protocol.html
* refactor: move from io/ioutil to io and os package (#17109)Eng Zer Jun2021-09-221-2/+2
| | | | | | | | | 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>
* Refactor renders (#15175)Lunny Xiao2021-04-191-24/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor renders * Some performance optimization * Fix comment * Transform reader * Fix csv test * Fix test * Fix tests * Improve optimaziation * Fix test * Fix test * Detect file encoding with reader * Improve optimaziation * reduce memory usage * improve code * fix build * Fix test * Fix for go1.15 * Fix render * Fix comment * Fix lint * Fix test * Don't use NormalEOF when unnecessary * revert change on util.go * Apply suggestions from code review Co-authored-by: zeripath <art27@cantab.net> * rename function * Take NormalEOF back Co-authored-by: zeripath <art27@cantab.net>
* Move macaron to chi (#14293)Lunny Xiao2021-01-262-20/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | Use [chi](https://github.com/go-chi/chi) instead of the forked [macaron](https://gitea.com/macaron/macaron). Since macaron and chi have conflicts with session share, this big PR becomes a have-to thing. According my previous idea, we can replace macaron step by step but I'm wrong. :( Below is a list of big changes on this PR. - [x] Define `context.ResponseWriter` interface with an implementation `context.Response`. - [x] Use chi instead of macaron, and also a customize `Route` to wrap chi so that the router usage is similar as before. - [x] Create different routers for `web`, `api`, `internal` and `install` so that the codes will be more clear and no magic . - [x] Use https://github.com/unrolled/render instead of macaron's internal render - [x] Use https://github.com/NYTimes/gziphandler instead of https://gitea.com/macaron/gzip - [x] Use https://gitea.com/go-chi/session which is a modified version of https://gitea.com/macaron/session and removed `nodb` support since it will not be maintained. **BREAK** - [x] Use https://gitea.com/go-chi/captcha which is a modified version of https://gitea.com/macaron/captcha - [x] Use https://gitea.com/go-chi/cache which is a modified version of https://gitea.com/macaron/cache - [x] Use https://gitea.com/go-chi/binding which is a modified version of https://gitea.com/macaron/binding - [x] Use https://github.com/go-chi/cors instead of https://gitea.com/macaron/cors - [x] Dropped https://gitea.com/macaron/i18n and make a new one in `code.gitea.io/gitea/modules/translation` - [x] Move validation form structs from `code.gitea.io/gitea/modules/auth` to `code.gitea.io/gitea/modules/forms` to avoid dependency cycle. - [x] Removed macaron log service because it's not need any more. **BREAK** - [x] All form structs have to be get by `web.GetForm(ctx)` in the route function but not as a function parameter on routes definition. - [x] Move Git HTTP protocol implementation to use routers directly. - [x] Fix the problem that chi routes don't support trailing slash but macaron did. - [x] `/api/v1/swagger` now will be redirect to `/api/swagger` but not render directly so that `APIContext` will not create a html render. Notices: - Chi router don't support request with trailing slash - Integration test `TestUserHeatmap` maybe mysql version related. It's failed on my macOS(mysql 5.7.29 installed via brew) but succeed on CI. Co-authored-by: 6543 <6543@obermui.de>
* Not using "ctx.ServerError" in api (#12907)赵智超2020-09-201-5/+3
| | | | | | This function will render a whole html page which is not useful for API. Signed-off-by: a1012112796 <1012112796@qq.com>
* API: Move AllowedReactions endpoint into GetGenneralUI endpoint + creat new ↵65432020-06-221-42/+0
| | | | | | | | | | | | | swagger section settings (#11854) * move Setting function into its own package * swagger add&use new section "settings" * move api AllowedReactions into general UI-Settings endpoint * prepare TEST * lint
* API expose usefull General Repo settings settings (#11758)65432020-06-101-0/+17
| | | | | | | | | | | * GeneralRepoSettings expose MirrorsDisabled, HTTPGitDisabled, MaxCreationLimit * Apply suggestions from code review Co-authored-by: proton <25139420+proton-ab@users.noreply.github.com> * lint Co-authored-by: proton <25139420+proton-ab@users.noreply.github.com>
* Fix bug with globally disabling mirror (#11760)65432020-06-041-1/+3
| | | Ensure we return after `ctx.Error(...)`
* [API] Expose allowed Reactions (#11735)65432020-06-041-0/+23
| | | | | | | | | | | * [API] Expose allowed Reactions * dont be in soutch a rush * add TEST * use ElementsMatch Co-authored-by: Lauris BH <lauris@nix.lv>
* Allow different HardBreaks settings for documents and comments (#11515)zeripath2020-05-242-3/+13
| | | | | | | | | | | | | | | | GH has different HardBreaks behaviour for markdown comments and documents. Comments have hard breaks and documents have soft breaks - therefore Gitea's rendering will always be different from GH's if we only provide one setting. Here we split the setting in to two - one for documents and one for comments and other things. Signed-off-by: Andrew Thornton art27@cantab.net Changes to index.js as per @silverwind Co-authored-by: silverwind <me@silverwind.io> Changes to docs as per @guillep2k Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
* enable ENABLE_HARD_LINE_BREAK by default (#11162)silverwind2020-04-211-1/+1
| | | | | | | | enable ENABLE_HARD_LINE_BREAK by default This matches GitHub's rendering. Fix #11155
* Add gitea-vet (#10948)John Olheiser2020-04-052-0/+8
| | | | | | | | | | | | | | | | | * Add copyright Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add gitea-vet and fix non-compliance Signed-off-by: jolheiser <john.olheiser@gmail.com> * Combine tools.go into build.go and clean up Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove extra GO111MODULE=on Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Change markdown rendering from blackfriday to goldmark (#9533)zeripath2019-12-311-5/+0
| | | | | | | | | | | | | | | | | | | * Move to goldmark Markdown rendering moved from blackfriday to the goldmark. Multiple subtle changes required to the goldmark extensions to keep current rendering and defaults. Can go further with goldmark linkify and have this work within markdown rendering making the link processor unnecessary. Need to think about how to go about allowing extensions - at present it seems that these would be hard to do without recompilation. * linter fixes Co-authored-by: Lauris BH <lauris@nix.lv>
* Prefix all user-generated IDs in markup (#9477)John Olheiser2019-12-231-2/+2
| | | | | | | | | | * Prefix all user-generated IDs in markup * Add user-content- to IDs in unit-tests * fixup markdown_test.go * update the hrefs for the wiki test * Add blackfriday extension regex Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Swagger info corrections (#9441)65432019-12-203-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * use numbers and not http.Status___ enum * fix test * add many missing swagger responses * code format * Deletion Sould return 204 ... * error handling improvements * if special error type ... then add it to swagger too * one smal nit * invalidTopicsError is []string * valid swagger specification 2.0 - if you add responses swagger can tell you if you do it right :+1: * use ctx.InternalServerError * Revert "use numbers and not http.Status___ enum" This reverts commit b1ff386e2418ed6a7f183e756b13277d701278ef. * use http.Status* enum everywhere
* Sign merges, CRUD, Wiki and Repository initialisation with gpg key (#7631)zeripath2019-10-161-0/+62
| | | | | | | | | | | | | | | | | | | This PR fixes #7598 by providing a configurable way of signing commits across the Gitea instance. Per repository configurability and import/generation of trusted secure keys is not provided by this PR - from a security PoV that's probably impossible to do properly. Similarly web-signing, that is asking the user to sign something, is not implemented - this could be done at a later stage however. ## Features - [x] If commit.gpgsign is set in .gitconfig sign commits and files created through repofiles. (merges should already have been signed.) - [x] Verify commits signed with the default gpg as valid - [x] Signer, Committer and Author can all be different - [x] Allow signer to be arbitrarily different - We still require the key to have an activated email on Gitea. A more complete implementation would be to use a keyserver and mark external-or-unactivated with an "unknown" trust level icon. - [x] Add a signing-key.gpg endpoint to get the default gpg pub key if available - Rather than add a fake web-flow user I've added this as an endpoint on /api/v1/signing-key.gpg - [x] Try to match the default key with a user on gitea - this is done at verification time - [x] Make things configurable? - app.ini configuration done - [x] when checking commits are signed need to check if they're actually verifiable too - [x] Add documentation I have decided that adjusting the docker to create a default gpg key is not the correct thing to do and therefore have not implemented this.
* Use gitea forked macaron (#7933)Tamal Saha2019-08-232-4/+3
| | | Signed-off-by: Tamal Saha <tamal@appscode.com>
* Add golangci (#6418)kolaente2019-06-121-5/+22
|
* Move sdk structs to modules/structs (#6905)Lunny Xiao2019-05-113-4/+4
| | | | | | | | | | | | * move sdk structs to moduels/structs * fix tests * fix fmt * fix swagger * fix vendor
* Improve issue autolinks (#6273)mrsdizzie2019-04-121-3/+19
| | | | | | | | | | | | | | | | | | | | | | | | | * Improve issue autolinks Update autolinks to match what github does here: Issue in same repo: #1 Issue in different repo: org/repo#1 Fixes #6264 * Use setting.AppURL when parsing URL Using setting.AppURL here is a more reliable way of parsing the current URL and what other functions in this file seem to use. * Make ComposeMetas always return a valid context * Add per repository markdown renderers for better context * Update for use of context metas Now that we include the user and repo name inside context metas, update various code and tests for this new logic
* Markdown: enable some more extensions (#6362)Roland Koebler2019-03-211-2/+2
| | | | | | | | | | | | | | * Markdown: enable some more extensions Improve Markdown-rendering by enabling some extensions: - enable definitions lists - enable footnotes - enable header-ids and automatically generate header-ids (for linking to README-sections or creating table-of-contents for larger READMEs) * Markdown: update and exted tests Update and add tests for additionally enabled Markdown-extensions.
* Fix serving of raw wiki files other than .md (#5814)Gabriel Silva Simões2019-02-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix serving of raw wiki files other than .md Closes #4690. Closes #4395. Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Simplify code at routers/repo/wiki.go Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add more files to user2/repo1.wiki for testing Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Update macaron to v1.3.2 Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add tests for WikiRaw Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Fix NewResponseWriter usage due to macaron update Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com> * Add raw to reserved wiki names Signed-off-by: Gabriel Silva Simões <simoes.sgabriel@gmail.com>
* Swagger.v1.json template (#3572)Piotr Orzechowski2018-07-281-1/+1
| | | | | | * Turn swagger.v1.json into template * Rename ENABLE_SWAGGER_ENDPOINT option to ENABLE_SWAGGER
* Fix swagger errors (#4220)Antoine GIRARD2018-06-121-3/+6
| | | | | | | | | | Fix all the resting errors to have a valid swagger file. They are still some warnings but nothing blocking. Doing so I found that some request still misses son parameters for some POST/PUT/PATCH request. This means the a client generated from the swagger file will not work completely. Fix #4088 by activating validation in drone Should fix #4010.
* Rework special link parsing in the post-processing of markup (#3354)Morgan Bazalgette2018-02-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Get rid of autolink * autolink in markdown * Replace email addresses with mailto links * better handling of links * Remove autolink.js from footer * Refactor entire html.go * fix some bugs * Make tests green, move what we can to html_internal_test, various other changes to processor logic * Make markdown tests work again This is just a description to allow me to force push in order to restart the drone build. * Fix failing markdown tests in routers/api/v1/misc * Add license headers, log errors, future-proof <body> * fix formatting
* Populate URL field of API commits (#3546)Ethan Koenig2018-02-202-6/+6
| | | | | | * Populate URL field of API commits * fix orgmode_test
* Update swagger documentation (#2899)Ethan Koenig2017-11-132-32/+38
| | | | | | | | | | | * Update swagger documentation Add docs for missing endpoints Add documentation for request parameters Make parameter naming consistent Fix response documentation * Restore delete comments
* Move swagger-ui under /api/v1 (#2746)Antoine GIRARD2017-10-211-0/+19
| | | | | | | | | | | | * Move swagger interface under /api/v1 * Update swagger-ui * Add /api/swagger and prepare for multiple api version * Update test links * Fix footer link
* Add init support of orgmode document type on file view and readme (#2525)Lunny Xiao2017-09-211-1/+1
| | | | | | | | | | | | | | * add init support of orgmode document type on file view and readme * fix imports * fix imports and readmeExist * fix imports order * fix format * remove unnecessary convert
* Restructure markup & markdown to prepare for multiple markup language… (#2411)Lunny Xiao2017-09-162-11/+10
| | | | | | | | | | * restructure markup & markdown to prepare for multiple markup languages support * adjust some functions between markdown and markup * fix tests * improve the comments
* Improve swagger doc (#2274)Antoine GIRARD2017-08-212-3/+3
| | | | | | | | | | | | | | | | | | | | * Add swagger comment for adminCreateOrg * Add swagger comment for admin route * add hook swagger doc * Add tags * Add auth * Fix name of responses * Edit name method * Update vendor * make generate-swagger
* Fix rendering of external links (#2292)Ethan Koenig2017-08-131-1/+1
|
* gofmt (#1662)Ethan Koenig2017-05-041-1/+1
|
* Generate swagger json (#1402)Antoine GIRARD2017-05-022-2/+35
| | | | | | | - Generate swagger.json into public/ - Add swagger-ui auto-installation - Add footer link to local swagger-ui - Add /swagger url for using app url. - Fix Swagger-UI version via git tag
* Add basic integration test infrastructure (and new endpoint ↵Mura Li2017-03-061-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `/api/v1/version` for testing it) (#741) * Implement '/api/v1/version' * Cleanup and various fixes * Enhance run.sh * Add install_test.go * Add parameter utils.Config for testing handlers * Re-organize TestVersion.go * Rename functions * handling process cleanup properly * Fix missing function renaming * Cleanup the 'retry' logic * Cleanup * Remove unneeded logging code * Logging messages tweaking * Logging message tweaking * Fix logging messages * Use 'const' instead of hardwired numbers * We don't really need retries anymore * Move constant ServerHttpPort to install_test.go * Restore mistakenly removed constant * Add required comments to make the linter happy. * Fix comments and naming to address linter's complaints * Detect Gitea executale version automatically * Remove tests/run.sh, `go test` suffices. * Make `make build` a prerequisite of `make test` * Do not sleep before trying * Speedup the server pinging loop * Use defined const instead of hardwired numbers * Remove redundant error handling * Use a dedicated target for running code.gitea.io/tests * Do not make 'test' depend on 'build' target * Rectify the excluded package list * Remove redundant 'exit 1' * Change the API to allow passing test.T to test handlers * Make testing.T an embedded field * Use assert.Equal to comparing results * Add copyright info * Parametrized logging output * Use tmpdir instead * Eliminate redundant casting * Remove unneeded variable * Fix last commit * Add missing copyright info * Replace fmt.Fprintf with fmt.Fprint * rename the xtest to integration-test * Use Symlink instead of hard-link for cross-device linking * Turn debugging logs on * Follow the existing framework for APIs * Output logs only if test.v is true * Re-order import statements * Enhance the error message * Fix comment which breaks the linter's rule * Rename 'integration-test' to 'e2e-test' for saving keystrokes * Add comment to avoid possible confusion * Rename tests -> integration-tests Also change back the Makefile to use `make integration-test`. * Use tests/integration for now * tests/integration -> integrations Slightly flattened directory hierarchy is better. * Update Makefile accordingly * Fix a missing change in Makefile * govendor update code.gitea.io/sdk/gitea * Fix comment of struct fields * Fix conditional nonsense * Fix missing updates regarding version string changes * Make variable naming more consistent * Check http status code * Rectify error messages
* Fix go vet faults (#1060)Ethan Koenig2017-02-261-2/+2
|
* Fix URL handling in the whole markdown module, improve test coverage (#1027)Andrew Boyarshin2017-02-242-3/+10
| | | | | Amended with string to bool change in API SDK. Signed-off-by: Andrew Boyarshin <andrew.boyarshin@gmail.com>
* Markdown rendering overhaul (#186)Andrew Boyarshin2017-02-142-3/+188
| | | | | | | | | | | | * Markdown rendering overhaul Cleaned up and squashed commits into single one. Signed-off-by: Andrew Boyarshin <boyarshinand@gmail.com> * Fix markdown API, add markdown module and API tests, improve code coverage Signed-off-by: Andrew Boyarshin <boyarshinand@gmail.com>
* Golint fixed for modules/contextLunny Xiao2016-11-251-1/+1
|
* golint fixed for routers (#208)Lunny Xiao2016-11-241-2/+4
|
* Fix import path of go-sdk (#141)Sandro Santilli2016-11-111-1/+1
| | | | From code.gitea.io/go-sdk/gitea To code.gitea.io/sdk/gitea
* Update import paths from github.com/go-gitea to code.gitea.io (#135)Sandro Santilli2016-11-101-3/+3
| | | | | | | - Update import paths from github.com/go-gitea to code.gitea.io - Fix import path for travis See https://docs.travis-ci.com/user/languages/go#Go-Import-Path
* Replaced go-gogs-client with go-sdk importsThomas Boerger2016-11-071-1/+1
|
* Change import reference to match gitea instead of gogs (#37)Rémy Boulanouar2016-11-031-2/+2
|
* Convert all API handers to use *context.APIContextUnknwon2016-03-131-4/+4
|
* Rename module: middleware -> contextUnknwon2016-03-111-3/+3
|
* Make markdown as an independent moduleUnknwon2016-02-201-4/+4
|
* fix #1829 and fix #890Unknwon2015-12-041-1/+1
|
* refactor API routes and some work for #976Unknwon2015-12-041-0/+42