-
-
- {{template "repo/cite/cite_buttons" .}}
-
- {{svg "octicon-file-moved"}}
-
-
- diff --git a/modules/git/blob.go b/modules/git/blob.go index 4eef5f0e2a..e2dc624e86 100644 --- a/modules/git/blob.go +++ b/modules/git/blob.go @@ -157,22 +157,6 @@ func (b *Blob) NewTruncatedReader(limit int64) (rc io.ReadCloser, fullSize int64 }, fullSize, nil } -// GetBlobContent Gets the truncated content of the blob as raw text -func (b *Blob) GetBlobContent(limit int64) (string, error) { - if limit <= 0 { - return "", nil - } - rc, fullSize, err := b.NewTruncatedReader(limit) - if err != nil { - return "", err - } - defer rc.Close() - - buf := make([]byte, min(fullSize, limit)) - _, err = io.ReadFull(rc, buf) - return string(buf), err -} - type BlobTooLargeError struct { Size, Limit int64 } diff --git a/modules/git/blob_test.go b/modules/git/blob_test.go index a4b8033941..7caa2d2de3 100644 --- a/modules/git/blob_test.go +++ b/modules/git/blob_test.go @@ -45,24 +45,6 @@ func TestBlob(t *testing.T) { testBlob, err := repo.GetBlob("6c493ff740f9380390d5c9ddef4af18697ac9375") require.NoError(t, err) - t.Run("GetBlobContent", func(t *testing.T) { - r, err := testBlob.GetBlobContent(100) - require.NoError(t, err) - require.Equal(t, "file2\n", r) - - r, err = testBlob.GetBlobContent(-1) - require.NoError(t, err) - require.Empty(t, r) - - r, err = testBlob.GetBlobContent(4) - require.NoError(t, err) - require.Equal(t, "file", r) - - r, err = testBlob.GetBlobContent(6) - require.NoError(t, err) - require.Equal(t, "file2\n", r) - }) - t.Run("GetContentBase64", func(t *testing.T) { r, err := testBlob.GetContentBase64(100) require.NoError(t, err) @@ -140,11 +122,6 @@ func TestBlob(t *testing.T) { nonExistingBlob, err := repo.GetBlob("00003ff740f9380390d5c9ddef4af18690000000") require.NoError(t, err) - r, err := nonExistingBlob.GetBlobContent(100) - require.Error(t, err) - require.IsType(t, ErrNotExist{}, err) - require.Empty(t, r) - rc, size, err := nonExistingBlob.NewTruncatedReader(100) require.Error(t, err) require.IsType(t, ErrNotExist{}, err) diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go index 3b11d73390..5edf1163ae 100644 --- a/routers/web/repo/view.go +++ b/routers/web/repo/view.go @@ -601,6 +601,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) } if !fInfo.isLFSFile { if ctx.Repo.CanEnableEditor(ctx, ctx.Doer) { @@ -778,6 +779,10 @@ 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 @@ -793,16 +798,9 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) { return } for _, entry := range allEntries { - if entry.Name() == "CITATION.cff" || entry.Name() == "CITATION.bib" { - // Read Citation file contents - if content, err := entry.Blob().GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil { - log.Error("checkCitationFile: GetBlobContent: %v", err) - } else { - ctx.Data["CitationExist"] = true - ctx.Data["CitationFile"] = entry.Name() - ctx.PageData["citationFileContent"] = content - break - } + if isCitationFile(entry) { + ctx.Data["CitationFile"] = entry.Name() + break } } } diff --git a/templates/repo/cite/cite_buttons.tmpl b/templates/repo/cite/cite_buttons.tmpl deleted file mode 100644 index 5a6de23c5c..0000000000 --- a/templates/repo/cite/cite_buttons.tmpl +++ /dev/null @@ -1,8 +0,0 @@ - -BibTeX - - - - diff --git a/templates/repo/cite/cite_modal.tmpl b/templates/repo/cite/cite_modal.tmpl deleted file mode 100644 index 1ce959a5c5..0000000000 --- a/templates/repo/cite/cite_modal.tmpl +++ /dev/null @@ -1,20 +0,0 @@ -