Mirror of @tangled.org/core. Running on a Raspberry Pi Zero 2 (Please be gentle).
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

appview: add personal pronouns to profile

Signed-off-by: Shalabh Agarwal <me@serendipty01.dev>

fixes: https://tangled.org/@tangled.org/core/issues/224

authored by

Shalabh Agarwal and committed by
Tangled
df2a0d82 1b21764c

+63 -6
api/tangled/actorprofile.go

This is a binary file and will not be displayed.

+7
appview/db/db.go
··· 1106 1106 return err 1107 1107 }) 1108 1108 1109 + runMigration(conn, logger, "add-pronouns-profile", func(tx *sql.Tx) error { 1110 + _, err := tx.Exec(` 1111 + alter table profile add column pronouns text; 1112 + `) 1113 + return err 1114 + }) 1115 + 1109 1116 return &DB{ 1110 1117 db, 1111 1118 logger,
+26 -6
appview/db/profile.go
··· 129 129 did, 130 130 description, 131 131 include_bluesky, 132 - location 132 + location, 133 + pronouns 133 134 ) 134 - values (?, ?, ?, ?)`, 135 + values (?, ?, ?, ?, ?)`, 135 136 profile.Did, 136 137 profile.Description, 137 138 includeBskyValue, 138 139 profile.Location, 140 + profile.Pronouns, 139 141 ) 140 142 141 143 if err != nil { ··· 218 216 did, 219 217 description, 220 218 include_bluesky, 221 - location 219 + location, 220 + pronouns 222 221 from 223 222 profile 224 223 %s`, ··· 234 231 for rows.Next() { 235 232 var profile models.Profile 236 233 var includeBluesky int 234 + var pronouns sql.Null[string] 237 235 238 - err = rows.Scan(&profile.ID, &profile.Did, &profile.Description, &includeBluesky, &profile.Location) 236 + err = rows.Scan(&profile.ID, &profile.Did, &profile.Description, &includeBluesky, &profile.Location, &pronouns) 239 237 if err != nil { 240 238 return nil, err 241 239 } 242 240 243 241 if includeBluesky != 0 { 244 242 profile.IncludeBluesky = true 243 + } 244 + 245 + if pronouns.Valid { 246 + profile.Pronouns = pronouns.V 245 247 } 246 248 247 249 profileMap[profile.Did] = &profile ··· 310 302 311 303 func GetProfile(e Execer, did string) (*models.Profile, error) { 312 304 var profile models.Profile 305 + var pronouns sql.Null[string] 306 + 313 307 profile.Did = did 314 308 315 309 includeBluesky := 0 310 + 316 311 err := e.QueryRow( 317 - `select description, include_bluesky, location from profile where did = ?`, 312 + `select description, include_bluesky, location, pronouns from profile where did = ?`, 318 313 did, 319 - ).Scan(&profile.Description, &includeBluesky, &profile.Location) 314 + ).Scan(&profile.Description, &includeBluesky, &profile.Location, &pronouns) 320 315 if err == sql.ErrNoRows { 321 316 profile := models.Profile{} 322 317 profile.Did = did ··· 332 321 333 322 if includeBluesky != 0 { 334 323 profile.IncludeBluesky = true 324 + } 325 + 326 + if pronouns.Valid { 327 + profile.Pronouns = pronouns.V 335 328 } 336 329 337 330 rows, err := e.Query(`select link from profile_links where did = ?`, did) ··· 427 412 // ensure description is not too long 428 413 if len(profile.Location) > 40 { 429 414 return fmt.Errorf("Entered location is too long.") 415 + } 416 + 417 + // ensure pronouns are not too long 418 + if len(profile.Pronouns) > 40 { 419 + return fmt.Errorf("Entered pronouns are too long.") 430 420 } 431 421 432 422 // ensure links are in order
+6
appview/ingester.go
··· 291 291 292 292 includeBluesky := record.Bluesky 293 293 294 + pronouns := "" 295 + if record.Pronouns != nil { 296 + pronouns = *record.Pronouns 297 + } 298 + 294 299 location := "" 295 300 if record.Location != nil { 296 301 location = *record.Location ··· 330 325 Links: links, 331 326 Stats: stats, 332 327 PinnedRepos: pinned, 328 + Pronouns: pronouns, 333 329 } 334 330 335 331 ddb, ok := i.Db.Execer.(*db.DB)
+1
appview/models/profile.go
··· 19 19 Links [5]string 20 20 Stats [2]VanityStat 21 21 PinnedRepos [6]syntax.ATURI 22 + Pronouns string 22 23 } 23 24 24 25 func (p Profile) IsLinksEmpty() bool {
+11
appview/pages/templates/user/fragments/editBio.html
··· 20 20 </div> 21 21 22 22 <div class="flex flex-col gap-1"> 23 + <label class="m-0 p-0" for="pronouns">pronouns</label> 24 + <div class="flex items-center gap-2 w-full"> 25 + {{ $pronouns := "" }} 26 + {{ if and .Profile .Profile.Pronouns }} 27 + {{ $pronouns = .Profile.Pronouns }} 28 + {{ end }} 29 + <input type="text" class="py-1 px-1 w-full" name="pronouns" value="{{ $pronouns }}"> 30 + </div> 31 + </div> 32 + 33 + <div class="flex flex-col gap-1"> 23 34 <label class="m-0 p-0" for="location">location</label> 24 35 <div class="flex items-center gap-2 w-full"> 25 36 {{ $location := "" }}
+5
appview/pages/templates/user/fragments/profileCard.html
··· 12 12 class="text-lg font-bold dark:text-white overflow-hidden text-ellipsis whitespace-nowrap"> 13 13 {{ $userIdent }} 14 14 </p> 15 + {{ with .Profile }} 16 + {{ if .Pronouns }} 17 + <p class="text-gray-500 dark:text-gray-400">{{ .Pronouns }}</p> 18 + {{ end }} 19 + {{ end }} 15 20 <a href="/{{ $userIdent }}/feed.atom">{{ i "rss" "size-4" }}</a> 16 21 </div> 17 22
+2
appview/state/profile.go
··· 538 538 profile.Description = r.FormValue("description") 539 539 profile.IncludeBluesky = r.FormValue("includeBluesky") == "on" 540 540 profile.Location = r.FormValue("location") 541 + profile.Pronouns = r.FormValue("pronouns") 541 542 542 543 var links [5]string 543 544 for i := range 5 { ··· 653 652 Location: &profile.Location, 654 653 PinnedRepositories: pinnedRepoStrings, 655 654 Stats: vanityStats[:], 655 + Pronouns: &profile.Pronouns, 656 656 }}, 657 657 SwapRecord: cid, 658 658 })
+5
lexicons/actor/profile.json
··· 64 64 "type": "string", 65 65 "format": "at-uri" 66 66 } 67 + }, 68 + "pronouns": { 69 + "type": "string", 70 + "description": "Preferred gender pronouns.", 71 + "maxLength": 40 67 72 } 68 73 } 69 74 }