mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-02-19 00:57:49 -05:00
feat(ui): dedicated icon for CITATION file (#10873)
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Some checks are pending
/ release (push) Waiting to run
testing-integration / test-unit (push) Waiting to run
testing-integration / test-sqlite (push) Waiting to run
testing-integration / test-mariadb (v10.6) (push) Waiting to run
testing-integration / test-mariadb (v11.8) (push) Waiting to run
testing / backend-checks (push) Waiting to run
testing / frontend-checks (push) Waiting to run
testing / test-unit (push) Blocked by required conditions
testing / test-e2e (push) Blocked by required conditions
testing / test-remote-cacher (redis) (push) Blocked by required conditions
testing / test-remote-cacher (valkey) (push) Blocked by required conditions
testing / test-remote-cacher (garnet) (push) Blocked by required conditions
testing / test-remote-cacher (redict) (push) Blocked by required conditions
testing / test-mysql (push) Blocked by required conditions
testing / test-pgsql (push) Blocked by required conditions
testing / test-sqlite (push) Blocked by required conditions
testing / security-check (push) Blocked by required conditions
Fix forgejo/forgejo#7864 Screenshot: https://codeberg.org/attachments/62fbd43e-fe08-45dd-97a6-224353fd94a9 Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10873 Reviewed-by: 0ko <0ko@noreply.codeberg.org> Co-authored-by: oliverpool <git@olivier.pfad.fr> Co-committed-by: oliverpool <git@olivier.pfad.fr>
This commit is contained in:
parent
a2462adca0
commit
fdf4dfd2a5
4 changed files with 29 additions and 6 deletions
|
|
@ -118,9 +118,17 @@ func EntryIcon(entry *git.TreeEntry) string {
|
|||
return "file-submodule"
|
||||
}
|
||||
|
||||
if IsCitationFile(entry) {
|
||||
return "cross-reference"
|
||||
}
|
||||
|
||||
return "file"
|
||||
}
|
||||
|
||||
func IsCitationFile(entry *git.TreeEntry) bool {
|
||||
return entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib"
|
||||
}
|
||||
|
||||
// SetupGiteaRoot Sets GITEA_ROOT if it is not already set and returns the value
|
||||
func SetupGiteaRoot() string {
|
||||
giteaRoot := os.Getenv("GITEA_ROOT")
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry) {
|
|||
ctx.Data["EscapeStatus"] = status
|
||||
ctx.Data["FileContent"] = fileContent
|
||||
ctx.Data["LineEscapeStatus"] = statuses
|
||||
ctx.Data["IsCitationFile"] = isCitationFile(entry)
|
||||
ctx.Data["IsCitationFile"] = base.IsCitationFile(entry)
|
||||
}
|
||||
if !fInfo.isLFSFile {
|
||||
if ctx.Repo.CanEnableEditor(ctx, ctx.Doer) {
|
||||
|
|
@ -783,10 +783,6 @@ func checkHomeCodeViewable(ctx *context.Context) {
|
|||
ctx.NotFound("Home", errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
|
||||
}
|
||||
|
||||
func isCitationFile(entry *git.TreeEntry) bool {
|
||||
return entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib"
|
||||
}
|
||||
|
||||
func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
|
||||
if entry.Name() != "" {
|
||||
return
|
||||
|
|
@ -802,7 +798,7 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
|
|||
return
|
||||
}
|
||||
for _, entry := range allEntries {
|
||||
if isCitationFile(entry) {
|
||||
if base.IsCitationFile(entry) {
|
||||
ctx.Data["CitationFile"] = entry.Name()
|
||||
break
|
||||
}
|
||||
|
|
|
|||
|
|
@ -188,6 +188,11 @@ func TestRepoViewFileLines(t *testing.T) {
|
|||
TreePath: "seemingly-empty",
|
||||
ContentReader: strings.NewReader("\n"),
|
||||
},
|
||||
{
|
||||
Operation: "create",
|
||||
TreePath: "CITATION.cff",
|
||||
ContentReader: strings.NewReader(""),
|
||||
},
|
||||
})
|
||||
defer f()
|
||||
|
||||
|
|
@ -220,5 +225,18 @@ func TestRepoViewFileLines(t *testing.T) {
|
|||
testEOL(t, "empty", true)
|
||||
testEOL(t, "seemingly-empty", true)
|
||||
})
|
||||
t.Run("list", func(t *testing.T) {
|
||||
defer tests.PrintCurrentTest(t)()
|
||||
req := NewRequest(t, "GET", repo.Link())
|
||||
resp := MakeRequest(t, req, http.StatusOK)
|
||||
htmlDoc := NewHTMLParser(t, resp.Body)
|
||||
|
||||
nodes := htmlDoc.Find("#repo-files-table tr")
|
||||
t.Run("CITATION.cff", func(t *testing.T) {
|
||||
c, ok := nodes.Find(`.name a[title="CITATION.cff"] svg`).Attr("class")
|
||||
assert.True(t, ok, "could not find CITATION.cff line")
|
||||
assert.Contains(t, c, "octicon-cross-reference")
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ td .commit-summary {
|
|||
color: var(--color-primary);
|
||||
}
|
||||
|
||||
.repository.file.list #repo-files-table tbody .svg.octicon-cross-reference,
|
||||
.repository.file.list #repo-files-table tbody .svg.octicon-file,
|
||||
.repository.file.list #repo-files-table tbody .svg.octicon-file-symlink-file,
|
||||
.repository.file.list #repo-files-table tbody .svg.octicon-file-directory-symlink {
|
||||
|
|
|
|||
Loading…
Reference in a new issue