CartoDB / cartodb

Location Intelligence & Data Visualization tool
http://carto.com
BSD 3-Clause "New" or "Revised" License
2.75k stars 651 forks source link

[Kuviz] Metadata for social networks #15374

Open gonzaloriestra opened 4 years ago

gonzaloriestra commented 4 years ago

Add a default icon and metatags (title, description, image) to the Kuviz's HTML to improve the sharing experience in social networks

gonzaloriestra commented 4 years ago

@cmongut we need to define what to add as description and image.

cmongut commented 4 years ago

Are we saving a description in kuvizs? About the default image, we are working on it. Could we leave it prepare with a random picture to know it works and change it next week?

gonzaloriestra commented 4 years ago

The creation endpoint only receives the name, but I'm not sure if we are adding a description tag inside the HTML from CF (the name is already included as the title). @oleurud?

For example, this one has a title and an empty description: https://cartoframes.carto.com/kuviz/933d429c-a844-4c6b-8bc3-0d02e1737dbc

simon-contreras-deel commented 4 years ago

You can add the description using the Map description parameter

image

https://team.carto.com/u/simon-carto/kuviz/0a5dd049-b6f1-474b-82cc-2b3abb098e76

cmongut commented 4 years ago

Nice description @oleurud!

Let's use that field then :)

gonzaloriestra commented 4 years ago

One possible approach to include the metadata tags could be to modify the HTML after downloading it from S3. We could do it after calling add_cache_headers in both show and show_protected from kuviz/visualization_controller.rb with something like this:

def add_metadata_tags
  doc = Nokogiri::HTML::Document.parse(@source)
  head = doc.at('head')
  head << "<meta name=\"twitter:title\" content=\"patatin\">"
  @source = doc.to_html
end

We would need to add the same tags for Facebook (og) and Twitter that we use here: https://github.com/CartoDB/cartodb/blob/10b787af6f395c560df8e7be0d388f7bb41389ac/app/views/layouts/application_public_visualization_layout.html.erb

gonzaloriestra commented 4 years ago

After talking with @VictorVelarde, it seems it would make more sense to add these tags from the client (CARTOframes). So I'm moving this issue to the CF project.