Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gitea Profile Readmes #23260

Merged
merged 45 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
67fca4c
Preliminary md injection
LAX18 Mar 2, 2023
067cb77
Hardcoded .profile fetch in profile
LAX18 Mar 2, 2023
ec75550
Complete - User Profile MD V.1
LAX18 Mar 3, 2023
31c95d2
Merge branch 'go-gitea:main' into main
LAX18 Mar 3, 2023
dd184eb
Cleaning Up - Added Comment, Better Var Naming
LAX18 Mar 3, 2023
ac2721b
Boot out the hitchhiking Go binary
LAX18 Mar 3, 2023
687ecd5
Additional Cleanup, Passed Lint, Docs
LAX18 Mar 3, 2023
a90dce2
Optimization, Squash GitRepo Bug
LAX18 Mar 3, 2023
67d8115
Will use default branch
LAX18 Mar 3, 2023
4ef8df2
Fail's quietely - Won't Disrupt Tests
LAX18 Mar 3, 2023
f9dcf37
pull via git instead of http
techknowlogick Mar 3, 2023
b569e00
Merge pull request #1 from techknowlogick/profile
LAX18 Mar 3, 2023
c27e5ea
Created Overview Tab, Moved Profile Display
LAX18 Mar 3, 2023
d187f13
Use Repo Default Branch
LAX18 Mar 3, 2023
3920bda
Merge branch 'main' into main
LAX18 Mar 3, 2023
3c1e17a
Merge branch 'main' into main
LAX18 Mar 4, 2023
e36847d
When no README present, Don't display anything
LAX18 Mar 5, 2023
3f7890e
Oversight, remove TODO
LAX18 Mar 5, 2023
5ef464a
Add return statements to errors
LAX18 Mar 9, 2023
d13aad6
Merge branch 'go-gitea:main' into main
LAX18 Mar 14, 2023
e8103ba
Rebase - Bring Up To Date
LAX18 Mar 22, 2023
8a9b758
Merge branch 'main' into main
LAX18 Mar 22, 2023
70a0261
Migration to new CSS structure
LAX18 Mar 22, 2023
27245a5
Merge branch 'main' of https://github.com/LAX18/gitea into main
LAX18 Mar 22, 2023
277191a
Update docs/content/doc/usage/profile-readme.en-us.md as per recommen…
LAX18 Mar 23, 2023
3a105ad
Update docs/content/doc/usage/profile-readme.en-us.md as per suggestion
LAX18 Mar 23, 2023
92b4ee8
Merge branch 'main' into main
LAX18 Apr 19, 2023
8aede6e
Consolidate else and if statements in accordance with @lunny's sugges…
LAX18 Apr 19, 2023
0718169
Merge branch 'main' into main
LAX18 Apr 19, 2023
782ffb7
Merge branch 'main' into main
LAX18 Apr 25, 2023
c14f567
Refactor Logic
LAX18 Apr 25, 2023
1288de9
Update routers/web/user/profile.go
LAX18 Apr 26, 2023
0f5feed
Update routers/web/user/profile.go
LAX18 Apr 26, 2023
e5caf8f
Formatting Changes
LAX18 Apr 26, 2023
b642c2e
Merge branch 'main' into main
LAX18 Apr 26, 2023
34574ad
Working Again
LAX18 Apr 26, 2023
1cb8d40
Update docs/content/doc/usage/profile-readme.en-us.md
lunny May 2, 2023
a1588e8
Updates to .profile docs
LAX18 May 8, 2023
881d52b
Show .ProfileButton on all profile tabs
LAX18 May 9, 2023
c63f191
Unified Profile Menubar
LAX18 May 9, 2023
9dab776
Merge pull request #3 from LAX18/profile-tabs-consolidate
LAX18 May 9, 2023
c4bf572
Merge branch 'main' into main
LAX18 May 9, 2023
c0675e4
Refactor to remove unneeded and duplicate code
LAX18 May 9, 2023
623d562
Rework Templates to save duplicate code
LAX18 May 9, 2023
0ec40c4
Merge branch 'main' into main
GiteaBot May 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions docs/content/doc/usage/profile-readme.en-us.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
date: "2023-03-02T21:00:00+05:00"
title: "Usage: Gitea Profile README's"
LAX18 marked this conversation as resolved.
Show resolved Hide resolved
slug: "profile-readme"
weight: 12
toc: false
draft: false
menu:
sidebar:
parent: "usage"
name: "Gitea Profile README's"
LAX18 marked this conversation as resolved.
Show resolved Hide resolved
weight: 12
identifier: "profile-readme"
---

# Gitea Profile README's
lunny marked this conversation as resolved.
Show resolved Hide resolved

To display a markdown file in your Gitea profile page, simply make a repository named ".profile" and edit the README.md file inside. Gitea will automatically pull this file in and display it above your repositories
24 changes: 24 additions & 0 deletions routers/web/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package user

import (
"fmt"
"io"
"net/http"
"strings"

Expand Down Expand Up @@ -90,6 +91,29 @@ func Profile(ctx *context.Context) {
ctx.Data["RenderedDescription"] = content
}

// Fetches user's .profile/README.md and adds it to the users profile (if it exists)
resp, err := http.Get(setting.AppURL + ctx.ContextUser.Name + "/.profile/raw/branch/main/README.md")
LAX18 marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
ctx.ServerError("RenderString", err)
return
}
defer resp.Body.Close()
bytes, err := io.ReadAll(resp.Body)
if err != nil {
ctx.ServerError("RenderString", err)
return
}
profileContent, err := markdown.RenderString(&markup.RenderContext{
Ctx: ctx,
}, string(bytes))
if err != nil {
ctx.ServerError("RenderString", err)
return
}
if resp.StatusCode == 200 {
ctx.Data["ReadmeProfile"] = profileContent
}

showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)

orgs, err := organization.FindOrgs(organization.FindOrgOptions{
Expand Down
3 changes: 3 additions & 0 deletions templates/user/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
</div>
</div>
<div class="ui eleven wide column">
{{if .ReadmeProfile}}
<div id="readme_profile" class="render-content markup"> {{$.ReadmeProfile|Str2html}} </div>
{{end}}
<div class="ui secondary stackable pointing tight menu">
<a class='{{if and (ne .TabName "activity") (ne .TabName "following") (ne .TabName "followers") (ne .TabName "stars") (ne .TabName "watching") (ne .TabName "projects") (ne .TabName "code")}}active {{end}}item' href="{{.Owner.HomeLink}}">
{{svg "octicon-repo"}} {{.locale.Tr "user.repositories"}}
Expand Down
7 changes: 7 additions & 0 deletions web_src/less/_user.less
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,10 @@
#notification_div .tab.segment {
overflow-x: auto;
}

#readme_profile {
padding: 10px;
border-radius: 0.28571429rem;
background: var(--color-card);
border: 1px solid var(--color-secondary);
}