Social embeds with oEmbed and Open Graph - #643
Conversation
|
May be a stupid question, but I have never changed something server side wise. So how could I implement it, after changing the files? Thanks for your help! |
Post logs and check this https://github.com/rr-/szurubooru/wiki/Common-errors |
|
Well doesn't seem to be a permission issue. When I remove the embed merge and rebuild everything works again. Sorry here's the |
|
I took another stab at this but continue to get this error:
I tried hardcoding the directory (/var/www/index.htm), but even that gets the same error which is confusing because I run:
...and I confirm the index file is there. I assume it has something to do with the fact I am running inside a docker but not sure what's up. Pretty desperate to get some proper SEO built into my instance so if anyone has an idea how to get this working inside a docker I'd love to hear it. |
|
I believe this setup can't work for docker based deployments, because the index.htm file lives inside the client container and the server container wants to read it. I am not sure what the best solution to this would be. |
|
Should now work in Docker. |
|
my site is like booru.domain.com @rest.routes.get("/index(?P<path>/.+)")
def post_index(ctx: rest.Context, params: Dict[str, str]) -> rest.Response:
path = _index_path(params)
if not index_html:
logging.info("Embed was requested but index.htm file does not exist. Redirecting to 404.")
return {"return_type": "custom", "status_code": "404", "content": [("content-type", "text/html")]}
try:
oembed = get_post(ctx, {}, path)
except posts.PostNotFoundError:
return {"return_type": "custom", "status_code": "404", "content": index_html}
url = config.config["site_url"] + path
new_html = index_html.replace("</head>", f'''
<meta property="og:site_name" content="{config.config["name"]}">
<meta property="og:url" content="{html.escape(url).replace("//","/")}">
<meta property="og:type" content="article">
<meta property="og:title" content="{html.escape(oembed['title'])}">
<meta name="twitter:title" content="{html.escape(oembed['title'])}">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="{html.escape(oembed['url']).replace("//","/")}">
<meta property="og:image:url" content="{html.escape(oembed['url']).replace("//","/")}">
<meta property="og:image:width" content="{oembed['width']}">
<meta property="og:image:height" content="{oembed['height']}">
<meta property="article:author" content="{html.escape(oembed['author_name'] or '')}">
<link rel="alternate" type="application/json+oembed" href="{config.config["site_url"]}/api/oembed?url={quote(html.escape(url))}" title="{html.escape(config.config["name"])}"></head>
''').replace("<html>", '<html prefix="og: http://ogp.me/ns#">').replace("<title>Loading...</title>", f"<title>{html.escape(oembed['title'])}</title>").replace("//","/")
return {"return_type": "custom", "content": new_html}just replaced them with single slashes in embed_api.py to fix also for the nginx used instead |
|
You need to set |


Differences with the approaches in #421, #422 and #441:
nameattribute instead ofproperty)Things that can be improved later:
Meant to be used with an nginx config like:
Discord


Twitter
Closes #416