Signed-off-by: Anirudh Oppiliappan anirudh@tangled.org
ERROR
appview/pages/templates/fragments/dolly/logo.html
ERROR
appview/pages/templates/fragments/dolly/logo.html
Failed to calculate interdiff for this file.
ERROR
appview/pages/templates/fragments/dolly/logo.svg
ERROR
appview/pages/templates/fragments/dolly/logo.svg
Failed to calculate interdiff for this file.
ERROR
appview/pages/templates/goodfirstissues/index.html
ERROR
appview/pages/templates/goodfirstissues/index.html
Failed to calculate interdiff for this file.
REBASED
appview/pages/templates/layouts/base.html
REBASED
appview/pages/templates/layouts/base.html
This patch was likely rebased, as context lines do not match.
REBASED
appview/pages/templates/layouts/profilebase.html
REBASED
appview/pages/templates/layouts/profilebase.html
This patch was likely rebased, as context lines do not match.
ERROR
appview/pages/templates/repo/index.html
ERROR
appview/pages/templates/repo/index.html
Failed to calculate interdiff for this file.
ERROR
appview/pages/templates/timeline/home.html
ERROR
appview/pages/templates/timeline/home.html
Failed to calculate interdiff for this file.
ERROR
appview/state/router.go
ERROR
appview/state/router.go
Failed to calculate interdiff for this file.
ERROR
appview/state/state.go
ERROR
appview/state/state.go
Failed to calculate interdiff for this file.
NEW
appview/pages/repoinfo/repoinfo.go
NEW
appview/pages/repoinfo/repoinfo.go
···
1
1
package repoinfo
2
2
3
3
import (
4
+
"encoding/json"
4
5
"fmt"
5
6
"path"
6
7
"slices"
···
117
118
func (r RolesInRepo) IsPushAllowed() bool {
118
119
return slices.Contains(r.Roles, "repo:push")
119
120
}
121
+
122
+
// PrimaryLanguage returns the first (most used) language from a list, or empty string if none
123
+
func PrimaryLanguage(languages []interface{}) string {
124
+
if len(languages) == 0 {
125
+
return ""
126
+
}
127
+
128
+
// Languages are already sorted by percentage in descending order
129
+
// Just get the first one
130
+
if firstLang, ok := languages[0].(map[string]interface{}); ok {
131
+
if name, ok := firstLang["Name"].(string); ok {
132
+
return name
133
+
}
134
+
}
135
+
136
+
return ""
137
+
}
138
+
139
+
// StructuredData generates Schema.org JSON-LD structured data for the repository
140
+
func (r RepoInfo) StructuredData(primaryLanguage string) string {
141
+
data := map[string]interface{}{
142
+
"@context": "https://schema.org",
143
+
"@type": "SoftwareSourceCode",
144
+
"name": r.Name,
145
+
"description": r.Description,
146
+
"codeRepository": "https://tangled.org/" + r.FullName(),
147
+
"url": "https://tangled.org/" + r.FullName(),
148
+
"author": map[string]interface{}{
149
+
"@type": "Person",
150
+
"name": r.owner(),
151
+
"url": "https://tangled.org/" + r.owner(),
152
+
},
153
+
}
154
+
155
+
// Add programming language if available
156
+
if primaryLanguage != "" {
157
+
data["programmingLanguage"] = primaryLanguage
158
+
}
159
+
160
+
jsonBytes, err := json.Marshal(data)
161
+
if err != nil {
162
+
return "{}"
163
+
}
164
+
return string(jsonBytes)
165
+
}
NEW
appview/pages/templates/repo/issues/fragments/og.html
NEW
appview/pages/templates/repo/issues/fragments/og.html
···
1
-
{{ define "repo/issues/fragments/og" }}
2
-
{{ $title := printf "%s #%d" .Issue.Title .Issue.IssueId }}
3
-
{{ $description := or .Issue.Body .RepoInfo.Description }}
4
-
{{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
5
-
{{ $imageUrl := printf "https://tangled.org/%s/issues/%d/opengraph" .RepoInfo.FullName .Issue.IssueId }}
6
-
7
-
<meta property="og:title" content="{{ unescapeHtml $title }}" />
8
-
<meta property="og:type" content="object" />
9
-
<meta property="og:url" content="{{ $url }}" />
10
-
<meta property="og:description" content="{{ $description }}" />
11
-
<meta property="og:image" content="{{ $imageUrl }}" />
12
-
<meta property="og:image:width" content="1200" />
13
-
<meta property="og:image:height" content="600" />
14
-
15
-
<meta name="twitter:card" content="summary_large_image" />
16
-
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
17
-
<meta name="twitter:description" content="{{ $description }}" />
18
-
<meta name="twitter:image" content="{{ $imageUrl }}" />
19
-
{{ end }}
NEW
appview/pages/templates/repo/pulls/fragments/og.html
NEW
appview/pages/templates/repo/pulls/fragments/og.html
···
1
-
{{ define "repo/pulls/fragments/og" }}
2
-
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
3
-
{{ $description := or .Pull.Body .RepoInfo.Description }}
4
-
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
5
-
{{ $imageUrl := printf "https://tangled.org/%s/pulls/%d/opengraph" .RepoInfo.FullName .Pull.PullId }}
1
+
{{ define "pulls/fragments/og" }}
2
+
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
3
+
{{ $description := or .Pull.Body .RepoInfo.Description }}
4
+
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
5
+
{{ $imageUrl := printf "https://tangled.org/%s/pulls/%d/opengraph" .RepoInfo.FullName .Pull.PullId }}
6
6
7
-
<meta property="og:title" content="{{ unescapeHtml $title }}" />
8
-
<meta property="og:type" content="object" />
9
-
<meta property="og:url" content="{{ $url }}" />
10
-
<meta property="og:description" content="{{ $description }}" />
11
-
<meta property="og:image" content="{{ $imageUrl }}" />
12
-
<meta property="og:image:width" content="1200" />
13
-
<meta property="og:image:height" content="600" />
7
+
<meta property="og:title" content="{{ unescapeHtml $title }}" />
8
+
<meta property="og:type" content="object" />
9
+
<meta property="og:url" content="{{ $url }}" />
10
+
<meta property="og:description" content="{{ $description }}" />
11
+
<meta property="og:image" content="{{ $imageUrl }}" />
12
+
<meta property="og:image:width" content="1200" />
13
+
<meta property="og:image:height" content="600" />
14
14
15
-
<meta name="twitter:card" content="summary_large_image" />
16
-
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
17
-
<meta name="twitter:description" content="{{ $description }}" />
18
-
<meta name="twitter:image" content="{{ $imageUrl }}" />
15
+
<meta name="twitter:card" content="summary_large_image" />
16
+
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
17
+
<meta name="twitter:description" content="{{ $description }}" />
18
+
<meta name="twitter:image" content="{{ $imageUrl }}" />
19
19
{{ end }}