summaryrefslogtreecommitdiff
path: root/internal/showcase
diff options
context:
space:
mode:
Diffstat (limited to 'internal/showcase')
-rw-r--r--internal/showcase/showcase.go12
-rw-r--r--internal/showcase/showcase_test.go19
2 files changed, 28 insertions, 3 deletions
diff --git a/internal/showcase/showcase.go b/internal/showcase/showcase.go
index 9cf43a6..c6154f9 100644
--- a/internal/showcase/showcase.go
+++ b/internal/showcase/showcase.go
@@ -27,6 +27,7 @@ type ProjectSummary struct {
Summary string
CodebergURL string
GitHubURL string
+ CgitURL string
Metadata *RepoMetadata
RankHistory []RepoRankHistory // Latest 5 weekly rank points, newest first
Images []string // Relative paths to images in showcase directory
@@ -669,9 +670,10 @@ func (g *Generator) getRepositories() ([]string, error) {
return repos, nil
}
-func (g *Generator) buildProjectLinks(repoName string) (string, string) {
+func (g *Generator) buildProjectLinks(repoName string) (string, string, string) {
codebergURL := ""
githubURL := ""
+ cgitURL := fmt.Sprintf("https://cgit.f3s.buetow.org/%s/", repoName)
if codebergOrg := g.config.FindCodebergOrg(); codebergOrg != nil {
codebergURL = fmt.Sprintf("https://codeberg.org/%s/%s", codebergOrg.Name, repoName)
@@ -681,7 +683,7 @@ func (g *Generator) buildProjectLinks(repoName string) (string, string) {
githubURL = fmt.Sprintf("https://github.com/%s/%s", githubOrg.Name, repoName)
}
- return codebergURL, githubURL
+ return codebergURL, githubURL, cgitURL
}
func (g *Generator) prepareStatsRepoPath(repoName, repoPath string) (string, func() error, error) {
@@ -833,7 +835,7 @@ func (g *Generator) generateProjectSummary(repoName string, forceRegenerate bool
summary = sanitizeSummaryForGemtext(summary)
// Build URLs
- codebergURL, githubURL := g.buildProjectLinks(repoName)
+ codebergURL, githubURL, cgitURL := g.buildProjectLinks(repoName)
// Always extract images from README (not cached)
fmt.Printf("Extracting images from README...\n")
@@ -865,6 +867,7 @@ func (g *Generator) generateProjectSummary(repoName string, forceRegenerate bool
Summary: summary,
CodebergURL: codebergURL,
GitHubURL: githubURL,
+ CgitURL: cgitURL,
Metadata: metadata,
Images: images,
CodeSnippet: codeSnippet,
@@ -1078,6 +1081,9 @@ func (g *Generator) formatGemtext(summaries []ProjectSummary) string {
if summary.GitHubURL != "" {
builder.WriteString(fmt.Sprintf("=> %s View on GitHub\n", summary.GitHubURL))
}
+ if summary.CgitURL != "" {
+ builder.WriteString(fmt.Sprintf("=> %s View in cgit\n", summary.CgitURL))
+ }
}
diff --git a/internal/showcase/showcase_test.go b/internal/showcase/showcase_test.go
index fa18799..cd571f8 100644
--- a/internal/showcase/showcase_test.go
+++ b/internal/showcase/showcase_test.go
@@ -148,6 +148,25 @@ func TestFormatGemtext_SanitizesMarkdownHeadingsInSummary(t *testing.T) {
}
}
+func TestFormatGemtext_IncludesCgitLink(t *testing.T) {
+ t.Parallel()
+
+ g := &Generator{config: &config.Config{}}
+ content := g.formatGemtext([]ProjectSummary{
+ {
+ Name: "cpuinfo",
+ Summary: "summary",
+ CodebergURL: "https://codeberg.org/snonux/cpuinfo",
+ GitHubURL: "https://github.com/snonux/cpuinfo",
+ CgitURL: "https://cgit.f3s.buetow.org/cpuinfo/",
+ },
+ })
+
+ if !strings.Contains(content, "=> https://cgit.f3s.buetow.org/cpuinfo/ View in cgit\n") {
+ t.Fatalf("cgit link was not rendered: %s", content)
+ }
+}
+
func TestFindReadmeContent_UsesRepoPathWithoutChangingCWD(t *testing.T) {
t.Parallel()