-
-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display timestamp in link embed (dynamic OpenGraph tags) #59
Comments
Hello, thanks for the suggestion, this is a great idea! I'll look into it. 👍 |
This will require SSR to deliver a dynamic OpenGraph tag, so the project will no longer be a static site but will include a server (which is fine by me). Update: This actually doesn't require SSR, but it does require a server to modify the delivered html file to include the dynamic tag. I guess that's a form of SSR, but it does not involve rendering Svelte's output (this could be done, but it's not really necessary since we aren't making any API calls) |
Cool! Im running a small discord server,bit will be able to embed there?
Perfect! |
This will not require you to do anything on your end, assuming you want to continue using my site (at pixelatomy.com/snow-stamp). I just need to write an SSR version of Snow-Stamp and run a server for it instead of static hosting. |
Perfect! |
One issue I did not foresee is that the embed would have to display the timestamp for a specific time zone. I considered just using UTC, and/or only showing the date without a time, since usually people use Snow-Stamp just to check the age of accounts or servers and don't need the exact time. But I think there's a better solution:
|
I'm sorry i'm on IT but not on coding :D |
I'm just documenting my thoughts and process, don't worry! I appreciate your input though. Including a parameter in the URL seems like the best solution. On a related note, I'm trying to structure this in a way so that Snow-Stamp can continue to be hosted statically for anyone who wants that. |
let's do this! 👍 |
I made good progress today. The server works and is able to deliver a modified index.html containing the dynamic embed tag. Incoming wall of text: Time zonesWorking with time zones in JS is a real pain. I'm using the Day.js library on the server to display a timestamp in the specified time zone. It shouldn't be necessary to import this on the web side, which is good because I want to keep the bundle size low. Currently, the time zone is added to the URL by its TZ database name (e.g. There's also the issue of locale. The locale handles how time and date are formatted, such as Year/Month/Day ordering and 12/24 hour clocks. Snow-Stamp currently displays timestamps in the user's locale format automatically. I need to be able to tell the server to format the timestamp in the same locale. That means adding the locale to the URL too, unless it could be inferred from the time zone. I may end up creating a custom list of shortened time zone names so that Another option?I could potentially avoid all of this trouble by encoding the pre-formatted timestamp right into the URL. That way the user's browser can tell the server exactly how the timestamp should look in the embed. The only issue is I don't want to generate really long URLs. I could determine locale formatting in the browser and store it as a number with bitwise operations (I really only need YMD ordering and 12/24hr), and for the time zone name I could create a lookup table with as many names as possible that can then be converted to a single number. That number can be bit shifted into the locale format number and the result is a single URL parameter (in addition to the snowflake itself). I think this is the better option overall. That reminds me, I could compress the snowflake too, by using |
ok i read everything, thanks for heads up, i didnt understand quite everything but i assume this is kinda diary for you. |
I've abandoned the strategy of parsing YMD order and 12/24 hour formats because even if I could get that to work, I'd still need to apply it to a timestamp with the correct time zone. There are just too many unknowns involved. So what I have now is a copy of the output locale string with a shortened time zone name appended.
The URL is longer than I'd like. For the above, the timestamp string is I'm working on a compression algorithm that should significantly reduce the string length by taking advantage of the limited expected character set of a timestamp (e.g. |
I know this is silly but I'm starting to reconsider using Day.js again. It only adds about 6kb to the bundle size and it could ensure consistent formatting across web/server with a much smaller footprint in the URL. Update: The first problem is that Day.js only includes the However, I am okay with this less-reliable locale detection for the embed itself, and I can load all locales on the server with no problem. I came across someone's useful code for detecting browser locale and loading the corresponding Day.js locale. For time zone, we have I should include some fallback behavior on both the web and server. If the web fails to detect a language, it won't be in the URL and the server will assume |
After being held up for hours by a very annoying bug in Day.js, I've got this to a point where I am almost ready to merge to main. I am strongly considering getting some tests written, because I now have many testable, pure functions that could use some thorough breaking in (and to protect against regression, of course). The only tough thing is that some of the functions depend on browser or environment values that I don't know how to recreate (because I don't know all the possibilities). I think this is okay though - I've designed the app so that the output of these functions should not break anything, but rather be ignored in favor of fallback values. Another thing I should do (but I'm too lazy to do it now) is get more of my shared variables into the svelte store. I'm doing dumb things to get them to work across components. I also have to make sure I know how to set up the server on my VPS, with nginx and whatnot. Finally, I need to put in some due diligence and find people across the world to help me test this. I don't want to be blind-sided by time zone or locale issues. I should probably create a pull request with a checklist for these things. |
👍 |
@vegeta897 so how is it going? i cant wait anymore! xD |
Changes merged, stand by for deployment... 🎉 Deployed! https://pixelatomy.com/snow-stamp |
Hello,
As title says,
Whenever i copy the link generated by pasting message id, users have to open their browser to check it
Im asking if its possible for the link to instant timestamp embedded in discord channel
Thanks in advance
The text was updated successfully, but these errors were encountered: