Repository navigation
web: migrate the repository code browser to React - #8536
Merged
Merged
Conversation
3 of 4 tasks
unknwon
force-pushed
the
code-react-flamego
branch
4 times, most recently
from
November 14, 2026 07:11
770d79c to
efbc651
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 14, 2026 16:03
2bbe79f to
5d6c503
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 14, 2026 17:11
460f8e2 to
8d9ca79
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:00
2fc7955 to
bb530f6
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 14, 2026 19:34
a45a327 to
6c27ddf
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 14, 2026 20:21
27a3982 to
9b407b0
Compare
unknwon
force-pushed
the
code-react-flamego
branch
5 times, most recently
from
November 14, 2026 23:00
ee8be3a to
939b590
Compare
unknwon
force-pushed
the
code-react-flamego
branch
from
November 14, 2026 23:31
939b590 to
83f93dc
Compare
unknwon
force-pushed
the
code-react-flamego
branch
2 times, most recently
from
November 15, 2026 13:45
4ad1e97 to
9522885
Compare
unknwon
force-pushed
the
code-react-flamego
branch
4 times, most recently
from
November 15, 2026 22:45
a5c8d5c to
f1caa37
Compare
unknwon
force-pushed
the
code-react-flamego
branch
from
November 16, 2026 00:46
f1caa37 to
906a58a
Compare
unknwon
force-pushed
the
code-react-flamego
branch
from
November 16, 2026 01:45
906a58a to
417a301
Compare
unknwon
force-pushed
the
code-react-flamego
branch
from
November 16, 2026 02:24
417a301 to
8fb7046
Compare
unknwon
force-pushed
the
code-react-flamego
branch
from
November 16, 2026 03:07
8fb7046 to
0f4acc7
Compare
4 tasks done
unknwon
marked this pull request as ready for review
November 16, 2026 12:54
The repository home and the files at a branch, a tag or a commit
(/{owner}/{repo}/src/{ref}/{path}) are now a React page backed by
/api/web/{owner}/{repo}/src. A directory lists its entries with their last
commits and shows its README. A file is highlighted with line numbers that
select lines into the URL, or rendered when it is Markdown, Org mode or a
notebook, and images, videos and PDFs show inline. The root shows the
description, the branch and release counts, and a menu with the clone URL
and the archives. An empty repository shows the quick guide.
unknwon
force-pushed
the
code-react-flamego
branch
from
November 16, 2026 12:57
0f4acc7 to
89669e8
Compare
The quick guide's remote URL was always SSH, while the server-rendered page switched it along with the clone URL.
Raw SVG files are served as sandboxed images instead of plain text, so relative SVG images in Markdown load, and images marked #gh-light-mode-only or #gh-dark-mode-only show only in that theme.
Files show the same Pierre icons as the diff file tree, counts of one branch, release or commit are singular, and selected lines in dark mode keep code above 4.5:1.
Markdown, Org mode and notebooks get Preview and Code buttons like GitHub, and ?plain=1 opens the highlighted source with line selection.
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Migrates the repository code browser to React: the repository home (
/{owner}/{repo}) and the files at a branch, a tag or a commit (/{owner}/{repo}/src/{ref}/{path}). Both are backed byGET /api/web/{owner}/{repo}/src/{ref}/{path}, which resolves the ref like the commit history (the shortest leading part that names a branch or a tag, else a commit SHA, else the default branch).@ sha. A ".." row goes up. The first README is shown below, rendered for Markdown and Org mode and as text otherwise.localStoragekey as legacy) and ZIP and TAR.GZ downloads..editorconfig. In dark mode, punctuation is lifted from Pierre's#636363and selected lines are tinted less, so code on them stays above 4.5:1. Clicking or dragging over line numbers writes#L5or#L5-L9, and opening such a link highlights the lines and scrolls to them.?plain=1) shows the highlighted source with line numbers and line selection.MAX_DISPLAY_FILE_SIZElink to the raw file.RefPickerkeeps the path when switching refs, and a breadcrumb links every directory. Writers on an editable branch get "New file" and "Upload file". When the viewer can open a pull request, a compare button goes to the base repository with the same rules as legacy (forks compare against their base)./raw/serves.svgasimage/svg+xmlwithContent-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox, so relative SVG images load and an SVG opened directly cannot run scripts. Images ending in#gh-light-mode-onlyor#gh-dark-mode-onlyshow only in that theme, as on GitHub.repo.Homehandler (view.go) and thehome,view_list,view_file,emptyandbranch_dropdowntemplates, and the notebook<script>tags inbase/head.tmpl, which only these pages used.CloneBoxmoved out of the wiki page so both pages share it, andeditorconfigIndentis now shared by the editor and the file view.repo.file_preview,repo.file_view_mode,repo.code,repo.commit,repo.release,repo.download_archive,repo.file_lineandrepo.file_lines. Sentence-cased "No description", "Quick guide" and "Compare changes".Behavior changes from legacy
<br>and showed the rest as HTML.Screenshots
Repository home (Gogs itself)
File icons
File icons, dark
README with the theme-specific SVG logo
README, dark
A directory with JS, TS, JSON and Markdown
Code menu
File with selected lines, dark
File at a commit (no permalink, editing disabled)
Markdown, Preview
Markdown, Code
Markdown, Code, dark
Notebook, Code
Notebook
PDF
Org mode
Submodule
Tag
Image
Empty repository
Home, dark
Checklist
Test plan
go test ./cmd/gogs/internal/web/ ./internal/git/ ./internal/route/...passes, andTestRequireViewAccesscovers the new endpoint.moon run gogs:lintandmoon run web:lintreport 0 issues.-tags prodbuild with SQLite. Seed: alice owns the publicwidgets, the emptyemptyand the privatesecret. bob can write tosecretand owns the forkbob/widgets. carol has no access.widgetshas Markdown, Org mode, a notebook, a PNG, a PDF, a binary, a symlink and a submodule.master/src/server/long.go(with its.editorconfigtab width), a tag and a commit SHA return the right entries and files. A missing ref or path gets 404, and so does..%2Ftraversal. carol gets 404 onsecret, and alice gets the quick guide onempty. Signed out,editorisno_writeand there is no compare target. bob's fork compares againstalice/widgetsmaster...bob:master./alice/widgets?go-get=1still answers with thego-importmeta tag.#L120-L124link, opened each file kind, and followed Edit into the editor. The wiki's clone box still works. No sideways scroll at 375.mainafter web: migrate the commit compare page to React #8534 and rechecked with a-tags prodbuild.alice/alphagot a README with a relative image, a notebook, an Org file, a PNG, a binary, a nesteddocs/guides/deepand the tagv1.0.0. The home, the Code menu (both archives 200), the nested breadcrumb, the tag picker and switching tolong-history(path kept) all work. Clicking a line number writes#L10, and opening#L121-L123scrolls there and highlights 3 lines, also in a fresh browser. The notebook shows its output, the image shows inline, the binary offers "View raw", and a missing path shows the not-found page (API 404). A new private repository gets 404 from the API andrawfor signed out and bob, and 200 for alice. On a new empty repository, switching the clone box between HTTP and SSH now switches bothgit remote addcommands, and the choice survives a reload. Signed out, the empty repository shows the read-only message.scrollWidthis 375 on the home, a directory and a file.mainintoalice/gogs. Its README shows the light logo in light mode and the dark logo in dark mode, with the badges./raw/main/docs/images/logo-light.svgisimage/svg+xmlwith the sandbox CSP,README.mdstaystext/plain, and an SVG with a<script>opened from/raw/does not run it. The root says "1 Branch", "0 Releases" and "1 Commit". Files get Pierre's icons (Markdown, Git, Go, JSON, JS, TS, HTML), symlinks keep theirs, and the file header uses the same icon. Onlong.go#L121-L123in dark mode, measured contrast on the selected lines is 5.84:1 for punctuation (2.33:1 before), 4.61:1 for function names (3.93:1 before) and 8.1:1 for strings. Light mode is unchanged.README.md, Preview is pressed by default. Code switches to?plain=truewith the highlighted source, Back returns to the preview, and opening?plain=1#L20-L22shows the source with lines 20 to 22 selected. The notebook and the Org file get the same buttons, andlong.gogets none. The header fits at 375px.