improve og profile card (#9051)
This commit is contained in:
@@ -394,6 +394,7 @@ func (srv *Server) Shutdown() error {
|
|||||||
func (srv *Server) NewTemplateContext() pongo2.Context {
|
func (srv *Server) NewTemplateContext() pongo2.Context {
|
||||||
return pongo2.Context{
|
return pongo2.Context{
|
||||||
"staticCDNHost": srv.cfg.staticCDNHost,
|
"staticCDNHost": srv.cfg.staticCDNHost,
|
||||||
|
"favicon": fmt.Sprintf("%s/static/favicon.png", srv.cfg.staticCDNHost),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -599,13 +600,16 @@ func (srv *Server) WebProfile(c echo.Context) error {
|
|||||||
unauthedViewingOkay = false
|
unauthedViewingOkay = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !unauthedViewingOkay {
|
|
||||||
return c.Render(http.StatusOK, "profile.html", data)
|
|
||||||
}
|
|
||||||
req := c.Request()
|
req := c.Request()
|
||||||
data["profileView"] = pv
|
data["profileView"] = pv
|
||||||
data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
|
data["requestURI"] = fmt.Sprintf("https://%s%s", req.Host, req.URL.Path)
|
||||||
data["requestHost"] = req.Host
|
data["requestHost"] = req.Host
|
||||||
|
|
||||||
|
if !unauthedViewingOkay {
|
||||||
|
data["requiresAuth"] = true
|
||||||
|
}
|
||||||
|
|
||||||
return c.Render(http.StatusOK, "profile.html", data)
|
return c.Render(http.StatusOK, "profile.html", data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,7 @@
|
|||||||
<meta name="application-name" content="Bluesky">
|
<meta name="application-name" content="Bluesky">
|
||||||
<meta name="generator" content="bskyweb">
|
<meta name="generator" content="bskyweb">
|
||||||
<meta property="og:site_name" content="Bluesky Social">
|
<meta property="og:site_name" content="Bluesky Social">
|
||||||
|
<meta property="og:logo" content="{{ favicon }}">
|
||||||
<meta name="twitter:site" content="@bluesky" />
|
<meta name="twitter:site" content="@bluesky" />
|
||||||
<link type="application/activity+json" href="" />
|
<link type="application/activity+json" href="" />
|
||||||
|
|
||||||
|
|||||||
@@ -9,36 +9,48 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block html_head_extra -%}
|
{% block html_head_extra -%}
|
||||||
{%- if profileView -%}
|
|
||||||
<meta property="og:site_name" content="Bluesky Social">
|
<meta property="og:site_name" content="Bluesky Social">
|
||||||
<meta property="og:type" content="profile">
|
<meta property="og:type" content="profile">
|
||||||
<meta property="profile:username" content="{{ profileView.Handle }}">
|
{%- if requestURI %}
|
||||||
{%- if requestURI %}
|
|
||||||
<meta property="og:url" content="{{ requestURI }}">
|
<meta property="og:url" content="{{ requestURI }}">
|
||||||
<link rel="canonical" href="{{ requestURI|canonicalize_url }}" />
|
<link rel="canonical" href="{{ requestURI|canonicalize_url }}" />
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
|
|
||||||
|
{%- if profileView -%}
|
||||||
|
<meta property="profile:username" content="{{ profileView.Handle }}">
|
||||||
{%- if profileView.DisplayName %}
|
{%- if profileView.DisplayName %}
|
||||||
<meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})">
|
<meta property="og:title" content="{{ profileView.DisplayName }} (@{{ profileView.Handle }})">
|
||||||
{% else %}
|
{% else %}
|
||||||
<meta property="og:title" content="{{ profileView.Handle }}">
|
<meta property="og:title" content="{{ profileView.Handle }}">
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{%- if profileView.Description %}
|
|
||||||
<meta name="description" content="{{ profileView.Description }}">
|
<link rel="alternate" href="at://{{ profileView.Did }}/app.bsky.actor.profile/self" />
|
||||||
<meta property="og:description" content="{{ profileView.Description }}">
|
|
||||||
{% endif -%}
|
|
||||||
{%- if profileView.Banner %}
|
|
||||||
<meta property="og:image" content="{{ profileView.Banner }}">
|
|
||||||
<meta name="twitter:card" content="summary_large_image">
|
|
||||||
{%- elif profileView.Avatar -%}
|
|
||||||
{# Don't use avatar image in cards; usually looks bad #}
|
|
||||||
<meta name="twitter:card" content="summary">
|
|
||||||
{% endif %}
|
|
||||||
<meta name="twitter:label1" content="Account DID">
|
<meta name="twitter:label1" content="Account DID">
|
||||||
<meta name="twitter:value1" content="{{ profileView.Did }}">
|
<meta name="twitter:value1" content="{{ profileView.Did }}">
|
||||||
|
|
||||||
{%- if requestHost %}
|
{%- if requestHost %}
|
||||||
<link rel="alternate" type="application/rss+xml" href="https://{{ requestHost }}/profile/{{ profileView.Did }}/rss">
|
<link rel="alternate" type="application/rss+xml" href="https://{{ requestHost }}/profile/{{ profileView.Did }}/rss">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<link rel="alternate" href="at://{{ profileView.Did }}/app.bsky.actor.profile/self" />
|
|
||||||
|
{# Only show details if auth isn't required #}
|
||||||
|
{% if not requiresAuth %}
|
||||||
|
{%- if profileView.Description %}
|
||||||
|
<meta name="description" content="{{ profileView.Description }}">
|
||||||
|
<meta property="og:description" content="{{ profileView.Description }}">
|
||||||
|
{% endif -%}
|
||||||
|
{%- if profileView.Banner %}
|
||||||
|
<meta property="og:image" content="{{ profileView.Banner }}">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
{%- elif profileView.Avatar -%}
|
||||||
|
{# Don't use avatar image in cards; usually looks bad #}
|
||||||
|
<meta name="twitter:card" content="summary">
|
||||||
|
{% endif %}
|
||||||
|
{% else %}
|
||||||
|
<meta name="description" content="This profile requires authentication to view.">
|
||||||
|
<meta property="og:description" content="This profile requires authentication to view.">
|
||||||
|
<meta property="twitter:description" content="This profile requires authentication to view.">
|
||||||
|
{% endif %}
|
||||||
{% endif -%}
|
{% endif -%}
|
||||||
{%- endblock %}
|
{%- endblock %}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user