back interdiff of round #1 and #0

appview/pages: seo improvements, sitemap, schemae and more #676

open
opened by anirudh.fi targeting master from push-wmkmzrsvlkmk
files
appview
pages
repoinfo
templates
fragments
goodfirstissues
layouts
repo
issues
fragments
pulls
fragments
timeline
state
ERROR
appview/pages/templates/fragments/breadcrumb.html

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/fragments/dolly/logo.html

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/fragments/dolly/logo.svg

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/goodfirstissues/index.html

Failed to calculate interdiff for this file.

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

This patch was likely rebased, as context lines do not match.

ERROR
appview/pages/templates/repo/index.html

Failed to calculate interdiff for this file.

ERROR
appview/pages/templates/timeline/home.html

Failed to calculate interdiff for this file.

ERROR
appview/state/router.go

Failed to calculate interdiff for this file.

ERROR
appview/state/state.go

Failed to calculate interdiff for this file.

NEW
appview/pages/repoinfo/repoinfo.go
···
package repoinfo
import (
"fmt"
"path"
"slices"
···
func (r RolesInRepo) IsPushAllowed() bool {
return slices.Contains(r.Roles, "repo:push")
}
···
package repoinfo
import (
+
"encoding/json"
"fmt"
"path"
"slices"
···
func (r RolesInRepo) IsPushAllowed() bool {
return slices.Contains(r.Roles, "repo:push")
}
+
+
// PrimaryLanguage returns the first (most used) language from a list, or empty string if none
+
func PrimaryLanguage(languages []interface{}) string {
+
if len(languages) == 0 {
+
return ""
+
}
+
+
// Languages are already sorted by percentage in descending order
+
// Just get the first one
+
if firstLang, ok := languages[0].(map[string]interface{}); ok {
+
if name, ok := firstLang["Name"].(string); ok {
+
return name
+
}
+
}
+
+
return ""
+
}
+
+
// StructuredData generates Schema.org JSON-LD structured data for the repository
+
func (r RepoInfo) StructuredData(primaryLanguage string) string {
+
data := map[string]interface{}{
+
"@context": "https://schema.org",
+
"@type": "SoftwareSourceCode",
+
"name": r.Name,
+
"description": r.Description,
+
"codeRepository": "https://tangled.org/" + r.FullName(),
+
"url": "https://tangled.org/" + r.FullName(),
+
"author": map[string]interface{}{
+
"@type": "Person",
+
"name": r.owner(),
+
"url": "https://tangled.org/" + r.owner(),
+
},
+
}
+
+
// Add programming language if available
+
if primaryLanguage != "" {
+
data["programmingLanguage"] = primaryLanguage
+
}
+
+
jsonBytes, err := json.Marshal(data)
+
if err != nil {
+
return "{}"
+
}
+
return string(jsonBytes)
+
}
NEW
appview/pages/templates/repo/issues/fragments/og.html
···
-
{{ define "repo/issues/fragments/og" }}
-
{{ $title := printf "%s #%d" .Issue.Title .Issue.IssueId }}
-
{{ $description := or .Issue.Body .RepoInfo.Description }}
-
{{ $url := printf "https://tangled.org/%s/issues/%d" .RepoInfo.FullName .Issue.IssueId }}
-
{{ $imageUrl := printf "https://tangled.org/%s/issues/%d/opengraph" .RepoInfo.FullName .Issue.IssueId }}
-
-
<meta property="og:title" content="{{ unescapeHtml $title }}" />
-
<meta property="og:type" content="object" />
-
<meta property="og:url" content="{{ $url }}" />
-
<meta property="og:description" content="{{ $description }}" />
-
<meta property="og:image" content="{{ $imageUrl }}" />
-
<meta property="og:image:width" content="1200" />
-
<meta property="og:image:height" content="600" />
-
-
<meta name="twitter:card" content="summary_large_image" />
-
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
-
<meta name="twitter:description" content="{{ $description }}" />
-
<meta name="twitter:image" content="{{ $imageUrl }}" />
-
{{ end }}
···
NEW
appview/pages/templates/repo/pulls/fragments/og.html
···
-
{{ define "repo/pulls/fragments/og" }}
-
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
-
{{ $description := or .Pull.Body .RepoInfo.Description }}
-
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
-
{{ $imageUrl := printf "https://tangled.org/%s/pulls/%d/opengraph" .RepoInfo.FullName .Pull.PullId }}
-
<meta property="og:title" content="{{ unescapeHtml $title }}" />
-
<meta property="og:type" content="object" />
-
<meta property="og:url" content="{{ $url }}" />
-
<meta property="og:description" content="{{ $description }}" />
-
<meta property="og:image" content="{{ $imageUrl }}" />
-
<meta property="og:image:width" content="1200" />
-
<meta property="og:image:height" content="600" />
-
<meta name="twitter:card" content="summary_large_image" />
-
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
-
<meta name="twitter:description" content="{{ $description }}" />
-
<meta name="twitter:image" content="{{ $imageUrl }}" />
{{ end }}
···
+
{{ define "pulls/fragments/og" }}
+
{{ $title := printf "%s #%d" .Pull.Title .Pull.PullId }}
+
{{ $description := or .Pull.Body .RepoInfo.Description }}
+
{{ $url := printf "https://tangled.org/%s/pulls/%d" .RepoInfo.FullName .Pull.PullId }}
+
{{ $imageUrl := printf "https://tangled.org/%s/pulls/%d/opengraph" .RepoInfo.FullName .Pull.PullId }}
+
<meta property="og:title" content="{{ unescapeHtml $title }}" />
+
<meta property="og:type" content="object" />
+
<meta property="og:url" content="{{ $url }}" />
+
<meta property="og:description" content="{{ $description }}" />
+
<meta property="og:image" content="{{ $imageUrl }}" />
+
<meta property="og:image:width" content="1200" />
+
<meta property="og:image:height" content="600" />
+
<meta name="twitter:card" content="summary_large_image" />
+
<meta name="twitter:title" content="{{ unescapeHtml $title }}" />
+
<meta name="twitter:description" content="{{ $description }}" />
+
<meta name="twitter:image" content="{{ $imageUrl }}" />
{{ end }}