An ATproto social media client -- with an independent Appview.

improve og profile card (#9051)

authored by

hailey and committed by
GitHub
cbcce8c9 2c6752f2

+36 -19
+7 -3
bskyweb/cmd/bskyweb/server.go
··· 394 394 func (srv *Server) NewTemplateContext() pongo2.Context { 395 395 return pongo2.Context{ 396 396 "staticCDNHost": srv.cfg.staticCDNHost, 397 + "favicon": fmt.Sprintf("%s/static/favicon.png", srv.cfg.staticCDNHost), 397 398 } 398 399 } 399 400 ··· 599 600 unauthedViewingOkay = false 600 601 } 601 602 } 602 - if !unauthedViewingOkay { 603 - return c.Render(http.StatusOK, "profile.html", data) 604 - } 603 + 605 604 req := c.Request() 606 605 data["profileView"] = pv 607 606 data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path) 608 607 data["requestHost"] = req.Host 608 + 609 + if !unauthedViewingOkay { 610 + data["requiresAuth"] = true 611 + } 612 + 609 613 return c.Render(http.StatusOK, "profile.html", data) 610 614 } 611 615
+1
bskyweb/templates/base.html
··· 95 95 <meta name="application-name" content="Bluesky"> 96 96 <meta name="generator" content="bskyweb"> 97 97 <meta property="og:site_name" content="Bluesky Social"> 98 + <meta property="og:logo" content="{{ favicon }}"> 98 99 <meta name="twitter:site" content="@bluesky" /> 99 100 <link type="application/activity+json" href="" /> 100 101
+28 -16
bskyweb/templates/profile.html
··· 9 9 {% endblock %} 10 10 11 11 {% block html_head_extra -%} 12 - {%- if profileView -%} 13 12 <meta property="og:site_name" content="Bluesky Social"> 14 13 <meta property="og:type" content="profile"> 15 - <meta property="profile:username" content="{{ profileView.Handle }}"> 16 - {%- if requestURI %} 14 + {%- if requestURI %} 17 15 <meta property="og:url" content="{{ requestURI }}"> 18 16 <link rel="canonical" href="{{ requestURI|canonicalize_url }}" /> 19 - {% endif -%} 17 + {% endif -%} 18 + 19 + {%- if profileView -%} 20 + <meta property="profile:username" content="{{ profileView.Handle }}"> 20 21 {%- if profileView.DisplayName %} 21 22 <meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})"> 22 23 {% else %} 23 24 <meta property="og:title" content="{{ profileView.Handle }}"> 24 25 {% endif -%} 25 - {%- if profileView.Description %} 26 - <meta name="description" content="{{ profileView.Description }}"> 27 - <meta property="og:description" content="{{ profileView.Description }}"> 28 - {% endif -%} 29 - {%- if profileView.Banner %} 30 - <meta property="og:image" content="{{ profileView.Banner }}"> 31 - <meta name="twitter:card" content="summary_large_image"> 32 - {%- elif profileView.Avatar -%} 33 - {# Don't use avatar image in cards; usually looks bad #} 34 - <meta name="twitter:card" content="summary"> 35 - {% endif %} 26 + 27 + <link rel="alternate" href="at://{{ profileView.Did }}/app.bsky.actor.profile/self" /> 28 + 36 29 <meta name="twitter:label1" content="Account DID"> 37 30 <meta name="twitter:value1" content="{{ profileView.Did }}"> 31 + 38 32 {%- if requestHost %} 39 33 <link rel="alternate" type="application/rss+xml" href="https://{{ requestHost }}/profile/{{ profileView.Did }}/rss"> 40 34 {% endif %} 41 - <link rel="alternate" href="at://{{ profileView.Did }}/app.bsky.actor.profile/self" /> 35 + 36 + {# Only show details if auth isn't required #} 37 + {% if not requiresAuth %} 38 + {%- if profileView.Description %} 39 + <meta name="description" content="{{ profileView.Description }}"> 40 + <meta property="og:description" content="{{ profileView.Description }}"> 41 + {% endif -%} 42 + {%- if profileView.Banner %} 43 + <meta property="og:image" content="{{ profileView.Banner }}"> 44 + <meta name="twitter:card" content="summary_large_image"> 45 + {%- elif profileView.Avatar -%} 46 + {# Don't use avatar image in cards; usually looks bad #} 47 + <meta name="twitter:card" content="summary"> 48 + {% endif %} 49 + {% else %} 50 + <meta name="description" content="This profile requires authentication to view."> 51 + <meta property="og:description" content="This profile requires authentication to view."> 52 + <meta property="twitter:description" content="This profile requires authentication to view."> 53 + {% endif %} 42 54 {% endif -%} 43 55 {%- endblock %} 44 56