···
"tangled.sh/tangled.sh/core/appview/auth"
"tangled.sh/tangled.sh/core/appview/db"
"tangled.sh/tangled.sh/core/appview/pages/markup"
21
+
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
"tangled.sh/tangled.sh/core/appview/pagination"
24
-
"tangled.sh/tangled.sh/core/appview/state/userutil"
"tangled.sh/tangled.sh/core/patchutil"
"tangled.sh/tangled.sh/core/types"
···
templateDir string // Path to templates on disk for dev mode
43
+
rctx *markup.RenderContext
func NewPages(dev bool) *Pages {
47
+
// initialized with safe defaults, can be overriden per use
48
+
rctx := &markup.RenderContext{
t: make(map[string]*template.Template),
templateDir: "appview/pages",
···
type ForkRepoParams struct {
301
+
RepoInfo repoinfo.RepoInfo
func (p *Pages) ForkRepo(w io.Writer, params ForkRepoParams) error {
···
type RepoDescriptionParams struct {
351
+
RepoInfo repoinfo.RepoInfo
func (p *Pages) EditRepoDescriptionFragment(w io.Writer, params RepoDescriptionParams) error {
···
return p.executePlain("repo/fragments/repoDescription", w, params)
357
-
type RepoInfo struct {
363
-
RepoAt syntax.ATURI
368
-
SourceHandle string
373
-
type RolesInRepo struct {
377
-
func (r RolesInRepo) SettingsAllowed() bool {
378
-
return slices.Contains(r.Roles, "repo:settings")
381
-
func (r RolesInRepo) CollaboratorInviteAllowed() bool {
382
-
return slices.Contains(r.Roles, "repo:invite")
385
-
func (r RolesInRepo) RepoDeleteAllowed() bool {
386
-
return slices.Contains(r.Roles, "repo:delete")
389
-
func (r RolesInRepo) IsOwner() bool {
390
-
return slices.Contains(r.Roles, "repo:owner")
393
-
func (r RolesInRepo) IsCollaborator() bool {
394
-
return slices.Contains(r.Roles, "repo:collaborator")
397
-
func (r RolesInRepo) IsPushAllowed() bool {
398
-
return slices.Contains(r.Roles, "repo:push")
401
-
func (r RepoInfo) OwnerWithAt() string {
402
-
if r.OwnerHandle != "" {
403
-
return fmt.Sprintf("@%s", r.OwnerHandle)
409
-
func (r RepoInfo) FullName() string {
410
-
return path.Join(r.OwnerWithAt(), r.Name)
413
-
func (r RepoInfo) OwnerWithoutAt() string {
414
-
if strings.HasPrefix(r.OwnerWithAt(), "@") {
415
-
return strings.TrimPrefix(r.OwnerWithAt(), "@")
417
-
return userutil.FlattenDid(r.OwnerDid)
421
-
func (r RepoInfo) FullNameWithoutAt() string {
422
-
return path.Join(r.OwnerWithoutAt(), r.Name)
425
-
func (r RepoInfo) GetTabs() [][]string {
426
-
tabs := [][]string{
427
-
{"overview", "/", "square-chart-gantt"},
428
-
{"issues", "/issues", "circle-dot"},
429
-
{"pulls", "/pulls", "git-pull-request"},
432
-
if r.Roles.SettingsAllowed() {
433
-
tabs = append(tabs, []string{"settings", "/settings", "cog"})
439
-
// each tab on a repo could have some metadata:
441
-
// issues -> number of open issues etc.
442
-
// settings -> a warning icon to setup branch protection? idk
444
-
// we gather these bits of info here, because go templates
445
-
// are difficult to program in
446
-
func (r RepoInfo) TabMetadata() map[string]any {
447
-
meta := make(map[string]any)
449
-
if r.Stats.PullCount.Open > 0 {
450
-
meta["pulls"] = r.Stats.PullCount.Open
453
-
if r.Stats.IssueCount.Open > 0 {
454
-
meta["issues"] = r.Stats.IssueCount.Open
type RepoIndexParams struct {
364
+
RepoInfo repoinfo.RepoInfo
TagMap map[string][]string
CommitsTrunc []*object.Commit
···
return p.executeRepo("repo/empty", w, params)
482
-
rctx := markup.RenderContext{
483
-
Ref: params.RepoInfo.Ref,
484
-
FullRepoName: params.RepoInfo.FullName(),
382
+
p.rctx = &markup.RenderContext{
383
+
RepoInfo: params.RepoInfo,
385
+
RendererType: markup.RendererTypeRepoMarkdown,
if params.ReadmeFileName != "" {
···
ext := filepath.Ext(params.ReadmeFileName)
case ".md", ".markdown", ".mdown", ".mkdn", ".mkd":
492
-
htmlString = rctx.RenderMarkdown(params.Readme)
393
+
htmlString = p.rctx.RenderMarkdown(params.Readme)
params.HTMLReadme = template.HTML(bluemonday.UGCPolicy().Sanitize(htmlString))
···
type RepoLogParams struct {
408
+
RepoInfo repoinfo.RepoInfo
TagMap map[string][]string
···
type RepoCommitParams struct {
422
+
RepoInfo repoinfo.RepoInfo
EmailToDidOrHandle map[string]string
···
type RepoTreeParams struct {
436
+
RepoInfo repoinfo.RepoInfo
···
type RepoBranchesParams struct {
472
+
RepoInfo repoinfo.RepoInfo
types.RepoBranchesResponse
···
type RepoTagsParams struct {
484
+
RepoInfo repoinfo.RepoInfo
···
type RepoBlobParams struct {
496
+
RepoInfo repoinfo.RepoInfo
···
switch markup.GetFormat(params.Path) {
case markup.FormatMarkdown:
610
-
rctx := markup.RenderContext{
611
-
Ref: params.RepoInfo.Ref,
612
-
FullRepoName: params.RepoInfo.FullName(),
511
+
p.rctx = &markup.RenderContext{
512
+
RepoInfo: params.RepoInfo,
RendererType: markup.RendererTypeRepoMarkdown,
615
-
params.RenderedContents = template.HTML(rctx.RenderMarkdown(params.Contents))
516
+
params.RenderedContents = template.HTML(p.rctx.RenderMarkdown(params.Contents))
···
type RepoSettingsParams struct {
561
+
RepoInfo repoinfo.RepoInfo
Collaborators []Collaborator
···
type RepoIssuesParams struct {
577
+
RepoInfo repoinfo.RepoInfo
DidHandleMap map[string]string
···
type RepoSingleIssueParams struct {
592
+
RepoInfo repoinfo.RepoInfo
···
type RepoNewIssueParams struct {
614
+
RepoInfo repoinfo.RepoInfo
···
type EditIssueCommentParams struct {
625
+
RepoInfo repoinfo.RepoInfo
···
type SingleIssueCommentParams struct {
DidHandleMap map[string]string
637
+
RepoInfo repoinfo.RepoInfo
···
type RepoNewPullParams struct {
648
+
RepoInfo repoinfo.RepoInfo
···
type RepoPullsParams struct {
660
+
RepoInfo repoinfo.RepoInfo
DidHandleMap map[string]string
···
type RepoSinglePullParams struct {
692
+
RepoInfo repoinfo.RepoInfo
DidHandleMap map[string]string
···
type RepoPullPatchParams struct {
DidHandleMap map[string]string
708
+
RepoInfo repoinfo.RepoInfo
···
type RepoPullInterdiffParams struct {
DidHandleMap map[string]string
723
+
RepoInfo repoinfo.RepoInfo
Interdiff *patchutil.InterdiffResult
···
type PullPatchUploadParams struct {
735
+
RepoInfo repoinfo.RepoInfo
func (p *Pages) PullPatchUploadFragment(w io.Writer, params PullPatchUploadParams) error {
···
type PullCompareBranchesParams struct {
743
+
RepoInfo repoinfo.RepoInfo
···
type PullCompareForkParams struct {
752
+
RepoInfo repoinfo.RepoInfo
···
type PullCompareForkBranchesParams struct {
761
+
RepoInfo repoinfo.RepoInfo
SourceBranches []types.Branch
TargetBranches []types.Branch
···
type PullResubmitParams struct {
772
+
RepoInfo repoinfo.RepoInfo
···
type PullActionsParams struct {
783
+
RepoInfo repoinfo.RepoInfo
MergeCheck types.MergeCheckResponse
···
type PullNewCommentParams struct {
796
+
RepoInfo repoinfo.RepoInfo