#118 Allow users to embed Medium posts with Liquid Tags#1161
#118 Allow users to embed Medium posts with Liquid Tags#1161benhalpern merged 2 commits intoforem:masterfrom
Conversation
app/labor/markdown_parser.rb
Outdated
| def whitelisted_image_host?(src) | ||
| # GitHub camo image won't parse but should be safe to host direct | ||
| src.start_with?("https://camo.githubusercontent.com/") | ||
| src.start_with?("https://camo.githubusercontent.com/") || src.start_with?("https://cdn-images-1.medium.com") |
There was a problem hiding this comment.
I doubt medium would like us hotlinking their cdn
|
ping @Zhao-Andy |
9866a68 to
e720bea
Compare
|
@Zhao-Andy can I get a review on this? (sorry it took so long too) |
|
Great job @edisonywh ! I have an odd question about the UI: shouldn't it be clear that the embed is from medium? Like this they look like regular dev.to posts, I guess I'm used to other embeds that visibly tell you where the content is coming from. Just a thought. |
|
@rhymes Ah good point, I just straight out copied from other css haha. Any tips on that? Don't want to break the design guideline |
|
@edisonywh I googled a bit and it seems like they removed support for embeddable medium posts sometime ago and in the terms of service they say:
So I guess you can't add a medium logo in there :-( Maybe a sort of subtitle/byline that says "from Medium.com" ? |
@rhymes I looked at their branding guideline post (posted in 2017), and upon downloading, the Looks like I can use the logo afterall? :) EDIT: Thoughts? |
| class MediumTag < LiquidTagBase | ||
| include ApplicationHelper | ||
| include ActionView::Helpers::TagHelper | ||
| include InlineSvg::ActionView::Helpers |
There was a problem hiding this comment.
Added this line for inline_svg to reuse the Medium icon that's already in codebase
|
Did you know adding |
|
@Link2Twenty I did not know that! Would that be the preferred way to do this? |
|
I tried to download the JSON format and it contains invalid chars at the beginning, I suppose it's related to CORS and the fact that Medium doesn't advertise the format anywhere. I'd stick to your version for the time being |
|
Yeah quick search says it's to prevent JSON hijacking? https://stackoverflow.com/questions/2669690/why-does-google-prepend-while1-to-their-json-responses |
|
@Zhao-Andy is there anything else I can do to move this forward? :) |
|
@edisonywh I think we'll want to adjust the design a bit more to make sure it really feels differentiated from DEV articles. Let me circle back w/ the team and get back to you. |
app/liquid_tags/medium_tag.rb
Outdated
| end | ||
| end | ||
|
|
||
| Liquid::Template.register_tag("medium", MediumTag) |
There was a problem hiding this comment.
@edisonywh will you remove this line for now? we're going to mess with the design a tiny bit but would like to merge what you have so far into the codebase.
There was a problem hiding this comment.
Sure thing! Will ping you again once I've done so
jessleenyc
left a comment
There was a problem hiding this comment.
left a comment above!
- Added new liquid tag - "{% medium https://medium.com}"
- Added a scraper - `MediumArticleRetrievalService` which crawls the
given Medium URL for informations needed for the liquid tag
b860536 to
a833f82
Compare
|
@jessleenyc updated and removed the register tag line. Feel free to ping me if there's anything else I can do to help! |
jessleenyc
left a comment
There was a problem hiding this comment.
lgtm!
we'll make some minor tweaks and then make it available soon!
* master: (83 commits) Update gitdocs (forem#2500) Condense 'ask me anything' to 'ama' (forem#2428) [ci skip] Add user_signed_in? to cache key for styles (forem#2498) Added troubleshooting for byebug without readline issue (forem#2481) Fix some frontend linting issues (forem#2495) [ci skip] Fix <br/> in footer. (forem#2491) Remove extra param and add message for prefill (forem#2487) Make Cards Change Dynamically and add Reader/Follower Charts (forem#2488) Temporarily comment out random (forem#2486) Add nav buttons to pwa desktop (forem#2484) Feature/filtered charts (forem#2482) Add caching for historical data (forem#2476) There are installation sections for other OSes now. (forem#2480) Add inbox guidelines to users (forem#2473) Release Open Inbox (forem#2468) Convert underscores in article slugs properly (forem#2472) Update framework defaults to match those in Rails 5.1 (forem#2309) Enable random order for specs (forem#2466) [ci skip] forem#118 Allow users to embed Medium posts with Liquid Tags (forem#1161) Allow API to return top articles (forem#2469) ... # Conflicts: # Envfile # app/models/user.rb # db/schema.rb

What type of PR is this? (check all applicable)
Description
MediumArticleRetrievalServicewhich crawls thegiven Medium URL for informations needed for the liquid tag
Right now my implementation takes a full link, but we can choose to use handle + article ID. Open to suggestion here.
Related Tickets & Documents
#118
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?