Closed
Description
Describe the solution you'd like
It would be nice to have a liquid tag to integrate reddit submissions
Describe alternatives you've considered
I haven't researched intensively but found that Reddit has an embedding mechanism (oEmbed ?)
Additional context
A maybe useful GH wiki page about Reddit embedding.
Activity
benhalpern commentedon Jan 14, 2019
This makes sense. I think we'd do it via the API and embed via plain old backend HTML. This is our preference when it's not rich content like CodePen, etc.
Link2Twenty commentedon Jan 15, 2019
If you take any post and put
.json
at the end of it you see the post details in json form.https://www.reddit.com/r/aww/comments/ag3s4b/ive_waited_28_years_to_finally_havr_my_first_pet/
becomes
https://www.reddit.com/r/aww/comments/ag3s4b/ive_waited_28_years_to_finally_havr_my_first_pet.json
the first item in the array is the original post the second is replies.
If we dig down like this
json[0].data.children[0].data
we get to the data we wantWhich should contain everything we need.
rhymes commentedon Jan 15, 2019
@Link2Twenty I did a couple of experiments:
In that example there's a picture of the pet, which is a separate attribute, is there a documented logic on where such picture should be put? As a human I can see the pet's image is the body of the post, but with a quick glance I can't find that info in the JSON.
In this case for example - https://www.reddit.com/r/IAmA/comments/afvl2w/im_scott_from_scotts_cheap_flights_my_profession.json - the post has a body which is contained in
selftext
- but what if you have both a body and images?I also tried to see if Reddit's own embedding system was an option. Under posts you can find a "share -> embed" which brings you to a page like this https://embed.redditmedia.com/widgets/embed?url=https://www.reddit.com/r/IAmA/comments/afvl2w/im_scott_from_scotts_cheap_flights_my_profession/ - unfortunately it requires to embed a JS so it's not an option.
So the solution, be it API or JSON, requires a little bit of "figuring out" what's the logic since direct embedding can't be easily set up.
Also, the body is in markdown and can be quite long which means that it needs to be processed even just for being shortened for the liquid tag preview
Link2Twenty commentedon Jan 15, 2019
I can see the pet's image is the body of the post
it's the URL, not the preview URL
"url": "https://i.redd.it/jpqodmc83ia21.jpg"
but what if you have both a body and images
You can't, the post can only be an image, a link or contain body text the platform doesn't let you mix and match.
it needs to be processed even just for being shortened for the liquid tag preview
I may be incorrect, but I think liquid tags in this manner only get the data once?
Link2Twenty commentedon Jan 25, 2019
So the information I think we'd need from the JSON can be found like so.
All the following have the base
json[0].data.children[0].data
For image post
author: Miaogua007
subreddit_name_prefixed: r/aww
created_utc: 1547549225.0
over_18: false
title: I've waited 28 years to finally havr my first pet. Everyone, meet Mycroft.
post_hint: image
permalink: /r/aww/comments/ag3s4b/ive_waited_28_years_to_finally_havr_my_first_pet/
url: https://i.redd.it/jpqodmc83ia21.jpg
For text/self post
author: scottkeyes
subreddit_name_prefixed: r/IAmA
created_utc: 1547470871
over_18: false
title: I'm Scott from Scott's Cheap Flights. My profession is finding cheap flights. Here to answer travel questions and help you find flights for the next 8 hours. AMA
post_hint: self
permalink: /r/IAmA/comments/afvl2w/im_scott_from_scotts_cheap_flights_my_profession/
selftext: I may have the world's best (...)
I'm not sure what other
post_hint
s are valid.The
over_18
attribute indicates NSFW, perhaps we should block them or just show the title?cesc1989 commentedon Oct 1, 2019
Hi @jessleenyc 👋
This issue looks very interesting and I'd like to tackle it. Could you provide or guide me how to start with liquid tags in devto?
I've read https://docs.dev.to/frontend/liquid-tags/ and took a look to some existing Liquid tags however I'd like to have a whole picture of the process of creating one.
3 remaining items