mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-30 22:11:07 +00:00 
			
		
		
		
	Extend API MarkupOptions to contain branch path.
The `api.MarkupOptions{}`  to have `BranchPath` which contains the
current branch. The `RenderMarkup` function utilizes a struct since there
are too many variables passed as arguments and that is not a good sign
for readability.
And `repo-editor.js` will contain a new form data which is `branch-path`
which will then be utilized by `edit.tmpl` as `data-branch-path`.
Closes: #4510
## Checklist
The [contributor guide](https://forgejo.org/docs/next/contributor/) contains information that will be helpful to first time contributors. There also are a few [conditions for merging Pull Requests in Forgejo repositories](https://codeberg.org/forgejo/governance/src/branch/main/PullRequestsAgreement.md). You are also welcome to join the [Forgejo development chatroom](https://matrix.to/#/#forgejo-development:matrix.org).
### Tests
- I added test coverage for Go changes...
  - [ ] in their respective `*_test.go` for unit tests.
  - [ ] in the `tests/integration` directory if it involves interactions with a live Forgejo server.
- I added test coverage for JavaScript changes...
  - [ ] in `web_src/js/*.test.js` if it can be unit tested.
  - [x] in `tests/e2e/*.test.e2e.js` if it requires interactions with a live Forgejo server (see also the [developer guide for JavaScript testing](https://codeberg.org/forgejo/forgejo/src/branch/forgejo/tests/e2e/README.md#end-to-end-tests)).
### Documentation
- [ ] I created a pull request [to the documentation](https://codeberg.org/forgejo/docs) to explain to Forgejo users how to use this change.
- [ ] I did not document these changes and I do not expect someone else to do it.
### Release notes
- [ ] I do not want this change to show in the release notes.
- [x] I want the title to show in the release notes with a link to this pull request.
- [ ] I want the content of the `release-notes/<pull request number>.md` to be be used for the release notes instead of the title.
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/5781
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Nirmal Kumar R <tildezero@gmail.com>
Co-committed-by: Nirmal Kumar R <tildezero@gmail.com>
		
	
			
		
			
				
	
	
		
			105 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			105 lines
		
	
	
	
		
			2.2 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // Copyright 2015 The Gogs Authors. All rights reserved.
 | |
| // SPDX-License-Identifier: MIT
 | |
| 
 | |
| package structs
 | |
| 
 | |
| // SearchResults results of a successful search
 | |
| type SearchResults struct {
 | |
| 	OK   bool          `json:"ok"`
 | |
| 	Data []*Repository `json:"data"`
 | |
| }
 | |
| 
 | |
| // SearchError error of a failed search
 | |
| type SearchError struct {
 | |
| 	OK    bool   `json:"ok"`
 | |
| 	Error string `json:"error"`
 | |
| }
 | |
| 
 | |
| // MarkupOption markup options
 | |
| type MarkupOption struct {
 | |
| 	// Text markup to render
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Text string
 | |
| 	// Mode to render (comment, gfm, markdown, file)
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Mode string
 | |
| 	// Context to render
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Context string
 | |
| 	// Is it a wiki page ?
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Wiki bool
 | |
| 	// File path for detecting extension in file mode
 | |
| 	//
 | |
| 	// in: body
 | |
| 	FilePath string
 | |
| 	// The current branch path where the form gets posted
 | |
| 	//
 | |
| 	// in: body
 | |
| 	BranchPath string
 | |
| }
 | |
| 
 | |
| // MarkupRender is a rendered markup document
 | |
| // swagger:response MarkupRender
 | |
| type MarkupRender string
 | |
| 
 | |
| // MarkdownOption markdown options
 | |
| type MarkdownOption struct {
 | |
| 	// Text markdown to render
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Text string
 | |
| 	// Mode to render (comment, gfm, markdown)
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Mode string
 | |
| 	// Context to render
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Context string
 | |
| 	// Is it a wiki page ?
 | |
| 	//
 | |
| 	// in: body
 | |
| 	Wiki bool
 | |
| }
 | |
| 
 | |
| // MarkdownRender is a rendered markdown document
 | |
| // swagger:response MarkdownRender
 | |
| type MarkdownRender string
 | |
| 
 | |
| // ServerVersion wraps the version of the server
 | |
| type ServerVersion struct {
 | |
| 	Version string `json:"version"`
 | |
| }
 | |
| 
 | |
| // GitignoreTemplateInfo name and text of a gitignore template
 | |
| type GitignoreTemplateInfo struct {
 | |
| 	Name   string `json:"name"`
 | |
| 	Source string `json:"source"`
 | |
| }
 | |
| 
 | |
| // LicensesListEntry is used for the API
 | |
| type LicensesTemplateListEntry struct {
 | |
| 	Key  string `json:"key"`
 | |
| 	Name string `json:"name"`
 | |
| 	URL  string `json:"url"`
 | |
| }
 | |
| 
 | |
| // LicensesInfo contains information about a License
 | |
| type LicenseTemplateInfo struct {
 | |
| 	Key            string `json:"key"`
 | |
| 	Name           string `json:"name"`
 | |
| 	URL            string `json:"url"`
 | |
| 	Implementation string `json:"implementation"`
 | |
| 	Body           string `json:"body"`
 | |
| }
 | |
| 
 | |
| // APIError is an api error with a message
 | |
| type APIError struct {
 | |
| 	Message string `json:"message"`
 | |
| 	URL     string `json:"url"`
 | |
| }
 |