Skip to content

Conversation

@earl-warren
Copy link
Contributor

  • The <title> element that lives inside the <head> element is an important element that gives browsers and search engine crawlers the title of the webpage, hence the element name. It's therefor important that this title is accurate.
  • Currently there are three issues with titles on repositories. It doesn't use the FullName and instead only uses the repository name, this doesn't distinguish which user or organisation the repository is on. It doesn't show the full treepath in the title when visiting an file inside a directory and instead only uses the latest path in treepath. It can show the repository name twice if the .Title variable also included the repository name such as on the repository homepage.
  • Use the repository's fullname (which include which user the repository is on) instead of just their name.
  • Display the repository's fullname if it isn't already in .Title.
  • Use the full treepath in the repository code view instead of just the last path.
  • Adds integration tests.
  • Adds a new repository (repo59) that has 3 depths for folders, which wasn't in any other fixture repository yet, so the full treepath for could be properly tested.
  • Resolves https://codeberg.org/forgejo/forgejo/issues/1276

(cherry picked from commit 8712eaa394053a8c8f1f4cb17307e094c65c7059)

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Sep 11, 2023
- The `<title>` element that lives inside the `<head>` element is an important element that gives browsers and search engine crawlers the title of the webpage, hence the element name. It's therefor important that this title is accurate.
- Currently there are three issues with titles on repositories. It doesn't use the `FullName` and instead only uses the repository name, this doesn't distinguish which user or organisation the repository is on. It doesn't show the full treepath in the title when visiting an file inside a directory and instead only uses the latest path in treepath. It can show the repository name twice if the `.Title` variable also included the repository name such as on the repository homepage.
- Use the repository's fullname (which include which user the repository is on) instead of just their name.
- Display the repository's fullname if it isn't already in `.Title`.
- Use the full treepath in the repository code view instead of just the
last path.
- Adds integration tests.
- Adds a new repository (`repo59`) that has 3 depths for folders, which
wasn't in any other fixture repository yet, so the full treepath for
could be properly tested.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1276

(cherry picked from commit 8712eaa394053a8c8f1f4cb17307e094c65c7059)
@silverwind
Copy link
Member

silverwind commented Sep 11, 2023

It doesn't show the full treepath in the title when visiting an file inside a directory and instead only uses the latest path in treepath

This path shortening is intentional, otherwise with deeply nested files, the tab title would become unreadable if all you see is directory names, given that usually there is only around ~20-50 characters available on a tab title. This behaviour matches GitHub and I want to keep it.

defer dataRc.Close()

ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+path.Base(ctx.Repo.TreePath), ctx.Repo.RefName)
ctx.Data["Title"] = ctx.Tr("repo.file.title", ctx.Repo.Repository.Name+"/"+util.PathEscapeSegments(ctx.Repo.TreePath), ctx.Repo.RefName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And the code is wrong: do not do double-escaping.

I also agree to keep the short title, do not show the full path. For example, many languages like Java/PHP have quite deep paths.

Copy link
Member

@silverwind silverwind Sep 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly GitHub shows the full path currently when viewing files, but I assume that is a regression from their recent react rewrite of the file view, not an intentional change. In any case I prefer the current short paths.

Original short title was added in #17987.

@go-gitea go-gitea locked as resolved and limited conversation to collaborators Dec 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants