Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
84 changes: 84 additions & 0 deletions components/package/list/list.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/* GitHub's package list: the search, type filter and Search button on one line, then a box with a row per package
(its icon, name and type, then the latest version and who published it). */
.theme-package-search {
margin: 0 0 16px;
}

.theme-package-search-controls {
display: flex;
align-items: center;
gap: 8px;
}

.theme-package-search-controls > .theme-search-field {
flex: 1;
}

.theme-package-row {
border: 1px solid var(--color-secondary);
border-bottom: 0;
}

.theme-package-row:first-child {
border-radius: 6px 6px 0 0;
}

.theme-package-row:last-of-type {
border-bottom: 1px solid var(--color-secondary);
border-radius: 0 0 6px 6px;
}

.theme-package-row:only-of-type {
border-radius: var(--border-radius);
}

.theme-package-row > .flex-item {
gap: 16px;
padding: 16px;
}

.theme-package-icon {
flex: none;
color: var(--color-text-light-1);
}

.theme-package-row .flex-item-title {
flex-wrap: wrap;
gap: 8px;
font-size: 16px;
line-height: 24px;
}

.theme-package-row .flex-item-title > a {
color: var(--color-primary);
}

.theme-package-row .flex-item-body {
display: block;
margin-top: 4px;
color: var(--color-text-light-1);
font-size: 12px;
line-height: 18px;
}

.theme-package-version {
margin-right: 12px;
}

@media (max-width: 767px) {
.theme-package-search-controls {
flex-wrap: wrap;
}

.theme-package-search-controls > .theme-search-field {
flex-basis: 100%;
}

.theme-package-search-controls > .theme-select-wrap {
flex: 1;
}

.theme-package-search-controls .theme-select {
width: 100%;
}
}
60 changes: 60 additions & 0 deletions components/package/list/list.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- /* GitHub's package list for a user, an organization or a repository: the search with the type filter, then a box
with a row per package, or the empty state. Called with the page context. */ -}}
{{if .HasPackages}}
<form class="ui form ignore-dirty theme-package-search">
<div class="theme-package-search-controls">
{{template "components/common/search/search" dict "Kind" "plain" "Value" .Query "Placeholder" (ctx.Locale.Tr "search.package_kind")}}
<span class="theme-select-wrap"><select class="theme-select" name="type" aria-label="{{ctx.Locale.Tr "packages.filter.type"}}">
<option value="">{{ctx.Locale.Tr "packages.filter.type"}}</option>
<option value="all">{{ctx.Locale.Tr "packages.filter.type.all"}}</option>
{{range $type := .AvailableTypes}}
<option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
{{end}}
</select></span>
<button class="secondary button theme-control theme-control-wide" type="submit">{{ctx.Locale.Tr "search.search"}}</button>
</div>
</form>
{{end}}
<div class="theme-package-list">
{{range .PackageDescriptors}}
<div class="theme-package-row">
<div class="flex-item">
<div class="theme-package-icon">{{svg .Package.Type.SVGName 24}}</div>
<div class="flex-item-main">
<div class="flex-item-title">
<a href="{{.VersionWebLink}}">{{.Package.Name}}</a>
<span class="ui basic label">{{.Package.Type.Name}}</span>
</div>
<div class="flex-item-body">
<span class="theme-package-version">{{.Version.LowerVersion}}</span>
{{$timeStr := DateUtils.TimeSince .Version.CreatedUnix}}
{{$hasRepositoryAccess := false}}
{{if .Repository}}
{{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}}
{{end}}
{{if $hasRepositoryAccess}}
{{ctx.Locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink .Creator.GetDisplayName .Repository.Link .Repository.FullName}}
{{else}}
{{ctx.Locale.Tr "packages.published_by" $timeStr .Creator.HomeLink .Creator.GetDisplayName}}
{{end}}
</div>
</div>
</div>
</div>
{{else}}
{{if not .HasPackages}}
<div class="theme-empty">
{{svg "octicon-package" 48}}
<h2>{{ctx.Locale.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
{{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}
<p>{{ctx.Locale.Tr "packages.empty.repo" $packagesUrl}}</p>
{{end}}
<p>{{ctx.Locale.Tr "packages.empty.documentation" "https://forgejo.org/docs/latest/user/packages/"}}</p>
</div>
{{else}}
{{template "user/profile_empty" dict "Icon" "octicon-package" "Title" (ctx.Locale.Tr "packages.filter.no_result")}}
{{end}}
{{end}}
</div>
{{template "base/paginate" .}}
2 changes: 1 addition & 1 deletion scripts/assembleForgejo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const copyTemplates = (source: string, target: string): void => {
};
copyTemplates(join(root, "components"), join(templates, "components"));

for (const directory of ["common", "project", "repository"]) {
for (const directory of readdirSync(join(root, "components"))) {
const source = join(root, "components", directory);
for (const component of readdirSync(source, { withFileTypes: true })) {
if (!component.isDirectory()) continue;
Expand Down
16 changes: 16 additions & 0 deletions src/build-output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,22 @@ describe("Forgejo 15 native integration", () => {
expect(read("templates", "repo", "activity.tmpl")).toContain("flex-container github-insights");
});

it("lists a repository's packages like a user's or an organization's", () => {
const read = (...parts: string[]) => fs.readFileSync(path.join(ROOT_DIR, ...parts), "utf-8");
expect(read("templates", "repo", "packages.tmpl")).toContain('{{template "components/package/list/list" .}}');
expect(read("templates", "user", "profile_packages.tmpl")).toContain(
'{{template "components/package/list/list" .}}'
);
// Forgejo's flash message is a classless div; the old list rule boxed it into a stray line.
expect(read("styles", "components", "repo", "packages.ts")).not.toContain("div:not([class])");
expect(read("scripts", "assembleForgejo.ts")).toContain('readdirSync(join(root, "components"))');
expect(
fs.existsSync(
path.join(DIST_DIR, "forgejo", "public", "assets", "css", "components", "package", "list", "list.css")
)
).toBe(true);
});

it("matches GitHub's repository About, visibility, and code-search details", () => {
const headerStyle = fs.readFileSync(path.join(ROOT_DIR, "styles", "templates", "repo", "header.ts"), "utf-8");
const headerTemplate = fs.readFileSync(path.join(ROOT_DIR, "templates", "repo", "home_header.tmpl"), "utf-8");
Expand Down
41 changes: 2 additions & 39 deletions styles/components/repo/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,7 @@
* limitations under the License.
*/

import { css, cssCombine, otherThemeVars, themeVars } from "@lutinglt/gitea-github-theme/core";

const packageList = css`
.page-content.packages > .ui.container > div:not([class]):not(:has(img.ui.avatar)) {
border: 1px solid ${themeVars.color.light.border};
border-radius: ${otherThemeVars.border.radius};
margin-top: 16px;
> .flex-list {
border-top: 1px solid ${themeVars.color.light.border};
&:first-child {
border-top: 0;
}
> .flex-item {
padding: 16px;
.flex-item-title {
gap: 8px;
> a {
min-height: 25px;
}
.ui.label {
background-color: transparent;
border: 1px solid ${themeVars.color.light.border};
color: ${themeVars.color.primary.self};
gap: 4px;
min-height: 24.5px;
padding: 3px 6px;
}
}
.flex-item-body {
font-size: 12px;
a {
text-decoration: underline;
}
}
}
}
}
`;
import { css, cssCombine, themeVars } from "@lutinglt/gitea-github-theme/core";

const packageDetails = css`
.page-content.packages {
Expand Down Expand Up @@ -138,4 +101,4 @@ const packageDetailsMobile = css`
}
`;

export default cssCombine(packageList, packageDetails, packageDetailsMobile);
export default cssCombine(packageDetails, packageDetailsMobile);
51 changes: 0 additions & 51 deletions styles/pages/profile-subpages.css
Original file line number Diff line number Diff line change
Expand Up @@ -266,53 +266,6 @@
line-height: 20px;
}

:is(.github-profile, .github-org) .profile-package-row {
border: 1px solid var(--color-secondary);
border-bottom: 0;
}

:is(.github-profile, .github-org) .profile-package-row:first-child {
border-radius: 6px 6px 0 0;
}

:is(.github-profile, .github-org) .profile-package-row:last-of-type {
border-bottom: 1px solid var(--color-secondary);
border-radius: 0 0 6px 6px;
}

:is(.github-profile, .github-org) .profile-package-row:only-of-type {
border-radius: var(--border-radius);
}

:is(.github-profile, .github-org) .profile-package-row > .flex-item {
gap: 16px;
padding: 16px;
}

:is(.github-profile, .github-org) .profile-package-icon {
flex: none;
color: var(--color-text-light-1);
}

:is(.github-profile, .github-org) .profile-packages .flex-item-title {
flex-wrap: wrap;
gap: 8px;
font-size: 16px;
line-height: 24px;
}

:is(.github-profile, .github-org) .profile-packages .flex-item-body {
display: block;
margin-top: 4px;
color: var(--color-text-light-1);
font-size: 12px;
line-height: 18px;
}

:is(.github-profile, .github-org) .profile-package-version {
margin-right: 12px;
}

:is(.github-profile, .github-org) .profile-package-breadcrumb {
margin: 0 0 16px;
font-size: 14px;
Expand Down Expand Up @@ -363,10 +316,6 @@
border-color: var(--github-borderColor-accent-emphasis);
}

:is(.github-profile, .github-org) .profile-packages .flex-item-title > a {
color: var(--color-primary);
}

:is(.github-profile, .github-org) .profile-subpage-title {
overflow-wrap: anywhere;
}
Expand Down
1 change: 1 addition & 0 deletions templates/base/component_assets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<script src="{{AssetUrlPrefix}}/js/components/common/dropdown/dropdown.js" defer></script>
<script src="{{AssetUrlPrefix}}/js/components/common/dropdown/open-animation.js" defer></script>
<script src="{{AssetUrlPrefix}}/js/branch-selector.js" defer></script>
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/package/list/list.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/branch/branch.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/commit-groups/commit-groups.css">
<link rel="stylesheet" href="{{AssetUrlPrefix}}/css/components/repository/label/list.css">
Expand Down
16 changes: 16 additions & 0 deletions templates/repo/packages.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{/* A repository's packages in the package list a user or organization shows, under a "Packages" heading. */}}
{{template "base/head" .}}
<div role="main" aria-label="{{.Title}}" class="page-content repository packages">
<div class="ui container">
{{if (and .Repository.IsPrivate .Repository.Owner.Visibility.IsPublic)}}
<div class="ui warning message flash-message flash-warning">
{{svg "octicon-alert"}}
{{ctx.Locale.Tr "repo.packages.visibility_warning" .Repository.OwnerName}}
</div>
{{end}}
<div class="theme-list-heading"><div class="theme-list-title"><h1>{{ctx.Locale.Tr "packages.title"}}</h1></div></div>
{{template "base/alert" .}}
{{template "components/package/list/list" .}}
</div>
</div>
{{template "base/footer" .}}
60 changes: 1 addition & 59 deletions templates/user/profile_packages.tmpl
Original file line number Diff line number Diff line change
@@ -1,63 +1,5 @@
<section class="profile-packages">
<h2 class="profile-subpage-title">{{ctx.Locale.Tr "packages.title"}}</h2>
{{template "base/alert" .}}
{{if .HasPackages}}
<form class="ui form ignore-dirty profile-list-search">
<div class="profile-search-controls">
{{template "components/common/search/search" dict "Kind" "plain" "Value" .Query "Placeholder" (ctx.Locale.Tr "search.package_kind")}}
<span class="theme-select-wrap"><select class="theme-select" name="type" aria-label="{{ctx.Locale.Tr "packages.filter.type"}}">
<option value="">{{ctx.Locale.Tr "packages.filter.type"}}</option>
<option value="all">{{ctx.Locale.Tr "packages.filter.type.all"}}</option>
{{range $type := .AvailableTypes}}
<option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
{{end}}
</select></span>
<button class="secondary button theme-control theme-control-wide" type="submit">{{ctx.Locale.Tr "search.search"}}</button>
</div>
</form>
{{end}}
<div class="profile-package-list">
{{range .PackageDescriptors}}
<div class="profile-package-row">
<div class="flex-item">
<div class="profile-package-icon">{{svg .Package.Type.SVGName 24}}</div>
<div class="flex-item-main">
<div class="flex-item-title">
<a href="{{.VersionWebLink}}">{{.Package.Name}}</a>
<span class="ui basic label">{{.Package.Type.Name}}</span>
</div>
<div class="flex-item-body">
<span class="profile-package-version">{{.Version.LowerVersion}}</span>
{{$timeStr := DateUtils.TimeSince .Version.CreatedUnix}}
{{$hasRepositoryAccess := false}}
{{if .Repository}}
{{$hasRepositoryAccess = index $.RepositoryAccessMap .Repository.ID}}
{{end}}
{{if $hasRepositoryAccess}}
{{ctx.Locale.Tr "packages.published_by_in" $timeStr .Creator.HomeLink .Creator.GetDisplayName .Repository.Link .Repository.FullName}}
{{else}}
{{ctx.Locale.Tr "packages.published_by" $timeStr .Creator.HomeLink .Creator.GetDisplayName}}
{{end}}
</div>
</div>
</div>
</div>
{{else}}
{{if not .HasPackages}}
<div class="theme-empty profile-empty">
{{svg "octicon-package" 48}}
<h2>{{ctx.Locale.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
{{$packagesUrl := URLJoin .Owner.HomeLink "-" "packages"}}
<p>{{ctx.Locale.Tr "packages.empty.repo" $packagesUrl}}</p>
{{end}}
<p>{{ctx.Locale.Tr "packages.empty.documentation" "https://forgejo.org/docs/latest/user/packages/"}}</p>
</div>
{{else}}
{{template "user/profile_empty" dict "Icon" "octicon-package" "Title" (ctx.Locale.Tr "packages.filter.no_result")}}
{{end}}
{{end}}
</div>
{{template "base/paginate" .}}

{{template "components/package/list/list" .}}
</section>
Loading