Skip to content
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

Created rich_link_controller and functionalities #227

Merged
merged 21 commits into from
May 31, 2022
Merged

Conversation

MatheusBuss
Copy link
Contributor

@MatheusBuss MatheusBuss commented May 8, 2022

What issue does this PR close

Closes #182

Changes Proposed (a list of new changes introduced by this PR)

Add rich link/preview when Cambiatus andand associated links are shared in different social medias

How to test ( a list of instructions on how to test this PR)

  1. Run mix phx.server
  2. Send HTTP request for differente funcionalities
    2.1. For User sharing send GET request to /api/rich_link/profile/#{user_name}
    2.2. For Product sharing send GET request to /api/rich_link/shop?id=#{product_id}
    2.3. For Community sharing send GET request to /api/rich_link (Use the host header in the HTTP request for the appropriate community)
  3. Check html info sent by the server

Example of sharing html generated by these changes through Whatsapp:

image

@MatheusBuss MatheusBuss requested a review from lucca65 May 9, 2022 15:24
@MatheusBuss
Copy link
Contributor Author

The Elixir part should be working now. Sharing the HTML generated by the phoenix server worked on WhatsApp, Slack and Facebook. Twitter was not yet tested.

Some of the next steps that I have discussed with @NeoVier:
1 - Use NGINX to redirect the GET request from social media web crawlers based on their user agents (we can look into this list https://developers.whatismybrowser.com/useragents/explore/software_name/)
2 - Check if all the fields are beign filled correctly according to the Open Graph Protocol (https://ogp.me/)

Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bro, when the bio has markdown we don't render it properly, like you can see on https://api.staging.cambiatus.io/api/rich_link/profile/lucca (I've published it to staging).

lib/cambiatus_web/router.ex Show resolved Hide resolved
@MatheusBuss
Copy link
Contributor Author

MatheusBuss commented May 10, 2022

bro, when the bio has markdown we don't render it properly, like you can see on https://api.staging.cambiatus.io/api/rich_link/profile/lucca (I've published it to staging).

Using pandex I was able to convert markdown to plain text, so it shouldn't be a problem then. But this alternative requires the installation of pandex itself and Pandoc.

I've tried approaching it using Earmark (which is already on mix.exs), but it only converts into HTML os AST as far as I can tell. Therefore we would need to convert that result into plain text afterwards.

So I believe we should try to use pandex going forward

@lucca65
Copy link
Member

lucca65 commented May 10, 2022

Ok @MatheusBuss! Np for pandoc

Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also tests? 😬 🔧

lib/cambiatus_web/controllers/rich_link_controller.ex Outdated Show resolved Hide resolved
@MatheusBuss
Copy link
Contributor Author

Still to do:

  • Use Phoenix's views to render the template
  • Implement NGINX redirect
  • Rewrite some template fields to properly comply to the Open Graph Protocol

Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its getting better and better bro! Keep it up!

@lucca65
Copy link
Member

lucca65 commented May 13, 2022

a URL precisa ser pra tela do perfil, ao invés do email

@MatheusBuss MatheusBuss requested a review from lucca65 May 20, 2022 16:37
Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the long time to work on the review @MatheusBuss

README.md Outdated Show resolved Hide resolved
lib/cambiatus_web/controllers/rich_link_controller.ex Outdated Show resolved Hide resolved
lib/cambiatus_web/views/rich_link_view.ex Outdated Show resolved Hide resolved
nginx/nginx.conf Outdated Show resolved Hide resolved
@MatheusBuss MatheusBuss requested a review from lucca65 May 24, 2022 14:34
Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the instructions. Just followed it now and tested on telegram.

here is the result for this URL: https://api.staging.cambiatus.io/api/rich_link/profile/lucca
Captura de Tela 2022-05-24 às 11 54 28

I'm missing the photo and we also have a tag that was not rendered correctly.

Also its rendering some sort of lorem ipsum, even if my profile don't have it:

Captura de Tela 2022-05-24 às 11 57 46

@MatheusBuss
Copy link
Contributor Author

Also its rendering some sort of lorem ipsum, even if my profile don't have it

That's odd. I tested on Telegram and had the same result, but on WhatsApp it renders correctly (other than the underline tag and the image)
image

Even checking the html on the page it doesn't have any lorem ipsum in it. Don't know why it shows on Telegram, maybe it's cached from previous tests?

I liked the instructions. Just followed it now and tested on telegram.

We should try to use an URL withouth the /api/rich_link to test if nginx is redirecting correctly the crawlers (something like https://buss.staging.cambiatus.io/profile/mattheusbuss). I even tried with this link, but it didn't work.

@MatheusBuss
Copy link
Contributor Author

Don't know why it shows on Telegram, maybe it's cached from previous tests?

Exactly this. I found @webpagebot on this thread . It clears the cache on telegram. Now the description is updated!

image

@lucca65
Copy link
Member

lucca65 commented May 25, 2022

Great bro this is awesome! Can we also preview the profile image when sharing profile links?

@MatheusBuss
Copy link
Contributor Author

MatheusBuss commented May 25, 2022

I was looking into it, and the html does include the image link, but it isn't loading. I tried downloading based on the link and noticed that the file doesn't have the extension (.jpeg or .png) so it could be that.
Another reason might be the image size. Facebook limits the image size to 8MB (per the developer page) but I remember reading some recommendations to limit the size to 30 kB, but I will have to double check on that.

@lucca65
Copy link
Member

lucca65 commented May 26, 2022

I see bro, in this case can you open a new issue for us to transform images on this link? This way we can tackle this in a part two

@MatheusBuss
Copy link
Contributor Author

I see bro, in this case can you open a new issue for us to transform images on this link? This way we can tackle this in a part two

Created cambiatus/lambda-functions#2

Copy link
Member

@lucca65 lucca65 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! congrats bro!

Copy link
Member

@henriquecbuss henriquecbuss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💰 🔗

🎉

@MatheusBuss MatheusBuss merged commit 03b4093 into master May 31, 2022
@MatheusBuss MatheusBuss deleted the feature/rich_link branch May 31, 2022 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add rich link preview to the shop
3 participants