Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub like repo home page #32213

Merged
merged 56 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
83fe8c9
wip
yp05327 Oct 8, 2024
e28398b
fix cite button
yp05327 Oct 8, 2024
ca47b74
fix
yp05327 Oct 8, 2024
4265297
fix
yp05327 Oct 8, 2024
f217245
simpify mobile view
yp05327 Oct 8, 2024
1bf3f66
Merge branch 'main' into github-like-repo-home-page
yp05327 Oct 8, 2024
3652576
improve
yp05327 Oct 8, 2024
4018f54
fix lint
yp05327 Oct 8, 2024
69ab709
fix lint
yp05327 Oct 8, 2024
c2c9a1e
improve
yp05327 Oct 21, 2024
c4b2b95
fix lint
yp05327 Oct 21, 2024
156fdec
fix
yp05327 Oct 21, 2024
69f8601
Merge branch 'main' into github-like-repo-home-page
yp05327 Oct 21, 2024
72d2bbe
fix edit topic
yp05327 Oct 21, 2024
cbb7426
Merge branch 'main' into github-like-repo-home-page
yp05327 Nov 7, 2024
56dd034
add changes from #32383 #32409
yp05327 Nov 7, 2024
16bf69c
Add 'Copy path' button to file view #32584
yp05327 Nov 27, 2024
0dd7935
Fix issues with inconsistent spacing in areas #32607
yp05327 Nov 27, 2024
ba6bd51
Merge branch 'main' into github-like-repo-home-page
yp05327 Nov 28, 2024
176c90d
fix
yp05327 Nov 28, 2024
2e3c4d3
fix ts type issues
yp05327 Nov 28, 2024
4e2480b
Remove jQuery import from some files #32512
yp05327 Nov 28, 2024
3cc6973
follow hiifong's suggestion
yp05327 Nov 28, 2024
eb65b87
fix lint
yp05327 Nov 28, 2024
1597ba5
Merge branch 'main' into github-like-repo-home-page
yp05327 Nov 28, 2024
4455935
fix files table width
yp05327 Dec 3, 2024
d90d552
Merge branch 'main' into github-like-repo-home-page
yp05327 Dec 3, 2024
3720d0e
fix branch-selector-dropdown width
yp05327 Dec 3, 2024
ac44d90
fix lint
yp05327 Dec 3, 2024
c562e11
fix topic overflow bug
yp05327 Dec 3, 2024
5c0e899
fix label word break
yp05327 Dec 3, 2024
536ec4a
move to home.css
yp05327 Dec 4, 2024
d11bf78
add release unit enable check
yp05327 Dec 4, 2024
f651272
simplify the condition
yp05327 Dec 5, 2024
67026e1
simplify the condiftion
yp05327 Dec 5, 2024
4373ad1
remove jQuery
yp05327 Dec 5, 2024
0a2d81c
fix
yp05327 Dec 5, 2024
156a195
Update web_src/js/features/citation.ts
wxiaoguang Dec 5, 2024
db453b5
Update web_src/js/features/citation.ts
wxiaoguang Dec 5, 2024
be1875e
Update web_src/js/features/citation.ts
wxiaoguang Dec 5, 2024
8a865de
remvoe unnecessary code
yp05327 Dec 5, 2024
a4b0b0e
improve
yp05327 Dec 5, 2024
5dbb110
convert into one line
yp05327 Dec 6, 2024
20cf941
improve
yp05327 Dec 6, 2024
e67c4c1
improve
yp05327 Dec 6, 2024
15a1600
fix lint
yp05327 Dec 6, 2024
16d77d8
fix lint
yp05327 Dec 6, 2024
c261174
Merge branch 'main' into github-like-repo-home-page
wxiaoguang Dec 6, 2024
b83d4d0
fix layout
wxiaoguang Dec 6, 2024
2aa1b19
the code SHOULD and MUST match
wxiaoguang Dec 6, 2024
0538c5a
temp fix
wxiaoguang Dec 6, 2024
ca5bfa6
refactor
wxiaoguang Dec 6, 2024
680aee4
remove dead code and fix lint
wxiaoguang Dec 6, 2024
b9e5dcc
change tooltips to title
yp05327 Dec 6, 2024
a6f2570
Merge branch 'main' into github-like-repo-home-page
wxiaoguang Dec 6, 2024
6412de6
fix layout
wxiaoguang Dec 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ confirm_delete_selected = Confirm to delete all selected items?

name = Name
value = Value
readme = Readme

filter = Filter
filter.clear = Clear Filter
Expand Down Expand Up @@ -1035,7 +1036,8 @@ generate_repo = Generate Repository
generate_from = Generate From
repo_desc = Description
repo_desc_helper = Enter short description (optional)
repo_lang = Language
repo_no_desc = No description provided
repo_lang = Languages
repo_gitignore_helper = Select .gitignore templates.
repo_gitignore_helper_desc = Choose which files not to track from a list of templates for common languages. Typical artifacts generated by each language's build tools are included on .gitignore by default.
issue_labels = Issue Labels
Expand Down
21 changes: 21 additions & 0 deletions routers/web/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -903,6 +903,22 @@ func renderLanguageStats(ctx *context.Context) {
ctx.Data["LanguageStats"] = langs
}

func renderLatestRelease(ctx *context.Context) {
release, err := repo_model.GetLatestReleaseByRepoID(ctx, ctx.Repo.Repository.ID)
if err != nil && !repo_model.IsErrReleaseNotExist(err) {
ctx.ServerError("GetLatestReleaseByRepoID", err)
return
}

if release != nil {
if err = release.LoadAttributes(ctx); err != nil {
ctx.ServerError("release.LoadAttributes", err)
return
}
ctx.Data["LatestRelease"] = release
}
}

func renderRepoTopics(ctx *context.Context) {
topics, err := db.Find[repo_model.Topic](ctx, &repo_model.FindTopicOptions{
RepoID: ctx.Repo.Repository.ID,
Expand Down Expand Up @@ -1015,6 +1031,11 @@ func renderHomeCode(ctx *context.Context) {
return
}

renderLatestRelease(ctx)
if ctx.Written() {
return
}

if entry.IsDir() {
renderDirectory(ctx)
} else {
Expand Down
359 changes: 228 additions & 131 deletions templates/repo/home.tmpl

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions templates/repo/sub_menu.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,12 @@
{{svg "octicon-tag"}} <b>{{ctx.Locale.PrettyNumber .NumTags}}</b> {{ctx.Locale.TrN .NumTags "repo.tag" "repo.tags"}}
</a>
{{end}}
{{if .DetectedRepoLicenses}}
<a class="item muted" href="{{.RepoLink}}/src/{{.Repository.DefaultBranch}}/{{PathEscapeSegments .LicenseFileName}}" data-tooltip-placement="top" data-tooltip-content="{{StringUtils.Join .DetectedRepoLicenses ", "}}">
{{svg "octicon-law"}} <b>{{if eq (len .DetectedRepoLicenses) 1}}{{index .DetectedRepoLicenses 0}}{{else}}{{ctx.Locale.Tr "repo.multiple_licenses"}}{{end}}</b>
</a>
{{end}}
<span class="item not-mobile" {{if not (eq .Repository.Size 0)}}data-tooltip-placement="top" data-tooltip-content="{{.Repository.SizeDetailsString}}"{{end}}>
{{$fileSizeFormatted := FileSize .Repository.Size}}{{/* the formatted string is always "{val} {unit}" */}}
{{$fileSizeFields := StringUtils.Split $fileSizeFormatted " "}}
{{svg "octicon-database"}} <b>{{ctx.Locale.PrettyNumber (index $fileSizeFields 0)}}</b> {{index $fileSizeFields 1}}
</span>
{{end}}
</div>
{{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeCode) (not .IsEmptyRepo) .LanguageStats}}
<div class="ui segment sub-menu language-stats-details tw-hidden">
{{range .LanguageStats}}
<div class="item">
<i class="color-icon" style="background-color: {{.Color}}"></i>
<span class="tw-font-semibold">
{{if eq .Language "other"}}
{{ctx.Locale.Tr "repo.language_other"}}
{{else}}
{{.Language}}
{{end}}
</span>
{{.Percentage}}%
</div>
{{end}}
</div>
<a class="ui segment language-stats show-panel toggle" data-panel=".repository-summary > .sub-menu">
{{range .LanguageStats}}
<div class="bar" style="width: {{.Percentage}}%; background-color: {{.Color}}" data-tooltip-placement="top" data-tooltip-content={{.Language}} data-tooltip-follow-cursor="horizontal"></div>
{{end}}
</a>
{{end}}
</div>
{{end}}
7 changes: 7 additions & 0 deletions web_src/css/modules/flexcontainer.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
min-width: 0; /* make the "text truncate" work, otherwise the flex axis is not limited and the text just overflows */
}

.flex-container-repo {
wxiaoguang marked this conversation as resolved.
Show resolved Hide resolved
width: 25%;
}

@media (max-width: 767.98px) {
.flex-container {
flex-direction: column;
Expand All @@ -30,4 +34,7 @@
order: -1;
width: auto;
}
.flex-container-repo {
width: auto;
}
}
21 changes: 20 additions & 1 deletion web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1836,14 +1836,33 @@ td .commit-summary {
background: var(--color-secondary);
}

.repository .repository-summary .segment.language-stats {
.language-stats {
yp05327 marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
gap: 2px;
padding: 0;
height: 10px;
white-space: nowrap;
border-radius: 0 0 3px 3px !important;
overflow: hidden;
width: 100%;
margin-top: 1rem;
margin-bottom: 5px;
}

.language-stats-details {
display: flex;
flex-wrap: wrap;
}

.language-stats-details .item {
height: 30px;
line-height: var(--line-height-default);
display: flex;
align-items: center;
justify-content: center;
gap: 0.25em;
padding: 0 0.5em; /* make the UI look better for narrow (mobile) view */
text-decoration: none;
}

#cite-repo-modal #citation-panel {
Expand Down
11 changes: 5 additions & 6 deletions web_src/js/features/citation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function initCitationFileCopyContent() {
const citationCopyApa = document.querySelector('#citation-copy-apa');
const citationCopyBibtex = document.querySelector('#citation-copy-bibtex');
const inputContent = document.querySelector('#citation-copy-content');
const modal = document.querySelector('#cite-repo-modal');

if ((!citationCopyApa && !citationCopyBibtex) || !inputContent) return;

Expand All @@ -41,9 +42,9 @@ export async function initCitationFileCopyContent() {
citationCopyApa.classList.toggle('primary', !isBibtex);
};

document.querySelector('#cite-repo-button')?.addEventListener('click', async (e) => {
const dropdownBtn = e.target.closest('.ui.dropdown.button');
dropdownBtn.classList.add('is-loading');
document.querySelector('#cite-repo-button')?.addEventListener('click', async () => {
$(modal).modal('show');
lunny marked this conversation as resolved.
Show resolved Hide resolved
$(modal).addClass('is-loading');

try {
try {
Expand All @@ -68,9 +69,7 @@ export async function initCitationFileCopyContent() {
inputContent.select();
});
} finally {
dropdownBtn.classList.remove('is-loading');
$(modal).removeClass('is-loading');
}

$('#cite-repo-modal').modal('show');
});
}
3 changes: 2 additions & 1 deletion web_src/js/features/repo-home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ export function initRepoTopicBar() {
topicArray.sort();
for (const topic of topicArray) {
// it should match the code in repo/home.tmpl
// TODO: sort items in topicDropdown, or items in edit div will have different order to the items in view div
const link = document.createElement('a');
link.classList.add('repo-topic', 'ui', 'large', 'label');
link.href = `${appSubUrl}/explore/repos?q=${encodeURIComponent(topic)}&topic=1`;
link.textContent = topic;
mgrBtn.parentNode.insertBefore(link, mgrBtn); // insert all new topics before manage button
viewDiv.append(link);
}
}
hideElem(editDiv);
Expand Down
Loading