MemosViewer.php script to add link preview and no-js viewing #3721
andrigamerita
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The other day, I needed a really fast solution to make a memo readable from its URL in user agents where the JavaScript webapp won't work, such as very old browsers, search engines, and social media previews, as well as faster loading for just reading on bad Internet. What I came up with is a PHP script that uses the REST API (and bruteforces the protobuf API where necessary, since apparently the REST API is still broken) to get data from the server, and injects it into the base HTML that is served at any request. 😀
Haven't tested if it works on v0.22.3, I'm still on v0.22.2 waiting for the next bugfix release, but if there are no breaking changes in the API it will work. I've put the script for download here: https://gitlab.com/octospacc/Snippets/-/blob/main/MemosViewer.php, and more information for those who want it (including nginx setup) is on a memo on my instance: https://memos.octt.eu.org/m/8edpaJ4n4gtdbSZVDcBve3 (maybe disable JavaScript to see for yourself how it works). You will see it's really basic and the rendered content isn't 1:1 to the Memos webapp, but for me it's just what I needed, a simple HTML fallback.
I made the code MIT so that it's perfectly compatible with Memos, feel free to use it however you please!
If this concept was to be integrated within Memos itself it would be a lot better (for the benefits I outlined above, and also accessibility which for me isn't a requirement but for others is), but unfortunately I'm not well versed in Go and can't even spin up the development environment, I will leave it to someone else...
Finally, screenshots of the no-JS HTML view in various browsers, and how a link with both an image or without appears when shared on Telegram:
Beta Was this translation helpful? Give feedback.
All reactions